导航菜单

页面标题

页面副标题

自健身 v3.3.4 - WelcomeActivity.java 源代码

正在查看: 自健身 v3.3.4 应用的 WelcomeActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.mu.gymtrain.Activity;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import butterknife.BindView;
import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.PathUtils;
import com.hjq.http.EasyConfig;
import com.mu.gymtrain.Base.BaseActivity;
import com.mu.gymtrain.Bean.Event;
import com.mu.gymtrain.Http.CreatMap;
import com.mu.gymtrain.Http.HttpHelper;
import com.mu.gymtrain.R;
import com.mu.gymtrain.Utils.FinalTools;
import com.mu.gymtrain.Utils.PreferenceUtils;
import com.mu.gymtrain.Utils.ToastUtils;
import com.mu.gymtrain.Utils.UrlConfig;
import java.io.IOException;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class WelcomeActivity extends BaseActivity {

    @BindView(R.id.iv_temp)
    ImageView ivtemp;

    public int getContentLayout() {
        return R.layout.activity_welcome;
    }

    public void initView() {
    }

    public void onClick(View v) {
    }

    public void initData() {
        String str = PathUtils.getExternalStoragePath() + "/Android/日志信息";
        if (FileUtils.createOrExistsDir(str)) {
            LogUtils.getConfig().setDir(str);
        }
        if (TextUtils.isEmpty(getGymIdFromSP())) {
            saveGymIdToSP(Event.DELETE_COMMENT);
            saveGymNameToSP("朝阳门店");
        }
        to();
    }

    private void to() {
        if (TextUtils.isEmpty(getToken())) {
            startActivity(new Intent((Context) this, (Class<?>) RegistActivity.class));
            finish();
        } else {
            checkToken();
        }
    }

    private void checkToken() {
        HttpHelper.getInstance().getRetrofitService(this).getUserWeightTest(new CreatMap.Builder().addParams("pageindex", "1").addParams("pagesize", "1").build().getParam()).enqueue(new Callback<ResponseBody>() {
            @Override
            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                try {
                    if (((ResponseBody) response.body()).string().contains("20000")) {
                        WelcomeActivity.this.showToast("登录状态失效,请重新登录");
                        PreferenceUtils.getInstance().saveString(FinalTools.TOKEN, "");
                        WelcomeActivity.this.startActivity(new Intent((Context) WelcomeActivity.this, (Class<?>) RegistActivity.class));
                    } else {
                        EasyConfig.getInstance().addHeader(UrlConfig.Params.TOKEN, WelcomeActivity.this.getToken());
                        WelcomeActivity.this.startActivity(new Intent((Context) WelcomeActivity.this, (Class<?>) MainActivity.class));
                    }
                    WelcomeActivity.this.finish();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onFailure(Call<ResponseBody> call, Throwable t) {
                ToastUtils.show(WelcomeActivity.this, "没有网络");
                WelcomeActivity.this.startActivity(new Intent((Context) WelcomeActivity.this, (Class<?>) RegistActivity.class));
                WelcomeActivity.this.finish();
            }
        });
    }
}