-
-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Insertion and Deletion of Event triggers on a background thread
- need to have regular lookups to remove deleted event trigger files from storage. Signed-off-by: Arka Prava Basu <[email protected]>
- Loading branch information
Showing
5 changed files
with
60 additions
and
54 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/main/java/org/havenapp/main/database/async/EventTriggerDeleteAsync.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.havenapp.main.database.async | ||
|
||
import android.os.AsyncTask | ||
import org.havenapp.main.HavenApp | ||
import org.havenapp.main.model.EventTrigger | ||
|
||
/** | ||
* Created by Arka Prava Basu <[email protected]> on 8/9/18. | ||
*/ | ||
class EventTriggerDeleteAsync(private val callback: DeleteCallback) | ||
: AsyncTask<EventTrigger, Unit, Unit>() { | ||
override fun doInBackground(vararg params: EventTrigger) { | ||
HavenApp.dataBaseInstance.getEventTriggerDAO().delete(params.get(0)) | ||
// todo delete file here? | ||
} | ||
|
||
override fun onPostExecute(result: Unit?) { | ||
callback.onEventTriggerDeleted() | ||
} | ||
|
||
interface DeleteCallback { | ||
fun onEventTriggerDeleted() | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/org/havenapp/main/database/async/EventTriggerInsertAsync.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.havenapp.main.database.async | ||
|
||
import android.os.AsyncTask | ||
import org.havenapp.main.HavenApp | ||
import org.havenapp.main.model.EventTrigger | ||
|
||
/** | ||
* Created by Arka Prava Basu <[email protected]> on 8/9/18. | ||
*/ | ||
class EventTriggerInsertAsync(private val callback: InsertCallback) | ||
: AsyncTask<EventTrigger, Unit, Long>() { | ||
override fun doInBackground(vararg params: EventTrigger): Long { | ||
return HavenApp.dataBaseInstance.getEventTriggerDAO().insert(params.get(0)) | ||
} | ||
|
||
override fun onPostExecute(result: Long) { | ||
callback.onEventTriggerInserted(result) | ||
} | ||
|
||
interface InsertCallback { | ||
fun onEventTriggerInserted(eventTriggerId: Long) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters