1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
| public class MainActivity extends AppCompatActivity {
public static LineChart lineChart;
public static String dataParseGet = "";
private static final String SAVE_AKTIVITY = "one other";
public static ArrayList<String> as = new ArrayList<String>();
public static TextView data, texterr;
RadioButton myRadioButton;
public ArrayList<SpinnerModel> CustomListViewValuesArr = new ArrayList<>();
fetchDataHistory f = new fetchDataHistory();
boolean b;
CustomAdapter adapter;
MainActivity activity = null;
RequestQueue requestQueue;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
activity = this;
setListData();
// Connect by id
Spinner SpinnerExample = (Spinner) findViewById(R.id.spinner);
data = (TextView) findViewById(R.id.textt);
texterr = (TextView) findViewById(R.id.texterr);
final RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radioGroup);
//forPieChar();
// For adapter spinner
Resources res = getResources();
adapter = new CustomAdapter(activity, R.layout.spinner_rows, CustomListViewValuesArr, res);
SpinnerExample.setAdapter(adapter);
requestQueue = Volley.newRequestQueue(getApplicationContext());
// get data with fetchDataHistory and lineChart connect by id
fetchDataHistory process1 = new fetchDataHistory();
process1.execute();
lineChart= (LineChart) findViewById(R.id.lineChar);
lineChart.setDragEnabled(true);
lineChart.setScaleEnabled(false);
SpinnerExample.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
int rgs_id = radioGroup.getCheckedRadioButtonId();
myRadioButton = (RadioButton) findViewById(rgs_id);
String s = myRadioButton.getText().toString();
if (s.equals("USD")) {
b = true;
} else {
b = false;
}
fetchData process = new fetchData(b, position);
process.execute();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
public void setListData() {
String coy[] = {"Bitcoin", "Ethereum", "Ripple", "Bitcoin Cash", "Cardano", "Litecoin", "NEM", "Stellar", "IOTA", "NEO", "EOS", "Dash", "Monero", "TRON", "Bitcoin Gold", "Ethereum Classic", "ICON", "Qtum", "Lisk", "RaiBlocks"};
for (int i = 0; i < coy.length; i++) {
final SpinnerModel sched = new SpinnerModel();
sched.setCompanyName(coy[i]);
;
sched.setImage("image" + i);
CustomListViewValuesArr.add(sched);
}
}
public void forPieChar(){
lineChart= (LineChart) findViewById(R.id.lineChar);
lineChart.setDragEnabled(true);
lineChart.setScaleEnabled(false);
ArrayList<Entry> yValues = new ArrayList<>();
yValues.add(new Entry(1, 73f));
yValues.add(new Entry(2, 75f));
LineDataSet set1 = new LineDataSet(yValues, "Data Set 1");
set1.setFillAlpha(110);
ArrayList<ILineDataSet> dataSets = new ArrayList<>();
dataSets.add(set1);
LineData data =new LineData(dataSets);
lineChart.setData(data);
}
} |