正在查看: WeatherSense v1.8.9 应用的 SettingActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: WeatherSense v1.8.9 应用的 SettingActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.emax.weather.ui.activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.emax.weahter.R;
import com.emax.weather.base.ActivityCollector;
import com.emax.weather.base.MvpBaseActivity;
import com.emax.weather.base.RxBus;
import com.emax.weather.bean.RxBusEvent;
import com.emax.weather.bean.Unit;
import com.emax.weather.bean.db.DaoHadle;
import com.emax.weather.event.UnitSettingEvent;
import com.emax.weather.presenter.UnitSettingPresenterImp;
import com.emax.weather.service.HistroyDataService;
import com.emax.weather.util.AndroidScheduler;
import com.emax.weather.utils.CheckClickUtils;
import com.emax.weather.utils.MyInternalStorage;
import com.emax.weather.widget.CheckPopWindow;
import com.emax.weather.widget.DeleteAccountWindow;
import com.emax.weather.widget.PressureUnitPopWindow;
import com.emax.weather.widget.RainVolumeUnitPopWindow;
import com.emax.weather.widget.TemperatureUnitPopWindow;
import com.emax.weather.widget.WindSpeendUnitPopWindow;
import com.ezon.health.utils_lib.SharedPre;
import com.ezon.health.utils_lib.SharedPreUtils;
import com.ezon.health.utils_lib.ToastUtil;
import com.umeng.message.PushAgent;
import com.umeng.message.api.UPushAliasCallback;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import java.io.File;
public class SettingActivity extends MvpBaseActivity<UnitSettingEvent.UnitSettingView, UnitSettingPresenterImp> implements UnitSettingEvent.UnitSettingView, TemperatureUnitPopWindow.OnCheckClickListener, PressureUnitPopWindow.OnCheckClickListener, CheckPopWindow.OnCheckClickListener, WindSpeendUnitPopWindow.OnCheckClickListener, RainVolumeUnitPopWindow.OnCheckClickListener, DeleteAccountWindow.OnCheckClickListener {
@BindView(R.id.back_sub)
ImageView backSub;
private CheckPopWindow checkPopWindow;
@BindView(R.id.delete_account_tv)
TextView deleteAccountTv;
private DeleteAccountWindow deleteAccountWindow;
private Disposable disposable;
@BindView(R.id.llFactoryModule)
LinearLayout factoryModuleLl;
private boolean isLog = true;
@BindView(R.id.log_out_btn)
Button logOutBtn;
@BindView(R.id.master_hint)
TextView masterHint;
@BindView(R.id.master_pressure_enter_iv)
ImageView masterPressureEnterIv;
@BindView(R.id.master_pressure_lable)
TextView masterPressureLable;
@BindView(R.id.master_pressure_rl)
RelativeLayout masterPressureRl;
@BindView(R.id.master_pressure_value)
TextView masterPressureValue;
@BindView(R.id.master_rain_rl)
RelativeLayout masterRainRl;
@BindView(R.id.master_rain_value)
TextView masterRainVolume;
@BindView(R.id.master_temperature_enter_iv)
ImageView masterTemperatureEnterIv;
@BindView(R.id.master_temperature_lable)
TextView masterTemperatureLable;
@BindView(R.id.master_temperature_rl)
RelativeLayout masterTemperatureRl;
@BindView(R.id.master_temperature_value)
TextView masterTemperatureValue;
@BindView(R.id.master_wind_enter_iv)
ImageView masterWindEnterIv;
@BindView(R.id.master_wind_lable)
TextView masterWindLable;
@BindView(R.id.master_wind_rl)
RelativeLayout masterWindRl;
@BindView(R.id.master_wind_value)
TextView masterWindValue;
private PressureUnitPopWindow pressureUnitPopWindow;
private RainVolumeUnitPopWindow rainVolumeUnitPopWindow;
@BindView(R.id.setting)
TextView setting;
private TemperatureUnitPopWindow temperaturePopWindow;
@BindView(R.id.title_rl)
RelativeLayout titleRl;
@BindView(R.id.title_sub)
TextView titleSub;
private Unit unit;
private WindSpeendUnitPopWindow windSpeendUnitPopWindow;
@Override
protected int getActivityRId() {
return R.layout.activity_setting;
}
@Override
public Context getContext() {
return this;
}
@Override
public void onReject() {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ButterKnife.bind(this);
if (SharedPreUtils.getInt(this, SharedPre.FactoryUrl.FACTORY_URL, -1) == 0) {
this.factoryModuleLl.setVisibility(8);
} else {
this.factoryModuleLl.setVisibility(0);
}
this.titleSub.setText(getString(R.string.Setting));
((UnitSettingPresenterImp) this.mPresenter).requestData();
this.masterRainRl.setVisibility(SharedPreUtils.getInt(this, SharedPre.App.SERIAL, 1) != 1 ? 0 : 8);
this.disposable = RxBus.getInstance().toObserverable(RxBusEvent.class).subscribeOn(AndroidScheduler.mainThread()).subscribe(new Consumer<RxBusEvent>() {
public void accept(RxBusEvent rxBusEvent) throws Exception {
if (MainActivity.NOT_DEVICE.equals(rxBusEvent.getUpdateTheData()) && SettingActivity.this.isLog) {
SettingActivity.this.isLog = false;
SettingActivity.this.dismissLoadingViews();
Toast.makeText(SettingActivity.this, rxBusEvent.getError(), 0).show();
}
}
});
}
@Override
public UnitSettingPresenterImp createPresenter() {
return new UnitSettingPresenterImp(this);
}
@OnClick({R.id.master_temperature_rl, R.id.master_pressure_rl, R.id.log_out_btn, R.id.master_wind_rl, R.id.master_rain_rl, R.id.delete_account_tv})
public void onViewClicked(View view) {
if (CheckClickUtils.isFastClick()) {
}
switch (view.getId()) {
case R.id.delete_account_tv:
DeleteAccountWindow deleteAccountWindow = new DeleteAccountWindow(this, this);
this.deleteAccountWindow = deleteAccountWindow;
deleteAccountWindow.showPopupWindow(view);
break;
case R.id.log_out_btn:
CheckPopWindow checkPopWindow = new CheckPopWindow(this, getString(R.string.sure_to_log_out), this);
this.checkPopWindow = checkPopWindow;
checkPopWindow.showPopupWindow(view);
break;
case R.id.master_pressure_rl:
if (this.unit == null) {
this.unit = new Unit();
}
PressureUnitPopWindow pressureUnitPopWindow = new PressureUnitPopWindow(this, this, this.unit);
this.pressureUnitPopWindow = pressureUnitPopWindow;
pressureUnitPopWindow.showPopupWindow(view);
break;
case R.id.master_rain_rl:
if (this.unit == null) {
this.unit = new Unit();
}
RainVolumeUnitPopWindow rainVolumeUnitPopWindow = new RainVolumeUnitPopWindow(this, this, this.unit);
this.rainVolumeUnitPopWindow = rainVolumeUnitPopWindow;
rainVolumeUnitPopWindow.showPopupWindow(view);
break;
case R.id.master_temperature_rl:
if (this.unit == null) {
this.unit = new Unit();
}
TemperatureUnitPopWindow temperatureUnitPopWindow = new TemperatureUnitPopWindow(this, this, this.unit);
this.temperaturePopWindow = temperatureUnitPopWindow;
temperatureUnitPopWindow.showPopupWindow(view);
break;
case R.id.master_wind_rl:
if (this.unit == null) {
this.unit = new Unit();
}
WindSpeendUnitPopWindow windSpeendUnitPopWindow = new WindSpeendUnitPopWindow(this, this, this.unit);
this.windSpeendUnitPopWindow = windSpeendUnitPopWindow;
windSpeendUnitPopWindow.showPopupWindow(view);
break;
}
}
@Override
public void onPressureAgree(int value) {
if (value == 0) {
this.masterPressureValue.setText(getString(R.string.hpa));
} else if (value == 1) {
this.masterPressureValue.setText(getString(R.string.inhg));
} else if (value == 2) {
this.masterPressureValue.setText(getString(R.string.mmhg));
}
Unit unit = new Unit();
unit.setAtmoUnit(Integer.valueOf(value));
((UnitSettingPresenterImp) this.mPresenter).UnitSettingPost(unit);
}
@Override
public void onTemperatureAgree(int value) {
if (value == 0) {
this.masterTemperatureValue.setText(getString(R.string.centigrade));
} else {
this.masterTemperatureValue.setText(getString(R.string.Fahrenheit));
}
Unit unit = new Unit();
unit.setTempUnit(Integer.valueOf(value));
((UnitSettingPresenterImp) this.mPresenter).UnitSettingPost(unit);
}
@Override
public void onWindSpeedAgree(int value) {
if (value == 0) {
this.masterWindValue.setText(getString(R.string.KPH));
} else {
this.masterWindValue.setText(getString(R.string.MPH));
}
Unit unit = new Unit();
unit.setWindSpeedUnit(Integer.valueOf(value));
((UnitSettingPresenterImp) this.mPresenter).UnitSettingPost(unit);
}
@Override
public void onRainVolumeAgree(int value) {
if (value == 0) {
this.masterRainVolume.setText(getString(R.string.inchh));
} else {
this.masterRainVolume.setText(getString(R.string.mmh));
}
Unit unit = new Unit();
unit.setRainfallUnit(Integer.valueOf(value));
((UnitSettingPresenterImp) this.mPresenter).UnitSettingPost(unit);
}
@Override
public void dismissLoadingViews() {
dismissProgressDialog();
}
@Override
public void showLoadingViews() {
showProgressDialog();
}
@Override
public void showErrorViews(int errorCode, String msg) {
try {
ToastUtil.show(msg, this);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void refreshContentView(int type, Unit data) {
this.unit = data;
if (data.getTempUnit().intValue() == 0) {
this.masterTemperatureValue.setText(getString(R.string.centigrade));
} else {
this.masterTemperatureValue.setText(getString(R.string.Fahrenheit));
}
if (data.getAtmoUnit().intValue() == 0) {
this.masterPressureValue.setText(getString(R.string.hpa));
} else if (data.getAtmoUnit().intValue() == 1) {
this.masterPressureValue.setText(getString(R.string.inhg));
} else if (data.getAtmoUnit().intValue() == 2) {
this.masterPressureValue.setText(getString(R.string.mmhg));
}
if (data.getWindSpeedUnit().intValue() == 0) {
this.masterWindValue.setText(getString(R.string.KPH));
} else if (data.getWindSpeedUnit().intValue() == 1) {
this.masterWindValue.setText(getString(R.string.MPH));
}
if (data.getRainfallUnit() != null) {
if (data.getRainfallUnit().intValue() == 0) {
this.masterRainVolume.setText(getResources().getString(R.string.inchh));
} else if (data.getRainfallUnit().intValue() == 1) {
this.masterRainVolume.setText(getResources().getString(R.string.mmh));
}
}
}
@Override
public void showToastMessage(int msg) {
ToastUtil.show(getString(msg), this);
}
@Override
public void settingSuccess() {
showToastMessage(R.string.setting_successed);
}
@Override
public Unit getUnit() {
return this.unit;
}
@Override
public void deleteSuccess() {
Toast.makeText(this, getResources().getString(R.string.Delete_Account_Success), 0).show();
DaoHadle.deleteData();
String string = SharedPreUtils.getString(this, SharedPre.Alarm.DEVICE_NAME, "");
SharedPreUtils.clearSharedPre(this);
SharedPreUtils.putString(this, SharedPre.Alarm.DEVICE_NAME, string);
ActivityCollector.finishAll();
startActivity(new Intent(this, (Class<?>) LoginActivity.class));
}
@Override
public void deleteFail() {
Toast.makeText(this, getResources().getString(R.string.Delete_Account_Fail), 0).show();
}
@Override
public void settingFail() {
this.masterTemperatureValue.setText(getString(R.string.centigrade));
this.masterPressureValue.setText(getString(R.string.hpa));
this.masterWindValue.setText(getString(R.string.KPH));
this.masterRainVolume.setText(getResources().getString(R.string.inchh));
}
@Override
public void onAgree() {
PushAgent.getInstance(this).deleteAlias(DaoHadle.getUser().getOpenid(), "EZON_HEALTH", new UPushAliasCallback() {
public final void onMessage(boolean z, Object obj) {
System.out.println("----------------删除友盟别名--------------" + z);
}
});
HistroyDataService.stopService(this);
DaoHadle.cleanData();
new MyInternalStorage(this).delete("YahooData.txt");
File[] listFiles = new File(getApplicationContext().getFilesDir().getAbsolutePath() + "/history").listFiles();
if (listFiles != null) {
for (File file : listFiles) {
file.delete();
}
}
File[] listFiles2 = new File(getApplicationContext().getExternalFilesDir(null).getAbsolutePath() + "/history").listFiles();
if (listFiles2 != null) {
for (File file2 : listFiles2) {
file2.delete();
}
}
ActivityCollector.finishAll();
startActivity(new Intent(this, (Class<?>) LoginActivity.class));
String string = SharedPreUtils.getString(this, SharedPre.User.ACCOUNT_EMAIL, "");
int i = SharedPreUtils.getInt(this, SharedPre.FactoryUrl.FACTORY_URL, -1);
String string2 = SharedPreUtils.getString(this, SharedPre.Alarm.DEVICE_NAME, "");
SharedPreUtils.clearSharedPre(this);
SharedPreUtils.putString(this, SharedPre.Alarm.DEVICE_NAME, string2);
SharedPreUtils.putString(this, SharedPre.User.ACCOUNT_EMAIL, string);
SharedPreUtils.putInt(this, SharedPre.FactoryUrl.FACTORY_URL, i);
}
@Override
public void confirm() {
((UnitSettingPresenterImp) this.mPresenter).deleteAccountPost();
}
@Override
protected void onDestroy() {
super.onDestroy();
Disposable disposable = this.disposable;
if (disposable == null || disposable.isDisposed()) {
return;
}
this.disposable.dispose();
this.disposable = null;
}
}