项目作者: shuhart

项目描述 :
Drag & drop item decorator for RecyclerView with support for highlighting hovered items.
高级语言: Java
项目地址: git://github.com/shuhart/HoveringCallback.git
创建时间: 2018-01-30T17:55:54Z
项目社区:https://github.com/shuhart/HoveringCallback

开源协议:Apache License 2.0

下载


HoveringCallback

Drag & drop item decorator for RecyclerView with support for highlighting hovered items.

Sample

Usage

  1. Add mavenCentral() to repositories block in your gradle file.
  2. Add implementation 'com.github.shuhart:hoveringcallback:1.3.0' to your dependencies.
  3. Look into the sample for additional details on how to use and configure the library.

Example:

  1. HoverItemDecoration itemDecoration = new HoverItemDecoration(
  2. new HoveringCallback() {
  3. @Override
  4. public void attachToRecyclerView(@Nullable RecyclerView recyclerView) {
  5. super.attachToRecyclerView(recyclerView);
  6. addOnDropListener(new OnDroppedListener() {
  7. @Override
  8. public void onDroppedOn(RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
  9. Toast.makeText(
  10. MainActivity.this,
  11. "Dropped on position " + target.getAdapterPosition(),
  12. Toast.LENGTH_SHORT).show();
  13. }
  14. });
  15. }
  16. },
  17. new ItemBackgroundCallback() {
  18. private int hoverColor = Color.parseColor("#e9effb");
  19. @Override
  20. public int getDefaultBackgroundColor(@NonNull RecyclerView.ViewHolder viewHolder) {
  21. return Color.WHITE;
  22. }
  23. @Override
  24. public int getDraggingBackgroundColor(@NonNull RecyclerView.ViewHolder viewHolder) {
  25. return Color.WHITE;
  26. }
  27. @Override
  28. public int getHoverBackgroundColor(@NonNull RecyclerView.ViewHolder viewHolder) {
  29. return hoverColor;
  30. }
  31. });
  32. itemDecoration.attachToRecyclerView(recyclerView);

License

  1. Copyright 2018 Bogdan Kornev.
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.