@Override public void onResume() { super.onResume(); // HockeyApp integration for crash reports & updates checkForCrashes(); controller.getCategories(CategoryManager.getRootCategory()); mAdapter.notifyDataSetChanged(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getActionBar().setHomeButtonEnabled(false); setContentView(R.layout.main); // HockeyApp integration for crash reports & updates checkForUpdates(); controller = new MainCategoriesListController(); controller.addOutboxHandler(new Handler(this)); mAdapter = new MainCategoriesAdapter(this, controller.getModel()); setListAdapter(mAdapter); // onClick listener getListView() .setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int position, long l) { Intent intent = new Intent(MainCategoriesActivity.this, ProductListActivity.class); Category selectedCategory = (Category) mAdapter.getItem(position); intent.putExtra(INTENT_EXTRA_CATEGORY_MAIN, selectedCategory); startActivity(intent); } }); // Create the search suggestions list mSearchList = (ListView) findViewById(R.id.searchList); mSearchList.setAdapter(new SortOptionsAdapter(this, controller.getSearchSuggestions())); mSearchList.setVisibility(View.GONE); mSearchList.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapter, View view, int position, long arg) { String searchString = (String) mSearchList.getItemAtPosition(position); onQueryTextSubmit(searchString); } }); }
/** Set up the action menu */ @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); // Set up the search box and table SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); searchView.setQueryHint(getResources().getString(R.string.search_products_hint)); // Workaround to set the color of the searchView text LinearLayout linearLayout1 = (LinearLayout) searchView.getChildAt(0); LinearLayout linearLayout2 = (LinearLayout) linearLayout1.getChildAt(2); LinearLayout linearLayout3 = (LinearLayout) linearLayout2.getChildAt(1); AutoCompleteTextView autoComplete = (AutoCompleteTextView) linearLayout3.getChildAt(0); autoComplete.setTextColor(getResources().getColor(R.color.editTextDark)); searchView.setOnQueryTextListener(this); searchView.setOnQueryTextFocusChangeListener( new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { mSearchList.setVisibility(View.VISIBLE); } else { mSearchList.setVisibility(View.GONE); } } }); menu.removeItem(R.id.refine); return true; }