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