Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/fragments/FavoritesFragment.java
Show All 39 Lines | public class FavoritesFragment extends BaseFragment { | ||||
private ListView favoriteListView; | private ListView favoriteListView; | ||||
private EditText busStopNameText; | private EditText busStopNameText; | ||||
private TextView favoriteTipTextView; | private TextView favoriteTipTextView; | ||||
private ImageView angeryBusImageView; | private ImageView angeryBusImageView; | ||||
@Nullable | @Nullable | ||||
private CommonFragmentListener mListener; | private CommonFragmentListener mListener; | ||||
public static final String FRAGMENT_TAG = "BusTOFavFragment"; | |||||
public static FavoritesFragment newInstance() { | public static FavoritesFragment newInstance() { | ||||
FavoritesFragment fragment = new FavoritesFragment(); | FavoritesFragment fragment = new FavoritesFragment(); | ||||
Bundle args = new Bundle(); | Bundle args = new Bundle(); | ||||
//args.putString(ARG_PARAM1, param1); | //args.putString(ARG_PARAM1, param1); | ||||
//args.putString(ARG_PARAM2, param2); | //args.putString(ARG_PARAM2, param2); | ||||
fragment.setArguments(args); | fragment.setArguments(args); | ||||
return fragment; | return fragment; | ||||
} | } | ||||
private FavoritesFragment(){ | public FavoritesFragment(){ | ||||
} | } | ||||
@Override | @Override | ||||
public void onCreate(Bundle savedInstanceState) { | public void onCreate(Bundle savedInstanceState) { | ||||
super.onCreate(savedInstanceState); | super.onCreate(savedInstanceState); | ||||
if (getArguments() != null) { | if (getArguments() != null) { | ||||
//do nothing | //do nothing | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | public void onCreateContextMenu(@NonNull ContextMenu menu, @NonNull View v, | ||||
// if we aren't attached to activity, return null | // if we aren't attached to activity, return null | ||||
if (getActivity()==null) return; | if (getActivity()==null) return; | ||||
MenuInflater inflater = getActivity().getMenuInflater(); | MenuInflater inflater = getActivity().getMenuInflater(); | ||||
inflater.inflate(R.menu.menu_favourites_entry, menu); | inflater.inflate(R.menu.menu_favourites_entry, menu); | ||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
public void onResume() { | |||||
super.onResume(); | |||||
if (mListener!=null) mListener.readyGUIfor(FragmentKind.FAVORITES); | |||||
} | |||||
@Override | |||||
public boolean onContextItemSelected(MenuItem item) { | public boolean onContextItemSelected(MenuItem item) { | ||||
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item | AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item | ||||
.getMenuInfo(); | .getMenuInfo(); | ||||
Stop busStop = (Stop) favoriteListView.getItemAtPosition(info.position); | Stop busStop = (Stop) favoriteListView.getItemAtPosition(info.position); | ||||
switch (item.getItemId()) { | switch (item.getItemId()) { | ||||
case R.id.action_favourite_entry_delete: | case R.id.action_favourite_entry_delete: | ||||
Show All 37 Lines | public boolean onContextItemSelected(MenuItem item) { | ||||
TODO: start map on button press | TODO: start map on button press | ||||
*/ | */ | ||||
return true; | return true; | ||||
default: | default: | ||||
return super.onContextItemSelected(item); | return super.onContextItemSelected(item); | ||||
} | } | ||||
} | } | ||||
void showStops(List<Stop> busStops){ | void showStops(List<Stop> busStops){ | ||||
// If no data is found show a friendly message | // If no data is found show a friendly message | ||||
if (busStops.size() == 0) { | if (busStops.size() == 0) { | ||||
favoriteListView.setVisibility(View.INVISIBLE); | favoriteListView.setVisibility(View.INVISIBLE); | ||||
// TextView favoriteTipTextView = (TextView) findViewById(R.id.favoriteTipTextView); | // TextView favoriteTipTextView = (TextView) findViewById(R.id.favoriteTipTextView); | ||||
//assert favoriteTipTextView != null; | //assert favoriteTipTextView != null; | ||||
favoriteTipTextView.setVisibility(View.VISIBLE); | favoriteTipTextView.setVisibility(View.VISIBLE); | ||||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register