adding a helper function for refreshing the messages
This commit is contained in:
parent
049b8f9877
commit
251eca8823
|
@ -8,9 +8,8 @@ import com.simplemobiletools.commons.extensions.launchPurchaseThankYouIntent
|
|||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.smsmessenger.R
|
||||
import com.simplemobiletools.smsmessenger.extensions.config
|
||||
import com.simplemobiletools.smsmessenger.models.Events
|
||||
import com.simplemobiletools.smsmessenger.helpers.refreshMessages
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.util.*
|
||||
|
||||
class SettingsActivity : SimpleActivity() {
|
||||
|
@ -56,7 +55,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
private fun setupChangeDateTimeFormat() {
|
||||
settings_change_date_time_format_holder.setOnClickListener {
|
||||
ChangeDateTimeFormatDialog(this) {
|
||||
EventBus.getDefault().post(Events.RefreshMessages())
|
||||
refreshMessages()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,10 +14,9 @@ import com.simplemobiletools.commons.views.MyRecyclerView
|
|||
import com.simplemobiletools.smsmessenger.R
|
||||
import com.simplemobiletools.smsmessenger.activities.SimpleActivity
|
||||
import com.simplemobiletools.smsmessenger.extensions.deleteThread
|
||||
import com.simplemobiletools.smsmessenger.models.Events
|
||||
import com.simplemobiletools.smsmessenger.helpers.refreshMessages
|
||||
import com.simplemobiletools.smsmessenger.models.Message
|
||||
import kotlinx.android.synthetic.main.item_message.view.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
class MessagesAdapter(
|
||||
activity: SimpleActivity, var messages: ArrayList<Message>,
|
||||
|
@ -97,7 +96,7 @@ class MessagesAdapter(
|
|||
|
||||
activity.runOnUiThread {
|
||||
if (messagesToRemove.isEmpty()) {
|
||||
EventBus.getDefault().post(Events.RefreshMessages())
|
||||
refreshMessages()
|
||||
finishActMode()
|
||||
} else {
|
||||
removeSelectedItems(positions)
|
||||
|
|
|
@ -12,14 +12,13 @@ import com.simplemobiletools.commons.views.MyRecyclerView
|
|||
import com.simplemobiletools.smsmessenger.R
|
||||
import com.simplemobiletools.smsmessenger.activities.SimpleActivity
|
||||
import com.simplemobiletools.smsmessenger.extensions.deleteMessage
|
||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_DATE_TIME
|
||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_RECEIVED_MESSAGE
|
||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_SENT_MESSAGE
|
||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_SENT_MESSAGE_ERROR
|
||||
import com.simplemobiletools.smsmessenger.models.*
|
||||
import com.simplemobiletools.smsmessenger.helpers.*
|
||||
import com.simplemobiletools.smsmessenger.models.Message
|
||||
import com.simplemobiletools.smsmessenger.models.ThreadDateTime
|
||||
import com.simplemobiletools.smsmessenger.models.ThreadError
|
||||
import com.simplemobiletools.smsmessenger.models.ThreadItem
|
||||
import kotlinx.android.synthetic.main.item_received_message.view.*
|
||||
import kotlinx.android.synthetic.main.item_thread_date_time.view.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
class ThreadAdapter(
|
||||
activity: SimpleActivity, var messages: ArrayList<ThreadItem>,
|
||||
|
@ -125,7 +124,7 @@ class ThreadAdapter(
|
|||
} else {
|
||||
removeSelectedItems(positions)
|
||||
}
|
||||
EventBus.getDefault().post(Events.RefreshMessages())
|
||||
refreshMessages()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.simplemobiletools.smsmessenger.helpers
|
||||
|
||||
import com.simplemobiletools.smsmessenger.models.Events
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
const val THREAD_ID = "thread_id"
|
||||
const val THREAD_NAME = "thread_name"
|
||||
const val THREAD_NUMBER = "thread_number"
|
||||
|
@ -9,3 +12,7 @@ const val THREAD_DATE_TIME = 1
|
|||
const val THREAD_RECEIVED_MESSAGE = 2
|
||||
const val THREAD_SENT_MESSAGE = 3
|
||||
const val THREAD_SENT_MESSAGE_ERROR = 4
|
||||
|
||||
fun refreshMessages() {
|
||||
EventBus.getDefault().post(Events.RefreshMessages())
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@ import com.simplemobiletools.smsmessenger.extensions.insertNewSMS
|
|||
import com.simplemobiletools.smsmessenger.helpers.THREAD_ID
|
||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_NAME
|
||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_NUMBER
|
||||
import com.simplemobiletools.smsmessenger.models.Events
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import com.simplemobiletools.smsmessenger.helpers.refreshMessages
|
||||
|
||||
class SmsReceiver : BroadcastReceiver() {
|
||||
@SuppressLint("NewApi")
|
||||
|
@ -49,7 +48,7 @@ class SmsReceiver : BroadcastReceiver() {
|
|||
showNotification(context, address, body, threadID.toInt())
|
||||
}
|
||||
|
||||
EventBus.getDefault().post(Events.RefreshMessages())
|
||||
refreshMessages()
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
|
|
Loading…
Reference in New Issue