Use DSLV for FolderPicker

This commit is contained in:
Adrian Ulrich 2017-04-10 19:58:49 +02:00
parent 1b88ebdc84
commit 08330cdb84
3 changed files with 16 additions and 18 deletions

View File

@ -20,7 +20,9 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
@ -52,12 +54,14 @@ THE SOFTWARE.
android:background="?android:attr/dividerHorizontal"
/>
<ListView
<com.mobeta.android.dslv.DragSortListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:listSelector="?android:attr/selectableItemBackground"
android:divider="@drawable/inset_divider"
android:dividerHeight="1dip" />
android:dividerHeight="1dip"
android:layout_height="0px"
android:layout_width="fill_parent"
android:layout_weight="1"
android:choiceMode="multipleChoice"
dslv:drag_enabled="false" />
</LinearLayout>

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013-2016 Adrian Ulrich <adrian@blinkenlights.ch>
* Copyright (C) 2013-2017 Adrian Ulrich <adrian@blinkenlights.ch>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -30,6 +30,7 @@ import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import com.mobeta.android.dslv.DragSortListView;
public abstract class FolderPickerActivity extends Activity
implements AdapterView.OnItemClickListener
@ -42,7 +43,7 @@ public abstract class FolderPickerActivity extends Activity
/**
* Our listview
*/
private ListView mListView;
private DragSortListView mListView;
/**
* View displaying the current path
*/
@ -67,7 +68,7 @@ public abstract class FolderPickerActivity extends Activity
mCurrentPath = new File("/");
mListAdapter = new FolderPickerAdapter(this, 0);
mPathDisplay = (TextView) findViewById(R.id.path_display);
mListView = (ListView) findViewById(R.id.list);
mListView = (DragSortListView)findViewById(R.id.list);
mSaveButton = (Button) findViewById(R.id.save_button);
mListView.setAdapter(mListAdapter);
@ -129,12 +130,10 @@ public abstract class FolderPickerActivity extends Activity
* Called if user taps a row
*/
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ViewHolder holder = (ViewHolder)view.getTag();
int pos = (int)holder.id;
public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
String dirent = mListAdapter.getItem(pos);
File newPath = null;
if(pos == 0) {
newPath = mCurrentPath.getParentFile();
}

View File

@ -43,7 +43,6 @@ public class FolderPickerAdapter
@Override
public View getView(int pos, View convertView, ViewGroup parent) {
DraggableRow row;
ViewHolder holder;
if (convertView == null) {
row = (DraggableRow)mInflater.inflate(R.layout.draggable_row, parent, false);
@ -51,15 +50,11 @@ public class FolderPickerAdapter
row.getCoverView().setImageResource(R.drawable.folder);
holder = new ViewHolder();
row.setTag(holder);
} else {
row = (DraggableRow)convertView;
holder = (ViewHolder)row.getTag();
}
String label = getItem(pos);
holder.id = pos;
row.getTextView().setText(label);
return row;
}