woxblom / DragListView

Drag and drop to reorder items in a list, grid or board for Android. Based on RecyclerView. Also supports swiping items in a list.
Apache License 2.0
693 stars 177 forks source link

how BoardView customer column and rows like launcher? #148

Closed yuxingfafu closed 5 years ago

yuxingfafu commented 5 years ago

first of all,thank you very much:) thank you for your work.

i want to how BoardView or DragListView customer column and rows like launcher? i want to user it to develop a view like launcher,andr sort icons like ios desk,at the same time could drag between pages.

thanks a lot:)

could this can help me? thanks you very much :)

woxblom commented 5 years ago

Hey, Thanks :)

Sorry to say but there is no support for grid layout in BoardView. You are welcome to fork and try and add it yourself however.

DragListView supports gridlayout which you can see in the sample app, but then you won't get the paging feature like in BoardView.

BR Magnus

yuxingfafu commented 5 years ago

thanks you very much! how DragListView could drag or sort with page? could you help me?

https://github.com/zhuguohui/PageGridView https://github.com/GcsSloop/pager-layoutmanager

i am not familiar with code, could you add the function for DragListView ,if so, it could work like launcher:

thanks you very much:)

woxblom commented 5 years ago

Actually when I think about it I think it is easiest to add grid support to the BoardView. I will take a look at it. I will go on vacation in 3 days however so if it is trickier than I think you gonna have to wait until I come back.

yuxingfafu commented 5 years ago

thank you very much :) at the same time i will try my idea, try could modify it by myself. thank you very much. i look forward your new version could done like launcher:)

woxblom commented 5 years ago

I just released version 1.6.5. Here I added support to provide an own layout manager when adding a column. In the sample app you can now switch between grid and list in the overflow menu to try it out.

It will not give you a launcher layout with holes in it but it will give you a grid. If you want one with holes in it you need to implement your own layoutmanager and provide when adding a column.

BR Magnus

yuxingfafu commented 5 years ago

thank you,i will have a try :)

yuxingfafu commented 5 years ago

thank a lot,woxblom i found there 2 question;like the gif pic show,could you help ,

lli22-lnssq

1.if column=4,row=4, and i drop one page to second page, the second item is all realy 16 items, i should not move success. should move failed. i read some code ,but i cound not find where to control it

2.scoller to left or right is too sensitive, i just move a little left of right , it will scoll to left page or right page. i try to modify code float scrollEdge = getResources().getDisplayMetrics().widthPixels * (isPortrait ? 0.18f : 0.14f); but not efftct

woxblom commented 5 years ago
  1. You call setBoardCallback on BoardView and implement that interface to choose which items can move and where they can be dropped.

  2. Yeah I agree it is to sensitive. I have made an update which makes it better. I changed 0.18 to 0.06. So it is the correct place you tried to change. Version 1.6.6 should be out soon with the change.

yuxingfafu commented 5 years ago

thanks a lot, i will hava a try the second question. but for the first question,i also have a doubt, the interface BoardCallback as flow.how could i just the original and target item on which page, how could i get the current page item nums? ` mBoardView.setBoardCallback(new BoardView.BoardCallback() { @Override public boolean canDragItemAtPosition(int column, int dragPoon) { Log.d("1111111111",column+","+dragPoon); // Add logic here to prevent an item to be dragged return true; }

        @Override
        public boolean canDropItemAtPosition(int oldColumn, int oldRow, int newColumn, int newRow) {
            Log.d("22222222",oldColumn+","+oldColumn);
            Log.d("2222222",newColumn+","+newRow);
            // Add logic here to prevent an item to be dropped
            return true;
        }
    `});````
yuxingfafu commented 5 years ago

sorry,i also i other question, if i want to persistence the data to sqlite or SharedPreferences,how get the BoardView the datasoure ,and save it, and when i reboot phone, I wanto read the persistence data(sqllite or SharedPreferences) and set the persistence data for BoardView ,if so it could keep the original sort as well

woxblom commented 5 years ago

You have the source already as you are sending in the adapters for the diffferent columns. It is that source you will have to check.

About persistence, I think you need to google that yourself for a bit as that is a big question and not part of this lib.

BR Magnus

yuxingfafu commented 5 years ago

thanks a lot. i try to modify the animation when long clicked to drag,but not effect,(i want to add shake with all items like launcher ios ) the class DragItem startDrag and endDrag method. i try to hide the mRealDragView with startDrag,and show mRealDragView with endDrag ,like gif below ,could give me some tips? thanks you :)

device-2019-07-09-202118

woxblom commented 5 years ago

Sorry I don't really know. You will have to experiment with the lib and see what you can achieve.

yuxingfafu commented 5 years ago

thank you, i will try my idea. i found other question;when lib boardview on Landscape ,for example the phone width is 1280,the height is 800.
so i modify the code class BoardView onFinishInflate method mColumnWidth = 1280; i write it hard code.

scoll betwen page not effect. it may stay the middle area between two page. image image image

woxblom commented 5 years ago

I don't think you should hard code stuff. Use the real width taken from the view in that case.

yuxingfafu commented 5 years ago

Yeah I agree it is to sensitive. I have made an update which makes it better. I changed 0.18 to 0.06. So it is the correct place you tried to change. Version 1.6.6 should be out soon with the change.

for this questtion.i try ,found when draging on one page,i will easyly drop to other page. is there reason with mColumnWidth = (int) (res.getDisplayMetrics().widthPixels ); i modify device-2019-07-10-172531

yuxingfafu commented 5 years ago

I don't think you should hard code stuff. Use the real width taken from the view in that case.

i try modify mColumnWidth = (int) (res.getDisplayMetrics().widthPixels ); also have the question ,could help me to analysis

woxblom commented 5 years ago

No the reason is the value on line 369. The lower value the less sensitive it is.

yuxingfafu commented 5 years ago

how the appropriate it should be? float scrollEdge = getResources().getDisplayMetrics().widthPixels * (isPortrait ? 0.06f : 0.14f);

woxblom commented 5 years ago

I works for me if is set the width to mColumnWidth = (int) (res.getDisplayMetrics().widthPixels ); and then change setSnapToColumnInLandscape to true. Then I can switch pages without any problem.

woxblom commented 5 years ago

You will have to try different values yourself. If you set it to 0 then you need to move the finger all the way to the edge.

yuxingfafu commented 5 years ago

thank you, i try my idea,but also have a question with animation ,could help me check some code, if convenient, i send code to you email?

woxblom commented 5 years ago

If it is an isolated question about animation you can post it here. I don't have time to do deep analysis of bigger stuff unfortunately.

yuxingfafu commented 5 years ago

thank you very much

image image the zip code is below DragListView.zip

yuxingfafu commented 5 years ago

the animation gif is follow:

device-2019-07-11-091151

woxblom commented 5 years ago

So what is your question about the animation? :)

yuxingfafu commented 5 years ago

en,

yuxingfafu commented 5 years ago

and the sensitive i modify as your code ,it's ok now

yuxingfafu commented 5 years ago

with the animation, could add a function as follow: when long click trigger drag, it add a empty page, if so , could drag the item long clicked to a new empty page. :) thanks you

woxblom commented 5 years ago

That is specific features regarding implementing a home screen. I will not add that to the main lib but you can fork the lib and add it yourself.

Will close this issue now.