mirror of https://github.com/tasks/tasks
Finished implementing filter mode specs for all three filter modes
parent
f1cffcc704
commit
7cb1a40923
@ -1,39 +0,0 @@
|
||||
package com.todoroo.astrid.tags.reusable;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import com.todoroo.andlib.utility.AndroidUtilities;
|
||||
import com.todoroo.astrid.activity.FilterListFragment;
|
||||
import com.todoroo.astrid.activity.TaskListActivity;
|
||||
import com.todoroo.astrid.activity.TaskListFragment;
|
||||
import com.todoroo.astrid.ui.MainMenuPopover;
|
||||
|
||||
public class FeaturedListActivity extends TaskListActivity {
|
||||
|
||||
@Override
|
||||
protected Class<? extends FilterListFragment> getFilterListClass() {
|
||||
return FeaturedListFragment.class;
|
||||
}
|
||||
|
||||
|
||||
public static final int[] FORBIDDEN_MENU_ITEMS = {
|
||||
TaskListFragment.MENU_NEW_FILTER_ID,
|
||||
TaskListFragment.MENU_ADDONS_ID,
|
||||
MainMenuPopover.MAIN_MENU_ITEM_FEATURED_LISTS,
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean shouldAddMenuItem(int itemId) {
|
||||
return AndroidUtilities.indexOf(FORBIDDEN_MENU_ITEMS, itemId) < 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mainMenuItemSelected(int item, Intent customIntent) {
|
||||
if (item == MainMenuPopover.MAIN_MENU_ITEM_LISTS) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
super.mainMenuItemSelected(item, customIntent);
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.todoroo.astrid.tags.reusable;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.astrid.activity.FilterListFragment;
|
||||
import com.todoroo.astrid.activity.FilterModeSpec;
|
||||
import com.todoroo.astrid.activity.TaskListFragment;
|
||||
import com.todoroo.astrid.api.Filter;
|
||||
import com.todoroo.astrid.api.FilterListItem;
|
||||
import com.todoroo.astrid.core.CoreFilterExposer;
|
||||
import com.todoroo.astrid.ui.MainMenuPopover;
|
||||
|
||||
public class FeaturedListFilterMode implements FilterModeSpec {
|
||||
|
||||
@Override
|
||||
public int[] getForbiddenMenuItems() {
|
||||
return FORBIDDEN_MENU_ITEMS;
|
||||
}
|
||||
|
||||
private static final int[] FORBIDDEN_MENU_ITEMS = {
|
||||
TaskListFragment.MENU_NEW_FILTER_ID,
|
||||
TaskListFragment.MENU_ADDONS_ID,
|
||||
MainMenuPopover.MAIN_MENU_ITEM_FEATURED_LISTS
|
||||
};
|
||||
|
||||
@Override
|
||||
public Class<? extends FilterListFragment> getFilterListClass() {
|
||||
return FeaturedListFragment.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getDefaultFilter(Context context) {
|
||||
Filter defaultFilter = FeaturedListFilterExposer.getDefaultFilter();
|
||||
if (defaultFilter == null)
|
||||
return CoreFilterExposer.buildInboxFilter(context.getResources());
|
||||
else
|
||||
return defaultFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMainMenuIconAttr() {
|
||||
return R.attr.asMainMenu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFilterItemClickedCallback(FilterListItem item) {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.todoroo.astrid.activity;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.astrid.api.Filter;
|
||||
import com.todoroo.astrid.api.FilterListItem;
|
||||
import com.todoroo.astrid.core.CoreFilterExposer;
|
||||
|
||||
public class DefaultFilterMode implements FilterModeSpec {
|
||||
|
||||
@Override
|
||||
public int[] getForbiddenMenuItems() {
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends FilterListFragment> getFilterListClass() {
|
||||
return FilterListFragment.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getDefaultFilter(Context context) {
|
||||
return CoreFilterExposer.buildInboxFilter(context.getResources());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMainMenuIconAttr() {
|
||||
return R.attr.asMainMenu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFilterItemClickedCallback(FilterListItem item) {
|
||||
//
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue