正在查看: 爱心e站 v1.0.0 应用的 ActivityInstrumentDemand.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 爱心e站 v1.0.0 应用的 ActivityInstrumentDemand.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.newheyd.JZKFcanjiren.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.google.gson.Gson;
import com.newheyd.JZKFcanjiren.BaseActivity;
import com.newheyd.JZKFcanjiren.Bean.InstrumentStatisticsBean;
import com.newheyd.JZKFcanjiren.R;
import com.newheyd.JZKFcanjiren.Utils.NewUtil;
import com.newheyd.JZKFcanjiren.Utils.StastisticUtil;
import com.newheyd.JZKFcanjiren.Utils.locationUtil.LocationAddrUtil;
import com.newheyd.JZKFcanjiren.View.TitleView;
import com.newheyd.JZKFcanjiren.model.BaseResult;
import com.newheyd.JZKFcanjiren.net.NewHYTask;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import lecho.lib.hellocharts.model.PieChartData;
import lecho.lib.hellocharts.model.SliceValue;
import lecho.lib.hellocharts.view.PieChartView;
import org.json.JSONArray;
import org.json.JSONException;
public class ActivityInstrumentDemand extends BaseActivity {
private TitleView titleView;
private PieChartData typeData;
private LinearLayout type_container;
private ArrayList<InstrumentStatisticsBean> typeStatistics = new ArrayList<>();
private PieChartView typeChartView = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_instrument_demand);
super.onCreate(savedInstanceState);
freshInstrumentStatisic();
goStatistics();
}
public void goStatistics() {
HashMap<String, String> map = LocationAddrUtil.getInstance().getLocationParam(this.mContext);
StastisticUtil.getInstance().onEvent(this.mContext, "ActivityInstrumentDemand", map);
}
public void freshInstrumentStatisic() {
try {
InputStream is = this.mContext.getAssets().open("instrument_statistic");
int length = is.available();
byte[] buffer = new byte[length];
is.read(buffer);
String temp = new String(buffer);
Gson gson = new Gson();
this.typeStatistics.clear();
try {
JSONArray jsonArray = new JSONArray(temp);
for (int i = 0; i < jsonArray.length(); i++) {
this.typeStatistics.add(gson.fromJson(jsonArray.getString(i), InstrumentStatisticsBean.class));
}
} catch (JSONException e) {
e.printStackTrace();
}
} catch (IOException e2) {
e2.printStackTrace();
}
int numValues = this.typeStatistics.size() > 7 ? 7 : this.typeStatistics.size();
String[] colors = {"#255E91", "#5B9BD5", "#ED7D31", "#A5A5A5", "#FFC000", "#4472C4", "#70AD47"};
List<SliceValue> values = new ArrayList<>();
double totalNum = 0.0d;
if (this.type_container.getChildCount() > 0) {
this.type_container.removeAllViews();
}
for (int i2 = 0; i2 < numValues; i2++) {
totalNum += this.typeStatistics.get(i2).getNum();
}
for (int i3 = 0; i3 < numValues; i3++) {
SliceValue sliceValue = new SliceValue(this.typeStatistics.get(i3).getNum(), Color.parseColor(colors[i3]));
values.add(sliceValue);
View child = LayoutInflater.from(this.mContext).inflate(R.layout.item_type, (ViewGroup) null);
TextView tv_name = (TextView) child.findViewById(R.id.type_name);
TextView tv_hot = (TextView) child.findViewById(R.id.type_hot);
tv_hot.setBackground(NewUtil.getDrawable(this.mContext.getResources().getDimension(R.dimen.dimen_20), Color.parseColor(colors[i3])));
tv_name.setText(this.typeStatistics.get(i3).getIdtkind() + ":" + String.valueOf(this.typeStatistics.get(i3).getNum()) + "/" + NewUtil.formatData((this.typeStatistics.get(i3).getNum() * 100.0d) / totalNum) + "%");
this.type_container.addView(child);
}
this.typeData = new PieChartData(values);
this.typeData.setHasLabels(false);
this.typeData.setHasCenterCircle(true);
this.typeData.setCenterText1("总计");
this.typeData.setCenterText1FontSize(16);
this.typeData.setCenterText2FontSize(14);
this.typeData.setCenterText2(String.valueOf(totalNum));
this.typeChartView.setChartRotationEnabled(false);
this.typeChartView.setValueTouchEnabled(true);
this.typeChartView.setPieChartData(this.typeData);
this.typeChartView.setValueSelectionEnabled(false);
}
@Override
public void onResponseBefore(NewHYTask task) {
}
@Override
public void onResponseAfter(NewHYTask task) {
}
@Override
public void onResponseSuccessful(NewHYTask task, BaseResult object) {
}
@Override
public void onResponseError(NewHYTask task, BaseResult object) {
}
@Override
public void onServerError(NewHYTask task, int failedType) {
}
@Override
public void initViews() {
this.titleView = (TitleView) findViewById(R.id.titleview_service);
this.typeChartView = findViewById(R.id.chart_type);
this.type_container = (LinearLayout) findViewById(R.id.type_container);
}
@Override
public void setListener() {
this.titleView.setOnTitleClik(new TitleView.BackListenner() {
@Override
public void BackSet() {
ActivityInstrumentDemand.this.finish();
}
}, null);
}
}