Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.61 KB | None | 0 0
  1. package cz.master.hope.Fragments;
  2.  
  3. import android.app.usage.UsageStatsManager;
  4. import android.content.Context;
  5. import android.graphics.Color;
  6. import android.os.Bundle;
  7. import android.support.v4.app.Fragment;
  8. import android.support.v4.content.ContextCompat;
  9. import android.view.LayoutInflater;
  10. import android.view.View;
  11. import android.view.ViewGroup;
  12. import android.widget.ImageButton;
  13. import android.widget.ImageView;
  14. import android.widget.TextView;
  15.  
  16. import com.github.mikephil.charting.animation.Easing;
  17. import com.github.mikephil.charting.charts.BarChart;
  18. import com.github.mikephil.charting.charts.PieChart;
  19. import com.github.mikephil.charting.components.Legend;
  20. import com.github.mikephil.charting.components.XAxis;
  21. import com.github.mikephil.charting.components.YAxis;
  22. import com.github.mikephil.charting.data.BarData;
  23. import com.github.mikephil.charting.data.BarDataSet;
  24. import com.github.mikephil.charting.data.BarEntry;
  25. import com.github.mikephil.charting.data.Entry;
  26. import com.github.mikephil.charting.data.PieData;
  27. import com.github.mikephil.charting.data.PieDataSet;
  28. import com.github.mikephil.charting.highlight.Highlight;
  29. import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
  30. import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
  31.  
  32. import org.joda.time.DateTime;
  33.  
  34. import java.text.DecimalFormat;
  35. import java.util.ArrayList;
  36. import java.util.HashMap;
  37. import java.util.List;
  38. import java.util.Map;
  39.  
  40. import cz.master.hope.AppUsageAndEvents.AppEvents;
  41. import cz.master.hope.AppUsageAndEvents.AppRunDuration;
  42. import cz.master.hope.AppUsageAndEvents.AppUsage;
  43. import cz.master.hope.R;
  44. import cz.master.hope.Utilities.ColorPalette;
  45. import cz.master.hope.Utilities.SharedPrefsAccess;
  46. import cz.master.hope.Utilities.TimeSpan;
  47.  
  48. import static cz.master.hope.Utilities.DateFormator.formatAppUsageTime;
  49. import static cz.master.hope.Utilities.DateFormator.milisToDateString;
  50.  
  51. /**
  52. * Fragment activity used for displaying users mobile activity.
  53. */
  54. public class MobileActivitiesFragment extends Fragment implements OnChartValueSelectedListener {
  55.  
  56. /* Context */
  57. Context context;
  58.  
  59. /* Constants */
  60. public final static int INIT = 0;
  61. public final static int ANIMATION_LENGTH = 1500;
  62. public final static float PIE_CHART_TEXT_SIZE = 13;
  63. public final static float PIE_CHART_HOLE_RADIUS = 65;
  64. public final static float PIE_CHART_TRANSPARENT_BORDER = 5;
  65. private static final String COLOR_PALETTE_KEY = "color_palette_item_";
  66. private static final String COLOR_PALETTE_INDEX = "color_palette_index" ;
  67. private static final String USAGE_STATS_NOT_PRESENT = "usage_stats_not_present";
  68.  
  69. /* Highlighted pie chart part */
  70. private int highlightedPiePart = INIT;
  71.  
  72. /* Shared preferences keys */
  73. public final static String SP_KEY_TIME_SPAN = "shared_preferences_key_time_span_mobile_activities";
  74.  
  75. /* Time span */
  76. TimeSpan timeSpan = TimeSpan.TODAY;
  77.  
  78. /* GUI elements */
  79. private PieChart pieChart;
  80. private BarChart barChart;
  81. private ImageView ivAppIcon;
  82. private TextView tvAppName;
  83. private TextView tvUsedTime;
  84. private TextView tvLastTimeUsed;
  85. private TextView tvTimeSpan;
  86. private ImageButton ibTimeSpanMinus;
  87. private ImageButton ibTimeSpanPlus;
  88.  
  89. /* Package name to color hash map */
  90. private List<Integer> appColorPalette;
  91.  
  92. /* Pie chart values */
  93. private ArrayList<Entry> pieChartYValues;
  94. private ArrayList<String> pieChartXValues;
  95. private PieDataSet pieDataSet;
  96. private List<AppUsage> usageStats;
  97.  
  98. /* Bar chart values */
  99. private ArrayList<BarEntry> barChartYValues;
  100. private ArrayList<String> barChartXValues;
  101. private BarDataSet barDataSet;
  102.  
  103. /**
  104. * Lifecycle of fragment.
  105. */
  106.  
  107. /**
  108. * Refresh fragment. This method is called from parent activity.
  109. */
  110. public void refresh() {
  111.  
  112. /* Refresh pie chart */
  113. updatePieChart();
  114.  
  115. /* Refresh bar chart */
  116. updateBarChart();
  117. }
  118.  
  119. /**
  120. * Required empty public constructor
  121. */
  122. public MobileActivitiesFragment() {}
  123.  
  124. @Override
  125. public void onCreate(Bundle savedInstanceState) {
  126. super.onCreate(savedInstanceState);
  127.  
  128. context = getContext();
  129.  
  130. /* Get last selected time span from shared preferences */
  131. String timeSpanString = SharedPrefsAccess.load(context, SP_KEY_TIME_SPAN);
  132. timeSpan = TimeSpan.getType(timeSpanString,context);
  133. }
  134.  
  135. @Override
  136. public void onPause() {
  137. super.onPause();
  138.  
  139. /* Store time span to shared preferences */
  140. SharedPrefsAccess.save(context, SP_KEY_TIME_SPAN, TimeSpan.getString(timeSpan, context));
  141. }
  142.  
  143. @Override
  144. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  145.  
  146. /* Inflate the layout for this fragment */
  147. View fragmentView = inflater.inflate(R.layout.mobile_activites_fragment_layout, container, false);
  148.  
  149. if (!SharedPrefsAccess.loadBool(context,USAGE_STATS_NOT_PRESENT)) {
  150.  
  151. /* Setup GUI */
  152. setupGUI(fragmentView);
  153.  
  154. /* Create bars */
  155. createPieChart();
  156. createBarChart();
  157.  
  158. /* Change time span */
  159. //timeSpanPanel();
  160. }
  161.  
  162. /* Inflate the layout for this fragment */
  163. return fragmentView;
  164. }
  165.  
  166. /**
  167. * Connect to all GUI elements.
  168. */
  169. public void setupGUI(View fragmentView) {
  170.  
  171. pieChart = (PieChart) fragmentView.findViewById(R.id.mobile_activites_fragment_pieChart);
  172. barChart = (BarChart) fragmentView.findViewById(R.id.mobile_activites_fragment_barChart);
  173. ivAppIcon = (ImageView) fragmentView.findViewById(R.id.mobile_activites_fragment_app_detail_image);
  174. tvAppName = (TextView) fragmentView.findViewById(R.id.mobile_activites_fragment_app_detail_name);
  175. tvUsedTime = (TextView) fragmentView.findViewById(R.id.mobile_activites_fragment_app_detail_time);
  176. tvLastTimeUsed = (TextView) fragmentView.findViewById(R.id.mobile_activites_fragment_app_detail_last_used);
  177. //tvTimeSpan = (TextView) fragmentView.findViewById(R.id.change_time_span_text);
  178. //ibTimeSpanMinus = (ImageButton) fragmentView.findViewById(R.id.change_time_span_minus);
  179. //ibTimeSpanPlus = (ImageButton) fragmentView.findViewById(R.id.change_time_span_plus);
  180.  
  181. /* Set up listeners */
  182. pieChart.setOnChartValueSelectedListener(this);
  183. }
  184.  
  185. /**
  186. * Pie chart.
  187. */
  188.  
  189. /**
  190. * Initialize and configure pie chart. Also set data to it.
  191. */
  192. public void createPieChart() {
  193. configurePieChart();
  194. getPieChartData();
  195. pieChartSetHighlight(highlightedPiePart);
  196. pieChartOnHighlightChange(highlightedPiePart);
  197. }
  198.  
  199. /**
  200. * Update pie chart.
  201. */
  202. public void updatePieChart() {
  203.  
  204. getPieChartData();
  205. pieChartSetHighlight(highlightedPiePart);
  206. pieChartOnHighlightChange(highlightedPiePart);
  207.  
  208. /* Run animation again */
  209. pieChart.animateY(ANIMATION_LENGTH, Easing.EasingOption.Linear);
  210. }
  211.  
  212. /**
  213. * Collect data for pie chart.
  214. */
  215. public void getPieChartData() {
  216.  
  217. /* Get app usage */
  218. usageStats = getPieChartSourceData();
  219.  
  220. pieChartYValues = new ArrayList<>();
  221. pieChartXValues = new ArrayList<>();
  222.  
  223. /* Get app usage data and percentage */
  224. float[] usagePercentage = AppUsage.countAppUsagePercentage(usageStats);
  225.  
  226. for (int i = 0; i < usagePercentage.length; i++) {
  227. pieChartYValues.add(new Entry(usagePercentage[i], i));
  228. pieChartXValues.add(AppUsage.getAppName(usageStats.get(i).getPackageName(), context));
  229. }
  230.  
  231. /* Init colors */
  232. initAppColorPalette();
  233.  
  234. /* Create dataset */
  235. pieDataSet = new PieDataSet(pieChartYValues, "");
  236. pieDataSet.setDrawValues(false);
  237. pieDataSet.setColors(appColorPalette);
  238.  
  239. pieChart.setData(new PieData(pieChartXValues, pieDataSet));
  240. }
  241.  
  242. /**
  243. * Collect data according to selected time span.
  244. */
  245. public List<AppUsage> getPieChartSourceData() {
  246.  
  247. switch (timeSpan) {
  248. case TODAY:
  249. return AppUsage.getAppUsageTodayFiltered(context);
  250. case LAST_WEEK:
  251. return AppUsage.getAppUsage(context, UsageStatsManager.INTERVAL_WEEKLY);
  252. case LAST_MONTH:
  253. return AppUsage.getAppUsage(context, UsageStatsManager.INTERVAL_MONTHLY);
  254. case LAST_YEAR:
  255. return AppUsage.getAppUsage(context, UsageStatsManager.INTERVAL_YEARLY);
  256. }
  257.  
  258. return AppUsage.getAppUsage(context, UsageStatsManager.INTERVAL_DAILY);
  259. }
  260.  
  261. /**
  262. * Configure pie chart settings.
  263. */
  264. public void configurePieChart() {
  265.  
  266. pieChart.setDrawSliceText(false);
  267. pieChart.animateY(ANIMATION_LENGTH, Easing.EasingOption.Linear);
  268. pieChart.setDrawCenterText(true);
  269. pieChart.setCenterTextSize(PIE_CHART_TEXT_SIZE);
  270. pieChart.setHoleRadius(PIE_CHART_HOLE_RADIUS);
  271. pieChart.setTransparentCircleRadius(PIE_CHART_HOLE_RADIUS + PIE_CHART_TRANSPARENT_BORDER);
  272.  
  273. /* Setup legend and description */
  274. configurePieChartLegend();
  275. pieChart.setDescription("");
  276. }
  277.  
  278. /**
  279. * Configure pie chart legend.
  280. */
  281. public void configurePieChartLegend() {
  282.  
  283. Legend legend = pieChart.getLegend();
  284.  
  285. /* Display legend */
  286. legend.setEnabled(true);
  287.  
  288. /* If enabled, the content of the legend will not clip outside the charts bounds,
  289. * but instead create a new line. Please note that this reduces performance
  290. * and is only available for legends below the chart.
  291. */
  292. legend.setWordWrapEnabled(true);
  293.  
  294. /* Center legend */
  295. legend.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
  296. }
  297.  
  298. /**
  299. * Listen to click on PieChart element.
  300. */
  301. @Override
  302. public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
  303. highlightedPiePart = e.getXIndex();
  304. pieChartOnHighlightChange(e.getXIndex());
  305. }
  306.  
  307. /**
  308. * Listen to unselected on PieChart element.
  309. */
  310. @Override
  311. public void onNothingSelected() {
  312. pieChartSetHighlight(INIT);
  313. pieChartOnHighlightChange(INIT);
  314. }
  315.  
  316. /**
  317. * Highlight pie chart element with given index.
  318. */
  319. public void pieChartSetHighlight(int index) {
  320. Highlight h = new Highlight(index, INIT);
  321. pieChart.highlightValues(new Highlight[]{h});
  322. }
  323.  
  324. /**
  325. * React to Pie chart highlight change.
  326. * - Display selected app in middle of pie chart.
  327. * - Change information in detail information bar.
  328. */
  329. public void pieChartOnHighlightChange(int index) {
  330.  
  331. setPieChartMiddleText(index);
  332. setInfoPanelData(index);
  333. }
  334.  
  335. /**
  336. * Display selected app in middle of pie chart.
  337. */
  338. public void setPieChartMiddleText(int index) {
  339.  
  340. String appName;
  341.  
  342. /* Get activity name */
  343. try {
  344. appName = pieChartXValues.get(index);
  345.  
  346. /* There is possibility pie chart is gonna change on refresh in a way that it has less
  347. items.*/
  348. } catch (IndexOutOfBoundsException e) {
  349. pieChartOnHighlightChange(INIT);
  350. return;
  351. }
  352.  
  353. /* Format percentage */
  354. DecimalFormat df = new DecimalFormat("0.0");
  355. String percentage = df.format(pieChartYValues.get(index).getVal());
  356.  
  357. /* Text color change */
  358. pieChart.setCenterTextColor(pieDataSet.getColor(index));
  359. pieChart.setCenterText(appName + " " + percentage + "%");
  360. }
  361.  
  362. /**
  363. * Set all data information about app run and display it on info panel.
  364. */
  365. public void setInfoPanelData(int index) {
  366.  
  367. /* Others have special info panel configuration */
  368. if (pieChartXValues.get(index).equals("OTHERS")) {
  369. setInfoPanelOthers();
  370. return;
  371. }
  372.  
  373. String packageName = usageStats.get(index).getPackageName();
  374. String appName = pieChartXValues.get(index);
  375. String usedTime = formatAppUsageTime(usageStats.get(index).getTotalTimeInForeground());
  376. String lastTimeUsed = milisToDateString(usageStats.get(index).getLastTimeUsed(),context);
  377.  
  378. ivAppIcon.setImageDrawable(AppUsage.getAppIcon(context, packageName));
  379. tvAppName.setText(appName);
  380. tvUsedTime.setText(usedTime);
  381. tvLastTimeUsed.setText(lastTimeUsed);
  382.  
  383. /* Change value colors */
  384. tvUsedTime.setTextColor(pieDataSet.getColor(index));
  385. tvLastTimeUsed.setTextColor(pieDataSet.getColor(index));
  386. }
  387.  
  388. /**
  389. * Set all data information about Others app run and display it on info panel.
  390. */
  391. public void setInfoPanelOthers() {
  392.  
  393. int index = usageStats.size() - 1;
  394.  
  395. String usedTime = formatAppUsageTime(usageStats.get(index).getTotalTimeInForeground());
  396. String lastTimeUsed = milisToDateString(usageStats.get(index).getLastTimeUsed(),context);
  397.  
  398. ivAppIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ideas_icon));
  399. tvAppName.setText(getString(R.string.otherApps));
  400. tvUsedTime.setText(usedTime);
  401. tvLastTimeUsed.setText(lastTimeUsed);
  402.  
  403. /* Change value colors */
  404. tvUsedTime.setTextColor(pieDataSet.getColor(index));
  405. tvLastTimeUsed.setTextColor(pieDataSet.getColor(index));
  406. }
  407.  
  408. /**
  409. * Bar chart.
  410. */
  411.  
  412. /**
  413. * Initialize and configure bar chart. Also set data to it.
  414. */
  415. public void createBarChart() {
  416. configureBarChart();
  417. getBarChartData();
  418. barChartSetViewCenter();
  419. }
  420.  
  421. /**
  422. * Update bar chart.
  423. */
  424. public void updateBarChart() {
  425.  
  426. getBarChartData();
  427. barChartSetViewCenter();
  428.  
  429. /* Run animation again */
  430. barChart.animateY(ANIMATION_LENGTH, Easing.EasingOption.Linear);
  431. }
  432.  
  433. /**
  434. * Configure bar chart settings.
  435. */
  436. public void configureBarChart() {
  437.  
  438. /* Basic settings */
  439. barChart.setPinchZoom(false);
  440. barChart.setDrawGridBackground(false);
  441. barChart.setDrawBarShadow(false);
  442. barChart.setDrawValueAboveBar(false);
  443. barChart.setDrawBorders(false);
  444.  
  445. /* Get rid of all axis lines */
  446. barChart.getAxisLeft().setDrawGridLines(false);
  447. barChart.getAxisRight().setDrawGridLines(false);
  448. barChart.getXAxis().setDrawAxisLine(false);
  449. barChart.getXAxis().setDrawGridLines(false);
  450. barChart.getAxisLeft().setDrawAxisLine(false);
  451. barChart.getAxisRight().setDrawAxisLine(false);
  452. barChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
  453.  
  454. /* Animation */
  455. barChart.animateY(ANIMATION_LENGTH, Easing.EasingOption.Linear);
  456.  
  457. /* Hide all descriptions */
  458. barChart.setDescription("");
  459. barChart.getAxisLeft().setDrawLabels(false);
  460. barChart.getAxisRight().setDrawLabels(false);
  461. barChart.getLegend().setEnabled(false);
  462.  
  463. /* Set zoom */
  464. barChart.setScaleMinima(3, 1);
  465. barChart.setDoubleTapToZoomEnabled(false);
  466.  
  467. /* No highlighting */
  468. barChart.setHighlightPerDragEnabled(false);
  469. barChart.setHighlightPerTapEnabled(true);
  470.  
  471. /* Get rid of margins */
  472. barChart.setViewPortOffsets(4f, 4f, 4f, 4f);
  473. }
  474.  
  475. /**
  476. * Collect data for bar chart.
  477. */
  478. public void getBarChartData() {
  479.  
  480. /* Init lists */
  481. barChartXValues = new ArrayList<>();
  482. barChartYValues = new ArrayList<>();
  483.  
  484. /* Dataset */
  485. createBarChartDataset();
  486.  
  487. ArrayList<IBarDataSet> dataSets = new ArrayList<>();
  488. dataSets.add(barDataSet);
  489.  
  490. BarData data = new BarData(barChartXValues, dataSets);
  491.  
  492. barChart.setData(data);
  493. barChart.invalidate();
  494. }
  495.  
  496. /**
  497. * Create bar chart item dataset.
  498. */
  499. public void createBarChartDataset() {
  500.  
  501. /* Get current time */
  502. DateTime now = new DateTime();
  503.  
  504. /* Get all events tha happened in last 24 hours */
  505. List<List<AppRunDuration>> appsRunDuration = AppEvents.getAppsRunDurationDividedByHours
  506. (usageStats,context, now.withTimeAtStartOfDay().getMillis());
  507.  
  508. /* Displaying 24 hours */
  509. for (int i = 0; i < 24; i++)
  510. barChartXValues.add(i + "h");
  511.  
  512. for (int i = 0; i < appsRunDuration.size(); i++) {
  513.  
  514. if (appsRunDuration.get(i).size() == 0) {
  515. barChartYValues.add(new BarEntry(0, i));
  516. continue;
  517. }
  518.  
  519. float[] entries = new float[appsRunDuration.get(i).size()];
  520. for (int j = 0; j < appsRunDuration.get(i).size(); j++) {
  521. entries[j] = appsRunDuration.get(i).get(j).getDuration();
  522. }
  523.  
  524. barChartYValues.add(new BarEntry(entries, i));
  525. }
  526.  
  527. /* Now we have data. We can set marker */
  528. barChart.setMarkerView(new BarChartMarkerApp(context, R.layout.bar_chart_marker, appsRunDuration));
  529.  
  530. barDataSet = new BarDataSet(barChartYValues, "");
  531. barDataSet.setColors(setCorrectColors(appsRunDuration));
  532. barDataSet.setDrawValues(false);
  533. }
  534.  
  535. /**
  536. * Focus bar chart on bar witch has the mot actual values.
  537. */
  538. public void barChartSetViewCenter() {
  539.  
  540. int index = 0;
  541.  
  542. switch (index){
  543. default:
  544. index = DateTime.now().getHourOfDay();
  545. }
  546.  
  547. barChart.centerViewToAnimated(index, 0, YAxis.AxisDependency.LEFT, ANIMATION_LENGTH);
  548. }
  549.  
  550. /**
  551. * Initialize hash map, who maps package name to color.
  552. */
  553. public void initAppColorPalette() {
  554.  
  555. appColorPalette = new ArrayList<>();
  556. int appColor,colorIndex;
  557.  
  558. /* Go through all */
  559. for (AppUsage appUsage : usageStats) {
  560.  
  561. /* Load app color */
  562. appColor = SharedPrefsAccess.loadInt(context,COLOR_PALETTE_KEY + appUsage.getPackageName());
  563.  
  564. /* Look to shared preferences */
  565. if (appColor != -1) {
  566. appColorPalette.add(appColor);
  567. } else {
  568.  
  569. /* Get index of last used color from color palette */
  570. colorIndex = SharedPrefsAccess.loadInt(context,COLOR_PALETTE_INDEX);
  571. if (colorIndex == -1) { colorIndex = 0; }
  572.  
  573. /* App package name not found in shared preferences -> create new preference */
  574. SharedPrefsAccess.save(context,COLOR_PALETTE_KEY + appUsage.getPackageName(),
  575. ColorPalette.MOBILE_ACTIVITIES[colorIndex]);
  576.  
  577. /* Add color to list */
  578. appColorPalette.add(ColorPalette.MOBILE_ACTIVITIES[colorIndex]);
  579.  
  580. /* Save new color index */
  581. SharedPrefsAccess.save(context,COLOR_PALETTE_INDEX,
  582. ((colorIndex + 1) % ColorPalette.MOBILE_ACTIVITIES.length));
  583. }
  584. }
  585. }
  586.  
  587. /**
  588. * Set color to dataset in way they correspond pieChart graph.
  589. */
  590. public List<Integer> setCorrectColors(List<List<AppRunDuration>> appsRunDuration) {
  591.  
  592. List<Integer> colors = new ArrayList<>();
  593.  
  594. /* Create mapping app -> color */
  595. Map<String,Integer> appToColor = new HashMap<>();
  596.  
  597. for (int i = 0;i < usageStats.size();i++) {
  598. appToColor.put(usageStats.get(i).getPackageName(), appColorPalette.get(i));
  599. }
  600.  
  601. for (int i = 0; i < appsRunDuration.size(); i++) {
  602.  
  603. /* Even blank bars need color */
  604. if (appsRunDuration.get(i).size() == 0) {
  605. colors.add(Color.TRANSPARENT);
  606. }
  607.  
  608. for (int j = 0; j < appsRunDuration.get(i).size(); j++) {
  609.  
  610. /* Key not find -> app is in "OTHERS" */
  611. if (!appToColor.containsKey(appsRunDuration.get(i).get(j).getPackageName())) {
  612. colors.add(appToColor.get("OTHERS"));
  613. continue;
  614. }
  615.  
  616. colors.add(appToColor.get(appsRunDuration.get(i).get(j).getPackageName()));
  617. }
  618. }
  619.  
  620. return colors;
  621. }
  622.  
  623. /**
  624. * Setup time span panel, handle clicks.
  625. */
  626. public void timeSpanPanel() {
  627.  
  628. tvTimeSpan.setText(TimeSpan.getString(timeSpan, context));
  629.  
  630. /* Handle button clicks */
  631. ibTimeSpanMinus.setOnClickListener(new View.OnClickListener() {
  632. @Override
  633. public void onClick(View v) {
  634. timeSpanMinus();
  635. }
  636. });
  637.  
  638. ibTimeSpanPlus.setOnClickListener(new View.OnClickListener() {
  639. @Override
  640. public void onClick(View v) {
  641. timeSpanPlus();
  642. }
  643. });
  644. }
  645.  
  646. /**
  647. * Change time span "-".
  648. */
  649. public void timeSpanMinus () {
  650.  
  651. /* Get new time span */
  652. timeSpan = TimeSpan.previous(timeSpan);
  653.  
  654. /* Set text */
  655. tvTimeSpan.setText(TimeSpan.getString(timeSpan,context));
  656.  
  657. updatePieChart();
  658. }
  659.  
  660. /**
  661. * Change time span "+".
  662. */
  663. public void timeSpanPlus () {
  664.  
  665. /* Get new time span */
  666. timeSpan = TimeSpan.next(timeSpan);
  667.  
  668. /* Set text */
  669. tvTimeSpan.setText(TimeSpan.getString(timeSpan,context));
  670.  
  671. updatePieChart();
  672. }
  673. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement