You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
3.1 KiB
90 lines
3.1 KiB
package com.example.yangenneng0.myapplication.viewUI;
|
|
|
|
import android.content.DialogInterface;
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.support.v7.app.AlertDialog;
|
|
import android.support.v7.app.AppCompatActivity;
|
|
import android.util.Log;
|
|
import android.view.View;
|
|
import android.widget.Button;
|
|
|
|
import com.example.yangenneng0.myapplication.R;
|
|
import com.example.yangenneng0.myapplication.dao.UserDataDao;
|
|
import com.example.yangenneng0.myapplication.model.UserData;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
public class StatisticalChartActivity extends AppCompatActivity {
|
|
|
|
Button lineChartBtn;// 折线图按钮
|
|
Button pieChartBtn; //饼状图按钮
|
|
private ArrayList<UserData> UserDataList;
|
|
AlertDialog.Builder builder;
|
|
@Override
|
|
protected void onCreate( Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
setContentView(R.layout.statistical_chart);
|
|
|
|
UserDataDao userDataDao = new UserDataDao();
|
|
UserDataList = userDataDao.getUserDataList();
|
|
|
|
builder = new AlertDialog.Builder(this);
|
|
builder.setTitle("没有数据");
|
|
builder.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
dialog.dismiss();
|
|
}
|
|
});
|
|
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
dialog.dismiss();
|
|
}
|
|
});
|
|
initView();
|
|
}
|
|
|
|
/*
|
|
* 绑定统计图页面内2个选项button click事件
|
|
* */
|
|
private void initView() {
|
|
lineChartBtn = findViewById(R.id.line_chart_entrance_btn);
|
|
pieChartBtn = findViewById(R.id.pie_chart_entrance_btn);
|
|
|
|
//折线图入口
|
|
lineChartBtn.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
if (UserDataList.size() != 0) {
|
|
Log.d("222222222","333333333");
|
|
Intent intent = new Intent();
|
|
intent.setClass(StatisticalChartActivity.this, LineChartActivity.class);
|
|
StatisticalChartActivity.this.startActivity(intent);
|
|
}else{
|
|
//页面返回时,弹出提示框,包括确认、取消按钮,提示文字
|
|
Log.d("222222222","222222222");
|
|
builder.show();
|
|
}
|
|
}
|
|
});
|
|
|
|
//饼状图入口
|
|
pieChartBtn.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
if (UserDataList.size() != 0) {
|
|
Intent intent = new Intent();
|
|
intent.setClass(StatisticalChartActivity.this, PieChartActivity.class);
|
|
StatisticalChartActivity.this.startActivity(intent);
|
|
}else{
|
|
builder.show();
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
}
|