use of android.support.v7.widget.GridLayoutManager in project bilibili-android-client by HotBitmapGG.
the class HomeAttentionFragment method createHeadView.
private void createHeadView() {
View headView = LayoutInflater.from(getActivity()).inflate(R.layout.layout_attention_head_view, mRecyclerView, false);
RecyclerView mBangumiRecycler = (RecyclerView) headView.findViewById(R.id.focus_head_recycler);
mBangumiRecycler.setHasFixedSize(false);
mBangumiRecycler.setNestedScrollingEnabled(false);
mBangumiRecycler.setLayoutManager(new GridLayoutManager(getActivity(), 3));
mBangumiRecycler.setAdapter(new AttentionBangumiAdapter(mBangumiRecycler, chaseBangumis));
mHeaderViewRecyclerAdapter.addHeaderView(headView);
}
use of android.support.v7.widget.GridLayoutManager 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));
}
}
use of android.support.v7.widget.GridLayoutManager in project LeafPic by HoraApps.
the class MainActivity method initUI.
private void initUI() {
/**** TOOLBAR ****/
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
/**** RECYCLER VIEW ****/
rvAlbums = (RecyclerView) findViewById(R.id.grid_albums);
rvMedia = ((RecyclerView) findViewById(R.id.grid_photos));
rvAlbums.setHasFixedSize(true);
rvAlbums.setItemAnimator(new DefaultItemAnimator());
rvMedia.setHasFixedSize(true);
rvMedia.setItemAnimator(new DefaultItemAnimator());
albumsAdapter = new AlbumsAdapter(getAlbums().dispAlbums, MainActivity.this);
albumsAdapter.setOnClickListener(albumOnClickListener);
albumsAdapter.setOnLongClickListener(albumOnLongCLickListener);
rvAlbums.setAdapter(albumsAdapter);
mediaAdapter = new MediaAdapter(getAlbum().getMedia(), MainActivity.this);
mediaAdapter.setOnClickListener(photosOnClickListener);
mediaAdapter.setOnLongClickListener(photosOnLongClickListener);
rvMedia.setAdapter(mediaAdapter);
int spanCount = SP.getInt("n_columns_folders", 2);
rvAlbumsDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
rvAlbums.addItemDecoration(rvAlbumsDecoration);
rvAlbums.setLayoutManager(new GridLayoutManager(this, spanCount));
spanCount = SP.getInt("n_columns_media", 3);
rvMediaDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
rvMedia.setLayoutManager(new GridLayoutManager(getApplicationContext(), spanCount));
rvMedia.addItemDecoration(rvMediaDecoration);
/**** SWIPE TO REFRESH ****/
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
swipeRefreshLayout.setColorSchemeColors(getAccentColor());
swipeRefreshLayout.setProgressBackgroundColorSchemeColor(getBackgroundColor());
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (albumsMode) {
getAlbums().clearSelectedAlbums();
new PrepareAlbumTask().execute();
} else {
getAlbum().clearSelectedPhotos();
new PreparePhotosTask().execute();
}
}
});
/**** DRAWER ****/
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerLayout.addDrawerListener(new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) {
public void onDrawerClosed(View view) {
//Put your code here
// materialMenu.animateIconState(MaterialMenuDrawable.IconState.BURGER);
}
public void onDrawerOpened(View drawerView) {
//Put your code here
//materialMenu.animateIconState(MaterialMenuDrawable.IconState.ARROW);
}
});
/**** FAB ***/
fabCamera = (FloatingActionButton) findViewById(R.id.fab_camera);
fabCamera.setImageDrawable(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_camera_alt).color(Color.WHITE));
fabCamera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA));
}
});
//region TESTING
fabCamera.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// NOTE: this is used to acquire write permission on sd with api 21
// TODO call this one when unable to write on sd
requestSdCardPermissions();
return false;
}
});
//endregion
setRecentApp(getString(R.string.app_name));
setupUI();
}
use of android.support.v7.widget.GridLayoutManager in project LeafPic by HoraApps.
the class SelectAlbumBottomSheet 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);
theme = new ThemeHelper(getContext());
RecyclerView mRecyclerView = (RecyclerView) contentView.findViewById(R.id.folders);
mRecyclerView.setLayoutManager(new GridLayoutManager(getContext(), 1));
adapter = new BottomSheetAlbumsAdapter();
mRecyclerView.setAdapter(adapter);
exploreModePanel = (LinearLayout) contentView.findViewById(R.id.explore_mode_panel);
currentFolderPath = (TextView) contentView.findViewById(R.id.bottom_sheet_sub_title);
imgExploreMode = (IconicsImageView) contentView.findViewById(R.id.toggle_hidden_icon);
imgExploreMode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toggleExplorerMode(!exploreMode);
}
});
toggleExplorerMode(false);
/**SET UP THEME**/
theme.setColorScrollBarDrawable(ContextCompat.getDrawable(dialog.getContext(), R.drawable.ic_scrollbar));
contentView.findViewById(R.id.ll_bottom_sheet_title).setBackgroundColor(theme.getPrimaryColor());
contentView.findViewById(R.id.ll_select_folder).setBackgroundColor(theme.getCardBackgroundColor());
((TextView) contentView.findViewById(R.id.bottom_sheet_title)).setText(title);
((IconicsImageView) contentView.findViewById(R.id.create_new_folder)).setColor(theme.getIconColor());
((TextView) contentView.findViewById(R.id.create_new_folder_text)).setTextColor(theme.getSubTextColor());
((IconicsImageView) contentView.findViewById(R.id.done)).setColor(theme.getIconColor());
contentView.findViewById(R.id.done).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
selectAlbumInterface.folderSelected(currentFolderPath.getText().toString());
}
});
contentView.findViewById(R.id.ll_create_new_folder).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final EditText editText = new EditText(getContext());
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), theme.getDialogStyle());
AlertDialogsHelper.getInsertTextDialog(((ThemedActivity) getActivity()), builder, editText, R.string.new_folder);
builder.setPositiveButton(R.string.ok_action, 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);
}
});
builder.show();
}
});
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();
}
use of android.support.v7.widget.GridLayoutManager in project LeafPic by HoraApps.
the class ExcludedAlbumsActivity method initUI.
private void initUI() {
RecyclerView mRecyclerView;
Toolbar toolbar;
/** TOOLBAR **/
toolbar = (Toolbar) findViewById(org.horaapps.leafpic.R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);
/** RECYCLE VIEW**/
mRecyclerView = (RecyclerView) findViewById(org.horaapps.leafpic.R.id.excluded_albums);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setAdapter(new ExcludedItemsAdapter());
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 1));
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.setBackgroundColor(getBackgroundColor());
/**SET UP UI COLORS**/
toolbar.setBackgroundColor(getPrimaryColor());
toolbar.setNavigationIcon(getToolbarIcon(GoogleMaterial.Icon.gmd_arrow_back));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
setStatusBarColor();
setNavBarColor();
setRecentApp(getString(org.horaapps.leafpic.R.string.excluded_albums));
findViewById(org.horaapps.leafpic.R.id.rl_ea).setBackgroundColor(getBackgroundColor());
}
Aggregations