修改资源名称和去掉无用代码
This commit is contained in:
@@ -4,14 +4,4 @@
|
||||
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name=".activity.PushMessageActivity"
|
||||
android:theme="@style/ModulePushMessageTheme">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,123 +0,0 @@
|
||||
package com.mogo.module.push.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.mogo.module.push.Config
|
||||
import com.mogo.module.push.R
|
||||
import com.mogo.module.push.adapter.PushMessageAdapter
|
||||
import com.mogo.module.push.model.PushBean
|
||||
import com.mogo.module.push.repository.PushRepository
|
||||
import com.mogo.module.push.utils.AnalyticsUtils
|
||||
import com.mogo.module.push.utils.HandlerUtils
|
||||
import com.mogo.module.push.utils.startClearAnimator
|
||||
import com.mogo.module.push.view.PushItemAnimator
|
||||
import com.mogo.module.push.view.SwipeItemLayout
|
||||
import com.mogo.module.push.view.getApis
|
||||
import com.mogo.module.push.viewmodel.MessageViewModel
|
||||
import com.mogo.service.intent.IMogoIntentListener
|
||||
import com.mogo.utils.UiThreadHandler
|
||||
import com.mogo.utils.logger.Logger
|
||||
import kotlinx.android.synthetic.main.module_push_message_activity.*
|
||||
|
||||
class PushMessageActivity : AppCompatActivity(), IMogoIntentListener {
|
||||
private lateinit var viewModel: MessageViewModel
|
||||
private var adapter = PushMessageAdapter()
|
||||
private var clearing = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
// window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
||||
setContentView(R.layout.module_push_message_activity)
|
||||
AnalyticsUtils.track(Config.NEWS_HISTORY_OPEN)
|
||||
module_push_activity_close.setOnClickListener {
|
||||
AnalyticsUtils.track(Config.NEWS_HISTORY_CLOSE)
|
||||
finish()
|
||||
}
|
||||
module_push_activity_clear.setOnClickListener {
|
||||
AnalyticsUtils.track(Config.NEWS_HISTORY_ALL_CLEAR)
|
||||
if (!clearing) {
|
||||
clearing = true
|
||||
startClearAnimator(module_push_activity_recycler_view) {
|
||||
viewModel.deleteAll()
|
||||
clearing = false
|
||||
}
|
||||
}
|
||||
}
|
||||
adapter.deletePushBean = object : PushMessageAdapter.PushAdapterListener {
|
||||
override fun lastItemShow(show: Boolean) {
|
||||
if (!show && !clearing) {
|
||||
val size = viewModel.list?.size ?: 0
|
||||
if (size > 0 && size < module_push_activity_recycler_view.childCount) {
|
||||
return
|
||||
}
|
||||
}
|
||||
module_push_activity_clear.visibility =
|
||||
if (show) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
override fun deleteBean(bean: PushBean, action: Boolean) {
|
||||
if (clearing) return
|
||||
viewModel.delete(bean)
|
||||
if (action) {
|
||||
AnalyticsUtils.track(Config.NEWS_HISTORY_ONE_CLICK, "title", bean.title)
|
||||
finish()
|
||||
} else {
|
||||
AnalyticsUtils.track(Config.NEWS_HISTORY_ONE_CLEAR, "title", bean.title)
|
||||
adapter.removeItem(bean)
|
||||
if (adapter.datas?.size ?: 0 == 0) {
|
||||
module_push_activity_not_data.visibility = View.VISIBLE
|
||||
}
|
||||
updateHistoryMessageCount()
|
||||
}
|
||||
}
|
||||
}
|
||||
module_push_activity_recycler_view.layoutManager = LinearLayoutManager(this)
|
||||
module_push_activity_recycler_view.adapter = adapter
|
||||
module_push_activity_recycler_view.itemAnimator = PushItemAnimator()
|
||||
module_push_activity_recycler_view.addOnItemTouchListener(
|
||||
SwipeItemLayout.OnSwipeItemTouchListener(this)
|
||||
)
|
||||
viewModel = MessageViewModel(object :
|
||||
MessageViewModel.MessageListChange {
|
||||
override fun messageListChange(list: MutableList<PushBean>?) {
|
||||
runOnUiThread {
|
||||
var size = list?.size ?: 0
|
||||
adapter.datas = list
|
||||
module_push_activity_not_data.visibility = if (size > 0) View.GONE else View.VISIBLE
|
||||
updateHistoryMessageCount()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
getApis(this).intentManagerApi.registerIntentListener(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this)
|
||||
}
|
||||
|
||||
private fun updateHistoryMessageCount(){
|
||||
HandlerUtils.mBgHandler.post{
|
||||
var count = PushRepository.pushRepository.pushBeanDao.getAllCount()
|
||||
UiThreadHandler.post {
|
||||
module_push_activity_title.text = if (count > 0) "历史消息(${count})" else "历史消息"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onIntentReceived(intentStr: String?, intent: Intent?) {
|
||||
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(intentStr)) {
|
||||
Logger.d("PushMessageActivity", "close by home key.")
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
getApis(this).intentManagerApi.unregisterIntentListener(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this)
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,8 @@ public
|
||||
*/
|
||||
class MessageHistoryFragment extends MvpFragment< MessageHistoryView, MessageHistoryPresenter > implements MessageHistoryView, IMogoMsgCenterListener {
|
||||
|
||||
private static final String TAG = "MessageHistoryFragment";
|
||||
|
||||
private View mClear;
|
||||
private RecyclerView mHistoryList;
|
||||
private TextView mTitle;
|
||||
@@ -55,11 +57,11 @@ class MessageHistoryFragment extends MvpFragment< MessageHistoryView, MessageHis
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
mClear = findViewById( R.id.module_push_activity_clear );
|
||||
mHistoryList = findViewById( R.id.module_push_activity_recycler_view );
|
||||
mTitle = findViewById( R.id.module_push_activity_title );
|
||||
mEmptyPlaceHolder = findViewById( R.id.module_push_activity_not_data );
|
||||
mClose = findViewById( R.id.module_push_activity_close );
|
||||
mClear = findViewById( R.id.module_push_id_clear );
|
||||
mHistoryList = findViewById( R.id.module_push_id_recycler_view );
|
||||
mTitle = findViewById( R.id.module_push_id_title );
|
||||
mEmptyPlaceHolder = findViewById( R.id.module_push_id_not_data );
|
||||
mClose = findViewById( R.id.module_push_id_close );
|
||||
|
||||
AnalyticsUtils.track( Config.NEWS_HISTORY_OPEN, null );
|
||||
mClose.setOnClickListener( view -> {
|
||||
@@ -74,7 +76,6 @@ class MessageHistoryFragment extends MvpFragment< MessageHistoryView, MessageHis
|
||||
() -> {
|
||||
mViewModel.deleteAll();
|
||||
mClearing = false;
|
||||
return null;
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -104,9 +105,11 @@ class MessageHistoryFragment extends MvpFragment< MessageHistoryView, MessageHis
|
||||
@Override
|
||||
public void lastItemShow( boolean show ) {
|
||||
if ( !show && !mClearing ) {
|
||||
int size = mViewModel.getList().size();
|
||||
if ( size > 0 && size < mHistoryList.getChildCount() ) {
|
||||
return;
|
||||
if ( mViewModel.getList() != null ) {
|
||||
int size = mViewModel.getList().size();
|
||||
if ( size > 0 && size < mHistoryList.getChildCount() ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
mClear.setVisibility( show ? View.VISIBLE : View.GONE );
|
||||
|
||||
@@ -4,8 +4,11 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.get
|
||||
import androidx.core.view.isNotEmpty
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
fun startClearAnimator(root: ViewGroup, method: () -> Unit) {
|
||||
val TAG: String = "AnimatorUtils.kt"
|
||||
|
||||
fun startClearAnimator(root: ViewGroup, runnable: Runnable) {
|
||||
if (root.isNotEmpty()) {
|
||||
var view: View
|
||||
var size = root.childCount - 1
|
||||
@@ -13,13 +16,19 @@ fun startClearAnimator(root: ViewGroup, method: () -> Unit) {
|
||||
view = root[i]
|
||||
view.animate().translationX(-view.width.toFloat()).apply {
|
||||
if (i == 0) {
|
||||
withEndAction(method)
|
||||
try {
|
||||
withEndAction(runnable)
|
||||
} catch (e: Exception) {
|
||||
Logger.e(TAG, e, "startClearAnimator->withEndAction")
|
||||
}
|
||||
}
|
||||
duration = 200
|
||||
startDelay = 100 * (size - i).toLong()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
method()
|
||||
runnable?.apply {
|
||||
run()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_activity_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="@dimen/module_push_activity_title_margin_top"
|
||||
android:text="历史消息(2)"
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="@dimen/module_push_activity_title_text_size" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_push_activity_close"
|
||||
android:layout_width="@dimen/module_push_margin_start"
|
||||
android:layout_height="@dimen/module_push_margin_start"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="@dimen/module_push_activity_close_margin_top"
|
||||
android:layout_marginEnd="@dimen/module_push_activity_close_margin_end"
|
||||
android:padding="@dimen/module_push_activity_close_padding"
|
||||
android:src="@drawable/module_push_close" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/module_push_activity_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/module_push_activity_recycler_view_margin_top"
|
||||
android:layout_marginEnd="@dimen/module_push_activity_close_margin_end" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_activity_not_data"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:text="暂无消息"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/module_push_activity_not_data_text_size" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_activity_clear"
|
||||
android:layout_width="@dimen/module_push_content_only_height"
|
||||
android:layout_height="@dimen/module_push_button_height"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:layout_marginBottom="@dimen/module_push_activity_clear_margin_bottom"
|
||||
android:background="@drawable/module_push_activity_clear_bg"
|
||||
android:gravity="center"
|
||||
android:text="清空历史消息"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/module_push_title_text_size"
|
||||
android:visibility="gone" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -9,11 +9,11 @@
|
||||
android:layout_marginLeft="@dimen/module_push_panel_marginRight"
|
||||
android:paddingLeft="@dimen/module_push_panel_paddingLeft"
|
||||
android:paddingRight="@dimen/module_push_panel_paddingLeft"
|
||||
android:background="@drawable/module_push_message_activity_background"
|
||||
android:background="@drawable/module_push_message_background"
|
||||
android:layout_gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_activity_title"
|
||||
android:id="@+id/module_push_id_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/module_push_activity_title_margin_top"
|
||||
@@ -22,7 +22,7 @@
|
||||
android:textSize="@dimen/module_push_activity_title_text_size" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_push_activity_close"
|
||||
android:id="@+id/module_push_id_close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
@@ -30,31 +30,31 @@
|
||||
android:src="@drawable/module_push_close" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/module_push_activity_recycler_view"
|
||||
android:id="@+id/module_push_id_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:overScrollMode="never"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/module_push_activity_recycler_view_margin_top" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_activity_not_data"
|
||||
android:id="@+id/module_push_id_not_data"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:text="暂无消息"
|
||||
android:text="@string/module_push_str_not_data"
|
||||
android:textColor="@color/module_push_panel_title_textColor"
|
||||
android:textSize="@dimen/module_push_activity_not_data_text_size" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_activity_clear"
|
||||
android:id="@+id/module_push_id_clear"
|
||||
android:layout_width="@dimen/module_push_content_only_height"
|
||||
android:layout_height="@dimen/module_push_button_height"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:layout_marginBottom="@dimen/module_push_activity_clear_margin_bottom"
|
||||
android:background="@drawable/module_push_activity_clear_bg"
|
||||
android:background="@drawable/module_push_clear_bg"
|
||||
android:gravity="center"
|
||||
android:text="清空历史消息"
|
||||
android:text="@string/module_push_str_clear"
|
||||
android:textColor="@color/module_push_panel_title_textColor"
|
||||
android:textSize="@dimen/module_push_title_text_size"
|
||||
android:visibility="gone"
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<resources>
|
||||
<string name="app_name">mogo-module-push</string>
|
||||
<string name="module_push_str_delete">清除</string>
|
||||
<string name="module_push_str_clear">清空历史消息</string>
|
||||
<string name="module_push_str_not_data">暂无消息</string>
|
||||
</resources>
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
<item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
|
||||
<item name="android:windowBackground">@drawable/module_push_message_activity_background</item>
|
||||
<item name="android:windowBackground">@drawable/module_push_message_background</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user