Search in sources :

Example 76 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project FlexibleAdapter by davideas.

the class FragmentEndlessScrolling method createNewGridLayoutManager.

@Override
protected GridLayoutManager createNewGridLayoutManager() {
    GridLayoutManager gridLayoutManager = new SmoothScrollGridLayoutManager(getActivity(), mColumnCount);
    gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            // here, you should use them and not Layout integers
            switch(mAdapter.getItemViewType(position)) {
                case R.layout.recycler_scrollable_expandable_item:
                case R.layout.recycler_scrollable_header_item:
                case R.layout.recycler_scrollable_footer_item:
                case R.layout.recycler_scrollable_layout_item:
                case R.layout.recycler_scrollable_uls_item:
                case R.layout.progress_item:
                    return mColumnCount;
                default:
                    return 1;
            }
        }
    });
    return gridLayoutManager;
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) SmoothScrollGridLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager) SmoothScrollGridLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager)

Example 77 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project wire-android by wireapp.

the class EmojiBottomSheetDialog method init.

private void init(List<String> recent, Set<String> unsupported) {
    populateEmojis(recent, unsupported);
    final RecyclerView recyclerView = new RecyclerView(getContext());
    final EmojiAdapter adapter = new EmojiAdapter(getContext());
    final GridLayoutManager layoutManager = new GridLayoutManager(getContext(), getEmojiLayoutManagerSpanCount(), LinearLayoutManager.HORIZONTAL, false);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            return spaces.contains(position) ? getEmojiLayoutManagerSpanCount() : 1;
        }
    });
    LinearLayout ll = new LinearLayout(getContext());
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        // noinspection deprecation
        ll.setBackgroundColor(getContext().getResources().getColor(R.color.background_graphite));
    } else {
        ll.setBackgroundColor(getContext().getResources().getColor(R.color.background_graphite, getContext().getTheme()));
    }
    ll.setOrientation(LinearLayout.VERTICAL);
    final TabIndicatorLayout til = new TabIndicatorLayout(getContext());
    int[] labels = new int[3];
    labels[0] = R.string.sketch__emoji_keyboard__size_label__small;
    labels[1] = R.string.sketch__emoji_keyboard__size_label__medium;
    labels[2] = R.string.sketch__emoji_keyboard__size_label__large;
    til.setLabels(labels);
    til.setSelected(currentEmojiSize.ordinal());
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        // noinspection deprecation
        til.setTextColor(getContext().getResources().getColorStateList(R.color.wire__text_color_dark_selector));
        // noinspection deprecation
        til.setPrimaryColor(getContext().getResources().getColor(R.color.text__primary_dark));
    } else {
        til.setTextColor(getContext().getResources().getColorStateList(R.color.wire__text_color_dark_selector, getContext().getTheme()));
        til.setPrimaryColor(getContext().getResources().getColor(R.color.text__primary_dark, getContext().getTheme()));
    }
    til.setLabelHeight(getContext().getResources().getDimensionPixelSize(R.dimen.sketch__emoji__keyboard__tab_label_size));
    til.setCallback(new TabIndicatorLayout.Callback() {

        @Override
        public void onItemSelected(int pos) {
            til.setSelected(pos);
            currentEmojiSize = EmojiSize.values()[pos];
            adapter.setEmojiSize(currentEmojiSize);
            setRecyclerViewPadding(recyclerView);
            layoutManager.setSpanCount(getEmojiLayoutManagerSpanCount());
        }
    });
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getContext().getResources().getDimensionPixelSize(R.dimen.sketch__emoji__keyboard__tab_size));
    ll.addView(til, params);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapter);
    ll.addView(recyclerView);
    setRecyclerViewPadding(recyclerView);
    adapter.setOnEmojiClickListener(new EmojiAdapter.OnEmojiClickListener() {

        @Override
        public void onEmojiClick(String emoji, EmojiSize emojiSize) {
            if (listener != null) {
                listener.onEmojiSelected(emoji, emojiSize);
            }
            dismiss();
        }
    });
    adapter.setEmojis(emojis, currentEmojiSize);
    setContentView(ll);
}
Also used : ViewGroup(android.view.ViewGroup) TabIndicatorLayout(com.waz.zclient.ui.views.tab.TabIndicatorLayout) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayout(android.widget.LinearLayout)

Example 78 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project FlexibleAdapter by davideas.

the class FragmentOverall method createNewGridLayoutManager.

@Override
protected GridLayoutManager createNewGridLayoutManager() {
    mAdapter.setAnimationEntryStep(false);
    GridLayoutManager gridLayoutManager = new SmoothScrollGridLayoutManager(getActivity(), mColumnCount);
    gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            return mAdapter.getItem(position).getSpanSize(mColumnCount, position);
        }
    });
    return gridLayoutManager;
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) SmoothScrollGridLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager) SmoothScrollGridLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager)

Example 79 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project FlexibleAdapter by davideas.

the class FragmentOverall method onPrepareOptionsMenu.

@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    MenuItem gridMenuItem = menu.findItem(R.id.action_list_type);
    if (mRecyclerView.getLayoutManager() instanceof StaggeredGridLayoutManager) {
        gridMenuItem.setIcon(R.drawable.ic_view_agenda_white_24dp);
        gridMenuItem.setTitle(R.string.linear_layout);
    } else if (mRecyclerView.getLayoutManager() instanceof GridLayoutManager) {
        gridMenuItem.setIcon(R.drawable.ic_dashboard_white_24dp);
        gridMenuItem.setTitle(R.string.staggered_layout);
    } else {
        gridMenuItem.setIcon(R.drawable.ic_view_grid_white_24dp);
        gridMenuItem.setTitle(R.string.grid_layout);
    }
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) SmoothScrollGridLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager) MenuItem(android.view.MenuItem) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager)

Example 80 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project Android-SpinKit by ybq.

the class StyleFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list);
    GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 4);
    layoutManager.setOrientation(RecyclerView.VERTICAL);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(new RecyclerView.Adapter<Holder>() {

        @Override
        public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
            @SuppressLint("InflateParams") View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_style, null);
            return new Holder(view);
        }

        @Override
        public void onBindViewHolder(Holder holder, int position) {
            holder.bind(position);
        }

        @Override
        public int getItemCount() {
            return Style.values().length;
        }
    });
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) ViewGroup(android.view.ViewGroup) RecyclerView(androidx.recyclerview.widget.RecyclerView) SpinKitView(com.github.ybq.android.spinkit.SpinKitView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) SuppressLint(android.annotation.SuppressLint)

Aggregations

GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)122 RecyclerView (androidx.recyclerview.widget.RecyclerView)63 View (android.view.View)45 TextView (android.widget.TextView)19 StaggeredGridLayoutManager (androidx.recyclerview.widget.StaggeredGridLayoutManager)16 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)13 ImageView (android.widget.ImageView)12 Nullable (androidx.annotation.Nullable)11 Toolbar (androidx.appcompat.widget.Toolbar)10 ViewGroup (android.view.ViewGroup)7 SmoothScrollGridLayoutManager (eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager)7 SuppressLint (android.annotation.SuppressLint)6 Context (android.content.Context)6 ArrayList (java.util.ArrayList)6 NonNull (androidx.annotation.NonNull)5 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)5 List (java.util.List)5 RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)5 Drawable (android.graphics.drawable.Drawable)4 Handler (android.os.Handler)3