Fixed bug

This commit is contained in:
Amine 2018-09-15 16:08:08 +02:00
parent 339d384561
commit 7fb54f14c7

View File

@ -3,6 +3,7 @@ package apps.amine.bou.readerforselfoss
import android.graphics.drawable.ColorDrawable import android.graphics.drawable.ColorDrawable
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.preference.PreferenceManager
import android.support.v4.app.FragmentManager import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentStatePagerAdapter import android.support.v4.app.FragmentStatePagerAdapter
import android.support.v4.content.ContextCompat import android.support.v4.content.ContextCompat
@ -63,6 +64,15 @@ class ReaderActivity : AppCompatActivity() {
supportActionBar?.setDisplayHomeAsUpEnabled(true) supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true) supportActionBar?.setDisplayShowHomeEnabled(true)
val prefs = PreferenceManager.getDefaultSharedPreferences(this)
api = SelfossApi(
this,
this@ReaderActivity,
prefs.getBoolean("isSelfSignedCert", false),
prefs.getBoolean("should_log_everything", false)
)
if (allItems.isEmpty()) { if (allItems.isEmpty()) {
finish() finish()
@ -77,12 +87,16 @@ class ReaderActivity : AppCompatActivity() {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
(pager.adapter as ScreenSlidePagerAdapter).notifyDataSetChanged() notifyAdapter()
pager.setPageTransformer(true, DepthPageTransformer()) pager.setPageTransformer(true, DepthPageTransformer())
(indicator as CircleIndicator).setViewPager(pager) (indicator as CircleIndicator).setViewPager(pager)
} }
private fun notifyAdapter() {
(pager.adapter as ScreenSlidePagerAdapter).notifyDataSetChanged()
}
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
if (markOnScroll) { if (markOnScroll) {
@ -142,6 +156,7 @@ class ReaderActivity : AppCompatActivity() {
response: Response<SuccessResponse> response: Response<SuccessResponse>
) { ) {
allItems[pager.currentItem] = allItems[pager.currentItem].toggleStar() allItems[pager.currentItem] = allItems[pager.currentItem].toggleStar()
notifyAdapter()
canRemoveFromFavorite() canRemoveFromFavorite()
} }
@ -165,6 +180,7 @@ class ReaderActivity : AppCompatActivity() {
response: Response<SuccessResponse> response: Response<SuccessResponse>
) { ) {
allItems[pager.currentItem] = allItems[pager.currentItem].toggleStar() allItems[pager.currentItem] = allItems[pager.currentItem].toggleStar()
notifyAdapter()
canFavorite() canFavorite()
} }