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 @@ @@ -1,5 +1,4 @@
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'com.getkeepsafe.dexcount'
android {
@ -82,11 +81,12 @@ dependencies { @@ -82,11 +81,12 @@ dependencies {
// dependency injection
def daggerVersion = '2.0.2'
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'
// 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
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; @@ -125,7 +125,7 @@ import acr.browser.lightning.utils.WebUtils;
import acr.browser.lightning.view.Handlers;
import acr.browser.lightning.view.LightningView;
import acr.browser.lightning.view.SearchView;
import butterknife.Bind;
import butterknife.BindView;
import butterknife.ButterKnife;
public abstract class BrowserActivity extends ThemableBrowserActivity implements BrowserView, UIController, OnClickListener, OnLongClickListener {
@ -138,18 +138,18 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -138,18 +138,18 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
private static final String TAG_TABS_FRAGMENT = "TAG_TABS_FRAGMENT";
// Static Layout
@Bind(R.id.drawer_layout) DrawerLayout mDrawerLayout;
@Bind(R.id.content_frame) FrameLayout mBrowserFrame;
@Bind(R.id.left_drawer) ViewGroup mDrawerLeft;
@Bind(R.id.right_drawer) ViewGroup mDrawerRight;
@Bind(R.id.ui_layout) ViewGroup mUiLayout;
@Bind(R.id.toolbar_layout) ViewGroup mToolbarLayout;
@Bind(R.id.progress_view) AnimatedProgressBar mProgressBar;
@Bind(R.id.search_bar) RelativeLayout mSearchBar;
@BindView(R.id.drawer_layout) DrawerLayout mDrawerLayout;
@BindView(R.id.content_frame) FrameLayout mBrowserFrame;
@BindView(R.id.left_drawer) ViewGroup mDrawerLeft;
@BindView(R.id.right_drawer) ViewGroup mDrawerRight;
@BindView(R.id.ui_layout) ViewGroup mUiLayout;
@BindView(R.id.toolbar_layout) ViewGroup mToolbarLayout;
@BindView(R.id.progress_view) AnimatedProgressBar mProgressBar;
@BindView(R.id.search_bar) RelativeLayout mSearchBar;
// Toolbar Views
@Bind(R.id.toolbar) Toolbar mToolbar;
@BindView(R.id.toolbar) Toolbar mToolbar;
private View mSearchBackground;
private SearchView mSearch;
private ImageView mArrowImage;

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

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

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

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

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

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

1
build.gradle

@ -4,7 +4,6 @@ buildscript { @@ -4,7 +4,6 @@ buildscript {
}
dependencies {
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'
}
}

Loading…
Cancel
Save