Search in sources :

Example 16 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager 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 17 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project banner by youth5201314.

the class MarginDecoration method getItemOffsets.

@Override
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
    LinearLayoutManager linearLayoutManager = requireLinearLayoutManager(parent);
    if (linearLayoutManager.getOrientation() == LinearLayoutManager.VERTICAL) {
        outRect.top = mMarginPx;
        outRect.bottom = mMarginPx;
    } else {
        outRect.left = mMarginPx;
        outRect.right = mMarginPx;
    }
}
Also used : LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 18 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project banner by youth5201314.

the class RecyclerViewBannerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recyclerview_banner);
    ButterKnife.bind(this);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(new MyRecyclerViewAdapter(this));
}
Also used : LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) MyRecyclerViewAdapter(com.test.banner.adapter.MyRecyclerViewAdapter)

Example 19 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project banner by youth5201314.

the class BannerListFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    text.setText("当前页:" + index);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.setAdapter(new MyRecyclerViewAdapter(getActivity()));
}
Also used : LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) MyRecyclerViewAdapter(com.test.banner.adapter.MyRecyclerViewAdapter)

Example 20 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project Carbon by ZieIony.

the class BottomSheetLayout method updateRecycler.

private void updateRecycler() {
    if (menu == null)
        return;
    recycler.setLayoutManager(style == Style.List ? new LinearLayoutManager(getContext()) : new GridLayoutManager(getContext(), 3));
    ArrayList<Serializable> items = new ArrayList<>();
    for (int i = 0; i < menu.size(); i++) {
        if (menu.getItem(i).isVisible())
            items.add(new Item(menu.getItem(i)));
    }
    if (style == Style.List) {
        for (int i = 0; i < recycler.getItemDecorationCount(); i++) recycler.removeItemDecorationAt(0);
        ViewItemDecoration dividerItemDecoration = new ViewItemDecoration(getContext(), R.layout.carbon_menustrip_hseparator_item);
        dividerItemDecoration.setDrawAfter(position -> position < items.size() - 1 && items.get(position) instanceof NavigationView.Item && items.get(position + 1) instanceof NavigationView.Item && ((NavigationView.Item) items.get(position)).getGroupId() != ((NavigationView.Item) items.get(position + 1)).getGroupId());
        recycler.addItemDecoration(dividerItemDecoration);
        ViewItemDecoration paddingItemDecoration = new ViewItemDecoration(getContext(), R.layout.carbon_row_padding);
        paddingItemDecoration.setDrawAfter(position -> position == items.size() - 1);
        recycler.addItemDecoration(paddingItemDecoration);
    }
    RowListAdapter<Serializable> adapter = new RowListAdapter<>();
    adapter.putFactory(Item.class, style == Style.List ? BottomSheetRow::new : BottomSheetCell::new);
    adapter.setItems(items);
    recycler.setAdapter(adapter);
}
Also used : MenuItem(android.view.MenuItem) Serializable(java.io.Serializable) NavigationView(carbon.widget.NavigationView) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) ViewItemDecoration(carbon.recycler.ViewItemDecoration) ArrayList(java.util.ArrayList) RowListAdapter(carbon.recycler.RowListAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Aggregations

LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)470 RecyclerView (androidx.recyclerview.widget.RecyclerView)281 View (android.view.View)183 TextView (android.widget.TextView)65 ArrayList (java.util.ArrayList)37 Nullable (androidx.annotation.Nullable)33 Bundle (android.os.Bundle)32 Toolbar (androidx.appcompat.widget.Toolbar)32 Intent (android.content.Intent)30 ImageView (android.widget.ImageView)27 List (java.util.List)24 Test (org.junit.Test)24 Context (android.content.Context)23 NonNull (androidx.annotation.NonNull)23 ViewGroup (android.view.ViewGroup)22 AlertDialog (androidx.appcompat.app.AlertDialog)21 ContextualCard (com.android.settings.homepage.contextualcards.ContextualCard)20 LayoutInflater (android.view.LayoutInflater)18 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)16 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)16