use of com.hippo.easyrecyclerview.EasyRecyclerView in project EhViewer by seven332.
the class GalleryCommentsScene method onCreateView3.
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.scene_gallery_comments, container, false);
mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
mEditPanel = ViewUtils.$$(view, R.id.edit_panel);
mSendImage = (ImageView) ViewUtils.$$(mEditPanel, R.id.send);
mEditText = (EditText) ViewUtils.$$(mEditPanel, R.id.edit_text);
mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout);
mFab = (FloatingActionButton) ViewUtils.$$(view, R.id.fab);
Context context = getContext2();
Assert.assertNotNull(context);
Resources resources = context.getResources();
int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab);
Drawable drawable = DrawableManager.getDrawable(context, R.drawable.big_weird_face);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
tip.setCompoundDrawables(null, drawable, null, null);
mAdapter = new CommentAdapter();
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(LinearDividerItemDecoration.VERTICAL, context.getResources().getColor(R.color.divider), LayoutUtils.dp2pix(context, 1));
decoration.setShowLastDivider(true);
mRecyclerView.addItemDecoration(decoration);
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setOnItemClickListener(this);
mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop(), mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom() + paddingBottomFab);
// Cancel change animator
RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
if (itemAnimator instanceof DefaultItemAnimator) {
((DefaultItemAnimator) itemAnimator).setSupportsChangeAnimations(false);
}
mSendImage.setOnClickListener(this);
mFab.setOnClickListener(this);
addAboveSnackView(mEditPanel);
addAboveSnackView(mFabLayout);
mViewTransition = new ViewTransition(mRecyclerView, tip);
updateView(false);
return view;
}
use of com.hippo.easyrecyclerview.EasyRecyclerView in project EhViewer by seven332.
the class DownloadLabelsScene method onCreateView3.
@SuppressWarnings("deprecation")
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.scene_label_list, container, false);
mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
mViewTransition = new ViewTransition(mRecyclerView, tip);
Context context = getContext2();
Assert.assertNotNull(context);
Drawable drawable = DrawableManager.getDrawable(context, R.drawable.big_label);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
tip.setCompoundDrawables(null, drawable, null, null);
tip.setText(R.string.no_download_label);
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
RecyclerViewTouchActionGuardManager guardManager = new RecyclerViewTouchActionGuardManager();
guardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
guardManager.setEnabled(true);
// drag & drop manager
RecyclerViewDragDropManager dragDropManager = new RecyclerViewDragDropManager();
dragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) context.getResources().getDrawable(R.drawable.shadow_8dp));
// swipe manager
RecyclerViewSwipeManager swipeManager = new RecyclerViewSwipeManager();
RecyclerView.Adapter adapter = new LabelAdapter();
adapter.setHasStableIds(true);
// wrap for dragging
adapter = dragDropManager.createWrappedAdapter(adapter);
// wrap for swiping
adapter = swipeManager.createWrappedAdapter(adapter);
mAdapter = adapter;
final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
animator.setSupportsChangeAnimations(false);
mRecyclerView.hasFixedSize();
mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
mRecyclerView.setAdapter(adapter);
mRecyclerView.setItemAnimator(animator);
guardManager.attachRecyclerView(mRecyclerView);
swipeManager.attachRecyclerView(mRecyclerView);
dragDropManager.attachRecyclerView(mRecyclerView);
updateView();
return view;
}
use of com.hippo.easyrecyclerview.EasyRecyclerView in project EhViewer by seven332.
the class DownloadsScene method onItemLongClick.
@Override
public boolean onItemLongClick(EasyRecyclerView parent, View view, int position, long id) {
EasyRecyclerView recyclerView = mRecyclerView;
if (recyclerView == null) {
return false;
}
if (!recyclerView.isInCustomChoice()) {
recyclerView.intoCustomChoiceMode();
}
recyclerView.toggleItemChecked(position);
return true;
}
use of com.hippo.easyrecyclerview.EasyRecyclerView in project EhViewer by seven332.
the class DownloadsScene method onClickSecondaryFab.
@Override
public void onClickSecondaryFab(FabLayout view, FloatingActionButton fab, int position) {
Context context = getContext2();
Activity activity = getActivity2();
EasyRecyclerView recyclerView = mRecyclerView;
if (null == context || null == activity || null == recyclerView) {
return;
}
if (0 == position) {
recyclerView.checkAll();
} else {
List<DownloadInfo> list = mList;
if (list == null) {
return;
}
LongList gidList = null;
List<DownloadInfo> downloadInfoList = null;
// Start, Stop, Delete
boolean collectGid = position == 1 || position == 2 || position == 3;
// Delete or Move
boolean collectDownloadInfo = position == 3 || position == 4;
if (collectGid) {
gidList = new LongList();
}
if (collectDownloadInfo) {
downloadInfoList = new LinkedList<>();
}
SparseBooleanArray stateArray = recyclerView.getCheckedItemPositions();
for (int i = 0, n = stateArray.size(); i < n; i++) {
if (stateArray.valueAt(i)) {
DownloadInfo info = list.get(stateArray.keyAt(i));
if (collectDownloadInfo) {
downloadInfoList.add(info);
}
if (collectGid) {
gidList.add(info.gid);
}
}
}
switch(position) {
case 1:
{
// Start
Intent intent = new Intent(activity, DownloadService.class);
intent.setAction(DownloadService.ACTION_START_RANGE);
intent.putExtra(DownloadService.KEY_GID_LIST, gidList);
activity.startService(intent);
// Cancel check mode
recyclerView.outOfCustomChoiceMode();
break;
}
case 2:
{
// Stop
if (null != mDownloadManager) {
mDownloadManager.stopRangeDownload(gidList);
}
// Cancel check mode
recyclerView.outOfCustomChoiceMode();
break;
}
case 3:
{
// Delete
CheckBoxDialogBuilder builder = new CheckBoxDialogBuilder(context, getString(R.string.download_remove_dialog_message_2, gidList.size()), getString(R.string.download_remove_dialog_check_text), Settings.getRemoveImageFiles());
DeleteRangeDialogHelper helper = new DeleteRangeDialogHelper(downloadInfoList, gidList, builder);
builder.setTitle(R.string.download_remove_dialog_title).setPositiveButton(android.R.string.ok, helper).show();
break;
}
case 4:
{
// Move
List<DownloadLabel> labelRawList = EhApplication.getDownloadManager(context).getLabelList();
List<String> labelList = new ArrayList<>(labelRawList.size() + 1);
labelList.add(getString(R.string.default_download_label_name));
for (int i = 0, n = labelRawList.size(); i < n; i++) {
labelList.add(labelRawList.get(i).getLabel());
}
String[] labels = labelList.toArray(new String[labelList.size()]);
MoveDialogHelper helper = new MoveDialogHelper(labels, downloadInfoList);
new AlertDialog.Builder(context).setTitle(R.string.download_move_dialog_title).setItems(labels, helper).show();
break;
}
}
}
}
use of com.hippo.easyrecyclerview.EasyRecyclerView in project EhViewer by seven332.
the class DownloadsScene method onItemClick.
@Override
public boolean onItemClick(EasyRecyclerView parent, View view, int position, long id) {
Activity activity = getActivity2();
EasyRecyclerView recyclerView = mRecyclerView;
if (null == activity || null == recyclerView) {
return false;
}
if (recyclerView.isInCustomChoice()) {
recyclerView.toggleItemChecked(position);
return true;
} else {
List<DownloadInfo> list = mList;
if (list == null) {
return false;
}
if (position < 0 && position >= list.size()) {
return false;
}
Intent intent = new Intent(activity, GalleryActivity.class);
intent.setAction(GalleryActivity.ACTION_EH);
intent.putExtra(GalleryActivity.KEY_GALLERY_INFO, list.get(position));
startActivity(intent);
return true;
}
}
Aggregations