From 04fe4d13b47a3f80aa4bcd5d5d1efe0fe88aec5a Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Sat, 14 Jun 2014 15:13:44 -0400 Subject: [PATCH] Add lots of Lint fixes --- .../minimalbible/activities/BaseFragment.java | 2 +- .../downloader/ActivityDownloaderModule.java | 1 - .../activities/downloader/BookItemHolder.java | 8 ++++---- .../activities/downloader/BookListAdapter.java | 4 ++-- .../activities/downloader/BookListFragment.java | 13 ++----------- .../activities/downloader/DownloadActivity.java | 11 +++++------ .../downloader/manager/BookDownloadManager.java | 6 +++--- .../downloader/manager/BookDownloadThread.java | 1 - .../downloader/manager/DLProgressEvent.java | 4 ++-- .../downloader/manager/RefreshManager.java | 5 ----- .../minimalbible/test/DownloadActivityTest.java | 16 ++-------------- 11 files changed, 21 insertions(+), 50 deletions(-) diff --git a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/BaseFragment.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/BaseFragment.java index 85f341d..5b39dca 100644 --- a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/BaseFragment.java +++ b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/BaseFragment.java @@ -17,7 +17,7 @@ public class BaseFragment extends Fragment { * @param context The {@link android.app.Activity} we are displaying in * @param view The {@link android.view.View} we need to calculate the offset for. */ - public static void setInsets(Activity context, View view) { + protected static void setInsets(Activity context, View view) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return; SystemBarTintManager tintManager = new SystemBarTintManager(context); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); diff --git a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/ActivityDownloaderModule.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/ActivityDownloaderModule.java index 0ad6799..70ae79e 100644 --- a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/ActivityDownloaderModule.java +++ b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/ActivityDownloaderModule.java @@ -3,7 +3,6 @@ package org.bspeice.minimalbible.activities.downloader; import org.bspeice.minimalbible.MinimalBible; import org.bspeice.minimalbible.activities.downloader.manager.BookDownloadManager; import org.bspeice.minimalbible.activities.downloader.manager.BookDownloadThread; -import org.bspeice.minimalbible.activities.downloader.manager.InstalledManager; import org.bspeice.minimalbible.activities.downloader.manager.RefreshManager; import dagger.Module; diff --git a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookItemHolder.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookItemHolder.java index c5e4b8b..5b5a469 100644 --- a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookItemHolder.java +++ b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookItemHolder.java @@ -38,8 +38,8 @@ public class BookItemHolder { @Inject BookDownloadManager bookDownloadManager; @Inject InstalledManager installedManager; - Book b; - Subscription subscription; + private final Book b; + private Subscription subscription; public BookItemHolder(View v, Book b) { ButterKnife.inject(this, v); @@ -59,8 +59,8 @@ public class BookItemHolder { //TODO: Refactor subscription = bookDownloadManager.getDownloadEvents() .observeOn(AndroidSchedulers.mainThread()) - .filter((event) -> event.getB().getInitials() == b.getInitials()) - .subscribe((event) -> displayProgress((int)event.toCircular())); + .filter((event) -> event.getB().getInitials().equals(b.getInitials())) + .subscribe((event) -> displayProgress((int) event.toCircular())); } private void displayInstalled() { diff --git a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java index 3f0a619..aac8f73 100644 --- a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java +++ b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java @@ -15,9 +15,9 @@ import java.util.List; * Adapter to inflate list_download_items.xml */ public class BookListAdapter extends BaseAdapter implements AbsListView.RecyclerListener { - private List bookList; + private final List bookList; - private LayoutInflater inflater; + private final LayoutInflater inflater; public BookListAdapter(LayoutInflater inflater, List bookList) { this.bookList = bookList; diff --git a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookListFragment.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookListFragment.java index 90d01cd..846fdac 100644 --- a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookListFragment.java +++ b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookListFragment.java @@ -5,8 +5,6 @@ import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.DialogInterface; import android.os.Bundle; -import android.os.Looper; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -17,15 +15,8 @@ import org.bspeice.minimalbible.MinimalBible; import org.bspeice.minimalbible.R; import org.bspeice.minimalbible.activities.BaseFragment; import org.bspeice.minimalbible.activities.downloader.manager.RefreshManager; -import org.crosswire.jsword.book.Book; import org.crosswire.jsword.book.BookCategory; import org.crosswire.jsword.book.BookComparators; -import org.crosswire.jsword.book.BookFilter; -import org.crosswire.jsword.book.FilterUtil; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; import javax.inject.Inject; @@ -96,7 +87,7 @@ public class BookListFragment extends BaseFragment { * Trigger the functionality to display a list of modules. Prompts user if downloading * from the internet is allowable. */ - public void displayModules() { + private void displayModules() { boolean dialogDisplayed = downloadPrefs.hasShownDownloadDialog(); if (!dialogDisplayed) { @@ -131,7 +122,7 @@ public class BookListFragment extends BaseFragment { // First flatten the Map to its lists .flatMap((books) -> Observable.from(books.values())) // Then flatten the lists - .flatMap((books) -> Observable.from(books)) + .flatMap(Observable::from) .filter((book) -> book.getBookCategory() == BookCategory.fromString(getArguments().getString(ARG_BOOK_CATEGORY))) // Repack all the books diff --git a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/DownloadActivity.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/DownloadActivity.java index 8041a57..423199d 100644 --- a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/DownloadActivity.java +++ b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/DownloadActivity.java @@ -1,18 +1,17 @@ package org.bspeice.minimalbible.activities.downloader; -import org.bspeice.minimalbible.R; -import org.bspeice.minimalbible.activities.BaseActivity; -import org.bspeice.minimalbible.activities.BaseNavigationDrawerFragment; -import org.bspeice.minimalbible.activities.downloader.manager.DownloadManager; - import android.os.Bundle; -import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBar; import android.view.Menu; import android.view.MenuItem; +import org.bspeice.minimalbible.R; +import org.bspeice.minimalbible.activities.BaseActivity; +import org.bspeice.minimalbible.activities.BaseNavigationDrawerFragment; +import org.bspeice.minimalbible.activities.downloader.manager.DownloadManager; + public class DownloadActivity extends BaseActivity implements BaseNavigationDrawerFragment.NavigationDrawerCallbacks { diff --git a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/BookDownloadManager.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/BookDownloadManager.java index ef04d1d..021b502 100644 --- a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/BookDownloadManager.java +++ b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/BookDownloadManager.java @@ -32,14 +32,14 @@ public class BookDownloadManager implements WorkListener, BooksListener { /** * Mapping of Job ID to the EventBus we should trigger progress on */ - private Map bookMappings; + private final Map bookMappings; /** * Cached copy of downloads in progress so views displaying this info can get it quickly. */ - private Map inProgressDownloads; + private final Map inProgressDownloads; - private PublishSubject downloadEvents = PublishSubject.create(); + private final PublishSubject downloadEvents = PublishSubject.create(); @Inject Provider dlThreadProvider; diff --git a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/BookDownloadThread.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/BookDownloadThread.java index 70335e6..6fe9da5 100644 --- a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/BookDownloadThread.java +++ b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/BookDownloadThread.java @@ -5,7 +5,6 @@ import android.util.Log; import org.bspeice.minimalbible.MinimalBible; import org.crosswire.jsword.book.Book; import org.crosswire.jsword.book.install.InstallException; -import org.crosswire.jsword.book.install.Installer; import javax.inject.Inject; diff --git a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/DLProgressEvent.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/DLProgressEvent.java index ae5f981..135998e 100644 --- a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/DLProgressEvent.java +++ b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/DLProgressEvent.java @@ -6,8 +6,8 @@ import org.crosswire.jsword.book.Book; * Used for notifying that a book's download progress is ongoing */ public class DLProgressEvent { - private int progress; - private Book b; + private final int progress; + private final Book b; public static final int PROGRESS_COMPLETE = 100; public static final int PROGRESS_BEGINNING = 0; diff --git a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/RefreshManager.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/RefreshManager.java index 98948a8..3b94175 100644 --- a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/RefreshManager.java +++ b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/RefreshManager.java @@ -1,8 +1,5 @@ package org.bspeice.minimalbible.activities.downloader.manager; -import android.os.Handler; -import android.os.HandlerThread; - import org.bspeice.minimalbible.MinimalBible; import org.crosswire.jsword.book.Book; import org.crosswire.jsword.book.install.Installer; @@ -17,8 +14,6 @@ import javax.inject.Inject; import javax.inject.Singleton; import rx.Observable; -import rx.android.schedulers.AndroidSchedulers; -import rx.android.schedulers.HandlerThreadScheduler; import rx.schedulers.Schedulers; /** diff --git a/MinimalBible/src/test/java/org/bspeice/minimalbible/test/DownloadActivityTest.java b/MinimalBible/src/test/java/org/bspeice/minimalbible/test/DownloadActivityTest.java index 26784a7..e61586d 100644 --- a/MinimalBible/src/test/java/org/bspeice/minimalbible/test/DownloadActivityTest.java +++ b/MinimalBible/src/test/java/org/bspeice/minimalbible/test/DownloadActivityTest.java @@ -4,11 +4,8 @@ import android.test.InstrumentationTestCase; import org.bspeice.minimalbible.MinimalBible; import org.bspeice.minimalbible.MinimalBibleModules; -import org.bspeice.minimalbible.activities.downloader.manager.BookDownloadThread; -import org.bspeice.minimalbible.activities.downloader.manager.DLProgressEvent; import org.bspeice.minimalbible.activities.downloader.manager.DownloadManager; import org.bspeice.minimalbible.activities.downloader.manager.InstalledManager; -import org.bspeice.minimalbible.activities.downloader.manager.RefreshManager; import org.crosswire.jsword.book.Book; import org.crosswire.jsword.book.BookException; import org.crosswire.jsword.book.Books; @@ -16,16 +13,14 @@ import org.crosswire.jsword.book.install.Installer; import org.crosswire.jsword.passage.NoSuchKeyException; import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import javax.inject.Inject; -import javax.inject.Provider; import dagger.Module; import dagger.ObjectGraph; -import static com.jayway.awaitility.Awaitility.*; +import static com.jayway.awaitility.Awaitility.await; /** * Tests for the Download activity @@ -38,8 +33,6 @@ public class DownloadActivityTest extends InstrumentationTestCase { @Inject DownloadManager dm; @Inject InstalledManager im; - @Inject Provider bookDownloadThreadProvider; - @Inject RefreshManager rm; public void setUp() { MinimalBible application = MinimalBible.getApplication(); @@ -95,12 +88,7 @@ public class DownloadActivityTest extends InstrumentationTestCase { // Install a book Installer i = (Installer) dm.getInstallers().values().toArray()[0]; final Book testBook = i.getBooks().get(0); - await().atMost(30, TimeUnit.SECONDS).until(new Callable() { - @Override - public Boolean call() throws Exception { - return Books.installed().getBooks().contains(testBook); - } - }); + await().atMost(30, TimeUnit.SECONDS).until(() -> Books.installed().getBooks().contains(testBook)); // Validate that we can actually do something with the book // TODO: Validate that the book exists on the filesystem too