Trying to fix a strange issue with the loading when hiding items..

This commit is contained in:
Amine 2018-09-09 19:44:01 +02:00
parent 9606d36670
commit 3db3157dc9
3 changed files with 47 additions and 71 deletions

View File

@ -36,11 +36,11 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 28
buildToolsVersion '28.0.1'
buildToolsVersion '28.0.2'
defaultConfig {
applicationId "apps.amine.bou.readerforselfoss"
minSdkVersion 16
targetSdkVersion 27
targetSdkVersion 28
versionCode versionCodeFromGit()
versionName versionNameFromGit()
@ -66,6 +66,7 @@ android {
buildConfigField "String", "LOGIN_URL", appLoginUrl
buildConfigField "String", "LOGIN_USERNAME", appLoginUsername
buildConfigField "String", "LOGIN_PASSWORD", appLoginPassword
applicationIdSuffix ".dev"
}
}
flavorDimensions "build"
@ -93,13 +94,13 @@ dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// Android Support
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation "com.android.support:appcompat-v7:$android_version"
implementation "com.android.support:design:$android_version"
implementation "com.android.support:recyclerview-v7:$android_version"
implementation "com.android.support:support-v4:$android_version"
implementation "com.android.support:support-vector-drawable:$android_version"
implementation "com.android.support:customtabs:$android_version"
implementation "com.android.support:cardview-v7:$android_version"
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
//multidex

View File

@ -42,7 +42,6 @@ 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 co.zsmb.materialdrawerkt.builders.accountHeader
import co.zsmb.materialdrawerkt.builders.drawer
import co.zsmb.materialdrawerkt.builders.footer
@ -66,7 +65,6 @@ import com.mikepenz.materialdrawer.model.DividerDrawerItem
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem
import com.mikepenz.materialdrawer.model.SecondaryDrawerItem
import kotlinx.android.synthetic.main.activity_home.*
import org.acra.ACRA
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
@ -177,13 +175,12 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
alertDialog.setMessage(getString(R.string.gdpr_dialog_message))
alertDialog.setButton(
AlertDialog.BUTTON_NEUTRAL,
"OK",
{ dialog, _ ->
"OK"
) { dialog, _ ->
sharedEditor.putBoolean("GDPR_shown", true)
sharedEditor.commit()
dialog.dismiss()
}
)
alertDialog.show()
}
@ -242,7 +239,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
is ItemListAdapter -> adapter.removeItemAtIndex(position)
}
if (items.size > 0) {
badgeNew--
reloadBadgeContent()
@ -255,31 +251,10 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
}
}.toMap()
reloadTagsBadges()
} else {
tabNewBadge.hide()
}
val manager = recyclerView.layoutManager
val lastVisibleItem: Int = when (manager) {
is StaggeredGridLayoutManager -> manager.findLastCompletelyVisibleItemPositions(
null
).last()
is GridLayoutManager -> manager.findLastCompletelyVisibleItemPosition()
else -> 0
}
Log.e("TAGTAG", "$lastVisibleItem === ${items.size} && ${items.size} <= ${maxItemNumber()} && ${!lastFetchDone}x")
if (lastVisibleItem === items.size &&
items.size <= maxItemNumber() &&
!lastFetchDone
) {
if (maxItemNumber() <= itemsNumber) {
lastFetchDone = true
}
getElementsAccordingToTab(
appendResults = true,
offsetOverride = lastVisibleItem
)
// Just load everythin
if (items.size <= 0) {
getElementsAccordingToTab()
}
} else {
Toast.makeText(
@ -1012,11 +987,10 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
fullHeightCards,
appColors,
debugReadingItems,
userIdentifier,
{
userIdentifier
) {
updateItems(it)
}
)
} else {
recyclerAdapter =
ItemListAdapter(
@ -1029,11 +1003,10 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
articleViewer,
debugReadingItems,
userIdentifier,
appColors,
{
appColors
) {
updateItems(it)
}
)
recyclerView.addItemDecoration(
DividerItemDecoration(
@ -1161,7 +1134,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.refresh -> {
needsConfirmation(R.string.menu_home_refresh, R.string.refresh_dialog_message, {
needsConfirmation(R.string.menu_home_refresh, R.string.refresh_dialog_message) {
api.update().enqueue(object : Callback<String> {
override fun onResponse(
call: Call<String>,
@ -1183,12 +1156,12 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
}
})
Toast.makeText(this, R.string.refresh_in_progress, Toast.LENGTH_SHORT).show()
})
}
return true
}
R.id.readAll -> {
if (elementsShown == UNREAD_SHOWN) {
needsConfirmation(R.string.readAll, R.string.markall_dialog_message, {
needsConfirmation(R.string.readAll, R.string.markall_dialog_message) {
swipeRefreshLayout.isRefreshing = false
val ids = allItems.map { it.id }
val itemsByTag: Map<Long, Int> =
@ -1238,7 +1211,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
)
)
}
}
swipeRefreshLayout.isRefreshing = false
@ -1268,7 +1240,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
).show()
}
handleListResult()
})
}
}
return true
}

View File

@ -1,7 +1,10 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.31'
ext {
kotlin_version = '1.2.31'
android_version = '27.1.1'
}
repositories {
jcenter()
google()
@ -10,7 +13,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.android.tools.build:gradle:3.1.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}