Search in sources :

Example 1 with CardTTSUtil

use of org.liberty.android.fantastischmemo.utils.CardTTSUtil in project AnyMemo by helloworld1.

the class CardPlayerService method onBind.

// Note, it is recommended for service binding in a thread different
// from UI thread. The initialization like DAO creation is quite heavy
@Override
public IBinder onBind(Intent intent) {
    handler = new Handler();
    Bundle extras = intent.getExtras();
    assert extras != null : "dbpath is not passed to AMTTSService.";
    dbPath = extras.getString(EXTRA_DBPATH);
    final int cardId = extras.getInt(EXTRA_CURRENT_CARD_ID);
    cardTTSUtil = new CardTTSUtil(appComponents().applicationContext(), dbPath);
    dbOpenHelper = AnyMemoDBOpenHelperManager.getHelper(this, dbPath);
    // Assign a value to the cardPlayerContext so we do not need to check
    // null for every player methods. The initial STOPPED state will help
    // skipToPrev/skipToNext method to callback the event handler.
    reset();
    cardPlayerContext.setCurrentCard(dbOpenHelper.getCardDao().queryForId(cardId));
    return binder;
}
Also used : Bundle(android.os.Bundle) CardPlayerEventHandler(org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerEventHandler) Handler(android.os.Handler) CardTTSUtil(org.liberty.android.fantastischmemo.utils.CardTTSUtil)

Aggregations

Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 CardPlayerEventHandler (org.liberty.android.fantastischmemo.service.cardplayer.CardPlayerEventHandler)1 CardTTSUtil (org.liberty.android.fantastischmemo.utils.CardTTSUtil)1