[2.13.0-merge]yakun and code style
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
package com.mogo.eagle.core.function.notice;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.function.notice.fragment.MessageHistoryFragment;
|
||||
import com.mogo.service.fragmentmanager.IFragmentProvider;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/9/1
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = PushUIConstants.Push_MESSAGE_ACTIVITY_PATH )
|
||||
class PushHistoryUiProvider implements IFragmentProvider {
|
||||
|
||||
@Override
|
||||
public Fragment createFragment( FragmentActivity activity, int containerId, Bundle date ) {
|
||||
Fragment fragment = new MessageHistoryFragment();
|
||||
activity.getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace( containerId, fragment, PushUIConstants.Push_MESSAGE_ACTIVITY_PATH )
|
||||
.show( fragment )
|
||||
.commitNowAllowingStateLoss();
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.mogo.eagle.core.function.notice;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.function.notice.repository.PushRepository;
|
||||
import com.mogo.eagle.core.function.notice.utils.HandlerUtils;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
|
||||
|
||||
@Route(path = PushUIConstants.PATH)
|
||||
public class PushModuleProvider implements IMogoModuleProvider {
|
||||
@Override
|
||||
public Fragment createFragment(Context context, Bundle data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(Context context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getModuleName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getAppPackage() {
|
||||
return " ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppName() {
|
||||
return " ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final Context context) {
|
||||
HandlerUtils.INSTANCE.getMBgHandler().post(() -> PushRepository.Companion.init(context));
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.mogo.eagle.core.function.notice;
|
||||
|
||||
public class PushUIConstants {
|
||||
public static final String NAME = "PUSH_UI";
|
||||
public static final String PATH = "/push/ui";
|
||||
public static final String Push_MESSAGE_ACTIVITY_PATH = "/push/ui/message"; //消息列表activity
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
package com.mogo.eagle.core.function.notice.adapter
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.eagle.core.function.notice.R
|
||||
import com.mogo.eagle.core.function.notice.model.PushBean
|
||||
import com.mogo.eagle.core.function.notice.utils.dealSchema
|
||||
import com.mogo.eagle.core.function.notice.utils.stringConverterBitmap
|
||||
import com.mogo.eagle.core.function.notice.view.getApis
|
||||
import com.mogo.service.imageloader.MogoImageView
|
||||
import kotlin.math.abs
|
||||
|
||||
class PushMessageAdapter : RecyclerView.Adapter<PushMessageAdapter.MessageViewHolder>() {
|
||||
interface PushAdapterListener {
|
||||
fun deleteBean(bean: PushBean, action: Boolean)
|
||||
|
||||
fun lastItemShow(show: Boolean)
|
||||
}
|
||||
|
||||
var onAttachStateChangeListener = object : View.OnAttachStateChangeListener {
|
||||
override fun onViewDetachedFromWindow(p0: View?) {
|
||||
deletePushBean.lastItemShow(false)
|
||||
}
|
||||
|
||||
override fun onViewAttachedToWindow(p0: View?) {
|
||||
deletePushBean.lastItemShow(true)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lateinit var deletePushBean: PushAdapterListener
|
||||
|
||||
var datas: MutableList<PushBean>? = null
|
||||
set(value) {
|
||||
field = value
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun removeItem(bean: PushBean) {
|
||||
datas?.let {
|
||||
val position = it.indexOf(bean)
|
||||
if (position >= 0) {
|
||||
it.removeAt(position)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
if (itemCount == 0) {
|
||||
deletePushBean.lastItemShow(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MessageViewHolder {
|
||||
return MessageViewHolder(
|
||||
LayoutInflater.from(parent.context).inflate(
|
||||
R.layout.module_push_message_item,
|
||||
null
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return datas?.size ?: 0
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: MessageViewHolder, position: Int) {
|
||||
holder.setPushBean(datas!![position], position)
|
||||
}
|
||||
|
||||
|
||||
inner class MessageViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
private val pushAppIcon: MogoImageView = view.findViewById(R.id.module_push_item_app_icon)
|
||||
private val pushTitle: TextView = view.findViewById(R.id.module_push_item_title)
|
||||
private val pushContent: TextView = view.findViewById(R.id.module_push_item_content)
|
||||
private val pushImage: MogoImageView = view.findViewById(R.id.module_push_item_image)
|
||||
private val pushTimer: TextView = view.findViewById(R.id.module_push_item_time)
|
||||
private val pushDelete: TextView = view.findViewById(R.id.module_push_item_delete)
|
||||
private val pushClick: View = view.findViewById(R.id.module_push_item_click)
|
||||
|
||||
fun setPushBean(bean: PushBean, position: Int) {
|
||||
if (position == (datas?.size ?: 0) - 1) {
|
||||
itemView.addOnAttachStateChangeListener(onAttachStateChangeListener)
|
||||
} else {
|
||||
itemView.removeOnAttachStateChangeListener(onAttachStateChangeListener)
|
||||
}
|
||||
pushDelete.setOnClickListener {
|
||||
deletePushBean.deleteBean(bean, false)
|
||||
}
|
||||
if (bean.mainSchema.isNotEmpty()) {
|
||||
pushClick.setOnClickListener {
|
||||
dealSchema(bean.mainSchema, itemView.context)
|
||||
deletePushBean.deleteBean(bean, true)
|
||||
}
|
||||
} else {
|
||||
pushClick.setOnClickListener(null)
|
||||
}
|
||||
// getApis(itemView.context).imageLoaderApi.displayImage(bean.appIcon, pushAppIcon)
|
||||
pushTitle.text = bean.title
|
||||
pushContent.text = bean.content
|
||||
pushContent.visibility = if (bean.content.isEmpty()) View.GONE else View.VISIBLE
|
||||
if (bean.QRCode.isEmpty() && bean.imageUrl.isNotEmpty()) {
|
||||
getApis(itemView.context).imageLoaderApi.displayImage(bean.imageUrl, pushImage)
|
||||
}
|
||||
if (bean.QRCode.isNotEmpty()) {
|
||||
pushImage.setImageBitmap(
|
||||
stringConverterBitmap(
|
||||
bean.QRCode,
|
||||
pushImage.context.resources.getDimensionPixelSize(R.dimen.module_push_message_item_image_size),
|
||||
pushImage.context.resources.getDimensionPixelSize(R.dimen.module_push_message_item_image_size)
|
||||
)
|
||||
)
|
||||
}
|
||||
val diff = abs((System.currentTimeMillis() - bean.timestamp) / 1000).toInt()
|
||||
pushTimer.text = when {
|
||||
diff == 0 -> "现在"
|
||||
diff < 60 -> "${diff}秒前"
|
||||
diff < 60 * 60 -> "${diff / 60}分钟前"
|
||||
diff < 60 * 60 * 24 -> "${diff / 60 / 60}小时前"
|
||||
else -> "${diff / 60 / 60 / 24}天前"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,181 +0,0 @@
|
||||
package com.mogo.eagle.core.function.notice.fragment;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.eagle.core.function.notice.R;
|
||||
import com.mogo.eagle.core.function.notice.adapter.PushMessageAdapter;
|
||||
import com.mogo.eagle.core.function.notice.model.PushBean;
|
||||
import com.mogo.eagle.core.function.notice.repository.PushRepository;
|
||||
import com.mogo.eagle.core.function.notice.utils.AnimatorUtilsKt;
|
||||
import com.mogo.eagle.core.function.notice.utils.HandlerUtils;
|
||||
import com.mogo.eagle.core.function.notice.view.PushItemAnimator;
|
||||
import com.mogo.eagle.core.function.notice.view.SwipeItemLayout;
|
||||
import com.mogo.eagle.core.function.notice.viewmodel.MessageViewModel;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.module.common.view.OnPreventFastClickListener;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/9/1
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
public class MessageHistoryFragment extends MvpFragment< MessageHistoryView, MessageHistoryPresenter > implements MessageHistoryView {
|
||||
|
||||
private static final String TAG = "MessageHistoryFragment";
|
||||
|
||||
private View mClear;
|
||||
private RecyclerView mHistoryList;
|
||||
private TextView mTitle;
|
||||
private View mEmptyPlaceHolder;
|
||||
private View mClose;
|
||||
|
||||
private boolean mClearing = false;
|
||||
private PushMessageAdapter mAdapter = new PushMessageAdapter();
|
||||
private MessageViewModel mViewModel;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_push_message_hisotry_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTagName() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
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 );
|
||||
|
||||
mClose.setOnClickListener( new OnPreventFastClickListener() {
|
||||
@Override
|
||||
public void onClickImpl( View v ) {
|
||||
exitSelf();
|
||||
}
|
||||
} );
|
||||
mClear.setOnClickListener( new OnPreventFastClickListener() {
|
||||
@Override
|
||||
public void onClickImpl( View v ) {
|
||||
if ( !mClearing ) {
|
||||
mClearing = true;
|
||||
AnimatorUtilsKt.startClearAnimator(
|
||||
mHistoryList,
|
||||
() -> {
|
||||
mViewModel.deleteAll();
|
||||
mClearing = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
} );
|
||||
mAdapter.deletePushBean = new PushMessageAdapter.PushAdapterListener() {
|
||||
@Override
|
||||
public void deleteBean( @NotNull PushBean bean, boolean action ) {
|
||||
if ( mClearing ) {
|
||||
return;
|
||||
}
|
||||
mViewModel.delete( bean );
|
||||
if ( action ) {
|
||||
exitSelf();
|
||||
} else {
|
||||
mAdapter.removeItem( bean );
|
||||
if ( mAdapter.getItemCount() == 0 ) {
|
||||
mEmptyPlaceHolder.setVisibility( View.VISIBLE );
|
||||
}
|
||||
updateHistoryMessageCount();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lastItemShow( boolean show ) {
|
||||
if ( !show && !mClearing ) {
|
||||
if ( mViewModel.getList() != null ) {
|
||||
int size = mViewModel.getList().size();
|
||||
if ( size > 0 && size < mHistoryList.getChildCount() ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
mClear.setVisibility( show ? View.VISIBLE : View.GONE );
|
||||
}
|
||||
};
|
||||
mViewModel = new MessageViewModel( list -> {
|
||||
UiThreadHandler.post( () -> {
|
||||
int size = list == null ? 0 : list.size();
|
||||
mAdapter.setDatas( list );
|
||||
mEmptyPlaceHolder.setVisibility( size > 0 ? View.GONE : View.VISIBLE );
|
||||
updateHistoryMessageCount();
|
||||
} );
|
||||
} );
|
||||
|
||||
mHistoryList.setLayoutManager( new LinearLayoutManager( AbsMogoApplication.getApp() ) );
|
||||
mHistoryList.setAdapter( mAdapter );
|
||||
mHistoryList.setItemAnimator( new PushItemAnimator() );
|
||||
mHistoryList.addOnItemTouchListener( new SwipeItemLayout.OnSwipeItemTouchListener( getContext() ) );
|
||||
|
||||
mRootView.setOnClickListener( view -> {
|
||||
} );
|
||||
}
|
||||
|
||||
private void exitSelf() {
|
||||
try {
|
||||
getActivity().getSupportFragmentManager().beginTransaction()
|
||||
.remove( this )
|
||||
.commitNowAllowingStateLoss();
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateHistoryMessageCount() {
|
||||
HandlerUtils.INSTANCE.getMBgHandler().post( () -> {
|
||||
int count = 0;
|
||||
try {
|
||||
count = PushRepository.Companion.getPushRepository().getPushBeanDao().getAllCount();
|
||||
} catch ( Exception e ) {
|
||||
count = 0;
|
||||
}
|
||||
renderHistoryMessageCount( count );
|
||||
} );
|
||||
}
|
||||
|
||||
private void renderHistoryMessageCount( int count ) {
|
||||
UiThreadHandler.post( () -> {
|
||||
try {
|
||||
mTitle.setText( count > 0 ? "历史消息(" + count + ")" : "历史消息" );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected MessageHistoryPresenter createPresenter() {
|
||||
return new MessageHistoryPresenter( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.mogo.eagle.core.function.notice.fragment;
|
||||
|
||||
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/9/1
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class MessageHistoryPresenter extends Presenter< MessageHistoryView > {
|
||||
|
||||
public MessageHistoryPresenter( MessageHistoryView view ) {
|
||||
super( view );
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.mogo.eagle.core.function.notice.fragment;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/9/1
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
interface MessageHistoryView extends IView {
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
package com.mogo.eagle.core.function.notice.repository
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import androidx.room.Room
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_NOTICE
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.function.notice.PushUIConstants
|
||||
import com.mogo.eagle.core.function.notice.dao.PushBeanDatabase
|
||||
import com.mogo.eagle.core.function.notice.model.PushBean
|
||||
import com.mogo.eagle.core.function.notice.utils.HandlerUtils
|
||||
import com.mogo.eagle.core.function.notice.view.getApis
|
||||
import com.mogo.eagle.core.function.notice.viewmodel.PushViewModel
|
||||
import com.mogo.map.MogoLocationClient
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener
|
||||
import com.mogo.service.statusmanager.StatusDescriptor
|
||||
import java.util.*
|
||||
import kotlin.collections.HashSet
|
||||
|
||||
class PushRepository(mContext: Context) {
|
||||
|
||||
companion object {
|
||||
private const val TAG: String = "PushRepository"
|
||||
private lateinit var appContext: Context
|
||||
|
||||
fun init(context: Context) {
|
||||
appContext = context.applicationContext
|
||||
pushRepository
|
||||
}
|
||||
|
||||
val globalContext: Context by lazy {
|
||||
appContext
|
||||
}
|
||||
|
||||
val pushRepository: PushRepository by lazy {
|
||||
PushRepository(appContext)
|
||||
}
|
||||
}
|
||||
|
||||
// 被中断的push消息仅再次展示一次
|
||||
private val singleRePushSet = HashSet<PushBean>()
|
||||
|
||||
private val pushViewModel: PushViewModel = PushViewModel(mContext, this)
|
||||
private val pushBeanQueue: Queue<PushBean> = LinkedList()
|
||||
private val statusManager = getApis(mContext).statusManagerApi
|
||||
val pushBeanDao by lazy {
|
||||
Room.databaseBuilder(appContext, PushBeanDatabase::class.java, "database_push").build()
|
||||
.pushBeanDao()
|
||||
}
|
||||
private val locationClient =
|
||||
MogoLocationClient.getInstance(appContext)
|
||||
|
||||
private val mHandler = Handler(Looper.getMainLooper())
|
||||
|
||||
private val statusChangedListener: IMogoStatusChangedListener =
|
||||
IMogoStatusChangedListener { sd, open ->
|
||||
CallerLogger.d("$M_NOTICE$TAG", "sd = $sd , open = $open")
|
||||
}
|
||||
|
||||
init {
|
||||
HandlerUtils.mBgHandler.postDelayed({
|
||||
updateMsgNum()
|
||||
}, 5000)
|
||||
}
|
||||
|
||||
private fun updateMsgNum() {
|
||||
val num = pushBeanDao.getAllCount()
|
||||
if (num > 100) { //历史消息最多保留100条
|
||||
pushBeanDao.deleteMin()
|
||||
updateMsgNum()
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun startIterate() {
|
||||
CallerLogger.d("$M_NOTICE$TAG", "startIterate : ${pushViewModel.pushBean}")
|
||||
if (!pushViewModel.isAddWindow()) {
|
||||
val bean = pushBeanQueue.peek()
|
||||
if (bean != null) {
|
||||
if (needDelay(bean)) {
|
||||
mHandler.removeCallbacks(delayRunnable)
|
||||
mHandler.postDelayed(delayRunnable, 15000)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
return
|
||||
}
|
||||
mHandler.post {
|
||||
iterateNext()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存被中断的push消息
|
||||
*/
|
||||
fun push(pushBean: PushBean) {
|
||||
if (singleRePushSet.contains(pushBean)) {
|
||||
return
|
||||
}
|
||||
CallerLogger.d("$M_NOTICE$TAG", "保存待下一次开启")
|
||||
singleRePushSet.add(pushBean)
|
||||
pushBeanQueue.offer(pushBean)
|
||||
}
|
||||
|
||||
private var delayRunnable = {
|
||||
startIterate()
|
||||
}
|
||||
|
||||
private fun needDelay(bean: PushBean): Boolean {
|
||||
if (locationClient.lastKnowLocation != null) {
|
||||
if (bean.speedLimit > 0 && bean.speedLimit <= locationClient.lastKnowLocation.speed * 18 / 5) {
|
||||
CallerLogger.d(
|
||||
"$M_NOTICE$TAG",
|
||||
"speedLimit : " + locationClient.lastKnowLocation.speed
|
||||
)
|
||||
return true
|
||||
}
|
||||
}
|
||||
if (statusManager.isV2XShow) {
|
||||
return true
|
||||
}
|
||||
if (statusManager.isVoiceShow) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun iterateNext(needSave: Boolean = false) {
|
||||
try {
|
||||
val nextBean = pushBeanQueue.peek()
|
||||
if (nextBean == null) {
|
||||
pushViewModel.pushBean = nextBean
|
||||
return
|
||||
}
|
||||
if (needDelay(nextBean)) {
|
||||
mHandler.removeCallbacksAndMessages(null)
|
||||
mHandler.postDelayed({
|
||||
iterateNext(needSave)
|
||||
}, 15000)
|
||||
return
|
||||
}
|
||||
pushViewModel.pushBean = pushBeanQueue.poll()
|
||||
} catch (e: Exception) {
|
||||
CallerLogger.e("$M_NOTICE$TAG", "$e")
|
||||
}
|
||||
if (pushViewModel.pushBean != null) {
|
||||
statusManager.registerStatusChangedListener(
|
||||
PushUIConstants.PATH,
|
||||
StatusDescriptor.V2X_UI,
|
||||
statusChangedListener
|
||||
)
|
||||
statusManager.registerStatusChangedListener(
|
||||
PushUIConstants.PATH,
|
||||
StatusDescriptor.VOICE_UI,
|
||||
statusChangedListener
|
||||
)
|
||||
} else {
|
||||
statusManager.unregisterStatusChangedListener(
|
||||
PushUIConstants.PATH,
|
||||
StatusDescriptor.VOICE_UI,
|
||||
statusChangedListener
|
||||
)
|
||||
statusManager.unregisterStatusChangedListener(
|
||||
PushUIConstants.PATH,
|
||||
StatusDescriptor.V2X_UI,
|
||||
statusChangedListener
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun delete(bean: PushBean) {
|
||||
HandlerUtils.mBgHandler.post {
|
||||
pushBeanDao.delete(bean)
|
||||
updateMsgNum()
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteAll() {
|
||||
HandlerUtils.mBgHandler.post {
|
||||
pushBeanDao.deleteAll()
|
||||
}
|
||||
}
|
||||
|
||||
fun getAll(): MutableList<PushBean> {
|
||||
return pushBeanDao.getAll()
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package com.mogo.eagle.core.function.notice.utils
|
||||
|
||||
import android.util.ArrayMap
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.eagle.core.function.notice.repository.PushRepository
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.service.analytics.IMogoAnalytics
|
||||
|
||||
object AnalyticsUtils {
|
||||
private val Analytics =
|
||||
ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_ANALYTICS).navigation(PushRepository.globalContext) as IMogoAnalytics
|
||||
|
||||
fun track(event: String, vararg keyValue: String) {
|
||||
val map = ArrayMap<String, Any>()
|
||||
if (keyValue.isNotEmpty()) {
|
||||
for (i in 0..keyValue.size - 2 step 2) {
|
||||
map[keyValue[i]] = keyValue[i + 1]
|
||||
}
|
||||
}
|
||||
Analytics.track(event, map)
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.mogo.eagle.core.function.notice.utils
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
|
||||
object HandlerUtils {
|
||||
private val handlerThread = HandlerThread("push_ui_thread")
|
||||
val mBgHandler: Handler
|
||||
|
||||
init {
|
||||
handlerThread.start()
|
||||
mBgHandler = Handler(handlerThread.looper)
|
||||
}
|
||||
}
|
||||
@@ -1,494 +0,0 @@
|
||||
package com.mogo.eagle.core.function.notice.view
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.Scroller
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.LayoutRes
|
||||
import com.mogo.commons.context.ContextHolderUtil
|
||||
import com.mogo.eagle.core.function.notice.Config
|
||||
import com.mogo.eagle.core.function.notice.R
|
||||
import com.mogo.eagle.core.function.notice.model.PushBean
|
||||
import com.mogo.eagle.core.function.notice.utils.AnalyticsUtils
|
||||
import com.mogo.eagle.core.function.notice.utils.stringConverterBitmap
|
||||
import com.mogo.eagle.core.function.notice.view.roundimage.RoundedImageView
|
||||
import com.mogo.eagle.core.function.notice.viewmodel.PushViewModel
|
||||
import com.mogo.eagle.core.utilcode.mogo.glide.GlideApp
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadPoolService
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.service.windowview.IMogoTopViewManager
|
||||
import com.mogo.service.windowview.IMogoTopViewStatusListener
|
||||
|
||||
class FloatView constructor(
|
||||
private val pushViewModel: PushViewModel,
|
||||
private val context: Context
|
||||
) {
|
||||
|
||||
companion object {
|
||||
const val TYPE_TOP_VIEW = 1
|
||||
const val TYPE_WINDOW_MANAGER = 2
|
||||
const val TAG: String = "FloatView.kt"
|
||||
}
|
||||
|
||||
interface PushViewController {
|
||||
fun show(bean: PushBean?)
|
||||
fun hide()
|
||||
fun inflateView(@LayoutRes layoutId: Int)
|
||||
}
|
||||
|
||||
abstract inner class PushView(context: Context) : FrameLayout(context),
|
||||
PushViewController {
|
||||
private lateinit var titleIconContainer: View
|
||||
private lateinit var pushTitle: TextView
|
||||
private lateinit var pushImage: RoundedImageView
|
||||
private lateinit var pushContent: TextView
|
||||
private lateinit var pushCheck: TextView
|
||||
|
||||
private var pushData: PushBean? = null
|
||||
|
||||
override fun inflateView(layoutId: Int) {
|
||||
LayoutInflater.from(context).inflate(layoutId, this, true)
|
||||
pushTitle = findViewById(R.id.module_push_title)
|
||||
pushCheck = findViewById(R.id.module_push_check)
|
||||
pushImage = findViewById(R.id.module_push_image)
|
||||
pushContent = findViewById(R.id.module_push_content)
|
||||
titleIconContainer = findViewById(R.id.module_push_app_icon_title)
|
||||
setOnClickListener {
|
||||
pushViewModel.dealCmd(PushViewModel.VOICE_ACTION_PUSH_MAIN, "1")
|
||||
turnNextMessage()
|
||||
}
|
||||
pushCheck.setOnClickListener {
|
||||
pushData?.let {
|
||||
if (pushCheckDialog == null) {
|
||||
pushCheckDialog = PushCheckDialog(ContextHolderUtil.getContext())
|
||||
}
|
||||
pushCheckDialog!!.showCheckDialog(it.title, it.content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun turnNextMessage() {
|
||||
pushViewModel.pushBean?.apply {
|
||||
showTimeout = 0
|
||||
updateTimer()
|
||||
}
|
||||
}
|
||||
|
||||
open fun setBean(bean: PushBean) {
|
||||
pushData = bean
|
||||
// title
|
||||
pushTitle.text = bean.title
|
||||
|
||||
// image
|
||||
if (bean.imageUrl.isEmpty() && bean.QRCode.isEmpty()) {
|
||||
pushImage.gone()
|
||||
} else if (bean.imageUrl.isNotEmpty()) {
|
||||
val params = pushImage.layoutParams
|
||||
params.width = getImgWidth()
|
||||
params.height = getImgHeight()
|
||||
pushImage.layoutParams = params
|
||||
pushImage.visible()
|
||||
GlideApp.with(this).load(bean.imageUrl).into(pushImage)
|
||||
} else if (bean.QRCode.isNotEmpty()) {
|
||||
val params = pushImage.layoutParams
|
||||
params.width = getQrImgWidth()
|
||||
params.height = getQrImgHeight()
|
||||
pushImage.layoutParams = params
|
||||
ThreadPoolService.execute {
|
||||
val bmp = stringConverterBitmap(
|
||||
bean.QRCode,
|
||||
getQrImgWidth(),
|
||||
getQrImgHeight()
|
||||
)
|
||||
UiThreadHandler.post {
|
||||
pushImage.setImageBitmap(bmp)
|
||||
pushImage.visible()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// content
|
||||
if (bean.content.isEmpty()) {
|
||||
pushContent.gone()
|
||||
} else {
|
||||
pushContent.text = bean.content
|
||||
pushContent.visible()
|
||||
}
|
||||
|
||||
// 产品侧需要重新梳理,tts暂时不播报
|
||||
// if (bean.tts.isNotEmpty()) {
|
||||
// AIAssist.getInstance(context).speakTTSVoice(bean.tts)
|
||||
// }
|
||||
}
|
||||
|
||||
abstract fun getImgWidth(): Int
|
||||
abstract fun getImgHeight(): Int
|
||||
abstract fun getQrImgWidth(): Int
|
||||
abstract fun getQrImgHeight(): Int
|
||||
|
||||
override fun show(bean: PushBean?) {
|
||||
isAddWindow = true
|
||||
uiHandler.removeCallbacks(delayClosePush)
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
isAddWindow = false
|
||||
}
|
||||
}
|
||||
|
||||
open inner class PushViewInTopView(context: Context) : PushView(context) {
|
||||
|
||||
private val mTopViewManager: IMogoTopViewManager = getApis(context).topViewManager
|
||||
|
||||
init {
|
||||
inflateView(R.layout.module_push_item)
|
||||
}
|
||||
|
||||
private var topViewStatusListener = object : IMogoTopViewStatusListener {
|
||||
override fun onViewRemoved(view: View?) {
|
||||
isAddWindow = false
|
||||
if (pushViewModel.pushBean?.showTimeout ?: 0 > 0) {
|
||||
if (getApis(context).statusManagerApi.isV2XShow) {
|
||||
// 被中断的消息,需要再次被显示一次
|
||||
uiHandler.removeCallbacks(delayClosePush)
|
||||
pushViewModel.push()
|
||||
pushViewModel.pushMessageFinish()
|
||||
return
|
||||
}
|
||||
}
|
||||
pushViewModel.pushBean?.showTimeout = 0
|
||||
updateTimer()
|
||||
}
|
||||
|
||||
override fun onViewAdded(view: View?) {
|
||||
if (pushViewModel.pushBean != null) {
|
||||
startClosePush()
|
||||
}
|
||||
}
|
||||
|
||||
override fun beforeViewRemoveAnim(view: View?) {
|
||||
}
|
||||
|
||||
override fun beforeViewAddAnim(view: View?) {
|
||||
}
|
||||
}
|
||||
|
||||
override fun show(bean: PushBean?) {
|
||||
super.show(bean)
|
||||
mLastVisibleType = TYPE_TOP_VIEW
|
||||
mTopViewManager.addView(this, topViewStatusListener)
|
||||
setBean(bean!!)
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
super.hide()
|
||||
mTopViewManager.removeView(this)
|
||||
}
|
||||
|
||||
override fun getImgWidth(): Int =
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_width)
|
||||
|
||||
override fun getImgHeight(): Int =
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_height)
|
||||
|
||||
override fun getQrImgWidth(): Int =
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_height)
|
||||
|
||||
override fun getQrImgHeight(): Int =
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_height)
|
||||
}
|
||||
|
||||
// inner class PushViewInWindowView(context: Context) : PushView(context), View.OnTouchListener {
|
||||
//
|
||||
// private val mContentContainer: View
|
||||
// private val mWindowManager =
|
||||
// context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
|
||||
//
|
||||
// private val params = WindowManager.LayoutParams()
|
||||
//
|
||||
// init {
|
||||
//
|
||||
// @Suppress("DEPRECATION")
|
||||
// params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT
|
||||
// params.flags = (WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
|
||||
// or WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
|
||||
// or WindowManager.LayoutParams.FLAG_LOCAL_FOCUS_MODE
|
||||
// or WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
|
||||
// or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
|
||||
// params.width = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
// params.height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
// params.gravity = Gravity.START or Gravity.BOTTOM
|
||||
// params.format = PixelFormat.TRANSLUCENT
|
||||
// params.x = context.resources.getDimensionPixelSize(R.dimen.module_push_window_x)
|
||||
// params.y = context.resources.getDimensionPixelSize(R.dimen.module_push_window_x)
|
||||
// if (Build.VERSION.SDK_INT > 25) {
|
||||
// params.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
|
||||
// }
|
||||
//
|
||||
// inflateView(R.layout.module_push_item_vertical)
|
||||
// mContentContainer = findViewById(R.id.module_push_content_container)
|
||||
// setOnTouchListener(this)
|
||||
// }
|
||||
//
|
||||
// override fun show(bean: PushBean?) {
|
||||
// super.show(bean)
|
||||
// mLastVisibleType = TYPE_WINDOW_MANAGER
|
||||
// setBean(bean!!)
|
||||
//
|
||||
// try {
|
||||
// mWindowManager.addView(this, params)
|
||||
// } catch (e: Exception) {
|
||||
// mWindowManager.updateViewLayout(this, params)
|
||||
// }
|
||||
// translationXAnimation(
|
||||
// -ResourcesHelper.getDimension(context, R.dimen.module_push_ui_width_vertical),
|
||||
// 0f
|
||||
// ) {
|
||||
// if (pushViewModel.pushBean != null) {
|
||||
// startClosePush()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private fun translationXAnimation(
|
||||
// from: Float,
|
||||
// to: Float,
|
||||
// doOnEnd: (animator: Animator) -> Unit
|
||||
// ) {
|
||||
// val transitionXAnimator: ObjectAnimator =
|
||||
// ObjectAnimator.ofFloat(
|
||||
// this,
|
||||
// View.TRANSLATION_X,
|
||||
// from,
|
||||
// to
|
||||
// )
|
||||
// transitionXAnimator.duration = 200
|
||||
// transitionXAnimator.doOnEnd(doOnEnd)
|
||||
// transitionXAnimator.start()
|
||||
// }
|
||||
//
|
||||
// override fun hide() {
|
||||
// super.hide()
|
||||
// translationXAnimation(
|
||||
// this.x,
|
||||
// -ResourcesHelper.getDimension(context, R.dimen.module_push_ui_width_vertical)
|
||||
// ) {
|
||||
// this.x = 0f
|
||||
// mWindowManager.removeViewImmediate(this)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun onTouch(v: View?, ev: MotionEvent?): Boolean {
|
||||
//
|
||||
// if (mLastVisibleType != TYPE_WINDOW_MANAGER) {
|
||||
// return false
|
||||
// }
|
||||
// when (ev?.action) {
|
||||
// MotionEvent.ACTION_DOWN -> {
|
||||
// needInterceptClick = false
|
||||
// startX = ev.x
|
||||
// }
|
||||
// MotionEvent.ACTION_MOVE -> {
|
||||
// moveX = startX - ev.x
|
||||
// scrollBy(moveX.toInt(), 0)
|
||||
// startX = ev.x
|
||||
// if (scrollX < 0) {
|
||||
// scrollTo(0, 0)
|
||||
// }
|
||||
// if (!needInterceptClick && scrollX > 20) {
|
||||
// needInterceptClick = true
|
||||
// }
|
||||
// invalidate()
|
||||
// }
|
||||
// MotionEvent.ACTION_UP -> {
|
||||
// if (scrollX > 0) {
|
||||
// mScroller.startScroll(scrollX, 0, width - scrollX, 0)
|
||||
// invalidate()
|
||||
// return true
|
||||
// }
|
||||
// if (needInterceptClick) {
|
||||
// return true
|
||||
// }
|
||||
// }
|
||||
// else -> {
|
||||
// startX = 0f
|
||||
// moveX = 0f
|
||||
// }
|
||||
// }
|
||||
// return false
|
||||
// }
|
||||
//
|
||||
// override fun computeScroll() {
|
||||
// if (mScroller.computeScrollOffset()) {
|
||||
// scrollTo(mScroller.currX, mScroller.currY)
|
||||
// invalidate()
|
||||
// } else {
|
||||
// if (mScroller.currX == 0) {
|
||||
// return
|
||||
// }
|
||||
// mScroller.finalX = 0
|
||||
// removeCallbacks(delayClosePush)
|
||||
// if (isAddWindow) {
|
||||
// if (currentBean != null) {
|
||||
// AnalyticsUtils.track(Config.NEWS_CARD_SWIPE, "trigger_type", "1")
|
||||
// }
|
||||
// mWindowManager.removeView(this)
|
||||
// isAddWindow = false
|
||||
// }
|
||||
// pushViewModel.pushBean?.showTimeout = 0
|
||||
// updateTimer()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun getImgWidth(): Int =
|
||||
// context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_width_vertical)
|
||||
//
|
||||
// override fun getImgHeight(): Int =
|
||||
// context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_height_vertical)
|
||||
//
|
||||
// override fun getQrImgWidth(): Int =
|
||||
// context.resources.getDimensionPixelSize(R.dimen.module_push_image_qr_size_vertical)
|
||||
//
|
||||
// override fun getQrImgHeight(): Int =
|
||||
// context.resources.getDimensionPixelSize(R.dimen.module_push_image_qr_size_vertical)
|
||||
// }
|
||||
|
||||
private var pushCheckDialog: PushCheckDialog? = null
|
||||
private val delayClosePush: Runnable
|
||||
private var isAddWindow = false
|
||||
private val uiHandler = Handler(Looper.getMainLooper())
|
||||
|
||||
private var startX = 0f
|
||||
private var moveX = 0f
|
||||
private val mScroller: Scroller = Scroller(context)
|
||||
private var needInterceptClick = false
|
||||
private var pause = false
|
||||
|
||||
private var currentBean: PushBean? = null
|
||||
|
||||
|
||||
private var mLastVisibleType = -1
|
||||
private var pushViewController: PushViewController? = null
|
||||
|
||||
init {
|
||||
delayClosePush = Runnable {
|
||||
updateTimer()
|
||||
}
|
||||
}
|
||||
|
||||
fun pushBeanChanged(bean: PushBean?) {
|
||||
uiHandler.post {
|
||||
uiHandler.removeCallbacks(delayClosePush)
|
||||
if (bean == null) {
|
||||
if (currentBean != null) {
|
||||
AnalyticsUtils.track(Config.NEWS_CARD_DISAPPEAR, "title", currentBean!!.title)
|
||||
}
|
||||
hide()
|
||||
} else {
|
||||
show(bean)
|
||||
AnalyticsUtils.track(Config.NEWS_CARD_SHOW, "title", bean.title)
|
||||
}
|
||||
currentBean = bean
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateTimer() {
|
||||
uiHandler.removeCallbacks(delayClosePush)
|
||||
val time = pushViewModel.pushBean?.showTimeout ?: 0
|
||||
if (time > 0) {
|
||||
pushViewModel.pushBean!!.showTimeout--
|
||||
uiHandler.postDelayed(delayClosePush, 1000)
|
||||
} else {
|
||||
pushViewModel.pushMessageFinish(true)
|
||||
}
|
||||
}
|
||||
|
||||
private fun show(bean: PushBean) {
|
||||
if (isAddWindow) {
|
||||
if (getApis(context).statusManagerApi.isMainPageOnResume) {
|
||||
if (mLastVisibleType != TYPE_TOP_VIEW) {
|
||||
hide()
|
||||
(pushViewController as View).postDelayed({
|
||||
show(bean)
|
||||
}, 750L)
|
||||
} else {
|
||||
showByTopView(bean)
|
||||
}
|
||||
} else {
|
||||
if (mLastVisibleType != TYPE_WINDOW_MANAGER) {
|
||||
hide()
|
||||
(pushViewController as View).postDelayed({
|
||||
show(bean)
|
||||
}, 750L)
|
||||
} else {
|
||||
showByWindowManager(bean)
|
||||
}
|
||||
}
|
||||
startClosePush()
|
||||
} else {
|
||||
if (getApis(context).statusManagerApi.isMainPageOnResume) {
|
||||
showByTopView(bean)
|
||||
} else {
|
||||
showByWindowManager(bean)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showByTopView(bean: PushBean) {
|
||||
if (pushViewController !is PushViewInTopView) {
|
||||
pushViewController = PushViewInTopView(context)
|
||||
}
|
||||
pushViewController?.show(bean)
|
||||
}
|
||||
|
||||
private fun showByWindowManager(bean: PushBean?) {
|
||||
// if (pushViewController !is PushViewInWindowView) {
|
||||
// pushViewController = PushViewInWindowView(context)
|
||||
// }
|
||||
// pushViewController?.show(bean)
|
||||
}
|
||||
|
||||
private fun startClosePush() {
|
||||
uiHandler.removeCallbacks(delayClosePush)
|
||||
uiHandler.postDelayed(
|
||||
delayClosePush,
|
||||
1000L
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
fun hide() {
|
||||
if (!isAddWindow) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
pushViewController?.hide()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun pauseTimer(on: Boolean) {
|
||||
if (on) {
|
||||
uiHandler.removeCallbacks(delayClosePush)
|
||||
} else {
|
||||
updateTimer()
|
||||
uiHandler.post {
|
||||
if (on) {
|
||||
pause = true
|
||||
uiHandler.removeCallbacks(delayClosePush)
|
||||
} else if (pause) {
|
||||
pause = false
|
||||
updateTimer()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun isAddWindow(): Boolean = isAddWindow
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.mogo.eagle.core.function.notice.view
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.mogo.eagle.core.function.notice.R
|
||||
import com.mogo.module.common.dialog.BaseFloatDialog
|
||||
|
||||
class PushCheckDialog(context: Context) : BaseFloatDialog(context) {
|
||||
|
||||
private var pushCheckClose: ImageView? = null
|
||||
private var pushCheckTitle: TextView? = null
|
||||
private var pushCheckContent: TextView? = null
|
||||
|
||||
init {
|
||||
setContentView(R.layout.module_push_dialog_check)
|
||||
setCanceledOnTouchOutside(true)
|
||||
pushCheckClose = findViewById(R.id.module_push_dialog_close)
|
||||
pushCheckTitle = findViewById(R.id.module_push_dialog_title)
|
||||
pushCheckContent = findViewById(R.id.module_push_dialog_content)
|
||||
pushCheckClose?.setOnClickListener {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
fun showCheckDialog(title: String, content: String) {
|
||||
if (isShowing) {
|
||||
return
|
||||
}
|
||||
if (title.isBlank() || content.isBlank()) {
|
||||
return
|
||||
}
|
||||
pushCheckTitle?.text = title
|
||||
pushCheckContent?.text = content
|
||||
show()
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.mogo.eagle.core.function.notice.viewmodel
|
||||
|
||||
import com.mogo.eagle.core.function.notice.model.PushBean
|
||||
import com.mogo.eagle.core.function.notice.repository.PushRepository
|
||||
import com.mogo.eagle.core.function.notice.utils.HandlerUtils
|
||||
|
||||
class MessageViewModel(private val messageViewModel: MessageListChange) {
|
||||
|
||||
var list: MutableList<PushBean>? = null
|
||||
set(value) {
|
||||
field = value
|
||||
messageViewModel.messageListChange(value)
|
||||
}
|
||||
|
||||
init {
|
||||
HandlerUtils.mBgHandler.post {
|
||||
list = PushRepository.pushRepository.getAll()
|
||||
}
|
||||
}
|
||||
|
||||
interface MessageListChange {
|
||||
fun messageListChange(list: MutableList<PushBean>?)
|
||||
}
|
||||
|
||||
fun delete(bean: PushBean) {
|
||||
PushRepository.pushRepository.delete(bean)
|
||||
}
|
||||
|
||||
fun deleteAll() {
|
||||
list = null
|
||||
PushRepository.pushRepository.deleteAll()
|
||||
}
|
||||
}
|
||||
@@ -1,188 +0,0 @@
|
||||
package com.mogo.eagle.core.function.notice.viewmodel
|
||||
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import com.mogo.commons.voice.AIAssist
|
||||
import com.mogo.commons.voice.IMogoVoiceCmdCallBack
|
||||
import com.mogo.eagle.core.function.notice.Config
|
||||
import com.mogo.eagle.core.function.notice.model.PushBean
|
||||
import com.mogo.eagle.core.function.notice.repository.PushRepository
|
||||
import com.mogo.eagle.core.function.notice.utils.AnalyticsUtils
|
||||
import com.mogo.eagle.core.function.notice.utils.dealSchema
|
||||
import com.mogo.eagle.core.function.notice.view.FloatView
|
||||
|
||||
class PushViewModel(
|
||||
private val mContext: Context,
|
||||
private val pushRepository: PushRepository
|
||||
) {
|
||||
companion object {
|
||||
const val VOICE_ACTION_PUSH_MAIN = "VOICE_ACTION_PUSH_MAIN"
|
||||
const val VOICE_ACTION_PUSH_LEFT = "VOICE_ACTION_PUSH_LEFT"
|
||||
const val VOICE_ACTION_PUSH_RIGHT = "VOICE_ACTION_PUSH_RIGHT"
|
||||
const val VOICE_ACTION_PUSH_CANCEL = "VOICE_ACTION_PUSH_CANCEL"
|
||||
}
|
||||
|
||||
var floatView: FloatView? = null
|
||||
|
||||
private var mVoiceClient: AIAssist = AIAssist.getInstance(mContext)
|
||||
|
||||
private val voiceCmdCallback = object : IMogoVoiceCmdCallBack {
|
||||
override fun onSpeakEnd(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onCmdSelected(cmd: String?) {
|
||||
if (!cmd.isNullOrEmpty()) {
|
||||
dealCmd(cmd)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCmdAction(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onCmdCancel(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onSpeakSelectTimeOut(speakText: String?) {
|
||||
}
|
||||
}
|
||||
|
||||
fun dealCmd(cmd: String, isClick: String = "2") {
|
||||
if (TextUtils.isEmpty(cmd)) {
|
||||
return
|
||||
}
|
||||
pushBean?.let {
|
||||
when (cmd) {
|
||||
VOICE_ACTION_PUSH_MAIN -> {
|
||||
AnalyticsUtils.track(Config.NEWS_CARD_CLICK, "trigger_type", isClick)
|
||||
if (isClick == "2") {
|
||||
mVoiceClient.speakTTSVoiceWithLevel("好的",AIAssist.LEVEL1, voiceCmdCallback)
|
||||
}
|
||||
if (it.mainSchema.isNotEmpty()) {
|
||||
dealSchema(it.mainSchema, mContext)
|
||||
}
|
||||
}
|
||||
VOICE_ACTION_PUSH_LEFT -> {
|
||||
if (it.buttons.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
AnalyticsUtils.track(
|
||||
Config.NEWS_CARD_CLICK_BTN,
|
||||
"trigger_type",
|
||||
isClick, "btn_text", it.buttons[0].text
|
||||
)
|
||||
if (isClick == "2") {
|
||||
mVoiceClient.speakTTSVoiceWithLevel("好的", AIAssist.LEVEL1,voiceCmdCallback)
|
||||
}
|
||||
if (it.buttons[0].action.isNotEmpty()) {
|
||||
dealSchema(it.buttons[0].action, mContext)
|
||||
}
|
||||
}
|
||||
VOICE_ACTION_PUSH_RIGHT -> {
|
||||
if (it.buttons.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
AnalyticsUtils.track(
|
||||
Config.NEWS_CARD_CLICK_BTN,
|
||||
"trigger_type",
|
||||
isClick, "btn_text", it.buttons[1].text
|
||||
)
|
||||
if (isClick == "2") {
|
||||
mVoiceClient.speakTTSVoiceWithLevel("好的",AIAssist.LEVEL1 ,voiceCmdCallback)
|
||||
}
|
||||
if (it.buttons[1].action.isNotEmpty()) {
|
||||
dealSchema(it.buttons[1].action, mContext)
|
||||
}
|
||||
}
|
||||
VOICE_ACTION_PUSH_CANCEL -> {
|
||||
AnalyticsUtils.track(
|
||||
Config.NEWS_CARD_SWIPE,
|
||||
"trigger_type",
|
||||
isClick
|
||||
)
|
||||
if (isClick == "2") {
|
||||
mVoiceClient.speakTTSVoiceWithLevel("好的",AIAssist.LEVEL1, voiceCmdCallback)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var pushBean: PushBean? = null
|
||||
set(value) {
|
||||
field = value
|
||||
if (value == null) {
|
||||
floatView?.hide()
|
||||
floatView = null
|
||||
return
|
||||
}
|
||||
field?.showTimeoutShadow = field?.showTimeout?:0
|
||||
if (value.imageUrl.isBlank()) {
|
||||
value.imageUrl = ""
|
||||
}
|
||||
if (floatView == null) {
|
||||
floatView = FloatView(this, mContext)
|
||||
}
|
||||
floatView?.pushBeanChanged(field)
|
||||
registerVoiceCMD()
|
||||
}
|
||||
|
||||
fun pushMessageFinish(needSave: Boolean = false) {
|
||||
pushRepository.iterateNext(needSave)
|
||||
}
|
||||
|
||||
private fun registerVoiceCMD() {
|
||||
mVoiceClient.unregisterUnWakeupCommand(VOICE_ACTION_PUSH_CANCEL)
|
||||
mVoiceClient.unregisterUnWakeupCommand(VOICE_ACTION_PUSH_MAIN)
|
||||
mVoiceClient.unregisterUnWakeupCommand(VOICE_ACTION_PUSH_LEFT)
|
||||
mVoiceClient.unregisterUnWakeupCommand(VOICE_ACTION_PUSH_RIGHT)
|
||||
|
||||
if (pushBean != null && !pushBean!!.cancelVoiceCmd.isNullOrEmpty()) {
|
||||
mVoiceClient.registerUnWakeupCommand(
|
||||
VOICE_ACTION_PUSH_CANCEL,
|
||||
pushBean!!.cancelVoiceCmd!!.toTypedArray(),
|
||||
voiceCmdCallback
|
||||
)
|
||||
} else {
|
||||
mVoiceClient.registerUnWakeupCommand(
|
||||
VOICE_ACTION_PUSH_CANCEL,
|
||||
arrayOf("忽略", "取消", "算了", "不要", "不要了", "不看了", "关闭"),
|
||||
voiceCmdCallback
|
||||
)
|
||||
}
|
||||
|
||||
if (pushBean != null && !pushBean!!.mainVoiceCmd.isNullOrEmpty()) {
|
||||
mVoiceClient.registerUnWakeupCommand(
|
||||
VOICE_ACTION_PUSH_MAIN,
|
||||
pushBean!!.mainVoiceCmd!!.toTypedArray(),
|
||||
voiceCmdCallback
|
||||
)
|
||||
}
|
||||
|
||||
pushBean?.buttons?.forEach {
|
||||
it.voiceCmd?.apply {
|
||||
mVoiceClient.registerUnWakeupCommand(
|
||||
VOICE_ACTION_PUSH_RIGHT,
|
||||
toTypedArray(),
|
||||
voiceCmdCallback
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun speakDefault(voice: String) {
|
||||
mVoiceClient.speakTTSVoiceWithLevel(voice,AIAssist.LEVEL3 ,voiceCmdCallback)
|
||||
}
|
||||
|
||||
fun pauseAnimator(on: Boolean) {
|
||||
floatView?.pauseTimer(on)
|
||||
}
|
||||
|
||||
fun isAddWindow(): Boolean = floatView?.isAddWindow() ?: false
|
||||
|
||||
fun push() {
|
||||
pushBean?.apply {
|
||||
showTimeout = showTimeoutShadow
|
||||
pushRepository.push(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<corners android:radius="@dimen/module_push_clear_bg_radius" />
|
||||
<solid android:color="#FF494B66 "/>
|
||||
</shape>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="false">
|
||||
<shape>
|
||||
<corners android:radius="@dimen/module_push_ui_button_radius" />
|
||||
<gradient android:angle="135" android:endColor="#1F7EFF" android:startColor="#1E57A4" android:type="linear" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_pressed="true">
|
||||
<shape>
|
||||
<corners android:radius="@dimen/module_push_ui_button_radius" />
|
||||
<gradient android:angle="135" android:endColor="#124C9A" android:startColor="#123463" android:type="linear" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<corners android:radius="@dimen/module_push_panel_item_corner" />
|
||||
<solid android:color="#1F2131" />
|
||||
<!-- <gradient
|
||||
android:angle="-90"
|
||||
android:endColor="#2F3047"
|
||||
android:startColor="#3F4057"
|
||||
android:type="linear" />-->
|
||||
</shape>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="false">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="@dimen/module_push_ui_button_radius" />
|
||||
<gradient android:angle="135" android:endColor="#616381" android:startColor="#48495E" />
|
||||
</shape>
|
||||
|
||||
</item>
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="@dimen/module_push_ui_button_radius" />
|
||||
<gradient android:angle="135" android:endColor="#3A3B4D" android:startColor="#2B2C38" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="@dimen/module_push_dialog_check_width"
|
||||
android:layout_height="@dimen/module_push_dialog_check_height"
|
||||
android:background="@drawable/module_push_dialog_check_background">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_push_dialog_close"
|
||||
android:layout_width="@dimen/module_push_dialog_close_width"
|
||||
android:layout_height="@dimen/module_push_dialog_close_height"
|
||||
android:layout_marginLeft="@dimen/module_push_dialog_close_margin"
|
||||
android:layout_marginTop="@dimen/module_push_dialog_close_margin"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/module_push_dialog_close"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_dialog_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/module_push_dialog_title_margin"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/module_push_dialog_title_size"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_dialog_content"
|
||||
android:layout_width="@dimen/module_push_dialog_content_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/module_push_dialog_content_margin_top"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/module_push_dialog_content_size"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_push_dialog_title" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,94 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/module_push_ui_height"
|
||||
android:layout_marginTop="@dimen/module_push_ui_margin_top"
|
||||
android:background="@drawable/module_push_item_background">
|
||||
|
||||
<com.mogo.eagle.core.function.notice.view.roundimage.RoundedImageView
|
||||
android:id="@+id/module_push_image"
|
||||
android:layout_width="@dimen/module_push_ui_image_width"
|
||||
android:layout_height="@dimen/module_push_ui_image_height"
|
||||
android:scaleType="fitXY"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:riv_corner_radius_bottom_left="@dimen/module_push_ui_image_corner"
|
||||
app:riv_corner_radius_top_left="@dimen/module_push_ui_image_corner" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_push_app_icon_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/module_push_ui_app_icon_leftMargin"
|
||||
android:layout_marginTop="@dimen/module_push_ui_app_icon_topMargin"
|
||||
android:gravity="center_vertical"
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_push_image"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_goneMarginTop="@dimen/module_push_ui_app_icon_goneTopMargin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical|left"
|
||||
android:maxWidth="@dimen/module_push_title_mix_width"
|
||||
android:maxLength="25"
|
||||
android:singleLine="true"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/module_push_ui_title_textSize"
|
||||
app:layout_constrainedWidth="true"
|
||||
tools:text="官方公告" />
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/module_push_rl_content"
|
||||
android:layout_width="@dimen/module_push_ui_content_width"
|
||||
android:layout_height="@dimen/module_push_ui_content_height"
|
||||
android:layout_marginTop="@dimen/module_push_ui_content_marginTop"
|
||||
android:layout_marginBottom="@dimen/module_push_ui_content_marginBottom"
|
||||
app:layout_constraintLeft_toLeftOf="@id/module_push_app_icon_title"
|
||||
app:layout_constraintTop_toBottomOf="@id/module_push_app_icon_title">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="3"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/module_push_ui_title_text_size" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/module_push_line"
|
||||
android:layout_width="@dimen/module_push_line_width"
|
||||
android:layout_height="@dimen/module_push_line_height"
|
||||
android:layout_marginLeft="@dimen/module_push_line_margin_left"
|
||||
android:background="@color/module_push_item_line_color"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_push_rl_content"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_check"
|
||||
android:layout_width="@dimen/module_push_check_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/module_push_check_margin"
|
||||
android:layout_marginBottom="@dimen/module_push_check_margin"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_push_check"
|
||||
android:textColor="@color/module_push_check_color"
|
||||
android:textSize="@dimen/module_push_check_text_size"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/module_push_line"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,145 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/module_push_ui_height"
|
||||
android:background="@drawable/module_push_item_background_p">
|
||||
|
||||
<com.mogo.eagle.core.function.notice.view.roundimage.RoundedImageView
|
||||
android:id="@+id/module_push_image"
|
||||
android:layout_width="@dimen/module_push_ui_image_width"
|
||||
android:layout_height="@dimen/module_push_ui_image_height"
|
||||
android:layout_marginLeft="@dimen/module_push_ui_image_marLeft"
|
||||
android:scaleType="fitXY"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:riv_corner_radius="@dimen/module_push_ui_image_corner" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_push_app_icon_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/module_push_ui_app_icon_leftMargin"
|
||||
android:layout_marginTop="@dimen/module_push_ui_app_icon_topMargin"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/module_push_ui_app_icon_size"
|
||||
app:layout_constraintRight_toLeftOf="@+id/module_push_progress_bar_frame"
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_push_image"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_goneMarginTop="@dimen/module_push_ui_app_icon_goneTopMargin">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_push_app_icon"
|
||||
android:layout_width="@dimen/module_push_ui_app_icon_size"
|
||||
android:layout_height="@dimen/module_push_ui_app_icon_size"
|
||||
android:layout_marginRight="@dimen/module_push_title_margin_start"
|
||||
android:background="@drawable/module_push_ui_ic_message2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical|left"
|
||||
android:maxWidth="@dimen/module_push_title_mix_width"
|
||||
android:singleLine="true"
|
||||
android:maxLength="25"
|
||||
tools:text="标题标题标题标题标题标题标题"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/module_push_ui_title_textSize"
|
||||
app:layout_constrainedWidth="true" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="@dimen/module_push_ui_content_marginTop"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="@id/module_push_app_icon_title"
|
||||
app:layout_constraintRight_toRightOf="@id/module_push_progress_bar_frame"
|
||||
app:layout_constraintTop_toBottomOf="@id/module_push_app_icon_title">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:maxLines="3"
|
||||
android:layout_above="@+id/module_push_buttons"
|
||||
android:ellipsize="end"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/module_push_ui_title_text_size"
|
||||
tools:text="文本内容文本内容文本内文本内容文本内容文本内文本内容文本内容文本内文本内容文本内容文本内文本内容文本内容文本内文本内容文本内容文本内文本内容文本内容文本内文本内容文本内容文本内文本内容文本内容文本内文本内容文本内容文本内文本内容文本内容文本内文本内容文本内容文本内" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_push_buttons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/module_push_button_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="@dimen/module_push_button_margin_top"
|
||||
android:layout_marginBottom="@dimen/module_push_button_margin_bottom"
|
||||
android:gravity="center"
|
||||
android:weightSum="2">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_button_left"
|
||||
android:layout_width="@dimen/module_push_button_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/module_push_left_button"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:enabled="true"
|
||||
android:lines="1"
|
||||
android:maxWidth="@dimen/module_push_button_maxWidth"
|
||||
android:maxLength="6"
|
||||
android:text="查看"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="@dimen/module_push_title_text_size"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_button_right"
|
||||
android:layout_width="@dimen/module_push_button_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="@dimen/module_push_button_right_marLeft"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/module_push_right_button"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:lines="1"
|
||||
android:maxWidth="@dimen/module_push_button_maxWidth"
|
||||
android:maxLength="6"
|
||||
android:text="忽略"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="@dimen/module_push_title_text_size"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/module_push_progress_bar_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/module_push_progress_bar_frame_marginTop"
|
||||
android:layout_marginEnd="@dimen/module_push_progress_bar_frame_marginEnd"
|
||||
android:background="@drawable/module_push_decrease_timer_bkg"
|
||||
android:paddingLeft="@dimen/module_push_progress_bar_frame_padding"
|
||||
android:paddingRight="@dimen/module_push_progress_bar_frame_padding"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_timer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:textColor="#80FFFFFF"
|
||||
android:textSize="@dimen/module_push_ui_timer_textSize"
|
||||
tools:text="11s" />
|
||||
</FrameLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,63 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/module_push_panel_marginTop"
|
||||
android:layout_marginBottom="@dimen/module_push_panel_marginBottom"
|
||||
android:layout_marginRight="@dimen/module_push_panel_marginRight"
|
||||
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_background"
|
||||
android:layout_gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
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"
|
||||
android:text="历史消息"
|
||||
android:textColor="@color/module_push_panel_title_textColor"
|
||||
android:textSize="@dimen/module_push_activity_title_text_size" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_push_id_close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="@dimen/module_push_activity_close_margin_top"
|
||||
android:src="@drawable/module_push_close" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
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_id_not_data"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
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_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_clear_bg"
|
||||
android:gravity="center"
|
||||
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"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -1,105 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.mogo.eagle.core.function.notice.view.SwipeItemLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="@dimen/module_push_panel_paddingBottom">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/module_push_message_item_height">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/module_push_item_click"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/module_push_recycler_item_background">
|
||||
|
||||
<com.mogo.service.imageloader.MogoImageView
|
||||
android:id="@+id/module_push_item_app_icon"
|
||||
android:layout_width="@dimen/module_push_message_app_icon_size"
|
||||
android:layout_height="@dimen/module_push_message_app_icon_size"
|
||||
android:layout_marginStart="@dimen/module_push_message_margin_start"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_item_title"
|
||||
android:layout_width="@dimen/module_push_item_content_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/module_push_image_margin_top"
|
||||
android:layout_marginTop="@dimen/module_push_item_title_margin_top"
|
||||
android:ellipsize="end"
|
||||
android:gravity="left"
|
||||
android:maxLines="1"
|
||||
android:text="push title"
|
||||
android:textColor="@color/module_push_item_title_textColor"
|
||||
android:textSize="@dimen/module_push_title_text_size"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_push_item_app_icon"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_max="@dimen/module_push_item_content_width"
|
||||
app:layout_goneMarginBottom="@dimen/module_push_item_title_gone_margin_bottom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_item_content"
|
||||
android:layout_width="@dimen/module_push_item_content_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/module_push_item_content_margin_end"
|
||||
android:ellipsize="end"
|
||||
android:gravity="left"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/module_push_item_content_textColor"
|
||||
android:textSize="@dimen/module_push_item_content_text_size"
|
||||
app:layout_constraintStart_toStartOf="@+id/module_push_item_title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_push_item_title"
|
||||
tools:text="发现系统新版本,共140.3M。部分功能优化,建议下载升级。" />
|
||||
|
||||
<com.mogo.service.imageloader.MogoImageView
|
||||
android:id="@+id/module_push_item_image"
|
||||
android:layout_width="@dimen/module_push_item_image_width"
|
||||
android:layout_height="@dimen/module_push_item_image_height"
|
||||
android:layout_marginEnd="@dimen/module_push_message_item_image_margin_end"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:miv_radius="@dimen/module_push_item_image_radius"
|
||||
app:miv_shape="round" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_item_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/module_push_item_time_textSize"
|
||||
android:layout_marginEnd="@dimen/module_push_image_margin_top"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/module_push_item_time_textColor"
|
||||
android:textSize="@dimen/module_push_massage_time_text_size"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/module_push_item_content"
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_push_item_content"
|
||||
tools:text="3:20" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/module_push_button_margin_top">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_push_item_delete"
|
||||
android:layout_width="@dimen/module_push_message_item_height"
|
||||
android:layout_height="@dimen/module_push_message_item_height"
|
||||
android:layout_marginStart="@dimen/module_push_button_margin_top"
|
||||
android:background="@drawable/module_push_recycler_item_background"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_push_str_delete"
|
||||
android:textColor="@color/module_push_item_title_textColor"
|
||||
android:textSize="@dimen/module_push_title_text_size" />
|
||||
</FrameLayout>
|
||||
</com.mogo.eagle.core.function.notice.view.SwipeItemLayout>
|
||||
Reference in New Issue
Block a user