Skip to content

Commit

Permalink
For widget configuration, select a filter automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Su committed Nov 8, 2011
1 parent 924ebbd commit 7be3b6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java
Expand Up @@ -93,6 +93,9 @@ public class FilterAdapter extends BaseExpandableListAdapter {
/** whether to skip Filters that launch intents instead of being real filters */
private final boolean skipIntentFilters;

/** whether rows are selectable */
private final boolean selectable;

// Previous solution involved a queue of filters and a filterSizeLoadingThread. The filterSizeLoadingThread had
// a few problems: how to make sure that the thread is resumed when the controlling activity is resumed, and
// how to make sure that the the filterQueue does not accumulate filters without being processed. I am replacing
Expand All @@ -105,6 +108,11 @@ public class FilterAdapter extends BaseExpandableListAdapter {

public FilterAdapter(Activity activity, ExpandableListView listView,
int rowLayout, boolean skipIntentFilters) {
this(activity, listView, rowLayout, skipIntentFilters, false);
}

public FilterAdapter(Activity activity, ExpandableListView listView,
int rowLayout, boolean skipIntentFilters, boolean selectable) {
super();

DependencyInjectionService.getInstance().inject(this);
Expand All @@ -114,6 +122,7 @@ public FilterAdapter(Activity activity, ExpandableListView listView,
this.listView = listView;
this.layout = rowLayout;
this.skipIntentFilters = skipIntentFilters;
this.selectable = selectable;

inflater = (LayoutInflater) activity.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
Expand All @@ -127,6 +136,8 @@ public FilterAdapter(Activity activity, ExpandableListView listView,
}

private void offerFilter(final Filter filter) {
if(selectable && selection == null)
setSelection(filter);
filterExecutor.submit(new Runnable() {
@Override
public void run() {
Expand Down
Expand Up @@ -68,7 +68,7 @@ public void onCreate(Bundle icicle) {

// set up ui
adapter = new FilterAdapter(this, getExpandableListView(),
R.layout.filter_adapter_row, true);
R.layout.filter_adapter_row, true, true);
setListAdapter(adapter);

Button button = (Button)findViewById(R.id.ok);
Expand Down

0 comments on commit 7be3b6c

Please sign in to comment.