close #709
This commit is contained in:
parent
67b7b83795
commit
ea2b634b15
|
@ -53,6 +53,7 @@ import org.mariotaku.abstask.library.TaskStarter
|
|||
import org.mariotaku.chameleon.Chameleon
|
||||
import org.mariotaku.chameleon.ChameleonUtils
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.ktextension.setItemAvailability
|
||||
import org.mariotaku.ktextension.useCursor
|
||||
import org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
|
@ -203,6 +204,14 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
|
|||
inflater.inflate(R.menu.menu_messages_conversation_info, menu)
|
||||
}
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu) {
|
||||
if (adapter.conversation?.conversation_extras_type == ExtrasType.TWITTER_OFFICIAL) {
|
||||
menu.setItemAvailability(R.id.leave_conversation, true)
|
||||
} else {
|
||||
menu.setItemAvailability(R.id.leave_conversation, false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.leave_conversation -> {
|
||||
|
@ -210,9 +219,6 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
|
|||
df.show(childFragmentManager, "destroy_conversation_confirm")
|
||||
return true
|
||||
}
|
||||
R.id.delete_messages -> {
|
||||
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ class DestroyMessageTask(
|
|||
val account = AccountUtils.getAccountDetails(AccountManager.get(context), accountKey, true) ?:
|
||||
throw MicroBlogException("No account")
|
||||
val microBlog = account.newMicroBlogInstance(context, cls = MicroBlog::class.java)
|
||||
if (!performDestroyMessage(microBlog, account)) {
|
||||
if (!performDestroyMessage(context, microBlog, account, messageId)) {
|
||||
return false
|
||||
}
|
||||
val deleteWhere: String
|
||||
|
@ -66,7 +66,10 @@ class DestroyMessageTask(
|
|||
return true
|
||||
}
|
||||
|
||||
private fun performDestroyMessage(microBlog: MicroBlog, account: AccountDetails): Boolean {
|
||||
companion object {
|
||||
|
||||
private fun performDestroyMessage(context: Context, microBlog: MicroBlog,
|
||||
account: AccountDetails, messageId: String): Boolean {
|
||||
when (account.type) {
|
||||
AccountType.TWITTER -> {
|
||||
if (account.isOfficial(context)) {
|
||||
|
@ -78,5 +81,5 @@ class DestroyMessageTask(
|
|||
return true
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,4 @@
|
|||
android:id="@+id/leave_conversation"
|
||||
android:icon="@drawable/ic_action_delete"
|
||||
android:title="@string/action_leave_conversation"/>
|
||||
<item
|
||||
android:id="@+id/delete_messages"
|
||||
android:icon="@drawable/ic_action_delete"
|
||||
android:title="@string/action_delete_messages"/>
|
||||
</menu>
|
Loading…
Reference in New Issue