正在查看: WeatherSense v1.8.9 应用的 SplashActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: WeatherSense v1.8.9 应用的 SplashActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.emax.weather.ui.activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.widget.LinearLayout;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.emax.weahter.R;
import com.emax.weather.base.BaseActivity;
import com.emax.weather.bean.AlarmEventType;
import com.emax.weather.bean.User;
import com.emax.weather.bean.db.DaoHadle;
import com.emax.weather.net.RetrofitUtil;
import com.emax.weather.util.AndroidScheduler;
import com.emax.weather.utils.RxUtil;
import com.ezon.health.utils_lib.SharedPre;
import com.ezon.health.utils_lib.SharedPreUtils;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
public class SplashActivity extends BaseActivity {
private Disposable disposable;
@BindView(R.id.llFactoryModule)
LinearLayout factoryModuleLl;
private boolean isGetUser = false;
private String token;
@Override
protected int getActivityRId() {
return R.layout.activity_splash;
}
public void responseSettingSuccess() {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.out.println("lyq activity SplashActivity - SplashActivity");
ButterKnife.bind(this);
initPage();
String string = SharedPreUtils.getString(this, SharedPre.Alarm.ALARM_INFO);
if (TextUtils.isEmpty(string)) {
return;
}
List list = (List) new Gson().fromJson(string, new TypeToken<ArrayList<AlarmEventType>>() {
}.getType());
for (int i = 0; i < list.size(); i++) {
AlarmEventType alarmEventType = (AlarmEventType) list.get(i);
if (!alarmEventType.isOffLine()) {
list.remove(alarmEventType);
System.out.println("lyq alarm SplashActivity 清空非离线推送数据");
}
}
if (list != null && list.size() > 0) {
String json = new Gson().toJson(list);
System.out.println("lyq alarm SplashActivity putString result:" + json);
SharedPreUtils.putString(this, SharedPre.Alarm.ALARM_INFO, json);
return;
}
System.out.println("lyq alarm SplashActivity putString 空字符串");
SharedPreUtils.putString(this, SharedPre.Alarm.ALARM_INFO, "");
}
private void initPage() {
int i = SharedPreUtils.getInt(this, SharedPre.FactoryUrl.FACTORY_URL, -1);
if (i == -1) {
SharedPreUtils.putInt(this, SharedPre.FactoryUrl.FACTORY_URL, 0);
i = 0;
}
if (i == 0) {
RetrofitUtil.setUrl(0);
this.factoryModuleLl.setVisibility(8);
} else {
RetrofitUtil.setUrl(1);
this.factoryModuleLl.setVisibility(0);
}
RxUtil.addWork(new RxUtil.RxActionListener<User>() {
@Override
public User doAction() {
return DaoHadle.getUser();
}
@Override
public void reponseAction(User user) {
System.out.println("用户数据获取成功 reponseAction");
SplashActivity.this.isGetUser = true;
SplashActivity.this.token = DaoHadle.getUser().getToken();
}
@Override
public void reponseDataNull() {
System.out.println("用户数据获取成功 reponseDataNull");
SplashActivity.this.isGetUser = true;
}
@Override
public void reponseError(Throwable e) {
System.out.println("用户数据获取成功 reponseError " + e.getMessage());
SplashActivity.this.isGetUser = true;
}
});
this.disposable = Observable.interval(1500L, TimeUnit.MILLISECONDS).observeOn(AndroidScheduler.mainThread()).subscribe(new Consumer() {
public final void accept(Object obj) {
SplashActivity.this.lambda$initPage$0$SplashActivity((Long) obj);
}
}, new Consumer() {
public final void accept(Object obj) {
System.out.print("throwable.getMessage() = " + ((Throwable) obj).getMessage());
}
});
}
public void lambda$initPage$0$SplashActivity(Long l) throws Exception {
System.out.println("等待获取用户数据 :" + this.isGetUser);
if (this.isGetUser) {
clearDisposable();
if (this.token != null) {
startActivity(new Intent(this, (Class<?>) MainActivity.class));
finish();
} else {
startActivity(new Intent(this, (Class<?>) LoginActivity.class));
finish();
}
}
}
private void saveValue(boolean t) {
SharedPreferences.Editor edit = getSharedPreferences("my_prefs", 0).edit();
edit.putBoolean("privacy", t);
edit.apply();
}
private boolean getPrivacyValue() {
return getSharedPreferences("my_prefs", 0).getBoolean("privacy", false);
}
@Override
protected void onResume() {
List arrayList;
super.onResume();
Intent intent = getIntent();
Log.i("lyq Umeng", "lyq splash intent:" + intent.toString());
Bundle extras = intent.getExtras();
if (extras != null) {
try {
Log.i("lyq Umeng", "lyq splash bun != null");
for (String str : extras.keySet()) {
String string = extras.getString(str);
Log.i("lyq Umeng", "key = " + str + " value = " + string);
if ("weather_content".equals(str)) {
AlarmEventType alarmEventType = (AlarmEventType) new Gson().fromJson(string, AlarmEventType.class);
String string2 = SharedPreUtils.getString(this, SharedPre.Alarm.ALARM_INFO);
if (!TextUtils.isEmpty(string2)) {
arrayList = (List) new Gson().fromJson(string2, new TypeToken<ArrayList<AlarmEventType>>() {
}.getType());
if (arrayList == null) {
arrayList = new ArrayList();
}
} else {
arrayList = new ArrayList();
}
arrayList.add(alarmEventType);
SharedPreUtils.putString(this, SharedPre.Alarm.ALARM_INFO, new Gson().toJson(arrayList));
}
}
return;
} catch (Exception e) {
Log.i("lyq Umeng", "e.printStackTrace:" + e.toString());
e.printStackTrace();
return;
}
}
Log.i("lyq Umeng", "bun == null");
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
private void clearDisposable() {
Disposable disposable = this.disposable;
if (disposable == null || disposable.isDisposed()) {
return;
}
this.disposable.dispose();
this.disposable = null;
}
@Override
protected void onDestroy() {
super.onDestroy();
}
}