Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/fragments/FavoritesFragment.java
package it.reyboz.bustorino.fragments; | package it.reyboz.bustorino.fragments; | ||||
import android.app.AlertDialog; | import android.app.AlertDialog; | ||||
import android.content.Context; | import android.content.Context; | ||||
import android.content.DialogInterface; | import android.content.DialogInterface; | ||||
import android.content.Intent; | |||||
import android.os.Bundle; | import android.os.Bundle; | ||||
import android.os.Handler; | |||||
import android.view.ContextMenu; | import android.view.ContextMenu; | ||||
import android.view.LayoutInflater; | import android.view.LayoutInflater; | ||||
import android.view.MenuInflater; | import android.view.MenuInflater; | ||||
import android.view.MenuItem; | import android.view.MenuItem; | ||||
import android.view.View; | import android.view.View; | ||||
import android.view.ViewGroup; | import android.view.ViewGroup; | ||||
import android.widget.AdapterView; | import android.widget.AdapterView; | ||||
import android.widget.EditText; | import android.widget.EditText; | ||||
Show All 11 Lines | |||||
import it.reyboz.bustorino.ActivityFavorites; | import it.reyboz.bustorino.ActivityFavorites; | ||||
import it.reyboz.bustorino.ActivityMain; | import it.reyboz.bustorino.ActivityMain; | ||||
import it.reyboz.bustorino.ActivityMap; | import it.reyboz.bustorino.ActivityMap; | ||||
import it.reyboz.bustorino.R; | import it.reyboz.bustorino.R; | ||||
import it.reyboz.bustorino.adapters.StopAdapter; | import it.reyboz.bustorino.adapters.StopAdapter; | ||||
import it.reyboz.bustorino.backend.Stop; | import it.reyboz.bustorino.backend.Stop; | ||||
import it.reyboz.bustorino.data.FavoritesViewModel; | import it.reyboz.bustorino.data.FavoritesViewModel; | ||||
import it.reyboz.bustorino.data.UserDB; | |||||
import it.reyboz.bustorino.middleware.AsyncStopFavoriteAction; | import it.reyboz.bustorino.middleware.AsyncStopFavoriteAction; | ||||
public class FavoritesFragment extends BaseFragment { | 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; | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | public boolean onContextItemSelected(MenuItem item) { | ||||
}).execute(busStop); | }).execute(busStop); | ||||
return true; | return true; | ||||
case R.id.action_rename_bus_stop_username: | case R.id.action_rename_bus_stop_username: | ||||
showBusStopUsernameInputDialog(busStop); | showBusStopUsernameInputDialog(busStop); | ||||
return true; | return true; | ||||
case R.id.action_view_on_map: | case R.id.action_view_on_map: | ||||
final String theGeoUrl = busStop.getGeoURL(); | if (busStop.getLatitude() == null | busStop.getLongitude() == null | | ||||
/* | mListener==null | ||||
if(theGeoUrl==null){ | ) { | ||||
//doesn't have a position | |||||
Toast.makeText(getContext(),R.string.cannot_show_on_map_no_position,Toast.LENGTH_SHORT).show(); | Toast.makeText(getContext(), R.string.cannot_show_on_map_no_position, Toast.LENGTH_SHORT).show(); | ||||
return true; | return true; | ||||
} | } | ||||
// start ActivityMap with these extras in intent | //GeoPoint point = new GeoPoint(busStop.getLatitude(), busStop.getLongitude()); | ||||
Intent intent = new Intent(getContext(), ActivityMap.class); | |||||
Bundle b = new Bundle(); | |||||
double lat, lon; | |||||
if (busStop.getLatitude()!=null) | |||||
lat = busStop.getLatitude(); | |||||
else lat = 200; | |||||
if (busStop.getLongitude()!=null) | |||||
lon = busStop.getLongitude(); | |||||
else lon = 200; | |||||
b.putDouble("lat", lat); | |||||
b.putDouble("lon",lon); | |||||
b.putString("name", busStop.getStopDefaultName()); | |||||
b.putString("ID", busStop.ID); | |||||
intent.putExtras(b); | |||||
startActivity(intent); | mListener.showMapCenteredOnStop(busStop); | ||||
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){ | ||||
▲ Show 20 Lines • Show All 92 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