fixed 2 crashes in details screen

This commit is contained in:
danijoo
2015-11-05 18:24:15 +01:00
parent 3798aabc3c
commit b58e8a815c
2 changed files with 12 additions and 6 deletions

View File

@@ -4,4 +4,6 @@
* Changed about fragment appearance * Changed about fragment appearance
* Fixed NPE when rotating device in BookDetail fragment by retaining it * Fixed NPE when rotating device in BookDetail fragment by retaining it
* Fixed crash if a book has no author * Fixed crash if a book has no author when adding a book
* Fixed crash in details view when book has no author
* Fixed crash on configuration change in details screen (caused by ActionProvider)

View File

@@ -97,11 +97,13 @@ public class BookDetail extends Fragment implements LoaderManager.LoaderCallback
bookTitle = data.getString(data.getColumnIndex(AlexandriaContract.BookEntry.TITLE)); bookTitle = data.getString(data.getColumnIndex(AlexandriaContract.BookEntry.TITLE));
((TextView) rootView.findViewById(R.id.fullBookTitle)).setText(bookTitle); ((TextView) rootView.findViewById(R.id.fullBookTitle)).setText(bookTitle);
if(shareActionProvider != null) {
Intent shareIntent = new Intent(Intent.ACTION_SEND); Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
shareIntent.setType("text/plain"); shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_text) + bookTitle); shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_text) + bookTitle);
shareActionProvider.setShareIntent(shareIntent); shareActionProvider.setShareIntent(shareIntent);
}
String bookSubTitle = data.getString(data.getColumnIndex(AlexandriaContract.BookEntry.SUBTITLE)); String bookSubTitle = data.getString(data.getColumnIndex(AlexandriaContract.BookEntry.SUBTITLE));
((TextView) rootView.findViewById(R.id.fullBookSubTitle)).setText(bookSubTitle); ((TextView) rootView.findViewById(R.id.fullBookSubTitle)).setText(bookSubTitle);
@@ -110,6 +112,8 @@ public class BookDetail extends Fragment implements LoaderManager.LoaderCallback
((TextView) rootView.findViewById(R.id.fullBookDesc)).setText(desc); ((TextView) rootView.findViewById(R.id.fullBookDesc)).setText(desc);
String authors = data.getString(data.getColumnIndex(AlexandriaContract.AuthorEntry.AUTHOR)); String authors = data.getString(data.getColumnIndex(AlexandriaContract.AuthorEntry.AUTHOR));
if(authors == null)
authors = "";
String[] authorsArr = authors.split(","); String[] authorsArr = authors.split(",");
((TextView) rootView.findViewById(R.id.authors)).setLines(authorsArr.length); ((TextView) rootView.findViewById(R.id.authors)).setLines(authorsArr.length);
((TextView) rootView.findViewById(R.id.authors)).setText(authors.replace(",","\n")); ((TextView) rootView.findViewById(R.id.authors)).setText(authors.replace(",","\n"));