use of androidx.recyclerview.widget.GridLayoutManager in project android by nextcloud.
the class SyncedFoldersActivity method setupContent.
/**
* sets up the UI elements and loads all media/synced folders.
*/
private void setupContent() {
final int gridWidth = getResources().getInteger(R.integer.media_grid_width);
boolean lightVersion = getResources().getBoolean(R.bool.syncedFolder_light);
adapter = new SyncedFolderAdapter(this, clock, gridWidth, this, lightVersion);
syncedFolderProvider = new SyncedFolderProvider(getContentResolver(), preferences, clock);
binding.emptyList.emptyListIcon.setImageResource(R.drawable.nav_synced_folders);
ThemeButtonUtils.colorPrimaryButton(binding.emptyList.emptyListViewAction, this);
final GridLayoutManager lm = new GridLayoutManager(this, gridWidth);
adapter.setLayoutManager(lm);
int spacing = getResources().getDimensionPixelSize(R.dimen.media_grid_spacing);
binding.list.addItemDecoration(new MediaGridItemDecoration(spacing));
binding.list.setLayoutManager(lm);
binding.list.setAdapter(adapter);
load(gridWidth * 2, false);
}
use of androidx.recyclerview.widget.GridLayoutManager in project android by nextcloud.
the class UploadListActivity method setupContent.
private void setupContent() {
binding.list.setEmptyView(binding.emptyList.getRoot());
binding.emptyList.getRoot().setVisibility(View.GONE);
binding.emptyList.emptyListIcon.setImageResource(R.drawable.uploads);
binding.emptyList.emptyListIcon.getDrawable().mutate();
binding.emptyList.emptyListIcon.setAlpha(0.5f);
binding.emptyList.emptyListIcon.setVisibility(View.VISIBLE);
binding.emptyList.emptyListViewHeadline.setText(getString(R.string.upload_list_empty_headline));
binding.emptyList.emptyListViewText.setText(getString(R.string.upload_list_empty_text_auto_upload));
binding.emptyList.emptyListViewText.setVisibility(View.VISIBLE);
uploadListAdapter = new UploadListAdapter(this, uploadsStorageManager, getStorageManager(), userAccountManager, connectivityService, powerManagementService, clock);
final GridLayoutManager lm = new GridLayoutManager(this, 1);
uploadListAdapter.setLayoutManager(lm);
int spacing = getResources().getDimensionPixelSize(R.dimen.media_grid_spacing);
binding.list.addItemDecoration(new MediaGridItemDecoration(spacing));
binding.list.setLayoutManager(lm);
binding.list.setAdapter(uploadListAdapter);
ThemeLayoutUtils.colorSwipeRefreshLayout(this, swipeListRefreshLayout);
swipeListRefreshLayout.setOnRefreshListener(this::refresh);
loadItems();
}
use of androidx.recyclerview.widget.GridLayoutManager in project android by nextcloud.
the class ChooseTemplateDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Bundle arguments = getArguments();
if (arguments == null) {
throw new IllegalArgumentException("Arguments may not be null");
}
Activity activity = getActivity();
if (activity == null) {
throw new IllegalArgumentException("Activity may not be null");
}
parentFolder = arguments.getParcelable(ARG_PARENT_FOLDER);
creator = arguments.getParcelable(ARG_CREATOR);
title = arguments.getString(ARG_HEADLINE, getString(R.string.select_template));
if (savedInstanceState == null) {
title = arguments.getString(ARG_HEADLINE);
} else {
title = savedInstanceState.getString(ARG_HEADLINE);
}
// Inflate the layout for the dialog
LayoutInflater inflater = requireActivity().getLayoutInflater();
binding = ChooseTemplateBinding.inflate(inflater, null, false);
View view = binding.getRoot();
binding.filename.requestFocus();
ThemeTextInputUtils.colorTextInput(binding.filenameContainer, binding.filename, ThemeColorUtils.primaryColor(getContext()));
binding.filename.setOnKeyListener((v, keyCode, event) -> {
checkEnablingCreateButton();
return false;
});
binding.filename.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// generated method stub
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// generated method stub
}
@Override
public void afterTextChanged(Editable s) {
checkEnablingCreateButton();
}
});
try {
User user = currentAccount.getUser();
new FetchTemplateTask(this, clientFactory, user, creator).execute();
} catch (Exception e) {
Log_OC.e(TAG, "Loading stream url not possible: " + e);
}
binding.list.setHasFixedSize(true);
binding.list.setLayoutManager(new GridLayoutManager(activity, 2));
adapter = new TemplateAdapter(creator.getMimetype(), this, getContext(), currentAccount, clientFactory);
binding.list.setAdapter(adapter);
// Build the dialog
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setView(view).setPositiveButton(R.string.create, null).setNeutralButton(R.string.common_cancel, null).setTitle(title);
Dialog dialog = builder.create();
Window window = dialog.getWindow();
if (window != null) {
window.setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}
return dialog;
}
use of androidx.recyclerview.widget.GridLayoutManager in project android by nextcloud.
the class SendFilesDialog method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.send_files_fragment, container, false);
// populate send apps
Intent sendIntent = IntentUtil.createSendIntent(requireContext(), files);
List<ResolveInfo> matches = requireActivity().getPackageManager().queryIntentActivities(sendIntent, 0);
if (matches.isEmpty()) {
Toast.makeText(getContext(), R.string.no_send_app, Toast.LENGTH_SHORT).show();
dismiss();
return null;
}
List<SendButtonData> sendButtonDataList = setupSendButtonData(matches);
SendButtonAdapter.ClickListener clickListener = setupSendButtonClickListener(sendIntent);
RecyclerView sendButtonsView = view.findViewById(R.id.send_button_recycler_view);
sendButtonsView.setLayoutManager(new GridLayoutManager(getActivity(), 4));
sendButtonsView.setAdapter(new SendButtonAdapter(sendButtonDataList, clickListener));
return view;
}
use of androidx.recyclerview.widget.GridLayoutManager in project LiYuJapanese by 54wall.
the class GojuonMemoryFragment method setRecyclerView.
@Override
public void setRecyclerView(int type) {
switch(type) {
case Constants.GOJUON_CHENGYU:
RecyclerView.LayoutManager layoutManager2 = new GridLayoutManager(getContext(), Constants.COLUMN_CHENGYU);
mRecyclerView.setLayoutManager(layoutManager2);
break;
case Constants.GOJUON_MEMORY:
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(linearLayoutManager);
break;
default:
break;
}
}
Aggregations