This commit is contained in:
leafwai
2022-05-31 16:09:10 +08:00
parent b340397716
commit 7995f14050
15 changed files with 164 additions and 3 deletions

View File

@ -27,6 +27,7 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
}
override fun onActivityResumed(activity: Activity) {
GlobalActivityManager.currentActivity = activity
// 判断是否需要显示或隐藏返回小浮窗
if (FloatingBackViewManager.getType().isNotEmpty()) {

View File

@ -0,0 +1,14 @@
package com.gh.base
import android.app.Activity
import java.lang.ref.WeakReference
object GlobalActivityManager {
private var mCurrentActivityWeakRef: WeakReference<Activity>? = null
var currentActivity: Activity?
get() = mCurrentActivityWeakRef?.get()
set(activity) {
mCurrentActivityWeakRef = WeakReference<Activity>(activity)
}
}

View File

@ -7,7 +7,9 @@ import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
import com.gh.base.GlobalActivityManager;
import com.gh.gamecenter.BuildConfig;
import com.gh.gamecenter.common.base.activity.BaseActivity;
import com.gh.gamecenter.common.constant.Constants;
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
import com.gh.gamecenter.common.retrofit.BiResponse;
@ -26,6 +28,7 @@ import com.lightgame.utils.Utils;
import io.reactivex.schedulers.Schedulers;
import io.sentry.Sentry;
import io.sentry.android.core.SentryAndroid;
import kotlin.Pair;
/**
* Created by LGT on 2016/6/15.
@ -68,6 +71,19 @@ public class DataUtils {
return event;
}
});
options.setBeforeBreadcrumb(((breadcrumb, hint) -> {
if ("ui.lifecycle".equals(breadcrumb.getCategory()) && "started".equals(breadcrumb.getData("state"))) {
if (GlobalActivityManager.INSTANCE.getCurrentActivity() instanceof BaseActivity) {
Pair<String, String> businessId = ((BaseActivity) GlobalActivityManager.INSTANCE.getCurrentActivity()).getBusinessId();
if (businessId != null) {
breadcrumb.setData("businessId1", businessId.component1());
breadcrumb.setData("businessId2", businessId.component2());
}
}
}
return breadcrumb;
}));
});
Sentry.configureScope(scope -> {

View File

@ -15,6 +15,8 @@ import com.gh.gamecenter.qa.comment.CommentActivity;
import com.gh.gamecenter.qa.comment.NewCommentConversationFragment;
import com.halo.assistant.fragment.comment.CommentDetailFragment;
import kotlin.Pair;
/**
* Created by khy on 2017/3/22.
*/
@ -86,4 +88,18 @@ public class CommentDetailActivity extends ToolBarActivity {
args.putParcelable(EntranceConsts.KEY_LINK, linkEntity);
return getTargetIntent(context, CommentDetailActivity.class, NewCommentConversationFragment.class, args);
}
@Override
public Pair<String, String> getBusinessId() {
CommentDetailFragment fragment = (CommentDetailFragment) getTargetFragment();
if (fragment != null) {
if (fragment.getArguments().getString(EntranceConsts.KEY_COMMENTID) != null) {
return new Pair(fragment.getArguments().getString(EntranceConsts.KEY_COMMENTID), "");
} else {
return super.getBusinessId();
}
} else {
return super.getBusinessId();
}
}
}

View File

@ -64,6 +64,7 @@ import java.util.Locale;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import kotlin.Pair;
import retrofit2.HttpException;
/**
@ -568,4 +569,15 @@ public class LibaoDetailActivity extends ToolBarActivity implements LibaoDetailA
}
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
}
@Override
public Pair<String, String> getBusinessId() {
if (mLibaoEntity != null) {
return new Pair(mLibaoEntity.getId(), "");
} else if (getIntent().getStringExtra(EntranceConsts.KEY_ID) != null) {
return new Pair(getIntent().getStringExtra(EntranceConsts.KEY_ID), "");
} else {
return super.getBusinessId();
}
}
}

View File

@ -14,6 +14,8 @@ import com.gh.gamecenter.entity.ConcernEntity;
import com.gh.gamecenter.message.MessageDetailFragment;
import com.halo.assistant.HaloApp;
import kotlin.Pair;
/**
* Created by khy on 2016/11/8.
* 消息详情界面(评论详情)
@ -77,4 +79,24 @@ public class MessageDetailActivity extends ToolBarActivity {
super.onNightModeChange();
DisplayUtils.setStatusBarColor(this, R.color.transparent, !mNightMode);
}
@Override
public Pair<String, String> getBusinessId() {
MessageDetailFragment fragment = (MessageDetailFragment) getTargetFragment();
if (fragment.getArguments() != null) {
Object concernEntity = HaloApp.get(ConcernEntity.TAG, false);
Object commentEntity = fragment.requireArguments().getParcelable(CommentEntity.TAG);
if (fragment.getArguments().getString(EntranceConsts.KEY_NEWSID) != null && commentEntity != null) {
return new Pair(((CommentEntity) commentEntity).getId(), fragment.getArguments().getString(EntranceConsts.KEY_NEWSID));
} else if (fragment.getArguments().getString(EntranceConsts.KEY_NEWSID) != null) {
return new Pair(fragment.getArguments().getString(EntranceConsts.KEY_NEWSID), "");
} else if (concernEntity != null) {
return new Pair(((ConcernEntity) concernEntity).getId(), "");
} else {
return super.getBusinessId();
}
} else {
return super.getBusinessId();
}
}
}

View File

@ -71,6 +71,7 @@ import java.util.HashSet;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import kotlin.Pair;
import retrofit2.HttpException;
@ -729,4 +730,15 @@ public class NewsDetailActivity extends DownloadToolbarActivity implements OnCli
adapter.notifyItemRangeChanged(0, adapter.getItemCount());
}
}
@Override
public Pair<String, String> getBusinessId() {
if (getIntent().getStringExtra(EntranceConsts.KEY_NEWSID) != null) {
return new Pair(getIntent().getStringExtra(EntranceConsts.KEY_NEWSID), "");
} else if (mNewsEntity != null) {
return new Pair(mNewsEntity.getId(), "");
} else {
return super.getBusinessId();
}
}
}

View File

@ -22,6 +22,14 @@ class ColumnCollectionDetailActivity : ToolBarActivity() {
updateStatusBarColor(R.color.black, R.color.white)
}
override fun getBusinessId(): Pair<String, String> {
val fragment = targetFragment as ColumnCollectionDetailFragment
return if (fragment.arguments != null) {
Pair(fragment.requireArguments().getString(EntranceConsts.KEY_COLLECTION_ID) ?: "", "")
} else {
super.getBusinessId()
}
}
companion object {
/**

View File

@ -21,6 +21,15 @@ class CommonCollectionDetailActivity : ToolBarActivity() {
updateStatusBarColor(R.color.black, R.color.white)
}
override fun getBusinessId(): Pair<String, String> {
val fragment = targetFragment as CommonCollectionDetailFragment
return if (fragment.arguments != null) {
Pair(fragment.requireArguments().getString(EntranceConsts.KEY_COLLECTION_ID) ?: "", fragment.requireArguments().getString(EntranceConsts.KEY_BLOCK_ID) ?: "")
} else {
super.getBusinessId()
}
}
companion object {
fun getIntent(

View File

@ -3,9 +3,9 @@ package com.gh.gamecenter.gamecollection.detail
import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.gh.gamecenter.common.base.activity.ToolBarActivity
import com.gh.common.util.GameCollectionSquareBrowseTaskHelper
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.activity.ToolBarActivity
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.gamecollection.square.GameCollectionSquareActivity
@ -26,6 +26,15 @@ class GameCollectionDetailActivity : ToolBarActivity() {
)
}
override fun getBusinessId(): Pair<String, String> {
val fragment = targetFragment as GameCollectionDetailFragment
return if (fragment.arguments != null) {
Pair(fragment.requireArguments().getString(EntranceConsts.KEY_GAME_COLLECTION_ID) ?: "", "")
} else {
super.getBusinessId()
}
}
companion object {
@JvmStatic
fun getIntent(

View File

@ -11,16 +11,16 @@ import androidx.core.content.ContextCompat
import androidx.core.widget.doOnTextChanged
import androidx.lifecycle.ViewModelProviders
import androidx.recyclerview.widget.RecyclerView
import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment
import com.gh.common.exposure.ExposureManager
import com.gh.common.util.*
import com.gh.common.util.NewLogUtils
import com.gh.gamecenter.common.view.VerticalItemDecoration
import com.gh.download.DownloadManager
import com.gh.gamecenter.R
import com.gh.gamecenter.baselist.ListActivity
import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.common.view.VerticalItemDecoration
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.core.utils.KeyboardHeightObserver
import com.gh.gamecenter.core.utils.KeyboardHeightProvider
@ -411,4 +411,11 @@ class RatingReplyActivity : ListActivity<RatingReplyEntity, RatingReplyViewModel
}
}
override fun getBusinessId(): Pair<String, String> {
return if (intent.getStringExtra(EntranceConsts.KEY_COMMENTID) != null) {
Pair(intent.getStringExtra(EntranceConsts.KEY_COMMENTID) ?: "", "")
} else {
super.getBusinessId()
}
}
}

View File

@ -71,6 +71,14 @@ class CommentLogsActivity : ListActivity<RatingComment, NormalListViewModel<Rati
}
}
override fun getBusinessId(): Pair<String, String> {
return if (intent.getStringExtra(EntranceConsts.KEY_GAMEID) != null && intent.getStringExtra(EntranceConsts.KEY_COMMENTID) != null) {
Pair(intent.getStringExtra(EntranceConsts.KEY_GAMEID) ?: "", intent.getStringExtra(EntranceConsts.KEY_COMMENTID) ?: "")
} else {
super.getBusinessId()
}
}
companion object {
fun getIntent(context: Context, gameId: String, commentId: String): Intent {
val intent = Intent(context, CommentLogsActivity::class.java)

View File

@ -26,6 +26,15 @@ class HelpDetailActivity : ToolBarActivity() {
}
}
override fun getBusinessId(): Pair<String, String> {
val helpEntity = intent.getParcelableExtra<HelpEntity>(HelpEntity::class.java.simpleName)
return if (helpEntity != null) {
Pair(helpEntity.id, "")
} else {
super.getBusinessId()
}
}
companion object {
fun getIntent(context: Context, entity: HelpEntity): Intent {
val intent = Intent(context, HelpDetailActivity::class.java)

View File

@ -5,7 +5,9 @@ import android.content.Intent
import android.os.Bundle
import com.gh.gamecenter.common.base.activity.ToolBarActivity
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.gamecollection.detail.GameCollectionDetailFragment
import com.gh.gamecenter.gamecollection.detail.conversation.GameCollectionCommentConversationFragment
import com.gh.gamecenter.gamedetail.GameDetailFragment
import com.gh.gamecenter.qa.comment.conversation.CommentConversationFragment
class NewCommentDetailActivity : ToolBarActivity() {
@ -21,6 +23,14 @@ class NewCommentDetailActivity : ToolBarActivity() {
}
}
override fun getBusinessId(): Pair<String, String> {
return if (targetFragment.arguments != null) {
Pair(targetFragment.requireArguments().getString(EntranceConsts.KEY_COMMENT_ID) ?: "", "")
} else {
super.getBusinessId()
}
}
companion object {
@JvmStatic

View File

@ -40,6 +40,14 @@ class ForumVideoDetailActivity : BaseActivity() {
override fun isAutoResetViewBackgroundEnabled(): Boolean = true
override fun getBusinessId(): Pair<String, String> {
return if (containerFragment?.arguments != null) {
Pair(containerFragment?.requireArguments()?.getString(EntranceConsts.KEY_VIDEO_ID) ?: "", "")
} else {
super.getBusinessId()
}
}
companion object {
const val VIDEO_PATCH_REQUEST = 100