-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up external receiver error handling
- Loading branch information
1 parent
e6f3230
commit 479e6d4
Showing
7 changed files
with
101 additions
and
99 deletions.
There are no files selected for viewing
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
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
10 changes: 5 additions & 5 deletions
10
app/src/main/java/com/orgzly/android/external/actionhandlers/RunSearch.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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
package com.orgzly.android.external.actionhandlers | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import com.orgzly.android.external.types.ExternalHandlerFailure | ||
import com.orgzly.android.external.types.Note | ||
import com.orgzly.android.query.user.InternalQueryParser | ||
import com.orgzly.android.external.types.* | ||
|
||
class RunSearch : ExternalAccessActionHandler() { | ||
override val actions = listOf( | ||
action(::runSearch, "SEARCH") | ||
) | ||
|
||
private fun runSearch(intent: Intent): Response { | ||
private fun runSearch(intent: Intent): List<Note> { | ||
val searchTerm = intent.getStringExtra("QUERY") | ||
if (searchTerm.isNullOrBlank()) return Response(false, "Invalid search term!") | ||
if (searchTerm.isNullOrBlank()) throw ExternalHandlerFailure("invalid search term") | ||
val query = InternalQueryParser().parse(searchTerm) | ||
val notes = dataRepository.selectNotesFromQuery(query) | ||
return Response(true, notes.map(Note::from).toTypedArray()) | ||
return notes.map(Note::from) | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
app/src/main/java/com/orgzly/android/external/types/ExternalHandlerFailure.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,3 @@ | ||
package com.orgzly.android.external.types | ||
|
||
class ExternalHandlerFailure(msg: String) : Exception(msg) |