• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 package com.xxmassdeveloper.mpchartexample.notimportant;
3 
4 import android.content.Intent;
5 import android.net.Uri;
6 import android.os.Bundle;
7 import android.view.Menu;
8 import android.view.MenuItem;
9 import android.view.View;
10 import android.view.WindowManager;
11 import android.widget.AdapterView;
12 import android.widget.AdapterView.OnItemClickListener;
13 import android.widget.ListView;
14 
15 import com.github.mikephil.charting.utils.Utils;
16 import com.xxmassdeveloper.mpchartexample.AnotherBarActivity;
17 import com.xxmassdeveloper.mpchartexample.BarChartActivity;
18 import com.xxmassdeveloper.mpchartexample.BarChartActivityMultiDataset;
19 import com.xxmassdeveloper.mpchartexample.BarChartActivitySinus;
20 import com.xxmassdeveloper.mpchartexample.BarChartPositiveNegative;
21 import com.xxmassdeveloper.mpchartexample.BubbleChartActivity;
22 import com.xxmassdeveloper.mpchartexample.CandleStickChartActivity;
23 import com.xxmassdeveloper.mpchartexample.CombinedChartActivity;
24 import com.xxmassdeveloper.mpchartexample.CubicLineChartActivity;
25 import com.xxmassdeveloper.mpchartexample.DynamicalAddingActivity;
26 import com.xxmassdeveloper.mpchartexample.FilledLineActivity;
27 import com.xxmassdeveloper.mpchartexample.HalfPieChartActivity;
28 import com.xxmassdeveloper.mpchartexample.HorizontalBarChartActivity;
29 import com.xxmassdeveloper.mpchartexample.HorizontalBarNegativeChartActivity;
30 import com.xxmassdeveloper.mpchartexample.InvertedLineChartActivity;
31 import com.xxmassdeveloper.mpchartexample.LineChartActivity1;
32 import com.xxmassdeveloper.mpchartexample.LineChartActivity2;
33 import com.xxmassdeveloper.mpchartexample.LineChartActivityColored;
34 import com.xxmassdeveloper.mpchartexample.LineChartTime;
35 import com.xxmassdeveloper.mpchartexample.ListViewBarChartActivity;
36 import com.xxmassdeveloper.mpchartexample.ListViewMultiChartActivity;
37 import com.xxmassdeveloper.mpchartexample.MultiLineChartActivity;
38 import com.xxmassdeveloper.mpchartexample.PerformanceLineChart;
39 import com.xxmassdeveloper.mpchartexample.PieChartActivity;
40 import com.xxmassdeveloper.mpchartexample.PiePolylineChartActivity;
41 import com.xxmassdeveloper.mpchartexample.R;
42 import com.xxmassdeveloper.mpchartexample.RadarChartActivity;
43 import com.xxmassdeveloper.mpchartexample.RealtimeLineChartActivity;
44 import com.xxmassdeveloper.mpchartexample.ScatterChartActivity;
45 import com.xxmassdeveloper.mpchartexample.ScrollViewActivity;
46 import com.xxmassdeveloper.mpchartexample.StackedBarActivity;
47 import com.xxmassdeveloper.mpchartexample.StackedBarActivityNegative;
48 import com.xxmassdeveloper.mpchartexample.fragments.SimpleChartDemo;
49 
50 import java.util.ArrayList;
51 
52 import androidx.appcompat.app.AppCompatActivity;
53 
54 public class MainActivity extends AppCompatActivity implements OnItemClickListener {
55 
56     @Override
onCreate(Bundle savedInstanceState)57     protected void onCreate(Bundle savedInstanceState) {
58         super.onCreate(savedInstanceState);
59         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
60                 WindowManager.LayoutParams.FLAG_FULLSCREEN);
61         setContentView(R.layout.activity_main);
62 
63         setTitle("MPAndroidChart Example");
64 
65         // initialize the utilities
66         Utils.init(this);
67 
68         ArrayList<ContentItem> objects = new ArrayList<>();
69 
70         ////
71         objects.add(0, new ContentItem("Line Charts"));
72 
73         objects.add(1, new ContentItem("Basic", "Simple line chart."));
74         objects.add(2, new ContentItem("Multiple", "Show multiple data sets."));
75         objects.add(3, new ContentItem("Dual Axis", "Line chart with dual y-axes."));
76         objects.add(4, new ContentItem("Inverted Axis", "Inverted y-axis."));
77         objects.add(5, new ContentItem("Cubic", "Line chart with a cubic line shape."));
78         objects.add(6, new ContentItem("Colorful", "Colorful line chart."));
79         objects.add(7, new ContentItem("Performance", "Render 30.000 data points smoothly."));
80         objects.add(8, new ContentItem("Filled", "Colored area between two lines."));
81 
82         ////
83         objects.add(9, new ContentItem("Bar Charts"));
84 
85         objects.add(10, new ContentItem("Basic", "Simple bar chart."));
86         objects.add(11, new ContentItem("Basic 2", "Variation of the simple bar chart."));
87         objects.add(12, new ContentItem("Multiple", "Show multiple data sets."));
88         objects.add(13, new ContentItem("Horizontal", "Render bar chart horizontally."));
89         objects.add(14, new ContentItem("Stacked", "Stacked bar chart."));
90         objects.add(15, new ContentItem("Negative", "Positive and negative values with unique colors."));
91         objects.add(16, new ContentItem("Negative Horizontal", "demonstrates how to create a HorizontalBarChart with positive and negative values."));
92         objects.add(17, new ContentItem("Stacked 2", "Stacked bar chart with negative values."));
93         objects.add(18, new ContentItem("Sine", "Sine function in bar chart format."));
94 
95         ////
96         objects.add(19, new ContentItem("Pie Charts"));
97 
98         objects.add(20, new ContentItem("Basic", "Simple pie chart."));
99         objects.add(21, new ContentItem("Value Lines", "Stylish lines drawn outward from slices."));
100         objects.add(22, new ContentItem("Half Pie", "180° (half) pie chart."));
101 
102         ////
103         objects.add(23, new ContentItem("Other Charts"));
104 
105         objects.add(24, new ContentItem("Combined Chart", "Bar and line chart together."));
106         objects.add(25, new ContentItem("Scatter Plot", "Simple scatter plot."));
107         objects.add(26, new ContentItem("Bubble Chart", "Simple bubble chart."));
108         objects.add(27, new ContentItem("Candlestick", "Simple financial chart."));
109         objects.add(28, new ContentItem("Radar Chart", "Simple web chart."));
110 
111         ////
112         objects.add(29, new ContentItem("Scrolling Charts"));
113 
114         objects.add(30, new ContentItem("Multiple", "Various types of charts as fragments."));
115         objects.add(31, new ContentItem("View Pager", "Swipe through different charts."));
116         objects.add(32, new ContentItem("Tall Bar Chart", "Bars bigger than your screen!"));
117         objects.add(33, new ContentItem("Many Bar Charts", "More bars than your screen can handle!"));
118 
119         ////
120         objects.add(34, new ContentItem("Even More Line Charts"));
121 
122         objects.add(35, new ContentItem("Dynamic", "Build a line chart by adding points and sets."));
123         objects.add(36, new ContentItem("Realtime", "Add data points in realtime."));
124         objects.add(37, new ContentItem("Hourly", "Uses the current time to add a data point for each hour."));
125         //objects.add(38, new ContentItem("Realm.io Examples", "See more examples that use Realm.io mobile database."));
126 
127         MyAdapter adapter = new MyAdapter(this, objects);
128 
129         ListView lv = findViewById(R.id.listView1);
130         lv.setAdapter(adapter);
131 
132         lv.setOnItemClickListener(this);
133     }
134 
135     @Override
onItemClick(AdapterView<?> av, View v, int pos, long arg3)136     public void onItemClick(AdapterView<?> av, View v, int pos, long arg3) {
137 
138         Intent i = null;
139 
140         switch (pos) {
141             case 1:
142                 i = new Intent(this, LineChartActivity1.class);
143                 break;
144             case 2:
145                 i = new Intent(this, MultiLineChartActivity.class);
146                 break;
147             case 3:
148                 i = new Intent(this, LineChartActivity2.class);
149                 break;
150             case 4:
151                 i = new Intent(this, InvertedLineChartActivity.class);
152                 break;
153             case 5:
154                 i = new Intent(this, CubicLineChartActivity.class);
155                 break;
156             case 6:
157                 i = new Intent(this, LineChartActivityColored.class);
158                 break;
159             case 7:
160                 i = new Intent(this, PerformanceLineChart.class);
161                 break;
162             case 8:
163                 i = new Intent(this, FilledLineActivity.class);
164                 break;
165             case 10:
166                 i = new Intent(this, BarChartActivity.class);
167                 break;
168             case 11:
169                 i = new Intent(this, AnotherBarActivity.class);
170                 break;
171             case 12:
172                 i = new Intent(this, BarChartActivityMultiDataset.class);
173                 break;
174             case 13:
175                 i = new Intent(this, HorizontalBarChartActivity.class);
176                 break;
177             case 14:
178                 i = new Intent(this, StackedBarActivity.class);
179                 break;
180             case 15:
181                 i = new Intent(this, BarChartPositiveNegative.class);
182                 break;
183             case 16:
184                 i = new Intent(this, HorizontalBarNegativeChartActivity.class);
185                 break;
186             case 17:
187                 i = new Intent(this, StackedBarActivityNegative.class);
188                 break;
189             case 18:
190                 i = new Intent(this, BarChartActivitySinus.class);
191                 break;
192             case 20:
193                 i = new Intent(this, PieChartActivity.class);
194                 break;
195             case 21:
196                 i = new Intent(this, PiePolylineChartActivity.class);
197                 break;
198             case 22:
199                 i = new Intent(this, HalfPieChartActivity.class);
200                 break;
201             case 24:
202                 i = new Intent(this, CombinedChartActivity.class);
203                 break;
204             case 25:
205                 i = new Intent(this, ScatterChartActivity.class);
206                 break;
207             case 26:
208                 i = new Intent(this, BubbleChartActivity.class);
209                 break;
210             case 27:
211                 i = new Intent(this, CandleStickChartActivity.class);
212                 break;
213             case 28:
214                 i = new Intent(this, RadarChartActivity.class);
215                 break;
216             case 30:
217                 i = new Intent(this, ListViewMultiChartActivity.class);
218                 break;
219             case 31:
220                 i = new Intent(this, SimpleChartDemo.class);
221                 break;
222             case 32:
223                 i = new Intent(this, ScrollViewActivity.class);
224                 break;
225             case 33:
226                 i = new Intent(this, ListViewBarChartActivity.class);
227                 break;
228             case 35:
229                 i = new Intent(this, DynamicalAddingActivity.class);
230                 break;
231             case 36:
232                 i = new Intent(this, RealtimeLineChartActivity.class);
233                 break;
234             case 37:
235                 i = new Intent(this, LineChartTime.class);
236                 break;
237             /*case 38:
238                 i = new Intent(this, RealmMainActivity.class);
239                 break;*/
240         }
241 
242         if (i != null) startActivity(i);
243 
244         overridePendingTransition(R.anim.move_right_in_activity, R.anim.move_left_out_activity);
245     }
246 
247     @Override
onCreateOptionsMenu(Menu menu)248     public boolean onCreateOptionsMenu(Menu menu) {
249         getMenuInflater().inflate(R.menu.main, menu);
250         return true;
251     }
252 
253     @Override
onOptionsItemSelected(MenuItem item)254     public boolean onOptionsItemSelected(MenuItem item) {
255 
256         Intent i;
257 
258         switch (item.getItemId()) {
259             case R.id.viewGithub:
260                 i = new Intent(Intent.ACTION_VIEW);
261                 i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart"));
262                 startActivity(i);
263                 break;
264             case R.id.report:
265                 i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
266                         "mailto", "philjay.librarysup@gmail.com", null));
267                 i.putExtra(Intent.EXTRA_SUBJECT, "MPAndroidChart Issue");
268                 i.putExtra(Intent.EXTRA_TEXT, "Your error report here...");
269                 startActivity(Intent.createChooser(i, "Report Problem"));
270                 break;
271             case R.id.website:
272                 i = new Intent(Intent.ACTION_VIEW);
273                 i.setData(Uri.parse("http://at.linkedin.com/in/philippjahoda"));
274                 startActivity(i);
275                 break;
276         }
277 
278         return true;
279     }
280 }
281