GithubHelp home page GithubHelp logo

weileng11 / android-drag-square-master Goto Github PK

View Code? Open in Web Editor NEW
43.0 43.0 8.0 4.74 MB

编辑个人资料,图片可拖拽排序。有点像可拖拽的gridView,但是会更流畅。 这个demo是探探的个人资料编辑页面,受网上一位朋友的委托,该库模仿了其拖动效果

Java 100.00%

android-drag-square-master's People

Contributors

weileng11 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

android-drag-square-master's Issues

删除图片时回调传值错误

  1. 需要改动的

DraggableItemView.java

    @Override
    public void onDeleteClick(View view) {
        // parentView.onDeleteImage(imagePath, DraggableItemView.this);
        imagePath = null;
        imageView.setImageBitmap(null);
        addView.setVisibility(View.VISIBLE);
        parentView.onDeleteImage(DraggableItemView.this);
    }

imagePath = null 导致回调给DraggableSquareView在通过 deleteView.getImagePath() 获取到的已删除图片路径为空。应该将path传递给 parentView.onDeleteImag(imagePath, DraggableItemView.this) 再执行imagePath = null


  1. 需要改动的

DraggableSquareView.java

    /**
     * 删除某一个ImageView时,该imageView变成空的,需要移动到队尾
     */
    public void onDeleteImage(DraggableItemView deleteView) {
        if ((int)deleteView.getTag() == 0){
            return;
        }
        int status = deleteView.getStatus();
        int lastDraggableViewStatus = -1;
        // 需要将该回调提前到该位置,否则传递的status也就是删除的view的index索引是移动后的索引
        if (imageChangesListener != null) {
            imageChangesListener.onImageDeleted(deleteView.getImagePath(), status);
        }
        // 顺次将可拖拽的view往前移
        for (int i = status + 1; i < allStatus.length; i++) {
            DraggableItemView itemView = getItemViewByStatus(i);
            if (itemView.isDraggable()) {
                // 可拖拽的view往前移
                lastDraggableViewStatus = i;
                switchPosition(i, i - 1);
            } else {
                break;
            }
        }
        if (lastDraggableViewStatus > 0) {
            // 被delete的view移动到队尾
            deleteView.switchPosition(lastDraggableViewStatus);
        }
    }

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.