mirror of https://github.com/readrops/Readrops.git
Handle failed auto synchronizations
This commit is contained in:
parent
86c9f82f6d
commit
8eda0ce669
|
@ -4,6 +4,7 @@ import android.app.PendingIntent
|
||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.util.Log
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
import androidx.work.Worker
|
import androidx.work.Worker
|
||||||
|
@ -44,10 +45,13 @@ class SyncWorker(context: Context, parameters: WorkerParameters) : Worker(contex
|
||||||
val repository = ARepository.repositoryFactory(it, applicationContext)
|
val repository = ARepository.repositoryFactory(it, applicationContext)
|
||||||
|
|
||||||
disposable = repository.sync(null)
|
disposable = repository.sync(null)
|
||||||
.doOnError { result = Result.failure() }
|
.doOnError { throwable ->
|
||||||
|
result = Result.failure()
|
||||||
|
Log.e(TAG, throwable.message!!, throwable)
|
||||||
|
}
|
||||||
.subscribe()
|
.subscribe()
|
||||||
|
|
||||||
syncResults[it] = repository.syncResult
|
if (repository.syncResult != null) syncResults[it] = repository.syncResult
|
||||||
}
|
}
|
||||||
|
|
||||||
notificationManager.cancel(SYNC_NOTIFICATION_ID)
|
notificationManager.cancel(SYNC_NOTIFICATION_ID)
|
||||||
|
@ -106,7 +110,7 @@ class SyncWorker(context: Context, parameters: WorkerParameters) : Worker(contex
|
||||||
}
|
}
|
||||||
|
|
||||||
return NotificationCompat.Action.Builder(R.drawable.ic_read_later, applicationContext.getString(R.string.read_later),
|
return NotificationCompat.Action.Builder(R.drawable.ic_read_later, applicationContext.getString(R.string.read_later),
|
||||||
PendingIntent.getBroadcast(applicationContext, 0, broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT))
|
PendingIntent.getBroadcast(applicationContext, 0, broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT))
|
||||||
.setAllowGeneratedReplies(false)
|
.setAllowGeneratedReplies(false)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
@ -117,7 +121,7 @@ class SyncWorker(context: Context, parameters: WorkerParameters) : Worker(contex
|
||||||
}
|
}
|
||||||
|
|
||||||
return NotificationCompat.Action.Builder(R.drawable.ic_read, applicationContext.getString(R.string.read),
|
return NotificationCompat.Action.Builder(R.drawable.ic_read, applicationContext.getString(R.string.read),
|
||||||
PendingIntent.getBroadcast(applicationContext, 0, broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT))
|
PendingIntent.getBroadcast(applicationContext, 0, broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT))
|
||||||
.setAllowGeneratedReplies(false)
|
.setAllowGeneratedReplies(false)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue