TestActivity.java 7.28 KB
package com.cnlive.strike.moduleuser;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;

import androidx.annotation.Nullable;

import com.cnlive.strike.moudle.user.model.UserConst;
import com.cnlive.strike.moudle.user.ui.activity.FirstLoginActivity;
import com.cnlive.strike.moudle.user.ui.activity.LoginActivity;
import com.cnlive.strike.moudle.user.ui.activity.MainTestActivity;
import com.cnlive.strike.moudle.user.ui.activity.PersonalDataActivity;
import com.cnlive.strike.user.auth.UserService;

public class TestActivity extends Activity {
    private int eventType;
    private boolean isHasOtherUserInfo = false;
    private String TAG = "TestActivity";

    /************MainActivity   所需要的数据***********/
    private String type;
    private Uri uri;
    private boolean clickAd;
    private String sharetype;
    private String classifyTagMsg;
    /************LoginActivity  所需要的数据***********/
    private String tagMsg;
    /************修改用户头像 所需要的数据***********/
    private String faceUrl;
    /************修改用户昵称 所需要的数据***********/
    private String nickName;
    /************CoinRainAction 所需要的数据***********/
    private String taskId;
    private String contentId;
    private String addtype;
    private Boolean isDouyin;

    @Override
    protected void onCreate(@Nullable @android.support.annotation.Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (null != getIntent().getExtras()) {
            eventType = getIntent().getExtras().getInt("eventType");
            initAction(eventType);
        }
    }

    private void initAction(int eventType) {
        switch (eventType) {
            //是新用户
            case UserConst.IS_NEW_USER://是新用户
                Log.e(TAG, "是新用户");

                //TODO 必须设置用户头像
                //OpenInstall用户注册统计
//                        OpenInstall.reportRegister();
                //友盟账号登录统计,暂时只有平台登录,后续对接三方登录
//                        MobclickAgent.onProfileSignIn("CNLive", user.getUid());
                isHasOtherUserInfo = getIntent().getExtras().getBoolean("isHasOtherUserInfo");

                //判断是否有其他平台数据
                if (isHasOtherUserInfo) {
                    type = getIntent().getExtras().getString("type");
                    uri = (Uri) getIntent().getExtras().get("uri");
                    clickAd = getIntent().getExtras().getBoolean(LoginActivity.TAG_CLICK_AD);
                    sharetype = getIntent().getExtras().getString("sharetype");
                    classifyTagMsg = getIntent().getExtras().getString("classifyTagMsg");


                    //直接显示主视图
                    Intent intent = new Intent(this, MainTestActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                    intent.putExtra("type", type);
                    intent.putExtra("uri", uri);
                    intent.putExtra(LoginActivity.TAG_CLICK_AD, clickAd);
                    intent.putExtra("sharetype", sharetype);
                    if (!TextUtils.isEmpty(classifyTagMsg)) {
                        intent.putExtra("classifyTagMsg", classifyTagMsg);
                    }
                    startActivity(intent);
                } else {
                    tagMsg = getIntent().getExtras().getString("tagMsg");
                    clickAd = getIntent().getExtras().getBoolean(LoginActivity.TAG_CLICK_AD);
                    //没有第三方数据,跳转到设置用户信息的界面
                    Intent intent = new Intent(this, FirstLoginActivity.class);
                    intent.putExtra(LoginActivity.TAG_MSG, TextUtils.isEmpty(tagMsg) ? "" : tagMsg);
                    intent.putExtra(LoginActivity.TAG_CLICK_AD, clickAd);
                    startActivity(intent);

                }
                Log.e(TAG, "initAction: ");
                finish();
                break;
            case UserConst.IS_NOT_NEW_USER://不是新用户
                //todo
                //友盟账号登录统计,暂时只有平台登录,后续对接三方登录
//                        MobclickAgent.onProfileSignIn("CNLive", user.getUid());
                type = getIntent().getExtras().getString("type");
                uri = (Uri) getIntent().getExtras().get("uri");
                clickAd = getIntent().getExtras().getBoolean(LoginActivity.TAG_CLICK_AD);
                sharetype = getIntent().getExtras().getString("sharetype");
                classifyTagMsg = getIntent().getExtras().getString("classifyTagMsg");
                //直接显示主视图
//                Intent intent = new Intent(this, MainTestActivity.class);
//                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
//                intent.putExtra("type", type);
//                intent.putExtra("uri", uri);
//                intent.putExtra(LoginActivity.TAG_CLICK_AD, clickAd);
//                intent.putExtra("sharetype", sharetype);
//                if (!TextUtils.isEmpty(classifyTagMsg)) {
//                    intent.putExtra("classifyTagMsg", classifyTagMsg);
//                }
//                startActivity(intent);
                PersonalDataActivity.startActivity(this);
                Log.e(TAG, "不是新用户");
                finish();
                break;

            case UserConst.MODIFY_USER_IMAGE://修改用户头像
                Log.e(TAG, "修改用户头像");

                faceUrl = getIntent().getExtras().getString("faceUrl");
                //todo
//                LoginManager.modifyUserImage(UserService.getUid(this), faceUrl);
                finish();
                break;

            case UserConst.USER_INVALID://用户失效
                Log.e(TAG, "用户失效");

                //todo
                // UserOfflineUtil.userInvalid(context);
                finish();
            case UserConst.MODIFY_USER_NAME://修改用户名称
                //todo
                Log.e(TAG, "修改用户名称");
                nickName = getIntent().getExtras().getString("nickName");
                // LoginManager.modifyUserName( UserService.getUid(context), nickName);

                finish();
                break;
            case UserConst.COIN_RAIN_ACTION://下金币
                Log.e(TAG, "下金币");
                //todo
                taskId = getIntent().getExtras().getString("taskId");
                contentId = getIntent().getExtras().getString("contentId");
                addtype = getIntent().getExtras().getString("addtype");
                isDouyin = getIntent().getExtras().getBoolean("isDouyin");
                if (TextUtils.isEmpty(taskId)) {
                    taskId = "";
                }
                if (TextUtils.isEmpty(contentId)) {
                    contentId = "";
                }
                if (TextUtils.isEmpty(addtype)) {
                    addtype = "";
                }
                //CoinRainAction.code(activity, UserService.getUid(activity), taskId,contentId, addtype,isDouyin);

                break;
        }
    }

}