Giter Club home page Giter Club logo

android-drag-square's Introduction

Modified by Swifty

refactor the repository, easy to use with gradle import. [![](https://jitpack.io/v/SwiftyWang/android-drag-square.svg)](https://jitpack.io/#SwiftyWang/android-drag-square)

How to use

Add it in your root build.gradle at the end of repositories:
	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency

	dependencies {
	        compile 'com.github.SwiftyWang.android-drag-square:android-crop:1.2.3'
	}

get DraggablePresenter

```java DraggableSquareView dragSquare = (DraggableSquareView) findViewById(R.id.drag_square); contentText = (TextView) findViewById(R.id.contentText); draggablePresent = new DraggablePresentImpl(fragment, dragSquare); draggablePresent = new DraggablePresentImpl(activity, dragSquare); ```

need pass activity callback to DraggablePresentImpl:

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent result) {
        draggablePresent.onActivityResult(requestCode, resultCode, result);
    }

Set customer dialog

Customer dialog must extends ActionDialog.class ```java draggablePresent.setCustomActionDialog(new MyActionDialog(Context)); ```

listen image changes

```java dragSquare.setImageChangesListener(imageChangesListener);
public interface ImageChangesListener {
    void onImageAdded(String uri, int index);

    void onImageEdited(String uri, int index);

    void onImageDeleted(String uri, int index);
}

<h3>All public apis</h3>
```java
    SparseArray<String> getImageUrls();

    void setImages(String... imageUrls);

    void setCustomActionDialog(ActionDialog actionDialog);

android-drag-square

edit personal data which enables users to drag and rank image order

编辑个人资料,图片可拖拽排序。有点像可拖拽的gridView,但是会更流畅。
这个demo是探探的个人资料编辑页面,受网上一位朋友的委托,该库模仿了其拖动效果。
探探的安卓工程师,应该特别牛逼吧。因为最初时,这种拖拽效果真的无从下手。反编译探探的源代码,发现它做了很严肃的混淆处理。然后用Hierarchy Viewer看了View的层级,这才有了一点点的思路。
在代码撰写的过程中,我也踩了不少坑。细看代码深处,或许你会有一丝丝的收获吧。
当然,在最初的最初,我搜了不少的draggable gridview的仓库,可惜用起来的时候发现不够流畅、不够灵活。

截图

android-drag-square's People

Contributors

swiftywang avatar xmusistone avatar

Watchers

lixinyang 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.