• Stars
    star
    107
  • Rank 323,587 (Top 7 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

⭐ Android 看板,支持项拖拽、列拖拽。Draggable kanban/board view for Android.

DragBoardView

Codacy Badge

DragBoardView is a draggable kanban/board view for Android. it supports drag item, drag column, auto center

You can just use it like a RecyclerView!

Just use it like a RecyclerView! 中文文档

How to use Recyclerview:

1. Add dependency for recyclerview
compile 'com.android.support:recyclerview-v7:23.1.0'

Add recyclerview in main layout file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <android.support.v7.widget.RecyclerView
        android:id="@+id/item_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="vertical"
        />
</LinearLayout>
2. Make one item layout xml file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">

    <TextView
        android:id="@+id/txtChords"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_gravity="center_horizontal"
        />
    <TextView
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:id="@+id/txtLyrics"/>

</LinearLayout>
3. Make model class for each item in list.

it can be any custom class.

public class Item {

    private String name;

    public Item(String n) {
        name = n;
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
4. make adapter for recyclerview
import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.codexpedia.list.viewholder.R;
import java.util.ArrayList;

public class ItemArrayAdapter extends RecyclerView.Adapter<ItemArrayAdapter.ViewHolder> {

    //All methods in this adapter are required for a bare minimum recyclerview adapter
    private int listItemLayout;
    private ArrayList<Item> itemList;
    // Constructor of the class
    public ItemArrayAdapter(int layoutId, ArrayList<Item> itemList) {
        listItemLayout = layoutId;
        this.itemList = itemList;
    }

    // get the size of the list
    @Override
    public int getItemCount() {
        return itemList == null ? 0 : itemList.size();
    }


    // specify the row layout file and click for each row
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(listItemLayout, parent, false);
        ViewHolder myViewHolder = new ViewHolder(view);
        return myViewHolder;
    }

    // load data in each row element
    @Override
    public void onBindViewHolder(final ViewHolder holder, final int listPosition) {
        TextView item = holder.item;
        item.setText(itemList.get(listPosition).getName());
    }

    // Static inner class to initialize the views of rows
    static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
        public TextView item;
        public ViewHolder(View itemView) {
            super(itemView);
            itemView.setOnClickListener(this);
            item = (TextView) itemView.findViewById(R.id.txtChords);
        }
        @Override
        public void onClick(View view) {
            Log.d("onclick", "onClick " + getLayoutPosition() + " " + item.getText());
        }
    }
5. bind adapter with recyclerview
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.codexpedia.list.viewholder.R;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    RecyclerView recyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Initializing list view with the custom adapter
        ArrayList <Item> itemList = new ArrayList<Item>();

        ItemArrayAdapter itemArrayAdapter = new ItemArrayAdapter(R.layout.list_item, itemList);
        recyclerView = (RecyclerView) findViewById(R.id.item_list);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        recyclerView.setAdapter(itemArrayAdapter);

        // Populating list items
        for(int i=0; i<100; i++) {
            itemList.add(new Item("Item " + i));
        }

    }

}

As for DragBoardView, it's all the same.

How to use DragBoardView:

1. Add dependency for DragBoardView

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Add the dependency

dependencies {
    compile 'com.github.LinXueyuanStdio:DragBoardView:v1.0.0'
}

declare it in your main layout xml file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"/>

    <com.time.cat.dragboardview.DragBoardView
        android:id="@+id/layout_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/toolbar"/>

</RelativeLayout>
2. Make two item layout xml files.

One for each column item. it should contains a RecyclerView

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/col_content_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/rv"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

</RelativeLayout>

One for the item in each column.

<TextView
    android:id="@+id/item_title"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:text="item"/>
3. Make model class for each column and each item in list.

for each column, it should implement DragColumn interface.

public class Entry implements DragColumn {
    private final String name;
    private int columnIndex;
    private final List<DragItem> itemList;

    public Entry(String name, int columnIndex, List<DragItem> items) {
        this.name = name;
        this.columnIndex = columnIndex;
        this.itemList = items;
    }

    public String getName() {
        return name;
    }

    public List<DragItem> getItemList() {
        return itemList;
    }

    @Override
    public int getColumnIndex() {
        return columnIndex;
    }

    @Override
    public void setColumnIndex(int columnIndexInHorizontalRecycleView) {
        //save to database here
    }
}

for each item in the column, it should implement DragItem interface.

public class Item implements DragItem {
    private final String itemName;
    private int colIndex;
    private int itemIndex;

    public Item(String itemName, int colIndex, int itemIndex) {
        this.itemName = itemName;
        this.colIndex = colIndex;
        this.itemIndex = itemIndex;
    }

    public String getItemName() {
        return itemName;
    }

    @Override
    public int getColumnIndex() {
        return colIndex;
    }

    @Override
    public int getItemIndex() {
        return itemIndex;
    }

    @Override
    public void setColumnIndex(int columnIndexInHorizontalRecycleView) {
        //save to database here
    }

    @Override
    public void setItemIndex(int itemIndexInVerticalRecycleView) {
        //save to database here
    }
}
4. make adapter for DragBoardView
public class ColumnAdapter extends HorizontalAdapter<ColumnAdapter.ViewHolder>
public class ItemAdapter extends VerticalAdapter<ItemAdapter.ViewHolder>
5. bind adapter with DragBoardView
public class MainActivity extends AppCompatActivity {

    DragBoardView dragBoardView;
    List<DragColumn> mData = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        dragBoardView = findViewById(R.id.layout_main);
        mAdapter = new ColumnAdapter(this);
        mAdapter.setData(mData);
        dragBoardView.setHorizontalAdapter(mAdapter);
    }

}

gif

ScreenShot

截图1 截图2 截图3
截图4 截图5

Advance

Meanwhile, PagerRecyclerView is able to be customized by these 3 params:

name format description
singlePageFling boolean single Page Fling, default false
triggerOffset float trigger offset, default 0.25f
flingFactor float fling factor, default 0.15f

demo is more clear

demo apk

download

More Repositories

1

LaTeX_OCR_PRO

🎨 数学公式识别增强版:中英文手写印刷公式、支持初级符号推导(数据结构基于 LaTeX 抽象语法树)Math Formula OCR Pro, supports handwrite, Chinese-mixed formulas and simple symbol reasoning (based on LaTeX AST).
Jupyter Notebook
1,052
star
2

PythonDataMining

📔 在学院的书架上发现了一本不带脑子就能读懂的书《Python数据挖掘与实战》
Jupyter Notebook
618
star
3

LaTeX_OCR

💎 数学公式识别 Math Formula OCR
Jupyter Notebook
486
star
4

DictionaryData

高质量英语字典,400多本单词书+60000多个单词!单词书包括小学、中学、高中、考研、考博、出国(GRE、托福等等)等等,难道它不香吗?
282
star
5

chatgpt-review-rebuttal-extension

ChatGPT - Review & Rebuttal: A browser extension for generating reviews and rebuttals, powered by ChatGPT. 利用 ChatGPT 生成审稿意见和回复的浏览器插件
TypeScript
249
star
6

lifecycle-component

🏆 一套组件化规范,基于组件的生命周期,支持渐进式组件化、渐进式组件变插件化,高度自由的成长性架构
Java
141
star
7

PyTorch-DDPM

500 行代码实现降噪扩散模型 DDPM,干净无依赖
Jupyter Notebook
122
star
8

MLang

Android 动态化多语言框架,支持语言包的动态下发、升级、删除,一处安装,到处使用
Java
108
star
9

Data-for-LaTeX_OCR

LaTeX OCR 的数据仓库
90
star
10

TFLEX

[NeurIPS 2023] TFLEX: Temporal Feature-Logic Embedding Framework for Complex Reasoning over Temporal Knowledge Graph
Jupyter Notebook
29
star
11

Python-100-Days-CheatSheet

百日python,路线:语法->爬虫->网站->数据科学->机器学习->深度学习
12
star
12

KGE-toolbox

知识图谱基础设施
Python
11
star
13

notes

📖 机器学习笔记 Notes for Machine Learning
Jupyter Notebook
9
star
14

ranger_icon_plugin

Ranger plugin that adds icon support to Ranger
Python
7
star
15

EthereumDappTutorial

💡 以太坊去中心化网页app
JavaScript
7
star
16

data_cookbook

数据处理、数据可视化。有关pandas、pyecharts、d3等,轮子代码备忘,以后直接抄。
5
star
17

QubitE

code for "QubitE: Qubit Embedding for Knowledge Graph Completion"
Python
5
star
18

Numerical-Solution-of-Differential-Eequations

微分方程数值解法 Matlab 实现
MATLAB
4
star
19

LearnTelegram

一个长期的学习 Telegram 的计划,加中文注释供自己理解
Java
4
star
20

hash2face

map Hash to Face using GAN.
Python
4
star
21

AnimPlayer

公主连结人物精灵动画播放器
HTML
4
star
22

SmsDelayer

Android 手机短信转发器,转发至另一手机短信、邮箱、服务器。含服务端代码。
Java
4
star
23

FLEX

code for "FLEX: Feature-Logic Embedding Framework for CompleX Knowledge Graph Reasoning"
Python
4
star
24

RecommenderSystem_PyTorch

速通推荐系统
Jupyter Notebook
3
star
25

streamlit-markdown

a streaming markdown component for streamlit with LaTeX, Mermaid, Table, code support. A drop-in replacement for st.markdown.
JavaScript
3
star
26

project-TimeCat

时光猫官网
HTML
3
star
27

project-recite-words

被动背单词!每 1000 毫秒显示一个单词,就算一个小时记住只 5 %,也是 3600 * 0.05 = 180 个! 只要重复次数足够多,效率低又有什么呢?
HTML
3
star
28

tutorial_matlab

matlab
2
star
29

BGEA

Python
2
star
30

EchoEA

code for "EchoEA: Echo Information between Entities and Relations for Entity Alignment"
Python
2
star
31

DemoAppleBackend

练手项目,熟悉一下 Spring Boot
Java
1
star
32

KG_datasets

知识图谱常用数据集
1
star
33

TimeCatGradle

时光猫的 gradle 构建脚本,统一配置
Kotlin
1
star
34

LinXueyuanStdio

为 github 的个人主页添加一个README吧!!!
1
star
35

gotools

handy tools written with golang
Go
1
star
36

timecat-doc

时光猫文档
1
star
37

LearnManim

随便学一下3b1b画图
Python
1
star
38

LinXueyuanStdio.github.io

Blog for recording my learning process.
HTML
1
star
39

GradleDependancyReport

android 依赖可视化管理:包大小、包依赖、kotlin支持、打开浏览器查看
Groovy
1
star
40

TimeCatRepoTemplate

时光猫仓库模板
Java
1
star
41

learnGit

learn git from demand
1
star
42

TimeCatModuleTemplate

时光猫业务组件模板
Kotlin
1
star
43

TimeCatPlugin-PluginManager

时光猫插件 插件管理,插件上传
Java
1
star
44

SAMView

单Activity多View框架,不使用Fragment
Java
1
star
45

TimeCatModule-Plugin

时光猫组件 插件宿主
Java
1
star
46

TimeCatShadow

从腾讯的 Shadow 而来
Java
1
star
47

TimeCatMaven

打包aar减少编译时间
1
star
48

CodeFilesTemplate

CodeFileStruct Template for MachineLearning 代码文件组织结构模板
Python
1
star
49

settings

some useful settings
Shell
1
star
50

latex_template_mcm

2018美赛论文模板
TeX
1
star
51

UEdbq

伤害优衣的家伙在哪里?噢,是我啊,优衣对不起😁
Java
1
star
52

ComponentAnalysis

组件化分析
Vue
1
star
53

UAIcup

UAI CUP https://biendata.com/competition/UAI/
Jupyter Notebook
1
star