use of android.support.v7.widget.StaggeredGridLayoutManager in project VirtualApp by asLody.
the class ListAppFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
mRecyclerView = (DragSelectRecyclerView) view.findViewById(R.id.select_app_recycler_view);
mProgressBar = (ProgressBar) view.findViewById(R.id.select_app_progress_bar);
mInstallButton = (Button) view.findViewById(R.id.select_app_install_btn);
mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(3, OrientationHelper.VERTICAL));
mRecyclerView.addItemDecoration(new ItemOffsetDecoration(VUiKit.dpToPx(getContext(), 2)));
mAdapter = new CloneAppListAdapter(getActivity());
mRecyclerView.setAdapter(mAdapter);
mAdapter.setOnItemClickListener(new CloneAppListAdapter.ItemEventListener() {
@Override
public void onItemClick(AppInfo info, int position) {
int count = mAdapter.getSelectedCount();
if (!mAdapter.isIndexSelected(position)) {
if (count >= 9) {
Toast.makeText(getContext(), "No more then 9 apps can be chosen at a time!", Toast.LENGTH_SHORT).show();
return;
}
}
mAdapter.toggleSelected(position);
}
@Override
public boolean isSelectable(int position) {
return mAdapter.isIndexSelected(position) || mAdapter.getSelectedCount() < 9;
}
});
mAdapter.setSelectionListener(count -> {
mInstallButton.setEnabled(count > 0);
mInstallButton.setText(String.format(Locale.ENGLISH, "Install to SandBox (%d)", count));
});
mInstallButton.setOnClickListener(v -> {
Integer[] selectedIndices = mAdapter.getSelectedIndices();
ArrayList<AppInfoLite> dataList = new ArrayList<AppInfoLite>(selectedIndices.length);
for (int index : selectedIndices) {
AppInfo info = mAdapter.getItem(index);
dataList.add(new AppInfoLite(info.packageName, info.path, info.fastOpen));
}
Intent data = new Intent();
data.putParcelableArrayListExtra(VCommends.EXTRA_APP_INFO_LIST, dataList);
getActivity().setResult(Activity.RESULT_OK, data);
getActivity().finish();
});
new ListAppPresenterImpl(getActivity(), this, getSelectFrom()).start();
}
use of android.support.v7.widget.StaggeredGridLayoutManager in project VirtualApp by asLody.
the class SmartRecyclerAdapter method onCreateViewHolder.
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = null;
if (viewType == TYPE_HEADER) {
itemView = headerView;
} else if (viewType == TYPE_FOOTER) {
itemView = footerView;
}
if (itemView != null) {
//set StaggeredGridLayoutManager header & footer view
if (layoutManager instanceof StaggeredGridLayoutManager) {
ViewGroup.LayoutParams targetParams = itemView.getLayoutParams();
StaggeredGridLayoutManager.LayoutParams StaggerLayoutParams;
if (targetParams != null) {
StaggerLayoutParams = new StaggeredGridLayoutManager.LayoutParams(targetParams.width, targetParams.height);
} else {
StaggerLayoutParams = new StaggeredGridLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
StaggerLayoutParams.setFullSpan(true);
itemView.setLayoutParams(StaggerLayoutParams);
}
return new RecyclerView.ViewHolder(itemView) {
};
}
return super.onCreateViewHolder(parent, viewType);
}
use of android.support.v7.widget.StaggeredGridLayoutManager in project Meizhi by drakeet.
the class MainActivity method setupRecyclerView.
private void setupRecyclerView() {
final StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(layoutManager);
mMeizhiListAdapter = new MeizhiListAdapter(this, mMeizhiList);
mRecyclerView.setAdapter(mMeizhiListAdapter);
new Once(this).show("tip_guide_6", () -> {
Snackbar.make(mRecyclerView, getString(R.string.tip_guide), Snackbar.LENGTH_INDEFINITE).setAction(R.string.i_know, v -> {
}).show();
});
mRecyclerView.addOnScrollListener(getOnBottomListener(layoutManager));
mMeizhiListAdapter.setOnMeizhiTouchListener(getOnMeizhiTouchListener());
}
use of android.support.v7.widget.StaggeredGridLayoutManager in project InstaMaterial by frogermcs.
the class UserProfileActivity method setupUserProfileGrid.
private void setupUserProfileGrid() {
final StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
rvUserProfile.setLayoutManager(layoutManager);
rvUserProfile.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
userPhotosAdapter.setLockedAnimations(true);
}
});
}
use of android.support.v7.widget.StaggeredGridLayoutManager in project android-advancedrecyclerview by h6ah4i.
the class DraggableStaggeredGridExampleFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
mLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
// Start dragging after long press
mRecyclerViewDragDropManager.setInitiateOnLongPress(true);
mRecyclerViewDragDropManager.setInitiateOnMove(false);
mRecyclerViewDragDropManager.setLongPressTimeout(750);
//adapter
final DraggableStaggeredGridExampleAdapter myItemAdapter = new DraggableStaggeredGridExampleAdapter(getDataProvider());
mAdapter = myItemAdapter;
// wrap for dragging
mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter);
final GeneralItemAnimator animator = new DraggableItemAnimator();
mRecyclerView.setLayoutManager(mLayoutManager);
// requires *wrapped* adapter
mRecyclerView.setAdapter(mWrappedAdapter);
mRecyclerView.setItemAnimator(animator);
mRecyclerView.setHasFixedSize(false);
//noinspection StatementWithEmptyBody
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
}
mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
// for debugging
// animator.setDebug(true);
// animator.setMoveDuration(2000);
}
Aggregations