Files
assistant-android/app/src/main/java/com/gh/common/util/DirectUtils.kt
chenjuntao 1cf49b931e Merge remote-tracking branch 'origin/release' into dev
# Conflicts:
#	dependencies.gradle
2023-12-14 17:03:14 +08:00

2149 lines
73 KiB
Kotlin
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.gh.common.util
import android.annotation.SuppressLint
import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.text.TextUtils
import androidx.appcompat.app.AppCompatActivity
import com.alibaba.android.arouter.launcher.ARouter
import com.gh.common.constant.Config
import com.gh.common.exposure.ExposureManager.log
import com.gh.common.exposure.ExposureTraceUtils.appendTrace
import com.gh.common.util.EntranceUtils.jumpActivity
import com.gh.common.util.EntranceUtils.jumpActivityCompat
import com.gh.gamecenter.*
import com.gh.gamecenter.amway.AmwayActivity
import com.gh.gamecenter.catalog.CatalogActivity
import com.gh.gamecenter.category.CategoryDirectoryActivity
import com.gh.gamecenter.category2.CategoryV2Activity
import com.gh.gamecenter.common.base.activity.BaseActivity
import com.gh.gamecenter.common.base.activity.BaseActivity_TabLayout
import com.gh.gamecenter.common.base.activity.ToolBarActivity
import com.gh.gamecenter.common.base.fragment.BaseFragment_TabLayout
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.constant.EntranceConsts.*
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.entity.*
import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.provider.IQGameProvider
import com.gh.gamecenter.core.runOnIoThread
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.discovery.DiscoveryActivity
import com.gh.gamecenter.download.DownloadFragment.Companion.INDEX_UPDATE
import com.gh.gamecenter.entity.GameCollectionListEntity
import com.gh.gamecenter.entity.SubjectData
import com.gh.gamecenter.entity.SubjectRecommendEntity
import com.gh.gamecenter.entity.VideoLinkEntity
import com.gh.gamecenter.eventbus.EBSkip
import com.gh.gamecenter.feature.entity.GameDetailServer
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.LibaoEntity
import com.gh.gamecenter.feature.entity.MeEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.ExposureEvent.Companion.createEvent
import com.gh.gamecenter.feature.exposure.ExposureType
import com.gh.gamecenter.feature.provider.IConcernInfoProvider
import com.gh.gamecenter.forum.detail.ForumDetailActivity
import com.gh.gamecenter.forum.home.CommunityHomeFragment
import com.gh.gamecenter.forum.search.ForumOrUserSearchActivity
import com.gh.gamecenter.fragment.MainWrapperFragment
import com.gh.gamecenter.game.columncollection.detail.ColumnCollectionDetailActivity
import com.gh.gamecenter.game.commoncollection.detail.CommonCollectionDetailActivity
import com.gh.gamecenter.game.upload.GameSubmissionActivity
import com.gh.gamecenter.gamecollection.detail.GameCollectionDetailActivity
import com.gh.gamecenter.gamecollection.hotlist.GameCollectionHotListActivity
import com.gh.gamecenter.gamecollection.hotlist.GameCollectionListDetailActivity
import com.gh.gamecenter.gamecollection.square.GameCollectionSquareActivity
import com.gh.gamecenter.gamedetail.GameDetailFragment
import com.gh.gamecenter.gamedetail.fuli.kaifu.ServersCalendarActivity
import com.gh.gamecenter.gamedetail.fuli.kaifu.ServersCalendarManagementActivity
import com.gh.gamecenter.gamedetail.fuli.kaifu.ServersSubscribedGameListActivity
import com.gh.gamecenter.gamedetail.history.HistoryApkListActivity
import com.gh.gamecenter.gamedetail.rating.RatingReplyActivity
import com.gh.gamecenter.help.HelpAndFeedbackBridge
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.personalhome.UserHomeActivity
import com.gh.gamecenter.personalhome.background.PersonalityBackgroundActivity
import com.gh.gamecenter.personalhome.border.AvatarBorderActivity
import com.gh.gamecenter.personalhome.home.UserHistoryViewModel
import com.gh.gamecenter.qa.answer.detail.SimpleAnswerDetailActivity
import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity
import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity
import com.gh.gamecenter.qa.subject.CommunitySubjectActivity
import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
import com.gh.gamecenter.qgame.QGameHomeWrapperActivity
import com.gh.gamecenter.qgame.QGameSearchActivity
import com.gh.gamecenter.qgame.QGameViewModel
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.servers.GameServerTestActivity
import com.gh.gamecenter.servers.GameServersActivity
import com.gh.gamecenter.servers.gametest2.GameServerTestV2Activity
import com.gh.gamecenter.setting.SettingBridge
import com.gh.gamecenter.subject.SubjectActivity
import com.gh.gamecenter.tag.TagsActivity
import com.gh.gamecenter.toolbox.ToolBoxBlockActivity
import com.gh.gamecenter.video.data.VideoDataActivity
import com.gh.gamecenter.video.detail.VideoDetailActivity
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel
import com.gh.gamecenter.video.game.GameVideoActivity
import com.gh.gamecenter.video.videomanager.VideoManagerActivity
import com.gh.vspace.VDownloadManagerActivity
import com.halo.assistant.HaloApp
import com.halo.assistant.fragment.WebFragment
import com.lightgame.utils.Utils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import org.greenrobot.eventbus.EventBus
import retrofit2.HttpException
import java.net.URLEncoder
import java.util.*
import kotlin.math.roundToInt
/**
* 跳转用的方法
*/
object DirectUtils {
@JvmStatic
fun directToLinkPage(context: Context, linkEntity: LinkEntity, entrance: String, path: String) {
directToLinkPage(context, linkEntity, entrance, path, null)
}
@JvmStatic
fun directToLinkPage(
context: Context,
linkEntity: LinkEntity,
entrance: String,
path: String,
exposureEvent: ExposureEvent? = null
) {
directToLinkPage(context, linkEntity, entrance, path, exposureEvent, null)
}
// 用于判断是否已经对接相关类型
var directLinkTypes = arrayOf(
"article", "news",
"game",
"column",
"question",
"answer",
"community",
"community_article",
"community_column",
"community_special_column",
"web", "inurl",
"qq", "QQ",
"qqqun",
"tag",
"all_community_article",
"category",
"block",
"column_collection",
"server",
"top_game_comment",
"wechat_bind",
"video",
"catalog",
"category_v2",
"common_collection",
"game_list",
"game_list_detail",
"bbs_video",
"explore_column",
"game_explore",
"column_test_v2",
"game_list_collection"
)
fun directToLinkPage(
context: Context,
linkEntity: LinkEntity,
entrance: String,
path: String,
exposureEvent: ExposureEvent? = null,
unknownCallback: (() -> Unit)?,
) {
when (linkEntity.type) {
"article", "news", "文章" -> {
NewsUtils.statNewsViews(linkEntity.link) // 统计阅读量
directToArticle(
context, linkEntity.link
?: "", BaseActivity.mergeEntranceAndPath(entrance, path)
)
}
"game", "游戏" -> {
if (exposureEvent != null) {
directToGameDetail(
context, linkEntity.link
?: "", BaseActivity.mergeEntranceAndPath(entrance, path), traceEvent = exposureEvent
)
} else {
directToGameDetail(
context,
linkEntity.link ?: "",
entrance = BaseActivity.mergeEntranceAndPath(entrance, path)
)
}
}
"game_server_calendar" -> directToGameServerCalendar(context, linkEntity.link)
"column", "游戏专题" -> directToSubject(
context, linkEntity.link
?: "", linkEntity.text, BaseActivity.mergeEntranceAndPath(entrance, path), exposureEvent
)
"question", "社区问题" -> directToQuestionDetail(
context, linkEntity.link
?: "", entrance, path
)
"answer", "社区回答" -> directToAnswerDetail(context, linkEntity.link ?: "", entrance, path)
"community", "问答社区" -> {
if (linkEntity.link.isNullOrEmpty()) return
directToCommunity(context, CommunityEntity(linkEntity.link!!, linkEntity.text!!))
}
"community_article", "社区文章" -> directToCommunityArticle(
context,
linkEntity.community!!,
linkEntity.link!!,
entrance,
path
)
"community_column", "社区专题" -> directToCommunityColumn(
context,
linkEntity.community,
linkEntity.link!!,
entrance,
path
)
HOST_WEB, HOST_WEB_INURL, HOST_WEB_AL -> {
when {
linkEntity.link!!.contains("v.douyin") && PackageHelper.localPackageNameSet.contains("com.ss.android.ugc.aweme") -> {
directDouyin(context, "1402577827140941")
}
else -> directToWebView(
context,
url = linkEntity.link!!,
entrance = BaseActivity.mergeEntranceAndPath(entrance, path)
)
}
}
"qq", "QQ" -> directToQqConversation(context, linkEntity.link)
"outurl" -> directToExternalBrowser(context, linkEntity.link!!)
"qqqun", "QQ群" -> directToQqGroup(context, linkEntity.link!!)
"tag" -> context.startActivity(
TagsActivity.getIntent(
context,
linkEntity.text!!,
linkEntity.title,
entrance,
path,
exposureEvent?.source
)
)
"category", "分类" -> directCategoryDirectory(context, linkEntity.link!!, linkEntity.text!!)
"catalog" -> directCatalog(context, linkEntity.link!!, linkEntity.text!!, entrance, path)
"category_v2" -> directCategoryV2(
context,
linkEntity.link!!,
linkEntity.text!!,
entrance,
path,
exposureEvent
)
"block", "版块" -> {
if (linkEntity.link.isNullOrEmpty()) return
directToBlock(
context,
SubjectRecommendEntity(
link = linkEntity.link,
text = linkEntity.text,
name = linkEntity.name,
display = linkEntity.display ?: Display()
),
entrance,
exposureEvent
)
}
"column_collection", "专题合集" -> directToColumnCollection(
context,
linkEntity.link!!,
-1,
entrance,
"",
linkEntity.blockId,
linkEntity.blockName,
exposureEvent
)
"server", "game_server", "开服表" -> directToGameServers(context, entrance, path, exposureEvent)
"top_game_comment" -> directToAmway(context, null, entrance, path)
"wechat_bind" -> context.startActivity(WebActivity.getBindWechatIntent(context))
"video", "bbs_video", "video_stream", "视频" -> directToVideoDetail(
context,
videoId = linkEntity.link!!,
fromLocation = VideoDetailContainerViewModel.Location.VIDEO_CHOICENESS.value,
entrance = entrance,
path = path
)
"game_video" -> directToGameVideo(context, linkEntity.link ?: "", entrance, path)
"libao", "礼包" -> directToGiftDetail(context, linkEntity.link ?: "", entrance)
"feedback" -> directToFeedback(context, linkEntity.name, false, "", false, false, entrance)
"qa", "qa_content", "Q&A" -> directToQa(context, linkEntity.text ?: "", linkEntity.link ?: "")
"qa_list" -> directToHelpAndFeedback(context)
"qa_collection", "Q&A合集" -> directToQaCollection(
context, linkEntity.text
?: "", linkEntity.link
?: ""
)
"anliwall", "安利墙" -> directToAmway(
context,
fixedTopAmwayCommentId = null,
entrance = entrance,
path = path
)
"game_detail_comment" -> directToGameDetail(context, linkEntity.link ?: "", entrance)
"game_upload", "游戏投稿" -> directGameUpload(context, entrance, path)
"bbs_detail" -> directForumDetail(context, linkEntity.link ?: "", entrance)
"bbs_section" -> directForumDetailSection(
context,
linkEntity.community?.id,
linkEntity.link ?: "",
entrance
)
"mobile_bind" -> {
CheckLoginUtils.checkLogin(context, entrance) {
context.startActivity(SettingBridge.getBindPhoneNormalIntent(context, false))
}
}
"authentication" -> {
context.startActivity(ShellActivity.getIntent(context, ShellActivity.Type.REAL_NAME_INFO, null))
}
"user_background" -> {
CheckLoginUtils.checkLogin(context, entrance) {
context.startActivity(PersonalityBackgroundActivity.getIntent(context))
}
}
"avatar_frame" -> {
CheckLoginUtils.checkLogin(context, entrance) {
context.startActivity(AvatarBorderActivity.getIntent(context))
}
}
"badge" -> {
CheckLoginUtils.checkLogin(context, entrance) {
UserManager.getInstance().userInfoEntity?.run {
directToBadgeWall(context, userId, name, icon)
}
}
}
"etiquette_exam" -> directToRegulationTestPage(context)
"setting" -> context.startActivity(SettingBridge.getSettingIntent(context, false, entrance))
"index_page" -> directToHomeTab(context)
"video_upload" -> context.startActivity(VideoManagerActivity.getIntent(context, "", entrance))
"bbs" -> directToForum(context)
"user_page" -> directToHomeActivity(context, UserManager.getInstance().userId, "", entrance)
"video_tab" -> directToVideoTab(context)
"toolkit" -> context.startActivity(ToolBoxBlockActivity.getIntent(context, entrance))
"column_test" -> context.startActivity(
GameServerTestActivity.getIntent(
context, linkEntity.link
?: "", linkEntity.text ?: "", entrance, exposureEvent
)
)
"toolkit_detail" -> {
linkEntity.toolkit?.run {
if (url != null && url!!.contains(Config.URL_ARTICLE)) {
val newsId = url!!.substring(url!!.lastIndexOf("/") + 1, url!!.length - 5) // 5: ".html"
val intent = NewsDetailActivity.getIntentById(context, newsId, entrance)
context.startActivity(intent)
} else {
context.startActivity(WebActivity.getWebByCollectionTools(context, this, false))
}
} ?: ""
}
"halo_tab" -> directToPersonalTab(context)
"common_collection" -> directToCommonCollectionDetail(
context,
linkEntity.link ?: "",
linkEntity.blockId,
linkEntity.blockName,
entrance
)
//"h5_game_center" -> directLetoGameCenter(context)
"game_list" -> directToGameCollectionSquare(context, entrance, traceEvent = exposureEvent)
"game_list_detail" -> directToGameCollectionDetail(
context,
linkEntity.link ?: "",
entrance,
traceEvent = exposureEvent
)
"explore_column", "game_explore" -> context.startActivity(
DiscoveryActivity.getIntent(
context,
entrance,
exposureEvent
)
)
"column_test_v2" -> context.startActivity(
GameServerTestV2Activity.getIntent(
context,
entrance,
exposureEvent
)
)
"qq_mini_game_column" -> directToQGameHome(context)
"game_list_collection" -> directToGameCollectionListDetail(
context,
linkEntity.link ?: "",
linkEntity.text ?: "",
linkEntity.explain,
entrance
)
"" -> {
// do nothing
}
else -> {
if (unknownCallback != null) {
unknownCallback.invoke()
} else {
DialogHelper.showUpgradeDialog(context)
}
}
}
}
/**
* 跳转至QA请不要随意修改方法名
*/
@JvmStatic
fun directToQa(context: Context, text: String? = "", id: String) {
if (id.isEmpty()) return
val destination = RouteConsts.activity.qaActivity.toDestinationClass()
val bundle = Bundle()
bundle.putString(KEY_TO, destination?.name ?: "")
bundle.putString(KEY_NAVIGATION_TITLE, text)
bundle.putString(KEY_QA_ID, id)
jumpActivity(context, bundle)
}
/**
* 跳转至QA合集请不要随意修改方法名
*/
@JvmStatic
fun directToQaCollection(context: Context, text: String, id: String) {
if (id.isEmpty()) return
val destination = RouteConsts.activity.qaActivity.toDestinationClass()
val bundle = Bundle()
bundle.putString(KEY_TO, destination?.name ?: "")
bundle.putString(KEY_NAVIGATION_TITLE, text)
bundle.putString(KEY_QA_COLLECTION_ID, id)
jumpActivity(context, bundle)
}
/**
* 跳转至专题合集
*/
@JvmStatic
fun directToColumnCollection(
context: Context,
id: String,
position: Int = -1,
entrance: String,
columnName: String = "",
blockId: String = "",
blockName: String = "",
exposureEvent: ExposureEvent? = null
) {
if (id.isEmpty()) return
val bundle = Bundle()
bundle.putString(KEY_TO, ColumnCollectionDetailActivity::class.java.name)
bundle.putString(KEY_ENTRANCE, entrance)
bundle.putString(KEY_COLLECTION_ID, id)
bundle.putString(KEY_COLUMNNAME, columnName)
bundle.putString(KEY_BLOCK_ID, blockId)
bundle.putString(KEY_BLOCK_NAME, blockName)
bundle.putInt(KEY_POSITION, position)
if (exposureEvent != null) {
bundle.putParcelableArrayList(EntranceConsts.KEY_EXPOSURE_SOURCE_LIST, ArrayList(exposureEvent.source))
}
jumpActivity(context, bundle)
}
/**
* 跳转至资讯文章列表
*/
@JvmStatic
fun directToGameNews(context: Context, gameId: String?, gameName: String?, entrance: String?) {
val bundle = Bundle()
bundle.putString(KEY_TO, GameNewsActivity::class.java.name)
bundle.putString(KEY_ENTRANCE, entrance)
bundle.putString(KEY_GAMEID, gameId)
bundle.putString(KEY_GAMENAME, gameName)
jumpActivity(context, bundle)
}
/**
* 跳转至游戏日历表
*/
@JvmStatic
fun directToGameServerCalendar(context: Context, gameId: String?, kaifuTime: Long = 0) {
val bundle = Bundle()
bundle.putString(KEY_TO, ServersCalendarActivity::class.java.name)
bundle.putParcelable(GameEntity::class.java.simpleName, GameEntity().apply {
id = gameId ?: ""
})
bundle.putLong(KEY_KAIFU_TIME, kaifuTime)
bundle.putParcelable(GameDetailServer::class.java.simpleName, GameDetailServer())
bundle.putParcelable(MeEntity::class.java.simpleName, MeEntity())
jumpActivity(context, bundle)
}
/**
* 跳转至游戏历史版本页面
*/
@JvmStatic
fun directToHistoryApk(context: Context, gameId: String?) {
val bundle = Bundle()
bundle.putString(KEY_TO, HistoryApkListActivity::class.java.name)
bundle.putString(KEY_GAMEID, gameId)
jumpActivity(context, bundle)
}
/**
* 跳转到新闻详情
*/
@JvmStatic
fun directToArticle(context: Context, id: String, entrance: String? = null) {
if (id.isEmpty()) return
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_TO, NewsDetailActivity::class.java.simpleName)
bundle.putString(KEY_NEWSID, id)
if (entrance?.contains("隐私政策") == true) {
bundle.putBoolean(KEY_HIDE_USELESS_INFO, true)
}
jumpActivity(context, bundle)
}
/**
* 跳转到新闻详情
*/
@JvmStatic
fun directToArticle(context: Context, id: String, hideUselessInfo: Boolean, entrance: String? = null) {
if (id.isEmpty()) return
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_TO, NewsDetailActivity::class.java.simpleName)
bundle.putString(KEY_NEWSID, id)
bundle.putBoolean(KEY_HIDE_USELESS_INFO, hideUselessInfo)
jumpActivity(context, bundle)
}
/**
* 跳转至个人主页
*/
@JvmStatic
fun directToHomeActivity(context: Context, userId: String?, entrance: String? = null, path: String? = null) {
context.startActivity(UserHomeActivity.getIntent(context, userId ?: "", entrance, path))
}
@JvmStatic
fun directToRealName(context: Context) {
context.startActivity(ShellActivity.getIntent(context, ShellActivity.Type.REAL_NAME_INFO, null))
}
/**
* 跳转至个人主页
* @param position 定位到某个tab 0游戏 1发布
*/
@JvmStatic
fun directToHomeActivity(
context: Context,
userId: String?,
position: Int,
entrance: String? = null,
path: String? = null
) {
directToHomeActivity(context, userId, "", "", position, entrance, path)
}
/**
* 跳转至个人主页
* @param position 定位到某个tab 0游戏 1发布
* @param type 类型 (发布)
* @param gameType 类型 (游戏)
*/
@JvmStatic
fun directToHomeActivity(
context: Context,
userId: String? = "",
type: String? = "",
gameType: String? = "",
position: Int? = 0,
entrance: String? = null,
path: String? = null
) {
IntegralLogHelper.log("view_homepage", "个人主页")
val bundle = Bundle()
bundle.putString(KEY_USER_ID, userId)
bundle.putString(KEY_TO, UserHomeActivity::class.java.name)
bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
bundle.putString(KEY_PATH, path)
bundle.putString(KEY_TYPE, UserHistoryViewModel.TYPE.fromValue(type).value)
bundle.putString(KEY_GAME, gameType)
bundle.putInt(KEY_POSITION, position ?: 0)
jumpActivity(context, bundle)
}
/**
* 回到首页
*/
fun directToMainActivity(context: Context) {
val intent = Intent(context, MainActivity::class.java).apply { flags = Intent.FLAG_ACTIVITY_CLEAR_TOP }
context.startActivity(intent)
}
/**
* 跳转到游戏详情
*/
@JvmStatic
fun directToGameDetail(
context: Context,
id: String,
entrance: String? = null,
autoDownload: Boolean? = null,
tab: String? = "",
traceEvent: ExposureEvent? = null
) {
if (id.isEmpty()) return
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_TO, GameDetailActivity::class.java.simpleName)
bundle.putString(KEY_GAMEID, id)
if (!TextUtils.isEmpty(tab)) {
when (tab) {
"comment" -> bundle.putString(KEY_TARGET, GameDetailFragment.TAB_RATING)
"desc" -> bundle.putString(KEY_TARGET, GameDetailFragment.TAB_DESC)
"forum" -> bundle.putString(KEY_TARGET, GameDetailFragment.TAB_BBS)
"zone" -> bundle.putString(KEY_TARGET, GameDetailFragment.TAB_TRENDS)
}
}
if (traceEvent != null) {
val clickEvent = createEvent(GameEntity(id), traceEvent.source, appendTrace(traceEvent), ExposureType.CLICK)
log(clickEvent)
bundle.putParcelable(KEY_TRACE_EVENT, clickEvent)
}
bundle.putBoolean(KEY_AUTO_DOWNLOAD, autoDownload ?: false)
jumpActivity(context, bundle)
}
/**
* 跳转到游戏评分详情
*/
@JvmStatic
fun directToGameRatingDetail(
context: Context,
gameId: String? = "",
commentId: String? = "",
entrance: String? = null
) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_GAMEID, gameId)
bundle.putString(KEY_COMMENTID, commentId)
bundle.putString(KEY_TO, RatingReplyActivity::class.java.name)
jumpActivity(context, bundle)
}
/**
* 跳转视频流-游戏介绍进入
*/
@JvmStatic
fun directToGameDetailVideoStreaming(context: Context, id: String, entrance: String? = null) {
val bundle = Bundle()
bundle.putString(KEY_TO, GameVideoActivity::class.java.name)
bundle.putString(KEY_ENTRANCE, entrance)
bundle.putString(KEY_GAMEID, id)
bundle.putBoolean(KEY_OPEN_VIDEO_STREAMING, true)
bundle.putString(KEY_TARGET, GameDetailFragment.TAB_DESC)
jumpActivity(context, bundle)
}
@JvmStatic
fun directToGameDetail(
context: Context,
id: String,
defaultTab: String = GameDetailFragment.TAB_DESC,
entrance: String? = null
) {
val bundle = Bundle()
bundle.putString(KEY_TO, GameDetailActivity::class.java.name)
bundle.putString(KEY_ENTRANCE, entrance)
bundle.putString(KEY_GAMEID, id)
bundle.putString(KEY_TARGET, defaultTab)
jumpActivity(context, bundle)
}
// 专栏
@JvmStatic
fun directToSubject(
context: Context,
id: String,
subjectName: String? = "",
entrance: String? = null,
exposureEvent: ExposureEvent? = null,
isQQMiniGame: Boolean = false,
) {
if (id.isEmpty()) return
val bundle = Bundle()
val subjectData =
SubjectData(subjectId = id, subjectName = subjectName, isOrder = false, isQQMiniGame = isQQMiniGame)
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_TO, SubjectActivity::class.java.name)
bundle.putParcelable(EntranceConsts.KEY_SUBJECT_DATA, subjectData)
if (exposureEvent != null) bundle.putParcelableArrayList(
KEY_EXPOSURE_SOURCE_LIST,
ArrayList(exposureEvent.source)
)
jumpActivity(context, bundle)
}
// 反馈
@JvmStatic
fun directToFeedback(context: Context, content: String? = null, entrance: String? = null) {
directToFeedback(context, content, false, "", false, false, entrance)
}
@JvmStatic
fun directToFeedback(
context: Context,
content: String? = null,
isQaFeedback: Boolean = false,
qaContentId: String? = "",
isPlugin: Boolean = false,
isSmoothGame: Boolean = false,
entrance: String? = null
) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putBoolean(KEY_PLUGIN, isPlugin)
bundle.putBoolean(KEY_SMOOTH_GAME, isSmoothGame)
if (isPlugin) {
bundle.putString(KEY_HIDE_SUGGEST_HINT, "【插件问题】")
}
if (isSmoothGame) {
bundle.putString(KEY_HIDE_SUGGEST_HINT, "【畅玩问题】")
}
if (isQaFeedback) {
bundle.putBoolean(KEY_IS_QA_FEEDBACK, true)
bundle.putString(KEY_QA_CONTENT_ID, qaContentId)
} else {
bundle.putString(KEY_CONTENT, content)
}
context.startActivity(HelpAndFeedbackBridge.getSuggestionCategoryIntent(context, bundle))
}
/**
* 跳转至使用帮助与反馈,请不要随意修改方法名
*/
@JvmStatic
fun directToHelpAndFeedback(
context: Context,
content: String? = null,
isQaFeedback: Boolean = false,
qaContentId: String? = "",
isPlugin: Boolean = false,
isSmoothGame: Boolean = false,
entrance: String? = null
) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putBoolean(KEY_PLUGIN, isPlugin)
bundle.putBoolean(KEY_SMOOTH_GAME, isSmoothGame)
if (isPlugin) {
bundle.putString(KEY_HIDE_SUGGEST_HINT, "【插件问题】")
}
if (isSmoothGame) {
bundle.putString(KEY_HIDE_SUGGEST_HINT, "【畅玩问题】")
}
if (isQaFeedback) {
bundle.putBoolean(KEY_IS_QA_FEEDBACK, true)
bundle.putString(KEY_QA_CONTENT_ID, qaContentId)
} else {
bundle.putString(KEY_CONTENT, content)
}
directToHelpAndFeedback(context, bundle)
}
@JvmStatic
fun directToDownloadManager(context: Context, entrance: String? = null) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_TO, DownloadManagerActivity.TAG)
jumpActivity(context, bundle)
}
@JvmStatic
fun directToDownloadManagerAndStartUpdate(
context: Context,
gameId: String? = "",
packageName: String? = "",
entrance: String? = null
) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_TO, DownloadManagerActivity.TAG)
bundle.putString(KEY_GAMEID, gameId)
bundle.putString(KEY_PACKAGENAME, packageName)
bundle.putInt(BaseFragment_TabLayout.PAGE_INDEX, INDEX_UPDATE)
jumpActivityCompat(context, bundle)
}
@JvmStatic
fun directToToolbox(context: Context, gameId: String, toolboxUrl: String, entrance: String = ENTRANCE_BROWSER) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance)
bundle.putString(KEY_TO, ToolBoxBlockActivity::class.java.name)
bundle.putString(KEY_GAMEID, gameId)
bundle.putString(KEY_URL, toolboxUrl)
jumpActivity(context, bundle)
}
@JvmStatic
fun directToAnswerDetail(context: Context, id: String, entrance: String? = null, path: String? = null) {
if (id.isEmpty()) return
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_TO, SimpleAnswerDetailActivity::class.java.name)
bundle.putString(KEY_PATH, path)
bundle.putString(KEY_ANSWER_ID, id)
jumpActivity(context, bundle)
}
@JvmStatic
fun directToQuestionDetail(context: Context, id: String, entrance: String? = null, path: String? = null) {
if (id.isEmpty()) return
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_TO, NewQuestionDetailActivity::class.java.name)
bundle.putString(KEY_PATH, path)
bundle.putString(KEY_QUESTIONS_ID, id)
jumpActivity(context, bundle)
}
@JvmStatic
fun directToWebView(context: Context, url: String, entrance: String? = null) {
if (url.isEmpty()) return
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
if (url.contains("android_page_type=singleton")) {
bundle.putString(KEY_TO, SingletonWebActivity::class.java.simpleName)
} else {
bundle.putString(KEY_TO, WebActivity::class.java.simpleName)
}
if (url.contains("leave_web_page_handle_back_pressed=true")) {
bundle.putBoolean(WebFragment.KEY_LEAVE_WEB_PAGE_TO_HANDLE_BACK_PRESSED, true)
}
bundle.putString(EntranceConsts.KEY_URL, url)
jumpActivity(context, bundle)
}
@JvmStatic
fun directToExternalBrowser(context: Context, url: String) {
try {
if (url.isEmpty()) return
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(Uri.decode(url)))
if (context !is AppCompatActivity) {
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
context.startActivity(browserIntent)
} catch (e: Exception) {
e.printStackTrace()
url.copyTextAndToast(context.getString(R.string.direct_to_external_browser_failed_toast))
}
}
// 跳转 QQqqNumber 为空选择默认客服 QQ
@JvmStatic
fun directToQqConversation(context: Context, qqNumber: String? = null) {
var qq = qqNumber
if (TextUtils.isEmpty(qq)) {
qq = Config.getSettings()?.support?.qq ?: "3509629529"
}
if (ShareUtils.isQQClientAvailable(context)) {
// 安装了 QQ 直接调用QQ打开手机QQ进行会话 默认 QQ 号3509629529
val chatType: String
if (qq!!.startsWith("400") || qq.startsWith("800")) {
chatType = "crm"
} else {
chatType = "wpa"
}
val str = "mqqwpa://im/chat?chat_type=$chatType&uin=$qq&version=1&src_type=web"
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(str))
if (context !is AppCompatActivity) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
try {
context.startActivity(intent)
} catch (e: ActivityNotFoundException) {
ToastUtils.toast("无法跳转至QQ请稍后再试")
}
} else {
// 没有安装QQ 复制账号
qq?.copyTextAndToast("已复制 QQ $qq")
}
}
// 跳转 QQ 群
@JvmStatic
fun directToQqGroup(context: Context, groupNumber: String? = null): Boolean {
if (groupNumber.isNullOrEmpty()) return false
if (ShareUtils.isQQClientAvailable(context)) {
val intent = Intent()
intent.data =
Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D$groupNumber")
// 此Flag可根据具体产品需要自定义如设置则在加群界面按返回返回手Q主界面不设置按返回会返回到呼起产品界面 //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
return try {
if (context !is AppCompatActivity) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
context.startActivity(intent)
true
} catch (e: Exception) {
false
}
} else {
Utils.toast(context, "请安装QQ客户端")
return false
}
}
/**
* 跳转到 礼包详情
*/
@JvmStatic
fun directToGiftDetail(context: Context, giftId: String, entrance: String? = null) {
if (giftId.isEmpty()) return
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_TO, LibaoDetailActivity::class.java.simpleName)
bundle.putString(EntranceConsts.KEY_ID, giftId)
HaloApp.put(LibaoEntity.TAG, null)
jumpActivity(context, bundle)
}
/**
* 跳转到礼包中心,请不要随意修改方法名
*/
@JvmStatic
fun directToGift(context: Context, entrance: String) {
val intent = LibaoActivity.getIntent(context, entrance)
context.startActivity(intent)
}
/**
* 切换到社区页面(旧社区页面已经没有了,处理为跳转到论坛详情)
*/
@JvmStatic
fun directToCommunity(context: Context, community: CommunityEntity?) {
// if (MainActivity::class.java.name != RunningUtils.getTopActivity(context)) {
// val intent = Intent(context, MainActivity::class.java)
// intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
// context.startActivity(intent)
//
// UserManager.getInstance().setCommunityData(community)
//
// // 这里换个线程操作是为了做一点延时
// AppExecutor.ioExecutor.execute {
// EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_BBS))
// EventBus.getDefault().post(EBReuse(CommunityFragment.EB_RETRY_PAGE))
// }
// } else {
directForumDetail(context, community?.id)
// }
}
@JvmStatic
fun directToCommunityArticle(
context: Context,
articleId: String?,
communityId: String?,
entrance: String?,
path: String?
) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_PATH, path)
bundle.putString(KEY_TO, ArticleDetailActivity::class.java.name)
bundle.putString(KEY_COMMUNITY_ARTICLE_ID, articleId)
bundle.putParcelable(KEY_COMMUNITY_DATA, CommunityEntity(id = communityId!!))
jumpActivity(context, bundle)
}
@JvmStatic
fun directToCommunityArticle(
context: Context,
community: CommunityEntity?,
articleId: String?,
entrance: String?,
path: String?
) {
if (articleId.isNullOrEmpty()) return
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_PATH, path)
bundle.putString(KEY_TO, ArticleDetailActivity::class.java.name)
bundle.putString(KEY_COMMUNITY_ARTICLE_ID, articleId)
bundle.putParcelable(KEY_COMMUNITY_DATA, community)
jumpActivity(context, bundle)
}
/**
* 跳转到社区专题
*/
@JvmStatic
fun directToCommunityColumn(
context: Context,
community: CommunityEntity?,
subjectId: String,
entrance: String?,
path: String?
) {
if (subjectId.isEmpty()) return
val bundle = Bundle()
bundle.putString(KEY_PATH, path)
bundle.putString(KEY_TO, CommunitySubjectActivity::class.java.name)
bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
bundle.putString(KEY_COLUMN_ID, subjectId)
bundle.putParcelable(KEY_COMMUNITY_DATA, community)
jumpActivity(context, bundle)
}
@JvmStatic
fun directToVideoDetail(
context: Context, videoId: String,
entrance: String? = null,
path: String? = ""
) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_TO, ForumVideoDetailActivity::class.java.name)
bundle.putString(KEY_VIDEO_ID, videoId);
bundle.putString(KEY_PATH, path)
jumpActivity(context, bundle)
} else {
DialogHelper.showVideoUnsupportedDialog(context)
}
}
/**
* 跳转到旧视频页面
* @param fromLocation 可见 [VideoDetailContainerViewModel.Location]
*/
@JvmStatic
fun directToLegacyVideoDetail(
context: Context,
videoId: String,
fromLocation: String,
showComment: Boolean = false,
gameId: String = "",
entrance: String? = null,
path: String? = "",
referer: String = "",
type: String = "",
act: String = "",
paginationType: String = "",
fieldId: String = "",
sectionName: String = "",
isHomeVideo: Boolean = false
) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_TO, VideoDetailActivity::class.java.name)
bundle.putString(KEY_VIDEO_ID, videoId);
bundle.putString(KEY_PATH, path)
bundle.putString(KEY_ID, videoId)
bundle.putString(KEY_GAMEID, gameId)
bundle.putString(KEY_LOCATION, fromLocation)
bundle.putBoolean(KEY_SHOW_COMMENT, showComment)
bundle.putString(KEY_REFERER, referer)
bundle.putString(KEY_TYPE, type)
bundle.putString(KEY_ACTIVITY_NAME, act)
bundle.putString(KEY_PAGINATION_TYPE, paginationType)
bundle.putString(KEY_FIELD_ID, fieldId)
bundle.putString(KEY_SECTION_NAME, sectionName)
bundle.putBoolean(KEY_IS_HOME_VIDEO, isHomeVideo)
jumpActivity(context, bundle)
} else {
DialogHelper.showVideoUnsupportedDialog(context)
}
}
@JvmStatic
fun directToVideoDetail(
context: Context,
videoId: String,
fromLocation: String,
showComment: Boolean = false,
gameId: String = "",
entrance: String? = null,
path: String? = "",
referer: String = ""
) {
directToVideoDetail(context, videoId, entrance, path)
}
/**
* 跳转至安利墙
* @param fixedTopAmwayCommentId 需要置顶的安利Id
*/
@JvmStatic
fun directToAmway(
context: Context,
fixedTopAmwayCommentId: String? = null,
entrance: String? = null,
path: String? = ""
) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_TO, AmwayActivity::class.java.name)
bundle.putString(KEY_ID, fixedTopAmwayCommentId)
bundle.putString(KEY_PATH, path)
jumpActivity(context, bundle)
}
/**
* 跳转至徽章墙
*/
@JvmStatic
fun directToBadgeWall(context: Context, userId: String?, name: String?, icon: String?) {
var url: String = if (EnvHelper.isDevEnv) {
Constants.BADGE_ADDRESS_DEV
} else {
Constants.BADGE_ADDRESS
}
url = String.format(
Locale.CHINA,
"%s?user_id=%s&name=%s&icon=%s&timestamp=%d",
url,
userId,
name,
URLEncoder.encode(icon),
(Date().time / 1000 / 1000.toFloat()).roundToInt()
)
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至徽章详情
*/
@JvmStatic
fun directToBadgeDetail(context: Context, userId: String?, badgeId: String?) {
var url: String = if (EnvHelper.isDevEnv) {
Constants.BADGE_DETAIL_ADDRESS_DEV
} else {
Constants.BADGE_DETAIL_ADDRESS
}
url = String.format(
Locale.CHINA,
"%s?user_id=%s&badge_id=%s&timestamp=%d",
url,
userId,
badgeId,
(Date().time / 1000 / 1000.toFloat()).roundToInt()
)
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至上传视频
*/
@JvmStatic
fun directToVideoManager(
context: Context,
linkEntity: VideoLinkEntity,
simpleGameEntity: SimpleGameEntity,
entrance: String? = null,
path: String? = ""
) {
val bundle = Bundle()
bundle.putString(KEY_PATH, path)
bundle.putParcelable(VideoLinkEntity::class.java.simpleName, linkEntity)
bundle.putParcelable(SimpleGameEntity::class.java.simpleName, simpleGameEntity)
bundle.putString(KEY_TO, VideoManagerActivity::class.java.name)
bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
jumpActivity(context, bundle)
}
@JvmStatic
@JvmOverloads
fun directToFullScreenWebPage(
context: Context,
url: String,
webViewHandleBackPressed: Boolean = false,
entrance: String? = null
) {
context.startActivity(FullScreenWebActivity.getIntent(context, url, webViewHandleBackPressed, entrance))
}
@JvmStatic
fun directToRegulationTestPage(context: Context) {
val url = if (EnvHelper.isDevEnv) {
Constants.REGULATION_TEST_ADDRESS_DEV
} else {
Constants.REGULATION_TEST_ADDRESS
}
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转视频合集
*/
@JvmStatic
fun directToGameVideo(context: Context, gameId: String, entrance: String? = null, path: String? = "") {
if (gameId.isEmpty()) return
val bundle = Bundle()
bundle.putString(KEY_PATH, path)
bundle.putString(KEY_TO, GameVideoActivity::class.java.name)
bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
bundle.putString(KEY_GAMEID, gameId)
// context.startActivity(GameVideoActivity.getIntent(context, gameId, entrance, path))
jumpActivity(context, bundle)
}
@JvmStatic
fun directDouyin(context: Context, userId: String) {
if (PackageHelper.localPackageNameSet.contains("com.ss.android.ugc.aweme")) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("snssdk1128://user/profile/$userId"))
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent)
}
}
/**
* 跳转分类
*/
@JvmStatic
fun directCategoryDirectory(
context: Context,
categoryId: String,
categoryTitle: String,
entrance: String? = null,
path: String? = ""
) {
if (categoryId.isEmpty()) return
val bundle = Bundle()
bundle.putString(KEY_TO, CategoryDirectoryActivity::class.java.name)
bundle.putString(KEY_CATEGORY_ID, categoryId)
bundle.putString(KEY_CATEGORY_TITLE, categoryTitle)
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_PATH, path)
jumpActivity(context, bundle)
}
/**
* 跳转新分类
*/
@JvmStatic
fun directCatalog(
context: Context,
catalogId: String,
catalogTitle: String,
entrance: String? = null,
path: String? = "",
) {
if (catalogId.isEmpty()) return
val bundle = Bundle()
bundle.putString(KEY_TO, CatalogActivity::class.java.name)
bundle.putString(KEY_CATALOG_ID, catalogId)
bundle.putString(KEY_CATALOG_TITLE, catalogTitle)
bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
jumpActivity(context, bundle)
}
/**
* 跳转新分类2.0
*/
@JvmStatic
fun directCategoryV2(
context: Context,
categoryId: String,
categoryTitle: String,
entrance: String? = null,
path: String? = "",
exposureEvent: ExposureEvent? = null,
) {
if (categoryId.isEmpty()) return
val bundle = Bundle()
bundle.putString(KEY_TO, CategoryV2Activity::class.java.name)
bundle.putString(KEY_CATEGORY_ID, categoryId)
bundle.putString(KEY_CATEGORY_TITLE, categoryTitle)
bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
if (exposureEvent != null) bundle.putParcelableArrayList(
KEY_EXPOSURE_SOURCE_LIST,
ArrayList(exposureEvent.source)
)
jumpActivity(context, bundle)
}
/**
* 跳转到板块
*/
@JvmStatic
fun directToBlock(
context: Context,
blockData: SubjectRecommendEntity,
entrance: String,
exposureEvent: ExposureEvent? = null
) {
val bundle = Bundle()
bundle.putString(KEY_TO, BlockActivity::class.java.name)
bundle.putParcelable(KEY_BLOCK_DATA, blockData)
bundle.putString(KEY_ENTRANCE, entrance)
exposureEvent?.let { bundle.putParcelableArrayList(KEY_EXPOSURE_SOURCE_LIST, ArrayList(exposureEvent.source)) }
jumpActivity(context, bundle)
}
/**
* 跳转到开服表
*/
@JvmStatic
fun directToGameServers(context: Context, entrance: String, path: String, exposureEvent: ExposureEvent? = null) {
val bundle = Bundle()
bundle.putString(KEY_TO, GameServersActivity::class.java.name)
bundle.putString(KEY_ENTRANCE, ToolBarActivity.mergeEntranceAndPath(entrance, path))
exposureEvent?.let { bundle.putParcelableArrayList(KEY_EXPOSURE_SOURCE_LIST, ArrayList(exposureEvent.source)) }
jumpActivity(context, bundle)
}
/**
* 跳转到游戏上传
*/
@JvmStatic
fun directGameUpload(context: Context, entrance: String? = null, path: String? = "") {
val bundle = Bundle()
bundle.putString(KEY_TO, GameSubmissionActivity::class.java.name)
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_PATH, path)
jumpActivity(context, bundle)
}
@JvmStatic
fun directGameZone(context: Context, gameId: String, url: String, entrance: String? = null) {
RetrofitManager.getInstance()
.api
.getGameDigest(gameId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<GameEntity>() {
override fun onResponse(response: GameEntity?) {
response?.apply {
if (zone.status == "on") {
if (zone.style == "link") {
directToGameDetail(context, gameId, GameDetailFragment.TAB_TRENDS, entrance)
} else {
directToWebView(context, url, entrance)
}
} else {
directToWebView(context, url, entrance)
}
}
}
override fun onFailure(e: HttpException?) {
}
})
}
@JvmStatic
fun directVideoData(context: Context, entrance: String? = null) {
val bundle = Bundle()
bundle.putString(KEY_TO, VideoDataActivity::class.java.name)
bundle.putString(KEY_ENTRANCE, entrance)
jumpActivity(context, bundle)
}
@JvmStatic
fun directForumDetail(context: Context, bbsId: String? = "", entrance: String? = null) {
val bundle = Bundle()
bundle.putString(KEY_TO, ForumDetailActivity::class.java.name)
bundle.putString(KEY_BBS_ID, bbsId)
bundle.putString(KEY_ENTRANCE, entrance)
jumpActivity(context, bundle)
}
@JvmStatic
fun directForumDetailSection(
context: Context,
bbsId: String? = "",
sectionId: String? = "",
entrance: String? = null
) {
val bundle = Bundle()
bundle.putString(KEY_TO, ForumDetailActivity::class.java.name)
bundle.putString(KEY_BBS_ID, bbsId)
bundle.putString(KEY_BBS_SECTION_ID, sectionId)
bundle.putString(KEY_ENTRANCE, entrance)
jumpActivity(context, bundle)
}
/**
* 到首页-首页 tab
*/
@JvmStatic
fun directToHomeTab(context: Context) {
if (HaloApp.getInstance().isRunningForeground) {
val intent = Intent(context, MainActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
context.startActivity(intent)
// 这里换个线程操作是为了做一点延时
runOnIoThread {
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_HOME))
}
} else {
jumpActivity(context, Bundle().apply { putInt(KEY_POSITION, MainWrapperFragment.INDEX_HOME) })
}
}
/**
* 到首页-论坛 tab
* @param position 论坛的子 tab 位置
*/
@JvmStatic
fun directToForum(context: Context, position: Int = 0) {
if (HaloApp.getInstance().isRunningForeground) {
val intent = Intent(context, MainActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
context.startActivity(intent)
// 这里换个线程操作是为了做一点延时
runOnIoThread {
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_BBS))
EventBus.getDefault().post(EBSkip(CommunityHomeFragment.EB_TAB, position))
}
} else {
jumpActivity(context, Bundle().apply {
putInt(KEY_POSITION, MainWrapperFragment.INDEX_BBS)
putInt(KEY_SUB_POSITION, position)
})
}
}
/**
* 到首页-视频 tab
*/
@JvmStatic
fun directToVideoTab(context: Context) {
if (HaloApp.getInstance().isRunningForeground) {
val intent = Intent(context, MainActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
context.startActivity(intent)
// 这里换个线程操作是为了做一点延时
runOnIoThread {
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_VIDEO))
}
} else {
jumpActivity(context, Bundle().apply { putInt(KEY_POSITION, MainWrapperFragment.INDEX_VIDEO) })
}
}
/**
* 到首页-我的光环 tab
*/
@JvmStatic
fun directToPersonalTab(context: Context) {
if (HaloApp.getInstance().isRunningForeground) {
val intent = Intent(context, MainActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
context.startActivity(intent)
// 这里换个线程操作是为了做一点延时
runOnIoThread {
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_PERSONAL))
}
} else {
jumpActivity(context, Bundle().apply { putInt(KEY_POSITION, MainWrapperFragment.INDEX_PERSONAL) })
}
}
/**
* 跳转至使用帮助与反馈,请不要随意修改方法名
*/
@JvmStatic
fun directToHelpAndFeedback(context: Context, bundle: Bundle? = null) {
val destination = RouteConsts.activity.helpAndFeedbackActivity.toDestinationClass()
val newBundle = Bundle()
newBundle.putString(KEY_TO, destination?.name ?: "")
bundle?.let { newBundle.putAll(it) }
jumpActivityCompat(context, newBundle)
}
/**
* 跳转至商品详情
*/
@JvmStatic
fun directToCommodityDetail(context: Context, commodityId: String) {
var url: String = if (EnvHelper.isDevEnv) {
Constants.COMMODITY_DETAIL_ADDRESS_DEV
} else {
Constants.COMMODITY_DETAIL_ADDRESS
}
url = String.format(
Locale.CHINA,
"%s&shopid=%s&timestamp=%d",
url,
commodityId,
(Date().time / 1000 / 1000.toFloat()).roundToInt()
)
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至光能记录默认跳到光能记录第一个Tab
*/
@JvmStatic
fun directToEnergyRecord(context: Context) {
directToEnergyRecord(context, 0)
}
@JvmStatic
fun directToEnergyRecord(context: Context, position: Int) {
var url: String = if (EnvHelper.isDevEnv) {
Constants.ENERGY_RECORD_ADDRESS_DEV
} else {
Constants.ENERGY_RECORD_ADDRESS
}
url = String.format(
Locale.CHINA,
"%s&position=%s&timestamp=%d",
url,
position,
(Date().time / 1000 / 1000.toFloat()).roundToInt()
)
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至订单中心
*/
@JvmStatic
fun directToOrderCenter(context: Context) {
val url: String = if (EnvHelper.isDevEnv) {
Constants.ORDER_CENTER_ADDRESS_DEV
} else {
Constants.ORDER_CENTER_ADDRESS
}
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至订单详情
*/
@JvmStatic
fun directToOrderDetail(context: Context, orderId: String) {
var url: String = if (EnvHelper.isDevEnv) {
Constants.ORDER_DETAIL_ADDRESS_DEV
} else {
Constants.ORDER_DETAIL_ADDRESS
}
url = String.format(
Locale.CHINA,
"%s&order_id=%s&timestamp=%d",
url,
orderId,
(Date().time / 1000 / 1000.toFloat()).roundToInt()
)
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至邀请好友
*/
@JvmStatic
fun directToInviteFriends(context: Context) {
val url: String = if (EnvHelper.isDevEnv) {
Constants.INVITE_FRIENDS_ADDRESS_DEV
} else {
Constants.INVITE_FRIENDS_ADDRESS
}
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至等级页面
*/
@JvmStatic
fun directToLevelPage(context: Context) {
var url: String = if (isPublishEnv()) {
Constants.LEVEL_ADDRESS
} else {
Constants.LEVEL_ADDRESS_DEV
}
url = String.format(Locale.CHINA, "%s?timestamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至兑换规则
*/
@JvmStatic
fun directToExchangeRulePage(context: Context) {
var url: String = if (isPublishEnv()) {
Constants.EXCHANGE_RULE_ADDRESS
} else {
Constants.EXCHANGE_RULE_ADDRESS_DEV
}
url = String.format(Locale.CHINA, "%s&timestamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至光能规则
*/
@JvmStatic
fun directToEnergyRulePage(context: Context) {
var url: String = if (isPublishEnv()) {
Constants.ENERGY_RULE_ADDRESS
} else {
Constants.ENERGY_RULE_ADDRESS_DEV
}
url = String.format(Locale.CHINA, "%s&timestamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至兑换商品
*/
@JvmStatic
fun directToExchangeCommodityPage(context: Context) {
var url: String = if (isPublishEnv()) {
Constants.EXCHANGE_COMMODITY_ADDRESS
} else {
Constants.EXCHANGE_COMMODITY_ADDRESS_DEV
}
url = String.format(Locale.CHINA, "%s&timestamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至抽奖乐园
*/
@JvmStatic
fun directToLotteryParadisePage(context: Context) {
var url: String = if (isPublishEnv()) {
Constants.LOTTERY_PARADISE_ADDRESS
} else {
Constants.LOTTERY_PARADISE_ADDRESS_DEV
}
url = String.format(Locale.CHINA, "%s&timestamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至我的奖品
*/
@JvmStatic
fun directToMyPrizePage(context: Context) {
var url: String = if (isPublishEnv()) {
Constants.MY_PRIZE_ADDRESS
} else {
Constants.MY_PRIZE_ADDRESS_DEV
}
url = String.format(Locale.CHINA, "%s&timestamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至中奖订单详情
*/
@JvmStatic
fun directToWinOrderDetail(context: Context, orderId: String, activityId: String) {
var url: String = if (isPublishEnv()) {
Constants.WIN_ORDER_DETAIL_ADDRESS
} else {
Constants.WIN_ORDER_DETAIL_ADDRESS_DEV
}
url = String.format(
Locale.CHINA,
"%s&order_id=%s&activity_id=%s&timestamp=%d",
url,
orderId,
activityId,
(Date().time / 1000 / 1000.toFloat()).roundToInt()
)
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至地址信息
*/
@JvmStatic
fun directToAddressInfo(context: Context) {
var url: String = if (isPublishEnv()) {
Constants.ADDRESS_INFO_ADDRESS
} else {
Constants.ADDRESS_INFO_ADDRESS_DEV
}
url = String.format(Locale.CHINA, "%s&timestamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至领奖信息
*/
@JvmStatic
fun directToPrizeInfo(context: Context) {
var url: String = if (isPublishEnv()) {
Constants.PRIZE_INFO_ADDRESS
} else {
Constants.PRIZE_INFO_ADDRESS_DEV
}
url = String.format(Locale.CHINA, "%s&timestamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至提现信息
*/
@JvmStatic
fun directToWithdrawInfo(context: Context) {
var url: String = if (isPublishEnv()) {
Constants.WITHDRAW_INFO_ADDRESS
} else {
Constants.WITHDRAW_INFO_ADDRESS_DEV
}
url = String.format(Locale.CHINA, "%s&timestamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
directToFullScreenWebPage(context, url, true)
}
/**
* 跳转至活动详情
*/
@JvmStatic
fun directToActivityDetail(context: Context, activityId: String, categoryId: String, entrance: String) {
var url: String = if (isPublishEnv()) {
Constants.ACTIVITY_DETAIL_ADDRESS
} else {
Constants.ACTIVITY_DETAIL_ADDRESS_DEV
}
url = String.format(
Locale.CHINA,
"%s?from=ghzs&id=%s&category_id=%s&timestamp=%d",
url,
activityId,
categoryId,
(Date().time / 1000 / 1000.toFloat()).roundToInt()
)
directToWebView(context, url, entrance)
}
@JvmStatic
fun directToCommonCollectionDetail(
context: Context,
collectionId: String,
blockId: String = "",
blockName: String = "",
entrance: String = "",
exposureEvent: ExposureEvent? = null
) {
if (collectionId.isEmpty()) return
val bundle = Bundle()
bundle.putString(KEY_TO, CommonCollectionDetailActivity::class.java.name)
bundle.putString(KEY_BLOCK_ID, blockId)
bundle.putString(KEY_BLOCK_NAME, blockName)
bundle.putString(KEY_ENTRANCE, entrance)
bundle.putString(KEY_COLLECTION_ID, collectionId)
exposureEvent?.let { bundle.putParcelableArrayList(KEY_EXPOSURE_SOURCE_LIST, ArrayList(exposureEvent.source)) }
jumpActivity(context, bundle)
}
/**
* 跳转到游戏动态,请不要随意修改方法名
*/
@JvmStatic
fun directToConcernInfo(context: Context, entrance: String) {
context.startActivity(
(ARouter.getInstance().build(RouteConsts.provider.concernInfo)
.navigation() as? IConcernInfoProvider)?.getIntent(context, entrance)
)
}
/**
* 跳转至游戏单广场
*/
@JvmStatic
fun directToGameCollectionSquare(
context: Context,
entrance: String = "",
forumName: String = "",
gameCollectionTitle: String = "",
gameCollectionId: String = "",
collectionName: String = "",
collectionId: String = "",
traceEvent: ExposureEvent? = null
) {
val bundle = Bundle()
val exposureSourceList = traceEvent?.source
bundle.putString(KEY_TO, GameCollectionSquareActivity::class.java.name)
bundle.putString(KEY_ENTRANCE, entrance)
bundle.putString(KEY_FORUM_NAME, forumName)
bundle.putString(KEY_GAME_COLLECTION_TITLE, gameCollectionTitle)
bundle.putString(KEY_GAME_COLLECTION_ID, gameCollectionId)
bundle.putString(KEY_COLLECTION_ID, collectionId)
bundle.putString(KEY_COLLECTION_NAME, collectionName)
if (exposureSourceList is ArrayList) {
bundle.putParcelableArrayList(KEY_EXPOSURE_SOURCE_LIST, exposureSourceList)
} else if (exposureSourceList != null) {
bundle.putParcelableArrayList(KEY_EXPOSURE_SOURCE_LIST, ArrayList(exposureSourceList))
}
jumpActivity(context, bundle)
}
/**
* 跳转至游戏单热榜
*/
@JvmStatic
fun directToGameCollectionHotList(context: Context, entrance: String = "") {
val bundle = Bundle()
bundle.putString(KEY_TO, GameCollectionHotListActivity::class.java.name)
bundle.putString(KEY_ENTRANCE, entrance)
jumpActivity(context, bundle)
}
/**
* 跳转至游戏单详情
*/
@JvmStatic
fun directToGameCollectionDetail(
context: Context,
id: String,
entrance: String? = null,
path: String? = null,
traceEvent: ExposureEvent? = null,
) {
if (id.isEmpty()) return
val bundle = Bundle()
val exposureSourceList = traceEvent?.source
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_PATH, path)
bundle.putString(KEY_TO, GameCollectionDetailActivity::class.java.name)
bundle.putString(KEY_GAME_COLLECTION_ID, id)
if (exposureSourceList is ArrayList) {
bundle.putParcelableArrayList(KEY_EXPOSURE_SOURCE_LIST, exposureSourceList)
} else if (exposureSourceList != null) {
bundle.putParcelableArrayList(KEY_EXPOSURE_SOURCE_LIST, ArrayList(exposureSourceList))
}
jumpActivity(context, bundle)
}
/**
* 跳转至反馈详情, 请不要随意修改方法名
*/
@JvmStatic
fun directToSuggestion(
context: Context,
type: SuggestType = SuggestType.APP,
hiddenHint: String = "",
suggestHintType: String? = null,
content: String? = null,
game: SimpleGameEntity? = null,
isQaFeedback: Boolean = false,
qaContentId: String = "",
fromRatingKey: Boolean = false,
diagnosis: String = "",
forceLogin: Boolean = true,
requestCode: Int? = null,
isSmoothGame: Boolean = false
) {
val intent = HelpAndFeedbackBridge.getIntent(
context,
type,
hiddenHint,
suggestHintType,
content,
game,
isQaFeedback,
qaContentId,
fromRatingKey,
diagnosis,
forceLogin,
isSmoothGame
)
if (requestCode != null) {
(context as Activity).startActivityForResult(intent, requestCode)
} else {
context.startActivity(intent)
}
}
/**
* 跳转到论坛搜索页
* @param bbsId, 为空时搜索全范围的内容,不为空时搜索该 bbsId 对应的内容
*/
@JvmStatic
fun directToForumOrUserSearch(
context: Context,
bbsId: String,
entrance: String,
sourceEntrance: String,
forumName: String
) {
context.startActivity(ForumOrUserSearchActivity.getIntent(context, bbsId, entrance, sourceEntrance, forumName))
}
@JvmStatic
fun directToVGameDownload(context: Context, switchToDownloadingTab: Boolean = false) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, ENTRANCE_BROWSER)
bundle.putString(KEY_TO, VDownloadManagerActivity::class.java.name)
bundle.putInt(KEY_POSITION, if (switchToDownloadingTab) 1 else 0)
jumpActivity(context, bundle)
}
@JvmStatic
fun directToSuggestion(context: Context, type: SuggestType) {
directToSuggestion(context = context, type = type, requestCode = null)
}
@JvmStatic
fun directToSuggestion(context: Context, type: SuggestType, requestCode: Int?) {
directToSuggestion(context = context, type = type, hiddenHint = "", requestCode = requestCode)
}
@JvmStatic
fun directToSuggestion(context: Context, type: SuggestType, hiddenHint: String) {
directToSuggestion(context = context, type = type, hiddenHint = hiddenHint, requestCode = null)
}
@JvmStatic
fun directToSuggestion(
context: Context,
type: SuggestType,
hiddenHint: String,
forceLogin: Boolean = true,
requestCode: Int?
) {
directToSuggestion(
context = context,
type = type,
hiddenHint = hiddenHint,
suggestHintType = null,
forceLogin = forceLogin,
requestCode = requestCode,
)
}
@JvmStatic
fun directToSuggestion(
context: Context,
type: SuggestType,
suggestHintType: String? = null,
content: String? = null,
isQaFeedback: Boolean = false,
qaContentId: String = ""
) {
directToSuggestion(
context = context,
type = type,
hiddenHint = "",
suggestHintType = suggestHintType,
content = content,
isQaFeedback = isQaFeedback,
qaContentId = qaContentId
)
}
@JvmStatic
fun directToQGameHome(context: Context) {
context.startActivity(QGameHomeWrapperActivity.getIntent(context))
}
@JvmStatic
fun directToQGameSearch(
context: Context,
hint: String,
sourceEntrance: String
) {
context.startActivity(QGameSearchActivity.getIntent(context, hint, sourceEntrance))
}
@SuppressLint("CheckResult")
@JvmStatic
fun directToQGameById(
activity: Activity,
qqGameId: String
) {
if (activity !is AppCompatActivity || activity.supportFragmentManager.isDestroyed) {
ToastUtils.toast("启动QQ小游戏失败请稍后再试")
return
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
ToastUtils.toast("该游戏仅支持安卓5.0及以上设备")
return
}
CheckLoginUtils.checkLogin(
activity, null, true, "QQ小游戏-秒开"
) {
val userToken = UserManager.getInstance().token
val userId = UserManager.getInstance().userId
val userName = UserManager.getInstance().userInfoEntity?.name ?: "unknown"
val qGameProvider = ARouter
.getInstance()
.build(RouteConsts.provider.qGame)
.navigation() as IQGameProvider<*>
qGameProvider.setLoginInfo(activity, userId, userName, userToken)
qGameProvider.launchGame(activity, qqGameId) { _, _ ->
RetrofitManager
.getInstance()
.newApi
.postQGamePlay(qqGameId, userId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{
QGameViewModel.notifyQGameSubjectUpdate() // 通知QQ小游戏首页列表刷新
},
{}
) // 秒玩记录上报
}
}
}
@JvmStatic
fun directToMessageCenter(defaultTabIndex: Int) {
ARouter.getInstance().build(RouteConsts.activity.messageWrapperActivity)
.withInt(BaseActivity_TabLayout.PAGE_INDEX, defaultTabIndex)
.navigation()
}
// 跳转游戏单合集详情
@JvmStatic
fun directToGameCollectionListDetail(
context: Context,
collectionId: String,
collectionName: String,
explain: String,
entrance: String = ""
) {
context.startActivity(
GameCollectionListDetailActivity.getIntent(
context,
GameCollectionListEntity(id = collectionId, name = collectionName, explain = explain),
entrance
)
)
}
/**
* 跳转到游戏订阅页面
* @param context 上下文
*/
@JvmStatic
fun directToServersSubscribedGameList(context: Context) {
context.startActivity(ServersSubscribedGameListActivity.getIntent(context))
}
/**
* 跳转到开服订阅页面
* @param context 上下文
*/
@JvmStatic
fun directToServersCalendarManagement(context: Context, entrance: String) {
CheckLoginUtils.checkLogin(context, entrance) {
context.startActivity(ServersCalendarManagementActivity.getIntent(context))
}
}
}