From 021cf1359db2f7bf08c96770c92cc92ae791b71f Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Sat, 19 Jul 2014 23:33:19 -0400 Subject: [PATCH] Quick NPE fix --- .../minimalbible/activity/downloader/BookItemHolder.java | 2 +- .../bspeice/minimalbible/activity/viewer/BibleViewer.java | 2 +- .../bspeice/minimalbible/activity/viewer/BookFragment.java | 7 ++----- app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/BookItemHolder.java b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/BookItemHolder.java index c2edd6f..2ac34f5 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/BookItemHolder.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/BookItemHolder.java @@ -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 { diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BibleViewer.java b/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BibleViewer.java index 924b5bc..ecfac10 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BibleViewer.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BibleViewer.java @@ -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(); diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BookFragment.java b/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BookFragment.java index 571b7a5..a413b0c 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BookFragment.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BookFragment.java @@ -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); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 480439a..e13a246 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -11,4 +11,6 @@ Settings Downloads + Could not remove book. Try restarting application? +