Browse Source

Updating to butterknife v8

master
anthony restaino 8 years ago
parent
commit
2eea6fb60b
  1. 6
      app/build.gradle
  2. 20
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  3. 9
      app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java
  4. 17
      app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java
  5. 13
      app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java
  6. 1
      build.gradle

6
app/build.gradle

@ -1,5 +1,4 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'com.getkeepsafe.dexcount' apply plugin: 'com.getkeepsafe.dexcount'
android { android {
@ -82,11 +81,12 @@ dependencies {
// dependency injection // dependency injection
def daggerVersion = '2.0.2' def daggerVersion = '2.0.2'
compile "com.google.dagger:dagger:$daggerVersion" compile "com.google.dagger:dagger:$daggerVersion"
apt "com.google.dagger:dagger-compiler:$daggerVersion" annotationProcessor "com.google.dagger:dagger-compiler:$daggerVersion"
provided 'javax.annotation:jsr250-api:1.0' provided 'javax.annotation:jsr250-api:1.0'
// view binding // view binding
compile 'com.jakewharton:butterknife:7.0.1' compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
// permissions // permissions
compile 'com.anthonycr.grant:permissions:1.1.2' compile 'com.anthonycr.grant:permissions:1.1.2'

20
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -125,7 +125,7 @@ import acr.browser.lightning.utils.WebUtils;
import acr.browser.lightning.view.Handlers; import acr.browser.lightning.view.Handlers;
import acr.browser.lightning.view.LightningView; import acr.browser.lightning.view.LightningView;
import acr.browser.lightning.view.SearchView; import acr.browser.lightning.view.SearchView;
import butterknife.Bind; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
public abstract class BrowserActivity extends ThemableBrowserActivity implements BrowserView, UIController, OnClickListener, OnLongClickListener { public abstract class BrowserActivity extends ThemableBrowserActivity implements BrowserView, UIController, OnClickListener, OnLongClickListener {
@ -138,18 +138,18 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
private static final String TAG_TABS_FRAGMENT = "TAG_TABS_FRAGMENT"; private static final String TAG_TABS_FRAGMENT = "TAG_TABS_FRAGMENT";
// Static Layout // Static Layout
@Bind(R.id.drawer_layout) DrawerLayout mDrawerLayout; @BindView(R.id.drawer_layout) DrawerLayout mDrawerLayout;
@Bind(R.id.content_frame) FrameLayout mBrowserFrame; @BindView(R.id.content_frame) FrameLayout mBrowserFrame;
@Bind(R.id.left_drawer) ViewGroup mDrawerLeft; @BindView(R.id.left_drawer) ViewGroup mDrawerLeft;
@Bind(R.id.right_drawer) ViewGroup mDrawerRight; @BindView(R.id.right_drawer) ViewGroup mDrawerRight;
@Bind(R.id.ui_layout) ViewGroup mUiLayout; @BindView(R.id.ui_layout) ViewGroup mUiLayout;
@Bind(R.id.toolbar_layout) ViewGroup mToolbarLayout; @BindView(R.id.toolbar_layout) ViewGroup mToolbarLayout;
@Bind(R.id.progress_view) AnimatedProgressBar mProgressBar; @BindView(R.id.progress_view) AnimatedProgressBar mProgressBar;
@Bind(R.id.search_bar) RelativeLayout mSearchBar; @BindView(R.id.search_bar) RelativeLayout mSearchBar;
// Toolbar Views // Toolbar Views
@Bind(R.id.toolbar) Toolbar mToolbar; @BindView(R.id.toolbar) Toolbar mToolbar;
private View mSearchBackground; private View mSearchBackground;
private SearchView mSearch; private SearchView mSearch;
private ImageView mArrowImage; private ImageView mArrowImage;

9
app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java

@ -40,18 +40,15 @@ import acr.browser.lightning.reading.HtmlFetcher;
import acr.browser.lightning.reading.JResult; import acr.browser.lightning.reading.JResult;
import acr.browser.lightning.utils.ThemeUtils; import acr.browser.lightning.utils.ThemeUtils;
import acr.browser.lightning.utils.Utils; import acr.browser.lightning.utils.Utils;
import butterknife.Bind; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
public class ReadingActivity extends AppCompatActivity { public class ReadingActivity extends AppCompatActivity {
private static final String TAG = ReadingActivity.class.getSimpleName(); private static final String TAG = ReadingActivity.class.getSimpleName();
@Bind(R.id.textViewTitle) @BindView(R.id.textViewTitle) TextView mTitle;
TextView mTitle; @BindView(R.id.textViewBody) TextView mBody;
@Bind(R.id.textViewBody)
TextView mBody;
@Inject PreferenceManager mPreferences; @Inject PreferenceManager mPreferences;

17
app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java

@ -56,8 +56,9 @@ import acr.browser.lightning.dialog.LightningDialogBuilder;
import acr.browser.lightning.preference.PreferenceManager; import acr.browser.lightning.preference.PreferenceManager;
import acr.browser.lightning.utils.ThemeUtils; import acr.browser.lightning.utils.ThemeUtils;
import acr.browser.lightning.view.LightningView; import acr.browser.lightning.view.LightningView;
import butterknife.Bind; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.Unbinder;
public class BookmarksFragment extends Fragment implements View.OnClickListener, View.OnLongClickListener, BookmarksView { public class BookmarksFragment extends Fragment implements View.OnClickListener, View.OnLongClickListener, BookmarksView {
@ -92,9 +93,10 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
private final List<HistoryItem> mBookmarks = new ArrayList<>(); private final List<HistoryItem> mBookmarks = new ArrayList<>();
// Views // Views
@Bind(R.id.right_drawer_list) ListView mBookmarksListView; @BindView(R.id.right_drawer_list) ListView mBookmarksListView;
@Bind(R.id.starIcon) ImageView mBookmarkTitleImage; @BindView(R.id.starIcon) ImageView mBookmarkTitleImage;
@Bind(R.id.icon_star) ImageView mBookmarkImage; @BindView(R.id.icon_star) ImageView mBookmarkImage;
private Unbinder mUnbinder;
// Colors // Colors
private int mIconColor, mScrollIndex; private int mIconColor, mScrollIndex;
@ -176,7 +178,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.bookmark_drawer, container, false); final View view = inflater.inflate(R.layout.bookmark_drawer, container, false);
ButterKnife.bind(this, view); mUnbinder = ButterKnife.bind(this, view);
mBookmarksListView.setOnItemClickListener(mItemClickListener); mBookmarksListView.setOnItemClickListener(mItemClickListener);
mBookmarksListView.setOnItemLongClickListener(mItemLongClickListener); mBookmarksListView.setOnItemLongClickListener(mItemLongClickListener);
mBookmarkTitleImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN); mBookmarkTitleImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
@ -209,7 +211,10 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
@Override @Override
public void onDestroyView() { public void onDestroyView() {
super.onDestroyView(); super.onDestroyView();
ButterKnife.unbind(this); if (mUnbinder != null) {
mUnbinder.unbind();
mUnbinder = null;
}
} }
@Override @Override

13
app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java

@ -48,8 +48,9 @@ import acr.browser.lightning.utils.ThemeUtils;
import acr.browser.lightning.utils.Utils; import acr.browser.lightning.utils.Utils;
import acr.browser.lightning.view.BackgroundDrawable; import acr.browser.lightning.view.BackgroundDrawable;
import acr.browser.lightning.view.LightningView; import acr.browser.lightning.view.LightningView;
import butterknife.Bind; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.Unbinder;
/** /**
* A fragment that holds and manages the tabs and interaction with the tabs. * A fragment that holds and manages the tabs and interaction with the tabs.
@ -77,7 +78,8 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
@Nullable private LightningViewAdapter mTabsAdapter; @Nullable private LightningViewAdapter mTabsAdapter;
private UIController mUiController; private UIController mUiController;
@Bind(R.id.tabs_list) RecyclerView mRecyclerView; @BindView(R.id.tabs_list) RecyclerView mRecyclerView;
private Unbinder mUnbinder;
private TabsManager mTabsManager; private TabsManager mTabsManager;
@Inject Bus mBus; @Inject Bus mBus;
@ -130,7 +132,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
}); });
} }
ButterKnife.bind(this, view); mUnbinder = ButterKnife.bind(this, view);
SimpleItemAnimator animator; SimpleItemAnimator animator;
if (mShowInNavigationDrawer) { if (mShowInNavigationDrawer) {
@ -156,7 +158,10 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
@Override @Override
public void onDestroyView() { public void onDestroyView() {
super.onDestroyView(); super.onDestroyView();
ButterKnife.unbind(this); if (mUnbinder != null) {
mUnbinder.unbind();
mUnbinder = null;
}
mTabsAdapter = null; mTabsAdapter = null;
} }

1
build.gradle

@ -4,7 +4,6 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.1' classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.3' classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.3'
} }
} }

Loading…
Cancel
Save