@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_community_cookbook); // //////////////////// Was activity_home setTitle("Community Cookbook"); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); // Database Creation datasource = new DataSourceManager(this); datasource.open(); // List items should be given the 'activated' state when touched. /*((CCListFragment) getSupportFragmentManager().findFragmentById( R.id.CC_cookable_list)).setActivateOnItemClick(true); ///////// change? */ CCListFragment fragment = (CCListFragment) getSupportFragmentManager().findFragmentById(R.id.CC_cookable_list); fragment.setActivateOnItemClick(true); adapter = (ArrayAdapter<Cookable>) fragment.getListAdapter(); // Register text listener /*AutoCompleteTextView search = (AutoCompleteTextView) findViewById(R.id.CC_search); /// was home_search String[] tags = getResources().getStringArray(R.array.tags_array); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, tags); search.setAdapter(adapter); search.setOnEditorActionListener(this);*/ List<Tag> tags = datasource.getAllTags(); List<Meal> meals = datasource.getAllUserMeals(); List<Recipe> recipes = datasource.getAllUserRecipes(); String[] autocompleteStrings = new String[tags.size() + meals.size() + recipes.size()]; int i = 0; int j = 0; for (j = 0; j < meals.size(); i++, j++) { autocompleteStrings[i] = meals.get(j).getName(); } for (j = 0; j < recipes.size(); i++, j++) { autocompleteStrings[i] = recipes.get(j).getName(); } for (j = 0; j < tags.size(); i++, j++) { autocompleteStrings[i] = tags.get(j).getName(); } EditText search = (EditText) findViewById(R.id.CC_search); search.addTextChangedListener(this); search.setOnFocusChangeListener(this); CommColumn0 = (LinearLayout) findViewById(R.id.CC_column_0); // /////// in xml??? CommColumn1 = (LinearLayout) findViewById(R.id.CC_column_1); CommColumn2 = (LinearLayout) findViewById(R.id.CC_column_2); }
@Override public void onDestroy() { super.onDestroy(); datasource.close(); }
@Override protected void onPause() { datasource.close(); super.onPause(); }
@Override protected void onResume() { datasource.open(); super.onResume(); }