fix crash in FiltersActivity (#1409)

This commit is contained in:
Konrad Pozniak 2019-07-25 12:17:52 +02:00 committed by GitHub
parent 51da2a15e8
commit ce84233c4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -85,9 +85,14 @@ class FiltersActivity: BaseActivity() {
private fun createFilter(phrase: String, wholeWord: Boolean) {
api.createFilter(phrase, listOf(context), false, wholeWord, "").enqueue(object: Callback<Filter> {
override fun onResponse(call: Call<Filter>, response: Response<Filter>) {
filters.add(response.body()!!)
refreshFilterDisplay()
eventHub.dispatch(PreferenceChangedEvent(context))
val filterResponse = response.body()
if(response.isSuccessful && filterResponse != null) {
filters.add(filterResponse)
refreshFilterDisplay()
eventHub.dispatch(PreferenceChangedEvent(context))
} else {
Toast.makeText(this@FiltersActivity, "Error creating filter '$phrase'", Toast.LENGTH_SHORT).show()
}
}
override fun onFailure(call: Call<Filter>, t: Throwable) {