正在查看: WeatherSense v1.8.9 应用的 ClimateActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: WeatherSense v1.8.9 应用的 ClimateActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.emax.weather.ui.activity;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Bundle;
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.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.alibaba.pdns.DNSResolver;
import com.emax.weahter.R;
import com.emax.weather.base.BaseActivity;
import com.emax.weather.base.BaseApplication;
import com.emax.weather.base.BaseFragment;
import com.emax.weather.bean.DeviceName;
import com.emax.weather.bean.db.DaoHadle;
import com.emax.weather.receiver.DataDownloadReceiver;
import com.emax.weather.service.HistroyDataService;
import com.emax.weather.ui.fragment.climate.ClimateDayHistoryFragment;
import com.emax.weather.ui.fragment.climate.ClimateMonthHistoryFragment;
import com.emax.weather.ui.fragment.climate.ClimateWeekHistoryFragment;
import com.emax.weather.utils.CheckClickUtils;
import com.emax.weather.widget.DeviceSelectPopWindow;
import com.emax.weather.widget.TypeSelectPopWindow;
import com.ezon.health.utils_lib.AppUtils;
import com.ezon.health.utils_lib.SharedPre;
import com.ezon.health.utils_lib.SharedPreUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class ClimateActivity extends BaseActivity implements BaseFragment.FragmentManageListener, DeviceSelectPopWindow.OnCheckClickListener, TypeSelectPopWindow.OnTypeCheckClickListener {
public static final int AIRVOLUME = 3;
public static final int CH1 = 1;
public static final int CH2 = 2;
public static final int CH3 = 3;
public static final int HUMIDITY = 2;
public static final int MAIN = 0;
public static final int NOISE = 5;
public static final int OUTDOOR = 99;
public static final int PRESENTER = 7;
public static final int RIANFALL = 4;
public static final int TAG_DAY = 0;
public static final int TAG_MONTH = 2;
public static final int TAG_WEEK = 1;
public static final int TEMP = 1;
public static final int ULTRAVIOLETRAYS = 6;
@BindView(R.id.back_image)
ImageView backImage;
private String befStr;
private int channel;
private ClimateDayHistoryFragment climateDayFragment;
@BindView(R.id.climate_day_rl)
RelativeLayout climateDayRl;
@BindView(R.id.climate_day_tv)
TextView climateDayTv;
@BindView(R.id.climate_day_view)
View climateDayView;
@BindView(R.id.climate_device_title)
TextView climateDeviceTitle;
@BindView(R.id.climate_left_rl)
RelativeLayout climateLeftRl;
private ClimateMonthHistoryFragment climateMonthFragment;
@BindView(R.id.climate_month_rl)
RelativeLayout climateMonthRl;
@BindView(R.id.climate_month_tv)
TextView climateMonthTv;
@BindView(R.id.climate_month_view)
View climateMonthView;
@BindView(R.id.climate_right_rl)
RelativeLayout climateRightRl;
@BindView(R.id.climate_type_title)
TextView climateTypeTitle;
private ClimateWeekHistoryFragment climateWeekFragment;
@BindView(R.id.climate_week_rl)
RelativeLayout climateWeekRl;
@BindView(R.id.climate_week_tv)
TextView climateWeekTv;
@BindView(R.id.climate_week_view)
View climateWeekView;
private DataDownloadReceiver dataDownloadReceiver;
private int deleteIndex;
DeviceSelectPopWindow deviceSelectPopWindow;
@BindView(R.id.llFactoryModule)
LinearLayout factoryModuleLl;
FragmentManager fragmentManager;
private List<BaseFragment> fragments;
private int position;
@BindView(R.id.tv_show_progress)
TextView showProgressTv;
private int type;
List<String> typeList;
TypeSelectPopWindow typeSelectPopWindow;
private String[] types;
@Override
public void budleParam(Map<String, String> map) {
}
@Override
protected int getActivityRId() {
return R.layout.activity_climate;
}
@Override
public void showFragment(String pageTag) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
if (!AppUtils.isServiceExisted(this, BaseApplication.getApplication().getServiceName())) {
HistroyDataService.startService(this);
}
this.fragmentManager = getSupportFragmentManager();
if (savedInstanceState != null) {
System.out.println(this.fragmentManager.getFragments());
this.climateDayFragment = (ClimateDayHistoryFragment) this.fragmentManager.findFragmentByTag("dayFragment");
this.climateWeekFragment = (ClimateWeekHistoryFragment) this.fragmentManager.findFragmentByTag("weekFragment");
this.climateMonthFragment = (ClimateMonthHistoryFragment) this.fragmentManager.findFragmentByTag("monthFragment");
}
super.onCreate(savedInstanceState);
getWindow().addFlags(1024);
ButterKnife.bind(this);
initView();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
if (this.climateDayFragment != null) {
getSupportFragmentManager().putFragment(outState, "dayFragment", this.climateDayFragment);
}
if (this.climateWeekFragment != null) {
getSupportFragmentManager().putFragment(outState, "weekFragment", this.climateWeekFragment);
}
if (this.climateMonthFragment != null) {
getSupportFragmentManager().putFragment(outState, "monthFragment", this.climateMonthFragment);
}
super.onSaveInstanceState(outState);
}
private void initView() {
if (SharedPreUtils.getInt(this, SharedPre.FactoryUrl.FACTORY_URL, -1) == 0) {
this.factoryModuleLl.setVisibility(8);
} else {
this.factoryModuleLl.setVisibility(0);
}
this.types = new String[]{getString(R.string.temperature), getString(R.string.humidity), getString(R.string.airvolume), getString(R.string.rainvolume), getString(R.string.rays), getString(R.string.noise), getString(R.string.pressure)};
this.type = 1;
this.channel = 0;
this.fragments = new ArrayList();
setPosition(0);
List<DeviceName> climateDeviceName = DaoHadle.getClimateDeviceName(this);
this.deviceSelectPopWindow = new DeviceSelectPopWindow(this, this, climateDeviceName);
if (climateDeviceName.size() > 0) {
this.climateDeviceTitle.setText(climateDeviceName.get(0).getName());
} else {
this.climateDeviceTitle.setText(getString(R.string.Master));
}
this.typeList = DaoHadle.getClimateType(this);
TypeSelectPopWindow typeSelectPopWindow = new TypeSelectPopWindow(this, this, this.typeList);
this.typeSelectPopWindow = typeSelectPopWindow;
this.befStr = DNSResolver.QTYPE_IPV4;
typeSelectPopWindow.selectDevice(this.channel, DNSResolver.QTYPE_IPV4);
this.typeSelectPopWindow.notifyData();
this.climateTypeTitle.setText(getString(R.string.temperature));
this.dataDownloadReceiver = new DataDownloadReceiver() {
@Override
public void onDownloadData(String percent) {
ClimateActivity.this.showProgressTv.setVisibility(0);
ClimateActivity.this.showProgressTv.setText(ClimateActivity.this.getString(R.string.downloading) + " " + percent);
System.out.println("lyq climate 历史数据正在下载:" + percent);
}
@Override
public void onDownloadDataSuccess() {
System.out.println("lyq climate 历史数据正在下载完成");
ClimateActivity.this.showProgressTv.setVisibility(8);
ClimateActivity climateActivity = ClimateActivity.this;
climateActivity.setPosition(climateActivity.position);
ClimateActivity climateActivity2 = ClimateActivity.this;
climateActivity2.unregisterReceiver(climateActivity2.dataDownloadReceiver);
ClimateActivity.this.dataDownloadReceiver = null;
}
};
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(DataDownloadReceiver.DATA_DOWNLOADING_ACTION);
intentFilter.addAction(DataDownloadReceiver.DATA_DOWNLOAD_SUCCESS_ACTION);
if (Build.VERSION.SDK_INT >= 33) {
registerReceiver(this.dataDownloadReceiver, intentFilter, 2);
} else {
registerReceiver(this.dataDownloadReceiver, intentFilter);
}
if (AppUtils.isServiceExisted(this, BaseApplication.getApplication().getServiceName())) {
if (!SharedPreUtils.getBoolean(getApplicationContext(), SharedPre.History.LOAD_ALL, false)) {
Toast.makeText(getApplicationContext(), getString(R.string.load_all_data), 1).show();
this.showProgressTv.setVisibility(0);
this.showProgressTv.setText(getString(R.string.downloading) + " -- %");
return;
}
this.showProgressTv.setVisibility(8);
return;
}
this.showProgressTv.setVisibility(8);
}
public void setPosition(int position) {
this.position = position;
if (position == 0) {
ClimateDayHistoryFragment climateDayHistoryFragment = this.climateDayFragment;
if (climateDayHistoryFragment == null) {
ClimateDayHistoryFragment newInstance = ClimateDayHistoryFragment.newInstance(this.channel, this.type);
this.climateDayFragment = newInstance;
this.fragments.add(newInstance);
hideOthersFragment(this.climateDayFragment, R.id.climate_contentLayout, "dayFragment", true);
return;
}
climateDayHistoryFragment.setChange(this.channel, this.type);
hideOthersFragment(this.climateDayFragment, R.id.climate_contentLayout, "dayFragment", false);
return;
}
if (position == 1) {
ClimateWeekHistoryFragment climateWeekHistoryFragment = this.climateWeekFragment;
if (climateWeekHistoryFragment == null) {
ClimateWeekHistoryFragment newInstance2 = ClimateWeekHistoryFragment.newInstance(this.channel, this.type);
this.climateWeekFragment = newInstance2;
this.fragments.add(newInstance2);
hideOthersFragment(this.climateWeekFragment, R.id.climate_contentLayout, "weekFragment", true);
return;
}
climateWeekHistoryFragment.setChange(this.channel, this.type);
hideOthersFragment(this.climateWeekFragment, R.id.climate_contentLayout, "weekFragment", false);
return;
}
if (position != 2) {
return;
}
ClimateMonthHistoryFragment climateMonthHistoryFragment = this.climateMonthFragment;
if (climateMonthHistoryFragment == null) {
ClimateMonthHistoryFragment newInstance3 = ClimateMonthHistoryFragment.newInstance(this.channel, this.type);
this.climateMonthFragment = newInstance3;
this.fragments.add(newInstance3);
hideOthersFragment(this.climateMonthFragment, R.id.climate_contentLayout, "monthFragment", true);
return;
}
climateMonthHistoryFragment.setChange(this.channel, this.type);
hideOthersFragment(this.climateMonthFragment, R.id.climate_contentLayout, "monthFragment", false);
}
private void hideOthersFragment(BaseFragment showFragment, int contentId, String tag, Boolean add) {
FragmentTransaction beginTransaction = this.fragmentManager.beginTransaction();
if (add.booleanValue()) {
beginTransaction.add(contentId, showFragment, tag);
}
for (int i = 0; i < this.fragments.size(); i++) {
if (showFragment == this.fragments.get(i)) {
beginTransaction.show(this.fragments.get(i));
} else {
beginTransaction.hide(this.fragments.get(i));
}
}
beginTransaction.commitAllowingStateLoss();
}
private int getBarHeight() {
int identifier = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (identifier > 0) {
return getResources().getDimensionPixelSize(identifier);
}
return 0;
}
@OnClick({R.id.climate_left_rl, R.id.climate_right_rl, R.id.climate_day_rl, R.id.climate_week_rl, R.id.climate_month_rl})
public void onViewClicked(View view) {
if (CheckClickUtils.isFastClick()) {
}
switch (view.getId()) {
case R.id.climate_day_rl:
setPosition(0);
this.climateDayTv.setTextColor(getResources().getColor(2131034905));
this.climateDayView.setBackgroundColor(getResources().getColor(2131034905));
this.climateWeekTv.setTextColor(getResources().getColor(R.color.font_6b));
this.climateWeekView.setBackgroundColor(getResources().getColor(R.color.color_grey_525464));
this.climateMonthTv.setTextColor(getResources().getColor(R.color.font_6b));
this.climateMonthView.setBackgroundColor(getResources().getColor(R.color.color_grey_525464));
break;
case R.id.climate_left_rl:
this.deviceSelectPopWindow.showPopupWindow(view, view.getLeft(), view.getBottom() + getBarHeight() + 20);
break;
case R.id.climate_month_rl:
setPosition(2);
this.climateDayTv.setTextColor(getResources().getColor(R.color.font_6b));
this.climateDayView.setBackgroundColor(getResources().getColor(R.color.color_grey_525464));
this.climateWeekTv.setTextColor(getResources().getColor(R.color.font_6b));
this.climateWeekView.setBackgroundColor(getResources().getColor(R.color.color_grey_525464));
this.climateMonthTv.setTextColor(getResources().getColor(2131034905));
this.climateMonthView.setBackgroundColor(getResources().getColor(2131034905));
break;
case R.id.climate_right_rl:
this.typeSelectPopWindow.showPopupWindow(view, view.getLeft(), view.getBottom() + getBarHeight() + 20);
break;
case R.id.climate_week_rl:
setPosition(1);
this.climateDayTv.setTextColor(getResources().getColor(R.color.font_6b));
this.climateDayView.setBackgroundColor(getResources().getColor(R.color.color_grey_525464));
this.climateWeekTv.setTextColor(getResources().getColor(2131034905));
this.climateWeekView.setBackgroundColor(getResources().getColor(2131034905));
this.climateMonthTv.setTextColor(getResources().getColor(R.color.font_6b));
this.climateMonthView.setBackgroundColor(getResources().getColor(R.color.color_grey_525464));
break;
}
}
@Override
public void onCheck(Object object) {
if (object.getClass() == DeviceName.class) {
DeviceName deviceName = (DeviceName) object;
this.climateDeviceTitle.setText(deviceName.getName());
this.channel = deviceName.getChanel();
this.type = 1;
System.out.println("lyq climate (1:温度,2:湿度 ,3:风量,4:雨量,5:紫外线,6:气压) type:" + this.type + ",channel:" + this.channel);
this.befStr = DNSResolver.QTYPE_IPV4;
this.climateTypeTitle.setText(getString(R.string.temperature));
} else if (object.getClass() == String.class) {
this.climateTypeTitle.setText(object.toString());
for (int i = 0; i < this.types.length; i++) {
if (object.toString().equals(this.types[i])) {
this.type = i + 1;
System.out.println("lyq climate (1:温度,2:湿度 ,3:风量,4:雨量,5:紫外线,6:气压) type:" + this.type);
}
}
}
System.out.println("befStr = " + this.befStr);
this.typeSelectPopWindow.selectDevice(this.channel, this.befStr);
this.typeSelectPopWindow.notifyData();
int i2 = this.position;
if (i2 == 0) {
this.climateDayFragment.setChange(this.channel, this.type);
} else if (i2 == 1) {
this.climateWeekFragment.setChange(this.channel, this.type);
} else {
if (i2 != 2) {
return;
}
this.climateMonthFragment.setChange(this.channel, this.type);
}
}
@Override
public void onTypeCheck(int index, Object object) {
System.out.println("index = " + index + "object = " + object.toString());
if (DNSResolver.QTYPE_IPV4.equals(object.toString())) {
this.climateTypeTitle.setText(getString(R.string.temperature));
this.typeSelectPopWindow.setNotifyDataChange(this.befStr, DNSResolver.QTYPE_IPV4);
this.type = 1;
this.befStr = DNSResolver.QTYPE_IPV4;
} else if ("2".equals(object.toString())) {
this.climateTypeTitle.setText(getString(R.string.humidity));
this.typeSelectPopWindow.setNotifyDataChange(this.befStr, "2");
this.type = 2;
this.befStr = "2";
} else if ("3".equals(object.toString())) {
this.climateTypeTitle.setText(getString(R.string.airvolume));
this.typeSelectPopWindow.setNotifyDataChange(this.befStr, "3");
this.type = 3;
this.befStr = "3";
} else if ("4".equals(object.toString())) {
this.climateTypeTitle.setText(getString(R.string.rainvolume));
this.typeSelectPopWindow.setNotifyDataChange(this.befStr, "4");
this.type = 4;
this.befStr = "4";
} else if ("5".equals(object.toString())) {
this.climateTypeTitle.setText(getString(R.string.rays));
this.typeSelectPopWindow.setNotifyDataChange(this.befStr, "5");
this.type = 6;
this.befStr = "5";
} else if ("6".equals(object.toString())) {
this.climateTypeTitle.setText(getString(R.string.pressure));
this.typeSelectPopWindow.setNotifyDataChange(this.befStr, "6");
this.type = 7;
this.befStr = "6";
}
int i = this.position;
if (i == 0) {
this.climateDayFragment.setChange(this.channel, this.type);
} else if (i == 1) {
this.climateWeekFragment.setChange(this.channel, this.type);
} else {
if (i != 2) {
return;
}
this.climateMonthFragment.setChange(this.channel, this.type);
}
}
@Override
protected void onDestroy() {
super.onDestroy();
DataDownloadReceiver dataDownloadReceiver = this.dataDownloadReceiver;
if (dataDownloadReceiver != null) {
unregisterReceiver(dataDownloadReceiver);
}
}
}