Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/middleware/AsyncStopFavoriteAction.java
Show All 16 Lines | |||||
*/ | */ | ||||
package it.reyboz.bustorino.middleware; | package it.reyboz.bustorino.middleware; | ||||
import android.content.Context; | import android.content.Context; | ||||
import android.database.sqlite.SQLiteDatabase; | import android.database.sqlite.SQLiteDatabase; | ||||
import android.net.Uri; | import android.net.Uri; | ||||
import android.os.AsyncTask; | import android.os.AsyncTask; | ||||
import android.util.Log; | |||||
import android.widget.Toast; | import android.widget.Toast; | ||||
import it.reyboz.bustorino.R; | import it.reyboz.bustorino.R; | ||||
import it.reyboz.bustorino.backend.Stop; | import it.reyboz.bustorino.backend.Stop; | ||||
import it.reyboz.bustorino.data.AppDataProvider; | import it.reyboz.bustorino.data.AppDataProvider; | ||||
import it.reyboz.bustorino.data.UserDB; | import it.reyboz.bustorino.data.UserDB; | ||||
/** | /** | ||||
* Handler to add or remove or toggle a Stop in your favorites | * Handler to add or remove or toggle a Stop in your favorites | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | protected void onPostExecute(Boolean result) { | ||||
// now removed | // now removed | ||||
Toast.makeText(this.context, R.string.removed_from_favorites, Toast.LENGTH_SHORT).show(); | Toast.makeText(this.context, R.string.removed_from_favorites, Toast.LENGTH_SHORT).show(); | ||||
} | } | ||||
} else { | } else { | ||||
// wtf | // wtf | ||||
Toast.makeText(this.context, R.string.cant_add_to_favorites, Toast.LENGTH_SHORT).show(); | Toast.makeText(this.context, R.string.cant_add_to_favorites, Toast.LENGTH_SHORT).show(); | ||||
} | } | ||||
listener.doStuffWithResult(result); | listener.doStuffWithResult(result); | ||||
Log.d("BusTO FavoritesAction", "Action "+action+" completed"); | |||||
} | } | ||||
public interface ResultListener{ | public interface ResultListener{ | ||||
/** | /** | ||||
* Do what you need to to update the UI with the result | * Do what you need to to update the UI with the result | ||||
* @param result true if the action is done | * @param result true if the action is done | ||||
*/ | */ | ||||
void doStuffWithResult(Boolean result); | void doStuffWithResult(Boolean result); | ||||
} | } | ||||
} | } |
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