Quick NPE fix

This commit is contained in:
Bradlee Speice 2014-07-19 23:33:19 -04:00
parent d685beaae6
commit 021cf1359d
4 changed files with 6 additions and 7 deletions

View File

@ -99,7 +99,7 @@ public class BookItemHolder {
if (didRemove) {
isDownloaded.setImageResource(R.drawable.ic_action_download);
} else {
Toast.makeText(ctx, "Unable to remove book, might need to restart the application."
Toast.makeText(ctx, ctx.getText(R.string.book_removal_failure)
, Toast.LENGTH_SHORT).show();
}
} else {

View File

@ -149,7 +149,7 @@ public class BibleViewer extends BaseActivity implements
Log.d("BibleViewer", "Initializing main book: " + b.getName());
Log.d("MainThread?", Boolean.toString(Looper.myLooper() == Looper.getMainLooper()));
FragmentManager fragmentManager = getSupportFragmentManager();
Fragment f = BookFragment.newInstance(b.getName(), this);
Fragment f = BookFragment.newInstance(b.getName());
fragmentManager.beginTransaction()
.replace(R.id.container, f)
.commit();

View File

@ -30,8 +30,6 @@ import static org.crosswire.jsword.versification.system.Versifications.instance;
* A placeholder fragment containing a simple view.
*/
public class BookFragment extends BaseFragment {
Injector i;
@Inject @Named("MainBook") Book mBook;
@InjectView(R.id.book_content)
@ -42,9 +40,8 @@ public class BookFragment extends BaseFragment {
/**
* Returns a new instance of this fragment for the given section number.
*/
public static BookFragment newInstance(String bookName, Injector injector) {
public static BookFragment newInstance(String bookName) {
BookFragment fragment = new BookFragment();
fragment.i = injector;
Bundle args = new Bundle();
args.putString(ARG_BOOK_NAME, bookName);
fragment.setArguments(args);
@ -65,7 +62,7 @@ public class BookFragment extends BaseFragment {
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_viewer_main, container,
false);
i.inject(this);
((Injector)getActivity()).inject(this);
ButterKnife.inject(this, rootView);
mainContent.getSettings().setJavaScriptEnabled(true);

View File

@ -11,4 +11,6 @@
<string name="action_settings">Settings</string>
<string name="activity_downloader">Downloads</string>
<string name="book_removal_failure">Could not remove book. Try restarting application?</string>
</resources>