GithubHelp home page GithubHelp logo

wuqingman / draglayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from syehunter/draglayout

0.0 2.0 0.0 191 KB

RecyclerView with GridLayout that can be dragged.You may use this like the Netease ChannelManager or in some otherwise.

License: Apache License 2.0

Java 100.00%

draglayout's Introduction

DragLayout

RecyclerView with GridLayout that can be dragged.You may use this like the Netease ChannelManager or in some otherwise.

The DragLayout implemented with RecyclerView.

Usage:

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

dependencies {
    compile 'com.github.Syehunter:DragLayout:1.0.0'
}

There might be some error occurs when gradle build in Android Studio 2.0 with "META-INF/maven/com.belerweb/pinyin4j/pom.properties"(for I imported Pinyin4j.jar into library), just add this in your build.gradle:

android {
	...
	packagingOptions {
	    exclude 'META-INF/maven/com.belerweb/pinyin4j/pom.properties'
	    exclude 'META-INF/maven/com.belerweb/pinyin4j/pom.xml'
	}
}

The layout above is DragRecyclerView, and UnsignedRecyclerView below.

Defaulst is Chinese, and the UnsignedRecyclerView is sort by Pinjin, Use this in your code if you want to change the item content only:

mDragView.datas(dragList)
            .onItemClick(new OnItemClickListener() {
                @Override
                public void onItemClick(RecyclerView.ViewHolder holder, int position) {
                    Toast.makeText(MainActivity.this,
                            "position" + position + "has been clicked", Toast.LENGTH_SHORT).show();
                }
            })
            .onLongPress(new OnLongPressListener() {
                @Override
                public void onLongPress() {
                    mQuitBtn.setVisibility(View.VISIBLE);
                }
            })
            .onItemRemoved(new OnItemRemovedListener<String>() {
                @Override
                public void onItemRemoved(int position, String removedItem) {
                    mUnsignedView.addItem(removedItem);
                }
            })
            .keepItemCount(2)
            .build();
            
mUnsignedView = (UnsignedRecyclerView) findViewById(R.id.unsignedView);

mUnsignedView.hanZiDatas(unsignedList)
            .onItemRemoved(new OnItemRemovedListener<String>() {
                @Override
                public void onItemRemoved(int position, String removedItem) {
                    mDragView.addItem(removedItem);
                }
            })
            .build();

Method keepItemCount() that could let you set the unmoved item counts, default is 1.

Define your adapter extends BaseDragAdapter or BaseUnsignedAdapter if you don't like this, and dragViewHolder extends BaseDragViewHolder, remember to use DragGridLayoutManager instead of GridLayoutMananger, which will adjust RecyclerView's height to wrap_content(Unfortunately the DragGridLayoutManager doesn't support RecyclerView that has set SpanSizeLookup now, I will fix it in future).

draglayout's People

Contributors

syehunter avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.