Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync manager: write transaction exceptions #3938

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into sync-investigation
Okuro3499 committed Nov 20, 2024
commit f8796adadf5b1c64a476be6da865441fef5ab7b8
34 changes: 6 additions & 28 deletions app/src/main/java/org/ole/planet/myplanet/ui/sync/SyncActivity.kt
Original file line number Diff line number Diff line change
@@ -184,35 +184,13 @@ abstract class SyncActivity : ProcessUserDataActivity(), SyncListener, CheckVers
}
}

@Throws(Exception::class)
fun isServerReachable(processedUrl: String?): Boolean {
suspend fun isServerReachable(processedUrl: String?): Boolean {
Log.d("SyncActivity", "isServerReachable")
customProgressDialog?.setText(getString(R.string.connecting_to_server))
customProgressDialog?.show()
val apiInterface = client?.create(ApiInterface::class.java)
apiInterface?.isPlanetAvailable("$processedUrl/_all_dbs")?.enqueue(object : Callback<ResponseBody?> {
override fun onResponse(call: Call<ResponseBody?>, response: Response<ResponseBody?>) {
try {
Log.d("SyncActivity", "isServerReachable onResponse")
customProgressDialog?.dismiss()
val ss = response.body()?.string()
val myList = ss?.split(",".toRegex())?.dropLastWhile { it.isEmpty() }?.let { listOf(*it.toTypedArray()) }
if ((myList?.size ?: 0) < 8) {
alertDialogOkay(getString(R.string.check_the_server_address_again_what_i_connected_to_wasn_t_the_planet_server))
} else {
startSync()
}
} catch (e: Exception) {
e.printStackTrace()
syncFailed = true
if (extractProtocol("$processedUrl") == context.getString(R.string.http_protocol)) {
alertDialogOkay(getString(R.string.device_couldn_t_reach_local_server))
} else if (extractProtocol("$processedUrl") == context.getString(R.string.https_protocol)) {
alertDialogOkay(getString(R.string.device_couldn_t_reach_nation_server))
}
customProgressDialog?.dismiss()
}
}
return withContext(Dispatchers.IO) {
val apiInterface = client?.create(ApiInterface::class.java)
try {
Log.d("SyncActivity", "isServerReachable onResponse")
val response = apiInterface?.isPlanetAvailable("$processedUrl/_all_dbs")?.execute()

when {
response?.isSuccessful == true -> {
You are viewing a condensed version of this merge commit. You can view the full changes here.