public void finish(boolean animate) { if (mStarted) { mRecyclerView.removeItemDecoration(this); } final RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator(); if (itemAnimator != null) { itemAnimator.endAnimations(); } mRecyclerView.stopScroll(); if (mSwapTargetItem != null) { // return to default position updateSwapTargetTranslation(mDraggingItem, mSwapTargetItem, mCurTranslationPhase); moveToDefaultPosition(mSwapTargetItem.itemView, animate); mSwapTargetItem = null; } mRange = null; mDraggingItem = null; mTranslationY = 0; mDraggingItemHeight = 0; mCurTranslationPhase = 0.0f; mReqTranslationPhase = 0.0f; mStarted = false; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_big); recyclerView = (RecyclerView) findViewById(R.id.linear_recycler_view); datalist = new ArrayList<bigItem>(); mAdapter = new bigAdapter(datalist, this, this); recyclerView.setAdapter(mAdapter); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(linearLayoutManager); RecyclerView.ItemAnimator ia = new DefaultItemAnimator(); ia.setAddDuration(200); ia.setRemoveDuration(200); recyclerView.setItemAnimator(ia); imageid = R.drawable.ie; add = (Button) findViewById(R.id.add); remove = (Button) findViewById(R.id.remove); removeAll = (Button) findViewById(R.id.removeAll); change = (Button) findViewById(R.id.change); setListener(); }
public void finish(boolean animate) { if (mStarted) { mRecyclerView.removeItemDecoration(this); } final RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator(); if (itemAnimator != null) { itemAnimator.endAnimations(); } mRecyclerView.stopScroll(); // return to default position updateDraggingItemPosition(mTranslationX, mTranslationY); if (mDraggingItemViewHolder != null) { moveToDefaultPosition(mDraggingItemViewHolder.itemView, animate); } // show if (mDraggingItemViewHolder != null) { mDraggingItemViewHolder.itemView.setVisibility(View.VISIBLE); } mDraggingItemViewHolder = null; if (mDraggingItemImage != null) { mDraggingItemImage.recycle(); mDraggingItemImage = null; } mRange = null; mTranslationX = 0; mTranslationY = 0; mTranslationLeftLimit = 0; mTranslationRightLimit = 0; mTranslationTopLimit = 0; mTranslationBottomLimit = 0; mTouchPositionX = 0; mTouchPositionY = 0; mStarted = false; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_animate_list); radioGroup = (RadioGroup) findViewById(R.id.radioGroup); RecyclerView.ItemAnimator itemAnimator = new DefaultItemAnimator(); itemAnimator.setAddDuration(500); itemAnimator.setRemoveDuration(500); RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list); animAdapter = new AnimAdapter(); animAdapter.setOnItemClickListener(this); recyclerView.setItemAnimator(itemAnimator); recyclerView.setLayoutManager( new StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)); recyclerView.setAdapter(animAdapter); ItemTouchHelper ith = new ItemTouchHelper(_ithCallback); ith.attachToRecyclerView(recyclerView); }