Skip to content

Commit 224cb0a

Browse files
author
yogeshbalan
committed
2 parents eafec41 + 2479608 commit 224cb0a

14 files changed

+651
-54
lines changed

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ dependencies {
4848
compile 'com.diogobernardino:williamchart:2.0.1'
4949
compile 'com.github.blackfizz:eazegraph:1.2.2@aar'
5050
compile 'com.nineoldandroids:library:2.4.0'
51+
compile 'com.google.maps.android:android-maps-utils:0.3+'
5152
// compile 'com.android.support:multidex:1.0.0'
5253
}

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<uses-permission android:name="xyz.airquality.permission.C2D_MESSAGE" />
3535

3636
<application
37+
android:name=".ApplicationWrapper"
3738
android:allowBackup="true"
3839
android:icon="@mipmap/ic_launcher"
3940
android:label="@string/app_name"
Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
[
2+
{
3+
"state": "Andhra Pradesh",
4+
"coords": {
5+
"lat": 15.9128998,
6+
"lng": 79.7399875
7+
},
8+
"level": "26"
9+
},
10+
{
11+
"state": "Assam",
12+
"coords": {
13+
"lat": 26.2006043,
14+
"lng": 92.9375739
15+
},
16+
"level": "60"
17+
},
18+
{
19+
"state": "Bihar",
20+
"coords": {
21+
"lat": 25.0960742,
22+
"lng": 85.31311939999999
23+
},
24+
"level": "87"
25+
},
26+
{
27+
"state": "Chandigarh",
28+
"coords": {
29+
"lat": 30.7333148,
30+
"lng": 76.7794179
31+
},
32+
"level": "52"
33+
},
34+
{
35+
"state": "Chattisgarh",
36+
"coords": {
37+
"lat": 21.2786567,
38+
"lng": 81.8661442
39+
},
40+
"level": "15"
41+
},
42+
{
43+
"state": "Dadra & Nagar Haveli",
44+
"coords": {
45+
"lat": 20.316667,
46+
"lng": 72.966667
47+
},
48+
"level": "NA"
49+
},
50+
{
51+
"state": "Daman & Diu",
52+
"coords": {
53+
"lat": 20.3973736,
54+
"lng": 72.8327991
55+
},
56+
"level": "NA"
57+
},
58+
{
59+
"state": "Delhi",
60+
"coords": {
61+
"lat": 28.6139391,
62+
"lng": 77.2090212
63+
},
64+
"level": "116"
65+
},
66+
{
67+
"state": "Goa",
68+
"coords": {
69+
"lat": 15.2993265,
70+
"lng": 74.12399599999999
71+
},
72+
"level": "49"
73+
},
74+
{
75+
"state": "Gujarat",
76+
"coords": {
77+
"lat": 22.258652,
78+
"lng": 71.1923805
79+
},
80+
"level": "20"
81+
},
82+
{
83+
"state": "Haryana",
84+
"coords": {
85+
"lat": 29.0587757,
86+
"lng": 76.085601
87+
},
88+
"level": "52"
89+
},
90+
{
91+
"state": "Himachal Pradesh",
92+
"coords": {
93+
"lat": 31.1048294,
94+
"lng": 77.17339009999999
95+
},
96+
"level": "75"
97+
},
98+
{
99+
"state": "Jammu & Kashmir",
100+
"coords": {
101+
"lat": 32.7266016,
102+
"lng": 74.8570259
103+
},
104+
"level": "41"
105+
},
106+
{
107+
"state": "Jharkhand",
108+
"coords": {
109+
"lat": 23.6101808,
110+
"lng": 85.2799354
111+
},
112+
"level": "47"
113+
},
114+
{
115+
"state": "Karnataka",
116+
"coords": {
117+
"lat": 15.3172775,
118+
"lng": 75.7138884
119+
},
120+
"level": "39"
121+
},
122+
{
123+
"state": "Kerala",
124+
"coords": {
125+
"lat": 10.8505159,
126+
"lng": 76.2710833
127+
},
128+
"level": "28"
129+
},
130+
{
131+
"state": "Madhya Pradesh",
132+
"coords": {
133+
"lat": 22.9734229,
134+
"lng": 78.6568942
135+
},
136+
"level": "37"
137+
},
138+
{
139+
"state": "Maharashtra",
140+
"coords": {
141+
"lat": 19.7514798,
142+
"lng": 75.7138884
143+
},
144+
"level": "44"
145+
},
146+
{
147+
"state": "Manipur",
148+
"coords": {
149+
"lat": 24.6637173,
150+
"lng": 93.90626879999999
151+
},
152+
"level": "NA"
153+
},
154+
{
155+
"state": "Meghalaya",
156+
"coords": {
157+
"lat": 25.4670308,
158+
"lng": 91.366216
159+
},
160+
"level": "16"
161+
},
162+
{
163+
"state": "Mizoram",
164+
"coords": {
165+
"lat": 23.164543,
166+
"lng": 92.9375739
167+
},
168+
"level": "25"
169+
},
170+
{
171+
"state": "Nagaland",
172+
"coords": {
173+
"lat": 26.1584354,
174+
"lng": 94.5624426
175+
},
176+
"level": "37"
177+
},
178+
{
179+
"state": "Orissa",
180+
"coords": {
181+
"lat": 20.9516658,
182+
"lng": 85.0985236
183+
},
184+
"level": "26"
185+
},
186+
{
187+
"state": "Punjab",
188+
"coords": {
189+
"lat": 31.1471305,
190+
"lng": 75.34121789999999
191+
},
192+
"level": "46"
193+
},
194+
{
195+
"state": "Puducherry",
196+
"coords": {
197+
"lat": 11.9138598,
198+
"lng": 79.8144722
199+
},
200+
"level": "9"
201+
},
202+
{
203+
"state": "Rajasthan",
204+
"coords": {
205+
"lat": 27.0238036,
206+
"lng": 74.21793260000001
207+
},
208+
"level": "82"
209+
},
210+
{
211+
"state": "Sikkim",
212+
"coords": {
213+
"lat": 27.5329718,
214+
"lng": 88.5122178
215+
},
216+
"level": "NA"
217+
},
218+
{
219+
"state": "Tamilnadu",
220+
"coords": {
221+
"lat": 11.1271225,
222+
"lng": 78.6568942
223+
},
224+
"level": "27"
225+
},
226+
{
227+
"state": "Uttar Pradesh",
228+
"coords": {
229+
"lat": 27.5705886,
230+
"lng": 80.0981869
231+
},
232+
"level": "55"
233+
},
234+
{
235+
"state": "Uttarakhand",
236+
"coords": {
237+
"lat": 30.066753,
238+
"lng": 79.01929969999999
239+
},
240+
"level": "76"
241+
}
242+
]

app/src/main/java/xyz/airquality/HomeFragment.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.support.v7.widget.LinearLayoutManager;
88
import android.support.v7.widget.RecyclerView;
99
import android.support.v7.widget.Toolbar;
10+
import android.util.Log;
1011
import android.view.LayoutInflater;
1112
import android.view.View;
1213
import android.view.ViewGroup;
@@ -20,6 +21,9 @@
2021
import com.google.android.gms.maps.SupportMapFragment;
2122
import com.google.android.gms.maps.model.LatLng;
2223
import com.google.android.gms.maps.model.MarkerOptions;
24+
import com.parse.FindCallback;
25+
import com.parse.ParseObject;
26+
import com.parse.ParseQuery;
2327

2428
import java.util.ArrayList;
2529
import java.util.List;
@@ -49,6 +53,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
4953
spinner=(Spinner)rootView.findViewById(R.id.spinner_nav);
5054
spinner.setVisibility(View.VISIBLE);
5155
final List<String> list = new ArrayList<String>();
56+
list.add("DELHI");
57+
list.add("GUJARAT");
5258
list.add("ARUNACHAL PRADESH");
5359
list.add("PUDUCHERRY");
5460
list.add("JHARKHAND");list.add("HARYANA");list.add("MANIPUR");list.add("GOA");list.add("MEGHALAYA");
@@ -63,7 +69,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
6369
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
6470
@Override
6571
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
66-
72+
String state = list.get(i).toLowerCase();
73+
String stateToMatch = state.substring(0, 1).toUpperCase() + state.substring(1);
74+
loadStationFromParse(stateToMatch);
6775
}
6876

6977
@Override
@@ -76,16 +84,31 @@ public void onNothingSelected(AdapterView<?> adapterView) {
7684
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL,false));
7785
mRecyclerView.setHasFixedSize(true);
7886

79-
stationsAdapter = new StationsAdapter(getActivity());
87+
stationsAdapter = new StationsAdapter(getActivity(), new ArrayList<ParseObject>());
8088
mRecyclerView.setAdapter(stationsAdapter);
8189

82-
addToMap("78.98,78.98","title");
83-
8490
return rootView;
8591

8692

8793
}
8894

95+
private void loadStationFromParse(String state) {
96+
97+
ParseQuery query = ParseQuery.getQuery("StateRemark");
98+
query.whereEqualTo("State", state);
99+
Log.d("lol",state);
100+
query.findInBackground(new FindCallback<ParseObject>() {
101+
@Override
102+
public void done(final List<ParseObject> objects, com.parse.ParseException e) {
103+
if (e==null) {
104+
stationsAdapter.updateDataset(objects);
105+
} else {
106+
e.printStackTrace();
107+
}
108+
}
109+
});
110+
}
111+
89112
private void addToMap(String latlong,String title){
90113
mMap = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map)).getMap();
91114

0 commit comments

Comments
 (0)