{"id":19560205,"url":"https://github.com/huxq17/handygridview","last_synced_at":"2025-04-24T00:23:47.556Z","repository":{"id":96084190,"uuid":"110228877","full_name":"huxq17/HandyGridView","owner":"huxq17","description":"HandyGridView是一个高仿支付宝，网易新闻的高性能的标签可拖动排序的GridView。","archived":false,"fork":false,"pushed_at":"2020-03-11T14:51:42.000Z","size":1265,"stargazers_count":280,"open_issues_count":8,"forks_count":29,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-30T05:11:24.298Z","etag":null,"topics":["android-ui","drag-and-drop","gridview","handygridview"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huxq17.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-10T09:30:32.000Z","updated_at":"2025-03-11T04:37:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"9d63162d-197e-40a4-9012-25ced301d609","html_url":"https://github.com/huxq17/HandyGridView","commit_stats":{"total_commits":64,"total_committers":1,"mean_commits":64.0,"dds":0.0,"last_synced_commit":"9331d0bfd92f12fa71638762009932c5ba5e84f6"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huxq17%2FHandyGridView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huxq17%2FHandyGridView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huxq17%2FHandyGridView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huxq17%2FHandyGridView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huxq17","download_url":"https://codeload.github.com/huxq17/HandyGridView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250536490,"owners_count":21446743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-ui","drag-and-drop","gridview","handygridview"],"created_at":"2024-11-11T05:06:28.768Z","updated_at":"2025-04-24T00:23:47.489Z","avatar_url":"https://github.com/huxq17.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HandyGridView\n\n[![Android Arsenal]( https://img.shields.io/badge/Android%20Arsenal-HandyGridView-green.svg?style=flat )]( https://android-arsenal.com/details/1/6571 )\n\nHandyGridView本质上是一个GridView，所以你也可以当成普通的GridView来使用，HandyGridView继承了GridView并在此之上添加了item拖动和交换，绘制图文等功能。\n由于只是一个GridView，所以性能比目前其他大部分解决方案都要好。\n\nHandyGridView is a high-performance drag and drop GridView, it extends GridView, you can drag drop GridView item to sort the labels,and draw something on the GridView. Just use the HandyGridView like a GridView.\n\n---\n\n### Screenshots\n\n \u003cimg src=\"art/art.gif\" width=\"280\" height=\"475\" /\u003e\n\n---\n### Usage\n\n#### Gradle\n\n```groovy\ndependencies {\n   compile 'com.huxq17.handygridview:handygridview:1.2.0'\n\n}\n```\n\n#### minSdkVersion 11\n\n#### HandyGridView's three modes：\n\nMode | introduction\n---|---\nTOUCH | Edit mode，the item can be dragged\nLONG_PRESS | Long press mode，item can be dragged after long press.\nNONE | Item can not be dragged, jsut like normal GridView.\n\nUsage：\n\n```\nHandyGridView#setMode(TOUCH|LONG_PRESS|NONE);\n\n```\n\n#### Adapter\n\nHandyGridView会在item被拖动交换时发出通知，如果想要做出对应数据上的变化，则可以在Apdater中实现OnItemMovedListener，示例如下：\n\nHandyGridView will send a notification to notify you swip the data source when its item's order is changed. the usage is as follows:\n\n```\n\npublic class GridViewAdapter extends BaseAdapter implements OnItemMovedListener｛\n    @Override\n    public void onItemMoved(int from, int to) {\n        String s = mDatas.remove(from);\n        mDatas.add(to, s);\n    }\n\n    @Override\n    public boolean isFixed(int position) {\n        //When postion==0,the item can not be dragged.\n        if (position == 0) {\n            return true;\n        }\n        return false;\n    }\n｝\n```\n\n#### 绘制图文\nHandyGridView提供了在gridview上绘制图文的接口，示例如下：\n\nYou can draw something on HandyGridView, the usage is as follows:\n\n```\n    mGridView.setDrawer(new IDrawer() {\n            @Override\n            public void onDraw(Canvas canvas, int width, int height) {\n                if (!mGridView.isNoneMode()) {\n                    int offsetX = -DensityUtil.dip2px(MainActivity.this, 10);\n                    int offsetY = -DensityUtil.dip2px(MainActivity.this, 10);\n                    //文字绘制于gridview的右下角，并向左，向上偏移10dp。\n                    //Draw text on the right-bottom of GridView.\n                    drawTips(canvas, width + offsetX, height + offsetY);\n                }\n            }\n        },false);\n\n    private void drawTips(Canvas canvas, int width, int height) {\n        if (mTextPaint == null) {\n            mTextPaint = new TextPaint();\n            mTextPaint.setColor(Color.parseColor(\"#CFCFCF\"));\n            mTextPaint.setTextSize(DensityUtil.dip2px(MainActivity.this, 12));\n            Paint.FontMetrics fontMetrics = mTextPaint.getFontMetrics();\n            textHeight = (int) (fontMetrics.bottom - fontMetrics.top) + 1;\n            textWidth = (int) mTextPaint.measureText(paintText) + 1;\n        }\n        width = width - textWidth;\n        height = height - textHeight;\n        if (tipsLayout == null) {\n            tipsLayout = new StaticLayout(paintText, mTextPaint, width, Layout.Alignment.ALIGN_NORMAL, 1.5f, 0f, false);\n        }\n        canvas.translate(width, height);\n        tipsLayout.draw(canvas);\n    }\n\n```\n\n\n以上就是主要的用法了,[更多的用法可以参考example](https://github.com/huxq17/HandyGridView/blob/master/app/src/main/java/com/handygridview/example/MainActivity.java).\n\nThe above is the main usage,[click to get more](https://github.com/huxq17/HandyGridView/blob/master/app/src/main/java/com/handygridview/example/MainActivity.java).\n\n\n\n---\n\n### 更新日志\u003cbr/\u003e\n    2018-8-29：\n    1.解决HandyGridView在没有item并且horizontalSpacing为0dp或者没有设置时触摸会挂掉的问题\n\n    2017-12-29：\n    1.解决某些小米手机上item拖动交换时会闪烁的问题,更新到1.1.0\n\n---\n### LICENSE\n\n[Apache License 2.0](LICENSE)\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuxq17%2Fhandygridview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuxq17%2Fhandygridview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuxq17%2Fhandygridview/lists"}