Search in sources :

Example 1 with AdapterListener

use of com.winsonchiu.reader.adapter.AdapterListener in project Reader by TheKeeperOfPie.

the class FragmentProfile method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.fragment_profile, container, false);
    layoutCoordinator = (CoordinatorLayout) view.findViewById(R.id.layout_coordinator);
    layoutAppBar = (AppBarLayout) view.findViewById(R.id.layout_app_bar);
    listener = new ControllerProfile.Listener() {

        @Override
        public void setSortAndTime(Sort sort, Time time) {
            menu.findItem(sort.getMenuId()).setChecked(true);
            menu.findItem(time.getMenuId()).setChecked(true);
            itemSortTime.setTitle(getString(R.string.time_description, menu.findItem(controllerProfile.getTime().getMenuId()).toString()));
        }

        @Override
        public void setPage(Page page) {
            spinnerPage.setSelection(adapterProfilePage.getPages().indexOf(page));
            if (page.getPage().equals(ControllerProfile.PAGE_HIDDEN)) {
                callback.setDrawable(getResources().getDrawable(R.drawable.ic_visibility_white_24dp));
            } else {
                callback.setDrawable(getResources().getDrawable(R.drawable.ic_visibility_off_white_24dp));
            }
        }

        @Override
        public void setIsUser(boolean isUser) {
            // TODO: Fix set page for Profile view
            adapterProfilePage.setIsUser(isUser);
        }

        @Override
        public void loadLink(Comment comment) {
            Log.d(TAG, "Link ID: " + comment.getLinkId());
            Intent intent = new Intent(activity, ActivityMain.class);
            intent.setAction(Intent.ACTION_VIEW);
            intent.putExtra(ActivityMain.REDDIT_PAGE, Reddit.BASE_URL + "/r/" + comment.getSubreddit() + "/comments/" + comment.getLinkId().replace("t3_", ""));
            startActivity(intent);
        }

        @Override
        public RecyclerView.Adapter getAdapter() {
            return adapterProfile;
        }

        @Override
        public void setToolbarTitle(CharSequence title) {
            toolbar.setTitle(title);
        }

        @Override
        public void setRefreshing(boolean refreshing) {
            swipeRefreshProfile.setRefreshing(refreshing);
        }

        @Override
        public void post(Runnable runnable) {
            recyclerProfile.post(runnable);
        }
    };
    int styleColorBackground = AppSettings.THEME_DARK.equals(mListener.getThemeBackground()) ? R.style.MenuDark : R.style.MenuLight;
    ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(new ThemeWrapper(activity, UtilsColor.getThemeForColor(getResources(), themer.getColorPrimary(), mListener)), styleColorBackground);
    toolbar = (Toolbar) activity.getLayoutInflater().cloneInContext(contextThemeWrapper).inflate(R.layout.toolbar, layoutAppBar, false);
    layoutAppBar.addView(toolbar);
    ((AppBarLayout.LayoutParams) toolbar.getLayoutParams()).setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
    if (getFragmentManager().getBackStackEntryCount() <= 1) {
        toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mListener.openDrawer();
            }
        });
    } else {
        toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mListener.onNavigationBackClick();
            }
        });
    }
    toolbar.getNavigationIcon().mutate().setColorFilter(themer.getColorFilterPrimary());
    toolbar.setTitleTextColor(themer.getColorFilterPrimary().getColor());
    setUpOptionsMenu();
    adapterProfilePage = new AdapterProfilePage(activity);
    spinnerPage = new AppCompatSpinner(contextThemeWrapper);
    toolbar.addView(spinnerPage);
    ((Toolbar.LayoutParams) spinnerPage.getLayoutParams()).setMarginEnd((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()));
    spinnerPage.setAdapter(adapterProfilePage);
    spinnerPage.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            controllerProfile.setPage(adapterProfilePage.getItem(position)).subscribe(getReloadObserver());
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    swipeRefreshProfile = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_profile);
    swipeRefreshProfile.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            controllerProfile.reload().subscribe(getReloadObserver());
        }
    });
    linearLayoutManager = new LinearLayoutManager(activity);
    recyclerProfile = (RecyclerView) view.findViewById(R.id.recycler_profile);
    recyclerProfile.setHasFixedSize(true);
    recyclerProfile.setItemAnimator(null);
    recyclerProfile.setLayoutManager(linearLayoutManager);
    recyclerProfile.addItemDecoration(new ItemDecorationDivider(activity, ItemDecorationDivider.VERTICAL_LIST));
    AdapterListener adapterListener = new AdapterListener() {

        @Override
        public void scrollAndCenter(int position, int height) {
            UtilsAnimation.scrollToPositionWithCentering(position, recyclerProfile, false);
        }

        @Override
        public void hideToolbar() {
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }

        @Override
        public void clearDecoration() {
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }

        @Override
        public void requestMore() {
            controllerProfile.loadMoreLinks().observeOn(AndroidSchedulers.mainThread()).subscribe(new ObserverError<Listing>() {

                @Override
                public void onError(Throwable e) {
                    Toast.makeText(getContext(), getString(R.string.error_loading_links), Toast.LENGTH_SHORT).show();
                }
            });
        }

        @Override
        public void requestDisallowInterceptTouchEventVertical(boolean disallow) {
            recyclerProfile.requestDisallowInterceptTouchEvent(disallow);
            swipeRefreshProfile.requestDisallowInterceptTouchEvent(disallow);
            itemTouchHelper.select(null, CustomItemTouchHelper.ACTION_STATE_IDLE);
        }

        @Override
        public void requestDisallowInterceptTouchEventHorizontal(boolean disallow) {
            itemTouchHelper.setDisallow(disallow);
        }
    };
    AdapterLink.ViewHolderLink.Listener listenerLink = new AdapterLink.ViewHolderLink.Listener() {

        @Override
        public void onSubmitComment(Link link, String text) {
        }

        @Override
        public void onDownloadImage(Link link) {
        }

        @Override
        public void onDownloadImage(Link link, String title, String fileName, String url) {
        }

        @Override
        public void onLoadUrl(Link link, boolean forceExternal) {
        }

        @Override
        public void onShowFullEditor(Link link) {
        }

        @Override
        public void onVote(Link link, AdapterLink.ViewHolderLink viewHolderLink, Likes vote) {
        }

        @Override
        public void onCopyText(Link link) {
        }

        @Override
        public void onEdit(Link link) {
        }

        @Override
        public void onDelete(Link link) {
        }

        @Override
        public void onReport(Link link) {
        }

        @Override
        public void onSave(Link link) {
        }

        @Override
        public void onShowComments(Link link, AdapterLink.ViewHolderLink viewHolderLink, Source source) {
        }

        @Override
        public void onShowError(String error) {
        }

        @Override
        public void onMarkNsfw(Link link) {
        }
    };
    AdapterCommentList.ViewHolderComment.Listener listenerComments = new AdapterCommentList.ViewHolderComment.Listener() {

        @Override
        public void onToggleComment(Comment comment) {
        }

        @Override
        public void onShowReplyEditor(Comment comment) {
        }

        @Override
        public void onEditComment(Comment comment, String text) {
        }

        @Override
        public void onSendComment(Comment comment, String text) {
        }

        @Override
        public void onMarkRead(Comment comment) {
        }

        @Override
        public void onLoadNestedComments(Comment comment) {
        }

        @Override
        public void onJumpToParent(Comment comment) {
        }

        @Override
        public void onViewProfile(Comment comment) {
        }

        @Override
        public void onCopyText(Comment comment) {
        }

        @Override
        public void onDeleteComment(Comment comment) {
        }

        @Override
        public void onReport(Comment comment) {
        }

        @Override
        public void onVoteComment(Comment comment, AdapterCommentList.ViewHolderComment viewHolderComment, Likes vote) {
        }

        @Override
        public void onSave(Comment comment) {
        }
    };
    if (adapterProfile == null) {
        adapterProfile = new AdapterProfile(getActivity(), controllerProfile, adapterListener, listenerLink, listenerComments, listener);
    }
    recyclerProfile.setAdapter(adapterProfile);
    callback = new CustomItemTouchHelper.SimpleCallback(activity, R.drawable.ic_delete_white_24dp, ItemTouchHelper.START | ItemTouchHelper.END, ItemTouchHelper.START | ItemTouchHelper.END) {

        @Override
        public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
            int position = viewHolder.getAdapterPosition();
            if (position == 2 || (position >= 6 && controllerProfile.getViewType(position - 6) == ControllerProfile.VIEW_TYPE_LINK)) {
                return super.getSwipeDirs(recyclerView, viewHolder);
            }
            return 0;
        }

        @Override
        public boolean isLongPressDragEnabled() {
            return false;
        }

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
            return false;
        }

        @Override
        public void onSwiped(final RecyclerView.ViewHolder viewHolder, int direction) {
            Log.d(TAG, "onSwiped: " + viewHolder.getAdapterPosition());
            final int adapterPosition = viewHolder.getAdapterPosition();
            final int position = adapterPosition == 2 ? -1 : adapterPosition - 6;
            final Link link = adapterPosition == 2 ? controllerProfile.remove(-1) : controllerProfile.remove(position);
            mListener.getEventListenerBase().hide(link);
            if (snackbar != null) {
                snackbar.dismiss();
            }
            SpannableString text = new SpannableString(link.isHidden() ? getString(R.string.link_hidden) : getString(R.string.link_shown));
            text.setSpan(new ForegroundColorSpan(themer.getColorFilterPrimary().getColor()), 0, text.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
            //noinspection ResourceType
            snackbar = Snackbar.make(recyclerProfile, text, UtilsAnimation.SNACKBAR_DURATION).setActionTextColor(themer.getColorFilterPrimary().getColor()).setAction(R.string.undo, new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    mListener.getEventListenerBase().hide(link);
                    if (adapterPosition == 2) {
                        controllerProfile.setTopLink(link);
                        adapterProfile.notifyItemChanged(2);
                    } else {
                        controllerProfile.add(position, link);
                    }
                    recyclerProfile.invalidate();
                }
            });
            snackbar.getView().setBackgroundColor(themer.getColorPrimary());
            snackbar.show();
        }
    };
    itemTouchHelper = new CustomItemTouchHelper(callback);
    itemTouchHelper.attachToRecyclerView(recyclerProfile);
    return view;
}
Also used : ItemDecorationDivider(com.winsonchiu.reader.utils.ItemDecorationDivider) AdapterLink(com.winsonchiu.reader.links.AdapterLink) Page(com.winsonchiu.reader.data.Page) SpannableString(android.text.SpannableString) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) Sort(com.winsonchiu.reader.data.reddit.Sort) AppBarLayout(android.support.design.widget.AppBarLayout) ForegroundColorSpan(android.text.style.ForegroundColorSpan) AppCompatSpinner(android.support.v7.widget.AppCompatSpinner) SpannableString(android.text.SpannableString) AdapterView(android.widget.AdapterView) AdapterLink(com.winsonchiu.reader.links.AdapterLink) Link(com.winsonchiu.reader.data.reddit.Link) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) Time(com.winsonchiu.reader.data.reddit.Time) Source(com.winsonchiu.reader.comments.Source) ContextThemeWrapper(android.view.ContextThemeWrapper) ThemeWrapper(com.winsonchiu.reader.theme.ThemeWrapper) AdapterCommentList(com.winsonchiu.reader.comments.AdapterCommentList) ActivityMain(com.winsonchiu.reader.ActivityMain) CustomItemTouchHelper(com.winsonchiu.reader.utils.CustomItemTouchHelper) Comment(com.winsonchiu.reader.data.reddit.Comment) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) Intent(android.content.Intent) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) ContextThemeWrapper(android.view.ContextThemeWrapper) Listing(com.winsonchiu.reader.data.reddit.Listing) RecyclerView(android.support.v7.widget.RecyclerView) Likes(com.winsonchiu.reader.data.reddit.Likes)

Example 2 with AdapterListener

use of com.winsonchiu.reader.adapter.AdapterListener in project Reader by TheKeeperOfPie.

the class FragmentSearch method onCreateView.

// TODO: Remove/fix ResourceType warning
@SuppressWarnings("ResourceType")
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    view = bind(inflater.inflate(R.layout.fragment_search, container, false));
    listenerSearch = new ControllerSearch.Listener() {

        @Override
        public AdapterSearchSubreddits getAdapterSearchSubreddits() {
            return adapterSearchSubreddits;
        }

        @Override
        public AdapterSearchSubreddits getAdapterSearchSubredditsRecommended() {
            return adapterSearchSubredditsRecommended;
        }

        @Override
        public void scrollToLinks(int position) {
            layoutManagerLinks.scrollToPositionWithOffset(0, 0);
        }

        @Override
        public void scrollToLinksSubreddit(int position) {
            layoutManagerLinksSubreddit.scrollToPositionWithOffset(0, 0);
        }
    };
    int windowBackground = UtilsTheme.getAttributeColor(getContext(), android.R.attr.windowBackground, 0);
    setUpToolbar();
    adapterSearchSubreddits = new AdapterSearchSubreddits(getActivity(), new ControllerSearchBase() {

        @Override
        public Subreddit getSubreddit(int position) {
            return controllerSearch.getSubreddit(position);
        }

        @Override
        public int getSubredditCount() {
            return controllerSearch.getCountSubreddit();
        }
    }, new AdapterSearchSubreddits.ViewHolder.EventListener() {

        @Override
        public void onClickSubreddit(Subreddit subreddit) {
            controllerSearch.addViewedSubreddit(subreddit);
            controllerLinks.setParameters(subreddit.getDisplayName(), Sort.HOT, Time.ALL);
            closeKeyboard();
            mListener.onNavigationBackClick();
        }

        @Override
        public boolean supportsDrag() {
            return true;
        }

        @Override
        public void onStartDrag(AdapterSearchSubreddits.ViewHolder viewHolder) {
            itemTouchHelperSubreddits.startDrag(viewHolder);
        }

        @Override
        public void sendToTop(AdapterSearchSubreddits.ViewHolder viewHolder) {
            controllerSearch.moveSubreddit(viewHolder.getAdapterPosition(), 0);
            recyclerSearchSubreddits.postOnAnimationDelayed(() -> {
                if (layoutManagerSubreddits.findFirstVisibleItemPosition() <= 1) {
                    layoutManagerSubreddits.smoothScrollToPosition(recyclerSearchSubreddits, null, 0);
                }
            }, 150);
        }

        @Override
        public boolean isSubscriptionListShown() {
            return controllerSearch.isSubscriptionListShown();
        }
    });
    layoutManagerSubreddits = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
    recyclerSearchSubreddits.setLayoutManager(layoutManagerSubreddits);
    recyclerSearchSubreddits.setAdapter(adapterSearchSubreddits);
    recyclerSearchSubreddits.addItemDecoration(new ItemDecorationDivider(getActivity(), ItemDecorationDivider.VERTICAL_LIST));
    itemTouchHelperSubreddits = new ItemTouchHelper(new SimpleCallbackBackground(0, 0, windowBackground) {

        @Override
        public int getDragDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
            if (controllerSearch.isSubscriptionListShown()) {
                return ItemTouchHelper.UP | ItemTouchHelper.DOWN;
            }
            return super.getDragDirs(recyclerView, viewHolder);
        }

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
            controllerSearch.moveSubreddit(viewHolder.getAdapterPosition(), target.getAdapterPosition());
            return true;
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
        }

        @Override
        public boolean isLongPressDragEnabled() {
            return false;
        }
    });
    itemTouchHelperSubreddits.attachToRecyclerView(recyclerSearchSubreddits);
    AdapterLink.ViewHolderLink.Listener listenerLink = new AdapterLink.ViewHolderLink.Listener() {

        @Override
        public void onSubmitComment(Link link, String text) {
        }

        @Override
        public void onDownloadImage(Link link) {
        }

        @Override
        public void onDownloadImage(Link link, String title, String fileName, String url) {
        }

        @Override
        public void onLoadUrl(Link link, boolean forceExternal) {
        }

        @Override
        public void onShowFullEditor(Link link) {
        }

        @Override
        public void onVote(Link link, AdapterLink.ViewHolderLink viewHolderLink, Likes vote) {
        }

        @Override
        public void onCopyText(Link link) {
        }

        @Override
        public void onEdit(Link link) {
        }

        @Override
        public void onDelete(Link link) {
        }

        @Override
        public void onReport(Link link) {
        }

        @Override
        public void onSave(Link link) {
        }

        @Override
        public void onShowComments(Link link, AdapterLink.ViewHolderLink viewHolderLink, Source source) {
        }

        @Override
        public void onShowError(String error) {
        }

        @Override
        public void onMarkNsfw(Link link) {
        }
    };
    adapterLinks = new AdapterSearchLinkList(getActivity(), new AdapterListener() {

        @Override
        public void requestMore() {
            controllerSearch.loadMoreLinks().subscribe(getReloadObserver());
        }

        @Override
        public void scrollAndCenter(int position, int height) {
            UtilsAnimation.scrollToPositionWithCentering(position, recyclerSearchLinks, false);
        }

        @Override
        public void hideToolbar() {
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }

        @Override
        public void clearDecoration() {
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }

        @Override
        public void requestDisallowInterceptTouchEventVertical(boolean disallow) {
            recyclerSearchLinks.requestDisallowInterceptTouchEvent(disallow);
            recyclerSearchLinksSubreddit.requestDisallowInterceptTouchEvent(disallow);
            pagerSearch.requestDisallowInterceptTouchEvent(disallow);
        }

        @Override
        public void requestDisallowInterceptTouchEventHorizontal(boolean disallow) {
        }
    }, new AdapterLink.ViewHolderHeader.EventListener() {

        @Override
        public void onClickSubmit(Reddit.PostType postType) {
        }

        @Override
        public void showSidebar() {
        }
    }, listenerLink, Source.SEARCH_LINKS);
    adapterLinksSubreddit = new AdapterSearchLinkList(getActivity(), new AdapterListener() {

        @Override
        public void requestMore() {
            controllerSearch.loadMoreLinksSubreddit().subscribe(getReloadObserver());
        }

        @Override
        public void scrollAndCenter(int position, int height) {
            UtilsAnimation.scrollToPositionWithCentering(position, recyclerSearchLinksSubreddit, false);
        }

        @Override
        public void hideToolbar() {
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }

        @Override
        public void clearDecoration() {
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }

        @Override
        public void requestDisallowInterceptTouchEventVertical(boolean disallow) {
            recyclerSearchLinks.requestDisallowInterceptTouchEvent(disallow);
            recyclerSearchLinksSubreddit.requestDisallowInterceptTouchEvent(disallow);
            pagerSearch.requestDisallowInterceptTouchEvent(disallow);
        }

        @Override
        public void requestDisallowInterceptTouchEventHorizontal(boolean disallow) {
        }
    }, new AdapterLink.ViewHolderHeader.EventListener() {

        @Override
        public void onClickSubmit(Reddit.PostType postType) {
        }

        @Override
        public void showSidebar() {
        }
    }, listenerLink, Source.SEARCH_LINKS_SUBREDDIT);
    layoutManagerLinks = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
    recyclerSearchLinks.setLayoutManager(layoutManagerLinks);
    recyclerSearchLinks.setAdapter(adapterLinks);
    recyclerSearchLinks.addItemDecoration(new ItemDecorationDivider(getActivity(), ItemDecorationDivider.VERTICAL_LIST));
    layoutManagerLinksSubreddit = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
    recyclerSearchLinksSubreddit.setLayoutManager(layoutManagerLinksSubreddit);
    recyclerSearchLinksSubreddit.setAdapter(adapterLinksSubreddit);
    recyclerSearchLinksSubreddit.addItemDecoration(new ItemDecorationDivider(getActivity(), ItemDecorationDivider.VERTICAL_LIST));
    adapterSearchSubredditsRecommended = new AdapterSearchSubreddits(getActivity(), new ControllerSearchBase() {

        @Override
        public Subreddit getSubreddit(int position) {
            return controllerSearch.getSubredditRecommended(position);
        }

        @Override
        public int getSubredditCount() {
            return controllerSearch.getCountSubredditRecommended();
        }
    }, new AdapterSearchSubreddits.ViewHolder.EventListener() {

        @Override
        public void onClickSubreddit(Subreddit subreddit) {
            controllerLinks.setParameters(subreddit.getDisplayName(), Sort.HOT, Time.ALL);
            closeKeyboard();
            mListener.onNavigationBackClick();
        }

        @Override
        public boolean supportsDrag() {
            return false;
        }

        @Override
        public void onStartDrag(AdapterSearchSubreddits.ViewHolder viewHolder) {
        }

        @Override
        public void sendToTop(AdapterSearchSubreddits.ViewHolder viewHolder) {
        }

        @Override
        public boolean isSubscriptionListShown() {
            return controllerSearch.isSubscriptionListShown();
        }
    });
    layoutManagerSubredditsRecommended = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
    recyclerSearchSubredditsRecommended.setLayoutManager(layoutManagerSubredditsRecommended);
    recyclerSearchSubredditsRecommended.setAdapter(adapterSearchSubredditsRecommended);
    recyclerSearchSubredditsRecommended.addItemDecoration(new ItemDecorationDivider(getActivity(), ItemDecorationDivider.VERTICAL_LIST));
    pagerSearch.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            controllerSearch.setCurrentPage(position).subscribe(getReloadObserver());
            boolean sortSubredditsShown = controllerSearch.getCurrentPage() == ControllerSearch.PAGE_SUBREDDITS || controllerSearch.getCurrentPage() == ControllerSearch.PAGE_SUBREDDITS_RECOMMENDED;
            menu.findItem(R.id.item_sort_subreddits).setEnabled(sortSubredditsShown);
            menu.findItem(R.id.item_sort_subreddits).setVisible(sortSubredditsShown);
            menu.findItem(R.id.item_sort).setEnabled(!sortSubredditsShown);
            menu.findItem(R.id.item_sort).setVisible(!sortSubredditsShown);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    final int count = controllerLinks.isOnSpecificSubreddit() ? pagerSearch.getChildCount() : pagerSearch.getChildCount() - 1;
    pagerAdapter = new PagerAdapter() {

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            return pagerSearch.getChildAt(position);
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
        // No need to destroy the RecyclerViews since they'll be reused for a new query
        }

        @Override
        public CharSequence getPageTitle(int position) {
            switch(position) {
                case ControllerSearch.PAGE_SUBREDDITS:
                    return getString(R.string.subreddit);
                case ControllerSearch.PAGE_LINKS:
                    return getString(R.string.all);
                case ControllerSearch.PAGE_LINKS_SUBREDDIT:
                    return controllerLinks.getSubredditName();
                case ControllerSearch.PAGE_SUBREDDITS_RECOMMENDED:
                    return getString(R.string.recommended);
            }
            return super.getPageTitle(position);
        }

        @Override
        public int getCount() {
            return count;
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }
    };
    pagerSearch.setAdapter(pagerAdapter);
    layoutTabs.setTabMode(TabLayout.MODE_SCROLLABLE);
    layoutTabs.setTabTextColors(themer.getColorFilterTextMuted().getColor(), themer.getColorFilterPrimary().getColor());
    layoutTabs.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    layoutTabs.setupWithViewPager(pagerSearch);
    pagerSearch.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(layoutTabs));
    return view;
}
Also used : ItemDecorationDivider(com.winsonchiu.reader.utils.ItemDecorationDivider) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) AdapterLink(com.winsonchiu.reader.links.AdapterLink) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Source(com.winsonchiu.reader.comments.Source) PagerAdapter(android.support.v4.view.PagerAdapter) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) TabLayout(android.support.design.widget.TabLayout) AppBarLayout(android.support.design.widget.AppBarLayout) SimpleCallbackBackground(com.winsonchiu.reader.utils.SimpleCallbackBackground) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) ViewGroup(android.view.ViewGroup) ViewPager(android.support.v4.view.ViewPager) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) RecyclerView(android.support.v7.widget.RecyclerView) Subreddit(com.winsonchiu.reader.data.reddit.Subreddit) Likes(com.winsonchiu.reader.data.reddit.Likes) AdapterLink(com.winsonchiu.reader.links.AdapterLink) Link(com.winsonchiu.reader.data.reddit.Link)

Example 3 with AdapterListener

use of com.winsonchiu.reader.adapter.AdapterListener in project Reader by TheKeeperOfPie.

the class FragmentInbox method onCreateView.

@SuppressWarnings("ResourceType")
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_inbox, container, false);
    listener = new ControllerInbox.Listener() {

        @Override
        public void setPage(Page page) {
            spinnerPage.setSelection(adapterInboxPage.getPages().indexOf(page));
        }

        @Override
        public RecyclerView.Adapter getAdapter() {
            return adapterInbox;
        }

        @Override
        public void setToolbarTitle(CharSequence title) {
            toolbar.setTitle(title);
        }

        @Override
        public void setRefreshing(boolean refreshing) {
            swipeRefreshInbox.setRefreshing(refreshing);
        }

        @Override
        public void post(Runnable runnable) {
            recyclerInbox.post(runnable);
        }
    };
    layoutCoordinator = (CoordinatorLayout) view.findViewById(R.id.layout_coordinator);
    layoutAppBar = (AppBarLayout) view.findViewById(R.id.layout_app_bar);
    int styleColorBackground = AppSettings.THEME_DARK.equals(mListener.getThemeBackground()) ? R.style.MenuDark : R.style.MenuLight;
    ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(new ThemeWrapper(activity, UtilsColor.getThemeForColor(getResources(), themer.getColorPrimary(), mListener)), styleColorBackground);
    toolbar = (Toolbar) activity.getLayoutInflater().cloneInContext(contextThemeWrapper).inflate(R.layout.toolbar, layoutAppBar, false);
    layoutAppBar.addView(toolbar);
    ((AppBarLayout.LayoutParams) toolbar.getLayoutParams()).setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
    toolbar.setTitleTextColor(themer.getColorFilterPrimary().getColor());
    toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
    toolbar.getNavigationIcon().mutate().setColorFilter(themer.getColorFilterPrimary());
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mListener.openDrawer();
        }
    });
    setUpOptionsMenu();
    floatingActionButtonNewMessage = (FloatingActionButton) view.findViewById(R.id.fab_new_message);
    floatingActionButtonNewMessage.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            FragmentNewMessage fragmentNewMessage = FragmentNewMessage.newInstance();
            getFragmentManager().beginTransaction().hide(FragmentInbox.this).add(R.id.frame_fragment, fragmentNewMessage, FragmentNewMessage.TAG).addToBackStack(null).commit();
        }
    });
    floatingActionButtonNewMessage.setColorFilter(themer.getColorFilterAccent());
    behaviorFloatingActionButton = new ScrollAwareFloatingActionButtonBehavior(activity, null, new ScrollAwareFloatingActionButtonBehavior.OnVisibilityChangeListener() {

        @Override
        public void onStartHideFromScroll() {
        }

        @Override
        public void onEndHideFromScroll() {
        }
    });
    ((CoordinatorLayout.LayoutParams) floatingActionButtonNewMessage.getLayoutParams()).setBehavior(behaviorFloatingActionButton);
    adapterInboxPage = new AdapterInboxPage(activity);
    spinnerPage = new AppCompatSpinner(contextThemeWrapper);
    toolbar.addView(spinnerPage);
    ((Toolbar.LayoutParams) spinnerPage.getLayoutParams()).setMarginEnd((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()));
    spinnerPage.setAdapter(adapterInboxPage);
    spinnerPage.setSelection(adapterInboxPage.getPages().indexOf(controllerInbox.getPage()));
    spinnerPage.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            controllerInbox.setPage(adapterInboxPage.getItem(position));
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    swipeRefreshInbox = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_inbox);
    swipeRefreshInbox.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            controllerInbox.reload();
        }
    });
    linearLayoutManager = new LinearLayoutManager(activity);
    recyclerInbox = (RecyclerView) view.findViewById(R.id.recycler_inbox);
    recyclerInbox.setHasFixedSize(true);
    recyclerInbox.setItemAnimator(new DefaultItemAnimator());
    recyclerInbox.getItemAnimator().setRemoveDuration(UtilsAnimation.EXPAND_ACTION_DURATION);
    recyclerInbox.setLayoutManager(linearLayoutManager);
    recyclerInbox.addItemDecoration(new ItemDecorationDivider(activity, ItemDecorationDivider.VERTICAL_LIST));
    AdapterListener adapterListener = new AdapterListener() {

        @Override
        public void scrollAndCenter(int position, int height) {
            linearLayoutManager.scrollToPositionWithOffset(position, 0);
        }

        @Override
        public void hideToolbar() {
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }

        @Override
        public void clearDecoration() {
            behaviorFloatingActionButton.animateOut(floatingActionButtonNewMessage);
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }

        @Override
        public void requestMore() {
            controllerInbox.loadMore();
        }

        @Override
        public void requestDisallowInterceptTouchEventVertical(boolean disallow) {
            recyclerInbox.requestDisallowInterceptTouchEvent(disallow);
            swipeRefreshInbox.requestDisallowInterceptTouchEvent(disallow);
        }

        @Override
        public void requestDisallowInterceptTouchEventHorizontal(boolean disallow) {
        }
    };
    AdapterCommentList.ViewHolderComment.Listener listenerComments = new AdapterCommentList.ViewHolderComment.Listener() {

        @Override
        public void onToggleComment(Comment comment) {
        }

        @Override
        public void onShowReplyEditor(Comment comment) {
        }

        @Override
        public void onEditComment(Comment comment, String text) {
        }

        @Override
        public void onSendComment(Comment comment, String text) {
        }

        @Override
        public void onMarkRead(Comment comment) {
        }

        @Override
        public void onLoadNestedComments(Comment comment) {
        }

        @Override
        public void onJumpToParent(Comment comment) {
        }

        @Override
        public void onViewProfile(Comment comment) {
        }

        @Override
        public void onCopyText(Comment comment) {
        }

        @Override
        public void onDeleteComment(Comment comment) {
        }

        @Override
        public void onReport(Comment comment) {
        }

        @Override
        public void onVoteComment(Comment comment, AdapterCommentList.ViewHolderComment viewHolderComment, Likes vote) {
        }

        @Override
        public void onSave(Comment comment) {
        }
    };
    if (adapterInbox == null) {
        adapterInbox = new AdapterInbox(controllerInbox, controllerUser, adapterListener, listenerComments, mListener.getEventListenerBase());
    }
    recyclerInbox.setAdapter(adapterInbox);
    return view;
}
Also used : ItemDecorationDivider(com.winsonchiu.reader.utils.ItemDecorationDivider) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) Page(com.winsonchiu.reader.data.Page) FragmentNewMessage(com.winsonchiu.reader.FragmentNewMessage) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) ContextThemeWrapper(android.view.ContextThemeWrapper) ThemeWrapper(com.winsonchiu.reader.theme.ThemeWrapper) AdapterCommentList(com.winsonchiu.reader.comments.AdapterCommentList) ScrollAwareFloatingActionButtonBehavior(com.winsonchiu.reader.utils.ScrollAwareFloatingActionButtonBehavior) ScrollAwareFloatingActionButtonBehavior(com.winsonchiu.reader.utils.ScrollAwareFloatingActionButtonBehavior) AppBarLayout(android.support.design.widget.AppBarLayout) Comment(com.winsonchiu.reader.data.reddit.Comment) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) AppCompatSpinner(android.support.v7.widget.AppCompatSpinner) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) ContextThemeWrapper(android.view.ContextThemeWrapper) AdapterView(android.widget.AdapterView) Likes(com.winsonchiu.reader.data.reddit.Likes)

Example 4 with AdapterListener

use of com.winsonchiu.reader.adapter.AdapterListener in project Reader by TheKeeperOfPie.

the class FragmentThreadList method onCreateView.

@SuppressWarnings("ResourceType")
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    initialize();
    view = bind(inflater.inflate(R.layout.fragment_thread_list, container, false));
    setUpToolbar();
    buttonExpandActions.setOnClickListener(v -> toggleLayoutActions());
    behaviorButtonExpandActions = new ScrollAwareFloatingActionButtonBehavior(getActivity(), null, new ScrollAwareFloatingActionButtonBehavior.OnVisibilityChangeListener() {

        @Override
        public void onStartHideFromScroll() {
            hideLayoutActions(0);
        }

        @Override
        public void onEndHideFromScroll() {
            buttonExpandActions.setImageResource(R.drawable.ic_unfold_more_white_24dp);
            buttonExpandActions.setColorFilter(themer.getColorFilterAccent());
        }
    });
    ((CoordinatorLayout.LayoutParams) buttonExpandActions.getLayoutParams()).setBehavior(behaviorButtonExpandActions);
    buttonJumpTop.setOnClickListener(v -> scrollToPositionWithOffset(0, 0));
    buttonJumpTop.setOnLongClickListener(v -> {
        Toast.makeText(getActivity(), getString(R.string.content_description_button_jump_top), Toast.LENGTH_SHORT).show();
        return false;
    });
    buttonClearViewed.setOnClickListener(v -> controllerLinks.clearViewed(historian));
    buttonClearViewed.setOnLongClickListener(v -> {
        Toast.makeText(getActivity(), getString(R.string.content_description_button_clear_viewed), Toast.LENGTH_SHORT).show();
        return false;
    });
    // Margin is included within shadow margin on pre-Lollipop, so remove all regular margin
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        ((CoordinatorLayout.LayoutParams) buttonExpandActions.getLayoutParams()).setMargins(0, 0, 0, 0);
        int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics());
        LinearLayout.LayoutParams layoutParamsJumpTop = (LinearLayout.LayoutParams) buttonJumpTop.getLayoutParams();
        layoutParamsJumpTop.setMargins(0, 0, 0, 0);
        buttonJumpTop.setLayoutParams(layoutParamsJumpTop);
        LinearLayout.LayoutParams layoutParamsClearViewed = (LinearLayout.LayoutParams) buttonClearViewed.getLayoutParams();
        layoutParamsClearViewed.setMargins(0, 0, 0, 0);
        buttonClearViewed.setLayoutParams(layoutParamsClearViewed);
        RelativeLayout.LayoutParams layoutParamsActions = (RelativeLayout.LayoutParams) layoutActions.getLayoutParams();
        layoutParamsActions.setMarginStart(margin);
        layoutParamsActions.setMarginEnd(margin);
        layoutActions.setLayoutParams(layoutParamsActions);
    }
    buttonExpandActions.setColorFilter(themer.getColorFilterAccent());
    buttonJumpTop.setColorFilter(themer.getColorFilterAccent());
    buttonClearViewed.setColorFilter(themer.getColorFilterAccent());
    swipeRefreshThreadList.setOnRefreshListener(() -> {
        controllerLinks.reload();
    });
    AdapterListener adapterListener = new AdapterListener() {

        @Override
        public void requestMore() {
            controllerLinks.loadMore();
        }

        @Override
        public void scrollAndCenter(int position, int height) {
            UtilsAnimation.scrollToPositionWithCentering(position, recyclerThreadList, height, 0, 0, false);
        }

        @Override
        public void hideToolbar() {
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }

        @Override
        public void clearDecoration() {
            behaviorButtonExpandActions.animateOut(buttonExpandActions);
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }

        @Override
        public void requestDisallowInterceptTouchEventVertical(boolean disallow) {
            recyclerThreadList.requestDisallowInterceptTouchEvent(disallow);
            swipeRefreshThreadList.requestDisallowInterceptTouchEvent(disallow);
            itemTouchHelper.select(null, CustomItemTouchHelper.ACTION_STATE_IDLE);
        }

        @Override
        public void requestDisallowInterceptTouchEventHorizontal(boolean disallow) {
            itemTouchHelper.setDisallow(disallow);
        }
    };
    AdapterLink.ViewHolderLink.Listener listener = new LinksListenerBase(mListener.getEventListenerBase()) {

        @Override
        public void onVote(Link link, AdapterLink.ViewHolderLink viewHolderLink, Likes vote) {
            mListener.getEventListenerBase().onVote(link, vote).subscribe(new ObserverEmpty<Link>() {

                @Override
                public void onError(Throwable e) {
                    controllerLinks.getEventHolder().getErrors().call(LinksError.VOTE);
                }

                @Override
                public void onNext(Link link) {
                    controllerLinks.update(link);
                }
            });
        }

        @Override
        public void onDelete(Link link) {
            new AlertDialog.Builder(getContext()).setTitle(R.string.delete_post).setMessage(link.getTitle()).setPositiveButton(R.string.yes, (dialog, which) -> {
                mListener.getEventListenerBase().onDelete(link).subscribe(new ObserverEmpty<Link>() {

                    @Override
                    public void onError(Throwable e) {
                        controllerLinks.getEventHolder().getErrors().call(LinksError.DELETE);
                    }

                    @Override
                    public void onNext(Link link) {
                        controllerLinks.remove(link);
                    }
                });
            }).setNegativeButton(R.string.no, null).show();
        }

        @Override
        public void onReport(Link link) {
            // TODO: Add link title
            new AlertDialog.Builder(getContext()).setTitle(R.string.report_title).setSingleChoiceItems(Report.getDisplayReasons(getResources()), -1, (dialog, which) -> {
                reportSelected = Report.values()[which];
            }).setPositiveButton(R.string.ok, (dialog, which) -> {
                if (reportSelected == Report.OTHER) {
                    View viewDialog = LayoutInflater.from(getContext()).inflate(R.layout.dialog_text_input, null, false);
                    final EditText editText = (EditText) viewDialog.findViewById(R.id.edit_text);
                    editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(100) });
                    new AlertDialog.Builder(getContext()).setView(viewDialog).setTitle(R.string.item_report).setPositiveButton(R.string.ok, (dialog1, which1) -> {
                        mListener.getEventListenerBase().onReport(link, editText.getText().toString()).subscribe(new ObserverError<String>() {

                            @Override
                            public void onError(Throwable e) {
                                controllerLinks.getEventHolder().getErrors().call(LinksError.REPORT);
                            }
                        });
                    }).setNegativeButton(R.string.cancel, (dialog1, which1) -> {
                        dialog1.dismiss();
                    }).show();
                } else if (reportSelected != null) {
                    mListener.getEventListenerBase().onReport(link, reportSelected.getReason()).subscribe(new ObserverError<String>() {

                        @Override
                        public void onError(Throwable e) {
                            controllerLinks.getEventHolder().getErrors().call(LinksError.REPORT);
                        }
                    });
                }
            }).setNegativeButton(R.string.cancel, null).show();
        }

        @Override
        public void onSave(Link link) {
            if (link.isSaved()) {
                mListener.getEventListenerBase().onUnsave(link).subscribe(new ObserverEmpty<Link>() {

                    @Override
                    public void onError(Throwable e) {
                        controllerLinks.getEventHolder().getErrors().call(LinksError.UNSAVE);
                    }

                    @Override
                    public void onNext(Link link) {
                        controllerLinks.update(link);
                    }
                });
            } else {
                mListener.getEventListenerBase().onSave(link).subscribe(new ObserverEmpty<Link>() {

                    @Override
                    public void onError(Throwable e) {
                        controllerLinks.getEventHolder().getErrors().call(LinksError.SAVE);
                    }

                    @Override
                    public void onNext(Link link) {
                        controllerLinks.update(link);
                    }
                });
            }
        }

        @Override
        public void onMarkNsfw(Link link) {
            if (link.isOver18()) {
                mListener.getEventListenerBase().onUnmarkNsfw(link).subscribe(new ObserverEmpty<Link>() {

                    @Override
                    public void onError(Throwable e) {
                        controllerLinks.getEventHolder().getErrors().call(LinksError.UNMARK_NSFW);
                    }

                    @Override
                    public void onNext(Link link) {
                        controllerLinks.update(link);
                    }
                });
            } else {
                mListener.getEventListenerBase().onMarkNsfw(link).subscribe(new ObserverEmpty<Link>() {

                    @Override
                    public void onError(Throwable e) {
                        controllerLinks.getEventHolder().getErrors().call(LinksError.MARK_NSFW);
                    }

                    @Override
                    public void onNext(Link link) {
                        controllerLinks.update(link);
                    }
                });
            }
        }
    };
    adapterLinkList = new AdapterLinkList(getActivity(), adapterListener, eventListenerHeader, listener);
    adapterLinkGrid = new AdapterLinkGrid(getActivity(), adapterListener, eventListenerHeader, listener);
    adapterLink = AppSettings.MODE_GRID.equals(preferences.getString(AppSettings.INTERFACE_MODE, AppSettings.MODE_GRID)) ? adapterLinkGrid : adapterLinkList;
    itemDecorationDivider = new ItemDecorationDivider(getActivity(), ItemDecorationDivider.VERTICAL_LIST);
    //        recyclerThreadList.setItemAnimator(null);
    resetAdapter(adapterLink);
    recyclerThreadList.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            switch(newState) {
                case RecyclerView.SCROLL_STATE_IDLE:
                case RecyclerView.SCROLL_STATE_DRAGGING:
                    picasso.resumeTag(AdapterLink.TAG_PICASSO);
                    break;
                case RecyclerView.SCROLL_STATE_SETTLING:
                    picasso.pauseTag(AdapterLink.TAG_PICASSO);
                    break;
            }
        }
    });
    itemTouchHelper = new CustomItemTouchHelper(new CustomItemTouchHelper.SimpleCallback(getActivity(), R.drawable.ic_visibility_off_white_24dp, ItemTouchHelper.START | ItemTouchHelper.END, ItemTouchHelper.START | ItemTouchHelper.END) {

        @Override
        public float getSwipeThreshold(RecyclerView.ViewHolder viewHolder) {
            if (layoutManager instanceof StaggeredGridLayoutManager) {
                return 1f / ((StaggeredGridLayoutManager) layoutManager).getSpanCount();
            }
            return 0.5f;
        }

        @Override
        public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
            if (viewHolder.getAdapterPosition() == 0) {
                return 0;
            }
            ViewGroup.LayoutParams layoutParams = viewHolder.itemView.getLayoutParams();
            if (layoutParams instanceof StaggeredGridLayoutManager.LayoutParams && !((StaggeredGridLayoutManager.LayoutParams) layoutParams).isFullSpan()) {
                int spanCount = layoutManager instanceof StaggeredGridLayoutManager ? ((StaggeredGridLayoutManager) layoutManager).getSpanCount() : 2;
                int spanIndex = ((StaggeredGridLayoutManager.LayoutParams) layoutParams).getSpanIndex() % spanCount;
                if (spanIndex == 0) {
                    return ItemTouchHelper.END;
                } else if (spanIndex == spanCount - 1) {
                    return ItemTouchHelper.START;
                }
            }
            return super.getSwipeDirs(recyclerView, viewHolder);
        }

        @Override
        public boolean isLongPressDragEnabled() {
            return false;
        }

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
            return false;
        }

        @Override
        public void onSwiped(final RecyclerView.ViewHolder viewHolder, int direction) {
            // Offset by 1 due to subreddit header
            Link link = controllerLinks.hideLink(viewHolder.getAdapterPosition());
            mListener.getEventListenerBase().hide(link);
            if (snackbar != null) {
                snackbar.dismiss();
            }
            SpannableString text = new SpannableString(link.isHidden() ? getString(R.string.link_hidden) : getString(R.string.link_shown));
            text.setSpan(new ForegroundColorSpan(themer.getColorFilterPrimary().getColor()), 0, text.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
            //noinspection ResourceType
            snackbar = Snackbar.make(recyclerThreadList, text, UtilsAnimation.SNACKBAR_DURATION).setActionTextColor(themer.getColorFilterPrimary().getColor()).setAction(R.string.undo, v -> {
                mListener.getEventListenerBase().hide(link);
                controllerLinks.reshowLastHiddenLink();
            });
            snackbar.getView().setBackgroundColor(themer.getColorPrimary());
            snackbar.show();
        }
    });
    itemTouchHelper.attachToRecyclerView(recyclerThreadList);
    recyclerThreadList.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {

        @Override
        public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
            //                rv.getChildViewHolder(rv.findChildViewUnder(e.getX(), e.getY()));
            return false;
        }

        @Override
        public void onTouchEvent(RecyclerView rv, MotionEvent e) {
        }

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        }
    });
    if (layoutManager instanceof LinearLayoutManager) {
        recyclerThreadList.setPadding(0, 0, 0, 0);
    } else {
        int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
        recyclerThreadList.setPadding(padding, 0, padding, 0);
    }
    textSidebar.setMovementMethod(LinkMovementMethod.getInstance());
    buttonSubscribe.setOnClickListener(v -> controllerLinks.subscribe());
    return view;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) ObserverEmpty(com.winsonchiu.reader.rx.ObserverEmpty) Historian(com.winsonchiu.reader.history.Historian) ViewPropertyAnimatorListener(android.support.v4.view.ViewPropertyAnimatorListener) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) LinkMovementMethod(android.text.method.LinkMovementMethod) UtilsAnimation(com.winsonchiu.reader.utils.UtilsAnimation) BindView(butterknife.BindView) Picasso(com.squareup.picasso.Picasso) Reddit(com.winsonchiu.reader.data.reddit.Reddit) Likes(com.winsonchiu.reader.data.reddit.Likes) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) View(android.view.View) Button(android.widget.Button) ViewCompat(android.support.v4.view.ViewCompat) ForegroundColorSpan(android.text.style.ForegroundColorSpan) Log(android.util.Log) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) ActionLog(com.winsonchiu.reader.rx.ActionLog) FloatingActionButton(android.support.design.widget.FloatingActionButton) CustomItemTouchHelper(com.winsonchiu.reader.utils.CustomItemTouchHelper) UtilsReddit(com.winsonchiu.reader.utils.UtilsReddit) ViewGroup(android.view.ViewGroup) R(com.winsonchiu.reader.R) UtilsColor(com.winsonchiu.reader.utils.UtilsColor) FragmentBase(com.winsonchiu.reader.FragmentBase) FragmentNewPost(com.winsonchiu.reader.FragmentNewPost) TextView(android.widget.TextView) RelativeLayout(android.widget.RelativeLayout) Time(com.winsonchiu.reader.data.reddit.Time) Nullable(android.support.annotation.Nullable) Snackbar(android.support.design.widget.Snackbar) InputFilter(android.text.InputFilter) User(com.winsonchiu.reader.data.reddit.User) Subscription(rx.Subscription) ObserverError(com.winsonchiu.reader.rx.ObserverError) Report(com.winsonchiu.reader.data.reddit.Report) AppBarLayout(android.support.design.widget.AppBarLayout) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) Spanned(android.text.Spanned) FastOutSlowInInterpolator(android.support.v4.view.animation.FastOutSlowInInterpolator) Subreddit(com.winsonchiu.reader.data.reddit.Subreddit) UtilsRx(com.winsonchiu.reader.utils.UtilsRx) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) AppSettings(com.winsonchiu.reader.AppSettings) MenuItem(android.view.MenuItem) GravityCompat(android.support.v4.view.GravityCompat) Inject(javax.inject.Inject) MotionEvent(android.view.MotionEvent) Toast(android.widget.Toast) Menu(android.view.Menu) Link(com.winsonchiu.reader.data.reddit.Link) ScrollAwareFloatingActionButtonBehavior(com.winsonchiu.reader.utils.ScrollAwareFloatingActionButtonBehavior) Build(android.os.Build) DrawerLayout(android.support.v4.widget.DrawerLayout) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) SpannableString(android.text.SpannableString) LayoutInflater(android.view.LayoutInflater) ControllerUser(com.winsonchiu.reader.ControllerUser) Sort(com.winsonchiu.reader.data.reddit.Sort) ItemDecorationDivider(com.winsonchiu.reader.utils.ItemDecorationDivider) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TextUtils(android.text.TextUtils) Thing(com.winsonchiu.reader.data.reddit.Thing) FragmentSearch(com.winsonchiu.reader.search.FragmentSearch) RecyclerView(android.support.v7.widget.RecyclerView) AlertDialog(android.support.v7.app.AlertDialog) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) Toolbar(android.support.v7.widget.Toolbar) ActivityMain(com.winsonchiu.reader.ActivityMain) FragmentListenerBase(com.winsonchiu.reader.FragmentListenerBase) Activity(android.app.Activity) UtilsTheme(com.winsonchiu.reader.utils.UtilsTheme) EditText(android.widget.EditText) ItemDecorationDivider(com.winsonchiu.reader.utils.ItemDecorationDivider) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) SpannableString(android.text.SpannableString) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ScrollAwareFloatingActionButtonBehavior(com.winsonchiu.reader.utils.ScrollAwareFloatingActionButtonBehavior) ScrollAwareFloatingActionButtonBehavior(com.winsonchiu.reader.utils.ScrollAwareFloatingActionButtonBehavior) AppBarLayout(android.support.design.widget.AppBarLayout) EditText(android.widget.EditText) InputFilter(android.text.InputFilter) ForegroundColorSpan(android.text.style.ForegroundColorSpan) SpannableString(android.text.SpannableString) RelativeLayout(android.widget.RelativeLayout) Link(com.winsonchiu.reader.data.reddit.Link) CustomItemTouchHelper(com.winsonchiu.reader.utils.CustomItemTouchHelper) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) ViewGroup(android.view.ViewGroup) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) MotionEvent(android.view.MotionEvent) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) ObserverError(com.winsonchiu.reader.rx.ObserverError) RecyclerView(android.support.v7.widget.RecyclerView) Likes(com.winsonchiu.reader.data.reddit.Likes) LinearLayout(android.widget.LinearLayout)

Example 5 with AdapterListener

use of com.winsonchiu.reader.adapter.AdapterListener in project Reader by TheKeeperOfPie.

the class FragmentCommentsInner method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    scrollToPaddingTop = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics());
    scrollToPaddingBottom = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 56, getResources().getDisplayMetrics());
    layoutRoot = (CustomFrameLayout) inflater.inflate(R.layout.fragment_comments_inner, container, false);
    CallbackYouTubeDestruction callbackYouTubeDestruction = () -> {
        adapterCommentList.destroyYouTubePlayerFragments();
        adapterLink.destroyYouTubePlayerFragments();
    };
    swipeRefreshCommentList = (SwipeRefreshLayout) layoutRoot.findViewById(R.id.swipe_refresh_comment_list);
    swipeRefreshCommentList.setOnRefreshListener(() -> controllerComments.reloadAllComments());
    linearLayoutManager = new LinearLayoutManager(getActivity());
    recyclerCommentList = (RecyclerView) layoutRoot.findViewById(R.id.recycler_comment_list);
    recyclerCommentList.setLayoutManager(linearLayoutManager);
    recyclerCommentList.setHasFixedSize(true);
    recyclerCommentList.setItemAnimator(null);
    AdapterListener adapterListenerComment = new AdapterListener() {

        @Override
        public void scrollAndCenter(int position, int height) {
            linearLayoutManager.scrollToPositionWithOffset(position, 0);
        }

        @Override
        public void hideToolbar() {
            callback.hideToolbar();
        }

        @Override
        public void clearDecoration() {
            callback.clearDecoration();
        }

        @Override
        public void requestMore() {
            controllerComments.loadMoreComments();
        }

        @Override
        public void requestDisallowInterceptTouchEventVertical(boolean disallow) {
            recyclerCommentList.requestDisallowInterceptTouchEvent(disallow);
            swipeRefreshCommentList.requestDisallowInterceptTouchEvent(disallow);
        }

        @Override
        public void requestDisallowInterceptTouchEventHorizontal(boolean disallow) {
        }
    };
    AdapterLink.ViewHolderLink.Listener listenerLink = new LinksListenerBase(mListener.getEventListenerBase()) {

        @Override
        public void onVote(Link link, AdapterLink.ViewHolderLink viewHolderLink, Likes vote) {
        }

        @Override
        public void onDelete(Link link) {
        }

        @Override
        public void onReport(Link link) {
        }

        @Override
        public void onSave(Link link) {
        }

        @Override
        public void onMarkNsfw(Link link) {
        }
    };
    AdapterCommentList.ViewHolderComment.Listener listenerComment = new AdapterCommentList.ViewHolderComment.Listener() {

        @Override
        public void onToggleComment(Comment comment) {
            controllerComments.toggleComment(comment);
        }

        @Override
        public void onShowReplyEditor(Comment comment) {
        }

        @Override
        public void onEditComment(Comment comment, String text) {
        }

        @Override
        public void onSendComment(Comment comment, String text) {
        }

        @Override
        public void onMarkRead(Comment comment) {
        }

        @Override
        public void onLoadNestedComments(Comment comment) {
            controllerComments.loadNestedComments(comment);
        }

        @Override
        public void onJumpToParent(Comment comment) {
            controllerComments.jumpToParent(comment);
        }

        @Override
        public void onViewProfile(Comment comment) {
        }

        @Override
        public void onCopyText(Comment comment) {
        }

        @Override
        public void onDeleteComment(Comment comment) {
        }

        @Override
        public void onReport(Comment comment) {
            // TODO: Add comment text
            new AlertDialog.Builder(getContext()).setTitle(R.string.report_title).setSingleChoiceItems(Report.getDisplayReasons(getResources()), -1, (dialog, which) -> {
                reportSelected = Report.values()[which];
            }).setPositiveButton(R.string.ok, (dialog, which) -> {
                if (reportSelected == Report.OTHER) {
                    View viewDialog = LayoutInflater.from(getContext()).inflate(R.layout.dialog_text_input, null, false);
                    final EditText editText = (EditText) viewDialog.findViewById(R.id.edit_text);
                    editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(100) });
                    new AlertDialog.Builder(getContext()).setView(viewDialog).setTitle(R.string.item_report).setPositiveButton(R.string.ok, (dialog1, which1) -> {
                        mListener.getEventListenerBase().onReport(link, editText.getText().toString()).subscribe(new ObserverError<String>() {

                            @Override
                            public void onError(Throwable e) {
                                controllerComments.getEventHolder().getErrors().call(CommentsError.REPORT);
                            }
                        });
                    }).setNegativeButton(R.string.cancel, (dialog1, which1) -> {
                        dialog1.dismiss();
                    }).show();
                } else if (reportSelected != null) {
                    mListener.getEventListenerBase().onReport(link, reportSelected.getReason()).subscribe(new ObserverError<String>() {

                        @Override
                        public void onError(Throwable e) {
                            controllerComments.getEventHolder().getErrors().call(CommentsError.REPORT);
                        }
                    });
                }
            }).setNegativeButton(R.string.cancel, null).show();
        }

        @Override
        public void onVoteComment(Comment comment, AdapterCommentList.ViewHolderComment viewHolderComment, Likes vote) {
        }

        @Override
        public void onSave(Comment comment) {
        }
    };
    adapterCommentList = new AdapterCommentList(getActivity(), adapterListenerComment, listenerComment, listenerLink, youTubeListener, callbackYouTubeDestruction, getArguments().getBoolean(ARG_IS_GRID, false), getArguments().getString(ARG_FIRST_LINK_NAME), getArguments().getInt(ARG_COLOR_LINK, 0), getArguments().getBoolean(ARG_ACTIONS_EXPANDED, false));
    observer = new RecyclerView.AdapterDataObserver() {

        @Override
        public void onItemRangeChanged(int positionStart, int itemCount) {
            super.onItemRangeChanged(positionStart, itemCount);
            if (positionStart == 0) {
                callback.releaseYouTube();
            }
        }
    };
    adapterCommentList.registerAdapterDataObserver(observer);
    recyclerCommentList.setAdapter(adapterCommentList);
    layoutManagerLink = new LinearLayoutManagerWrapHeight(getActivity(), LinearLayoutManager.VERTICAL, false);
    layoutManagerLink.setOnSizeChangedListener((width, height, oldWidth, oldHeight) -> {
        if (postExpanded && targetExpandPostHeight == 0) {
            targetExpandPostHeight = height + heightExpandHandle;
            postExpanded = false;
            expandPost(true);
        }
    });
    AdapterListener adapterListenerLink = new AdapterListener() {

        @Override
        public void scrollAndCenter(int position, int height) {
            layoutManagerLink.scrollToPositionWithOffset(position, 0);
        }

        @Override
        public void hideToolbar() {
            callback.hideToolbar();
        }

        @Override
        public void clearDecoration() {
            callback.clearDecoration();
        }

        @Override
        public void requestMore() {
        }

        @Override
        public void requestDisallowInterceptTouchEventVertical(boolean disallow) {
            recyclerLink.requestDisallowInterceptTouchEvent(disallow);
        }

        @Override
        public void requestDisallowInterceptTouchEventHorizontal(boolean disallow) {
        }
    };
    adapterLink = new AdapterLinkHeader(getActivity(), controllerComments, adapterListenerLink, listenerLink, youTubeListener, callbackYouTubeDestruction, getArguments().getBoolean(ARG_IS_GRID, false), getArguments().getString(ARG_FIRST_LINK_NAME), getArguments().getInt(ARG_COLOR_LINK, 0), getArguments().getBoolean(ARG_ACTIONS_EXPANDED, false));
    final GestureDetectorCompat gestureDetectorExpand = new GestureDetectorCompat(getActivity(), new GestureDetector.SimpleOnGestureListener() {

        private float startY;

        private int startHeight;

        @Override
        public boolean onDown(MotionEvent e) {
            if (targetExpandPostHeight == 0) {
                targetExpandPostHeight = layoutManagerLink.getFirstChildHeight() + heightExpandHandle;
            }
            if (e.getY() > imageExpandIndicator.getY() && e.getY() < imageExpandIndicator.getY() + heightExpandHandle) {
                startY = e.getY();
                startHeight = targetExpandPostHeight;
            } else {
                startY = 0;
            }
            return super.onDown(e);
        }

        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            if (startY == 0) {
                return super.onScroll(e1, e2, distanceX, distanceY);
            }
            float distance = e2.getY() - startY;
            targetExpandPostHeight = (int) Math.min(startHeight + distance, layoutRoot.getHeight());
            layoutExpandPostInner.getLayoutParams().height = targetExpandPostHeight;
            layoutExpandPostInner.requestLayout();
            return super.onScroll(e1, e2, distanceX, distanceY);
        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            if (startY == 0) {
                return super.onFling(e1, e2, velocityX, velocityY);
            }
            if (velocityY < -expandFlingThreshold) {
                startY = 0;
                expandPost(false);
                return true;
            } else if (velocityY > expandFlingThreshold) {
                startY = 0;
                targetExpandPostHeight = layoutRoot.getHeight() - heightExpandHandle;
                postExpanded = false;
                expandPost(true);
                return true;
            }
            return super.onFling(e1, e2, velocityX, velocityY);
        }
    });
    heightExpandHandle = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 33, getResources().getDisplayMetrics());
    expandFlingThreshold = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, EXPAND_FLING_THRESHOLD, getResources().getDisplayMetrics());
    layoutExpandPostInner = (ViewGroup) layoutRoot.findViewById(R.id.layout_expand_post_inner);
    imageExpandIndicator = (ImageView) layoutRoot.findViewById(R.id.image_expand_indicator);
    imageExpandIndicator.setColorFilter(themer.getColorFilterIcon());
    layoutRoot.setDispatchTouchListener((v, event) -> gestureDetectorExpand.onTouchEvent(event));
    recyclerLink = (RecyclerView) layoutRoot.findViewById(R.id.recycler_link);
    recyclerLink.setLayoutManager(layoutManagerLink);
    recyclerLink.setItemAnimator(null);
    if (savedInstanceState != null) {
        String youtubeId = savedInstanceState.getString(ARG_YOUTUBE_ID, null);
        if (!TextUtils.isEmpty(youtubeId)) {
            callback.loadYouTubeVideo(youtubeId, savedInstanceState.getInt(ARG_YOUTUBE_TIME, 0));
        }
    }
    if (savedInstanceState != null && savedInstanceState.containsKey("Link")) {
        adapterLink.setAnimationFinished(true);
        adapterCommentList.setAnimationFinished(true);
        controllerComments.setLinkFromCache((Link) savedInstanceState.get("Link"));
    } else if (link != null) {
        controllerComments.setLink(link);
        link = null;
    }
    adapterCommentList.setData(controllerComments.getData());
    if (animationFinished) {
        setAnimationFinished(true);
    }
    return layoutRoot;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Context(android.content.Context) GestureDetector(android.view.GestureDetector) CallbackYouTubeDestruction(com.winsonchiu.reader.utils.CallbackYouTubeDestruction) Bundle(android.os.Bundle) LinksListenerBase(com.winsonchiu.reader.links.LinksListenerBase) CustomApplication(com.winsonchiu.reader.CustomApplication) AdapterLink(com.winsonchiu.reader.links.AdapterLink) UtilsRx(com.winsonchiu.reader.utils.UtilsRx) ImageView(android.widget.ImageView) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) UtilsList(com.winsonchiu.reader.utils.UtilsList) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Animator(android.animation.Animator) CustomFrameLayout(com.winsonchiu.reader.views.CustomFrameLayout) UtilsAnimation(com.winsonchiu.reader.utils.UtilsAnimation) Likes(com.winsonchiu.reader.data.reddit.Likes) MotionEvent(android.view.MotionEvent) Link(com.winsonchiu.reader.data.reddit.Link) View(android.view.View) Comment(com.winsonchiu.reader.data.reddit.Comment) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) RectF(android.graphics.RectF) LinearLayoutManagerWrapHeight(com.winsonchiu.reader.utils.LinearLayoutManagerWrapHeight) LayoutInflater(android.view.LayoutInflater) YouTubeListener(com.winsonchiu.reader.utils.YouTubeListener) Sort(com.winsonchiu.reader.data.reddit.Sort) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TextUtils(android.text.TextUtils) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ComponentActivity(com.winsonchiu.reader.dagger.components.ComponentActivity) ViewGroup(android.view.ViewGroup) R(com.winsonchiu.reader.R) RecyclerView(android.support.v7.widget.RecyclerView) FragmentBase(com.winsonchiu.reader.FragmentBase) AlertDialog(android.support.v7.app.AlertDialog) TypedValue(android.util.TypedValue) ActivityMain(com.winsonchiu.reader.ActivityMain) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) FragmentListenerBase(com.winsonchiu.reader.FragmentListenerBase) RxAdapterEvent(com.winsonchiu.reader.adapter.RxAdapterEvent) Nullable(android.support.annotation.Nullable) InputFilter(android.text.InputFilter) Activity(android.app.Activity) Subscription(rx.Subscription) EditText(android.widget.EditText) ObserverError(com.winsonchiu.reader.rx.ObserverError) ValueAnimator(android.animation.ValueAnimator) Report(com.winsonchiu.reader.data.reddit.Report) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) YouTubeListener(com.winsonchiu.reader.utils.YouTubeListener) CallbackYouTubeDestruction(com.winsonchiu.reader.utils.CallbackYouTubeDestruction) LinearLayoutManagerWrapHeight(com.winsonchiu.reader.utils.LinearLayoutManagerWrapHeight) GestureDetector(android.view.GestureDetector) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) EditText(android.widget.EditText) Comment(com.winsonchiu.reader.data.reddit.Comment) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) InputFilter(android.text.InputFilter) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) MotionEvent(android.view.MotionEvent) LinksListenerBase(com.winsonchiu.reader.links.LinksListenerBase) ObserverError(com.winsonchiu.reader.rx.ObserverError) RecyclerView(android.support.v7.widget.RecyclerView) Likes(com.winsonchiu.reader.data.reddit.Likes) AdapterLink(com.winsonchiu.reader.links.AdapterLink) Link(com.winsonchiu.reader.data.reddit.Link)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 RecyclerView (android.support.v7.widget.RecyclerView)6 View (android.view.View)6 AdapterListener (com.winsonchiu.reader.adapter.AdapterListener)6 Likes (com.winsonchiu.reader.data.reddit.Likes)6 AppBarLayout (android.support.design.widget.AppBarLayout)5 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)5 Link (com.winsonchiu.reader.data.reddit.Link)5 ItemDecorationDivider (com.winsonchiu.reader.utils.ItemDecorationDivider)5 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)4 ViewGroup (android.view.ViewGroup)4 ImageView (android.widget.ImageView)4 AdapterLink (com.winsonchiu.reader.links.AdapterLink)4 SpannableString (android.text.SpannableString)3 ForegroundColorSpan (android.text.style.ForegroundColorSpan)3 ContextThemeWrapper (android.view.ContextThemeWrapper)3 ActivityMain (com.winsonchiu.reader.ActivityMain)3 Comment (com.winsonchiu.reader.data.reddit.Comment)3 Sort (com.winsonchiu.reader.data.reddit.Sort)3 ThemeWrapper (com.winsonchiu.reader.theme.ThemeWrapper)3