Search in sources :

Example 11 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project Tusky by Vavassor.

the class ViewThreadFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_view_thread, container, false);
    Context context = getContext();
    swipeRefreshLayout = rootView.findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue);
    recyclerView = rootView.findViewById(R.id.recyclerView);
    recyclerView.setHasFixedSize(true);
    LinearLayoutManager layoutManager = new LinearLayoutManager(context);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAccessibilityDelegateCompat(new ListStatusAccessibilityDelegate(recyclerView, this, statuses::getPairedItemOrNull));
    DividerItemDecoration divider = new DividerItemDecoration(context, layoutManager.getOrientation());
    recyclerView.addItemDecoration(divider);
    recyclerView.addItemDecoration(new ConversationLineItemDecoration(context));
    alwaysShowSensitiveMedia = accountManager.getActiveAccount().getAlwaysShowSensitiveMedia();
    alwaysOpenSpoiler = accountManager.getActiveAccount().getAlwaysOpenSpoiler();
    reloadFilters();
    recyclerView.setAdapter(adapter);
    statuses.clear();
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    return rootView;
}
Also used : Context(android.content.Context) ListStatusAccessibilityDelegate(com.keylesspalace.tusky.util.ListStatusAccessibilityDelegate) SimpleItemAnimator(androidx.recyclerview.widget.SimpleItemAnimator) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) ConversationLineItemDecoration(com.keylesspalace.tusky.view.ConversationLineItemDecoration) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 12 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project materialistic by hidroh.

the class FavoriteFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_favorite, container, false);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
    mEmptySearchView = view.findViewById(R.id.empty_search);
    mEmptyView = view.findViewById(R.id.empty);
    mEmptyView.findViewById(R.id.header_card_view).setOnLongClickListener(v -> {
        View bookmark = mEmptyView.findViewById(R.id.bookmarked);
        bookmark.setVisibility(bookmark.getVisibility() == View.VISIBLE ? View.INVISIBLE : View.VISIBLE);
        return true;
    });
    mEmptyView.setVisibility(View.INVISIBLE);
    return view;
}
Also used : SearchView(androidx.appcompat.widget.SearchView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 13 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project materialistic by hidroh.

the class BaseListFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mRecyclerView.setLayoutManager(new SnappyLinearLayoutManager(getActivity(), false));
    final int verticalMargin = getResources().getDimensionPixelSize(R.dimen.cardview_vertical_margin);
    final int horizontalMargin = getResources().getDimensionPixelSize(R.dimen.cardview_horizontal_margin);
    final int divider = getResources().getDimensionPixelSize(R.dimen.divider);
    mRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {

        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            if (getAdapter().isCardViewEnabled()) {
                outRect.set(horizontalMargin, verticalMargin, horizontalMargin, 0);
            } else {
                outRect.set(0, 0, 0, divider);
            }
        }
    });
}
Also used : Rect(android.graphics.Rect) SnappyLinearLayoutManager(io.github.hidroh.materialistic.widget.SnappyLinearLayoutManager) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 14 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project PhotoView by chrisbanes.

the class ActivityTransitionActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_transition);
    RecyclerView list = findViewById(R.id.list);
    list.setLayoutManager(new GridLayoutManager(this, 2));
    ImageAdapter imageAdapter = new ImageAdapter(new ImageAdapter.Listener() {

        @Override
        public void onImageClicked(View view) {
            transition(view);
        }
    });
    list.setAdapter(imageAdapter);
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 15 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project materialistic by hidroh.

the class ThreadPreviewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Item item = getIntent().getParcelableExtra(EXTRA_ITEM);
    if (item == null) {
        finish();
        return;
    }
    supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_thread_preview);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    // noinspection ConstantConditions
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    recyclerView.setLayoutManager(new SnappyLinearLayoutManager(this, false));
    recyclerView.addItemDecoration(new CommentItemDecoration(this));
    recyclerView.setAdapter(new ThreadPreviewRecyclerViewAdapter(mItemManager, item));
    mKeyDelegate.setScrollable(new KeyDelegate.RecyclerViewHelper(recyclerView, KeyDelegate.RecyclerViewHelper.SCROLL_ITEM), null);
}
Also used : Item(io.github.hidroh.materialistic.data.Item) MenuItem(android.view.MenuItem) SnappyLinearLayoutManager(io.github.hidroh.materialistic.widget.SnappyLinearLayoutManager) RecyclerView(androidx.recyclerview.widget.RecyclerView) CommentItemDecoration(io.github.hidroh.materialistic.widget.CommentItemDecoration) ThreadPreviewRecyclerViewAdapter(io.github.hidroh.materialistic.widget.ThreadPreviewRecyclerViewAdapter)

Aggregations

RecyclerView (androidx.recyclerview.widget.RecyclerView)352 View (android.view.View)232 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)156 TextView (android.widget.TextView)51 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)39 ImageView (android.widget.ImageView)29 Nullable (androidx.annotation.Nullable)29 Toolbar (androidx.appcompat.widget.Toolbar)25 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)20 Intent (android.content.Intent)19 NonNull (androidx.annotation.NonNull)19 StaggeredGridLayoutManager (androidx.recyclerview.widget.StaggeredGridLayoutManager)19 Bundle (android.os.Bundle)18 ViewGroup (android.view.ViewGroup)16 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)16 Context (android.content.Context)15 Rect (android.graphics.Rect)15 SuppressLint (android.annotation.SuppressLint)12 LayoutInflater (android.view.LayoutInflater)11