From 374537b5c7bd0f00a3783ffd4c911a4d83731f05 Mon Sep 17 00:00:00 2001 From: Amine Date: Sun, 14 Oct 2018 11:07:10 +0200 Subject: [PATCH] Preparing for room migrations. Some cleaning. --- app/build.gradle | 7 +++++++ .../java/apps/amine/bou/readerforselfoss/HomeActivity.kt | 8 +++++--- .../bou/readerforselfoss/api/selfoss/SelfossModels.kt | 8 ++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9ba9726..94449db 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -56,6 +56,13 @@ android { // tests testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + + javaCompileOptions { + annotationProcessorOptions { + arguments = ["room.schemaLocation": + "$projectDir/schemas".toString()] + } + } } buildTypes { release { diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt index 76590a0..0a2a408 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt @@ -45,6 +45,7 @@ import apps.amine.bou.readerforselfoss.utils.customtabs.CustomTabActivityHelper import apps.amine.bou.readerforselfoss.utils.drawer.CustomUrlPrimaryDrawerItem import apps.amine.bou.readerforselfoss.utils.flattenTags import apps.amine.bou.readerforselfoss.utils.longHash +import apps.amine.bou.readerforselfoss.utils.maybeHandleSilentException import apps.amine.bou.readerforselfoss.utils.persistence.toEntity import apps.amine.bou.readerforselfoss.utils.persistence.toView import co.zsmb.materialdrawerkt.builders.accountHeader @@ -68,6 +69,7 @@ import com.mikepenz.materialdrawer.model.PrimaryDrawerItem import com.mikepenz.materialdrawer.model.SecondaryDrawerItem import kotlinx.android.synthetic.main.activity_home.* import kotlinx.android.synthetic.main.fragment_article.* +import org.acra.ACRA import retrofit2.Call import retrofit2.Callback import retrofit2.Response @@ -153,7 +155,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { db = Room.databaseBuilder( applicationContext, - AppDatabase::class.java!!, "selfoss-database" + AppDatabase::class.java, "selfoss-database" ).build() @@ -817,7 +819,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { private fun handleInfiniteScroll() { recyclerViewScrollListener = object : RecyclerView.OnScrollListener() { override fun onScrolled(localRecycler: RecyclerView, dx: Int, dy: Int) { - if (localRecycler != null && dy > 0) { + if (dy > 0) { val manager = recyclerView.layoutManager val lastVisibleItem: Int = when (manager) { is StaggeredGridLayoutManager -> manager.findLastCompletelyVisibleItemPositions( @@ -1178,7 +1180,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { .toMap() fun readAllDebug(e: Throwable) { - // TODO: debug + ACRA.getErrorReporter().maybeHandleSilentException(e, this@HomeActivity) } if (ids.isNotEmpty()) { diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossModels.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossModels.kt index 1b69670..edb8935 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossModels.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossModels.kt @@ -9,13 +9,13 @@ import apps.amine.bou.readerforselfoss.utils.Config import apps.amine.bou.readerforselfoss.utils.isEmptyOrNullOrNullString import com.google.gson.annotations.SerializedName -private fun constructUrl(config: Config?, path: String, file: String): String { - val baseUriBuilder = Uri.parse(config!!.baseUrl).buildUpon() - baseUriBuilder.appendPath(path).appendPath(file) - +private fun constructUrl(config: Config?, path: String, file: String?): String { return if (file.isEmptyOrNullOrNullString()) { "" } else { + val baseUriBuilder = Uri.parse(config!!.baseUrl).buildUpon() + baseUriBuilder.appendPath(path).appendPath(file) + baseUriBuilder.toString() } }