refactor(ReceiverUtil): 重构
This commit is contained in:
parent
e4f4a357be
commit
4b1a2e084b
|
|
@ -44,8 +44,8 @@ import com.huanchengfly.tieba.post.ui.utils.isSeparating
|
|||
import com.huanchengfly.tieba.post.utils.AccountUtil
|
||||
import com.huanchengfly.tieba.post.utils.JobServiceUtil
|
||||
import com.huanchengfly.tieba.post.utils.PermissionUtils
|
||||
import com.huanchengfly.tieba.post.utils.ReceiverUtil
|
||||
import com.huanchengfly.tieba.post.utils.TiebaUtil
|
||||
import com.huanchengfly.tieba.post.utils.newIntentFilter
|
||||
import com.huanchengfly.tieba.post.utils.requestPermission
|
||||
import com.ramcosta.composedestinations.DestinationsNavHost
|
||||
import com.ramcosta.composedestinations.animations.defaults.RootNavGraphDefaultAnimations
|
||||
|
|
@ -137,7 +137,7 @@ class MainActivityV2 : BaseComposeActivity() {
|
|||
ContextCompat.registerReceiver(
|
||||
this,
|
||||
newMessageReceiver,
|
||||
ReceiverUtil.createIntentFilter(NotifyJobService.ACTION_NEW_MESSAGE),
|
||||
newIntentFilter(NotifyJobService.ACTION_NEW_MESSAGE),
|
||||
ContextCompat.RECEIVER_NOT_EXPORTED
|
||||
)
|
||||
startService(Intent(this, NotifyJobService::class.java))
|
||||
|
|
|
|||
|
|
@ -268,13 +268,13 @@ open class MainActivity : BaseActivity(), NavigationBarView.OnItemSelectedListen
|
|||
ContextCompat.registerReceiver(
|
||||
this,
|
||||
newMessageReceiver,
|
||||
ReceiverUtil.createIntentFilter(NotifyJobService.ACTION_NEW_MESSAGE),
|
||||
newIntentFilter(NotifyJobService.ACTION_NEW_MESSAGE),
|
||||
ContextCompat.RECEIVER_NOT_EXPORTED
|
||||
)
|
||||
ContextCompat.registerReceiver(
|
||||
this,
|
||||
accountSwitchReceiver,
|
||||
ReceiverUtil.createIntentFilter(AccountUtil.ACTION_SWITCH_ACCOUNT),
|
||||
newIntentFilter(AccountUtil.ACTION_SWITCH_ACCOUNT),
|
||||
ContextCompat.RECEIVER_NOT_EXPORTED
|
||||
)
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
package com.huanchengfly.tieba.post.utils;
|
||||
package com.huanchengfly.tieba.post.utils
|
||||
|
||||
import android.content.IntentFilter;
|
||||
import android.content.IntentFilter
|
||||
|
||||
public class ReceiverUtil {
|
||||
public static IntentFilter createIntentFilter(String action) {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(action);
|
||||
return filter;
|
||||
}
|
||||
fun newIntentFilter(action: String) =
|
||||
IntentFilter().apply {
|
||||
addAction(action)
|
||||
}
|
||||
Loading…
Reference in New Issue