Search in sources :

Example 56 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project AndroidUtilCode by Blankj.

the class DebugMenuItem method bind.

@Override
public void bind(@NonNull ItemViewHolder holder, int position) {
    TextView menuTitle = holder.findViewById(R.id.menuCategory);
    RecyclerView menuRv = holder.findViewById(R.id.menuRv);
    ShadowHelper.applyMenu(holder.itemView);
    menuTitle.setText(mTitle);
    BaseItemAdapter<DebugItem> adapter = new BaseItemAdapter<>();
    adapter.setItems(DebugItem.getDebugItems(mDebugs));
    menuRv.setAdapter(adapter);
    menuRv.setLayoutManager(new GridLayoutManager(menuRv.getContext(), 4));
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) TextView(android.widget.TextView) RecyclerView(androidx.recyclerview.widget.RecyclerView) BaseItemAdapter(com.blankj.utildebug.base.rv.BaseItemAdapter)

Example 57 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project MiMangaNu by raulhaag.

the class MainFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    setHasOptionsMenu(true);
    setRetainInstance(true);
    pm = PreferenceManager.getDefaultSharedPreferences(getActivity());
    MainActivity.colors = ThemeColors.getColors(pm);
    ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_main, container, false);
    final CoordinatorLayout cl = viewGroup.findViewById(R.id.coordinator_layout);
    recyclerView = viewGroup.findViewById(R.id.recicleview_mis_mangas);
    swipeReLayout = viewGroup.findViewById(R.id.str);
    swipeReLayout.setColorSchemeColors(MainActivity.colors[0], MainActivity.colors[1]);
    swipeReLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            updateListTask = new UpdateListTask(getActivity(), cl, pm, currentVault);
            updateListTask.execute();
        }
    });
    int columnSize = Integer.parseInt(pm.getString("grid_columns", "-1"));
    if (columnSize == -1 || pm.getBoolean("grid_columns_automatic_detection", true))
        columnSize = Util.getInstance().getGridColumnSizeFromWidth(getActivity());
    recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), columnSize));
    if (updateListTask != null && updateListTask.getStatus() == AsyncTask.Status.RUNNING) {
        swipeReLayout.post(new Runnable() {

            @Override
            public void run() {
                swipeReLayout.setRefreshing(true);
            }
        });
    }
    return viewGroup;
}
Also used : CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) ViewGroup(android.view.ViewGroup) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) Nullable(androidx.annotation.Nullable)

Example 58 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project MiMangaNu by raulhaag.

the class ServerFilteredNavigationFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedState) {
    super.onActivityCreated(savedState);
    SharedPreferences pm = PreferenceManager.getDefaultSharedPreferences(getActivity());
    colors = ThemeColors.getColors(pm);
    ActionBar mActBar = getActivity().getActionBar();
    if (mActBar != null) {
        mActBar.setTitle(getResources().getString(R.string.listaen) + " " + serverBase.getServerName());
        mActBar.setDisplayHomeAsUpEnabled(true);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getActivity().getWindow();
        window.setNavigationBarColor(colors[0]);
        window.setStatusBarColor(colors[4]);
    }
    serverBase = ServerBase.getServer(serverID, getContext());
    if (filters == null) {
        filters = serverBase.getBasicFilter();
    }
    recyclerViewGrid = getView().findViewById(R.id.grilla);
    if (serverBase.getFilteredType() == ServerBase.FilteredType.TEXT) {
        DividerItemDecoration divider = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
        Drawable sd = ContextCompat.getDrawable(getContext(), R.drawable.divider);
        sd.setColorFilter(colors[0], PorterDuff.Mode.DARKEN);
        divider.setDrawable(sd);
        recyclerViewGrid.addItemDecoration(divider);
    }
    loading = getView().findViewById(R.id.loading);
    int columnSize = Integer.parseInt(pm.getString("grid_columns", "-1"));
    if (columnSize == -1 || pm.getBoolean("grid_columns_automatic_detection", true))
        columnSize = Util.getInstance().getGridColumnSizeFromWidth(getActivity());
    if (serverBase.getFilteredType() == ServerBase.FilteredType.TEXT)
        columnSize = 1;
    recyclerViewGrid.setLayoutManager(new GridLayoutManager(getActivity(), columnSize));
    if (mAdapter != null) {
        mAdapter.setOnCreateContextMenuListener(this);
        recyclerViewGrid.setAdapter(mAdapter);
        recyclerViewGrid.getLayoutManager().scrollToPosition(firstVisibleItem);
        loading.setVisibility(View.INVISIBLE);
    } else {
        loadLastTask = (LoadLastTask) new LoadLastTask().execute(req_page);
    }
}
Also used : Window(android.view.Window) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) SharedPreferences(android.content.SharedPreferences) Drawable(android.graphics.drawable.Drawable) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) ActionBar(android.app.ActionBar)

Example 59 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project ForPDA by RadiationX.

the class AutoFitRecyclerView method init.

private void init() {
    manager = new GridLayoutManager(getContext(), 1);
    setLayoutManager(manager);
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager)

Example 60 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project Ruisi by freedom10086.

the class FrageForums method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    userImg = mRootView.findViewById(R.id.img);
    formsList = mRootView.findViewById(R.id.recycler_view);
    formsList.setClipToPadding(false);
    formsList.setPadding(0, 0, 0, (int) getResources().getDimension(R.dimen.bottombarHeight));
    mRootView.findViewById(R.id.search).setOnClickListener(this);
    adapter = new ForumsAdapter(getActivity());
    int spanCount = Math.max(4, DimenUtils.px2dip(getResources(), Resources.getSystem().getDisplayMetrics().widthPixels) / 75);
    GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), spanCount);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            int type = adapter.getItemViewType(position);
            if (type == ForumsAdapter.TYPE_HEADER || type == ForumsAdapter.TYPE_WATER) {
                return spanCount;
            } else {
                // 4 / 1 = 4 列
                return 1;
            }
        }
    });
    userImg.setOnClickListener(this);
    formsList.setLayoutManager(layoutManager);
    formsList.setAdapter(adapter);
    return mRootView;
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) ForumsAdapter(me.yluo.ruisiapp.adapter.ForumsAdapter) Nullable(androidx.annotation.Nullable)

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