Search in sources :

Example 16 with GridLayoutManager

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);
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) MediaGridItemDecoration(com.owncloud.android.ui.decoration.MediaGridItemDecoration) SyncedFolderProvider(com.owncloud.android.datamodel.SyncedFolderProvider) SyncedFolderAdapter(com.owncloud.android.ui.adapter.SyncedFolderAdapter) SuppressLint(android.annotation.SuppressLint)

Example 17 with GridLayoutManager

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();
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) MediaGridItemDecoration(com.owncloud.android.ui.decoration.MediaGridItemDecoration) UploadListAdapter(com.owncloud.android.ui.adapter.UploadListAdapter)

Example 18 with GridLayoutManager

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;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Window(android.view.Window) User(com.nextcloud.client.account.User) Bundle(android.os.Bundle) Activity(android.app.Activity) View(android.view.View) ExternalSiteWebView(com.owncloud.android.ui.activity.ExternalSiteWebView) TextEditorWebView(com.owncloud.android.ui.activity.TextEditorWebView) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) AlertDialog(androidx.appcompat.app.AlertDialog) Dialog(android.app.Dialog) LayoutInflater(android.view.LayoutInflater) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TemplateAdapter(com.owncloud.android.ui.adapter.TemplateAdapter) NonNull(androidx.annotation.NonNull)

Example 19 with GridLayoutManager

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;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) SendButtonAdapter(com.owncloud.android.ui.adapter.SendButtonAdapter) Intent(android.content.Intent) SendButtonData(com.owncloud.android.ui.components.SendButtonData) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Nullable(androidx.annotation.Nullable)

Example 20 with GridLayoutManager

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;
    }
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

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