当前位置: 首页>>代码示例>>Java>>正文


Java RecyclerViewDragDropManager类代码示例

本文整理汇总了Java中com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager的典型用法代码示例。如果您正苦于以下问题:Java RecyclerViewDragDropManager类的具体用法?Java RecyclerViewDragDropManager怎么用?Java RecyclerViewDragDropManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RecyclerViewDragDropManager类属于com.h6ah4i.android.widget.advrecyclerview.draggable包,在下文中一共展示了RecyclerViewDragDropManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUpRecyclerView

import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入依赖的package包/类
private void setUpRecyclerView() {
    recyclerViewDragDropManager = new RecyclerViewDragDropManager();
    final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();

    playingQueueAdapter = new PlayingQueueAdapter(
            ((AppCompatActivity) getActivity()),
            MusicPlayerRemote.getPlayingQueue(),
            MusicPlayerRemote.getPosition(),
            R.layout.item_list,
            false,
            null);
    wrappedAdapter = recyclerViewDragDropManager.createWrappedAdapter(playingQueueAdapter);

    layoutManager = new LinearLayoutManager(getActivity());

    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(wrappedAdapter);
    recyclerView.setItemAnimator(animator);

    recyclerViewDragDropManager.attachRecyclerView(recyclerView);

    layoutManager.scrollToPositionWithOffset(MusicPlayerRemote.getPosition() + 1, 0);
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:24,代码来源:FlatPlayerFragment.java

示例2: onViewCreated

import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入依赖的package包/类
@Override
public void onViewCreated(View aView, @Nullable Bundle aSavedInstanceState) {
    super.onViewCreated(aView, aSavedInstanceState);

    mRecyclerView = (RecyclerView) aView.findViewById(R.id.recycler_view);

    mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
    mRecyclerViewDragDropManager.setInitiateOnLongPress(true);
    mRecyclerViewDragDropManager.setInitiateOnMove(false);

    mLayoutManager = new LinearLayoutManager(getContext());
    mRecyclerView.setLayoutManager(mLayoutManager);

    final DragOnLongPressAdapter myItemAdapter = new DragOnLongPressAdapter(
            ((MainActivity) getActivity()).getDataSet());
    mAdapter = myItemAdapter;
    mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter);
    mRecyclerView.setAdapter(mWrappedAdapter);  // requires *wrapped* adapter
    mRecyclerView.addItemDecoration(
            new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(),
                    R.drawable.list_divider_h), true));
    mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
}
 
开发者ID:DenK91,项目名称:LinkedListInDB,代码行数:24,代码来源:DragOnLongPressFragment.java

示例3: setUpRecyclerView

import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入依赖的package包/类
private void setUpRecyclerView() {
    ViewUtil.setUpFastScrollRecyclerViewColor(this, ((FastScrollRecyclerView) recyclerView), ThemeStore.accentColor(this));
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    if (playlist instanceof AbsCustomPlaylist) {
        adapter = new CustomPlaylistSongAdapter(this, new ArrayList<Song>(), R.layout.item_list, false, this);
        recyclerView.setAdapter(adapter);
    } else {
        recyclerViewDragDropManager = new RecyclerViewDragDropManager();
        final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();
        adapter = new PlaylistSongAdapter(this, new ArrayList<PlaylistSong>(), R.layout.item_list, false, this, new PlaylistSongAdapter.OnMoveItemListener() {
            @Override
            public void onMoveItem(int fromPosition, int toPosition) {
                if (PlaylistsUtil.moveItem(PlaylistDetailActivity.this, playlist.id, fromPosition, toPosition)) {
                    Song song = adapter.getDataSet().remove(fromPosition);
                    adapter.getDataSet().add(toPosition, song);
                    adapter.notifyItemMoved(fromPosition, toPosition);
                }
            }
        });
        wrappedAdapter = recyclerViewDragDropManager.createWrappedAdapter(adapter);

        recyclerView.setAdapter(wrappedAdapter);
        recyclerView.setItemAnimator(animator);

        recyclerViewDragDropManager.attachRecyclerView(recyclerView);
    }

    adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
            checkIsEmpty();
        }
    });
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:36,代码来源:PlaylistDetailActivity.java

示例4: setUpRecyclerView

import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入依赖的package包/类
private void setUpRecyclerView() {
    mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
    final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();

    mPlayingQueueAdapter = new PlayingQueueAdapter(
            (AppCompatActivity) getActivity(),
            MusicPlayerRemote.getPlayingQueue(),
            MusicPlayerRemote.getPosition(),
            R.layout.item_list,
            false,
            null);
    mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(mPlayingQueueAdapter);

    mLayoutManager = new LinearLayoutManager(getContext());

    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setAdapter(mWrappedAdapter);
    mRecyclerView.setItemAnimator(animator);

    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
               /* if (recyclerView.canScrollVertically(RecyclerView.NO_POSITION)) {
                    mAppBarLayout.setElevation(5f);
                } else {
                    mAppBarLayout.setElevation(0f);
                }*/
            }
        }
    });

    mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
    mLayoutManager.scrollToPositionWithOffset(MusicPlayerRemote.getPosition() + 1, 0);
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:37,代码来源:PlayingQueueFragment.java

示例5: setUpRecyclerView

import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入依赖的package包/类
private void setUpRecyclerView() {
    ViewUtil.setUpFastScrollRecyclerViewColor(this,
            ((FastScrollRecyclerView) recyclerView),
            ThemeStore.accentColor(this));
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    if (playlist instanceof AbsCustomPlaylist) {
        adapter = new PlaylistSongAdapter(this, new ArrayList<Song>(), R.layout.item_list, false, this);
        recyclerView.setAdapter(adapter);
    } else {
        recyclerViewDragDropManager = new RecyclerViewDragDropManager();
        final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();
        adapter = new OrderablePlaylistSongAdapter(this, new ArrayList<PlaylistSong>(), R.layout.item_list, false, this, (fromPosition, toPosition) -> {
            if (PlaylistsUtil.moveItem(PlaylistDetailActivity.this, playlist.id, fromPosition, toPosition)) {
                Song song = adapter.getDataSet().remove(fromPosition);
                adapter.getDataSet().add(toPosition, song);
                adapter.notifyItemMoved(fromPosition, toPosition);
            }
        });
        wrappedAdapter = recyclerViewDragDropManager.createWrappedAdapter(adapter);

        recyclerView.setAdapter(wrappedAdapter);
        recyclerView.setItemAnimator(animator);

        recyclerViewDragDropManager.attachRecyclerView(recyclerView);
    }
    adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
            checkIsEmpty();
        }
    });
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:34,代码来源:PlaylistDetailActivity.java

示例6: onBindViewHolder

import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入依赖的package包/类
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
    final MyItem item = mProvider.get(position);

    // set listeners
    // (if the item is *not pinned*, click event comes to the itemView)
    holder.itemView.setOnClickListener(mItemViewOnClickListener);
    // (if the item is *pinned*, click event comes to the mContainer)
    holder.mContainer.setOnClickListener(mSwipeableViewContainerOnClickListener);

    // set text
    holder.mTextView.setText(item.getContent());

    // set background resource (target view ID: container)
    final int dragState = holder.getDragStateFlags();
    final int swipeState = holder.getSwipeStateFlags();

    if (((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_UPDATED) != 0) ||
            ((swipeState & RecyclerViewSwipeManager.STATE_FLAG_IS_UPDATED) != 0)) {
        int bgResId;

        if ((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_ACTIVE) != 0) {
            bgResId = R.drawable.bg_item_dragging_active_state;
        } else if ((dragState & RecyclerViewDragDropManager.STATE_FLAG_DRAGGING) != 0) {
            bgResId = R.drawable.bg_item_dragging_state;
        } else if ((swipeState & RecyclerViewSwipeManager.STATE_FLAG_IS_ACTIVE) != 0) {
            bgResId = R.drawable.bg_item_swiping_active_state;
        } else if ((swipeState & RecyclerViewSwipeManager.STATE_FLAG_SWIPING) != 0) {
            bgResId = R.drawable.bg_item_swiping_state;
        } else {
            bgResId = R.drawable.bg_item_normal_state;
        }

        holder.mContainer.setBackgroundResource(bgResId);
    }

    // set swiping properties
    holder.setSwipeItemSlideAmount(
            item.isPinedToSwipeLeft() ? RecyclerViewSwipeManager.OUTSIDE_OF_THE_WINDOW_LEFT : 0);
}
 
开发者ID:hanks-zyh,项目名称:RecylerView,代码行数:41,代码来源:MyDraggableSwipeableItemAdapter.java

示例7: onBindViewHolder

import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入依赖的package包/类
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {


    MyItem item = dataList.get(position);
    holder.textView.setText(item.getContent());

    // set background resource (target view ID: container)
    final int dragState = holder.getDragStateFlags();
    final int swipeState = holder.getSwipeStateFlags();

    if (((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_UPDATED) != 0) ||
            ((swipeState & RecyclerViewSwipeManager.STATE_FLAG_IS_UPDATED) != 0)) {
        int bgResId;

        if ((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_ACTIVE) != 0) {
            bgResId = R.drawable.bg_item_dragging_active_state;
        } else if ((dragState & RecyclerViewDragDropManager.STATE_FLAG_DRAGGING) != 0) {
            bgResId = R.drawable.bg_item_dragging_state;
        } else if ((swipeState & RecyclerViewSwipeManager.STATE_FLAG_IS_ACTIVE) != 0) {
            bgResId = R.drawable.bg_item_swiping_active_state;
        } else if ((swipeState & RecyclerViewSwipeManager.STATE_FLAG_SWIPING) != 0) {
            bgResId = R.drawable.bg_item_swiping_state;
        } else {
            bgResId = R.drawable.bg_item_normal_state;
        }

        holder.container.setBackgroundResource(bgResId);
    }

    // set swiping properties
    holder.setSwipeItemSlideAmount(
            item.isPinedToSwipeLeft() ? RecyclerViewSwipeManager.OUTSIDE_OF_THE_WINDOW_LEFT : 0);
}
 
开发者ID:hanks-zyh,项目名称:RecylerView,代码行数:35,代码来源:MyAdapter.java

示例8: onBindViewHolder

import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
	TourItem item = _items.get(position);

	holder._name.setText(item.getName());
	holder._description.setText(item.getDescription());
	if(item.getDescription().equals(""))
		holder._description.setVisibility(View.GONE);
	else
		holder._description.setVisibility(View.VISIBLE);

	if(item.hasMainImage()) {
		String image_filepath = item.getMainImageFilepath();
		ImageView image_view = holder._thumbnail;
		Utilities.loadBitmap(image_view, image_filepath, Utilities.dp_to_px(40), Utilities.dp_to_px(40), getActivity());
	} else
		holder._thumbnail.setImageResource(R.drawable.default_thumbnail);

	// set background resource (target view ID: container)
	final int dragState = holder.getDragStateFlags();

	if (((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_UPDATED) != 0)) {
		int bgResId;

		if ((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_ACTIVE) != 0) {
			bgResId = R.drawable.bg_item_dragging_active_state;
		} else if ((dragState & RecyclerViewDragDropManager.STATE_FLAG_DRAGGING) != 0) {
			bgResId = R.drawable.bg_item_dragging_state;
		} else {
			bgResId = R.drawable.bg_item_normal_state;
		}
		holder._container.setBackgroundResource(bgResId);
	}
}
 
开发者ID:WriterOfAlicrow,项目名称:OpenCVTour,代码行数:35,代码来源:TourItemListFragment.java

示例9: correctItemDragStateFlags

import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入依赖的package包/类
private void correctItemDragStateFlags(RecyclerView.ViewHolder holder, int groupPosition, int childPosition) {
    if (!(holder instanceof DraggableItemViewHolder)) {
        return;
    }

    final DraggableItemViewHolder holder2 = (DraggableItemViewHolder) holder;

    final boolean groupRangeSpecified =
            (mDraggingItemGroupRangeStart != RecyclerView.NO_POSITION) &&
            (mDraggingItemGroupRangeEnd != RecyclerView.NO_POSITION);
    final boolean childRangeSpecified =
            (mDraggingItemChildRangeStart != RecyclerView.NO_POSITION) &&
            (mDraggingItemChildRangeEnd != RecyclerView.NO_POSITION);
    final boolean isInGroupRange =
                    (groupPosition >= mDraggingItemGroupRangeStart) &&
                    (groupPosition <= mDraggingItemGroupRangeEnd);
    final boolean isInChildRange =
            (groupPosition != RecyclerView.NO_POSITION) &&
            (childPosition >= mDraggingItemChildRangeStart) &&
                    (childPosition <= mDraggingItemChildRangeEnd);

    final int flags = holder2.getDragStateFlags();
    boolean needCorrection = false;

    if (((flags & RecyclerViewDragDropManager.STATE_FLAG_DRAGGING) != 0) &&
            ((flags & RecyclerViewDragDropManager.STATE_FLAG_IS_IN_RANGE) == 0)) {
        if (!groupRangeSpecified || isInGroupRange) {
            if (!childRangeSpecified || (childRangeSpecified && isInChildRange)) {
                needCorrection = true;
            }
        }
    }

    if (needCorrection) {
        holder2.setDragStateFlags(
                flags | RecyclerViewDragDropManager.STATE_FLAG_IS_IN_RANGE |
                        RecyclerViewDragDropManager.STATE_FLAG_IS_UPDATED);
    }
}
 
开发者ID:WriterOfAlicrow,项目名称:OpenCVTour,代码行数:40,代码来源:ExpandableRecyclerViewWrapperAdapter.java

示例10: setUpRecyclerView

import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入依赖的package包/类
private void setUpRecyclerView() {
    ViewUtil.setUpFastScrollRecyclerViewColor(this, ((FastScrollRecyclerView) recyclerView), ThemeStore.accentColor(this));
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    if (playlist instanceof AbsCustomPlaylist) {
        adapter = new PlaylistSongAdapter(this, new ArrayList<Song>(), R.layout.item_list, false, this);
        recyclerView.setAdapter(adapter);
    } else {
        recyclerViewDragDropManager = new RecyclerViewDragDropManager();
        final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();
        adapter = new OrderablePlaylistSongAdapter(this, new ArrayList<PlaylistSong>(), R.layout.item_list, false, this, (fromPosition, toPosition) -> {
            if (PlaylistsUtil.moveItem(PlaylistDetailActivity.this, playlist.id, fromPosition, toPosition)) {
                Song song = adapter.getDataSet().remove(fromPosition);
                adapter.getDataSet().add(toPosition, song);
                adapter.notifyItemMoved(fromPosition, toPosition);
            }
        });
        wrappedAdapter = recyclerViewDragDropManager.createWrappedAdapter(adapter);

        recyclerView.setAdapter(wrappedAdapter);
        recyclerView.setItemAnimator(animator);

        recyclerViewDragDropManager.attachRecyclerView(recyclerView);
    }

    adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
            checkIsEmpty();
        }
    });
}
 
开发者ID:kabouzeid,项目名称:Phonograph,代码行数:33,代码来源:PlaylistDetailActivity.java

示例11: onBindItemGroupViewHolder

import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入依赖的package包/类
private void onBindItemGroupViewHolder(MyGroupViewHolder holder, int groupPosition) {
    // group item
    final AbstractExpandableDataProvider.GroupData item = mProvider.getGroupItem(groupPosition);

    // set text
    holder.mTextView.setText(item.getText());

    // set background resource (target view ID: container)
    final int dragState = holder.getDragStateFlags();
    final int expandState = holder.getExpandStateFlags();

    if (((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_UPDATED) != 0) ||
            ((expandState & RecyclerViewExpandableItemManager.STATE_FLAG_IS_UPDATED) != 0)) {
        int bgResId;
        boolean isExpanded;

        if ((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_ACTIVE) != 0) {
            bgResId = R.drawable.bg_group_item_dragging_active_state;

            // need to clear drawable state here to get correct appearance of the dragging item.
            DrawableUtils.clearState(holder.mContainer.getForeground());
        } else if (((dragState & RecyclerViewDragDropManager.STATE_FLAG_DRAGGING) != 0) &&
                ((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_IN_RANGE) != 0)) {
            bgResId = R.drawable.bg_group_item_dragging_state;
        } else if ((expandState & RecyclerViewExpandableItemManager.STATE_FLAG_IS_EXPANDED) != 0) {
            bgResId = R.drawable.bg_group_item_expanded_state;
        } else {
            bgResId = R.drawable.bg_group_item_normal_state;
        }

        if ((expandState & RecyclerViewExpandableItemManager.STATE_FLAG_IS_EXPANDED) != 0) {
            isExpanded = true;
        } else {
            isExpanded = false;
        }

        holder.mContainer.setBackgroundResource(bgResId);
        holder.mIndicator.setExpandedState(isExpanded, true);
    }
}
 
开发者ID:pczhu,项目名称:android-advancedrecyclerview-master,代码行数:41,代码来源:MyExpandableDraggableWithSectionItemAdapter.java

示例12: onBindChildViewHolder

import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入依赖的package包/类
@Override
public void onBindChildViewHolder(MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
    // child item
    final AbstractExpandableDataProvider.ChildData item = mProvider.getChildItem(groupPosition, childPosition);

    // set text
    holder.mTextView.setText(item.getText());

    final int dragState = holder.getDragStateFlags();

    if (((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_UPDATED) != 0)) {
        int bgResId;

        if ((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_ACTIVE) != 0) {
            bgResId = R.drawable.bg_item_dragging_active_state;

            // need to clear drawable state here to get correct appearance of the dragging item.
            DrawableUtils.clearState(holder.mContainer.getForeground());
        } else if (((dragState & RecyclerViewDragDropManager.STATE_FLAG_DRAGGING) != 0) &&
                ((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_IN_RANGE) != 0)) {
            bgResId = R.drawable.bg_item_dragging_state;
        } else {
            bgResId = R.drawable.bg_item_normal_state;
        }

        holder.mContainer.setBackgroundResource(bgResId);
    }
}
 
开发者ID:pczhu,项目名称:android-advancedrecyclerview-master,代码行数:29,代码来源:MyExpandableDraggableWithSectionItemAdapter.java

示例13: onBindViewHolder

import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入依赖的package包/类
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
    final AbstractDataProvider.Data item = mProvider.getItem(position);

    // set text
    holder.mTextView.setText(item.getText());

    // set background resource (target view ID: container)
    final int dragState = holder.getDragStateFlags();

    if (((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_UPDATED) != 0)) {
        int bgResId;

        if ((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_ACTIVE) != 0) {
            bgResId = R.drawable.bg_item_dragging_active_state;

            // need to clear drawable state here to get correct appearance of the dragging item.
            DrawableUtils.clearState(holder.mContainer.getForeground());
        } else if ((dragState & RecyclerViewDragDropManager.STATE_FLAG_DRAGGING) != 0) {
            bgResId = R.drawable.bg_item_dragging_state;
        } else {
            bgResId = R.drawable.bg_item_normal_state;
        }

        holder.mContainer.setBackgroundResource(bgResId);
    }
}
 
开发者ID:pczhu,项目名称:android-advancedrecyclerview-master,代码行数:28,代码来源:MyDraggableItemAdapter.java

示例14: onViewCreated

import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入依赖的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());

        // drag & drop manager
        mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
        mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
                (NinePatchDrawable) getResources().getDrawable(R.drawable.material_shadow_z3));

        //adapter
        final MyDraggableItemAdapter myItemAdapter = new MyDraggableItemAdapter(getDataProvider());
        mAdapter = myItemAdapter;

        mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter);      // wrap for dragging

        final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();

        mRecyclerView.setLayoutManager(mLayoutManager);
        mRecyclerView.setAdapter(mWrappedAdapter);  // requires *wrapped* adapter
        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_z1)));
        }
        mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(getResources().getDrawable(R.drawable.list_divider), true));

        mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);

        // for debugging
//        animator.setDebug(true);
//        animator.setMoveDuration(2000);
    }
 
开发者ID:pczhu,项目名称:android-advancedrecyclerview-master,代码行数:41,代码来源:RecyclerListViewFragment.java

示例15: onViewCreated

import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入依赖的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());

        // drag & drop manager
        mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
        mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
                (NinePatchDrawable) getResources().getDrawable(R.drawable.material_shadow_z3));

        //adapter
        final MyDraggableWithSectionItemAdapter myItemAdapter = new MyDraggableWithSectionItemAdapter(getDataProvider());
        mAdapter = myItemAdapter;

        mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter);      // wrap for dragging

        final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();

        mRecyclerView.setLayoutManager(mLayoutManager);
        mRecyclerView.setAdapter(mWrappedAdapter);  // requires *wrapped* adapter
        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_z1)));
        }
        mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(getResources().getDrawable(R.drawable.list_divider), true));

        mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);

        // for debugging
//        animator.setDebug(true);
//        animator.setMoveDuration(2000);
    }
 
开发者ID:pczhu,项目名称:android-advancedrecyclerview-master,代码行数:41,代码来源:RecyclerListViewFragment.java


注:本文中的com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。