|
|
@ -2,13 +2,13 @@ package com.tanshui.timeuse.fragment;
|
|
|
|
|
|
|
|
|
|
|
|
import android.graphics.Color;
|
|
|
|
import android.graphics.Color;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
@ -18,26 +18,27 @@ import com.tanshui.timeuse.PieInfo;
|
|
|
|
import com.tanshui.timeuse.R;
|
|
|
|
import com.tanshui.timeuse.R;
|
|
|
|
import com.tanshui.timeuse.database.timeUseDBHelper;
|
|
|
|
import com.tanshui.timeuse.database.timeUseDBHelper;
|
|
|
|
import com.tanshui.timeuse.taskInfo;
|
|
|
|
import com.tanshui.timeuse.taskInfo;
|
|
|
|
import com.tanshui.timeuse.util.ColorRandom;
|
|
|
|
|
|
|
|
import com.tanshui.timeuse.util.PieChart;
|
|
|
|
import com.tanshui.timeuse.util.PieChart;
|
|
|
|
|
|
|
|
|
|
|
|
import java.text.NumberFormat;
|
|
|
|
import java.text.NumberFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
public class today extends Fragment{
|
|
|
|
public class today extends Fragment{
|
|
|
|
private List<PieInfo> pieInfoList=new ArrayList<>();
|
|
|
|
|
|
|
|
private List<AppInfo> appInfoList=new ArrayList<>();
|
|
|
|
|
|
|
|
private List<taskInfo> taskInfoList=new ArrayList<>();
|
|
|
|
|
|
|
|
private timeUseDBHelper dbHepler;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
|
View view = inflater.inflate(R.layout.fragment_today, container, false);
|
|
|
|
View view = inflater.inflate(R.layout.fragment_today, container, false);
|
|
|
|
|
|
|
|
List<PieInfo> pieInfoList=new ArrayList<>();
|
|
|
|
|
|
|
|
List<AppInfo> appInfoList;
|
|
|
|
|
|
|
|
List<taskInfo> taskInfoList;
|
|
|
|
|
|
|
|
timeUseDBHelper dbHepler;
|
|
|
|
TextView btn1=view.findViewById(R.id.pie_btn1);
|
|
|
|
TextView btn1=view.findViewById(R.id.pie_btn1);
|
|
|
|
TextView btn2=view.findViewById(R.id.pie_btn2);
|
|
|
|
TextView btn2=view.findViewById(R.id.pie_btn2);
|
|
|
|
TextView btn3=view.findViewById(R.id.pie_btn3);
|
|
|
|
TextView btn3=view.findViewById(R.id.pie_btn3);
|
|
|
@ -167,11 +168,11 @@ public class today extends Fragment{
|
|
|
|
pie_chart1.startAnima();
|
|
|
|
pie_chart1.startAnima();
|
|
|
|
long finalTotalTime = totalTime;
|
|
|
|
long finalTotalTime = totalTime;
|
|
|
|
btn1.setOnClickListener(v -> {
|
|
|
|
btn1.setOnClickListener(v -> {
|
|
|
|
if (pieInfoList.get(0).selected) {
|
|
|
|
if (pieInfoList.get(0).isSelected()) {
|
|
|
|
pieInfoList.get(0).selected = false;
|
|
|
|
pieInfoList.get(0).setSelected(false);
|
|
|
|
btn1.setText(topFive.get(0).getLabel()+" "+getTimeFromInt(topFive.get(0).getTimeLong()));
|
|
|
|
btn1.setText(topFive.get(0).getLabel()+" "+getTimeFromInt(topFive.get(0).getTimeLong()));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
pieInfoList.get(0).selected = true;
|
|
|
|
pieInfoList.get(0).setSelected(true);
|
|
|
|
btn1.setText(topFive.get(0).getLabel()+" "+percentInstance.format((float)topFive.get(0).getTimeLong()/ finalTotalTime));
|
|
|
|
btn1.setText(topFive.get(0).getLabel()+" "+percentInstance.format((float)topFive.get(0).getTimeLong()/ finalTotalTime));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pie_chart1.setData(pieInfoList);
|
|
|
|
pie_chart1.setData(pieInfoList);
|
|
|
@ -179,11 +180,11 @@ public class today extends Fragment{
|
|
|
|
pie_chart1.invalidate();
|
|
|
|
pie_chart1.invalidate();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
btn2.setOnClickListener(v -> {
|
|
|
|
btn2.setOnClickListener(v -> {
|
|
|
|
if (pieInfoList.get(1).selected) {
|
|
|
|
if (pieInfoList.get(1).isSelected()) {
|
|
|
|
pieInfoList.get(1).selected = false;
|
|
|
|
pieInfoList.get(1).setSelected(false);
|
|
|
|
btn2.setText(topFive.get(1).getLabel()+" "+getTimeFromInt(topFive.get(1).getTimeLong()));
|
|
|
|
btn2.setText(topFive.get(1).getLabel()+" "+getTimeFromInt(topFive.get(1).getTimeLong()));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
pieInfoList.get(1).selected = true;
|
|
|
|
pieInfoList.get(1).setSelected(true);
|
|
|
|
btn2.setText(topFive.get(1).getLabel()+" "+percentInstance.format((float)topFive.get(1).getTimeLong()/ finalTotalTime));
|
|
|
|
btn2.setText(topFive.get(1).getLabel()+" "+percentInstance.format((float)topFive.get(1).getTimeLong()/ finalTotalTime));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pie_chart1.setData(pieInfoList);
|
|
|
|
pie_chart1.setData(pieInfoList);
|
|
|
@ -191,11 +192,11 @@ public class today extends Fragment{
|
|
|
|
pie_chart1.invalidate();
|
|
|
|
pie_chart1.invalidate();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
btn3.setOnClickListener(v -> {
|
|
|
|
btn3.setOnClickListener(v -> {
|
|
|
|
if (pieInfoList.get(2).selected) {
|
|
|
|
if (pieInfoList.get(2).isSelected()) {
|
|
|
|
pieInfoList.get(2).selected = false;
|
|
|
|
pieInfoList.get(2).setSelected(false);
|
|
|
|
btn3.setText(topFive.get(2).getLabel()+" "+getTimeFromInt(topFive.get(2).getTimeLong()));
|
|
|
|
btn3.setText(topFive.get(2).getLabel()+" "+getTimeFromInt(topFive.get(2).getTimeLong()));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
pieInfoList.get(2).selected = true;
|
|
|
|
pieInfoList.get(2).setSelected(true);
|
|
|
|
btn3.setText(topFive.get(2).getLabel()+" "+percentInstance.format((float)topFive.get(3).getTimeLong()/ finalTotalTime));
|
|
|
|
btn3.setText(topFive.get(2).getLabel()+" "+percentInstance.format((float)topFive.get(3).getTimeLong()/ finalTotalTime));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pie_chart1.setData(pieInfoList);
|
|
|
|
pie_chart1.setData(pieInfoList);
|
|
|
@ -203,11 +204,11 @@ public class today extends Fragment{
|
|
|
|
pie_chart1.invalidate();
|
|
|
|
pie_chart1.invalidate();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
btn4.setOnClickListener(v -> {
|
|
|
|
btn4.setOnClickListener(v -> {
|
|
|
|
if (pieInfoList.get(3).selected) {
|
|
|
|
if (pieInfoList.get(3).isSelected()) {
|
|
|
|
pieInfoList.get(3).selected = false;
|
|
|
|
pieInfoList.get(3).setSelected(false);
|
|
|
|
btn4.setText(topFive.get(3).getLabel()+" "+getTimeFromInt(topFive.get(3).getTimeLong()));
|
|
|
|
btn4.setText(topFive.get(3).getLabel()+" "+getTimeFromInt(topFive.get(3).getTimeLong()));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
pieInfoList.get(3).selected = true;
|
|
|
|
pieInfoList.get(3).setSelected(true);
|
|
|
|
btn4.setText(topFive.get(3).getLabel()+" "+percentInstance.format((float)topFive.get(3).getTimeLong()/ finalTotalTime));
|
|
|
|
btn4.setText(topFive.get(3).getLabel()+" "+percentInstance.format((float)topFive.get(3).getTimeLong()/ finalTotalTime));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pie_chart1.setData(pieInfoList);
|
|
|
|
pie_chart1.setData(pieInfoList);
|
|
|
@ -215,11 +216,11 @@ public class today extends Fragment{
|
|
|
|
pie_chart1.invalidate();
|
|
|
|
pie_chart1.invalidate();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
btn5.setOnClickListener(v -> {
|
|
|
|
btn5.setOnClickListener(v -> {
|
|
|
|
if (pieInfoList.get(4).selected) {
|
|
|
|
if (pieInfoList.get(4).isSelected()) {
|
|
|
|
pieInfoList.get(4).selected = false;
|
|
|
|
pieInfoList.get(4).setSelected(false);
|
|
|
|
btn5.setText(topFive.get(4).getLabel()+" "+getTimeFromInt(topFive.get(4).getTimeLong()));
|
|
|
|
btn5.setText(topFive.get(4).getLabel()+" "+getTimeFromInt(topFive.get(4).getTimeLong()));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
pieInfoList.get(4).selected = true;
|
|
|
|
pieInfoList.get(4).setSelected(true);
|
|
|
|
btn5.setText(topFive.get(4).getLabel()+" "+percentInstance.format((float)topFive.get(4).getTimeLong()/ finalTotalTime));
|
|
|
|
btn5.setText(topFive.get(4).getLabel()+" "+percentInstance.format((float)topFive.get(4).getTimeLong()/ finalTotalTime));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pie_chart1.setData(pieInfoList);
|
|
|
|
pie_chart1.setData(pieInfoList);
|
|
|
@ -227,12 +228,12 @@ public class today extends Fragment{
|
|
|
|
pie_chart1.invalidate();
|
|
|
|
pie_chart1.invalidate();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
btn6.setOnClickListener(v -> {
|
|
|
|
btn6.setOnClickListener(v -> {
|
|
|
|
if (pieInfoList.get(5).selected) {
|
|
|
|
if (pieInfoList.get(5).isSelected()) {
|
|
|
|
pieInfoList.get(5).selected = false;
|
|
|
|
pieInfoList.get(5).setSelected(false);
|
|
|
|
btn6.setText("其他 "+getTimeFromInt((finalTotalTime-topFive.get(0).getTimeLong()-topFive.get(1).getTimeLong()-topFive.get(2).getTimeLong()-
|
|
|
|
btn6.setText("其他 "+getTimeFromInt((finalTotalTime-topFive.get(0).getTimeLong()-topFive.get(1).getTimeLong()-topFive.get(2).getTimeLong()-
|
|
|
|
topFive.get(3).getTimeLong()-topFive.get(4).getTimeLong())));
|
|
|
|
topFive.get(3).getTimeLong()-topFive.get(4).getTimeLong())));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
pieInfoList.get(5).selected = true;
|
|
|
|
pieInfoList.get(5).setSelected(true);
|
|
|
|
btn6.setText("其他 "+percentInstance.format((float)(finalTotalTime-topFive.get(0).getTimeLong()-topFive.get(1).getTimeLong()-topFive.get(2).getTimeLong()-
|
|
|
|
btn6.setText("其他 "+percentInstance.format((float)(finalTotalTime-topFive.get(0).getTimeLong()-topFive.get(1).getTimeLong()-topFive.get(2).getTimeLong()-
|
|
|
|
topFive.get(3).getTimeLong()-topFive.get(4).getTimeLong())/finalTotalTime));
|
|
|
|
topFive.get(3).getTimeLong()-topFive.get(4).getTimeLong())/finalTotalTime));
|
|
|
|
}
|
|
|
|
}
|
|
|
|