pull/37/head
kunfei 5 years ago
parent 278cc0f5f5
commit e1f0afc692
  1. 3
      app/src/main/java/io/legado/app/data/dao/RssArticleDao.kt
  2. 21
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt
  3. 6
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt

@ -18,4 +18,7 @@ interface RssArticleDao {
@Update @Update
fun update(vararg rssArticle: RssArticle) fun update(vararg rssArticle: RssArticle)
@Query("delete from rssArticles where origin = :origin")
fun delete(origin: String)
} }

@ -1,6 +1,8 @@
package io.legado.app.ui.rss.article package io.legado.app.ui.rss.article
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
@ -38,6 +40,25 @@ class RssArticlesActivity : VMBaseActivity<RssArticlesViewModel>(R.layout.activi
} }
} }
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.rss_articles, menu)
return super.onCompatCreateOptionsMenu(menu)
}
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.menu_clear -> {
intent.getStringExtra("url")?.let {
refresh_progress_bar.isAutoLoading = true
viewModel.loadContent(it) {
refresh_progress_bar.isAutoLoading = false
}
}
}
}
return super.onCompatOptionsItemSelected(item)
}
private fun initView() { private fun initView() {
ATH.applyEdgeEffectColor(recycler_view) ATH.applyEdgeEffectColor(recycler_view)
recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.layoutManager = LinearLayoutManager(this)

@ -42,4 +42,10 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application
} }
} }
fun clear(url: String, onFinally: () -> Unit) {
execute {
App.db.rssArtivleDao().delete(url)
loadContent(url, onFinally)
}
}
} }
Loading…
Cancel
Save