Use DSLV for FolderPicker

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

No files matched your search

@@ -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();
}
@@ -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;
}