Search in sources :

Example 1 with Unbinder

use of butterknife.Unbinder in project apps-android-wikipedia by wikimedia.

the class LocalCompilationsFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.fragment_local_compilations, container, false);
    unbinder = ButterKnife.bind(this, view);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setAdapter(adapter);
    recyclerView.addItemDecoration(new DrawableItemDecoration(getContext(), R.attr.list_separator_drawable));
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    errorView.setBackClickListener(v -> getActivity().finish());
    emptyDescription.setMovementMethod(LinkMovementMethod.getInstance());
    emptyDescription.setText(StringUtil.fromHtml(getString(R.string.offline_library_empty_description_sideload)));
    RichTextUtil.removeUnderlinesFromLinks(emptyDescription);
    packsHint.setMovementMethod(LinkMovementMethod.getInstance());
    packsHint.setText(StringUtil.fromHtml(getString(R.string.offline_library_packs_hint)));
    RichTextUtil.removeUnderlinesFromLinks(packsHint);
    dataUsageHint.setMovementMethod(new LinkMovementMethodExt((url, titleString) -> {
        if (url.equals(UriUtil.LOCAL_URL_SETTINGS)) {
            startActivity(SettingsActivity.newIntent(getContext()));
        }
    }));
    dataUsageHint.setText(StringUtil.fromHtml(getString(R.string.offline_library_data_usage_hint)));
    RichTextUtil.removeUnderlinesFromLinks(dataUsageHint);
    funnel = new OfflineLibraryFunnel(WikipediaApp.getInstance(), 0);
    return view;
}
Also used : ShareCompat(android.support.v4.app.ShareCompat) Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) DrawableItemDecoration(org.wikipedia.views.DrawableItemDecoration) ButterKnife(butterknife.ButterKnife) Intent(android.content.Intent) NonNull(android.support.annotation.NonNull) LinkMovementMethod(android.text.method.LinkMovementMethod) DefaultViewHolder(org.wikipedia.views.DefaultViewHolder) ShareUtil(org.wikipedia.util.ShareUtil) PageItemView(org.wikipedia.views.PageItemView) OnClick(butterknife.OnClick) SettingsActivity(org.wikipedia.settings.SettingsActivity) ArrayList(java.util.ArrayList) BindView(butterknife.BindView) FileUtil.bytesToUserVisibleUnit(org.wikipedia.util.FileUtil.bytesToUserVisibleUnit) WikipediaApp(org.wikipedia.WikipediaApp) FragmentUtil(org.wikipedia.activity.FragmentUtil) StringUtil(org.wikipedia.util.StringUtil) View(android.view.View) SearchEmptyView(org.wikipedia.views.SearchEmptyView) Unbinder(butterknife.Unbinder) LinkMovementMethodExt(org.wikipedia.page.LinkMovementMethodExt) R(org.wikipedia.R) RichTextUtil(org.wikipedia.richtext.RichTextUtil) LayoutInflater(android.view.LayoutInflater) OfflineLibraryFunnel(org.wikipedia.analytics.OfflineLibraryFunnel) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) PopupMenu(android.support.v7.widget.PopupMenu) UriUtil(org.wikipedia.util.UriUtil) ViewGroup(android.view.ViewGroup) File(java.io.File) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) TextView(android.widget.TextView) WikiErrorView(org.wikipedia.views.WikiErrorView) ResourceUtil(org.wikipedia.util.ResourceUtil) Nullable(android.support.annotation.Nullable) DimenUtil(org.wikipedia.util.DimenUtil) DateUtil.getShortDateString(org.wikipedia.util.DateUtil.getShortDateString) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) DrawableItemDecoration(org.wikipedia.views.DrawableItemDecoration) OfflineLibraryFunnel(org.wikipedia.analytics.OfflineLibraryFunnel) LinkMovementMethodExt(org.wikipedia.page.LinkMovementMethodExt) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) PageItemView(org.wikipedia.views.PageItemView) BindView(butterknife.BindView) View(android.view.View) SearchEmptyView(org.wikipedia.views.SearchEmptyView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) WikiErrorView(org.wikipedia.views.WikiErrorView) Nullable(android.support.annotation.Nullable)

Example 2 with Unbinder

use of butterknife.Unbinder in project butterknife by JakeWharton.

the class BindBitmapTest method asBitmap.

@Test
public void asBitmap() {
    Target target = new Target();
    Bitmap expected = BitmapFactory.decodeResource(context.getResources(), R.drawable.pixel);
    Unbinder unbinder = new BindBitmapTest$Target_ViewBinding(target, context);
    assertTrue(target.actual.sameAs(expected));
    unbinder.unbind();
    assertTrue(target.actual.sameAs(expected));
}
Also used : Bitmap(android.graphics.Bitmap) BindBitmap(butterknife.BindBitmap) Unbinder(butterknife.Unbinder) Test(org.junit.Test)

Example 3 with Unbinder

use of butterknife.Unbinder in project butterknife by JakeWharton.

the class BindBoolTest method asBoolean.

@Test
public void asBoolean() {
    Target target = new Target();
    boolean expected = context.getResources().getBoolean(R.bool.just_true);
    Unbinder unbinder = new BindBoolTest$Target_ViewBinding(target, context);
    assertThat(target.actual).isEqualTo(expected);
    unbinder.unbind();
    assertThat(target.actual).isEqualTo(expected);
}
Also used : Unbinder(butterknife.Unbinder) Test(org.junit.Test)

Example 4 with Unbinder

use of butterknife.Unbinder in project butterknife by JakeWharton.

the class BindColorTest method asColorStateList.

@Test
public void asColorStateList() {
    ColorStateListTarget target = new ColorStateListTarget();
    ColorStateList expected = context.getResources().getColorStateList(R.color.colors);
    Unbinder unbinder = new BindColorTest$ColorStateListTarget_ViewBinding(target, context);
    assertThat(target.actual.toString()).isEqualTo(expected.toString());
    unbinder.unbind();
    assertThat(target.actual.toString()).isEqualTo(expected.toString());
}
Also used : Unbinder(butterknife.Unbinder) ColorStateList(android.content.res.ColorStateList) Test(org.junit.Test)

Example 5 with Unbinder

use of butterknife.Unbinder in project butterknife by JakeWharton.

the class BindDimenTest method asFloat.

@Test
public void asFloat() {
    FloatTarget target = new FloatTarget();
    float expected = context.getResources().getDimension(R.dimen.twelve_point_two_dp);
    Unbinder unbinder = new BindDimenTest$FloatTarget_ViewBinding(target, context);
    assertThat(target.actual).isEqualTo(expected);
    unbinder.unbind();
    assertThat(target.actual).isEqualTo(expected);
}
Also used : Unbinder(butterknife.Unbinder) Test(org.junit.Test)

Aggregations

Unbinder (butterknife.Unbinder)82 Test (org.junit.Test)70 View (android.view.View)52 UiThreadTest (androidx.test.annotation.UiThreadTest)31 TextView (android.widget.TextView)21 AdapterView (android.widget.AdapterView)15 BindView (butterknife.BindView)13 Bundle (android.os.Bundle)12 LayoutInflater (android.view.LayoutInflater)12 ViewGroup (android.view.ViewGroup)12 ButterKnife (butterknife.ButterKnife)12 R (com.simplecity.amp_library.R)10 List (java.util.List)9 Nullable (android.support.annotation.Nullable)8 Aesthetic (com.afollestad.aesthetic.Aesthetic)8 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)8 Inject (javax.inject.Inject)8 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)7 RecyclerView (android.support.v7.widget.RecyclerView)6 Rx.distinctToMainThread (com.afollestad.aesthetic.Rx.distinctToMainThread)6