Reordering of favorites list
This commit is contained in:
parent
0c51fe904d
commit
fcc9f2ba21
@ -13,3 +13,4 @@ android.library.reference.1=../ActionBarSherlock/library
|
||||
android.library.reference.2=../HoloEverywhere/library
|
||||
android.library.reference.3=../NineOldAndroids/library
|
||||
android.library.reference.4=../android-numberpicker/library
|
||||
android.library.reference.5=../drag-sort-listview/library
|
||||
|
BIN
res/drawable-hdpi/drag_handle.png
Executable file
BIN
res/drawable-hdpi/drag_handle.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 506 B |
BIN
res/drawable-mdpi/drag_handle.png
Executable file
BIN
res/drawable-mdpi/drag_handle.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 429 B |
BIN
res/drawable-xhdpi/drag_handle.png
Executable file
BIN
res/drawable-xhdpi/drag_handle.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 586 B |
@ -6,6 +6,15 @@
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dragHandle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:contentDescription="Drag handle"
|
||||
android:src="@drawable/drag_handle" />
|
||||
|
||||
<com.dougkeen.bart.controls.CountdownTextView
|
||||
android:id="@+id/countdownText"
|
||||
style="@style/DepartureCountdownText"
|
||||
@ -25,15 +34,16 @@
|
||||
<TextView
|
||||
android:id="@+id/originText"
|
||||
style="@style/FavoriteListingTextView"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toLeftOf="@id/countdownText"
|
||||
android:layout_toRightOf="@id/dragHandle"
|
||||
android:text="Origin" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/to"
|
||||
style="@style/FavoriteListingTextView"
|
||||
android:layout_below="@id/originText"
|
||||
android:layout_toRightOf="@id/dragHandle"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="8dp"
|
||||
android:text="to" />
|
||||
|
@ -1,15 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res/com.dougkeen.bart"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ListView
|
||||
<com.mobeta.android.dslv.DragSortListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
android:layout_margin="3dp"
|
||||
android:layout_weight="1"
|
||||
android:dividerHeight="1dp"
|
||||
android:padding="3dp"
|
||||
app:collapsed_height="1dp"
|
||||
app:drag_enabled="true"
|
||||
app:drag_handle_id="@id/dragHandle"
|
||||
app:drag_scroll_start="0.33"
|
||||
app:drag_start_mode="onDown"
|
||||
app:float_alpha="0.6"
|
||||
app:remove_enabled="true"
|
||||
app:remove_mode="flingRemove"
|
||||
app:slide_shuffle_speed="0.3" />
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/empty"
|
||||
|
@ -17,7 +17,6 @@ import com.WazaBe.HoloEverywhere.app.AlertDialog;
|
||||
import com.WazaBe.HoloEverywhere.app.AlertDialog.Builder;
|
||||
import com.WazaBe.HoloEverywhere.app.DialogFragment;
|
||||
import com.WazaBe.HoloEverywhere.sherlock.SActivity;
|
||||
import com.WazaBe.HoloEverywhere.widget.ListView;
|
||||
import com.WazaBe.HoloEverywhere.widget.TextView;
|
||||
import com.actionbarsherlock.view.ActionMode;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
@ -46,6 +45,7 @@ import com.googlecode.androidannotations.annotations.ItemLongClick;
|
||||
import com.googlecode.androidannotations.annotations.UiThread;
|
||||
import com.googlecode.androidannotations.annotations.ViewById;
|
||||
import com.googlecode.androidannotations.annotations.rest.RestService;
|
||||
import com.mobeta.android.dslv.DragSortListView;
|
||||
|
||||
@EActivity(R.layout.main)
|
||||
public class RoutesListActivity extends SActivity implements TickSubscriber {
|
||||
@ -74,7 +74,7 @@ public class RoutesListActivity extends SActivity implements TickSubscriber {
|
||||
ElevatorClient elevatorClient;
|
||||
|
||||
@ViewById(android.R.id.list)
|
||||
ListView listView;
|
||||
DragSortListView listView;
|
||||
|
||||
@ViewById(R.id.quickLookupButton)
|
||||
Button quickLookupButton;
|
||||
@ -107,6 +107,27 @@ public class RoutesListActivity extends SActivity implements TickSubscriber {
|
||||
startContextualActionMode();
|
||||
}
|
||||
|
||||
private DragSortListView.DropListener onDrop = new DragSortListView.DropListener() {
|
||||
@Override
|
||||
public void drop(int from, int to) {
|
||||
if (from == to)
|
||||
return;
|
||||
|
||||
StationPair item = mRoutesAdapter.getItem(from);
|
||||
|
||||
mRoutesAdapter.move(item, to);
|
||||
mRoutesAdapter.notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
private DragSortListView.RemoveListener onRemove = new DragSortListView.RemoveListener() {
|
||||
@Override
|
||||
public void remove(int which) {
|
||||
mRoutesAdapter.remove(mRoutesAdapter.getItem(which));
|
||||
mRoutesAdapter.notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
@AfterViews
|
||||
void afterViews() {
|
||||
setTitle(R.string.favorite_routes);
|
||||
@ -118,6 +139,9 @@ public class RoutesListActivity extends SActivity implements TickSubscriber {
|
||||
|
||||
listView.setEmptyView(findViewById(android.R.id.empty));
|
||||
|
||||
listView.setDropListener(onDrop);
|
||||
listView.setRemoveListener(onRemove);
|
||||
|
||||
if (mCurrentAlerts != null) {
|
||||
showAlertMessage(mCurrentAlerts);
|
||||
}
|
||||
|
@ -112,6 +112,11 @@ public class FavoritesArrayAdapter extends ArrayAdapter<StationPair> {
|
||||
}
|
||||
}
|
||||
|
||||
public void move(StationPair object, int to) {
|
||||
super.remove(object);
|
||||
super.insert(object, to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
super.clear();
|
||||
|
@ -43,6 +43,7 @@ public class StationPair implements Parcelable {
|
||||
private Station origin;
|
||||
private Station destination;
|
||||
private String fare;
|
||||
|
||||
private long fareLastUpdated;
|
||||
private int averageTripLength;
|
||||
private int averageTripSampleCount;
|
||||
@ -126,6 +127,12 @@ public class StationPair implements Parcelable {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StationPair [origin=" + origin + ", destination=" + destination
|
||||
+ "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user