Java Code Examples for androidx.recyclerview.widget.RecyclerView#addOnScrollListener()

The following examples show how to use androidx.recyclerview.widget.RecyclerView#addOnScrollListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecyclerViewFastScroller.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
public void setRecyclerView(final @Nullable RecyclerView recyclerView) {
  if (this.recyclerView != null) {
    this.recyclerView.removeOnScrollListener(onScrollListener);
  }
  this.recyclerView = recyclerView;
  if (recyclerView != null) {
    recyclerView.addOnScrollListener(onScrollListener);
    recyclerView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
      @Override
      public boolean onPreDraw() {
        recyclerView.getViewTreeObserver().removeOnPreDrawListener(this);
        if (handle.isSelected()) return true;
        final int verticalScrollOffset = recyclerView.computeVerticalScrollOffset();
        final int verticalScrollRange = recyclerView.computeVerticalScrollRange();
        float proportion = (float)verticalScrollOffset / ((float)verticalScrollRange - height);
        setBubbleAndHandlePosition(height * proportion);
        return true;
      }
    });
  }
}
 
Example 2
Source File: RecyclerViewFastScroller.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
public void setRecyclerView(final @NonNull RecyclerView recyclerView) {
  if (this.recyclerView != null) {
    this.recyclerView.removeOnScrollListener(onScrollListener);
  }
  this.recyclerView = recyclerView;
  recyclerView.addOnScrollListener(onScrollListener);
  recyclerView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
    @Override
    public boolean onPreDraw() {
      recyclerView.getViewTreeObserver().removeOnPreDrawListener(this);
      if (handle.isSelected()) return true;
      final int verticalScrollOffset = recyclerView.computeVerticalScrollOffset();
      final int verticalScrollRange = recyclerView.computeVerticalScrollRange();
      float proportion = (float)verticalScrollOffset / ((float)verticalScrollRange - height);
      setBubbleAndHandlePosition(height * proportion);
      return true;
    }
  });
}
 
Example 3
Source File: FastScroller.java    From HaoReader with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Set the {@link RecyclerView} associated with this {@link FastScroller}. This allows the
 * FastScroller to set its layout parameters and listen for scroll changes.
 *
 * @param recyclerView The {@link RecyclerView} to attach, cannot be null
 * @see #detachRecyclerView()
 */
public void attachRecyclerView(@NonNull RecyclerView recyclerView) {
    this.recyclerView = recyclerView;

    if (getParent() instanceof ViewGroup) {
        setLayoutParams((ViewGroup) getParent());
    } else if (recyclerView.getParent() instanceof ViewGroup) {
        ViewGroup viewGroup = (ViewGroup) recyclerView.getParent();
        viewGroup.addView(this);
        setLayoutParams(viewGroup);
    }

    recyclerView.addOnScrollListener(scrollListener);


    layoutChangeListener = (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom)
            -> setViewPositions(getScrollProportion(FastScroller.this.recyclerView), false);

    recyclerView.addOnLayoutChangeListener(layoutChangeListener);
}
 
Example 4
Source File: SelectEntriesActivity.java    From Aegis with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_select_entries);

    ActionBar bar = getSupportActionBar();
    bar.setHomeAsUpIndicator(R.drawable.ic_close);
    bar.setDisplayHomeAsUpEnabled(true);

    _adapter = new ImportEntriesAdapter();
    RecyclerView entriesView = findViewById(R.id.list_entries);
    entriesView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            onScroll(dx, dy);
        }
    });

    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    entriesView.setLayoutManager(layoutManager);
    entriesView.setAdapter(_adapter);
    entriesView.setNestedScrollingEnabled(false);

    Intent intent = getIntent();
    List<ImportEntry> entries = (ArrayList<ImportEntry>) intent.getSerializableExtra("entries");
    List<DatabaseImporterEntryException> errors = (ArrayList<DatabaseImporterEntryException>) intent.getSerializableExtra("errors");

    for (ImportEntry entry : entries) {
        _adapter.addEntry(entry);
    }

    if (errors.size() > 0) {
        showErrorDialog(errors);
    }

    FloatingActionButton fabMenu = findViewById(R.id.fab);
    fabMenu.setOnClickListener(v -> returnSelectedEntries());
    _fabScrollHelper = new FabScrollHelper(fabMenu);
}
 
Example 5
Source File: RecyclerViewScrollbar.java    From revolution-irc with GNU General Public License v3.0 5 votes vote down vote up
public void setRecyclerView(RecyclerView recyclerView) {
    if (mRecyclerView != null) {
        mRecyclerView.removeOnScrollListener(mScrollListener);
        mRecyclerView.removeOnLayoutChangeListener(mLayoutChangeListener);
    }

    mRecyclerView = recyclerView;

    recyclerView.addOnScrollListener(mScrollListener);
    recyclerView.addOnLayoutChangeListener(mLayoutChangeListener);
    registerAdapterDataObserver();
}
 
Example 6
Source File: CarouselDecorator.java    From Hentoid with Apache License 2.0 5 votes vote down vote up
public void decorate(RecyclerView recyclerView) {
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapter);
    recyclerView.addOnScrollListener(new CarouselOnScrollListener());

    LinearSnapHelper snapHelper = new LinearSnapHelper();
    snapHelper.attachToRecyclerView(recyclerView);
}
 
Example 7
Source File: EpoxyVisibilityTracker.java    From epoxy with Apache License 2.0 5 votes vote down vote up
/**
 * Attach the tracker.
 *
 * @param recyclerView The recyclerview that the EpoxyController has its adapter added to.
 */
public void attach(@NonNull RecyclerView recyclerView) {
  attachedRecyclerView = recyclerView;
  recyclerView.addOnScrollListener(this.listener);
  recyclerView.addOnLayoutChangeListener(this.listener);
  recyclerView.addOnChildAttachStateChangeListener(this.listener);
  setTracker(recyclerView, this);
}
 
Example 8
Source File: MainActivity.java    From AndroidMaterialDialog with Apache License 2.0 5 votes vote down vote up
@Override
protected final void onResume() {
    super.onResume();
    fragment = (PreferenceFragment) getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        RecyclerView recyclerView = fragment.getListView();
        recyclerView.addOnScrollListener(createScrollListener());
    }
}
 
Example 9
Source File: SlimAdapter.java    From SlimAdapter with MIT License 5 votes vote down vote up
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
    super.onAttachedToRecyclerView(recyclerView);
    if (moreLoader != null) {
        recyclerView.addOnScrollListener(moreLoader);
    }
}
 
Example 10
Source File: FrageMyTopic.java    From Ruisi with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    Bundle bundle = getArguments();//从activity传过来的Bundle
    int uid = 0;
    if (bundle != null) {
        uid = bundle.getInt("uid", 0);
        String username = bundle.getString("username", "我的");
        if (uid == 0) {
            title = "我的帖子";
        } else {
            title = username + "的帖子";
        }
    }
    initToolbar(true, title);
    RecyclerView recyclerView = mRootView.findViewById(R.id.recycler_view);
    recyclerView.setHasFixedSize(true);
    SwipeRefreshLayout refreshLayout = mRootView.findViewById(R.id.refresh_layout);
    refreshLayout.setEnabled(false);
    String myUid = App.getUid(getActivity());

    url = "home.php?mod=space&uid=" + (uid > 0 ? uid : myUid) + "&do=thread&view=me&mobile=2";
    datas = new ArrayList<>();
    adapter = new MyPostsListAdapter(getActivity(), datas);

    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    recyclerView.addItemDecoration(new MyListDivider(getActivity(), MyListDivider.VERTICAL));
    recyclerView.addOnScrollListener(new LoadMoreListener(layoutManager, this, 10));
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapter);
    refresh();
    return mRootView;
}
 
Example 11
Source File: HideActivity.java    From PagerBottomTabStrip with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    RecyclerView recyclerView = view.findViewById(R.id.recyclerView);
    recyclerView.setAdapter(new TestAdapter());
    recyclerView.addItemDecoration(new DividerItemDecoration(view.getContext(), DividerItemDecoration.VERTICAL));
    recyclerView.addOnScrollListener(new ListScrollListener());
}
 
Example 12
Source File: StickyHeaderDecoration.java    From RecyclerExt with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the ItemDecoration that performs the functionality to
 * have the current header view sticky (persisted at the start of the
 * RecyclerView).
 * <p>
 * <b>NOTE:</b> This will tightly couple to the <code>parent</code> and the
 * adapter.  If you intend to swap out adapters you will need to first call
 * {@link #dispose()} then replace this decoration with a new one.
 *
 * @param parent The RecyclerView to couple the ItemDecoration to
 */
public StickyHeaderDecoration(@NonNull RecyclerView parent) {
    if (parent.getAdapter() == null || !(parent.getAdapter() instanceof HeaderApi)) {
        throw new ExceptionInInitializerError("The Adapter must be set before this is created and extend RecyclerHeaderAdapter, RecyclerHeaderListAdapter or implement HeaderApi");
    }

    this.parent = parent;
    adapter = parent.getAdapter();
    headerApi = (HeaderApi) adapter;
    dataObserver = new StickyHeaderDataObserver(this);
    scrollListener = new StickyHeaderScrollListener(this);

    adapter.registerAdapterDataObserver(dataObserver);
    parent.addOnScrollListener(scrollListener);
}
 
Example 13
Source File: EndlessRecyclerAdapter.java    From GestureViews with Apache License 2.0 4 votes vote down vote up
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
    super.onAttachedToRecyclerView(recyclerView);
    recyclerView.addOnScrollListener(scrollListener);
    loadNextItemsIfNeeded(recyclerView);
}
 
Example 14
Source File: AsyncAdapter.java    From financisto with GNU General Public License v2.0 4 votes vote down vote up
public void onStart(RecyclerView recyclerView) {
    recyclerView.addOnScrollListener(onScrollListener);
    listUtil.refresh();
}
 
Example 15
Source File: GithubFragment.java    From RendererRecyclerViewAdapter with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(final LayoutInflater inflater,
                         @Nullable final ViewGroup container,
                         @Nullable final Bundle savedInstanceState) {
	View inflate = inflater.inflate(R.layout.fragment_github, container, false);

	mGithubPresenter = new GithubPresenter(
			getUIRouter(),
			getMenuController(),
			MainManager.getInstance().getStargazersManager(),
			MainManager.getInstance().getForksManager(),
			mMainPresenterView
	);

	mSwipeToRefresh = (SwipeRefreshLayout) inflate.findViewById(R.id.refresh);
	mSwipeToRefresh.setOnRefreshListener(() -> mGithubPresenter.onRefresh());

	mRecyclerViewAdapter = new RendererRecyclerViewAdapter();
	mRecyclerViewAdapter.setDiffCallback(new ItemsDiffCallback());
	mRecyclerViewAdapter.registerRenderer(new LoadMoreViewBinder(R.layout.item_load_more));
	mRecyclerViewAdapter.registerRenderer(createStargazerRenderer(R.layout.item_user_full_width));
	mRecyclerViewAdapter.registerRenderer(createListRenderer()
			.registerRenderer(createForkRenderer())
			.registerRenderer(createStargazerRenderer(R.layout.item_user_150))
	);

	mRecyclerViewAdapter.registerRenderer(new ViewBinder<>(
			R.layout.item_category,
			CategoryModel.class,
			(model, finder, payloads) -> finder
					.find(R.id.title, (ViewProvider<TextView>) view -> view.setText(model.getName()))
					.setOnClickListener(R.id.viewAll, (v -> mGithubPresenter.onCategoryClicked(model)))
	));

	mLayoutManager = new GridLayoutManager(getContext(), MAX_SPAN_COUNT);
	mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
		@Override
		public int getSpanSize(final int position) {
			final Type type = mRecyclerViewAdapter.getType(position);
			if (type.equals(ForkModel.class) || type.equals(StargazerModel.class)) {
				return 1;
			}
			return 3;
		}
	});

	mRecyclerView = (RecyclerView) inflate.findViewById(R.id.recycler_view);
	mRecyclerView.setLayoutManager(mLayoutManager);
	mRecyclerView.setAdapter(mRecyclerViewAdapter);
	mRecyclerView.addItemDecoration(new MyItemDecoration());
	mRecyclerView.addOnScrollListener(new EndlessScrollListener() {
		@Override
		public void onLoadMore(final int page, final int totalItemsCount) {
			mGithubPresenter.onLoadMore();
		}
	});
	return inflate;
}
 
Example 16
Source File: InteractionUtil.java    From litho with Apache License 2.0 4 votes vote down vote up
public Scroller(RecyclerView recyclerView) {
  mRecyclerView = recyclerView;
  recyclerView.addOnScrollListener(this);
}
 
Example 17
Source File: AppKeysActivity.java    From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_keys);
    mViewModel = new ViewModelProvider(this, mViewModelFactory).get(AppKeysViewModel.class);

    //Bind ui
    ButterKnife.bind(this);

    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    //noinspection ConstantConditions
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    final ExtendedFloatingActionButton fab = findViewById(R.id.fab_add);
    final RecyclerView appKeysRecyclerView = findViewById(R.id.recycler_view_keys);
    appKeysRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    final DividerItemDecoration dividerItemDecoration =
            new DividerItemDecoration(appKeysRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
    appKeysRecyclerView.addItemDecoration(dividerItemDecoration);
    appKeysRecyclerView.setItemAnimator(new DefaultItemAnimator());

    final Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
        switch (bundle.getInt(EXTRA_DATA)) {
            case MANAGE_APP_KEY:
                break;
            case ADD_APP_KEY:
                getSupportActionBar().setTitle(R.string.title_select_app_key);
                fab.hide();
                mAdapter = new ManageAppKeyAdapter(this, mViewModel.getNetworkLiveData());
                mAdapter.setOnItemClickListener(this);
                appKeysRecyclerView.setAdapter(mAdapter);
                setUpObserver();
                break;
            case BIND_APP_KEY:
            case PUBLICATION_APP_KEY:
                getSupportActionBar().setTitle(R.string.title_select_app_key);
                fab.hide();
                //Get selected mesh node
                final ProvisionedMeshNode node = mViewModel.getSelectedMeshNode().getValue();
                if (node != null) {
                    final List<NodeKey> applicationKeys = node.getAddedAppKeys();
                    if (!applicationKeys.isEmpty()) {
                        mAdapter = new ManageAppKeyAdapter(mViewModel.getNetworkLiveData().getAppKeys(), applicationKeys);
                        mAdapter.setOnItemClickListener(this);
                        appKeysRecyclerView.setAdapter(mAdapter);
                    } else {
                        final TextView textView = mEmptyView.findViewById(R.id.rationale);
                        textView.setText(R.string.no_added_app_keys_rationale);
                        mEmptyView.setVisibility(View.VISIBLE);
                    }
                }
                break;
        }
    } else {
        getSupportActionBar().setTitle(R.string.title_manage_app_keys);
        final ItemTouchHelper.Callback itemTouchHelperCallback = new RemovableItemTouchHelperCallback(this);
        final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemTouchHelperCallback);
        itemTouchHelper.attachToRecyclerView(appKeysRecyclerView);
        mAdapter = new ManageAppKeyAdapter(this, mViewModel.getNetworkLiveData());
        mAdapter.setOnItemClickListener(this);
        appKeysRecyclerView.setAdapter(mAdapter);
        setUpObserver();
    }


    fab.setOnClickListener(v -> {
        final Intent intent = new Intent(this, AddAppKeyActivity.class);
        startActivity(intent);
    });

    appKeysRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(@NonNull final RecyclerView recyclerView, final int dx, final int dy) {
            super.onScrolled(recyclerView, dx, dy);
            final LinearLayoutManager m = (LinearLayoutManager) recyclerView.getLayoutManager();
            if (m != null) {
                if (m.findFirstCompletelyVisibleItemPosition() == 0) {
                    fab.extend();
                } else {
                    fab.shrink();
                }
            }
        }
    });
}
 
Example 18
Source File: GroupsFragment.java    From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) {
    @SuppressLint("InflateParams") final View rootView = inflater.inflate(R.layout.fragment_groups, null);
    mViewModel = new ViewModelProvider(requireActivity(), mViewModelFactory).get(SharedViewModel.class);
    ButterKnife.bind(this, rootView);

    final ExtendedFloatingActionButton fab = rootView.findViewById(R.id.fab_add_group);

    // Configure the recycler view
    final RecyclerView recyclerViewGroups = rootView.findViewById(R.id.recycler_view_groups);
    recyclerViewGroups.setLayoutManager(new LinearLayoutManager(requireContext()));
    final DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerViewGroups.getContext(), DividerItemDecoration.VERTICAL);
    recyclerViewGroups.addItemDecoration(dividerItemDecoration);
    final ItemTouchHelper.Callback itemTouchHelperCallback = new RemovableItemTouchHelperCallback(this);
    final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemTouchHelperCallback);
    itemTouchHelper.attachToRecyclerView(recyclerViewGroups);
    final GroupAdapter adapter = new GroupAdapter(requireContext());
    adapter.setOnItemClickListener(this);
    recyclerViewGroups.setAdapter(adapter);

    mViewModel.getNetworkLiveData().observe(getViewLifecycleOwner(), meshNetworkLiveData -> {
        if (meshNetworkLiveData != null) {
            if (meshNetworkLiveData.getMeshNetwork().getGroups().isEmpty()) {
                mEmptyView.setVisibility(View.VISIBLE);
            } else {
                mEmptyView.setVisibility(View.INVISIBLE);
            }
        }
    });

    mViewModel.getGroups().observe(getViewLifecycleOwner(), groups -> {
        final MeshNetwork network = mViewModel.getNetworkLiveData().getMeshNetwork();
        adapter.updateAdapter(network, groups);
    });

    fab.setOnClickListener(v -> {
        DialogFragmentCreateGroup fragmentCreateGroup = DialogFragmentCreateGroup.newInstance();
        fragmentCreateGroup.show(getChildFragmentManager(), null);
    });

    recyclerViewGroups.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(@NonNull final RecyclerView recyclerView, final int dx, final int dy) {
            super.onScrolled(recyclerView, dx, dy);
            final LinearLayoutManager m = (LinearLayoutManager) recyclerView.getLayoutManager();
            if (m != null) {
                if (m.findFirstCompletelyVisibleItemPosition() == 0) {
                    fab.extend();
                } else {
                    fab.shrink();
                }
            }
        }
    });

    return rootView;

}
 
Example 19
Source File: VerticalRecyclerViewListener.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {

    // Prevent multitouch, once we start to listen with a RV,
    // we ignore any other RV until the touch is released (UP)
    if((mCurrentRVTouched != null && rv != mCurrentRVTouched)) {
        return true;
    }
        
    // If scroll direction is not Vertical, then ignore and reset last RV touched
    if(!verticalDirection(e)) {
        mCurrentRVTouched = null;
        return false;
    }

    if (e.getAction() == MotionEvent.ACTION_DOWN) {
        mCurrentRVTouched = rv;
        if (rv.getScrollState() == RecyclerView.SCROLL_STATE_IDLE) {

            if (mLastTouchedRecyclerView != null && rv != mLastTouchedRecyclerView) {
                removeLastTouchedRecyclerViewScrollListener(false);
            }
            mYPosition = ((CellRecyclerView) rv).getScrolledY();
            rv.addOnScrollListener(this);

            if (rv == mCellRecyclerView) {
                Log.d(LOG_TAG, "mCellRecyclerView scroll listener added");
            } else if (rv == mRowHeaderRecyclerView) {
                Log.d(LOG_TAG, "mRowHeaderRecyclerView scroll listener added");
            }

            // Refresh the value;
            mIsMoved = false;
        }
    } else if (e.getAction() == MotionEvent.ACTION_MOVE) {
        mCurrentRVTouched = rv;
        // Why does it matter ?
        // user scroll any recyclerView like brushing, at that time, ACTION_UP will be
        // triggered
        // before scrolling. So, we need to store whether it moved or not.
        mIsMoved = true;
    } else if (e.getAction() == MotionEvent.ACTION_UP) {
        mCurrentRVTouched = null;
        int nScrollY = ((CellRecyclerView) rv).getScrolledY();

        // TODO: Even if moved value is true and it may not scroll. This should be fixed.
        // TODO: The scenario is scroll lightly center RecyclerView vertically.
        // TODO: Below if condition may be changed later.

        // Is it just touched without scrolling then remove the listener
        if (mYPosition == nScrollY && !mIsMoved && rv.getScrollState() == RecyclerView
                .SCROLL_STATE_IDLE) {
            rv.removeOnScrollListener(this);

            if (rv == mCellRecyclerView) {
                Log.d(LOG_TAG, "mCellRecyclerView scroll listener removed from up ");
            } else if (rv == mRowHeaderRecyclerView) {
                Log.d(LOG_TAG, "mRowHeaderRecyclerView scroll listener removed from up");
            }
        }

        mLastTouchedRecyclerView = rv;

    }

    return false;
}
 
Example 20
Source File: ClipsFragment.java    From arcusandroid with Apache License 2.0 4 votes vote down vote up
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    noClipsContent = view.findViewById(R.id.no_clips);
    noClipsText = view.findViewById(R.id.no_clips_text);
    progressContainer = view.findViewById(R.id.download_container);
    progressBar = view.findViewById(R.id.download_progress);
    RelativeLayout filterContainer = view.findViewById(R.id.filter_container);
    showPinnedClipsToggle = view.findViewById(R.id.toggle);
    LinearLayout toolbarContainer = view.findViewById(R.id.filter_bar);
    filter = view.findViewById(R.id.filter);

    adapter = new ClipRecyclerViewAdapter(this, null, (BaseActivity) getActivity());
    adapter.setHasStableIds(true);
    adapter.addHeaders("All Devices", "All of Time?");

    swipeContainer = view.findViewById(R.id.swipeContainer);
    swipeContainer.setOnRefreshListener(() -> {
        adapter.removeAll();
        adapter.addHeaders("All Devices", "All of Time?");
        ClipListingController.instance().refresh();
    });
    swipeContainer.setColorSchemeResources(R.color.arcus_teal, R.color.arcus_light_blue);

    RecyclerView recyclerView = view.findViewById(R.id.recyclerview);
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    recyclerView.addOnScrollListener(new EndlessScrollRecycleListener(3) {
        @Override public void onLoadMore() {
            if (!loadingMore.getAndSet(true)) {
                ClipListingController.instance().loadMoreClips();
            }
        }
    });

    filterContainer.setOnClickListener(view1 -> filterByDevice());
    updateFilterText();

    view.findViewById(R.id.cancel_active_download).setOnClickListener(v -> ClipDownloadControllerImpl.instance().cancelCurrentDownload());

    ViewBackgroundTarget vbt = new ViewBackgroundTarget(toolbarContainer);
    ImageManager.with(getContext())
        .putWallpaper(Wallpaper.ofCurrentPlace().darkened())
        .withFirstTransform(new FilterBarTransformation())
        .into(vbt)
        .execute();

    Version1TextView pinnedClipsText = view.findViewById(R.id.pinned_clips_text);
    if(SubscriptionController.isPremiumOrPro()){
        pinnedClipsText.setText(R.string.camera_pinned_clips_title);
        showPinnedClipsToggle.setOnClickListener(view12 -> filterByPinned(showPinnedClipsToggle.isChecked()));
    } else {
        pinnedClipsText.setText(R.string.camera_clips_clips_title);
        showPinnedClipsToggle.setVisibility(View.GONE);
    }
}