Search in sources :

Example 1 with GridSpacingItemDecoration

use of org.horaapps.leafpic.views.GridSpacingItemDecoration in project LeafPic by HoraApps.

the class AlbumsFragment method setUpColumns.

public void setUpColumns() {
    int columnsCount = columnsCount();
    if (columnsCount != ((GridLayoutManager) rv.getLayoutManager()).getSpanCount()) {
        rv.removeItemDecoration(spacingDecoration);
        spacingDecoration = new GridSpacingItemDecoration(columnsCount, Measure.pxToDp(3, getContext()), true);
        rv.addItemDecoration(spacingDecoration);
        rv.setLayoutManager(new GridLayoutManager(getContext(), columnsCount));
    }
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) GridSpacingItemDecoration(org.horaapps.leafpic.views.GridSpacingItemDecoration)

Example 2 with GridSpacingItemDecoration

use of org.horaapps.leafpic.views.GridSpacingItemDecoration in project LeafPic by HoraApps.

the class AlbumsFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_albums, container, false);
    ButterKnife.bind(this, v);
    int spanCount = columnsCount();
    spacingDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getContext()), true);
    rv.setHasFixedSize(true);
    rv.addItemDecoration(spacingDecoration);
    rv.setLayoutManager(new GridLayoutManager(getContext(), spanCount));
    if (Prefs.animationsEnabled()) {
        rv.setItemAnimator(AnimationUtils.getItemAnimator(new LandingAnimator(new OvershootInterpolator(1f))));
    }
    adapter = new AlbumsAdapter(getContext(), this);
    refresh.setOnRefreshListener(this::displayAlbums);
    rv.setAdapter(adapter);
    return v;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) OvershootInterpolator(android.view.animation.OvershootInterpolator) AlbumsAdapter(org.horaapps.leafpic.adapters.AlbumsAdapter) LandingAnimator(jp.wasabeef.recyclerview.animators.LandingAnimator) BindView(butterknife.BindView) View(android.view.View) CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) GridSpacingItemDecoration(org.horaapps.leafpic.views.GridSpacingItemDecoration) Nullable(android.support.annotation.Nullable)

Example 3 with GridSpacingItemDecoration

use of org.horaapps.leafpic.views.GridSpacingItemDecoration in project LeafPic by HoraApps.

the class RvMediaFragment method setUpColumns.

public void setUpColumns() {
    int columnsCount = columnsCount();
    if (columnsCount != ((GridLayoutManager) rv.getLayoutManager()).getSpanCount()) {
        ((GridLayoutManager) rv.getLayoutManager()).getSpanCount();
        rv.removeItemDecoration(spacingDecoration);
        spacingDecoration = new GridSpacingItemDecoration(columnsCount, Measure.pxToDp(3, getContext()), true);
        rv.setLayoutManager(new GridLayoutManager(getContext(), columnsCount));
        rv.addItemDecoration(spacingDecoration);
    }
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) GridSpacingItemDecoration(org.horaapps.leafpic.views.GridSpacingItemDecoration)

Example 4 with GridSpacingItemDecoration

use of org.horaapps.leafpic.views.GridSpacingItemDecoration in project LeafPic by HoraApps.

the class SelectAlbumBuilder method setupDialog.

@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);
    View contentView = View.inflate(getContext(), R.layout.select_folder_bottom_sheet, null);
    final RecyclerView mRecyclerView = contentView.findViewById(R.id.folders);
    final Spinner spinner = contentView.findViewById(R.id.storage_spinner);
    currentFolderPath = contentView.findViewById(R.id.bottom_sheet_sub_title);
    exploreModePanel = contentView.findViewById(R.id.ll_explore_mode_panel);
    imgExploreMode = contentView.findViewById(R.id.toggle_hidden_icon);
    theme = ThemeHelper.getInstanceLoaded(getContext());
    sdCardPath = StorageHelper.getSdcardPath(getContext());
    mRecyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
    mRecyclerView.addItemDecoration(new GridSpacingItemDecoration(2, Measure.pxToDp(3, getContext()), true));
    adapter = new BottomSheetAlbumsAdapter();
    mRecyclerView.setAdapter(adapter);
    spinner.setAdapter(new VolumeSpinnerAdapter(contentView.getContext()));
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long l) {
            switch(pos) {
                case INTERNAL_STORAGE:
                    displayContentFolder(Environment.getExternalStorageDirectory());
                    break;
                default:
                    // }
                    break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
    /**
     *SET UP THEME*
     */
    contentView.findViewById(R.id.rl_bottom_sheet_title).setBackgroundColor(theme.getPrimaryColor());
    exploreModePanel.setBackgroundColor(theme.getPrimaryColor());
    contentView.findViewById(R.id.ll_select_folder).setBackgroundColor(theme.getCardBackgroundColor());
    theme.setColorScrollBarDrawable(ContextCompat.getDrawable(dialog.getContext(), R.drawable.ic_scrollbar));
    mRecyclerView.setBackgroundColor(theme.getBackgroundColor());
    fabDone = contentView.findViewById(R.id.fab_bottomsheet_done);
    fabDone.setBackgroundTintList(ColorStateList.valueOf(theme.getAccentColor()));
    fabDone.setImageDrawable(new IconicsDrawable(getContext()).icon(GoogleMaterial.Icon.gmd_done).color(Color.WHITE));
    fabDone.setVisibility(exploreMode ? View.VISIBLE : View.GONE);
    fabDone.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
            onFolderSelected.folderSelected(currentFolderPath.getText().toString());
        }
    });
    ((TextView) contentView.findViewById(R.id.bottom_sheet_title)).setText(title);
    ((ThemedIcon) contentView.findViewById(R.id.create_new_folder_icon)).setColor(theme.getIconColor());
    contentView.findViewById(R.id.rl_create_new_folder).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final EditText editText = new EditText(getContext());
            AlertDialog insertTextDialog = AlertDialogsHelper.getInsertTextDialog(((ThemedActivity) getActivity()), editText, R.string.new_folder);
            insertTextDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    File folderPath = new File(currentFolderPath.getText().toString() + File.separator + editText.getText().toString());
                    if (folderPath.mkdir())
                        displayContentFolder(folderPath);
                }
            });
            insertTextDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                }
            });
            insertTextDialog.show();
        }
    });
    contentView.findViewById(R.id.rl_bottom_sheet_title).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!forzed) {
                toggleExplorerMode(!exploreMode);
                fabDone.setVisibility(exploreMode ? View.VISIBLE : View.GONE);
            }
        }
    });
    dialog.setContentView(contentView);
    CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
    CoordinatorLayout.Behavior behavior = layoutParams.getBehavior();
    if (behavior != null && behavior instanceof BottomSheetBehavior) {
        ((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
    }
    adapter.notifyDataSetChanged();
    toggleExplorerMode(exploreMode);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Spinner(android.widget.Spinner) BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) TextView(android.widget.TextView) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) EditText(android.widget.EditText) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) GridLayoutManager(android.support.v7.widget.GridLayoutManager) ThemedIcon(org.horaapps.liz.ui.ThemedIcon) RecyclerView(android.support.v7.widget.RecyclerView) AdapterView(android.widget.AdapterView) File(java.io.File) GridSpacingItemDecoration(org.horaapps.leafpic.views.GridSpacingItemDecoration)

Example 5 with GridSpacingItemDecoration

use of org.horaapps.leafpic.views.GridSpacingItemDecoration in project LeafPic by HoraApps.

the class MainActivity method updateColumnsRvAlbums.

private void updateColumnsRvAlbums() {
    int spanCount = SP.getInt("n_columns_folders", 2);
    if (spanCount != ((GridLayoutManager) rvAlbums.getLayoutManager()).getSpanCount()) {
        rvAlbums.removeItemDecoration(rvAlbumsDecoration);
        rvAlbumsDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
        rvAlbums.addItemDecoration(rvAlbumsDecoration);
        rvAlbums.setLayoutManager(new GridLayoutManager(this, spanCount));
    }
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) GridSpacingItemDecoration(org.horaapps.leafpic.views.GridSpacingItemDecoration)

Aggregations

GridLayoutManager (android.support.v7.widget.GridLayoutManager)8 GridSpacingItemDecoration (org.horaapps.leafpic.views.GridSpacingItemDecoration)8 RecyclerView (android.support.v7.widget.RecyclerView)4 View (android.view.View)4 TextView (android.widget.TextView)4 CardView (android.support.v7.widget.CardView)3 Nullable (android.support.annotation.Nullable)2 OvershootInterpolator (android.view.animation.OvershootInterpolator)2 BindView (butterknife.BindView)2 IconicsDrawable (com.mikepenz.iconics.IconicsDrawable)2 LandingAnimator (jp.wasabeef.recyclerview.animators.LandingAnimator)2 AlbumsAdapter (org.horaapps.leafpic.adapters.AlbumsAdapter)2 MediaAdapter (org.horaapps.leafpic.adapters.MediaAdapter)2 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 BottomSheetBehavior (android.support.design.widget.BottomSheetBehavior)1 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 AlertDialog (android.support.v7.app.AlertDialog)1