Trying to fix a strange issue with the loading when hiding items..
This commit is contained in:
parent
9606d36670
commit
3db3157dc9
@ -36,11 +36,11 @@ android {
|
|||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
compileSdkVersion 28
|
compileSdkVersion 28
|
||||||
buildToolsVersion '28.0.1'
|
buildToolsVersion '28.0.2'
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "apps.amine.bou.readerforselfoss"
|
applicationId "apps.amine.bou.readerforselfoss"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 27
|
targetSdkVersion 28
|
||||||
versionCode versionCodeFromGit()
|
versionCode versionCodeFromGit()
|
||||||
versionName versionNameFromGit()
|
versionName versionNameFromGit()
|
||||||
|
|
||||||
@ -66,6 +66,7 @@ android {
|
|||||||
buildConfigField "String", "LOGIN_URL", appLoginUrl
|
buildConfigField "String", "LOGIN_URL", appLoginUrl
|
||||||
buildConfigField "String", "LOGIN_USERNAME", appLoginUsername
|
buildConfigField "String", "LOGIN_USERNAME", appLoginUsername
|
||||||
buildConfigField "String", "LOGIN_PASSWORD", appLoginPassword
|
buildConfigField "String", "LOGIN_PASSWORD", appLoginPassword
|
||||||
|
applicationIdSuffix ".dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flavorDimensions "build"
|
flavorDimensions "build"
|
||||||
@ -93,13 +94,13 @@ dependencies {
|
|||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
// Android Support
|
// Android Support
|
||||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
implementation "com.android.support:appcompat-v7:$android_version"
|
||||||
implementation 'com.android.support:design:27.1.1'
|
implementation "com.android.support:design:$android_version"
|
||||||
implementation 'com.android.support:recyclerview-v7:27.1.1'
|
implementation "com.android.support:recyclerview-v7:$android_version"
|
||||||
implementation 'com.android.support:support-v4:27.1.1'
|
implementation "com.android.support:support-v4:$android_version"
|
||||||
implementation 'com.android.support:support-vector-drawable:27.1.1'
|
implementation "com.android.support:support-vector-drawable:$android_version"
|
||||||
implementation 'com.android.support:customtabs:27.1.1'
|
implementation "com.android.support:customtabs:$android_version"
|
||||||
implementation 'com.android.support:cardview-v7:27.1.1'
|
implementation "com.android.support:cardview-v7:$android_version"
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
|
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
|
||||||
|
|
||||||
//multidex
|
//multidex
|
||||||
|
@ -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.drawer.CustomUrlPrimaryDrawerItem
|
||||||
import apps.amine.bou.readerforselfoss.utils.flattenTags
|
import apps.amine.bou.readerforselfoss.utils.flattenTags
|
||||||
import apps.amine.bou.readerforselfoss.utils.longHash
|
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.accountHeader
|
||||||
import co.zsmb.materialdrawerkt.builders.drawer
|
import co.zsmb.materialdrawerkt.builders.drawer
|
||||||
import co.zsmb.materialdrawerkt.builders.footer
|
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.PrimaryDrawerItem
|
||||||
import com.mikepenz.materialdrawer.model.SecondaryDrawerItem
|
import com.mikepenz.materialdrawer.model.SecondaryDrawerItem
|
||||||
import kotlinx.android.synthetic.main.activity_home.*
|
import kotlinx.android.synthetic.main.activity_home.*
|
||||||
import org.acra.ACRA
|
|
||||||
import retrofit2.Call
|
import retrofit2.Call
|
||||||
import retrofit2.Callback
|
import retrofit2.Callback
|
||||||
import retrofit2.Response
|
import retrofit2.Response
|
||||||
@ -177,13 +175,12 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
|||||||
alertDialog.setMessage(getString(R.string.gdpr_dialog_message))
|
alertDialog.setMessage(getString(R.string.gdpr_dialog_message))
|
||||||
alertDialog.setButton(
|
alertDialog.setButton(
|
||||||
AlertDialog.BUTTON_NEUTRAL,
|
AlertDialog.BUTTON_NEUTRAL,
|
||||||
"OK",
|
"OK"
|
||||||
{ dialog, _ ->
|
) { dialog, _ ->
|
||||||
sharedEditor.putBoolean("GDPR_shown", true)
|
sharedEditor.putBoolean("GDPR_shown", true)
|
||||||
sharedEditor.commit()
|
sharedEditor.commit()
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
)
|
|
||||||
alertDialog.show()
|
alertDialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,44 +239,22 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
|||||||
is ItemListAdapter -> adapter.removeItemAtIndex(position)
|
is ItemListAdapter -> adapter.removeItemAtIndex(position)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.size > 0) {
|
badgeNew--
|
||||||
badgeNew--
|
reloadBadgeContent()
|
||||||
reloadBadgeContent()
|
|
||||||
|
|
||||||
val tagHashes = i.tags.split(",").map { it.longHash() }
|
val tagHashes = i.tags.split(",").map { it.longHash() }
|
||||||
tagsBadge = tagsBadge.map {
|
tagsBadge = tagsBadge.map {
|
||||||
if (tagHashes.contains(it.key)) {
|
if (tagHashes.contains(it.key)) {
|
||||||
(it.key to (it.value - 1))
|
(it.key to (it.value - 1))
|
||||||
} else {
|
} else {
|
||||||
(it.key to it.value)
|
(it.key to it.value)
|
||||||
}
|
|
||||||
}.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(
|
}.toMap()
|
||||||
appendResults = true,
|
reloadTagsBadges()
|
||||||
offsetOverride = lastVisibleItem
|
|
||||||
)
|
// Just load everythin
|
||||||
|
if (items.size <= 0) {
|
||||||
|
getElementsAccordingToTab()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
@ -1012,11 +987,10 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
|||||||
fullHeightCards,
|
fullHeightCards,
|
||||||
appColors,
|
appColors,
|
||||||
debugReadingItems,
|
debugReadingItems,
|
||||||
userIdentifier,
|
userIdentifier
|
||||||
{
|
) {
|
||||||
updateItems(it)
|
updateItems(it)
|
||||||
}
|
}
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
recyclerAdapter =
|
recyclerAdapter =
|
||||||
ItemListAdapter(
|
ItemListAdapter(
|
||||||
@ -1029,11 +1003,10 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
|||||||
articleViewer,
|
articleViewer,
|
||||||
debugReadingItems,
|
debugReadingItems,
|
||||||
userIdentifier,
|
userIdentifier,
|
||||||
appColors,
|
appColors
|
||||||
{
|
) {
|
||||||
updateItems(it)
|
updateItems(it)
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
recyclerView.addItemDecoration(
|
recyclerView.addItemDecoration(
|
||||||
DividerItemDecoration(
|
DividerItemDecoration(
|
||||||
@ -1161,7 +1134,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
|||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.refresh -> {
|
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> {
|
api.update().enqueue(object : Callback<String> {
|
||||||
override fun onResponse(
|
override fun onResponse(
|
||||||
call: Call<String>,
|
call: Call<String>,
|
||||||
@ -1183,12 +1156,12 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
Toast.makeText(this, R.string.refresh_in_progress, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, R.string.refresh_in_progress, Toast.LENGTH_SHORT).show()
|
||||||
})
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
R.id.readAll -> {
|
R.id.readAll -> {
|
||||||
if (elementsShown == UNREAD_SHOWN) {
|
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
|
swipeRefreshLayout.isRefreshing = false
|
||||||
val ids = allItems.map { it.id }
|
val ids = allItems.map { it.id }
|
||||||
val itemsByTag: Map<Long, Int> =
|
val itemsByTag: Map<Long, Int> =
|
||||||
@ -1238,7 +1211,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
swipeRefreshLayout.isRefreshing = false
|
swipeRefreshLayout.isRefreshing = false
|
||||||
@ -1268,7 +1240,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
|||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
handleListResult()
|
handleListResult()
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.2.31'
|
ext {
|
||||||
|
kotlin_version = '1.2.31'
|
||||||
|
android_version = '27.1.1'
|
||||||
|
}
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
google()
|
google()
|
||||||
@ -10,7 +13,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
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"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user