本文整理汇总了Java中com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator类的典型用法代码示例。如果您正苦于以下问题:Java SwipeDismissItemAnimator类的具体用法?Java SwipeDismissItemAnimator怎么用?Java SwipeDismissItemAnimator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SwipeDismissItemAnimator类属于com.h6ah4i.android.widget.advrecyclerview.animator包,在下文中一共展示了SwipeDismissItemAnimator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateDialog
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator; //导入依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = LayoutInflater.from(builder.getContext());
View popupcontent = inflater.inflate(R.layout.popup_portrait_chooser,null,false);
builder.setView(popupcontent);
list = (AutofitRecyclerView) popupcontent.findViewById(R.id.popup_portrait_chooser_list);
adapter = new PortraitAdapter(imageUris);
adapter.setMinHeight(columnHeight);
adapter.setMinWidth(columnWidth);
adapter.setScaleType(scaleType);
list.setColumnWidth(columnWidth);
list.setAdapter(adapter);
GridLayoutManager layoutManager = new GridLayoutManager(getActivity(),3);
list.setLayoutManager(layoutManager);
list.setItemAnimator(new SwipeDismissItemAnimator());
// additional decorations
//noinspection StatementWithEmptyBody
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
list.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) getResources().getDrawable(R.drawable.material_shadow_z1)));
}
adapter.setEventListener(this);
builder.setTitle("Wähle ein Bild...");
AlertDialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(true);
return dialog;
}
示例2: onCreate
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RecyclerView rv = (RecyclerView) findViewById(R.id.recycler_view);
RecyclerViewSwipeManager swipeMgr = new RecyclerViewSwipeManager();
rv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
rv.setAdapter(swipeMgr.createWrappedAdapter(new Adapter()));
rv.setItemAnimator(new SwipeDismissItemAnimator());
swipeMgr.attachRecyclerView(rv);
rv.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(this, R.drawable.list_divider), true));
}
示例3: onCreateTestTargetItemAnimator
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator; //导入依赖的package包/类
@Override
protected GeneralItemAnimator onCreateTestTargetItemAnimator() {
return new SwipeDismissItemAnimator();
}
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:5,代码来源:SwipeDismissItemAnimatorTest.java
示例4: onCreate
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStatusBarColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimaryDark));
ToolbarActivityHelper.setContentView(this, R.layout.activity_record);
setActionBarUpIndicator(DrawableManager.getDrawable(this, R.drawable.v_arrow_left_dark_x24));
View tip = findViewById(R.id.tip);
mRecyclerView = (EasyRecyclerView) findViewById(R.id.recycler_view);
mViewTransition = new ViewTransition(tip, mRecyclerView);
// Layout Manager
int interval = getResources().getDimensionPixelOffset(R.dimen.card_interval);
if (getResources().getBoolean(R.bool.two_way)) {
mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
MarginItemDecoration decoration = new MarginItemDecoration(interval, interval, interval, interval, interval);
mRecyclerView.addItemDecoration(decoration);
decoration.applyPaddings(mRecyclerView);
mRecyclerView.setItemAnimator(new SlideInUpAnimator());
} else {
int halfInterval = interval / 2;
mRecyclerView.addItemDecoration(new RawMarginItemDecoration(0, halfInterval, 0, halfInterval));
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setPadding(0, halfInterval, 0, halfInterval);
}
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
mRecyclerViewTouchActionGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
mRecyclerViewTouchActionGuardManager.setEnabled(true);
// swipe manager
mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
mAdapter = new RecordAdapter();
mAdapter.setHasStableIds(true);
mWrappedAdapter = mRecyclerViewSwipeManager.createWrappedAdapter(mAdapter); // wrap for swiping
final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
// Change animations are enabled by default since support-v7-recyclerview v22.
// Disable the change animation in order to make turning back animation of swiped item works properly.
animator.setSupportsChangeAnimations(false);
mRecyclerView.hasFixedSize();
mRecyclerView.setAdapter(mWrappedAdapter); // requires *wrapped* adapter
mRecyclerView.setItemAnimator(animator);
mRecyclerView.setOnItemClickListener(this);
mRecyclerView.setSelector(Ripple.generateRippleDrawable(this, ResourcesUtils.getAttrBoolean(this, R.attr.dark)));
mRecyclerView.setDrawSelectorOnTop(true);
mRecyclerView.setClipToPadding(false);
mRecyclerView.setClipChildren(false);
// NOTE:
// The initialization order is very important! This order determines the priority of touch event handling.
//
// priority: TouchActionGuard > Swipe > DragAndDrop
mRecyclerViewTouchActionGuardManager.attachRecyclerView(mRecyclerView);
mRecyclerViewSwipeManager.attachRecyclerView(mRecyclerView);
updateLazyList();
checkEmpty(false);
Messenger.getInstance().register(Constants.MESSENGER_ID_UPDATE_RECORD, this);
}
示例5: onCreate
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStatusBarColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimaryDark));
ToolbarActivityHelper.setContentView(this, R.layout.activity_draft);
setActionBarUpIndicator(DrawableManager.getDrawable(this, R.drawable.v_arrow_left_dark_x24));
mTip = findViewById(R.id.tip);
mRecyclerView = (EasyRecyclerView) findViewById(R.id.recycler_view);
mViewTransition = new ViewTransition(mTip, mRecyclerView);
// Layout Manager
mLayoutManager = new LinearLayoutManager(this);
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
mRecyclerViewTouchActionGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
mRecyclerViewTouchActionGuardManager.setEnabled(true);
// swipe manager
mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
mAdapter = new DraftAdapter();
mAdapter.setHasStableIds(true);
mWrappedAdapter = mRecyclerViewSwipeManager.createWrappedAdapter(mAdapter); // wrap for swiping
final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
// Change animations are enabled by default since support-v7-recyclerview v22.
// Disable the change animation in order to make turning back animation of swiped item works properly.
animator.setSupportsChangeAnimations(false);
mRecyclerView.hasFixedSize();
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mWrappedAdapter); // requires *wrapped* adapter
mRecyclerView.setItemAnimator(animator);
mRecyclerView.setOnItemClickListener(this);
// NOTE:
// The initialization order is very important! This order determines the priority of touch event handling.
//
// priority: TouchActionGuard > Swipe > DragAndDrop
mRecyclerViewTouchActionGuardManager.attachRecyclerView(mRecyclerView);
mRecyclerViewSwipeManager.attachRecyclerView(mRecyclerView);
updateLazyList();
checkEmpty(false);
}
示例6: onCreate
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!handlerIntent(getIntent())) {
finish();
return;
}
setStatusBarColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimaryDark));
ToolbarActivityHelper.setContentView(this, R.layout.activity_forum_sort);
setActionBarUpIndicator(DrawableManager.getDrawable(this, R.drawable.v_arrow_left_dark_x24));
mTip = findViewById(R.id.tip);
mRecyclerView = (EasyRecyclerView) findViewById(R.id.recycler_view);
mViewTransition = new ViewTransition(mTip, mRecyclerView);
// Layout Manager
mLayoutManager = new LinearLayoutManager(this);
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
mRecyclerViewTouchActionGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
mRecyclerViewTouchActionGuardManager.setEnabled(true);
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
(NinePatchDrawable) getResources().getDrawable(R.drawable.shadow_8dp));
// swipe manager
mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
mAdapter = new ForumAdapter();
mAdapter.setHasStableIds(true);
mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(mAdapter); // wrap for dragging
mWrappedAdapter = mRecyclerViewSwipeManager.createWrappedAdapter(mWrappedAdapter); // wrap for swiping
final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
// Change animations are enabled by default since support-v7-recyclerview v22.
// Disable the change animation in order to make turning back animation of swiped item works properly.
animator.setSupportsChangeAnimations(false);
mRecyclerView.hasFixedSize();
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mWrappedAdapter); // requires *wrapped* adapter
mRecyclerView.setItemAnimator(animator);
// NOTE:
// The initialization order is very important! This order determines the priority of touch event handling.
//
// priority: TouchActionGuard > Swipe > DragAndDrop
mRecyclerViewTouchActionGuardManager.attachRecyclerView(mRecyclerView);
mRecyclerViewSwipeManager.attachRecyclerView(mRecyclerView);
mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
updateLazyList(false);
if (Settings.getGuideSortForumsActivity()) {
showEyeGuide();
}
}
示例7: onCreate
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//获取RecycleView,创建LayoutManager
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mLayoutManager = new LinearLayoutManager(this);
// touch guard manager 阻止当Swipe时列表滚动
mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
mRecyclerViewTouchActionGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
mRecyclerViewTouchActionGuardManager.setEnabled(true);
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
(NinePatchDrawable) getResources().getDrawable(R.drawable.material_shadow_z3_xxhdpi));
// swipe manager
mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
//adapter
for(int i=0;i<100;i++){
dataList.add(new MyItem(i,"测试数据"+i));
}
mAdapter = new MyAdapter(dataList);
mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(mAdapter); //处理一下mAdapter可以拖拽
mWrappedAdapter = mRecyclerViewSwipeManager.createWrappedAdapter(mWrappedAdapter); //处理一下mAdapter可以滑动删除
final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
// Change animations are enabled by default since support-v7-recyclerview v22.
// Disable the change animation in order to make turning back animation of swiped item works properly.
animator.setSupportsChangeAnimations(false);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mWrappedAdapter); // 注意设置的是mWrappedAdapter
mRecyclerView.setItemAnimator(animator);
//additional decorations
//noinspection StatementWithEmptyBody
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) getResources().getDrawable(R.drawable.material_shadow_z3_xxhdpi)));
}
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(getResources().getDrawable(R.drawable.list_divider), true));
// NOTE:
// 初始化的顺序十分重要,这决定了处理Touch事件的优先级
// 优先级: TouchActionGuard > Swipe > DragAndDrop
mRecyclerViewTouchActionGuardManager.attachRecyclerView(mRecyclerView);
mRecyclerViewSwipeManager.attachRecyclerView(mRecyclerView);
mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
}
示例8: finishSwiping
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator; //导入依赖的package包/类
private void finishSwiping(int result) {
final RecyclerView.ViewHolder swipingItem = mSwipingItem;
if (swipingItem == null) {
return;
}
if (mRecyclerView != null && mRecyclerView.getParent() != null) {
mRecyclerView.getParent().requestDisallowInterceptTouchEvent(false);
}
final int itemPosition = mSwipingItemPosition;
mVelocityTracker.clear();
mSwipingItem = null;
mSwipingItemPosition = RecyclerView.NO_POSITION;
mLastTouchX = 0;
mInitialTouchX = 0;
mTouchedItemOffsetX = 0;
mCheckingTouchSlop = RecyclerView.NO_ID;
mSwipingItemReactionType = 0;
if (mSwipingItemOperator != null) {
mSwipingItemOperator.finish();
mSwipingItemOperator = null;
}
final boolean toLeft = (result == RESULT_SWIPED_LEFT);
int afterReaction = AFTER_SWIPE_REACTION_DEFAULT;
if (mAdapter != null) {
afterReaction = mAdapter.onSwipeItemFinished(swipingItem, itemPosition, result);
}
afterReaction = correctAfterReaction(result, afterReaction);
switch (afterReaction) {
case AFTER_SWIPE_REACTION_DEFAULT:
mItemSlideAnimator.slideToDefaultPosition(swipingItem, true, mReturnToDefaultPositionAnimationDuration);
break;
case AFTER_SWIPE_REACTION_MOVE_TO_SWIPED_DIRECTION:
mItemSlideAnimator.slideToOutsideOfWindow(
swipingItem, toLeft, true, mMoveToOutsideWindowAnimationDuration);
break;
case AFTER_SWIPE_REACTION_REMOVE_ITEM: {
final RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
final long removeAnimationDuration = (itemAnimator != null) ? itemAnimator.getRemoveDuration() : 0;
if (supportsViewPropertyAnimator()) {
final long moveAnimationDuration = (itemAnimator != null) ? itemAnimator.getMoveDuration() : 0;
final RemovingItemDecorator decorator = new RemovingItemDecorator(
mRecyclerView, swipingItem, removeAnimationDuration, moveAnimationDuration);
decorator.setMoveAnimationInterpolator(SwipeDismissItemAnimator.MOVE_INTERPOLATOR);
decorator.start();
}
mItemSlideAnimator.slideToOutsideOfWindow(
swipingItem, toLeft, true, removeAnimationDuration);
}
break;
default:
throw new IllegalStateException("Unknwon after reaction type: " + afterReaction);
}
if (mAdapter != null) {
mAdapter.onSwipeItemFinished2(swipingItem, itemPosition, result, afterReaction);
}
}
示例9: initRecyclerView
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator; //导入依赖的package包/类
private void initRecyclerView() {
mRecyclerView = (RecyclerView) getView().findViewById(R.id.recylerView);
mLayoutManager = new LinearLayoutManager(getActivity());
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
mRecyclerViewTouchActionGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
mRecyclerViewTouchActionGuardManager.setEnabled(true);
// drag & drop manager 拖拽排序的manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
(NinePatchDrawable) getResources().getDrawable(R.drawable.material_shadow_z3_xxhdpi));
// swipe manager 滑动item的manager
mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
//adapter
mAdapter = new MyTaskAdapter(context, list);
mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(mAdapter); // wrap for swiping
mWrappedAdapter = mRecyclerViewSwipeManager.createWrappedAdapter(mWrappedAdapter); // wrap for swiping
final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
// Change animations are enabled by default since support-v7-recyclerview v22.
// Disable the change animation in order to make turning back animation of swiped item works properly.
animator.setSupportsChangeAnimations(false);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mWrappedAdapter); // requires *wrapped* adapter
mRecyclerView.setItemAnimator(animator);
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) getResources().getDrawable(R.drawable.material_shadow_z1_xxhdpi)));
}
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(getResources().getDrawable(R.drawable.list_divider), true));
// NOTE:
// The initialization order is very important! This order determines the priority of touch event handling.
// priority: TouchActionGuard > Swipe > DragAndDrop
mRecyclerViewTouchActionGuardManager.attachRecyclerView(mRecyclerView);
mRecyclerViewSwipeManager.attachRecyclerView(mRecyclerView);
mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
}
示例10: init
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator; //导入依赖的package包/类
/**
* 初始化
*/
private void init() {
listTask = new ArrayList<Task>();
listDay = new ArrayList<Day>();
adapterDay = new DayAdapter(context, listDay);
mRecyclerView = (RecyclerView) findViewById(R.id.lv_all_zixi);
lv_day = (ListView) findViewById(R.id.lv_day);
tv_day = (TextView) findViewById(R.id.tv_day);
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
mRecyclerViewTouchActionGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
mRecyclerViewTouchActionGuardManager.setEnabled(true);
// drag & drop manager 拖拽排序的manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
(NinePatchDrawable) getResources().getDrawable(R.drawable.material_shadow_z3_xxhdpi));
// swipe manager 滑动item的manager
mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
//adapter
mAdapter = new MyTaskAdapter(context, listTask);
mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(mAdapter); // wrap for swiping
mWrappedAdapter = mRecyclerViewSwipeManager.createWrappedAdapter(mWrappedAdapter); // wrap for swiping
final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
// Change animations are enabled by default since support-v7-recyclerview v22.
// Disable the change animation in order to make turning back animation of swiped item works properly.
animator.setSupportsChangeAnimations(false);
mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
mRecyclerView.setAdapter(mWrappedAdapter); // requires *wrapped* adapter
mRecyclerView.setItemAnimator(animator);
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) getResources().getDrawable(R.drawable.material_shadow_z1_xxhdpi)));
}
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(getResources().getDrawable(R.drawable.list_divider), true));
// NOTE:
// The initialization order is very important! This order determines the priority of touch event handling.
// priority: TouchActionGuard > Swipe > DragAndDrop
mRecyclerViewTouchActionGuardManager.attachRecyclerView(mRecyclerView);
mRecyclerViewSwipeManager.attachRecyclerView(mRecyclerView);
mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
lv_day.setAdapter(adapterDay);
// // 允许加载更多
// lv_day.setPullLoadEnable(true);
// // 允许下拉
// lv_day.setPullRefreshEnable(true);
// // 设置监听器
// lv_day.setXListViewListener(this);
// lv_day.pullRefreshing();
lv_day.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Day d = listDay.get(position);
Calendar tmp = Calendar.getInstance();
tmp.set(d.getYear(), d.getMonth(), d.getDay(), 0, 0, 1);
tv_day.setText(TaskUtil.getZixiDateS(tmp.getTimeInMillis()));
getZixiByDay(tmp);
}
});
// 加载数据
initData();
}
示例11: onViewCreated
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator; //导入依赖的package包/类
@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 LinearLayoutManager(getActivity());
final Parcelable eimSavedState = (savedInstanceState != null) ? savedInstanceState.getParcelable(SAVED_STATE_EXPANDABLE_ITEM_MANAGER) : null;
mRecyclerViewExpandableItemManager = new RecyclerViewExpandableItemManager(eimSavedState);
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
mRecyclerViewTouchActionGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
mRecyclerViewTouchActionGuardManager.setEnabled(true);
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
(NinePatchDrawable) getResources().getDrawable(R.drawable.material_shadow_z3));
// swipe manager
mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
//adapter
getDataProvider();
final MyExpandableDraggableWithSectionItemAdapter myItemAdapter = new MyExpandableDraggableWithSectionItemAdapter(getDataProvider());
mAdapter = myItemAdapter;
mWrappedAdapter = mRecyclerViewExpandableItemManager.createWrappedAdapter(myItemAdapter); // wrap for expanding
mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(mWrappedAdapter); // wrap for dragging
mWrappedAdapter = mRecyclerViewSwipeManager.createWrappedAdapter(mWrappedAdapter); // wrap for swiping
final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
// Change animations are enabled by default since support-v7-recyclerview v22.
// Need to disable them when using animation indicator.
animator.setSupportsChangeAnimations(false);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mWrappedAdapter); // requires *wrapped* adapter
mRecyclerView.setItemAnimator(animator);
mRecyclerView.setHasFixedSize(false);
// additional decorations
//noinspection StatementWithEmptyBody
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) getResources().getDrawable(R.drawable.material_shadow_z1)));
}
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(getResources().getDrawable(R.drawable.list_divider), true));
// NOTE:
// The initialization order is very important! This order determines the priority of touch event handling.
//
// priority: TouchActionGuard > Swipe > DragAndDrop > ExpandableItem
mRecyclerViewTouchActionGuardManager.attachRecyclerView(mRecyclerView);
mRecyclerViewSwipeManager.attachRecyclerView(mRecyclerView);
mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
mRecyclerViewExpandableItemManager.attachRecyclerView(mRecyclerView);
}
示例12: finishSwiping
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator; //导入依赖的package包/类
private void finishSwiping(int result) {
final RecyclerView.ViewHolder swipingItem = mSwipingItem;
if (swipingItem == null) {
return;
}
if (mRecyclerView != null && mRecyclerView.getParent() != null) {
mRecyclerView.getParent().requestDisallowInterceptTouchEvent(false);
}
final int itemPosition = mSwipingItemPosition;
mVelocityTracker.clear();
mSwipingItem = null;
mSwipingItemPosition = RecyclerView.NO_POSITION;
mLastTouchX = 0;
mInitialTouchX = 0;
mTouchedItemOffsetX = 0;
mCheckingTouchSlop = RecyclerView.NO_ID;
mSwipingItemReactionType = 0;
if (mSwipingItemOperator != null) {
mSwipingItemOperator.finish();
mSwipingItemOperator = null;
}
final boolean toLeft = (result == RESULT_SWIPED_LEFT);
int afterReaction = AFTER_SWIPE_REACTION_DEFAULT;
if (mAdapter != null) {
afterReaction = mAdapter.onSwipeItemFinished(swipingItem, itemPosition, result);
}
afterReaction = correctAfterReaction(result, afterReaction);
switch (afterReaction) {
case AFTER_SWIPE_REACTION_DEFAULT:
mItemSlideAnimator.slideToDefaultPosition(swipingItem, true, mReturnToDefaultPositionAnimationDuration);
break;
case AFTER_SWIPE_REACTION_MOVE_TO_SWIPED_DIRECTION:
mItemSlideAnimator.slideToOutsideOfWindow(
swipingItem, toLeft, true, mMoveToOutsideWindowAnimationDuration);
break;
case AFTER_SWIPE_REACTION_REMOVE_ITEM: {
final RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
final long removeAnimationDuration = (itemAnimator != null) ? itemAnimator.getRemoveDuration() : 0;
if (supportsViewPropertyAnimator()) {
final long moveAnimationDuration = (itemAnimator != null) ? itemAnimator.getMoveDuration() : 0;
final RemovingItemDecorator decorator = new RemovingItemDecorator(
mRecyclerView, swipingItem, removeAnimationDuration, moveAnimationDuration);
decorator.setMoveAnimationInterpolator(SwipeDismissItemAnimator.MOVE_INTERPOLATOR);
decorator.start();
}
mItemSlideAnimator.slideToOutsideOfWindow(
swipingItem, toLeft, true, removeAnimationDuration);
}
break;
default:
throw new IllegalStateException("Unknwon after reaction type: " + afterReaction);
}
if (mAdapter != null) {
mAdapter.onSwipeItemFinished2(swipingItem, itemPosition, result, afterReaction);
}
// raise onItemSwipeFinished() event
if (mItemSwipeEventListener != null) {
mItemSwipeEventListener.onItemSwipeFinished(itemPosition, result, afterReaction);
}
}
示例13: onCreateView3
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator; //导入依赖的package包/类
@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_search);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
tip.setCompoundDrawables(null, drawable, null, null);
tip.setText(R.string.no_quick_search);
// 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 QuickSearchAdapter();
adapter.setHasStableIds(true);
adapter = dragDropManager.createWrappedAdapter(adapter); // wrap for dragging
adapter = swipeManager.createWrappedAdapter(adapter); // wrap for swiping
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;
}
示例14: onCreateView3
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater,
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.scene_history, container, false);
View content = ViewUtils.$$(view, R.id.content);
mRecyclerView = (EasyRecyclerView) ViewUtils.$$(content, R.id.recycler_view);
FastScroller fastScroller = (FastScroller) ViewUtils.$$(content, R.id.fast_scroller);
TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
mViewTransition = new ViewTransition(content, tip);
Context context = getContext2();
Assert.assertNotNull(context);
Resources resources = context.getResources();
Drawable drawable = DrawableManager.getDrawable(context, R.drawable.big_history);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
tip.setCompoundDrawables(null, drawable, null, null);
RecyclerViewTouchActionGuardManager guardManager = new RecyclerViewTouchActionGuardManager();
guardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
guardManager.setEnabled(true);
RecyclerViewSwipeManager swipeManager = new RecyclerViewSwipeManager();
mAdapter = new HistoryAdapter();
mAdapter.setHasStableIds(true);
mAdapter = swipeManager.createWrappedAdapter(mAdapter);
mRecyclerView.setAdapter(mAdapter);
final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
animator.setSupportsChangeAnimations(false);
mRecyclerView.setItemAnimator(animator);
AutoStaggeredGridLayoutManager layoutManager = new AutoStaggeredGridLayoutManager(
0, StaggeredGridLayoutManager.VERTICAL);
layoutManager.setColumnSize(resources.getDimensionPixelOffset(Settings.getDetailSizeResId()));
layoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
mRecyclerView.setDrawSelectorOnTop(true);
mRecyclerView.hasFixedSize();
mRecyclerView.setClipToPadding(false);
mRecyclerView.setOnItemClickListener(this);
mRecyclerView.setOnItemLongClickListener(this);
int interval = resources.getDimensionPixelOffset(R.dimen.gallery_list_interval);
int paddingH = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_h);
int paddingV = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_v);
MarginItemDecoration decoration = new MarginItemDecoration(interval, paddingH, paddingV, paddingH, paddingV);
mRecyclerView.addItemDecoration(decoration);
decoration.applyPaddings(mRecyclerView);
guardManager.attachRecyclerView(mRecyclerView);
swipeManager.attachRecyclerView(mRecyclerView);
fastScroller.attachToRecyclerView(mRecyclerView);
HandlerDrawable handlerDrawable = new HandlerDrawable();
handlerDrawable.setColor(ResourcesUtils.getAttrColor(context, R.attr.colorAccent));
fastScroller.setHandlerDrawable(handlerDrawable);
updateLazyList();
updateView(false);
return view;
}
示例15: onCreateView3
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator; //导入依赖的package包/类
@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);
adapter = dragDropManager.createWrappedAdapter(adapter); // wrap for dragging
adapter = swipeManager.createWrappedAdapter(adapter); // wrap for swiping
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;
}