@Override public void onPrepareOptionsMenu(Menu menu) { menu.clear(); getSherlockActivity().getSupportMenuInflater().inflate(R.menu.gripmenu, menu); SubMenu submenu = menu.getItem(0).getSubMenu(); submenu.clear(); if (category == null) { category = (getArguments() != null) ? getArguments().getString(SearchFragment.ARG_CATEGORY) : null; } if (getArguments() == null || !getArguments().containsKey(SearchFragment.ARG_LIST) && !getArguments().containsKey(SearchFragment.ARG_QUERY)) { submenu.add(Menu.CATEGORY_SYSTEM, R.id.submenu_search, Menu.NONE, R.string.search_txt); } submenu.add(Menu.CATEGORY_SYSTEM, R.id.map_view, Menu.NONE, R.string.map_view); if (category != null) { String addString = getString( R.string.add_poi_in_cat, getString( CategoryHelper.getCategoryDescriptorByCategoryFiltered( CategoryHelper.CATEGORY_TYPE_POIS, category) .description)); submenu.add(Menu.CATEGORY_SYSTEM, R.id.menu_item_addpoi, Menu.NONE, addString); } // NotificationsSherlockFragmentDT.onPrepareOptionsMenuNotifications(menu); super.onPrepareOptionsMenu(menu); }
@Override public void onStart() { if (reload) { getPoiAdapter().clear(); reload = false; } DiscoverTrentoActivity.mDrawerToggle.setDrawerIndicatorEnabled(false); DiscoverTrentoActivity.drawerState = "off"; getSherlockActivity().getSupportActionBar().setHomeButtonEnabled(true); getSherlockActivity().getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSherlockActivity().getSupportActionBar().setDisplayShowTitleEnabled(true); Bundle bundle = this.getArguments(); String category = (bundle != null) ? bundle.getString(SearchFragment.ARG_CATEGORY) : null; CategoryDescriptor catDescriptor = CategoryHelper.getCategoryDescriptorByCategoryFiltered("pois", category); String categoryString = (catDescriptor != null) ? context.getResources().getString(catDescriptor.description) : null; // set title TextView title = (TextView) getView().findViewById(R.id.list_title); if (categoryString != null) { title.setText(categoryString); } else if (bundle != null && bundle.containsKey(SearchFragment.ARG_QUERY)) { String query = bundle.getString(SearchFragment.ARG_QUERY); title.setText(context.getResources().getString(R.string.search_for) + "'" + query + "'"); if (bundle.containsKey(SearchFragment.ARG_CATEGORY_SEARCH)) { category = bundle.getString(SearchFragment.ARG_CATEGORY_SEARCH); if (category != null) title.append( " " + context.getResources().getString(R.string.search_for) + " " + categoryString); } } if (bundle.containsKey(SearchFragment.ARG_WHERE_SEARCH)) { WhereForSearch where = bundle.getParcelable(SearchFragment.ARG_WHERE_SEARCH); if (where != null) title.append(" " + where.getDescription() + " "); } // close items menus if open ((View) list.getParent()) .setOnClickListener( new View.OnClickListener() { public void onClick(View v) { hideListItemsMenu(v, false); } }); list.setOnItemClickListener( new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { hideListItemsMenu(view, false); setStorePoiId(view, position); } }); FeedbackFragmentInflater.inflateHandleButton(getSherlockActivity(), getView()); super.onStart(); }