Added option to prevent updating sources and tags. (#332)
* Added option to prevent updating sources and tags. * Delete removed sources and tags from database.
This commit is contained in:
parent
e6b5ea4e67
commit
e62e04e13b
@ -102,6 +102,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||
private var infiniteScroll: Boolean = false
|
||||
private var lastFetchDone: Boolean = false
|
||||
private var itemsCaching: Boolean = false
|
||||
private var updateSources: Boolean = true
|
||||
private var hiddenTags: List<String> = emptyList()
|
||||
|
||||
private var periodicRefresh = false
|
||||
@ -426,6 +427,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||
displayAccountHeader = sharedPref.getBoolean("account_header_displaying", false)
|
||||
infiniteScroll = sharedPref.getBoolean("infinite_loading", false)
|
||||
itemsCaching = sharedPref.getBoolean("items_caching", false)
|
||||
updateSources = sharedPref.getBoolean("update_sources", true)
|
||||
hiddenTags = if (sharedPref.getString("hidden_tags", "")!!.isNotEmpty()) {
|
||||
sharedPref.getString("hidden_tags", "")!!.replace("\\s".toRegex(), "").split(",")
|
||||
} else {
|
||||
@ -728,6 +730,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||
if (maybeDrawerData.tags != null) {
|
||||
thread {
|
||||
val tagEntities = maybeDrawerData.tags.map { it.toEntity() }
|
||||
db.drawerDataDao().deleteAllTags()
|
||||
db.drawerDataDao().insertAllTags(*tagEntities.toTypedArray())
|
||||
}
|
||||
}
|
||||
@ -735,6 +738,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||
thread {
|
||||
val sourceEntities =
|
||||
maybeDrawerData.sources.map { it.toEntity() }
|
||||
db.drawerDataDao().deleteAllSources()
|
||||
db.drawerDataDao().insertAllSources(*sourceEntities.toTypedArray())
|
||||
}
|
||||
}
|
||||
@ -762,7 +766,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||
var sources: List<Source>?
|
||||
|
||||
fun sourcesApiCall() {
|
||||
if (this@HomeActivity.isNetworkAccessible(null, offlineShortcut)) {
|
||||
if (this@HomeActivity.isNetworkAccessible(null, offlineShortcut) && updateSources) {
|
||||
api.sources.enqueue(object : Callback<List<Source>> {
|
||||
override fun onResponse(
|
||||
call: Call<List<Source>>?,
|
||||
@ -785,7 +789,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||
}
|
||||
}
|
||||
|
||||
if (this@HomeActivity.isNetworkAccessible(null, offlineShortcut)) {
|
||||
if (this@HomeActivity.isNetworkAccessible(null, offlineShortcut) && updateSources) {
|
||||
api.tags.enqueue(object : Callback<List<Tag>> {
|
||||
override fun onResponse(
|
||||
call: Call<List<Tag>>,
|
||||
|
@ -140,6 +140,8 @@
|
||||
<string name="pref_switch_items_caching_off">Articles won\'t be saved to the device memory, and the app won\'t be usable offline.</string>
|
||||
<string name="pref_switch_items_caching_on">Articles will be saved to the device memory and will be used for offline use.</string>
|
||||
<string name="pref_switch_items_caching">Save items for offline use</string>
|
||||
<string name="pref_switch_update_sources">Check for new sources and tags</string>
|
||||
<string name="pref_switch_update_sources_summary">Disable this if your server is receiving excessive amounts of database queries.</string>
|
||||
<string name="no_network_connectivity">Not connected !</string>
|
||||
<string name="pref_switch_periodic_refresh">Sync articles</string>
|
||||
<string name="pref_switch_periodic_refresh_off">Articles will not be synced in the background</string>
|
||||
|
@ -34,4 +34,10 @@
|
||||
android:key="notify_new_items"
|
||||
android:dependency="periodic_refresh"
|
||||
android:title="@string/pref_switch_notify_new_items" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="update_sources"
|
||||
android:summary="@string/pref_switch_update_sources_summary"
|
||||
android:title="@string/pref_switch_update_sources" />
|
||||
</PreferenceScreen>
|
||||
|
Loading…
Reference in New Issue
Block a user