Commit d706e45b by zhangchengbo

fix:去除无用代码

parent 02bb4979
package com.secspace.sms.adapters
import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Color
import android.graphics.Typeface
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.util.Log
import android.util.Size
import android.util.TypedValue
import android.view.Menu
......@@ -30,23 +28,16 @@ import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.Target
import com.secspace.sms.R
import com.secspace.sms.activities.NewConversationActivity
import com.secspace.sms.activities.SimpleActivity
import com.secspace.sms.activities.ThreadActivity
import com.secspace.sms.databinding.*
import com.secspace.sms.dialogs.DeleteConfirmationDialog
import com.secspace.sms.dialogs.MessageDetailsDialog
import com.secspace.sms.dialogs.SelectTextDialog
import com.secspace.sms.extensions.*
import com.secspace.sms.helpers.*
import com.secspace.sms.models.Attachment
import com.secspace.sms.models.Message
import com.secspace.sms.models.ThreadItem
import com.simplemobiletools.commons.adapters.MyRecyclerViewListAdapter
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.views.MyRecyclerView
class ThreadAdapter(
......@@ -162,103 +153,6 @@ class ThreadAdapter(
}
}
private fun copyToClipboard() {
val firstItem = getSelectedItems().firstOrNull() as? Message ?: return
activity.copyToClipboard(firstItem.body)
}
private fun saveAs() {
val firstItem = getSelectedItems().firstOrNull() as? Message ?: return
val attachment = firstItem.attachment?.attachments?.first() ?: return
(activity as ThreadActivity).saveMMS(attachment.mimetype, attachment.uriString)
}
private fun shareText() {
val firstItem = getSelectedItems().firstOrNull() as? Message ?: return
activity.shareTextIntent(firstItem.body)
}
private fun selectText() {
val firstItem = getSelectedItems().firstOrNull() as? Message ?: return
if (firstItem.body.trim().isNotEmpty()) {
SelectTextDialog(activity, firstItem.body)
}
}
private fun showMessageDetails() {
val message = getSelectedItems().firstOrNull() as? Message ?: return
MessageDetailsDialog(activity, message)
}
private fun askConfirmDelete() {
val itemsCnt = selectedKeys.size
// not sure how we can get UnknownFormatConversionException here, so show the error and hope that someone reports it
val items = try {
resources.getQuantityString(R.plurals.delete_messages, itemsCnt, itemsCnt)
} catch (e: Exception) {
activity.showErrorToast(e)
return
}
val baseString = if (activity.config.useRecycleBin && !isRecycleBin) {
com.simplemobiletools.commons.R.string.move_to_recycle_bin_confirmation
} else {
com.simplemobiletools.commons.R.string.deletion_confirmation
}
val question = String.format(resources.getString(baseString), items)
DeleteConfirmationDialog(activity, question, activity.config.useRecycleBin && !isRecycleBin) { skipRecycleBin ->
ensureBackgroundThread {
val messagesToRemove = getSelectedItems()
if (messagesToRemove.isNotEmpty()) {
val toRecycleBin = !skipRecycleBin && activity.config.useRecycleBin && !isRecycleBin
deleteMessages(messagesToRemove.filterIsInstance<Message>(), toRecycleBin, false)
}
}
}
}
private fun askConfirmRestore() {
val itemsCnt = selectedKeys.size
// not sure how we can get UnknownFormatConversionException here, so show the error and hope that someone reports it
val items = try {
resources.getQuantityString(R.plurals.delete_messages, itemsCnt, itemsCnt)
} catch (e: Exception) {
activity.showErrorToast(e)
return
}
val baseString = R.string.restore_confirmation
val question = String.format(resources.getString(baseString), items)
ConfirmationDialog(activity, question) {
ensureBackgroundThread {
val messagesToRestore = getSelectedItems()
if (messagesToRestore.isNotEmpty()) {
deleteMessages(messagesToRestore.filterIsInstance<Message>(), false, true)
}
}
}
}
private fun forwardMessage() {
val message = getSelectedItems().firstOrNull() as? Message ?: return
val attachment = message.attachment?.attachments?.firstOrNull()
Intent(activity, NewConversationActivity::class.java).apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, message.body)
if (attachment != null) {
putExtra(Intent.EXTRA_STREAM, attachment.getUri())
}
activity.startActivity(this)
}
}
private fun getSelectedItems() = currentList.filter { selectedKeys.contains((it as? Message)?.hashCode() ?: 0) } as ArrayList<ThreadItem>
private fun isThreadDateTime(position: Int) = currentList.getOrNull(position) is ThreadItem.ThreadDateTime
......@@ -282,9 +176,9 @@ class ThreadAdapter(
false
}
/* setOnClickListener {
holder.viewClicked(message)
}*/
/* setOnClickListener {
holder.viewClicked(message)
}*/
}
if (message.isReceivedMessage()) {
......@@ -456,28 +350,6 @@ class ThreadAdapter(
}
}
/* private fun setupVCardView(holder: ViewHolder, parent: LinearLayout, message: Message, attachment: Attachment) {
val uri = attachment.getUri()
val vCardView = ItemAttachmentVcardBinding.inflate(layoutInflater).apply {
setupVCardPreview(
activity = activity,
uri = uri,
onClick = {
if (actModeCallback.isSelectable) {
holder.viewClicked(message)
} else {
val intent = Intent(activity, VCardViewerActivity::class.java).also {
it.putExtra(EXTRA_VCARD_URI, uri)
}
activity.startActivity(intent)
}
},
onLongClick = { holder.viewLongClicked() }
)
}.root
parent.addView(vCardView)
}*/
private fun setupFileView(holder: ViewHolder, parent: LinearLayout, message: Message, attachment: Attachment) {
val mimetype = attachment.mimetype
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment