Search in sources :

Example 1 with Place

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();
}
Also used : Place(ve.com.abicelis.remindy.model.Place)

Example 2 with Place

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());
}
Also used : LocationBasedReminder(ve.com.abicelis.remindy.model.reminder.LocationBasedReminder) RemindyDAO(ve.com.abicelis.remindy.database.RemindyDAO) Place(ve.com.abicelis.remindy.model.Place)

Example 3 with Place

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;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) Place(ve.com.abicelis.remindy.model.Place)

Example 4 with Place

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();
                }
            });
        }
    }
}
Also used : Status(com.google.android.gms.common.api.Status) RemindyDAO(ve.com.abicelis.remindy.database.RemindyDAO) Place(ve.com.abicelis.remindy.model.Place)

Example 5 with Place

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;
}
Also used : CouldNotGetDataException(ve.com.abicelis.remindy.exception.CouldNotGetDataException) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) Place(ve.com.abicelis.remindy.model.Place)

Aggregations

Place (ve.com.abicelis.remindy.model.Place)7 RemindyDAO (ve.com.abicelis.remindy.database.RemindyDAO)3 Cursor (android.database.Cursor)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 Status (com.google.android.gms.common.api.Status)2 ArrayList (java.util.ArrayList)2 Location (android.location.Location)1 SeekBar (android.widget.SeekBar)1 GoogleApiClient (com.google.android.gms.common.api.GoogleApiClient)1 PlaceSelectionListener (com.google.android.gms.location.places.ui.PlaceSelectionListener)1 CouldNotGetDataException (ve.com.abicelis.remindy.exception.CouldNotGetDataException)1 PlaceNotFoundException (ve.com.abicelis.remindy.exception.PlaceNotFoundException)1 LocationBasedReminder (ve.com.abicelis.remindy.model.reminder.LocationBasedReminder)1