Skip to content

Commit

Permalink
Switched from cwac-touchlist to drag-sort-listview
Browse files Browse the repository at this point in the history
  • Loading branch information
murgo committed Sep 3, 2012
1 parent eb3277f commit fbf0878
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 64 deletions.
6 changes: 3 additions & 3 deletions Android/IrssiNotifier/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.compiler.source=1.6
4 changes: 2 additions & 2 deletions Android/IrssiNotifier/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

# Project target.
target=android-15
android.library.reference.1=..\\\\..\\\\..\\\\Lib\\\\JakeWharton-Android-ViewPagerIndicator-439af9d\\\\library
android.library.reference.1=..\\..\\..\\Lib\\JakeWharton-Android-ViewPagerIndicator-439af9d\\library
android.library.reference.2=..\\..\\..\\Lib\\JakeWharton-ActionBarSherlock-df676ad\\library
android.library.reference.3=../../../Lib/cwac-touchlist
android.library.reference.3=../Lib/drag-sort-listview
33 changes: 20 additions & 13 deletions Android/IrssiNotifier/res/layout/channel_settings.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<com.commonsware.cwac.tlv.TouchListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tlv="http://schemas.android.com/apk/res/fi.iki.murgo.irssinotifier"

android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
tlv:normal_height="48dip"
tlv:expanded_height="92dip"
tlv:grabber="@+id/grabber_icon"
tlv:remove_mode="slide"
/>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/res/fi.iki.murgo.irssinotifier"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.mobeta.android.dslv.DragSortListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="0dp"
android:paddingBottom="0dp"
android:paddingLeft="10dp"
android:layout_margin="10dp"
dslv:collapsed_height="5dp"
dslv:drag_scroll_start="0.33"
dslv:max_drag_scroll_speed="0.5"
dslv:float_background_color="#000000"
dslv:remove_mode="none"
dslv:track_drag_scroll="false" />
</RelativeLayout>
5 changes: 3 additions & 2 deletions Android/IrssiNotifier/res/layout/channel_settings_row.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="64dip"
android:gravity="center_vertical"
android:background="#333333"
>

<ImageView android:id="@+id/grabber_icon"
<ImageView android:id="@id/drag"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
Expand All @@ -22,7 +23,7 @@
android:paddingLeft="9dip"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
android:layout_toRightOf="@id/grabber_icon"
android:layout_toRightOf="@id/drag"
android:layout_centerVertical="true"
android:ellipsize="marquee"
android:singleLine="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,46 @@
import java.util.ArrayList;
import java.util.List;

import com.mobeta.android.dslv.DragSortListView;

import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.commonsware.cwac.tlv.TouchListView;

public class ChannelSettingsActivity extends ListActivity {

private IconicAdapter adapter = null;
private List<Channel> channels;
private ArrayAdapter<String> adapter;
private Context ctx;

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.channel_settings);
ctx = this;

DataAccess da = new DataAccess(this);
channels = da.getChannels();
List<String> channelNames = new ArrayList<String>();
for (Channel ch : channels)
channelNames.add(ch.getName());

setContentView(R.layout.channel_settings);
final DragSortListView lv = (DragSortListView) getListView();

lv.setDropListener(onDrop);
lv.setRemoveListener(onRemove);
lv.setOnItemLongClickListener(getOnItemLongClickListener());

TouchListView tlv=(TouchListView)getListView();
adapter = new IconicAdapter(channelNames);
adapter = new ArrayAdapter<String>(this, R.layout.channel_settings_row, R.id.label, channelNames);
setListAdapter(adapter);

tlv.setDropListener(onDrop);
tlv.setRemoveListener(onRemove);

MessageBox.Show(this, null, "Drag channels from the grabber to reorder them, swipe grabber right to remove channel", null);

MessageBox.Show(this, null, "Drag channels from the grabber to reorder them, long press channel to remove it.", null);
}

@Override
Expand Down Expand Up @@ -72,42 +77,47 @@ protected void onDestroy() {
IrssiNotifierActivity.needsRefresh();
}

private TouchListView.DropListener onDrop=new TouchListView.DropListener() {
private DragSortListView.DropListener onDrop = new DragSortListView.DropListener() {
@Override
public void drop(int from, int to) {
String item = adapter.getItem(from);
adapter.remove(item);
adapter.insert(item, to);
String item = adapter.getItem(from);

adapter.remove(item);
adapter.insert(item, to);
}
};

private TouchListView.RemoveListener onRemove=new TouchListView.RemoveListener() {

private DragSortListView.RemoveListener onRemove = new DragSortListView.RemoveListener() {
@Override
public void remove(int which) {
adapter.remove(adapter.getItem(which));
adapter.remove(adapter.getItem(which));
}
};

class IconicAdapter extends ArrayAdapter<String> {
private List<String> data;

IconicAdapter(List<String> data) {
super(ChannelSettingsActivity.this, R.layout.channel_settings_row, data);
this.data = data;
}

public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;

if (row == null) {
LayoutInflater inflater=getLayoutInflater();
row = inflater.inflate(R.layout.channel_settings_row, parent, false);
private OnItemLongClickListener getOnItemLongClickListener() {
return new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, final View arg1, final int arg2, long arg3) {
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
final int index = arg2;
builder.setMessage("Are you sure you want to remove channel " + channels.get(index).getName() )
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
String item = adapter.getItem(index);
adapter.remove(item);
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();

return true;
}

TextView label = (TextView)row.findViewById(R.id.label);

label.setText("" + (position + 1) + ": " + data.get(position));

return row;
}
};
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Web page: https://irssinotifier.appspot.com/

- [ActionBarSherlock](https://github.com/JakeWharton/ActionBarSherlock). Thanks, [Jake Wharton](https://github.com/JakeWharton).
- [ViewPagerIndicator](https://github.com/JakeWharton/Android-ViewPagerIndicator/). Thanks, [Jake Wharton](https://github.com/JakeWharton).
- [cwac-touchlist](https://github.com/commonsguy/cwac-touchlist). Thanks, commonsguy.
- [drag-sort-listview](https://github.com/bauerca/drag-sort-listview). Thanks, [Carl Bauer](https://github.com/bauerca).

##License

Expand Down

0 comments on commit fbf0878

Please sign in to comment.