1259 lines
50 KiB
Kotlin
1259 lines
50 KiB
Kotlin
package com.gh.common.util
|
||
|
||
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.gh.base.BaseActivity
|
||
import com.gh.base.BaseActivity_TabLayout
|
||
import com.gh.base.ToolBarActivity
|
||
import com.gh.base.fragment.BaseFragment_TabLayout
|
||
import com.gh.common.AppExecutor
|
||
import com.gh.common.constant.Config
|
||
import com.gh.common.constant.Constants
|
||
import com.gh.common.exposure.ExposureEvent
|
||
import com.gh.common.exposure.ExposureEvent.Companion.createEvent
|
||
import com.gh.common.exposure.ExposureManager.log
|
||
import com.gh.common.exposure.ExposureTraceUtils.appendTrace
|
||
import com.gh.common.exposure.ExposureType
|
||
import com.gh.common.util.EntranceUtils.*
|
||
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.download.DownloadFragment.Companion.INDEX_UPDATE
|
||
import com.gh.gamecenter.entity.*
|
||
import com.gh.gamecenter.eventbus.EBReuse
|
||
import com.gh.gamecenter.eventbus.EBSkip
|
||
import com.gh.gamecenter.forum.detail.ForumDetailActivity
|
||
import com.gh.gamecenter.fragment.MainWrapperFragment
|
||
import com.gh.gamecenter.game.columncollection.detail.ColumnCollectionDetailActivity
|
||
import com.gh.gamecenter.game.upload.GameSubmissionActivity
|
||
import com.gh.gamecenter.gamedetail.GameDetailFragment
|
||
import com.gh.gamecenter.gamedetail.fuli.kaifu.ServersCalendarActivity
|
||
import com.gh.gamecenter.gamedetail.history.HistoryApkListActivity
|
||
import com.gh.gamecenter.gamedetail.rating.RatingReplyActivity
|
||
import com.gh.gamecenter.manager.UserManager
|
||
import com.gh.gamecenter.mygame.PlayedGameActivity
|
||
import com.gh.gamecenter.personalhome.UserHomeActivity
|
||
import com.gh.gamecenter.personalhome.background.PersonalityBackgroundActivity
|
||
import com.gh.gamecenter.personalhome.border.AvatarBorderActivity
|
||
import com.gh.gamecenter.qa.CommunityFragment
|
||
import com.gh.gamecenter.qa.answer.detail.AnswerDetailActivity
|
||
import com.gh.gamecenter.qa.article.SimpleArticleListActivity
|
||
import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity
|
||
import com.gh.gamecenter.qa.column.detail.AskColumnDetailActivity
|
||
import com.gh.gamecenter.qa.questions.detail.QuestionsDetailActivity
|
||
import com.gh.gamecenter.qa.subject.CommunitySubjectActivity
|
||
import com.gh.gamecenter.retrofit.Response
|
||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||
import com.gh.gamecenter.security.BindPhoneActivity
|
||
import com.gh.gamecenter.servers.GameServersActivity
|
||
import com.gh.gamecenter.subject.SubjectActivity
|
||
import com.gh.gamecenter.suggest.SuggestType
|
||
import com.gh.gamecenter.tag.TagsActivity
|
||
import com.gh.gamecenter.user.UserViewModel
|
||
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.halo.assistant.HaloApp
|
||
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 {
|
||
|
||
/**
|
||
* 跳转到特定页面,根据 [type] 决定跳转页面,[path] 为跳转前的页面名称
|
||
*/
|
||
@JvmStatic
|
||
fun directToSpecificPage(context: Context, type: String, link: String, text: String? = "", entrance: String? = null, path: String? = null) {
|
||
when (type) {
|
||
HOST_ARTICLE -> directToArticle(context, id = link, entrance = entrance)
|
||
|
||
HOST_GAME -> directToGameDetail(context, id = link, entrance = entrance)
|
||
|
||
HOST_GAME_DOWNLOAD -> directToGameDetail(context, id = link, entrance = entrance, autoDownload = true)
|
||
|
||
HOST_COLUMN -> directToSubject(context, id = link, subjectName = text, entrance = entrance)
|
||
|
||
HOST_QUESTION -> directToQuestionDetail(context, id = link, entrance = entrance, path = path)
|
||
|
||
HOST_ANSWER -> directToAnswerDetail(context, id = link, entrance = entrance, path = path)
|
||
|
||
HOST_WEB -> directToWebView(context, url = link, entrance = entrance)
|
||
|
||
HOST_DOWNLOAD -> directToDownloadManagerAndStartDownload(context, gameId = link, packageName = text, entrance = entrance)
|
||
|
||
HOST_UPDATE -> directToDownloadManagerAndStartUpdate(context, gameId = link, packageName = text, entrance = entrance)
|
||
|
||
HOST_LIBAO -> directToGiftDetail(context, giftId = link, entrance = entrance)
|
||
|
||
HOST_COMMUNITY -> directToCommunity(context, CommunityEntity(link, text!!))
|
||
}
|
||
}
|
||
|
||
@JvmStatic
|
||
fun directToLinkPage(context: Context, linkEntity: LinkEntity, entrance: String, path: String) {
|
||
directToLinkPage(context, linkEntity, entrance, path, null)
|
||
}
|
||
|
||
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"
|
||
)
|
||
|
||
fun directToLinkPage(context: Context,
|
||
linkEntity: LinkEntity,
|
||
entrance: String,
|
||
path: String,
|
||
exposureEvent: ExposureEvent? = null,
|
||
unknownCallback: (() -> Unit)?) {
|
||
when (linkEntity.type) {
|
||
"article", "news", "文章" -> {
|
||
NewsUtils.statNewsViews(context, 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
|
||
?: "", BaseActivity.mergeEntranceAndPath(entrance, path))
|
||
}
|
||
}
|
||
|
||
"column", "游戏专题" -> directToSubject(context, linkEntity.link
|
||
?: "", linkEntity.text, BaseActivity.mergeEntranceAndPath(entrance, path))
|
||
|
||
"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)
|
||
|
||
"community_special_column" -> directAskColumnDetail(context, linkEntity.link
|
||
?: "", linkEntity.community!!, entrance, path)
|
||
|
||
"web", "inurl", "web链接" -> {
|
||
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))
|
||
|
||
"all_community_article" -> directSimpleArticleList(context, linkEntity.link
|
||
?: "", entrance, path)
|
||
|
||
"category", "分类" -> directCategoryDirectory(context, linkEntity.link!!, linkEntity.text!!)
|
||
|
||
"catalog" -> directCatalog(context, linkEntity.link!!, linkEntity.text!!, entrance, path)
|
||
|
||
"block", "版块" -> {
|
||
if (linkEntity.link.isNullOrEmpty()) return
|
||
directToBlock(context,
|
||
SubjectRecommendEntity(
|
||
link = linkEntity.link,
|
||
text = linkEntity.text,
|
||
name = linkEntity.name,
|
||
display = linkEntity.display ?: Display()),
|
||
entrance)
|
||
}
|
||
|
||
"column_collection", "专题合集" -> directToColumnCollection(context, linkEntity.link!!, -1, entrance)
|
||
|
||
"server", "game_server", "开服表" -> directToGameServers(context, entrance, path)
|
||
|
||
"top_game_comment" -> directToAmway(context, null, entrance, path)
|
||
|
||
"wechat_bind" -> context.startActivity(WebActivity.getBindWechatIntent(context))
|
||
|
||
"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, linkEntity.text, entrance)
|
||
|
||
"qa", "Q&A" -> directToQa(context, linkEntity.text ?: "", linkEntity.link ?: "")
|
||
|
||
"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)
|
||
|
||
"mobile_bind" -> {
|
||
CheckLoginUtils.checkLogin(context, entrance) {
|
||
context.startActivity(BindPhoneActivity.getNormalIntent(context, false))
|
||
}
|
||
}
|
||
|
||
"authentication" -> {
|
||
CheckLoginUtils.checkLogin(context, entrance) {
|
||
context.startActivity(UserInfoEditActivity.getIntent(context, UserViewModel.TYPE_ID_CARD))
|
||
}
|
||
}
|
||
|
||
"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(SettingActivity.getIntent(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(ToolBoxActivity.getIntent(context, entrance))
|
||
|
||
"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)
|
||
|
||
//"h5_game_center" -> directLetoGameCenter(context)
|
||
|
||
"" -> {
|
||
// do nothing
|
||
}
|
||
else -> {
|
||
if (unknownCallback != null) {
|
||
unknownCallback.invoke()
|
||
} else {
|
||
DialogUtils.showLowVersionDialog(context)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 跳转至QA
|
||
*/
|
||
@JvmStatic
|
||
fun directToQa(context: Context, text: String? = "", id: String) {
|
||
if (id.isEmpty()) return
|
||
val bundle = Bundle()
|
||
bundle.putString(KEY_TO, QaActivity::class.java.simpleName)
|
||
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 bundle = Bundle()
|
||
bundle.putString(KEY_TO, QaActivity::class.java.simpleName)
|
||
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 = "") {
|
||
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.putInt(KEY_POSITION, position)
|
||
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?) {
|
||
val bundle = Bundle()
|
||
bundle.putString(KEY_TO, ServersCalendarActivity::class.java.name)
|
||
bundle.putParcelable(GameEntity::class.java.simpleName, GameEntity().apply {
|
||
id = gameId ?: ""
|
||
})
|
||
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)
|
||
jumpActivity(context, bundle)
|
||
}
|
||
|
||
/**
|
||
* 跳转至个人主页
|
||
*/
|
||
@JvmStatic
|
||
fun directToHomeActivity(context: Context, userId: String?, entrance: String? = null, path: String? = null) {
|
||
context.startActivity(UserHomeActivity.getIntent(context, userId ?: "", entrance, path))
|
||
}
|
||
|
||
/**
|
||
* 跳转至个人主页
|
||
* @param position 定位到某个tab 0游戏评论 1问答 2视频
|
||
*/
|
||
@JvmStatic
|
||
fun directToHomeActivity(context: Context, userId: String?, position: Int, entrance: String? = null, path: String? = null) {
|
||
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.putInt(KEY_POSITION, position)
|
||
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.putInt(KEY_TARGET, GameDetailFragment.INDEX_RATING)
|
||
"desc" -> bundle.putInt(KEY_TARGET, GameDetailFragment.INDEX_DESC)
|
||
"forum" -> bundle.putInt(KEY_TARGET, GameDetailFragment.INDEX_BBS)
|
||
"zone" -> bundle.putInt(KEY_TARGET, GameDetailFragment.INDEX_TRENDES)
|
||
}
|
||
}
|
||
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.putInt(KEY_TARGET, GameDetailFragment.INDEX_DESC)
|
||
jumpActivity(context, bundle)
|
||
}
|
||
|
||
@JvmStatic
|
||
fun directToGameDetail(context: Context, id: String, defaultTab: Int = GameDetailFragment.INDEX_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.putInt(KEY_TARGET, defaultTab)
|
||
jumpActivity(context, bundle)
|
||
}
|
||
|
||
// 跳转至用户玩过的游戏
|
||
fun directToPlayedGame(context: Context, userId: String, entrance: String = "", path: String = "") {
|
||
context.startActivity(PlayedGameActivity.getIntent(context, userId, entrance, path))
|
||
}
|
||
|
||
// 专栏
|
||
@JvmStatic
|
||
fun directToSubject(context: Context, id: String, subjectName: String? = "", entrance: String? = null) {
|
||
if (id.isEmpty()) return
|
||
val bundle = Bundle()
|
||
val subjectData = SubjectData(subjectId = id, subjectName = subjectName, isOrder = false)
|
||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||
bundle.putString(KEY_TO, SubjectActivity::class.java.name)
|
||
bundle.putParcelable(EntranceUtils.KEY_SUBJECT_DATA, subjectData)
|
||
jumpActivity(context, bundle)
|
||
}
|
||
|
||
// 反馈
|
||
@JvmStatic
|
||
fun directToFeedback(context: Context, content: String? = null, entrance: String? = null) {
|
||
directToFeedback(context, content, null, entrance)
|
||
}
|
||
|
||
@JvmStatic
|
||
fun directToFeedback(context: Context, content: String? = null, hintType: String? = null, entrance: String? = null) {
|
||
val bundle = Bundle()
|
||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||
bundle.putString(KEY_TO, SuggestionActivity::class.java.simpleName)
|
||
bundle.putString(KEY_CONTENT, content)
|
||
if (TextUtils.isEmpty(hintType)) {
|
||
bundle.putString(KEY_SUGGEST_HINT_TYPE, KEY_PLUGIN)
|
||
} else {
|
||
bundle.putString(KEY_SUGGEST_HINT_TYPE, hintType)
|
||
}
|
||
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.gameQuestion)
|
||
jumpActivity(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)
|
||
}
|
||
|
||
/**
|
||
* 跳转到下载管理器并开始下载 [gameId] 和 [packageName] 用于唯一确定一个下载文件
|
||
*/
|
||
@JvmStatic
|
||
fun directToDownloadManagerAndStartDownload(context: Context, gameId: String? = "", packageName: String? = "", entrance: String? = null) {
|
||
DownloadHelper.createABrandNewDownloadTaskQuietly(gameId, packageName) {
|
||
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.putBoolean(KEY_AUTO_DOWNLOAD, true)
|
||
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)
|
||
jumpActivity(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, ToolBoxActivity::class.java.simpleName)
|
||
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, AnswerDetailActivity::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, QuestionsDetailActivity::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)
|
||
bundle.putString(KEY_TO, WebActivity::class.java.simpleName)
|
||
bundle.putString(EntranceUtils.KEY_URL, url)
|
||
jumpActivity(context, bundle)
|
||
}
|
||
|
||
// 个人-系统消息
|
||
@JvmStatic
|
||
fun directToOfficialNotification(context: Context, entrance: String? = null) {
|
||
val bundle = Bundle()
|
||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||
bundle.putString(KEY_TO, MessageKeFuActivity::class.java.simpleName)
|
||
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: ActivityNotFoundException) {
|
||
e.printStackTrace()
|
||
Utils.toast(context, "跳转地址无效")
|
||
}
|
||
}
|
||
|
||
// 跳转 QQ,qqNumber 为空选择默认客服 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)
|
||
}
|
||
context.startActivity(intent)
|
||
} 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(EntranceUtils.KEY_ID, giftId)
|
||
HaloApp.put(LibaoEntity.TAG, null)
|
||
jumpActivity(context, bundle)
|
||
}
|
||
|
||
/**
|
||
* 切换到社区页面
|
||
*/
|
||
@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_ASK))
|
||
EventBus.getDefault().post(EBReuse(CommunityFragment.EB_RETRY_PAGE))
|
||
}
|
||
}
|
||
|
||
@JvmStatic
|
||
fun directToCommunity(context: Context) {
|
||
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)
|
||
}
|
||
|
||
// 这里换个线程操作是为了做一点延时
|
||
AppExecutor.ioExecutor.execute {
|
||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_ASK))
|
||
EventBus.getDefault().post(EBReuse(CommunityFragment.EB_RETRY_PAGE))
|
||
}
|
||
}
|
||
|
||
@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)
|
||
}
|
||
|
||
/**
|
||
* @param fromLocation 可见 [VideoDetailContainerViewModel.Location]
|
||
*/
|
||
@JvmStatic
|
||
fun directToVideoDetail(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 = "") {
|
||
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_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)
|
||
jumpActivity(context, bundle)
|
||
} else {
|
||
DialogUtils.showLowSystemVersionDialog(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, fromLocation, showComment, gameId, entrance, path, referer, "", "")
|
||
}
|
||
|
||
/**
|
||
* 跳转至安利墙
|
||
* @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 ("internal" == BuildConfig.FLAVOR) {
|
||
Constants.BADGE_ADDRESS_DEV
|
||
} else {
|
||
Constants.BADGE_ADDRESS
|
||
}
|
||
|
||
url = String.format(Locale.CHINA, "%s?user_id=%s&name=%s&icon=%s×tamp=%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 ("internal" == BuildConfig.FLAVOR) {
|
||
Constants.BADGE_DETAIL_ADDRESS_DEV
|
||
} else {
|
||
Constants.BADGE_DETAIL_ADDRESS
|
||
}
|
||
|
||
url = String.format(Locale.CHINA, "%s?user_id=%s&badge_id=%s×tamp=%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
|
||
fun directToFullScreenWebPage(context: Context, url: String, webViewHandleBackPressed: Boolean = false) {
|
||
context.startActivity(FullScreenWebActivity.getIntent(context, url, webViewHandleBackPressed))
|
||
}
|
||
|
||
@JvmStatic
|
||
fun directToRegulationTestPage(context: Context) {
|
||
val url = if ("internal" == BuildConfig.FLAVOR) {
|
||
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 directLetoGameCenter(context: Context) {
|
||
if (UserManager.getInstance().isLoggedIn) {
|
||
UserManager.getInstance().userInfoEntity?.run {
|
||
MgcAccountManager.syncAccount(context, if (idCard != null) idCard!!.name else name, mobile, name, icon, true,
|
||
object : SyncUserInfoListener {
|
||
override fun onSuccess(data: LoginResultBean?) {}
|
||
|
||
override fun onFail(code: String?, message: String?) {}
|
||
})
|
||
}
|
||
} else {
|
||
MgcAccountManager.exitAccount(context, object : SyncUserInfoListener {
|
||
override fun onSuccess(data: LoginResultBean?) {}
|
||
|
||
override fun onFail(code: String?, message: String?) {}
|
||
})
|
||
}
|
||
Leto.getInstance().startGameCenter(context)
|
||
}*/
|
||
|
||
/**
|
||
* 跳转分类
|
||
*/
|
||
@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)
|
||
}
|
||
|
||
/**
|
||
* 跳转到问题标签详情
|
||
*/
|
||
@JvmStatic
|
||
fun directAskColumnLabelDetail(context: Context, tag: String, community: CommunityEntity, entrance: String? = null, path: String? = "") {
|
||
val bundle = Bundle()
|
||
bundle.putString(KEY_TO, AskColumnDetailActivity::class.java.name)
|
||
bundle.putString(KEY_ASK_TAG, tag)
|
||
bundle.putParcelable(KEY_COMMUNITY_DATA, community)
|
||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||
bundle.putString(KEY_PATH, path)
|
||
jumpActivity(context, bundle)
|
||
}
|
||
|
||
/**
|
||
* 跳转到专栏详情
|
||
*/
|
||
@JvmStatic
|
||
fun directAskColumnDetail(context: Context, columnId: String, community: CommunityEntity, entrance: String? = null, path: String? = "") {
|
||
if (columnId.isEmpty()) return
|
||
val bundle = Bundle()
|
||
bundle.putString(KEY_TO, AskColumnDetailActivity::class.java.name)
|
||
bundle.putString(KEY_COLUMN_ID, columnId)
|
||
bundle.putParcelable(KEY_COMMUNITY_DATA, community)
|
||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||
bundle.putString(KEY_PATH, path)
|
||
jumpActivity(context, bundle)
|
||
}
|
||
|
||
/**
|
||
* 跳转到板块
|
||
*/
|
||
@JvmStatic
|
||
fun directToBlock(context: Context, blockData: SubjectRecommendEntity, entrance: String) {
|
||
val bundle = Bundle()
|
||
bundle.putString(KEY_TO, BlockActivity::class.java.name)
|
||
bundle.putParcelable(KEY_BLOCK_DATA, blockData)
|
||
bundle.putString(KEY_ENTRANCE, entrance)
|
||
jumpActivity(context, bundle)
|
||
}
|
||
|
||
/**
|
||
* 跳转到开服表
|
||
*/
|
||
@JvmStatic
|
||
fun directToGameServers(context: Context, entrance: String, path: String) {
|
||
val bundle = Bundle()
|
||
bundle.putString(KEY_TO, GameServersActivity::class.java.name)
|
||
bundle.putString(KEY_ENTRANCE, ToolBarActivity.mergeEntranceAndPath(entrance, path))
|
||
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 directSimpleArticleList(context: Context, sortType: String, entrance: String? = null, path: String? = "") {
|
||
if (sortType.isEmpty()) return
|
||
val bundle = Bundle()
|
||
bundle.putString(KEY_TO, SimpleArticleListActivity::class.java.name)
|
||
bundle.putString(KEY_TYPE, sortType)
|
||
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(HaloApp.getInstance().application)
|
||
.sensitiveApi
|
||
.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.INDEX_TRENDES, 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)
|
||
}
|
||
|
||
/**
|
||
* 到首页-首页 tab
|
||
*/
|
||
@JvmStatic
|
||
fun directToHomeTab(context: Context) {
|
||
if (RunningUtils.isRunning(context)
|
||
&& MainActivity::class.java.name == RunningUtils.getBaseActivity(context)) {
|
||
val intent = Intent(context, MainActivity::class.java)
|
||
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||
context.startActivity(intent)
|
||
|
||
// 这里换个线程操作是为了做一点延时
|
||
AppExecutor.ioExecutor.execute {
|
||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_HOME))
|
||
}
|
||
} else {
|
||
jumpActivity(context, Bundle().apply { putInt(KEY_POSITION, MainWrapperFragment.INDEX_HOME) })
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 到首页-论坛 tab
|
||
*/
|
||
@JvmStatic
|
||
fun directToForum(context: Context) {
|
||
if (RunningUtils.isRunning(context)
|
||
&& MainActivity::class.java.name == RunningUtils.getBaseActivity(context)) {
|
||
val intent = Intent(context, MainActivity::class.java)
|
||
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||
context.startActivity(intent)
|
||
|
||
// 这里换个线程操作是为了做一点延时
|
||
AppExecutor.ioExecutor.execute {
|
||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_ASK))
|
||
}
|
||
} else {
|
||
jumpActivity(context, Bundle().apply { putInt(KEY_POSITION, MainWrapperFragment.INDEX_ASK) })
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 到首页-视频 tab
|
||
*/
|
||
@JvmStatic
|
||
fun directToVideoTab(context: Context) {
|
||
if (RunningUtils.isRunning(context)
|
||
&& MainActivity::class.java.name == RunningUtils.getBaseActivity(context)) {
|
||
val intent = Intent(context, MainActivity::class.java)
|
||
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||
context.startActivity(intent)
|
||
|
||
// 这里换个线程操作是为了做一点延时
|
||
AppExecutor.ioExecutor.execute {
|
||
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 (RunningUtils.isRunning(context)
|
||
&& MainActivity::class.java.name == RunningUtils.getBaseActivity(context)) {
|
||
val intent = Intent(context, MainActivity::class.java)
|
||
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||
context.startActivity(intent)
|
||
|
||
// 这里换个线程操作是为了做一点延时
|
||
AppExecutor.ioExecutor.execute {
|
||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_PERSONAL))
|
||
}
|
||
} else {
|
||
jumpActivity(context, Bundle().apply { putInt(KEY_POSITION, MainWrapperFragment.INDEX_PERSONAL) })
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 跳转至使用帮助与反馈
|
||
* @param position 使用帮助:[HelpAndFeedbackActivity.HELP_ITEM],意见反馈:[HelpAndFeedbackActivity.SUGGESTION_ITEM]
|
||
*/
|
||
@JvmStatic
|
||
fun directToHelpAndFeedback(context: Context, position: Int = HelpAndFeedbackActivity.HELP_ITEM) {
|
||
val bundle = Bundle()
|
||
bundle.putString(KEY_TO, HelpAndFeedbackActivity::class.java.name)
|
||
bundle.putInt(BaseActivity_TabLayout.PAGE_INDEX, position)
|
||
jumpActivity(context, bundle)
|
||
}
|
||
|
||
/**
|
||
* 跳转至商品详情
|
||
*/
|
||
@JvmStatic
|
||
fun directToCommodityDetail(context: Context, commodityId: String) {
|
||
var url: String = if ("internal" == BuildConfig.FLAVOR) {
|
||
Constants.COMMODITY_DETAIL_ADDRESS_DEV
|
||
} else {
|
||
Constants.COMMODITY_DETAIL_ADDRESS
|
||
}
|
||
|
||
url = String.format(Locale.CHINA, "%s&shopid=%s×tamp=%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 ("internal" == BuildConfig.FLAVOR) {
|
||
Constants.ENERGY_RECORD_ADDRESS_DEV
|
||
} else {
|
||
Constants.ENERGY_RECORD_ADDRESS
|
||
}
|
||
|
||
url = String.format(Locale.CHINA, "%s&position=%s×tamp=%d", url, position, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||
directToFullScreenWebPage(context, url, true)
|
||
}
|
||
|
||
/**
|
||
* 跳转至订单中心
|
||
*/
|
||
@JvmStatic
|
||
fun directToOrderCenter(context: Context) {
|
||
var url: String = if ("internal" == BuildConfig.FLAVOR) {
|
||
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 ("internal" == BuildConfig.FLAVOR) {
|
||
Constants.ORDER_DETAIL_ADDRESS_DEV
|
||
} else {
|
||
Constants.ORDER_DETAIL_ADDRESS
|
||
}
|
||
|
||
url = String.format(Locale.CHINA, "%s&order_id=%s×tamp=%d", url, orderId, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||
directToFullScreenWebPage(context, url, true)
|
||
}
|
||
} |