forked from Louvorg/ReaderForSelfoss-multiplatform
Repository should be DB ok.
This commit is contained in:
@ -11,6 +11,7 @@ import bou.amine.apps.readerforselfossv2.android.themes.AppColors
|
||||
import bou.amine.apps.readerforselfossv2.android.themes.Toppings
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.Config
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.isBaseUrlValid
|
||||
import bou.amine.apps.readerforselfossv2.model.NetworkUnavailableException
|
||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||
import com.ftinc.scoop.Scoop
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@ -109,33 +110,40 @@ class AddSourceActivity : AppCompatActivity(), DIAware {
|
||||
}
|
||||
|
||||
|
||||
fun handleSpoutFailure(networkIssue: Boolean = false) {
|
||||
Toast.makeText(
|
||||
this@AddSourceActivity,
|
||||
if (networkIssue) R.string.cant_get_spouts_no_network else R.string.cant_get_spouts,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
mProgress.visibility = View.GONE
|
||||
}
|
||||
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
val items = repository.getSpouts()
|
||||
if (items != null) {
|
||||
try {
|
||||
val items = repository.getSpouts()
|
||||
if (items != null) {
|
||||
val itemsStrings = items.map { it.value.name }
|
||||
for ((key, value) in items) {
|
||||
spoutsKV[value.name] = key
|
||||
}
|
||||
|
||||
val itemsStrings = items.map { it.value.name }
|
||||
for ((key, value) in items) {
|
||||
spoutsKV[value.name] = key
|
||||
mProgress.visibility = View.GONE
|
||||
formContainer.visibility = View.VISIBLE
|
||||
|
||||
val spinnerArrayAdapter =
|
||||
ArrayAdapter(
|
||||
this@AddSourceActivity,
|
||||
android.R.layout.simple_spinner_item,
|
||||
itemsStrings
|
||||
)
|
||||
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
spoutsSpinner.adapter = spinnerArrayAdapter
|
||||
} else {
|
||||
handleSpoutFailure()
|
||||
}
|
||||
|
||||
mProgress.visibility = View.GONE
|
||||
formContainer.visibility = View.VISIBLE
|
||||
|
||||
val spinnerArrayAdapter =
|
||||
ArrayAdapter(
|
||||
this@AddSourceActivity,
|
||||
android.R.layout.simple_spinner_item,
|
||||
itemsStrings
|
||||
)
|
||||
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
spoutsSpinner.adapter = spinnerArrayAdapter
|
||||
} else {
|
||||
Toast.makeText(
|
||||
this@AddSourceActivity,
|
||||
R.string.cant_get_spouts,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
mProgress.visibility = View.GONE
|
||||
} catch (e: NetworkUnavailableException) {
|
||||
handleSpoutFailure(networkIssue = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,10 +38,9 @@ import bou.amine.apps.readerforselfossv2.android.utils.bottombar.removeBadge
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.customtabs.CustomTabActivityHelper
|
||||
import bou.amine.apps.readerforselfossv2.dao.ACTION
|
||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||
import bou.amine.apps.readerforselfossv2.rest.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.utils.ItemType
|
||||
import bou.amine.apps.readerforselfossv2.utils.longHash
|
||||
import bou.amine.apps.readerforselfossv2.utils.toEntity
|
||||
import bou.amine.apps.readerforselfossv2.utils.toView
|
||||
import com.ashokvarma.bottomnavigation.BottomNavigationBar
|
||||
import com.ashokvarma.bottomnavigation.BottomNavigationItem
|
||||
@ -167,6 +166,16 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
||||
handleSettings()
|
||||
|
||||
getElementsAccordingToTab()
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO: items caching should be done in the background when starting the app, like background.kt does
|
||||
// fetchedItems?.let {
|
||||
// CoroutineScope(Dispatchers.Main).launch {
|
||||
// insertDBItems(it)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private fun handleSwipeRefreshLayout() {
|
||||
|
@ -16,7 +16,7 @@ import bou.amine.apps.readerforselfossv2.android.themes.AppColors
|
||||
import bou.amine.apps.readerforselfossv2.android.themes.Toppings
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.toggleStar
|
||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||
import bou.amine.apps.readerforselfossv2.rest.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import com.ftinc.scoop.Scoop
|
||||
import com.russhwolf.settings.Settings
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
@ -11,7 +11,7 @@ import bou.amine.apps.readerforselfossv2.android.databinding.ActivitySourcesBind
|
||||
import bou.amine.apps.readerforselfossv2.android.themes.AppColors
|
||||
import bou.amine.apps.readerforselfossv2.android.themes.Toppings
|
||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||
import bou.amine.apps.readerforselfossv2.rest.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import com.ftinc.scoop.Scoop
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -16,7 +16,7 @@ import bou.amine.apps.readerforselfossv2.android.utils.customtabs.CustomTabActiv
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.glide.bitmapCenterCrop
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.glide.circularBitmapDrawable
|
||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||
import bou.amine.apps.readerforselfossv2.rest.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import com.amulyakhare.textdrawable.TextDrawable
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator
|
||||
import com.bumptech.glide.Glide
|
||||
|
@ -13,7 +13,7 @@ import bou.amine.apps.readerforselfossv2.android.utils.customtabs.CustomTabActiv
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.glide.bitmapCenterCrop
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.glide.circularBitmapDrawable
|
||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||
import bou.amine.apps.readerforselfossv2.rest.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import com.amulyakhare.textdrawable.TextDrawable
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator
|
||||
import org.kodein.di.DI
|
||||
|
@ -8,7 +8,7 @@ import bou.amine.apps.readerforselfossv2.android.R
|
||||
import bou.amine.apps.readerforselfossv2.android.themes.AppColors
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.Config
|
||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||
import bou.amine.apps.readerforselfossv2.rest.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.utils.ItemType
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
@ -16,7 +16,7 @@ import bou.amine.apps.readerforselfossv2.android.utils.Config
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.glide.circularBitmapDrawable
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.toTextDrawableString
|
||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||
import bou.amine.apps.readerforselfossv2.rest.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import com.amulyakhare.textdrawable.TextDrawable
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
@ -18,7 +18,7 @@ import bou.amine.apps.readerforselfossv2.android.utils.Config
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.network.isNetworkAccessible
|
||||
import bou.amine.apps.readerforselfossv2.dao.ACTION
|
||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||
import bou.amine.apps.readerforselfossv2.rest.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.utils.ItemType
|
||||
import com.russhwolf.settings.Settings
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@ -82,10 +82,10 @@ override fun doWork(): Result {
|
||||
|
||||
launch {
|
||||
try {
|
||||
val newItems = repository.allItems(ItemType.UNREAD)
|
||||
val newItems = repository.getMaxItemsForBackground(ItemType.UNREAD)
|
||||
handleNewItemsNotification(newItems, notifyNewItems, notificationManager)
|
||||
repository.allItems(ItemType.ALL)
|
||||
repository.allItems(ItemType.STARRED)
|
||||
repository.getMaxItemsForBackground(ItemType.ALL)
|
||||
repository.getMaxItemsForBackground(ItemType.STARRED)
|
||||
} catch (e: Throwable) {}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ import bou.amine.apps.readerforselfossv2.android.utils.customtabs.CustomTabActiv
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.glide.getBitmapInputStream
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.glide.loadMaybeBasicAuth
|
||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||
import bou.amine.apps.readerforselfossv2.rest.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.utils.isEmptyOrNullOrNullString
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
|
@ -4,7 +4,7 @@ import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.text.Html
|
||||
import android.webkit.URLUtil
|
||||
import bou.amine.apps.readerforselfossv2.rest.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
|
@ -1,10 +1,8 @@
|
||||
package bou.amine.apps.readerforselfossv2.android.model
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.RequiresApi
|
||||
import bou.amine.apps.readerforselfossv2.rest.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
fun SelfossModel.Item.toParcelable() : ParecelableItem =
|
||||
|
@ -2,7 +2,7 @@ package bou.amine.apps.readerforselfossv2.android.utils
|
||||
|
||||
import android.content.Context
|
||||
import bou.amine.apps.readerforselfossv2.android.model.getSourceTitle
|
||||
import bou.amine.apps.readerforselfossv2.rest.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.utils.DateUtils
|
||||
import bou.amine.apps.readerforselfossv2.utils.parseRelativeDate
|
||||
|
||||
|
@ -20,7 +20,7 @@ import bou.amine.apps.readerforselfossv2.android.R
|
||||
import bou.amine.apps.readerforselfossv2.android.ReaderActivity
|
||||
import bou.amine.apps.readerforselfossv2.android.model.getLinkDecoded
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.customtabs.CustomTabActivityHelper
|
||||
import bou.amine.apps.readerforselfossv2.rest.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.utils.toStringUriWithHttp
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
|
||||
|
@ -168,4 +168,5 @@
|
||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||
<string name="remove_source">Remove source</string>
|
||||
<string name="cant_get_spouts_no_network">Can\'t get spouts list because of a network issue.</string>
|
||||
</resources>
|
||||
|
@ -168,4 +168,5 @@
|
||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||
<string name="remove_source">Remove source</string>
|
||||
<string name="cant_get_spouts_no_network">Can\'t get spouts list because of a network issue.</string>
|
||||
</resources>
|
||||
|
@ -168,4 +168,5 @@
|
||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||
<string name="remove_source">Remove source</string>
|
||||
<string name="cant_get_spouts_no_network">Can\'t get spouts list because of a network issue.</string>
|
||||
</resources>
|
||||
|
@ -168,4 +168,5 @@
|
||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||
<string name="remove_source">Remove source</string>
|
||||
<string name="cant_get_spouts_no_network">Can\'t get spouts list because of a network issue.</string>
|
||||
</resources>
|
||||
|
@ -168,4 +168,5 @@
|
||||
<string name="reader_static_bar_on">La barre sera affichée</string>
|
||||
<string name="reader_static_bar_off">La barre sera affichée grâce au bouton</string>
|
||||
<string name="remove_source">Supprimer la source</string>
|
||||
<string name="cant_get_spouts_no_network">Can\'t get spouts list because of a network issue.</string>
|
||||
</resources>
|
||||
|
@ -168,4 +168,5 @@
|
||||
<string name="reader_static_bar_on">A barra inferior mostrarase sempre</string>
|
||||
<string name="reader_static_bar_off">A barra inferior pode mostrarse a través do botón flotante</string>
|
||||
<string name="remove_source">Eliminar fonte</string>
|
||||
<string name="cant_get_spouts_no_network">Can\'t get spouts list because of a network issue.</string>
|
||||
</resources>
|
||||
|
@ -168,4 +168,5 @@
|
||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||
<string name="remove_source">Remove source</string>
|
||||
<string name="cant_get_spouts_no_network">Can\'t get spouts list because of a network issue.</string>
|
||||
</resources>
|
||||
|
@ -168,4 +168,5 @@
|
||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||
<string name="remove_source">Remove source</string>
|
||||
<string name="cant_get_spouts_no_network">Can\'t get spouts list because of a network issue.</string>
|
||||
</resources>
|
||||
|
@ -168,4 +168,5 @@
|
||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||
<string name="remove_source">Remove source</string>
|
||||
<string name="cant_get_spouts_no_network">Can\'t get spouts list because of a network issue.</string>
|
||||
</resources>
|
||||
|
@ -168,4 +168,5 @@
|
||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||
<string name="remove_source">Remove source</string>
|
||||
<string name="cant_get_spouts_no_network">Can\'t get spouts list because of a network issue.</string>
|
||||
</resources>
|
||||
|
@ -168,4 +168,5 @@
|
||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||
<string name="remove_source">Remove source</string>
|
||||
<string name="cant_get_spouts_no_network">Can\'t get spouts list because of a network issue.</string>
|
||||
</resources>
|
||||
|
@ -168,4 +168,5 @@
|
||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||
<string name="remove_source">Remove source</string>
|
||||
<string name="cant_get_spouts_no_network">Can\'t get spouts list because of a network issue.</string>
|
||||
</resources>
|
||||
|
@ -168,4 +168,5 @@
|
||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||
<string name="remove_source">Remove source</string>
|
||||
<string name="cant_get_spouts_no_network">Can\'t get spouts list because of a network issue.</string>
|
||||
</resources>
|
||||
|
@ -168,4 +168,5 @@
|
||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||
<string name="remove_source">Remove source</string>
|
||||
<string name="cant_get_spouts_no_network">Can\'t get spouts list because of a network issue.</string>
|
||||
</resources>
|
||||
|
@ -168,4 +168,5 @@
|
||||
<string name="reader_static_bar_on">底部栏将始终显示</string>
|
||||
<string name="reader_static_bar_off">底部栏可以通过浮动按钮显示</string>
|
||||
<string name="remove_source">删除源</string>
|
||||
<string name="cant_get_spouts_no_network">Can\'t get spouts list because of a network issue.</string>
|
||||
</resources>
|
||||
|
@ -168,4 +168,5 @@
|
||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||
<string name="remove_source">Remove source</string>
|
||||
<string name="cant_get_spouts_no_network">Can\'t get spouts list because of a network issue.</string>
|
||||
</resources>
|
||||
|
@ -39,7 +39,8 @@
|
||||
<string name="addStringNoUrl">"Log in to add sources."</string>
|
||||
<string name="cant_get_sources">"Can't get sources list."</string>
|
||||
<string name="cant_create_source">"Can't create source."</string>
|
||||
<string name="cant_get_spouts">"Can't get spouts list."</string>
|
||||
<string name="cant_get_spouts_no_network">"Can't get spouts list because of a network issue."</string>
|
||||
<string name="cant_get_spouts">"Can't get spouts list. There may ben an api issue."</string>
|
||||
<string name="form_not_complete">"The form is not complete"</string>
|
||||
<string name="pref_header_links">"Links"</string>
|
||||
<string name="issue_tracker_link">"Issue Tracker"</string>
|
||||
|
Reference in New Issue
Block a user