use of ve.com.abicelis.remindy.model.Place in project Remindy by abicelis.
the class EditLocationBasedReminderFragment method handlePlaceTypeSelected.
private void handlePlaceTypeSelected(int position) {
Place selectedPlace = mPlaces.get(position);
mReminder.setPlace(selectedPlace);
mReminder.setPlaceId(selectedPlace.getId());
mAddress.setText(selectedPlace.getAddress());
if (mSetEnteringFlag) {
mReminder.setTriggerEntering(false);
mReminder.setTriggerExiting(false);
mEntering.setChecked(false);
mExiting.setChecked(false);
}
// Reset flag if used
mSetEnteringFlag = true;
updateMapView();
}
use of ve.com.abicelis.remindy.model.Place in project Remindy by abicelis.
the class EditLocationBasedReminderFragment method onCreate.
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
// If fragment was just called, expect a reminder at REMINDER_ARGUMENT
if (getArguments().containsKey(REMINDER_ARGUMENT))
mReminder = (LocationBasedReminder) getArguments().getSerializable(REMINDER_ARGUMENT);
else
Toast.makeText(getActivity(), getResources().getString(R.string.error_unexpected), Toast.LENGTH_SHORT).show();
mDao = new RemindyDAO(getActivity());
mPlaces = mDao.getPlaces();
// Set mReminder to the first place if empty
if (mReminder.getPlace() == null)
mReminder.setPlace(mPlaces.get(0));
for (Place p : mPlaces) mPlaceTypes.add(p.getAlias());
}
use of ve.com.abicelis.remindy.model.Place in project Remindy by abicelis.
the class RemindyDAO method getPlaces.
/**
* Returns a List of all the Places in the database.
*/
public List<Place> getPlaces() {
List<Place> places = new ArrayList<>();
SQLiteDatabase db = mDatabaseHelper.getReadableDatabase();
Cursor cursor = db.query(RemindyContract.PlaceTable.TABLE_NAME, null, null, null, null, null, null);
try {
while (cursor.moveToNext()) {
places.add(getPlaceFromCursor(cursor));
}
} finally {
cursor.close();
}
return places;
}
use of ve.com.abicelis.remindy.model.Place in project Remindy by abicelis.
the class GeofenceUtil method addGeofences.
/* GeoFence management methods */
public static void addGeofences(final Context context, GoogleApiClient googleApiClient) {
checkGoogleApiClient(googleApiClient);
List<Place> places = new RemindyDAO(context).getActivePlaces();
if (places.size() > 0) {
if (PackageManager.PERMISSION_GRANTED == ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION)) {
LocationServices.GeofencingApi.addGeofences(googleApiClient, getGeofencingRequest(places), getGeofencePendingIntent(context)).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
if (status.isSuccess())
Toast.makeText(context, "Geofences added/updated!", Toast.LENGTH_SHORT).show();
}
});
}
}
}
use of ve.com.abicelis.remindy.model.Place in project Remindy by abicelis.
the class RemindyDAO method getActivePlaces.
/**
* Returns a List of Places associated with PROGRAMMED tasks with location-based reminders
*/
public List<Place> getActivePlaces() {
List<Place> places = new ArrayList<>();
int taskCount;
Place place;
SQLiteDatabase db = mDatabaseHelper.getReadableDatabase();
Cursor cursor = db.query(RemindyContract.PlaceTable.TABLE_NAME, null, null, null, null, null, null);
try {
while (cursor.moveToNext()) {
place = getPlaceFromCursor(cursor);
try {
taskCount = getLocationBasedTasksAssociatedWithPlace(place.getId(), -1).size();
} catch (CouldNotGetDataException e) {
taskCount = 0;
}
if (taskCount > 0)
places.add(place);
}
} finally {
cursor.close();
}
return places;
}
Aggregations