115 lines
5.2 KiB
Java
115 lines
5.2 KiB
Java
package com.gh.gamecenter;
|
||
|
||
import android.content.Intent;
|
||
import android.net.Uri;
|
||
import android.os.Bundle;
|
||
import android.text.TextUtils;
|
||
|
||
import com.gh.base.BaseActivity;
|
||
import com.gh.common.util.DirectUtils;
|
||
import com.gh.common.util.PlatformUtils;
|
||
import com.gh.common.util.RunningUtils;
|
||
import com.gh.gamecenter.entity.CommunityEntity;
|
||
import com.gh.gamecenter.manager.UserManager;
|
||
import com.lightgame.config.CommonDebug;
|
||
import com.lightgame.utils.Utils;
|
||
|
||
import static com.gh.common.util.EntranceUtils.ENTRANCE_BROWSER;
|
||
import static com.gh.common.util.EntranceUtils.HOST_ANSWER;
|
||
import static com.gh.common.util.EntranceUtils.HOST_ARTICLE;
|
||
import static com.gh.common.util.EntranceUtils.HOST_COLUMN;
|
||
import static com.gh.common.util.EntranceUtils.HOST_COMMUNITY;
|
||
import static com.gh.common.util.EntranceUtils.HOST_COMMUNITY_ARTICLE;
|
||
import static com.gh.common.util.EntranceUtils.HOST_DOWNLOAD;
|
||
import static com.gh.common.util.EntranceUtils.HOST_GAME;
|
||
import static com.gh.common.util.EntranceUtils.HOST_QUESTION;
|
||
import static com.gh.common.util.EntranceUtils.HOST_SUGGESTION;
|
||
import static com.gh.common.util.EntranceUtils.KEY_GAME_NAME;
|
||
import static com.gh.common.util.EntranceUtils.KEY_NAME;
|
||
import static com.gh.common.util.EntranceUtils.KEY_PACKAGENAME;
|
||
import static com.gh.common.util.EntranceUtils.KEY_PLATFORM;
|
||
import static com.gh.common.util.EntranceUtils.KEY_VERSION;
|
||
|
||
/**
|
||
* Created by LGT on 2016/11/16.
|
||
* 链接跳转用
|
||
*/
|
||
public class SkipActivity extends BaseActivity {
|
||
|
||
@Override
|
||
protected int getLayoutId() {
|
||
//TODO 暂时无意义设置,避免崩溃罢了,修改完主题和Toolbar相关内容会干掉这个
|
||
return R.layout.fragment_main;
|
||
}
|
||
|
||
@Override
|
||
protected void onCreate(Bundle savedInstanceState) {
|
||
super.onCreate(savedInstanceState);
|
||
|
||
Uri uri = getIntent().getData();
|
||
if (uri != null) {
|
||
if (CommonDebug.IS_DEBUG) {
|
||
Utils.log("SkipActivity:: Uri=>" + uri.toString());
|
||
}
|
||
String host = uri.getHost();
|
||
String id = uri.getPath();
|
||
String name = uri.getQueryParameter("name");
|
||
if (!TextUtils.isEmpty(id)) {
|
||
id = id.substring(1);
|
||
}
|
||
|
||
if (host != null) {
|
||
switch (host) {
|
||
case HOST_ARTICLE:
|
||
DirectUtils.directToArticle(this, id, ENTRANCE_BROWSER);
|
||
break;
|
||
case HOST_GAME:
|
||
DirectUtils.directToGameDetail(this, id, ENTRANCE_BROWSER, false);
|
||
break;
|
||
case HOST_COLUMN:
|
||
DirectUtils.directToSubject(this, id, uri.getQueryParameter(KEY_NAME), ENTRANCE_BROWSER);
|
||
break;
|
||
case HOST_SUGGESTION:
|
||
String platform = uri.getQueryParameter(KEY_PLATFORM);
|
||
String platformName = PlatformUtils.getInstance(this).getPlatformName(platform);
|
||
String content = String.format("%s-%s-V%s,",
|
||
uri.getQueryParameter(KEY_GAME_NAME),
|
||
TextUtils.isEmpty(platformName) ? platform : platformName,
|
||
uri.getQueryParameter(KEY_VERSION));
|
||
DirectUtils.directToFeedback(this, content, ENTRANCE_BROWSER);
|
||
break;
|
||
case HOST_DOWNLOAD:
|
||
DirectUtils.directToDownloadManagerAndStartUpdate(this, id, uri.getQueryParameter(KEY_PACKAGENAME), ENTRANCE_BROWSER);
|
||
break;
|
||
case HOST_ANSWER:
|
||
DirectUtils.directToAnswerDetail(this, id, ENTRANCE_BROWSER, "浏览器");
|
||
break;
|
||
case HOST_QUESTION:
|
||
DirectUtils.directToQuestionDetail(this, id, ENTRANCE_BROWSER, "浏览器");
|
||
break;
|
||
case HOST_COMMUNITY:
|
||
Intent intent;
|
||
UserManager.getInstance().setCommunityData(new CommunityEntity(id, name));
|
||
// 把切换放到 MainActivity 处理
|
||
if (RunningUtils.isRunning(this)
|
||
&& MainActivity.class.getName().equals(RunningUtils.getBaseActivity(this))) {
|
||
intent = new Intent(this, MainActivity.class);
|
||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||
intent.putExtra(MainActivity.SWITCH_TO_COMMUNITY, true);
|
||
} else {
|
||
Bundle bundle = new Bundle();
|
||
bundle.putBoolean(MainActivity.SWITCH_TO_COMMUNITY, true);
|
||
intent = SplashScreenActivity.getSplashScreenIntent(this, bundle);
|
||
}
|
||
startActivity(intent);
|
||
break;
|
||
case HOST_COMMUNITY_ARTICLE:
|
||
DirectUtils.directToCommunityArticle(this, uri.getQueryParameter("articleId"), uri.getQueryParameter("communityId"), ENTRANCE_BROWSER);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
finish();
|
||
}
|
||
}
|