正在查看: WeatherSense v1.8.9 应用的 MainActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: WeatherSense v1.8.9 应用的 MainActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.emax.weather.ui.activity;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.os.Build;
import android.os.Bundle;
import android.os.Vibrator;
import android.text.TextUtils;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.animation.TranslateAnimation;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.core.widget.NestedScrollView;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import butterknife.OnClick;
import com.alibaba.pdns.DNSResolver;
import com.alibaba.pdns.f;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
import com.emax.weahter.R;
import com.emax.weather.adapter.ViewPageAdapter;
import com.emax.weather.base.ActivityCollector;
import com.emax.weather.base.BaseApplication;
import com.emax.weather.base.MvpBaseActivity;
import com.emax.weather.base.RxBus;
import com.emax.weather.bean.AlarmEventType;
import com.emax.weather.bean.BindedDevice;
import com.emax.weather.bean.DeviceAlarm;
import com.emax.weather.bean.DeviceLocation;
import com.emax.weather.bean.DeviceName;
import com.emax.weather.bean.DeviceNearby;
import com.emax.weather.bean.DeviceWeather;
import com.emax.weather.bean.DeviceWeatherDetailData;
import com.emax.weather.bean.EventData;
import com.emax.weather.bean.MyDeviceName;
import com.emax.weather.bean.RxBusEvent;
import com.emax.weather.bean.SensorDatas;
import com.emax.weather.bean.User;
import com.emax.weather.bean.db.DaoHadle;
import com.emax.weather.bean.yahoo.YahooForecasts;
import com.emax.weather.bean.yahoo.YahooRealtime;
import com.emax.weather.bean.yahoo.YahooWeather;
import com.emax.weather.event.HomeEvent;
import com.emax.weather.event.IMapManager;
import com.emax.weather.presenter.HomePresenterImp;
import com.emax.weather.service.HistroyDataService;
import com.emax.weather.util.AndroidScheduler;
import com.emax.weather.utils.AnimationUtil;
import com.emax.weather.utils.CheckClickUtils;
import com.emax.weather.utils.HomeUtil;
import com.emax.weather.utils.LanguageUtils;
import com.emax.weather.utils.MapHomeFactory;
import com.emax.weather.utils.MyInternalStorage;
import com.emax.weather.utils.RxUtil;
import com.emax.weather.widget.BindDeviceDialog;
import com.emax.weather.widget.NetWorkErrorDialog;
import com.emax.weather.widget.NotUploadDataDialog;
import com.emax.weather.widget.RentalsSunHeaderView;
import com.emax.weather.widget.UnboundDialog;
import com.ezon.health.utils_lib.AppUtils;
import com.ezon.health.utils_lib.ConvertUtils;
import com.ezon.health.utils_lib.LogUtils;
import com.ezon.health.utils_lib.SharedPre;
import com.ezon.health.utils_lib.SharedPreUtils;
import com.ezon.health.utils_lib.TimeUtils;
import com.ezon.health.utils_lib.ToastUtil;
import com.ezon.health.widget_lib.DispatchViewPage;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.material.navigation.NavigationView;
import com.google.android.material.tabs.TabLayout;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.tbruyelle.rxpermissions2.RxPermissions;
import in.srain.cube.views.ptr.PtrClassicFrameLayout;
import in.srain.cube.views.ptr.PtrDefaultHandler;
import in.srain.cube.views.ptr.PtrFrameLayout;
import in.srain.cube.views.ptr.PtrHandler;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
public class MainActivity extends MvpBaseActivity<HomeEvent.HomeView, HomePresenterImp> implements HomeEvent.HomeView, MapHomeFactory.OnMapAddressListener, UnboundDialog.OnUnBoundClickListener, BindDeviceDialog.OnBindDeviceClickListener {
private static final int COUNTS = 5;
private static final long DURATION = 3000;
public static final String MASTER_NAME = "CH0";
public static final String MTQQ_CONNECT = "MTQQ_CONNECT";
public static final String NETWORK_ERROR = "NETWORK_ERROR";
public static final String NOT_DEVICE = "NOT_DEVICE";
public static final String NO_UPLOAD_DATA = "NO_UPLOAD_DATA";
public static final String OTHER_DEVICE = "OTHER_DEVICE";
public static final String TOKEN_OUT = "TOKEN_OUT";
public static final String UPDATE_NOTIFICATION = "UPDATE_NOTIFICATION";
private String addr;
@BindView(R.id.ll_air_volume)
LinearLayout airVolumeLl;
@BindView(R.id.alarm_icon)
ImageView alarmIcon;
@BindView(R.id.alarm_msg)
TextView alarmMsg;
@BindView(R.id.alarm_rl)
RelativeLayout alarmRl;
@BindView(R.id.alarm_time)
TextView alarmTime;
private TranslateAnimation animation1;
private TranslateAnimation animation2;
private TranslateAnimation animation3;
private ObjectAnimator animator;
@BindView(R.id.blast_volume_iv)
ImageView blastVolumeIv;
@BindView(R.id.blast_volume_rl)
RelativeLayout blastVolumeRl;
@BindView(R.id.blast_volume_tv)
TextView blastVolumeTv;
@BindView(R.id.blast_volume_value_tv)
TextView blastVolumeValueTv;
@BindView(R.id.blast_volume_value_unit)
TextView blastVolumeValueUnit;
@BindView(R.id.bottom_left_rl)
RelativeLayout bottomLeftRl;
@BindView(R.id.cell_iv)
ImageView cellIv;
@BindView(R.id.chief_feel_iv)
ImageView chiefFeelIv;
@BindView(R.id.chief_feel_tv)
TextView chiefFeelTv;
@BindView(R.id.chief_ll)
LinearLayout chiefLl;
@BindView(R.id.chief_num1)
TextView chiefNum1;
@BindView(R.id.chief_num2)
TextView chiefNum2;
@BindView(R.id.chief_rl_middle)
RelativeLayout chiefRlMiddle;
@BindView(R.id.chief_section)
TextView chiefSection;
@BindView(R.id.chief_unit)
TextView chiefUnit;
@BindView(R.id.level_iv)
ImageView climateLevelIv;
@BindView(R.id.level_tv)
TextView climateLevelTv;
@BindView(R.id.climate_position_tv)
TextView climatePositionTv;
@BindView(R.id.climate_pressure_tv)
TextView climatePressureTv;
@BindView(R.id.climate_pressure_unit_tv)
TextView climatePressureUnitTv;
@BindView(R.id.climate_rainvalue_tv)
TextView climateRainValueTv;
@BindView(R.id.climate_rainvalue_unit_tv)
TextView climateRainValueUnitTv;
@BindView(R.id.climate_rainvolume_tv)
TextView climateRainVolumeTv;
@BindView(R.id.climate_rainvolume_unit_tv)
TextView climateRainVolumeUnitTv;
@BindView(R.id.climate_temperature_tv)
TextView climateTempTv;
@BindView(R.id.climate_temp_unit_tv)
TextView climateTempUnitTv;
@BindView(R.id.climate_warning_iv)
ImageView climateWarningIv;
@BindView(R.id.climate_fengsu_iv)
ImageView climateWindIv;
@BindView(R.id.climate_wind_tv)
TextView climateWindTv;
@BindView(R.id.climate_wind_unit_tv)
TextView climateWindUnitTv;
@BindView(R.id.nvLeft)
NavigationView designNavigationView;
private List<DeviceWeatherDetailData> detailDataList;
@BindView(R.id.direction_tv)
TextView directionTv;
private Disposable disposable;
@BindView(R.id.drawer_layout)
DrawerLayout drawerLayout;
@BindView(R.id.drip1_iv)
ImageView dripIv1;
@BindView(R.id.drip2_iv)
ImageView dripIv2;
@BindView(R.id.drip3_iv)
ImageView dripIv3;
@BindView(R.id.llFactoryModule)
LinearLayout factoryModuleLl;
@BindView(R.id.four)
RelativeLayout four;
@BindView(R.id.four_date_tv)
TextView fourDateTv;
@BindView(R.id.four_status_iv)
ImageView fourStatusIv;
@BindView(R.id.four_week_temperature_value)
TextView fourWeekTemperatureValue;
@BindView(R.id.rotate_header_web_view_frame)
PtrClassicFrameLayout frame;
@BindView(R.id.header_rl)
RelativeLayout headerRl;
@BindView(R.id.home_bottom)
LinearLayout homeBottom;
@BindView(R.id.home_page)
RelativeLayout homePage;
@BindView(R.id.humidity)
TextView humidity;
@BindView(R.id.humidity_iv)
ImageView humidityIv;
@BindView(R.id.iv_circle)
ImageView ivCircle;
@BindView(R.id.left_iv)
ImageView leftIv;
@BindView(R.id.left_rl)
RelativeLayout leftRl;
private List<AlarmEventType> list;
@BindView(R.id.ll_level)
LinearLayout llLevel;
private int mPointMargin;
@BindView(R.id.rotate_header_scroll_view)
NestedScrollView mScrollView;
private String mac;
@BindView(R.id.map_container)
FrameLayout mapContainer;
@BindView(R.id.map_item)
LinearLayout mapItem;
private IMapManager mapManager;
@BindView(R.id.map_title)
TextView mapTitle;
@BindView(R.id.max_iv)
ImageView maxIv;
@BindView(R.id.min_iv)
ImageView minIv;
private List<DeviceName> nameList;
@BindView(R.id.one)
RelativeLayout one;
@BindView(R.id.one_date_tv)
TextView oneDateTv;
@BindView(R.id.one_status_iv)
ImageView oneStatusIv;
@BindView(R.id.one_week_temperature_value)
TextView oneWeekTemperatureValue;
private ViewPageAdapter pageAdapter;
@BindView(R.id.point_group)
LinearLayout pointGroup;
private SensorDatas pressure;
@BindView(R.id.pressure_iv)
ImageView pressureIv;
@BindView(R.id.pressure_tv)
TextView pressureTv;
@BindView(R.id.pressure_unit)
TextView pressureUnit;
@BindView(2131231423)
ImageView rightIcon;
@BindView(R.id.rl_uv)
RelativeLayout rlUv;
private Disposable rxBusDisposable;
private List<SensorDatas> sensorDatases;
@BindView(R.id.status_iv)
ImageView statusIv;
@BindView(R.id.subset_view_page)
DispatchViewPage subsetViewPage;
@BindView(R.id.sunrise_lable)
TextView sunriseLable;
@BindView(R.id.sunrise_time)
TextView sunriseTime;
@BindView(R.id.sunrise_time_iv)
ImageView sunriseTimeIv;
@BindView(R.id.sunrise_time_middle_rl)
RelativeLayout sunriseTimeMiddleRl;
@BindView(R.id.sunrise_time_rl)
RelativeLayout sunriseTimeRl;
@BindView(R.id.sunrise_time_tv)
TextView sunriseTimeTv;
@BindView(R.id.sunset_lable)
TextView sunsetLable;
@BindView(R.id.sunset_time)
TextView sunsetTime;
@BindView(R.id.tabLayout)
TabLayout tabLayout;
private SensorDatas temperature;
@BindView(R.id.three)
RelativeLayout three;
@BindView(R.id.three_date_tv)
TextView threeDateTv;
@BindView(R.id.three_status_iv)
ImageView threeStatusIv;
@BindView(R.id.three_week_temperature_value)
TextView threeWeekTemperatureValue;
@BindView(2131231581)
TextView title;
@BindView(R.id.today_max_value)
TextView todayMaxValue;
@BindView(R.id.today_min_value)
TextView todayMinValue;
@BindView(R.id.top_value_ll)
RelativeLayout topValueLl;
@BindView(R.id.tv_light)
TextView tvLight;
@BindView(R.id.tv_uv_value)
TextView tvUvValue;
@BindView(R.id.two)
RelativeLayout two;
@BindView(R.id.two_date_tv)
TextView twoDateTv;
@BindView(R.id.two_status_iv)
ImageView twoStatusIv;
@BindView(R.id.two_week_temperature_value)
TextView twoWeekTemperatureValue;
private UnboundDialog unboundDialog;
@BindView(R.id.up_date_tv)
TextView upDateTv;
private String upStr;
@BindView(R.id.warning)
ImageView warning;
private List<DeviceWeatherDetailData> weatherDetailDataList;
@BindView(R.id.week_weather)
LinearLayout weekWeather;
@BindView(R.id.white_point)
ImageView whitePoint;
@BindView(R.id.wind_angel_tv)
TextView windAngelTv;
private long mStartLoadingTime = 0;
private Boolean isRefresh = false;
private String mainMac = "";
private int weatherCode = 0;
private boolean isShowUnboundDialog = false;
private Boolean isInit = true;
private long[] mHits = new long[5];
private int mCurrentAlarmPosition = 0;
private boolean isActivityLive = true;
@Override
protected int getActivityRId() {
return R.layout.activity_main;
}
@Override
public Context getContext() {
return this;
}
@Override
public void getDeviceFail(int code) {
}
@Override
public void openMqttSuccess() {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i("MainActivity", "lyq activity MainActivity - onCreate");
initView();
initData();
requestPermission();
}
private void requestPermission() {
RxPermissions rxPermissions = new RxPermissions(this);
Log.i("MainActivity", "lyq SDK_INT:" + Build.VERSION.SDK_INT + ",S:31");
if (Build.VERSION.SDK_INT >= 31) {
if (rxPermissions.isGranted("android.permission.BLUETOOTH_SCAN") && rxPermissions.isGranted("android.permission.BLUETOOTH_ADVERTISE") && rxPermissions.isGranted("android.permission.ACCESS_FINE_LOCATION") && rxPermissions.isGranted("android.permission.ACCESS_COARSE_LOCATION") && rxPermissions.isGranted("android.permission.ACCESS_LOCATION_EXTRA_COMMANDS") && rxPermissions.isGranted("android.permission.BLUETOOTH_CONNECT")) {
return;
}
rxPermissions.request(new String[]{"android.permission.BLUETOOTH_SCAN", "android.permission.BLUETOOTH_ADVERTISE", "android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION", "android.permission.ACCESS_LOCATION_EXTRA_COMMANDS", "android.permission.BLUETOOTH_CONNECT"}).subscribe(new Consumer() {
public final void accept(Object obj) {
MainActivity.this.lambda$requestPermission$0$MainActivity((Boolean) obj);
}
});
return;
}
if (rxPermissions.isGranted("android.permission.ACCESS_FINE_LOCATION") && rxPermissions.isGranted("android.permission.ACCESS_COARSE_LOCATION") && rxPermissions.isGranted("android.permission.ACCESS_LOCATION_EXTRA_COMMANDS")) {
return;
}
rxPermissions.request(new String[]{"android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION", "android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"}).subscribe(new Consumer() {
public final void accept(Object obj) {
MainActivity.this.lambda$requestPermission$1$MainActivity((Boolean) obj);
}
});
}
public void lambda$requestPermission$0$MainActivity(Boolean bool) throws Exception {
if (bool.booleanValue()) {
return;
}
ToastUtil.show(getApplicationContext().getString(R.string.Please_check_your_permissions), this);
}
public void lambda$requestPermission$1$MainActivity(Boolean bool) throws Exception {
if (bool.booleanValue()) {
return;
}
ToastUtil.show(getApplicationContext().getString(R.string.Please_check_your_permissions), this);
}
private void observeBusEvent() {
this.rxBusDisposable = RxBus.getInstance().toObserverable(RxBusEvent.class).observeOn(AndroidScheduler.mainThread()).subscribe(new Consumer() {
public final void accept(Object obj) {
MainActivity.this.lambda$observeBusEvent$4$MainActivity((RxBusEvent) obj);
}
}, new Consumer() {
public final void accept(Object obj) {
System.out.println("throwable.getMessage() = " + ((Throwable) obj).getMessage());
}
});
}
public void lambda$observeBusEvent$4$MainActivity(RxBusEvent rxBusEvent) throws Exception {
if (TOKEN_OUT.equals(rxBusEvent.getUpdateTheData()) && DaoHadle.getUser() != null) {
HistroyDataService.stopService(this);
showToastMessage(R.string.token_time_out);
clearCache();
Intent intent = new Intent(this, (Class<?>) LoginActivity.class);
intent.putExtra(TOKEN_OUT, TOKEN_OUT);
startActivity(intent);
ActivityCollector.finishAll();
finish();
return;
}
if ((NOT_DEVICE.equals(rxBusEvent.getUpdateTheData()) || OTHER_DEVICE.equals(rxBusEvent.getUpdateTheData())) && DaoHadle.getUser() != null) {
this.isShowUnboundDialog = true;
this.disposable = Observable.interval(0L, 2L, TimeUnit.SECONDS).observeOn(AndroidScheduler.mainThread()).subscribe(new Consumer() {
public final void accept(Object obj) {
MainActivity.this.lambda$observeBusEvent$2$MainActivity((Long) obj);
}
});
return;
}
if (MTQQ_CONNECT.equals(rxBusEvent.getUpdateTheData())) {
System.out.println("mqtt1");
((HomePresenterImp) this.mPresenter).startMqtt();
return;
}
if (NETWORK_ERROR.equals(rxBusEvent.getUpdateTheData())) {
this.isShowUnboundDialog = true;
Toast.makeText(getApplicationContext(), rxBusEvent.getError(), 0).show();
this.disposable = Observable.interval(0L, 2L, TimeUnit.SECONDS).observeOn(AndroidScheduler.mainThread()).subscribe(new Consumer() {
public final void accept(Object obj) {
MainActivity.this.lambda$observeBusEvent$3$MainActivity((Long) obj);
}
});
return;
}
if (UPDATE_NOTIFICATION.equals(rxBusEvent.getUpdateTheData()) && this.isActivityLive) {
System.out.println("lyq UPDATE_NOTIFICATION");
String string = SharedPreUtils.getString(getApplicationContext(), SharedPre.Alarm.ALARM_INFO);
Log.d("MainActivity", "lyq alarmInfo:" + string);
if (TextUtils.isEmpty(string)) {
return;
}
List<AlarmEventType> list = (List) new Gson().fromJson(string, new TypeToken<List<AlarmEventType>>() {
}.getType());
this.list = list;
if (list == null || list.size() <= 0) {
return;
}
alarmTos(this.list.get(0));
this.mCurrentAlarmPosition = 0;
}
}
public void lambda$observeBusEvent$2$MainActivity(Long l) throws Exception {
if (isFinishing() || !this.isShowUnboundDialog) {
return;
}
this.frame.refreshComplete();
dismissProgressDialog();
HistroyDataService.stopService(this);
clearCache();
UnboundDialog unboundDialog = new UnboundDialog(this, this);
this.unboundDialog = unboundDialog;
unboundDialog.show();
this.isShowUnboundDialog = false;
}
public void lambda$observeBusEvent$3$MainActivity(Long l) throws Exception {
if (isFinishing() || !this.isShowUnboundDialog) {
return;
}
new NetWorkErrorDialog(this).show();
this.isShowUnboundDialog = false;
}
private void clearCache() {
DaoHadle.deleteData();
String string = SharedPreUtils.getString(getApplicationContext(), SharedPre.User.ACCOUNT_EMAIL, "");
int i = SharedPreUtils.getInt(getApplicationContext(), SharedPre.FactoryUrl.FACTORY_URL, -1);
String string2 = SharedPreUtils.getString(getApplicationContext(), SharedPre.Alarm.DEVICE_NAME, "");
SharedPreUtils.clearSharedPre(getApplicationContext());
SharedPreUtils.putString(getApplicationContext(), SharedPre.Alarm.DEVICE_NAME, string2);
SharedPreUtils.putString(this, SharedPre.User.ACCOUNT_EMAIL, string);
SharedPreUtils.putInt(getApplicationContext(), SharedPre.FactoryUrl.FACTORY_URL, i);
}
@Override
public String getMacId() {
return this.mac;
}
@Override
public HomePresenterImp createPresenter() {
return new HomePresenterImp(this);
}
private void initData() {
String stringExtra = getIntent().getStringExtra("mac_device");
this.mac = stringExtra;
if (!TextUtils.isEmpty(stringExtra)) {
BaseApplication.getApplication().isBind = true;
LogUtils.d("mac地址:++++++++++++++++++", this.mac);
showProgressDialog();
SharedPreUtils.putString(getApplicationContext(), "mac_device", this.mac);
}
((HomePresenterImp) this.mPresenter).startMqtt();
observeBusEvent();
this.airVolumeLl.setVisibility(SharedPreUtils.getInt(getApplicationContext(), SharedPre.App.SERIAL, 1) == 1 ? 8 : 0);
}
private void initView() {
initAnimation();
this.designNavigationView.setItemIconTintList(null);
TextView textView = (TextView) this.designNavigationView.getHeaderView(0).findViewById(R.id.email_tv);
User user = DaoHadle.getUser();
if (user != null) {
textView.setText(user.getEmail());
}
this.designNavigationView.getMenu().getItem(6).setTitle(" " + BaseApplication.getVersionName());
this.designNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public final boolean onNavigationItemSelected(MenuItem menuItem) {
return MainActivity.this.lambda$initView$6$MainActivity(menuItem);
}
});
this.animator = AnimationUtil.RotateAnimation(this.rightIcon);
RentalsSunHeaderView rentalsSunHeaderView = new RentalsSunHeaderView(this);
rentalsSunHeaderView.setLayoutParams(new PtrFrameLayout.LayoutParams(-1, -2));
rentalsSunHeaderView.setPadding(0, ConvertUtils.dp2px(15.0f, this), 0, ConvertUtils.dp2px(10.0f, this));
rentalsSunHeaderView.setUp(this.frame);
this.frame.setResistance(3.0f);
this.frame.setRatioOfHeaderHeightToRefresh(0.2f);
this.frame.setLoadingMinTime(1000);
this.frame.setDurationToCloseHeader(ConnectionResult.DRIVE_EXTERNAL_STORAGE_REQUIRED);
this.frame.setHeaderView(rentalsSunHeaderView);
this.frame.setLastUpdateTimeKey("2011:10:10");
this.frame.addPtrUIHandler(rentalsSunHeaderView);
this.frame.setPullToRefresh(true);
this.frame.postDelayed(new Runnable() {
@Override
public final void run() {
MainActivity.this.lambda$initView$7$MainActivity();
}
}, 100L);
this.frame.setPtrHandler(new PtrHandler() {
public void onStart() {
MainActivity.this.topValueLl.setVisibility(8);
MainActivity.this.topValueLl.setAnimation(AnimationUtil.moveToViewLocation());
MainActivity.this.upDateTv.setVisibility(0);
}
public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
return PtrDefaultHandler.checkContentCanBePulledDown(frame, MainActivity.this.mScrollView, header);
}
public void onRefreshBegin(final PtrFrameLayout frame) {
System.out.println("lyq 下拉刷新后去获取绑定设备---");
((HomePresenterImp) MainActivity.this.mPresenter).getBindedDevice();
}
public void onComplete() {
MainActivity.this.upDateTv.setVisibility(8);
MainActivity.this.topValueLl.setVisibility(0);
MainActivity.this.topValueLl.setAnimation(AnimationUtil.moveToViewLocation());
}
});
initName();
initViewPage();
RxUtil.addWork(new RxUtil.RxActionListener<DeviceWeather>() {
@Override
public void reponseDataNull() {
}
@Override
public void reponseError(Throwable e) {
}
@Override
public DeviceWeather doAction() {
System.out.println("lyq climate getLastWeather");
return DaoHadle.getLastWeather();
}
@Override
public void reponseAction(DeviceWeather deviceWeather) {
System.out.println("lyq climate reponseAction");
MainActivity.this.initHomePage(deviceWeather);
}
});
}
public boolean lambda$initView$6$MainActivity(android.view.MenuItem r9) {
throw new UnsupportedOperationException("Method not decompiled: com.emax.weather.ui.activity.MainActivity.lambda$initView$6$MainActivity(android.view.MenuItem):boolean");
}
public void lambda$initView$7$MainActivity() {
this.frame.autoRefresh(true);
}
private void initAnimation() {
TranslateAnimation translateAnimation = new TranslateAnimation(0.0f, 0.0f, -5.0f, 15.0f);
this.animation1 = translateAnimation;
translateAnimation.setDuration(1000L);
this.animation1.setRepeatCount(-1);
this.animation1.setRepeatMode(1);
this.dripIv1.startAnimation(this.animation1);
TranslateAnimation translateAnimation2 = new TranslateAnimation(0.0f, 0.0f, -5.0f, 15.0f);
this.animation2 = translateAnimation2;
translateAnimation2.setDuration(500L);
this.animation2.setRepeatCount(-1);
this.animation2.setRepeatMode(1);
this.dripIv2.startAnimation(this.animation2);
TranslateAnimation translateAnimation3 = new TranslateAnimation(0.0f, 0.0f, -5.0f, 15.0f);
this.animation3 = translateAnimation3;
translateAnimation3.setDuration(750L);
this.animation3.setRepeatCount(-1);
this.animation3.setRepeatMode(1);
this.dripIv3.startAnimation(this.animation3);
}
private void initName() {
List<DeviceName> deviceName = DaoHadle.getDeviceName(this);
this.nameList = deviceName;
if (deviceName.size() > 0) {
this.nameList.remove(0);
}
ViewPageAdapter viewPageAdapter = this.pageAdapter;
if (viewPageAdapter != null) {
viewPageAdapter.setmNameList(this.nameList);
}
}
private void initViewPage() {
for (int i = 0; i < 3; i++) {
ImageView imageView = new ImageView(this);
imageView.setImageResource(R.drawable.shape_point_normal);
int dimensionPixelSize = getResources().getDimensionPixelSize(R.dimen.point_size);
this.whitePoint.setLayoutParams(new RelativeLayout.LayoutParams(dimensionPixelSize, dimensionPixelSize));
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(dimensionPixelSize, dimensionPixelSize);
if (i > 0) {
layoutParams.leftMargin = getResources().getDimensionPixelSize(R.dimen.point_size);
}
imageView.setLayoutParams(layoutParams);
this.pointGroup.addView(imageView);
}
ArrayList arrayList = new ArrayList();
this.weatherDetailDataList = arrayList;
ViewPageAdapter viewPageAdapter = new ViewPageAdapter(this, arrayList, this.nameList);
this.pageAdapter = viewPageAdapter;
this.subsetViewPage.setAdapter(viewPageAdapter);
this.whitePoint.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
MainActivity mainActivity = MainActivity.this;
mainActivity.mPointMargin = mainActivity.pointGroup.getChildAt(1).getLeft() - MainActivity.this.pointGroup.getChildAt(0).getLeft();
MainActivity.this.whitePoint.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
this.subsetViewPage.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
int i2 = (int) (MainActivity.this.mPointMargin * (position + positionOffset));
RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) MainActivity.this.whitePoint.getLayoutParams();
layoutParams2.leftMargin = i2;
MainActivity.this.whitePoint.setLayoutParams(layoutParams2);
}
@Override
public void onPageScrollStateChanged(int state) {
MainActivity.this.frame.setEnabled(state == 0);
}
});
}
public void initTab() {
this.tabLayout.removeAllTabs();
for (int i = 0; i < 3; i++) {
TabLayout tabLayout = this.tabLayout;
tabLayout.addTab(tabLayout.newTab().setText(this.nameList.get(i).getName()));
}
this.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabSelected(TabLayout.Tab tab) {
int position = tab.getPosition();
if (position == 0) {
MainActivity.this.subsetViewPage.setCurrentItem(0);
} else if (position == 1) {
MainActivity.this.subsetViewPage.setCurrentItem(1);
} else if (position == 2) {
MainActivity.this.subsetViewPage.setCurrentItem(2);
}
MainActivity.this.cellStatus(tab.getPosition());
}
});
}
public void cellStatus(int position) {
List<DeviceWeatherDetailData> list = this.detailDataList;
if (list != null) {
DeviceWeatherDetailData deviceWeatherDetailData = list.get(position);
int i = 0;
if (deviceWeatherDetailData.getTemperatureData() != null) {
i = deviceWeatherDetailData.getTemperatureData().getPower();
} else if (deviceWeatherDetailData.getHumidityData() != null) {
i = deviceWeatherDetailData.getHumidityData().getPower();
}
if (i == 0) {
this.cellIv.setImageResource(R.mipmap.battery1_icon);
} else {
this.cellIv.setImageResource(R.mipmap.battery4_icon);
}
}
}
@Override
public void dismissLoadingViews() {
runOnUiThread(new Runnable() {
@Override
public void run() {
MainActivity.this.frame.refreshComplete();
if (MainActivity.this.animator != null) {
MainActivity.this.animator.cancel();
}
if (MainActivity.this.mapManager != null) {
MainActivity.this.dismissProgressDialog();
}
}
});
}
@Override
public void showLoadingViews() {
showProgressDialog();
}
@Override
public void showErrorViews(final int errorCode, final String msg) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (MainActivity.this.isFinishing()) {
return;
}
ToastUtil.show(msg, MainActivity.this.getApplicationContext());
if (errorCode == 1003) {
new NotUploadDataDialog(MainActivity.this).show();
}
}
});
}
@Override
public void refreshContentView(int type, DeviceWeather data) {
if (!AppUtils.isServiceExisted(this, BaseApplication.getApplication().getServiceName())) {
HistroyDataService.startService(this);
}
System.out.println("lyq climate refreshContentView");
initHomePage(data);
}
public void initHomePage(DeviceWeather data) {
List list = (List) new Gson().fromJson(SharedPreUtils.getString(getApplicationContext(), SharedPre.Alarm.DEVICE_NAME, ""), new TypeToken<List<MyDeviceName>>() {
}.getType());
if (list != null) {
if (list.size() > 4 && !TextUtils.isEmpty(((MyDeviceName) list.get(4)).getDeivceName())) {
this.climatePositionTv.setText(((MyDeviceName) list.get(4)).getDeivceName());
} else {
this.climatePositionTv.setText(getString(R.string.outdoor));
}
}
this.mStartLoadingTime = data.getTime().longValue();
setUptime();
List<SensorDatas> sensorDatas = data.getSensorDatas();
this.sensorDatases = sensorDatas;
for (final SensorDatas sensorDatas2 : sensorDatas) {
if (1 == sensorDatas2.getType() && 0 == sensorDatas2.getChannel().longValue()) {
this.temperature = sensorDatas2;
} else if (2 == sensorDatas2.getType() && 0 == sensorDatas2.getChannel().longValue()) {
this.pressure = sensorDatas2;
}
if (sensorDatas2.getChannel().longValue() == 99) {
if (sensorDatas2.getType() == 1) {
if ("- -".equals(showWeather(sensorDatas2.getCurVal()))) {
this.climateTempTv.setText("- -");
} else {
this.climateTempTv.setText(HomeUtil.getTempValue2(sensorDatas2.getCurVal(), this));
}
if (Boolean.valueOf(SharedPreUtils.getBoolean(this, SharedPre.User.TEMPERATURE_VALUE, true)).booleanValue()) {
this.climateTempUnitTv.setText(getString(R.string.centigrade));
} else {
this.climateTempUnitTv.setText(getString(R.string.Fahrenheit));
}
} else if (sensorDatas2.getType() == 2) {
if ("- -".equals(showWeather(sensorDatas2.getCurVal()))) {
this.climateRainVolumeTv.setText(showWeather(sensorDatas2.getCurVal()));
} else {
this.climateRainVolumeTv.setText(((int) sensorDatas2.getCurVal()) + "");
}
} else if (sensorDatas2.getType() == 3) {
if (sensorDatas2.getDevWindVal() != null) {
if (SharedPreUtils.getBoolean(getApplicationContext(), SharedPre.User.WIND_SPEED, true)) {
this.climateWindTv.setText(showWeather(sensorDatas2.getDevWindVal().getCurrWindSpeed()));
this.climateWindUnitTv.setText(getString(R.string.KPH));
this.windAngelTv.setText(HomeUtil.getDirection((int) sensorDatas2.getDevWindVal().getWindDirection(), (Context) this));
} else {
if (sensorDatas2.getDevWindVal().getCurrWindSpeed() == 65535.0f || sensorDatas2.getDevWindVal().getCurrWindSpeed() == 255.0f) {
this.climateWindTv.setText("- -");
} else {
this.climateWindTv.setText(showWeather(HomeUtil.kmhToMph(sensorDatas2.getDevWindVal().getCurrWindSpeed())));
this.climateWindUnitTv.setText(getString(R.string.MPH));
}
this.windAngelTv.setText(HomeUtil.getDirection((int) sensorDatas2.getDevWindVal().getWindDirection(), (Context) this));
}
if (!isFinishing()) {
try {
Glide.with((FragmentActivity) this).load(Integer.valueOf(R.mipmap.fengche)).transform(new BitmapTransformation(this) {
@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
Matrix matrix = new Matrix();
if (sensorDatas2.getDevWindVal().getWindDirection() == 65535.0f || sensorDatas2.getDevWindVal().getWindDirection() == 255.0f) {
matrix.postRotate(0.0f);
} else {
matrix.postRotate(sensorDatas2.getDevWindVal().getWindDirection());
}
return Bitmap.createBitmap(toTransform, 0, 0, toTransform.getWidth(), toTransform.getHeight(), matrix, true);
}
@Override
public String getId() {
if (sensorDatas2.getDevWindVal().getWindDirection() == 65535.0f || sensorDatas2.getDevWindVal().getWindDirection() == 255.0f) {
return "0";
}
return sensorDatas2.getDevWindVal().getWindDirection() + "";
}
}).into(this.climateWindIv);
} catch (Exception e) {
e.printStackTrace();
}
}
}
} else if (sensorDatas2.getType() == 4) {
if (sensorDatas2.getDevRainfullVals() != null) {
if (getString(R.string.mmh).equals(SharedPreUtils.getString(getApplicationContext(), SharedPre.User.RAIN_VOLUME))) {
if (sensorDatas2.getDevRainfullVals().getHourRainfall() == 65535.0f || sensorDatas2.getDevRainfullVals().getHourRainfall() == 255.0f || sensorDatas2.getDevRainfullVals().getHourRainfall() == 36391.0f) {
this.climateRainValueTv.setText("- -");
} else {
this.climateRainValueTv.setText(String.format("%.1f", Float.valueOf(HomeUtil.inchToMmh(sensorDatas2.getDevRainfullVals().getHourRainfall()))));
}
this.climateRainValueUnitTv.setText(getString(R.string.mmh));
} else {
double hourRainfall = sensorDatas2.getDevRainfullVals().getHourRainfall();
if ("- -".equals(showWeather(new BigDecimal(hourRainfall).setScale(2, RoundingMode.UP).floatValue()))) {
this.climateRainValueTv.setText("- -");
} else {
this.climateRainValueTv.setText(String.format("%.2f", Double.valueOf(hourRainfall)));
}
this.climateRainValueUnitTv.setText(getString(R.string.inchh));
}
}
} else if (sensorDatas2.getType() != 5) {
if (sensorDatas2.getType() == 6) {
if (sensorDatas2.getDevLightVals() != null) {
float currLightIntensity = sensorDatas2.getDevLightVals().getCurrLightIntensity();
if (currLightIntensity != 255.0f && currLightIntensity != 65535.0f) {
this.tvUvValue.setText(String.valueOf((int) currLightIntensity));
if (currLightIntensity < 0.0f) {
this.tvLight.setText("Error");
} else if (currLightIntensity <= 100.0f) {
this.tvLight.setText("Dark/Night");
} else if (currLightIntensity <= 500.0f) {
this.tvLight.setText("Low Light");
} else if (currLightIntensity <= 5000.0f) {
this.tvLight.setText("Overcast/Shade");
} else if (currLightIntensity <= 20000.0f) {
this.tvLight.setText("Daylight");
} else {
this.tvLight.setText("Direct Sun");
}
} else {
this.tvUvValue.setText("- -");
this.tvLight.setText("- -");
}
if (sensorDatas2.getDevLightVals().getCurrUltraviolet() == 65535.0f || sensorDatas2.getDevLightVals().getCurrUltraviolet() == 255.0f || sensorDatas2.getDevLightVals().getCurrUltraviolet() == -99.0f) {
this.climateLevelIv.setImageDrawable(getResources().getDrawable(R.mipmap.icon_uv_low));
this.climateLevelTv.setText("0 LOW");
} else {
final float currUltraviolet = sensorDatas2.getDevLightVals().getCurrUltraviolet();
if (currUltraviolet <= 2.0f) {
this.climateLevelIv.setImageDrawable(getResources().getDrawable(R.mipmap.icon_uv_low));
this.climateLevelTv.setText(((int) currUltraviolet) + " LOW");
} else if (currUltraviolet <= 5.0f) {
this.climateLevelIv.setImageDrawable(getResources().getDrawable(R.mipmap.icon_uv_moderate));
this.climateLevelTv.setText(((int) currUltraviolet) + " MODERATE");
} else if (currUltraviolet <= 8.0f) {
this.climateLevelIv.setImageDrawable(getResources().getDrawable(R.mipmap.icon_uv_high));
this.climateLevelTv.setText(((int) currUltraviolet) + " HIGH");
} else if (currUltraviolet <= 10.0f) {
this.climateLevelIv.setImageDrawable(getResources().getDrawable(R.mipmap.icon_uv_veryhigh));
this.climateLevelTv.setText(((int) currUltraviolet) + " VERY HIGH");
} else {
this.climateLevelIv.setImageDrawable(getResources().getDrawable(R.mipmap.icon_uv_extreme));
this.climateLevelTv.setText(((int) currUltraviolet) + " EXTREME");
}
this.rlUv.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
MainActivity.this.rlUv.getViewTreeObserver().removeOnGlobalLayoutListener(this);
final int width = MainActivity.this.rlUv.getWidth();
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) MainActivity.this.ivCircle.getLayoutParams();
float f = width / 12;
if ((currUltraviolet * f) + MainActivity.this.ivCircle.getWidth() >= width) {
layoutParams.leftMargin = width - MainActivity.this.ivCircle.getWidth();
} else {
layoutParams.leftMargin = (int) (f * currUltraviolet);
}
MainActivity.this.ivCircle.setLayoutParams(layoutParams);
MainActivity.this.llLevel.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
MainActivity.this.llLevel.getViewTreeObserver().removeOnGlobalLayoutListener(this);
LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) MainActivity.this.climateLevelTv.getLayoutParams();
if (((width / 12) * currUltraviolet) + MainActivity.this.climateLevelTv.getWidth() >= MainActivity.this.llLevel.getWidth()) {
layoutParams2.leftMargin = MainActivity.this.llLevel.getWidth() - MainActivity.this.climateLevelTv.getWidth();
} else {
layoutParams2.leftMargin = (int) ((width / 12) * currUltraviolet);
}
MainActivity.this.climateLevelTv.setLayoutParams(layoutParams2);
}
});
}
});
}
}
} else if (sensorDatas2.getType() == 7) {
if (getString(R.string.hpa).equals(SharedPreUtils.getString(getApplicationContext(), SharedPre.User.PRESSURE_UNIT))) {
if ("- -".equals(showWeather(sensorDatas2.getCurVal()))) {
this.climatePressureTv.setText(showWeather(sensorDatas2.getCurVal()));
} else {
this.climatePressureTv.setText(((int) sensorDatas2.getCurVal()) + "");
}
} else if (getString(R.string.inhg).equals(SharedPreUtils.getString(getApplicationContext(), SharedPre.User.PRESSURE_UNIT))) {
this.climatePressureTv.setText(showWeather(new BigDecimal(sensorDatas2.getCurVal() / 33.86d).setScale(2, RoundingMode.UP).floatValue()));
} else if (getString(R.string.mmhg).equals(SharedPreUtils.getString(getApplicationContext(), SharedPre.User.PRESSURE_UNIT))) {
this.climatePressureTv.setText(showWeather(new BigDecimal(sensorDatas2.getCurVal() / 1.3332d).setScale(1, RoundingMode.UP).floatValue()));
} else {
this.climatePressureTv.setText(showWeather(sensorDatas2.getCurVal()));
}
this.climatePressureUnitTv.setText(SharedPreUtils.getString(getApplicationContext(), SharedPre.User.PRESSURE_UNIT));
}
}
}
}
List<SensorDatas> list2 = this.sensorDatases;
if (list2 == null || list2.size() <= 0) {
return;
}
this.detailDataList = HomeUtil.getPageData(this.sensorDatases);
initTab();
this.pageAdapter.setmDatas(this.detailDataList);
initWeather(this.temperature, this.pressure, data.getWeatherStatus());
}
private String showWeather(float cur) {
if (cur == 65535.0f || cur == 255.0f || cur == 36391.0f) {
return "- -";
}
return cur + "";
}
private void initWeather(SensorDatas temperature, SensorDatas pressure, int weatherStatus) {
if (!"- -".equals(showWeather(temperature.getCurVal()))) {
String tempValue1 = HomeUtil.getTempValue1(temperature.getCurVal(), this);
this.chiefNum1.setText(tempValue1.substring(0, tempValue1.indexOf(f.E)));
this.chiefNum2.setText(tempValue1.substring(tempValue1.indexOf(f.E)));
} else {
this.chiefNum1.setText("- -");
this.chiefNum2.setText("");
}
this.weatherCode = weatherStatus;
this.pageAdapter.setmWeatherCode(weatherStatus);
if (!"- -".equals(showWeather(temperature.getLowVal()))) {
this.todayMinValue.setText(HomeUtil.getTempValue1(temperature.getLowVal(), this) + "°");
} else {
this.todayMinValue.setText("- -°");
}
if (!"- -".equals(showWeather(temperature.getHihgVal()))) {
this.todayMaxValue.setText(HomeUtil.getTempValue1(temperature.getHihgVal(), this) + "°");
} else {
this.todayMaxValue.setText("- -°");
}
if (pressure != null) {
int round = Math.round(pressure.getCurVal());
this.humidity.setText(round + "%");
}
}
private void initBgWeatherStatus(int code) {
this.homePage.setBackgroundResource(HomeUtil.getBackGroundImage(code));
this.designNavigationView.setBackgroundResource(HomeUtil.getBackGroundImage(code));
}
@Override
public void showToastMessage(int msg) {
ToastUtil.show(getString(msg), this);
}
@Override
public void setYahooData(final YahooWeather yahooData) {
final String json = new Gson().toJson(yahooData);
System.out.println("lyq YahooData:" + json);
Observable.create(new ObservableOnSubscribe() {
public final void subscribe(ObservableEmitter observableEmitter) {
MainActivity.this.lambda$setYahooData$8$MainActivity(json, observableEmitter);
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidScheduler.mainThread()).subscribe(new Consumer() {
public final void accept(Object obj) {
MainActivity.this.lambda$setYahooData$9$MainActivity(yahooData, (String) obj);
}
}, new Consumer() {
public final void accept(Object obj) {
System.out.println("YahooData.txt获取信息失败 " + ((Throwable) obj).getMessage());
}
});
}
public void lambda$setYahooData$8$MainActivity(String str, ObservableEmitter observableEmitter) throws Exception {
try {
new MyInternalStorage(this).save("YahooData.txt", str);
observableEmitter.onNext("");
} catch (Exception unused) {
observableEmitter.onNext(str);
}
observableEmitter.onComplete();
}
public void lambda$setYahooData$9$MainActivity(YahooWeather yahooWeather, String str) throws Exception {
YahooRealtime realtime = yahooWeather.getRealtime();
this.title.setText(yahooWeather.location.getCity());
initRealtTime(realtime, yahooWeather.forecast.forecasts);
}
private void initRealtTime(YahooRealtime yahooRealtime, List<YahooForecasts> forecastsList) {
this.chiefFeelTv.setText(HomeUtil.getTempValue3(yahooRealtime.getTempFeel(), this));
this.chiefUnit.setText("°");
String string = SharedPreUtils.getString(getApplicationContext(), SharedPre.User.PRESSURE_UNIT);
if (!TextUtils.isEmpty(string)) {
this.pressureUnit.setText(string);
}
this.pressureTv.setText(yahooRealtime.getAtmosValue(string));
this.blastVolumeValueTv.setText(yahooRealtime.getWindSpeedValue(this) + "");
this.blastVolumeValueUnit.setText(yahooRealtime.getWindSpeedUnit(this));
this.directionTv.setText(HomeUtil.getDirection(yahooRealtime.getWindDirection(), (Context) this));
this.sunriseTime.setText(yahooRealtime.getSunrise());
this.sunsetTime.setText(yahooRealtime.getSunset());
if (forecastsList != null) {
if (forecastsList.size() > 0) {
System.out.println("lyq initRealtTime low: " + forecastsList.get(0).getLow() + " high: " + forecastsList.get(0).getHigh());
this.chiefSection.setText(HomeUtil.getTempValue(forecastsList.get(0).getLow(), this) + "°~" + HomeUtil.getTempValue(forecastsList.get(0).getHigh(), this) + "°");
ImageView imageView = this.statusIv;
StringBuilder sb = new StringBuilder();
sb.append("code");
sb.append(forecastsList.get(0).getWeatherCode().getCode());
imageView.setImageResource(HomeUtil.getResource(sb.toString(), this));
initBgWeatherStatus(forecastsList.get(0).getWeatherCode().getCode());
}
if (forecastsList.size() > 1) {
System.out.println("lyq initRealtTime oneWeek low: " + forecastsList.get(1).getLow() + " high: " + forecastsList.get(1).getHigh());
this.oneDateTv.setText(LanguageUtils.enToLanStr(getApplicationContext(), forecastsList.get(1).getDay()));
this.oneWeekTemperatureValue.setText(HomeUtil.getTempValue(forecastsList.get(1).getLow(), forecastsList.get(1).getHigh(), this));
this.oneStatusIv.setImageResource(HomeUtil.getResource("code" + forecastsList.get(1).getWeatherCode().getCode(), this));
}
if (forecastsList.size() > 2) {
System.out.println("lyq initRealtTime twoWeek low: " + forecastsList.get(2).getLow() + " high: " + forecastsList.get(2).getHigh());
this.twoDateTv.setText(LanguageUtils.enToLanStr(getApplicationContext(), forecastsList.get(2).getDay()));
this.twoWeekTemperatureValue.setText(HomeUtil.getTempValue(forecastsList.get(2).getLow(), forecastsList.get(2).getHigh(), this));
this.twoStatusIv.setImageResource(HomeUtil.getResource("code" + forecastsList.get(2).getWeatherCode().getCode(), this));
}
if (forecastsList.size() > 3) {
System.out.println("lyq initRealtTime threeWeek low: " + forecastsList.get(3).getLow() + " high: " + forecastsList.get(3).getHigh());
this.threeDateTv.setText(LanguageUtils.enToLanStr(getApplicationContext(), forecastsList.get(3).getDay()));
this.threeWeekTemperatureValue.setText(HomeUtil.getTempValue(forecastsList.get(3).getLow(), forecastsList.get(3).getHigh(), this));
this.threeStatusIv.setImageResource(HomeUtil.getResource("code" + forecastsList.get(3).getWeatherCode().getCode(), this));
}
if (forecastsList.size() > 4) {
System.out.println("lyq initRealtTime fourWeek low: " + forecastsList.get(4).getLow() + " high: " + forecastsList.get(4).getHigh());
this.fourDateTv.setText(LanguageUtils.enToLanStr(getApplicationContext(), forecastsList.get(4).getDay()));
this.fourWeekTemperatureValue.setText(HomeUtil.getTempValue(forecastsList.get(4).getLow(), forecastsList.get(4).getHigh(), this));
this.fourStatusIv.setImageResource(HomeUtil.getResource("code" + forecastsList.get(4).getWeatherCode().getCode(), this));
}
}
}
@Override
public String getAddress() {
return this.addr;
}
@Override
public void setDeviceInfo(DeviceLocation deviceLocation) {
Log.i("MainActivity", "lyq 下拉刷新 获取到设备信息 准备去获取2种天气");
if (deviceLocation.getCountry() == null || deviceLocation.getCity() == null) {
Toast.makeText(this, R.string.no_location, 0).show();
Intent intent = new Intent(this, (Class<?>) MapActivity.class);
intent.putExtra("ACTION", DNSResolver.QTYPE_IPV4);
startActivity(intent);
return;
}
this.addr = deviceLocation.getCountry() + "," + deviceLocation.getCity();
System.out.println("lyq climate 请求设备信息后 getRealtime");
((HomePresenterImp) this.mPresenter).requestData();
System.out.println("lyq climate 请求设备信息后 getYahooData");
((HomePresenterImp) this.mPresenter).getYahooData();
}
@Override
public void setNearInfo(DeviceNearby deviceNearby) {
this.mainMac = deviceNearby.getSelf().getMac();
IMapManager iMapManager = this.mapManager;
if (iMapManager != null) {
iMapManager.bindLocationData(deviceNearby);
}
}
@Override
public Long getUptime() {
return Long.valueOf(this.mStartLoadingTime);
}
@Override
public String getMac() {
return SharedPreUtils.getString(getApplicationContext(), "mac_device");
}
@Override
public void alarmTos(AlarmEventType info) {
EventData eventData = info.getEventData();
System.out.println("lyq alarmTos");
((Vibrator) getSystemService("vibrator")).vibrate(new long[]{300, 500}, -1);
this.alarmMsg.setText(String.format(getResources().getString(R.string.alarm_msg), HomeUtil.getDeviceName(eventData.getChannel(), this) + " " + HomeUtil.getAlarmMode(eventData.getType(), this)));
this.alarmTime.setText(TimeUtils.timeFormat(eventData.getAlarmTime()));
this.headerRl.setVisibility(8);
this.alarmRl.setVisibility(0);
this.alarmRl.setAnimation(AnimationUtil.moveToViewTopLocation());
}
@Override
public void setAlarmSuccess(List<DeviceAlarm> alarmList) {
Boolean valueOf = Boolean.valueOf(SharedPreUtils.getBoolean(getApplicationContext(), SharedPre.Alarm.SET_NICK_NAME, true));
this.isInit = valueOf;
if (valueOf.booleanValue()) {
if (TextUtils.isEmpty(SharedPreUtils.getString(getApplicationContext(), SharedPre.Alarm.DEVICE_NAME, ""))) {
saveAlarmData(alarmList);
} else {
ArrayList arrayList = (ArrayList) new Gson().fromJson(SharedPreUtils.getString(getApplicationContext(), SharedPre.Alarm.DEVICE_NAME, ""), new TypeToken<List<MyDeviceName>>() {
}.getType());
ArrayList arrayList2 = new ArrayList();
for (int i = 0; i < 4; i++) {
DeviceName deviceName = new DeviceName();
deviceName.setId(Long.valueOf(i));
deviceName.setChanel(i);
if (i == 0) {
deviceName.setName(arrayList.size() > 0 ? ((MyDeviceName) arrayList.get(0)).getDeivceName() : getString(R.string.defualt_master_name));
}
if (i == 1) {
deviceName.setName(arrayList.size() > 1 ? ((MyDeviceName) arrayList.get(1)).getDeivceName() : getString(R.string.defualt_ch1));
}
if (i == 2) {
deviceName.setName(arrayList.size() > 2 ? ((MyDeviceName) arrayList.get(2)).getDeivceName() : getString(R.string.defualt_ch2));
}
if (i == 3) {
deviceName.setName(arrayList.size() > 3 ? ((MyDeviceName) arrayList.get(3)).getDeivceName() : getString(R.string.defualt_ch3));
}
arrayList2.add(deviceName);
}
BaseApplication.getApplication().getDaoSession().getDeviceNameDao().insertOrReplaceInTx(arrayList2);
}
SharedPreUtils.putBoolean(getApplicationContext(), SharedPre.Alarm.SET_NICK_NAME, false);
}
initName();
initTab();
this.pageAdapter.setmDatas(HomeUtil.getPageData(this.sensorDatases));
if (alarmList != null) {
int i2 = 0;
while (true) {
if (i2 >= alarmList.size()) {
break;
}
if (alarmList.get(i2).getChannel() == 0) {
if (alarmList.get(i2).getAlarmMode() != 0) {
this.warning.setImageResource(R.mipmap.warningicon_k);
break;
}
this.warning.setImageResource(R.mipmap.warningicon);
}
i2++;
}
for (int i3 = 0; i3 < alarmList.size(); i3++) {
if (alarmList.get(i3).getChannel() == 99) {
if (alarmList.get(i3).getAlarmMode() != 0) {
this.climateWarningIv.setImageResource(R.mipmap.outdoor_red);
return;
}
this.climateWarningIv.setImageResource(R.mipmap.outdoor_green);
}
}
}
}
private void saveAlarmData(List<DeviceAlarm> data) {
String str = null;
String str2 = null;
String str3 = null;
String str4 = null;
String str5 = null;
for (int i = 0; i < data.size(); i++) {
if (data.get(i).getChannel() == 0) {
if (data.get(i).getType() == 1 || data.get(i).getType() == 0) {
str = data.get(i).getName();
}
} else if (data.get(i).getChannel() == 1) {
if (data.get(i).getType() == 1 || data.get(i).getType() == 0) {
str2 = data.get(i).getName();
}
} else if (data.get(i).getChannel() == 2) {
if (data.get(i).getType() == 1 || data.get(i).getType() == 0) {
str3 = data.get(i).getName();
}
} else if (data.get(i).getChannel() == 3) {
if (data.get(i).getType() == 1 || data.get(i).getType() == 0) {
str4 = data.get(i).getName();
}
} else if (data.get(i).getType() == 1 || data.get(i).getType() == 0) {
str5 = data.get(i).getName();
}
}
if (TextUtils.isEmpty(str)) {
str = getString(R.string.defualt_master_name);
}
if (TextUtils.isEmpty(str2)) {
str2 = getString(R.string.defualt_ch1);
}
if (TextUtils.isEmpty(str3)) {
str3 = getString(R.string.defualt_ch2);
}
if (TextUtils.isEmpty(str4)) {
str4 = getString(R.string.defualt_ch3);
}
if (TextUtils.isEmpty(str5)) {
str5 = getString(R.string.defualt_outdoor);
}
ArrayList arrayList = new ArrayList();
arrayList.add(new MyDeviceName(str));
arrayList.add(new MyDeviceName(str2));
arrayList.add(new MyDeviceName(str3));
arrayList.add(new MyDeviceName(str4));
arrayList.add(new MyDeviceName(str5));
SharedPreUtils.putString(getApplicationContext(), SharedPre.Alarm.DEVICE_NAME, new Gson().toJson(arrayList));
ArrayList arrayList2 = new ArrayList();
for (int i2 = 0; i2 < 4; i2++) {
DeviceName deviceName = new DeviceName();
deviceName.setId(Long.valueOf(i2));
deviceName.setChanel(i2);
if (i2 == 0) {
deviceName.setName(str);
}
if (i2 == 1) {
deviceName.setName(str2);
}
if (i2 == 2) {
deviceName.setName(str3);
}
if (i2 == 3) {
deviceName.setName(str4);
}
arrayList2.add(deviceName);
}
BaseApplication.getApplication().getDaoSession().getDeviceNameDao().insertOrReplaceInTx(arrayList2);
}
@Override
public void setAlarmFail() {
initName();
initTab();
}
@Override
public void undBindDevice() {
if (TextUtils.isEmpty(SharedPreUtils.getString(getApplicationContext(), "mac_device"))) {
startActivity(new Intent(this, (Class<?>) MapActivity.class));
finish();
}
}
@Override
public void showAirVolume(BindedDevice bindedDevice) {
this.frame.refreshComplete();
SharedPreUtils.putString(getApplicationContext(), "mac_device", bindedDevice.getMac());
SharedPreUtils.putInt(getApplicationContext(), SharedPre.App.SERIAL, bindedDevice.getSerial());
SharedPreUtils.putString(getApplicationContext(), SharedPre.User.MATCHING_MODE, bindedDevice.getMatchingMode());
if (bindedDevice.getSerial() == 1) {
this.airVolumeLl.setVisibility(8);
} else if (bindedDevice.getSerial() == 2) {
this.airVolumeLl.setVisibility(0);
}
System.out.println("lyq climate 绑定设备成功后 getUnit getDeviceInfo getAlarm");
((HomePresenterImp) this.mPresenter).getUnit();
((HomePresenterImp) this.mPresenter).getDeviceInfo();
((HomePresenterImp) this.mPresenter).getAlarm();
}
@Override
public void refreshDeviceFail() {
this.frame.refreshComplete();
dismissProgressDialog();
HistroyDataService.stopService(this);
clearCache();
new BindDeviceDialog(this, this).show();
}
@Override
public void refreshYahooData(YahooWeather yahooWeather) {
if (yahooWeather == null) {
return;
}
YahooRealtime yahooRealtime = yahooWeather.realtime;
this.title.setText(yahooWeather.location.getCity());
initRealtTime(yahooRealtime, yahooWeather.forecast.forecasts);
}
public void setUptime() {
this.upStr = TimeUtils.getFriendlyTimeSpanByNow(this.mStartLoadingTime, this);
this.upDateTv.setText(getString(R.string.last_update) + this.upStr);
}
@Override
protected void onPause() {
super.onPause();
dismissLoadingViews();
}
@Override
protected void onResume() {
super.onResume();
this.isActivityLive = true;
Bundle extras = getIntent().getExtras();
if (extras != null) {
String string = extras.getString("body");
System.out.println("lyq body:" + string);
}
if (SharedPreUtils.getInt(getApplicationContext(), SharedPre.FactoryUrl.FACTORY_URL, -1) == 0) {
this.factoryModuleLl.setVisibility(8);
} else {
this.factoryModuleLl.setVisibility(0);
}
initName();
initTab();
((HomePresenterImp) this.mPresenter).getYahooDataFormFile(this);
this.mScrollView.scrollTo(0, 0);
this.mScrollView.scrollBy(0, 0);
if (this.isRefresh.booleanValue()) {
this.frame.autoRefresh(true);
}
this.isRefresh = true;
setRequestedOrientation(1);
restartAnimation();
String string2 = SharedPreUtils.getString(getApplicationContext(), SharedPre.Alarm.ALARM_INFO);
System.out.println("lyq onResume 获取本地报警数据:" + string2);
if (!TextUtils.isEmpty(string2)) {
List<AlarmEventType> list = (List) new Gson().fromJson(string2, new TypeToken<List<AlarmEventType>>() {
}.getType());
this.list = list;
if (list == null || list.size() <= 0) {
return;
}
alarmTos(this.list.get(0));
this.mCurrentAlarmPosition = 0;
return;
}
this.headerRl.setVisibility(0);
this.alarmRl.setVisibility(8);
}
private void restartAnimation() {
this.dripIv1.startAnimation(this.animation1);
this.dripIv2.startAnimation(this.animation2);
this.dripIv3.startAnimation(this.animation3);
}
@Override
protected void onDestroy() {
super.onDestroy();
dismissLoadingViews();
Disposable disposable = this.disposable;
if (disposable != null && !disposable.isDisposed()) {
this.disposable.dispose();
this.disposable = null;
}
Disposable disposable2 = this.rxBusDisposable;
if (disposable2 == null || disposable2.isDisposed()) {
return;
}
this.rxBusDisposable.dispose();
this.rxBusDisposable = null;
}
@Override
public void address(String address) {
this.addr = address;
}
@Override
public void mapManager(IMapManager mapManager) {
this.mapManager = mapManager;
dismissLoadingViews();
}
@OnClick({R.id.left_iv, 2131231423, R.id.warning, R.id.chief_rl_middle, R.id.alarm_rl, R.id.climate_warning_iv})
public void onViewClicked(View view) {
String charSequence;
if (CheckClickUtils.isFastClick()) {
}
switch (view.getId()) {
case R.id.alarm_rl:
this.headerRl.setVisibility(0);
this.alarmRl.setVisibility(8);
List<AlarmEventType> list = this.list;
if (list != null && this.mCurrentAlarmPosition + 1 < list.size()) {
int i = this.mCurrentAlarmPosition + 1;
this.mCurrentAlarmPosition = i;
alarmTos(this.list.get(i));
break;
} else {
this.mCurrentAlarmPosition = 0;
List<AlarmEventType> list2 = this.list;
if (list2 != null) {
list2.clear();
}
SharedPreUtils.putString(getApplicationContext(), SharedPre.Alarm.ALARM_INFO, "");
break;
}
case R.id.climate_warning_iv:
Intent intent = new Intent(this, (Class<?>) RemindActivity.class);
if (TextUtils.isEmpty(this.climatePositionTv.getText().toString())) {
charSequence = getString(R.string.outdoor);
} else {
charSequence = this.climatePositionTv.getText().toString();
}
intent.putExtra("title", charSequence);
intent.putExtra(RemindActivity.CHANNEL, 99);
intent.putExtra(RemindActivity.WEATHER_CODE, this.weatherCode);
startActivity(intent);
break;
case R.id.left_iv:
if (this.drawerLayout.isDrawerOpen(3)) {
this.drawerLayout.closeDrawers();
break;
} else {
this.drawerLayout.openDrawer(3);
break;
}
case 2131231423:
startActivity(new Intent(this, (Class<?>) ClimateActivity.class));
break;
case R.id.warning:
List<DeviceName> deviceName = DaoHadle.getDeviceName(this);
String string = getString(R.string.defualt_master_name);
if (deviceName.size() > 0) {
for (int i2 = 0; i2 < deviceName.size(); i2++) {
if (deviceName.get(i2).getChanel() == 0) {
string = deviceName.get(i2).getName();
}
}
}
Intent intent2 = new Intent(this, (Class<?>) RemindActivity.class);
intent2.putExtra("title", MASTER_NAME);
intent2.putExtra("title", string);
intent2.putExtra(RemindActivity.CHANNEL, 0);
intent2.putExtra(RemindActivity.WEATHER_CODE, this.weatherCode);
startActivity(intent2);
break;
}
}
@Override
public void onUnBound() {
startActivity(new Intent(this, (Class<?>) MapActivity.class));
finish();
}
@Override
public void onLogOut() {
DaoHadle.cleanData();
startActivity(new Intent(this, (Class<?>) LoginActivity.class));
finish();
}
@Override
protected void onStop() {
super.onStop();
this.isActivityLive = false;
this.dripIv1.clearAnimation();
this.dripIv2.clearAnimation();
this.dripIv3.clearAnimation();
}
@Override
public void binding() {
startActivity(new Intent(this, (Class<?>) MapActivity.class));
finish();
}
@Override
public void logout() {
DaoHadle.cleanData();
startActivity(new Intent(this, (Class<?>) LoginActivity.class));
finish();
}
}