pull/63/head
kunfei 5 years ago
parent fc12579eb0
commit 4aafb528e2
  1. 16
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt
  2. 6
      app/src/main/res/menu/rss_read.xml

@ -1,6 +1,7 @@
package io.legado.app.ui.rss.read
import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.view.KeyEvent
import android.view.Menu
@ -15,6 +16,7 @@ import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.utils.NetworkUtils
import io.legado.app.utils.getViewModel
import kotlinx.android.synthetic.main.activity_rss_read.*
import org.jetbrains.anko.toast
class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_read),
ReadRssViewModel.CallBack {
@ -42,6 +44,9 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.menu_rss_star -> viewModel.star()
R.id.menu_share_it -> viewModel.rssArticle?.let {
shareText("链接分享", it.link)
}
}
return super.onCompatOptionsItemSelected(item)
}
@ -115,4 +120,15 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
}
return super.onKeyUp(keyCode, event)
}
private fun shareText(title: String, text: String) {
try {
val textIntent = Intent(Intent.ACTION_SEND)
textIntent.type = "text/plain"
textIntent.putExtra(Intent.EXTRA_TEXT, text)
startActivity(Intent.createChooser(textIntent, title))
} catch (e: Exception) {
toast(R.string.can_not_share)
}
}
}

@ -8,4 +8,10 @@
android:icon="@drawable/ic_star_border"
app:showAsAction="always" />
<item
android:id="@+id/menu_share_it"
android:title="@string/share"
android:icon="@drawable/ic_menu_share"
app:showAsAction="ifRoom" />
</menu>
Loading…
Cancel
Save