Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/ActivityFavorites.java
| Show All 40 Lines | |||||
| 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.widget.AdapterView.AdapterContextMenuInfo; | import android.widget.AdapterView.AdapterContextMenuInfo; | ||||
| import android.content.Intent; | import android.content.Intent; | ||||
| import android.database.sqlite.SQLiteDatabase; | import android.database.sqlite.SQLiteDatabase; | ||||
| import android.os.Bundle; | import android.os.Bundle; | ||||
| import org.osmdroid.util.GeoPoint; | |||||
| import java.util.List; | import java.util.List; | ||||
| public class ActivityFavorites extends AppCompatActivity implements LoaderManager.LoaderCallbacks<Cursor> { | public class ActivityFavorites extends AppCompatActivity implements LoaderManager.LoaderCallbacks<Cursor> { | ||||
| private ListView favoriteListView; | private ListView favoriteListView; | ||||
| private SQLiteDatabase userDB; | private SQLiteDatabase userDB; | ||||
| private EditText bus_stop_name; | private EditText bus_stop_name; | ||||
| @Override | @Override | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | public boolean onContextItemSelected(MenuItem item) { | ||||
| return true; | return true; | ||||
| case R.id.action_view_on_map: | case R.id.action_view_on_map: | ||||
| final String theGeoUrl = busStop.getGeoURL(); | final String theGeoUrl = busStop.getGeoURL(); | ||||
| if(theGeoUrl==null){ | if(theGeoUrl==null){ | ||||
| //doesn't have a position | //doesn't have a position | ||||
| Toast.makeText(getApplicationContext(),R.string.cannot_show_on_map_no_position,Toast.LENGTH_SHORT).show(); | Toast.makeText(getApplicationContext(),R.string.cannot_show_on_map_no_position,Toast.LENGTH_SHORT).show(); | ||||
| return true; | return true; | ||||
| } | } | ||||
| Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(theGeoUrl)); | |||||
| intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | // start ActivityMap with these extras in intent | ||||
| if(intent.resolveActivity(getPackageManager())!=null) | Intent intent = new Intent(ActivityFavorites.this, ActivityMap.class); | ||||
| Bundle b = new Bundle(); | |||||
| b.putDouble("lat", busStop.getLatitude()); | |||||
| b.putDouble("lon", busStop.getLongitude()); | |||||
| b.putString("name", busStop.getStopDefaultName()); | |||||
| b.putString("ID", busStop.ID); | |||||
| intent.putExtras(b); | |||||
| startActivity(intent); | startActivity(intent); | ||||
| else { | |||||
| Toast.makeText(getApplicationContext(),R.string.cannot_show_on_map_no_activity,Toast.LENGTH_SHORT).show(); | |||||
| } | |||||
| return true; | return true; | ||||
| default: | default: | ||||
| return super.onContextItemSelected(item); | return super.onContextItemSelected(item); | ||||
| } | } | ||||
| } | } | ||||
| void createFavoriteList() { | void createFavoriteList() { | ||||
| // TODO: memoize default list, query only user names every time? | // TODO: memoize default list, query only user names every time? | ||||
| ▲ Show 20 Lines • Show All 157 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