Search in sources :

Example 1 with DrawableItemDecoration

use of org.wikipedia.views.DrawableItemDecoration 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 DrawableItemDecoration

use of org.wikipedia.views.DrawableItemDecoration in project apps-android-wikipedia by wikimedia.

the class RemoteCompilationsFragment 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_remote_compilations, container, false);
    unbinder = ButterKnife.bind(this, view);
    toolbarLayout.setExpandedTitleColor(Color.WHITE);
    toolbarLayout.setCollapsedTitleTextColor(Color.WHITE);
    getAppCompatActivity().setSupportActionBar(toolbar);
    getAppCompatActivity().getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getAppCompatActivity().getSupportActionBar().setTitle("");
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setAdapter(adapter);
    recyclerView.addItemDecoration(new DrawableItemDecoration(getContext(), R.attr.list_separator_drawable));
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    errorView.setRetryClickListener((v) -> beginUpdate());
    errorView.setBackClickListener((v) -> getActivity().finish());
    beginUpdate();
    return view;
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) DrawableItemDecoration(org.wikipedia.views.DrawableItemDecoration) 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) WikiErrorView(org.wikipedia.views.WikiErrorView) Nullable(android.support.annotation.Nullable)

Example 3 with DrawableItemDecoration

use of org.wikipedia.views.DrawableItemDecoration in project apps-android-wikipedia by wikimedia.

the class ConfigureFragment method setupRecyclerView.

private void setupRecyclerView() {
    recyclerView.setHasFixedSize(true);
    ConfigureItemAdapter adapter = new ConfigureItemAdapter();
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.addItemDecoration(new DrawableItemDecoration(requireContext(), R.attr.list_separator_drawable));
    itemTouchHelper = new ItemTouchHelper(new RearrangeableItemTouchHelperCallback(adapter));
    itemTouchHelper.attachToRecyclerView(recyclerView);
}
Also used : ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) DrawableItemDecoration(org.wikipedia.views.DrawableItemDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 4 with DrawableItemDecoration

use of org.wikipedia.views.DrawableItemDecoration in project apps-android-wikipedia by wikimedia.

the class NewsFragment method initRecycler.

private void initRecycler() {
    links.setLayoutManager(new LinearLayoutManager(requireContext()));
    links.addItemDecoration(new DrawableItemDecoration(requireContext(), R.attr.list_separator_drawable));
    links.setNestedScrollingEnabled(false);
}
Also used : DrawableItemDecoration(org.wikipedia.views.DrawableItemDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 5 with DrawableItemDecoration

use of org.wikipedia.views.DrawableItemDecoration in project apps-android-wikipedia by wikimedia.

the class ReadingListFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.fragment_reading_list, container, false);
    unbinder = ButterKnife.bind(this, view);
    getAppCompatActivity().setSupportActionBar(toolbar);
    getAppCompatActivity().getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getAppCompatActivity().getSupportActionBar().setTitle("");
    DeviceUtil.updateStatusBarTheme(requireActivity(), toolbar, true);
    appBarLayout.addOnOffsetChangedListener(appBarListener);
    toolBarLayout.setCollapsedTitleTextColor(ResourceUtil.getThemedColor(requireContext(), R.attr.main_toolbar_icon_color));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        toolBarLayout.setStatusBarScrimColor(ResourceUtil.getThemedColor(requireContext(), R.attr.main_status_bar_color));
    }
    ItemTouchHelper.Callback touchCallback = new SwipeableItemTouchHelperCallback(requireContext());
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(touchCallback);
    itemTouchHelper.attachToRecyclerView(recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setAdapter(adapter);
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    recyclerView.addItemDecoration(new DrawableItemDecoration(requireContext(), R.attr.list_separator_drawable, false));
    recyclerView.addItemDecoration(new MarginItemDecoration(0, 0, 0, DimenUtil.roundedDpToPx(DimenUtil.getDimension(R.dimen.floating_queue_container_height))) {

        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            if (parent.getChildAdapterPosition(view) == adapter.getItemCount() - 1 && floatingQueueView.getVisibility() == View.VISIBLE) {
                super.getItemOffsets(outRect, view, parent, state);
            }
        }
    });
    headerView = new ReadingListItemView(getContext());
    headerView.setCallback(headerCallback);
    headerView.setClickable(false);
    headerView.setThumbnailVisible(false);
    headerView.setTitleTextAppearance(R.style.ReadingListTitleTextAppearance);
    readingListId = getArguments().getLong(EXTRA_READING_LIST_ID);
    disposables.add(WikipediaApp.getInstance().getBus().subscribe(new EventBusConsumer()));
    floatingQueueView.setCallback(this);
    swipeRefreshLayout.setColorSchemeResources(getThemedAttributeId(requireContext(), R.attr.colorAccent));
    swipeRefreshLayout.setOnRefreshListener(() -> ReadingListsFragment.refreshSync(ReadingListFragment.this, swipeRefreshLayout));
    if (ReadingListSyncAdapter.isDisabledByRemoteConfig()) {
        swipeRefreshLayout.setEnabled(false);
    }
    appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> swipeRefreshLayout.setEnabled(verticalOffset == 0));
    return view;
}
Also used : Rect(android.graphics.Rect) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) DrawableItemDecoration(org.wikipedia.views.DrawableItemDecoration) MarginItemDecoration(org.wikipedia.views.MarginItemDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) FloatingQueueView(org.wikipedia.main.floatingqueue.FloatingQueueView) PageItemView(org.wikipedia.views.PageItemView) BindView(butterknife.BindView) View(android.view.View) SearchEmptyView(org.wikipedia.views.SearchEmptyView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) RecyclerView(android.support.v7.widget.RecyclerView) SwipeableItemTouchHelperCallback(org.wikipedia.views.SwipeableItemTouchHelperCallback) Nullable(android.support.annotation.Nullable)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9 DrawableItemDecoration (org.wikipedia.views.DrawableItemDecoration)9 RecyclerView (android.support.v7.widget.RecyclerView)4 View (android.view.View)4 BindView (butterknife.BindView)4 SearchEmptyView (org.wikipedia.views.SearchEmptyView)4 Nullable (android.support.annotation.Nullable)3 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)3 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)3 TextView (android.widget.TextView)3 PageItemView (org.wikipedia.views.PageItemView)3 Rect (android.graphics.Rect)2 MarginItemDecoration (org.wikipedia.views.MarginItemDecoration)2 SwipeableItemTouchHelperCallback (org.wikipedia.views.SwipeableItemTouchHelperCallback)2 WikiErrorView (org.wikipedia.views.WikiErrorView)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 ShareCompat (android.support.v4.app.ShareCompat)1 PopupMenu (android.support.v7.widget.PopupMenu)1