From 3448dfddef8c2b419fb2b3653844665fb3ffdf46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=8E=89=E4=B9=85?= <1484288157@qq.com> Date: Sat, 28 Dec 2019 15:40:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=9020191228=E6=B5=8B=E8=AF=95=20?= =?UTF-8?q?https://gitlab.ghzs.com/pm/halo-app-issues/issues/716?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gh/common/util/NotificationHelper.kt | 28 +++++++++---------- .../java/com/gh/gamecenter/MainActivity.java | 2 +- .../rating/edit/RatingEditActivity.kt | 6 ++-- .../qa/answer/edit/AnswerEditActivity.kt | 6 +++- .../article/edit/ArticleTagsSelectFragment.kt | 6 ++-- .../qa/questions/edit/QuestionEditActivity.kt | 5 +++- .../qa/questions/edit/TagsSelectFragment.kt | 8 ++++++ .../video/upload/view/UploadVideoActivity.kt | 5 +++- 8 files changed, 43 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/gh/common/util/NotificationHelper.kt b/app/src/main/java/com/gh/common/util/NotificationHelper.kt index f91066818c..e49fc1915a 100644 --- a/app/src/main/java/com/gh/common/util/NotificationHelper.kt +++ b/app/src/main/java/com/gh/common/util/NotificationHelper.kt @@ -10,16 +10,15 @@ import com.gh.gamecenter.entity.NotificationUgc import com.gh.gamecenter.retrofit.BiResponse import com.gh.gamecenter.retrofit.RetrofitManager import com.halo.assistant.HaloApp +import com.lightgame.utils.AppManager import com.lightgame.utils.Utils import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers -import java.lang.ref.WeakReference object NotificationHelper { @JvmStatic - fun showNotificationHintDialog(activity: AppCompatActivity, ugc: NotificationUgc) { - val activityRef = WeakReference(activity) + fun showNotificationHintDialog(ugc: NotificationUgc) { val showedNewVersion = SPUtils.getInt(Constants.SP_SHOWED_NOTIFICATION_NEW_VERSION, 0) val currentVersion = PackageUtils.getVersionCode() // 版本升级后重置数据 @@ -52,37 +51,37 @@ object NotificationHelper { when (ugc) { NotificationUgc.LOGIN -> { if (!isShowedLogin) { - show(activityRef.get()) + show(AppManager.getInstance().currentActivity() as AppCompatActivity) SPUtils.setBoolean(Constants.SP_SHOWED_NOTIFICATION_LOGIN, true) } } NotificationUgc.QUESTION -> { - if (isShowedQuestion) { - show(activityRef.get()) + if (!isShowedQuestion) { + show(AppManager.getInstance().currentActivity() as AppCompatActivity) SPUtils.setBoolean(Constants.SP_SHOWED_NOTIFICATION_QUESTION, true) } } NotificationUgc.ANSWER -> { - if (isShowedAnswer) { - show(activityRef.get()) + if (!isShowedAnswer) { + show(AppManager.getInstance().currentActivity() as AppCompatActivity) SPUtils.setBoolean(Constants.SP_SHOWED_NOTIFICATION_ANSWER, true) } } NotificationUgc.ARTICLE -> { - if (isShowedArticle) { - show(activityRef.get()) + if (!isShowedArticle) { + show(AppManager.getInstance().currentActivity() as AppCompatActivity) SPUtils.setBoolean(Constants.SP_SHOWED_NOTIFICATION_ARTICLE, true) } } NotificationUgc.VIDEO -> { - if (isShowedVideo) { - show(activityRef.get()) + if (!isShowedVideo) { + show(AppManager.getInstance().currentActivity() as AppCompatActivity) SPUtils.setBoolean(Constants.SP_SHOWED_NOTIFICATION_VIDEO, true) } } NotificationUgc.RATING -> { - if (isShowedRating) { - show(activityRef.get()) + if (!isShowedRating) { + show(AppManager.getInstance().currentActivity() as AppCompatActivity) SPUtils.setBoolean(Constants.SP_SHOWED_NOTIFICATION_RATING, true) } } @@ -114,7 +113,6 @@ object NotificationHelper { Utils.log("notification is enable") } else { NotificationHintDialogFragment.getInstance(notificationHint).show(activity.supportFragmentManager, "notification") - //SPUtils.setBoolean(Constants.SP_SHOWED_NOTIFICATION_LOGIN, true) } } diff --git a/app/src/main/java/com/gh/gamecenter/MainActivity.java b/app/src/main/java/com/gh/gamecenter/MainActivity.java index 99aa4c4ff8..966f845e68 100644 --- a/app/src/main/java/com/gh/gamecenter/MainActivity.java +++ b/app/src/main/java/com/gh/gamecenter/MainActivity.java @@ -498,7 +498,7 @@ public class MainActivity extends BaseActivity { showNotificationHintDialog(); }*/ if (UserManager.getInstance().isLoggedIn()) { - NotificationHelper.showNotificationHintDialog(this, NotificationUgc.LOGIN); + NotificationHelper.showNotificationHintDialog(NotificationUgc.LOGIN); } } diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/rating/edit/RatingEditActivity.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/rating/edit/RatingEditActivity.kt index ddc50acc04..696730d4b5 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/rating/edit/RatingEditActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/rating/edit/RatingEditActivity.kt @@ -15,6 +15,7 @@ import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders import com.gh.base.ToolBarActivity import com.gh.base.fragment.WaitingDialogFragment +import com.gh.common.AppExecutor import com.gh.common.DefaultJsApi import com.gh.common.im.ImManager import com.gh.common.util.* @@ -170,7 +171,6 @@ class RatingEditActivity : ToolBarActivity() { mViewModel.postLiveData.observe(this, Observer { if (it.status == Status.SUCCESS) { MtaHelper.onEvent("发表评论", "提交", mGame.name) - NotificationHelper.showNotificationHintDialog(this, NotificationUgc.RATING) setResult(Activity.RESULT_OK) toast("提交成功") GdtHelper.logAction(ActionType.RATE, @@ -211,7 +211,9 @@ class RatingEditActivity : ToolBarActivity() { } else { finish() } - + AppExecutor.uiExecutor.executeWithDelay(Runnable { + NotificationHelper.showNotificationHintDialog(NotificationUgc.RATING) + },1000) } else if (it.status == Status.ERROR) { var errorString: String? = null try { diff --git a/app/src/main/java/com/gh/gamecenter/qa/answer/edit/AnswerEditActivity.kt b/app/src/main/java/com/gh/gamecenter/qa/answer/edit/AnswerEditActivity.kt index 7549bee750..842e6deb80 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/answer/edit/AnswerEditActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/answer/edit/AnswerEditActivity.kt @@ -16,6 +16,7 @@ import androidx.lifecycle.ViewModelProviders import butterknife.OnClick import com.gh.base.BaseRichEditorActivity import com.gh.base.fragment.WaitingDialogFragment +import com.gh.common.AppExecutor import com.gh.common.util.* import com.gh.gamecenter.R import com.gh.gamecenter.entity.NotificationUgc @@ -143,8 +144,11 @@ class AnswerEditActivity : BaseRichEditorActivity() { .getIntent(this, answerId, mEntrance, "编辑答案") startActivity(intent) } - NotificationHelper.showNotificationHintDialog(this, NotificationUgc.ANSWER) finish() + AppExecutor.uiExecutor.executeWithDelay(Runnable { + NotificationHelper.showNotificationHintDialog(NotificationUgc.ANSWER) + },1000) + } else if (it.status == Status.ERROR) { val errorString = it.exception?.response()?.errorBody()?.string() ErrorHelper.handleErrorWithCustomizedHandler(this, errorString, customizedHandler = { code -> diff --git a/app/src/main/java/com/gh/gamecenter/qa/article/edit/ArticleTagsSelectFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/article/edit/ArticleTagsSelectFragment.kt index 6376eae3f7..193b2ff0ab 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/article/edit/ArticleTagsSelectFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/article/edit/ArticleTagsSelectFragment.kt @@ -11,12 +11,12 @@ import android.view.ViewGroup import android.view.Window import android.widget.EditText import android.widget.TextView -import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders import com.gh.base.fragment.BaseDialogWrapperFragment import com.gh.base.fragment.BaseFragment +import com.gh.common.AppExecutor import com.gh.common.util.DisplayUtils import com.gh.common.util.NotificationHelper import com.gh.gamecenter.R @@ -71,8 +71,10 @@ class ArticleTagsSelectFragment : BaseFragment() { startActivity(intent) } toast("发布成功") - NotificationHelper.showNotificationHintDialog(activity as AppCompatActivity, NotificationUgc.ARTICLE) activity?.finish() + AppExecutor.uiExecutor.executeWithDelay(Runnable { + NotificationHelper.showNotificationHintDialog(NotificationUgc.ARTICLE) + },1000) }) mCancelBtn.setOnClickListener { diff --git a/app/src/main/java/com/gh/gamecenter/qa/questions/edit/QuestionEditActivity.kt b/app/src/main/java/com/gh/gamecenter/qa/questions/edit/QuestionEditActivity.kt index 20ab4ac9d2..c8680fa13c 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/questions/edit/QuestionEditActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/questions/edit/QuestionEditActivity.kt @@ -17,6 +17,7 @@ import androidx.lifecycle.ViewModelProviders import com.gh.base.ToolBarActivity import com.gh.base.fragment.BaseDialogWrapperFragment import com.gh.base.fragment.WaitingDialogFragment +import com.gh.common.AppExecutor import com.gh.common.util.* import com.gh.common.view.SpacingItemDecoration import com.gh.gamecenter.R @@ -143,8 +144,10 @@ class QuestionEditActivity : ToolBarActivity() { data.putExtra(QuestionsDetailEntity::class.java.simpleName, mViewModel.questionEntity) setResult(Activity.RESULT_OK, data) } - NotificationHelper.showNotificationHintDialog(this, NotificationUgc.QUESTION) finish() + AppExecutor.uiExecutor.executeWithDelay(Runnable { + NotificationHelper.showNotificationHintDialog(NotificationUgc.QUESTION) + },1000) } else if (it?.status == Status.ERROR) { val e = it.exception if (e != null && e.code() == 403) { diff --git a/app/src/main/java/com/gh/gamecenter/qa/questions/edit/TagsSelectFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/questions/edit/TagsSelectFragment.kt index 045fb5b47e..3dea94ee8b 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/questions/edit/TagsSelectFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/questions/edit/TagsSelectFragment.kt @@ -16,9 +16,11 @@ import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders import com.gh.base.fragment.BaseDialogWrapperFragment import com.gh.base.fragment.BaseFragment +import com.gh.common.AppExecutor import com.gh.common.util.* import com.gh.gamecenter.R import com.gh.gamecenter.entity.ErrorEntity +import com.gh.gamecenter.entity.NotificationUgc import com.gh.gamecenter.entity.Permissions import com.gh.gamecenter.manager.UserManager import com.gh.gamecenter.mvvm.Status @@ -91,6 +93,9 @@ class TagsSelectFragment : BaseFragment() { mModeratorPatchTagsCallback?.onPatchTagsSuccess() val fragment = parentFragment (fragment as? BaseDialogWrapperFragment)?.dismiss() + AppExecutor.uiExecutor.executeWithDelay(Runnable { + NotificationHelper.showNotificationHintDialog(NotificationUgc.QUESTION) + },1000) } else if (it?.status == Status.ERROR) { val e = it.exception if (e != null && e.code() == 403) { @@ -126,6 +131,9 @@ class TagsSelectFragment : BaseFragment() { } toast("发布成功") activity?.finish() + AppExecutor.uiExecutor.executeWithDelay(Runnable { + NotificationHelper.showNotificationHintDialog(NotificationUgc.QUESTION) + },1000) } else if (it?.status == Status.ERROR){ val errorString = it.exception?.response()?.errorBody()?.string() val errorEntity = errorString?.toObject() diff --git a/app/src/main/java/com/gh/gamecenter/video/upload/view/UploadVideoActivity.kt b/app/src/main/java/com/gh/gamecenter/video/upload/view/UploadVideoActivity.kt index 1676690013..0bbd0cf98c 100644 --- a/app/src/main/java/com/gh/gamecenter/video/upload/view/UploadVideoActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/video/upload/view/UploadVideoActivity.kt @@ -25,6 +25,7 @@ import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders import com.gh.base.ToolBarActivity import com.gh.base.fragment.WaitingDialogFragment +import com.gh.common.AppExecutor import com.gh.common.util.* import com.gh.common.view.DrawableView import com.gh.gamecenter.CropImageActivity @@ -197,9 +198,11 @@ class UploadVideoActivity : ToolBarActivity() { toast("发布成功") } - NotificationHelper.showNotificationHintDialog(this, NotificationUgc.VIDEO) setResult(RESULT_CODE_VIDEO) finish() + AppExecutor.uiExecutor.executeWithDelay(Runnable { + NotificationHelper.showNotificationHintDialog(NotificationUgc.VIDEO) + }, 1000) } else if (it.status == Status.ERROR) { ErrorHelper.handleError(this@UploadVideoActivity, it.exception?.response()?.errorBody()?.string()) }