正在查看: WeatherSense v1.8.9 应用的 RemindActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: WeatherSense v1.8.9 应用的 RemindActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.emax.weather.ui.activity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.core.view.ViewCompat;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.emax.weahter.R;
import com.emax.weather.base.MvpBaseActivity;
import com.emax.weather.base.RxBus;
import com.emax.weather.bean.DeviceAlarm;
import com.emax.weather.bean.RxBusEvent;
import com.emax.weather.event.RemindEvent;
import com.emax.weather.presenter.RemindPresenterImp;
import com.emax.weather.util.AndroidScheduler;
import com.emax.weather.utils.AnimationUtil;
import com.emax.weather.utils.HomeUtil;
import com.emax.weather.utils.TemperatureUtils;
import com.emax.weather.widget.loopView.LoopView;
import com.emax.weather.widget.loopView.OnItemSelectedListener;
import com.ezon.health.utils_lib.SharedPre;
import com.ezon.health.utils_lib.SharedPreUtils;
import com.ezon.health.utils_lib.ToastUtil;
import com.ezon.health.widget_lib.SwitchButton;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
public class RemindActivity extends MvpBaseActivity<RemindEvent.RemindView, RemindPresenterImp> implements RemindEvent.RemindView {
public static final String CHANNEL = "CHANNEL";
public static final String TITLE = "title";
public static final String WEATHER_CODE = "WEATHER_CODE";
@BindView(R.id.airvolume_lable)
TextView airvolumeLable;
@BindView(R.id.airvolume_max_loop_view)
LoopView airvolumeMaxLoopView;
@BindView(R.id.airvolume_max_unit)
LoopView airvolumeMaxUnit;
@BindView(R.id.airvolume_min_loop_view)
LoopView airvolumeMinLoopView;
@BindView(R.id.airvolume_min_unit)
LoopView airvolumeMinUnit;
private ArrayList<String> airvolumeNormalList;
@BindView(R.id.airvolume_swich_btn)
SwitchButton airvolumeSwichBtn;
@BindView(R.id.close)
ImageView close;
private int current;
private DeviceAlarm deviceAirVolumeAlarm;
private List<DeviceAlarm> deviceAlarmList;
private DeviceAlarm deviceHumidityAlarm;
private DeviceAlarm deviceRainVolumeAlarm;
private DeviceAlarm deviceTempAlarm;
private Disposable disposable;
@BindView(R.id.llFactoryModule)
LinearLayout factoryModuleLl;
private int humidIndex;
@BindView(R.id.humidity_lable)
TextView humidityLable;
@BindView(R.id.humidity_max_loop_view)
LoopView humidityMaxLoopView;
@BindView(R.id.humidity_max_unit)
LoopView humidityMaxUnit;
@BindView(R.id.humidity_min_loop_view)
LoopView humidityMinLoopView;
@BindView(R.id.humidity_min_unit)
LoopView humidityMinUnit;
private ArrayList<String> humidityNormalList;
@BindView(R.id.humidity_swich_btn)
SwitchButton humiditySwichBtn;
private Boolean isC;
private boolean isLog = true;
@BindView(R.id.main_layout)
RelativeLayout mainLayout;
private int maxAirVolumeIndex;
private int maxAirVolumeValue;
@BindView(R.id.max_airvolume_ll)
LinearLayout maxAirvolumeLl;
@BindView(R.id.max_airvolume_title)
TextView maxAirvolumeTitle;
private int maxHumidityIndex;
@BindView(R.id.max_humidity_ll)
LinearLayout maxHumidityLl;
@BindView(R.id.max_humidity_title)
TextView maxHumidityTitle;
private int maxRainVolumeIndex;
private float maxRainVolumeValue;
@BindView(R.id.max_rainvolume_ll)
LinearLayout maxRainvolumeLl;
@BindView(R.id.max_rainvolume_title)
TextView maxRainvolumeTitle;
private int maxTemperatureIndex;
@BindView(R.id.max_temperature_ll)
LinearLayout maxTemperatureLl;
@BindView(R.id.max_temperature_title)
TextView maxTemperatureTitle;
private int maxTemperatureValue;
private int maxhumidityValue;
private int minAirVolumeIndex;
private int minAirVolumeValue;
@BindView(R.id.min_airvolume_ll)
LinearLayout minAirvolumeLl;
@BindView(R.id.min_airvolume_title)
TextView minAirvolumeTitle;
private int minHumidityIndex;
@BindView(R.id.min_humidity_ll)
LinearLayout minHumidityLl;
@BindView(R.id.min_humidity_title)
TextView minHumidityTitle;
private int minRainVolumeIndex;
private float minRainVolumeValue;
@BindView(R.id.min_rainvolume_ll)
LinearLayout minRainvolumeLl;
@BindView(R.id.min_rainvolume_title)
TextView minRainvolumeTitle;
private int minTemperatureIndex;
@BindView(R.id.min_temperature_ll)
LinearLayout minTemperatureLl;
@BindView(R.id.min_temperature_title)
TextView minTemperatureTitle;
private int minTemperatureValue;
private int minhumidityValue;
@BindView(R.id.rainvolume_lable)
TextView rainVolumeLable;
@BindView(R.id.rainvolume_max_loop_view)
LoopView rainvolumeMaxLoopView;
@BindView(R.id.rainvolume_max_unit)
LoopView rainvolumeMaxUnit;
@BindView(R.id.rainvolume_min_loop_view)
LoopView rainvolumeMinLoopView;
@BindView(R.id.rainvolume_min_unit)
LoopView rainvolumeMinUnit;
private ArrayList<String> rainvolumeNormalList;
@BindView(R.id.rainvolume_swich_btn)
SwitchButton rainvolumeSwichBtn;
@BindView(R.id.remind_air_ll)
LinearLayout remindAirLl;
@BindView(R.id.remind_rain_ll)
LinearLayout remindRainLl;
@BindView(R.id.second_main_layout)
LinearLayout secondMainLayout;
@BindView(R.id.sumbit)
ImageView sumbit;
@BindView(R.id.title_bar)
LinearLayout tbCommon;
private int tempIndex;
@BindView(R.id.temp_max_loop_view)
LoopView tempMaxLoopView;
@BindView(R.id.temp_max_unit)
LoopView tempMaxUnit;
@BindView(R.id.temp_min_loop_view)
LoopView tempMinLoopView;
@BindView(R.id.temp_min_unit)
LoopView tempMinUnit;
private ArrayList<String> tempNormalList;
@BindView(R.id.temperature_lable)
TextView temperatureLable;
@BindView(R.id.temperature_swich_btn)
SwitchButton temperatureSwichBtn;
@BindView(2131231581)
TextView title;
private String titleStr;
@BindView(R.id.title_sub)
TextView tvTitleSub;
@BindView(R.id.view2)
View view2;
@BindView(R.id.view3)
View view3;
private int weatherCode;
@Override
protected int getActivityRId() {
return R.layout.activity_remind;
}
@Override
public Context getContext() {
return this;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ButterKnife.bind(this);
this.current = getIntent().getIntExtra(CHANNEL, 0);
System.out.println("lyq check current:" + this.current);
int intExtra = getIntent().getIntExtra(WEATHER_CODE, 0);
this.weatherCode = intExtra;
if (intExtra != 9999) {
this.mainLayout.setBackgroundResource(HomeUtil.getBackGroundImage(intExtra));
this.tbCommon.setVisibility(8);
} else {
this.mainLayout.setBackgroundColor(-1);
this.secondMainLayout.setBackgroundResource(0);
this.title.setVisibility(8);
this.tbCommon.setVisibility(0);
}
this.deviceAlarmList = new ArrayList();
initView();
this.disposable = RxBus.getInstance().toObserverable(RxBusEvent.class).subscribeOn(AndroidScheduler.mainThread()).subscribe(new Consumer() {
public final void accept(Object obj) {
RemindActivity.this.lambda$onCreate$0$RemindActivity((RxBusEvent) obj);
}
}, new Consumer() {
public final void accept(Object obj) {
System.out.println("throwable.getMessage() = " + ((Throwable) obj).getMessage());
}
});
}
public void lambda$onCreate$0$RemindActivity(RxBusEvent rxBusEvent) throws Exception {
if (MainActivity.NOT_DEVICE.equals(rxBusEvent.getUpdateTheData()) && this.isLog) {
this.isLog = false;
dismissLoadingViews();
Toast.makeText(this, rxBusEvent.getError(), 0).show();
}
}
@Override
public RemindPresenterImp createPresenter() {
return new RemindPresenterImp(this);
}
private void initView() {
if (SharedPreUtils.getInt(this, SharedPre.FactoryUrl.FACTORY_URL, -1) == 0) {
this.factoryModuleLl.setVisibility(8);
} else {
this.factoryModuleLl.setVisibility(0);
}
if (this.current == 99) {
this.remindAirLl.setVisibility(0);
this.remindRainLl.setVisibility(0);
this.view2.setVisibility(0);
this.view3.setVisibility(0);
} else {
this.remindAirLl.setVisibility(8);
this.remindRainLl.setVisibility(8);
this.view2.setVisibility(8);
this.view3.setVisibility(8);
}
if (this.weatherCode == 9999 && Build.VERSION.SDK_INT >= 23) {
this.title.setTextColor(getColor(2131034297));
this.temperatureLable.setTextColor(getColor(2131034297));
this.maxTemperatureTitle.setTextColor(getColor(2131034297));
this.minTemperatureTitle.setTextColor(getColor(2131034297));
this.humidityLable.setTextColor(getColor(2131034297));
this.maxHumidityTitle.setTextColor(getColor(2131034297));
this.minHumidityTitle.setTextColor(getColor(2131034297));
if (this.current == 99) {
this.airvolumeLable.setTextColor(getColor(2131034297));
this.maxAirvolumeTitle.setTextColor(getColor(2131034297));
this.minAirvolumeTitle.setTextColor(getColor(2131034297));
this.rainVolumeLable.setTextColor(getColor(2131034297));
this.maxRainvolumeTitle.setTextColor(getColor(2131034297));
this.minRainvolumeTitle.setTextColor(getColor(2131034297));
}
this.sumbit.setColorFilter(getColor(2131034297));
this.close.setColorFilter(getColor(2131034297));
}
((RemindPresenterImp) this.mPresenter).requestData();
this.titleStr = getIntent().getStringExtra("title");
this.temperatureSwichBtn.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
@Override
public final void onCheckedChanged(SwitchButton switchButton, boolean z) {
RemindActivity.this.lambda$initView$2$RemindActivity(switchButton, z);
}
});
this.humiditySwichBtn.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
@Override
public final void onCheckedChanged(SwitchButton switchButton, boolean z) {
RemindActivity.this.lambda$initView$3$RemindActivity(switchButton, z);
}
});
this.airvolumeSwichBtn.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
@Override
public final void onCheckedChanged(SwitchButton switchButton, boolean z) {
RemindActivity.this.lambda$initView$4$RemindActivity(switchButton, z);
}
});
this.rainvolumeSwichBtn.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
@Override
public final void onCheckedChanged(SwitchButton switchButton, boolean z) {
RemindActivity.this.lambda$initView$5$RemindActivity(switchButton, z);
}
});
}
public void lambda$initView$2$RemindActivity(SwitchButton switchButton, boolean z) {
if (z) {
this.maxTemperatureLl.setVisibility(0);
this.maxTemperatureLl.setAnimation(AnimationUtil.moveToViewTopLocation());
} else {
this.maxTemperatureLl.setVisibility(8);
}
}
public void lambda$initView$3$RemindActivity(SwitchButton switchButton, boolean z) {
if (z) {
this.maxHumidityLl.setVisibility(0);
this.maxHumidityLl.setAnimation(AnimationUtil.moveToViewTopLocation());
} else {
this.maxHumidityLl.setVisibility(8);
}
}
public void lambda$initView$4$RemindActivity(SwitchButton switchButton, boolean z) {
if (z) {
this.maxAirvolumeLl.setVisibility(0);
this.maxAirvolumeLl.setAnimation(AnimationUtil.moveToViewTopLocation());
} else {
this.maxAirvolumeLl.setVisibility(8);
}
}
public void lambda$initView$5$RemindActivity(SwitchButton switchButton, boolean z) {
if (z) {
this.maxRainvolumeLl.setVisibility(0);
this.maxRainvolumeLl.setAnimation(AnimationUtil.moveToViewTopLocation());
} else {
this.maxRainvolumeLl.setVisibility(8);
}
}
private void readAlarmData() {
Gson gson = new Gson();
String string = SharedPreUtils.getString(this, SharedPre.Alarm.ALARM_INFO);
System.out.println("lyq check 获取本地配置信息:" + string);
if (!TextUtils.isEmpty(string)) {
this.deviceAlarmList = (List) gson.fromJson(string, new TypeToken<List<DeviceAlarm>>() {
}.getType());
for (int i = 0; i < this.deviceAlarmList.size(); i++) {
if (this.deviceAlarmList.get(i).getChannel() == this.current) {
if (this.deviceAlarmList.get(i).getType() == 0 || this.deviceAlarmList.get(i).getType() == 1) {
this.deviceTempAlarm = this.deviceAlarmList.get(i);
this.tempIndex = i;
System.out.println("lyq check readAlarmData getAlarmMode:" + this.deviceAlarmList.get(i).getAlarmMode());
if (this.deviceAlarmList.get(i).getAlarmMode() != 0) {
System.out.println("lyq check true readAlarmData");
this.temperatureSwichBtn.setChecked(true);
this.maxTemperatureLl.setVisibility(0);
this.maxTemperatureLl.setAnimation(AnimationUtil.moveToViewTopLocation());
} else {
System.out.println("lyq check false readAlarmData");
this.temperatureSwichBtn.setChecked(false);
}
} else if (this.deviceAlarmList.get(i).getType() == 2) {
this.deviceHumidityAlarm = this.deviceAlarmList.get(i);
this.humidIndex = i;
if (this.deviceAlarmList.get(i).getAlarmMode() != 0) {
this.humiditySwichBtn.setChecked(true);
this.maxHumidityLl.setVisibility(0);
this.maxHumidityLl.setAnimation(AnimationUtil.moveToViewTopLocation());
} else {
this.humiditySwichBtn.setChecked(false);
}
} else if (this.deviceAlarmList.get(i).getType() == 3) {
this.deviceAirVolumeAlarm = this.deviceAlarmList.get(i);
if (this.deviceAlarmList.get(i).getAlarmMode() != 0) {
this.airvolumeSwichBtn.setChecked(true);
this.maxAirvolumeLl.setVisibility(0);
this.maxAirvolumeLl.setAnimation(AnimationUtil.moveToViewTopLocation());
} else {
this.airvolumeSwichBtn.setChecked(false);
}
} else if (this.deviceAlarmList.get(i).getType() == 4) {
this.deviceRainVolumeAlarm = this.deviceAlarmList.get(i);
if (this.deviceAlarmList.get(i).getAlarmMode() != 0) {
this.rainvolumeSwichBtn.setChecked(true);
this.maxRainvolumeLl.setVisibility(0);
this.maxRainvolumeLl.setAnimation(AnimationUtil.moveToViewTopLocation());
} else {
this.rainvolumeSwichBtn.setChecked(false);
}
}
}
}
initTemperature();
initHumidity();
initAirVolume();
initRainVolume();
return;
}
System.out.println("lyq check ALARM_INFO is NULL 去 requestData");
((RemindPresenterImp) this.mPresenter).requestData();
}
private void initTemperature() {
int i;
int i2;
this.tempNormalList = new ArrayList<>();
ArrayList arrayList = new ArrayList();
Boolean valueOf = Boolean.valueOf(SharedPreUtils.getBoolean(this, SharedPre.User.TEMPERATURE_VALUE, true));
this.isC = valueOf;
if (valueOf.booleanValue()) {
i = -19;
i2 = 60;
arrayList.add(getString(R.string.centigrade));
settingUnit(this.tempMaxUnit, arrayList);
settingUnit(this.tempMinUnit, arrayList);
} else {
i = -2;
i2 = 139;
arrayList.add(getString(R.string.Fahrenheit));
settingUnit(this.tempMaxUnit, arrayList);
settingUnit(this.tempMinUnit, arrayList);
}
while (i < i2) {
this.tempNormalList.add(String.valueOf(i));
i++;
}
if (this.deviceTempAlarm == null) {
DeviceAlarm deviceAlarm = new DeviceAlarm();
this.deviceTempAlarm = deviceAlarm;
deviceAlarm.setChannel(this.current);
HomeUtil.setDefault(this.deviceTempAlarm, 2, this);
}
if (TextUtils.isEmpty(this.deviceTempAlarm.getName())) {
if (this.weatherCode != 9999) {
this.title.setText(this.titleStr);
} else {
this.tvTitleSub.setText(this.titleStr);
}
} else if (this.weatherCode != 9999) {
this.title.setText(this.deviceTempAlarm.getName());
} else {
this.tvTitleSub.setText(this.deviceTempAlarm.getName());
}
int indexOf = this.tempNormalList.indexOf(String.valueOf((int) TemperatureUtils.getTemperatureValue(this.deviceTempAlarm.getAlarmHighVal(), this.isC)));
this.maxTemperatureIndex = indexOf;
if (indexOf < 0) {
this.maxTemperatureIndex = 0;
}
settingLoopView(this.tempMaxLoopView, this.tempNormalList, this.maxTemperatureIndex);
this.tempMaxLoopView.setListener(new OnItemSelectedListener() {
@Override
public final void onItemSelected(int i3) {
RemindActivity.this.lambda$initTemperature$6$RemindActivity(i3);
}
});
int indexOf2 = this.tempNormalList.indexOf(String.valueOf((int) TemperatureUtils.getTemperatureValue(this.deviceTempAlarm.getAlarmLowVal(), this.isC)));
this.minTemperatureIndex = indexOf2;
if (indexOf2 < 0) {
this.minTemperatureIndex = 0;
}
settingLoopView(this.tempMinLoopView, this.tempNormalList, this.minTemperatureIndex);
this.tempMinLoopView.setListener(new OnItemSelectedListener() {
@Override
public final void onItemSelected(int i3) {
RemindActivity.this.lambda$initTemperature$7$RemindActivity(i3);
}
});
}
public void lambda$initTemperature$6$RemindActivity(int i) {
this.maxTemperatureIndex = i;
}
public void lambda$initTemperature$7$RemindActivity(int i) {
this.minTemperatureIndex = i;
}
private void initHumidity() {
this.humidityNormalList = new ArrayList<>();
ArrayList arrayList = new ArrayList();
for (int i = 1; i < 100; i++) {
this.humidityNormalList.add(String.valueOf(i));
}
arrayList.add("%");
settingUnit(this.humidityMaxUnit, arrayList);
settingUnit(this.humidityMinUnit, arrayList);
if (this.deviceHumidityAlarm == null) {
DeviceAlarm deviceAlarm = new DeviceAlarm();
this.deviceHumidityAlarm = deviceAlarm;
deviceAlarm.setChannel(this.current);
HomeUtil.setDefault(this.deviceHumidityAlarm, 2, this);
}
int indexOf = this.humidityNormalList.indexOf(String.valueOf((int) this.deviceHumidityAlarm.getAlarmHighVal()));
this.maxHumidityIndex = indexOf;
if (indexOf < 0) {
this.maxHumidityIndex = 0;
}
settingLoopView(this.humidityMaxLoopView, this.humidityNormalList, this.maxHumidityIndex);
this.humidityMaxLoopView.setListener(new OnItemSelectedListener() {
@Override
public final void onItemSelected(int i2) {
RemindActivity.this.lambda$initHumidity$8$RemindActivity(i2);
}
});
int indexOf2 = this.humidityNormalList.indexOf(String.valueOf((int) this.deviceHumidityAlarm.getAlarmLowVal()));
this.minHumidityIndex = indexOf2;
if (indexOf2 < 0) {
this.minHumidityIndex = 0;
}
settingLoopView(this.humidityMinLoopView, this.humidityNormalList, this.minHumidityIndex);
this.humidityMinLoopView.setListener(new OnItemSelectedListener() {
@Override
public final void onItemSelected(int i2) {
RemindActivity.this.lambda$initHumidity$9$RemindActivity(i2);
}
});
}
public void lambda$initHumidity$8$RemindActivity(int i) {
this.maxHumidityIndex = i;
}
public void lambda$initHumidity$9$RemindActivity(int i) {
this.minHumidityIndex = i;
}
private void initAirVolume() {
String valueOf;
String valueOf2;
this.airvolumeNormalList = new ArrayList<>();
ArrayList arrayList = new ArrayList();
if (SharedPreUtils.getBoolean(this, SharedPre.User.WIND_SPEED, true)) {
arrayList.add("km/h");
} else {
arrayList.add("mph");
}
settingUnit(this.airvolumeMaxUnit, arrayList);
settingUnit(this.airvolumeMinUnit, arrayList);
for (int i = 0; i < 181; i++) {
this.airvolumeNormalList.add(String.valueOf(i));
}
if (this.deviceAirVolumeAlarm == null) {
DeviceAlarm deviceAlarm = new DeviceAlarm();
this.deviceAirVolumeAlarm = deviceAlarm;
deviceAlarm.setChannel(this.current);
HomeUtil.setDefault(this.deviceAirVolumeAlarm, 3, this);
}
if (SharedPreUtils.getBoolean(this, SharedPre.User.WIND_SPEED, true)) {
valueOf = String.valueOf((int) this.deviceAirVolumeAlarm.getAlarmHighVal());
} else {
valueOf = String.valueOf((int) (this.deviceAirVolumeAlarm.getAlarmHighVal() / 1.6d));
}
int indexOf = this.airvolumeNormalList.indexOf(valueOf);
this.maxAirVolumeIndex = indexOf;
if (indexOf < 0) {
this.maxAirVolumeIndex = 0;
}
settingLoopView(this.airvolumeMaxLoopView, this.airvolumeNormalList, this.maxAirVolumeIndex);
this.airvolumeMaxLoopView.setListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(int index) {
RemindActivity.this.maxAirVolumeIndex = index;
}
});
if (SharedPreUtils.getBoolean(this, SharedPre.User.WIND_SPEED, true)) {
valueOf2 = String.valueOf((int) this.deviceAirVolumeAlarm.getAlarmLowVal());
} else {
valueOf2 = String.valueOf((int) (this.deviceAirVolumeAlarm.getAlarmLowVal() * 1.6d));
}
int indexOf2 = this.airvolumeNormalList.indexOf(valueOf2);
this.minAirVolumeIndex = indexOf2;
if (indexOf2 < 0) {
this.minAirVolumeIndex = 0;
}
settingLoopView(this.airvolumeMinLoopView, this.airvolumeNormalList, this.minAirVolumeIndex);
this.airvolumeMinLoopView.setListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(int index) {
RemindActivity.this.minAirVolumeIndex = index;
}
});
}
private void initRainVolume() {
String valueOf;
String valueOf2;
this.rainvolumeNormalList = new ArrayList<>();
ArrayList arrayList = new ArrayList();
if (getString(R.string.mmh).equals(SharedPreUtils.getString(this, SharedPre.User.RAIN_VOLUME))) {
arrayList.add(getString(R.string.mmh));
for (int i = 1; i < 501; i++) {
this.rainvolumeNormalList.add(String.valueOf(i));
}
} else {
arrayList.add(getString(R.string.inchh));
for (int i2 = 0; i2 < 201; i2++) {
this.rainvolumeNormalList.add(String.valueOf((i2 * 1.0d) / 100.0d));
}
}
settingUnit(this.rainvolumeMaxUnit, arrayList);
settingUnit(this.rainvolumeMinUnit, arrayList);
if (this.deviceRainVolumeAlarm == null) {
DeviceAlarm deviceAlarm = new DeviceAlarm();
this.deviceRainVolumeAlarm = deviceAlarm;
deviceAlarm.setChannel(this.current);
HomeUtil.setDefault(this.deviceRainVolumeAlarm, 4, this);
}
if (getString(R.string.mmh).equals(SharedPreUtils.getString(this, SharedPre.User.RAIN_VOLUME))) {
valueOf = String.valueOf((int) (this.deviceRainVolumeAlarm.getAlarmHighVal() * 25.4d));
} else {
valueOf = String.valueOf(this.deviceRainVolumeAlarm.getAlarmHighVal());
}
int indexOf = this.rainvolumeNormalList.indexOf(valueOf);
this.maxRainVolumeIndex = indexOf;
if (indexOf < 0) {
this.maxRainVolumeIndex = 0;
}
settingLoopView(this.rainvolumeMaxLoopView, this.rainvolumeNormalList, this.maxRainVolumeIndex);
this.rainvolumeMaxLoopView.setListener(new OnItemSelectedListener() {
@Override
public final void onItemSelected(int i3) {
RemindActivity.this.lambda$initRainVolume$10$RemindActivity(i3);
}
});
if (getString(R.string.mmh).equals(SharedPreUtils.getString(this, SharedPre.User.RAIN_VOLUME))) {
valueOf2 = String.valueOf((int) (this.deviceRainVolumeAlarm.getAlarmLowVal() * 25.4d));
} else {
valueOf2 = String.valueOf(this.deviceRainVolumeAlarm.getAlarmLowVal());
}
int indexOf2 = this.rainvolumeNormalList.indexOf(valueOf2);
this.minRainVolumeIndex = indexOf2;
if (indexOf2 < 0) {
this.minRainVolumeIndex = 0;
}
settingLoopView(this.rainvolumeMinLoopView, this.rainvolumeNormalList, this.minRainVolumeIndex);
this.rainvolumeMinLoopView.setListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(int index) {
RemindActivity.this.minRainVolumeIndex = index;
}
});
}
public void lambda$initRainVolume$10$RemindActivity(int i) {
this.maxRainVolumeIndex = i;
}
public void settingLoopView(LoopView loopView, List<String> list, int i) {
if (this.weatherCode == 9999) {
loopView.setCenterTextColor(ViewCompat.MEASURED_STATE_MASK);
loopView.setOuterTextColor(ViewCompat.MEASURED_STATE_MASK);
}
loopView.setTextSize(12.0f);
loopView.setItems(list);
loopView.setCurrentPosition(i);
loopView.setItemsVisibleCount(5);
loopView.setNotLoop();
}
public void settingUnit(LoopView loopView, List<String> list) {
if (this.weatherCode == 9999) {
loopView.setCenterTextColor(ViewCompat.MEASURED_STATE_MASK);
loopView.setOuterTextColor(ViewCompat.MEASURED_STATE_MASK);
}
loopView.setTextSize(9.0f);
loopView.setItems(list);
loopView.setItemsVisibleCount(2);
loopView.setNotLoop();
loopView.setCurrentPosition(0);
}
@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, List<DeviceAlarm> deviceAlarmList) {
System.out.println("lyq check refreshContentView ----");
this.deviceAlarmList = deviceAlarmList;
for (int i = 0; i < deviceAlarmList.size(); i++) {
if (deviceAlarmList.get(i).getChannel() == this.current) {
if (deviceAlarmList.get(i).getType() == 0 || deviceAlarmList.get(i).getType() == 1) {
this.deviceTempAlarm = deviceAlarmList.get(i);
this.tempIndex = i;
if (deviceAlarmList.get(i).getAlarmMode() != 0) {
this.temperatureSwichBtn.setChecked(true);
System.out.println("lyq check true refreshContentView");
} else {
this.temperatureSwichBtn.setChecked(false);
System.out.println("lyq check false refreshContentView");
}
}
if (deviceAlarmList.get(i).getType() == 2) {
this.deviceHumidityAlarm = deviceAlarmList.get(i);
this.humidIndex = i;
if (deviceAlarmList.get(i).getAlarmMode() != 0) {
this.humiditySwichBtn.setChecked(true);
} else {
this.humiditySwichBtn.setChecked(false);
}
}
if (deviceAlarmList.get(i).getType() == 3) {
this.deviceAirVolumeAlarm = deviceAlarmList.get(i);
if (deviceAlarmList.get(i).getAlarmMode() != 0) {
this.airvolumeSwichBtn.setChecked(true);
} else {
this.airvolumeSwichBtn.setChecked(false);
}
}
if (deviceAlarmList.get(i).getType() == 4) {
this.deviceRainVolumeAlarm = deviceAlarmList.get(i);
if (deviceAlarmList.get(i).getAlarmMode() != 0) {
this.rainvolumeSwichBtn.setChecked(true);
} else {
this.rainvolumeSwichBtn.setChecked(false);
}
}
}
}
initTemperature();
initHumidity();
initAirVolume();
initRainVolume();
}
@Override
public void showToastMessage(int msg) {
ToastUtil.show(getString(msg), this);
}
@Override
public List<DeviceAlarm> getAlarm() {
return this.deviceAlarmList;
}
@Override
public void settingSuccess() {
onBackPressed();
showToastMessage(R.string.setting_successed);
}
@OnClick({R.id.sumbit, R.id.close})
public void onClick(View view) {
int id = view.getId();
if (id == 2131230961) {
finish();
return;
}
if (id != 2131231510) {
return;
}
if (this.deviceTempAlarm == null) {
DeviceAlarm deviceAlarm = new DeviceAlarm();
this.deviceTempAlarm = deviceAlarm;
deviceAlarm.setChannel(this.current);
}
ArrayList<String> arrayList = this.tempNormalList;
if (arrayList == null) {
return;
}
int intValue = Integer.valueOf(arrayList.get(this.maxTemperatureIndex)).intValue();
this.maxTemperatureValue = intValue;
this.deviceTempAlarm.setAlarmHighVal(TemperatureUtils.putTemperatureValue(intValue, this.isC));
int intValue2 = Integer.valueOf(this.tempNormalList.get(this.minTemperatureIndex)).intValue();
this.minTemperatureValue = intValue2;
this.deviceTempAlarm.setAlarmLowVal(TemperatureUtils.putTemperatureValue(intValue2, this.isC));
if (this.minTemperatureValue >= this.maxTemperatureValue && this.temperatureSwichBtn.isChecked()) {
ToastUtil.show(getString(R.string.temperature_setting_error), getApplicationContext());
return;
}
if (this.temperatureSwichBtn.isChecked()) {
this.deviceTempAlarm.setAlarmMode(3);
} else {
this.deviceTempAlarm.setAlarmMode(0);
}
if (this.deviceHumidityAlarm == null) {
DeviceAlarm deviceAlarm2 = new DeviceAlarm();
this.deviceHumidityAlarm = deviceAlarm2;
deviceAlarm2.setChannel(this.current);
}
ArrayList<String> arrayList2 = this.humidityNormalList;
if (arrayList2 == null) {
return;
}
this.maxhumidityValue = Integer.valueOf(arrayList2.get(this.maxHumidityIndex)).intValue();
int intValue3 = Integer.valueOf(this.humidityNormalList.get(this.minHumidityIndex)).intValue();
this.minhumidityValue = intValue3;
if (intValue3 >= this.maxhumidityValue && this.humiditySwichBtn.isChecked()) {
ToastUtil.show(getString(R.string.huimidity_setting_error), this);
return;
}
this.deviceHumidityAlarm.setAlarmHighVal(this.maxhumidityValue);
this.deviceHumidityAlarm.setAlarmLowVal(this.minhumidityValue);
if (this.humiditySwichBtn.isChecked()) {
this.deviceHumidityAlarm.setAlarmMode(3);
} else {
this.deviceHumidityAlarm.setAlarmMode(0);
}
if (this.deviceAirVolumeAlarm == null) {
DeviceAlarm deviceAlarm3 = new DeviceAlarm();
this.deviceAirVolumeAlarm = deviceAlarm3;
deviceAlarm3.setChannel(this.current);
}
ArrayList<String> arrayList3 = this.airvolumeNormalList;
if (arrayList3 == null) {
return;
}
int intValue4 = Integer.valueOf(arrayList3.get(this.maxAirVolumeIndex)).intValue();
this.maxAirVolumeValue = intValue4;
this.deviceAirVolumeAlarm.setAlarmHighVal(intValue4);
this.deviceAirVolumeAlarm.setAlarmLowVal(0.0f);
if (this.airvolumeSwichBtn.isChecked()) {
this.deviceAirVolumeAlarm.setAlarmMode(1);
} else {
this.deviceAirVolumeAlarm.setAlarmMode(0);
}
if (this.deviceRainVolumeAlarm == null) {
DeviceAlarm deviceAlarm4 = new DeviceAlarm();
this.deviceRainVolumeAlarm = deviceAlarm4;
deviceAlarm4.setChannel(this.current);
}
ArrayList<String> arrayList4 = this.rainvolumeNormalList;
if (arrayList4 == null) {
return;
}
this.maxRainVolumeValue = Float.valueOf(arrayList4.get(this.maxRainVolumeIndex)).floatValue();
if (getString(R.string.mmh).equals(SharedPreUtils.getString(this, SharedPre.User.RAIN_VOLUME))) {
this.deviceRainVolumeAlarm.setAlarmHighVal(new BigDecimal(this.maxRainVolumeValue / 25.4d).setScale(2, RoundingMode.HALF_UP).floatValue());
} else {
this.deviceRainVolumeAlarm.setAlarmHighVal(this.maxRainVolumeValue);
}
this.deviceRainVolumeAlarm.setAlarmLowVal(0.0f);
if (this.rainvolumeSwichBtn.isChecked()) {
this.deviceRainVolumeAlarm.setAlarmMode(1);
} else {
this.deviceRainVolumeAlarm.setAlarmMode(0);
}
this.deviceAlarmList.clear();
this.deviceTempAlarm.setType(1);
this.deviceHumidityAlarm.setType(2);
this.deviceAirVolumeAlarm.setType(3);
this.deviceRainVolumeAlarm.setType(4);
this.deviceAlarmList.add(this.deviceTempAlarm);
this.deviceAlarmList.add(this.deviceHumidityAlarm);
this.deviceAlarmList.add(this.deviceAirVolumeAlarm);
this.deviceAlarmList.add(this.deviceRainVolumeAlarm);
((RemindPresenterImp) this.mPresenter).settingAlarmPost();
}
@Override
protected void onDestroy() {
super.onDestroy();
Disposable disposable = this.disposable;
if (disposable == null || disposable.isDisposed()) {
return;
}
this.disposable.dispose();
this.disposable = null;
}
}