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));
}
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;
}
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);
}
}
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);
}
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;
}
Aggregations