Eric Kok
12 years ago
11 changed files with 157 additions and 29 deletions
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:paddingBottom="@dimen/margin_half" |
||||
android:paddingLeft="@dimen/margin_default" |
||||
android:paddingRight="@dimen/margin_default" |
||||
android:paddingTop="@dimen/margin_half" > |
||||
|
||||
<TextView |
||||
android:id="@+id/item_text" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:textSize="15sp" |
||||
android:textIsSelectable="false" /> |
||||
|
||||
</FrameLayout> |
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
package org.transdroid.core.gui.navigation; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.transdroid.core.gui.lists.SimpleListItem; |
||||
import org.transdroid.core.gui.lists.SimpleListItemView; |
||||
import org.transdroid.core.gui.lists.SimpleListItemView_; |
||||
|
||||
import android.content.Context; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.widget.BaseAdapter; |
||||
|
||||
public class FilterListItemAdapter extends BaseAdapter { |
||||
|
||||
private final Context context; |
||||
private List<? extends SimpleListItem> items; |
||||
|
||||
public FilterListItemAdapter(Context context, List<? extends SimpleListItem> items) { |
||||
this.context = context; |
||||
this.items = items; |
||||
} |
||||
|
||||
/** |
||||
* Allows updating of the full data list underlying this adapter, replacing all items |
||||
* @param newItems The new list of filter items to display |
||||
*/ |
||||
public void update(List<? extends SimpleListItem> newItems) { |
||||
this.items = newItems; |
||||
notifyDataSetChanged(); |
||||
} |
||||
|
||||
@Override |
||||
public int getCount() { |
||||
return items.size(); |
||||
} |
||||
|
||||
@Override |
||||
public SimpleListItem getItem(int position) { |
||||
return items.get(position); |
||||
} |
||||
|
||||
@Override |
||||
public long getItemId(int position) { |
||||
return position; |
||||
} |
||||
|
||||
@Override |
||||
public View getView(int position, View convertView, ViewGroup parent) { |
||||
SimpleListItemView filterItemView; |
||||
if (convertView == null || !(convertView instanceof SimpleListItemView)) { |
||||
filterItemView = SimpleListItemView_.build(context); |
||||
} else { |
||||
filterItemView = (SimpleListItemView) convertView; |
||||
} |
||||
filterItemView.bind(getItem(position)); |
||||
return filterItemView; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
package org.transdroid.core.gui.navigation; |
||||
|
||||
import org.androidannotations.annotations.EViewGroup; |
||||
import org.androidannotations.annotations.ViewById; |
||||
import org.transdroid.core.gui.lists.SimpleListItem; |
||||
|
||||
import android.content.Context; |
||||
import android.widget.FrameLayout; |
||||
import android.widget.TextView; |
||||
|
||||
/** |
||||
* View that represents some {@link SimpleListItem} object used to represent a navigation filter item |
||||
* @author Eric Kok |
||||
*/ |
||||
@EViewGroup(resName="list_item_filter") |
||||
public class FilterListItemView extends FrameLayout { |
||||
|
||||
@ViewById |
||||
protected TextView itemText; |
||||
|
||||
public FilterListItemView(Context context) { |
||||
super(context); |
||||
} |
||||
|
||||
public void bind(SimpleListItem filterItem) { |
||||
itemText.setText(filterItem.getName()); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue