├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── scopes │ └── scope_settings.xml └── vcs.xml ├── FlightsData.iml ├── README.md ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── shivam │ │ └── flights │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── data.js │ ├── java │ └── com │ │ └── example │ │ └── shivam │ │ └── flights │ │ ├── FareSortedActivity.java │ │ ├── FareSorter.java │ │ ├── LandSorter.java │ │ ├── LandingSortedActivity.java │ │ ├── MainActivity.java │ │ ├── TakeOffSorter.java │ │ └── TakeoffSortedActivity.java │ └── res │ ├── drawable-hdpi │ ├── ic_access_time_black_18dp.png │ ├── ic_access_time_white_18dp.png │ ├── ic_filter_list_black_24dp.png │ ├── ic_keyboard_arrow_down_white_18dp.png │ ├── ic_keyboard_arrow_up_white_18dp.png │ ├── ic_payment_black_18dp.png │ └── ic_payment_white_18dp.png │ ├── drawable-mdpi │ ├── ic_access_time_black_18dp.png │ ├── ic_access_time_white_18dp.png │ ├── ic_filter_list_black_24dp.png │ ├── ic_keyboard_arrow_down_white_18dp.png │ ├── ic_keyboard_arrow_up_white_18dp.png │ ├── ic_payment_black_18dp.png │ └── ic_payment_white_18dp.png │ ├── drawable-xhdpi │ ├── ic_access_time_black_18dp.png │ ├── ic_access_time_white_18dp.png │ ├── ic_filter_list_black_24dp.png │ ├── ic_keyboard_arrow_down_white_18dp.png │ ├── ic_keyboard_arrow_up_white_18dp.png │ ├── ic_payment_black_18dp.png │ └── ic_payment_white_18dp.png │ ├── drawable-xxhdpi │ ├── ic_access_time_black_18dp.png │ ├── ic_access_time_white_18dp.png │ ├── ic_filter_list_black_24dp.png │ ├── ic_keyboard_arrow_down_white_18dp.png │ ├── ic_keyboard_arrow_up_white_18dp.png │ ├── ic_payment_black_18dp.png │ └── ic_payment_white_18dp.png │ ├── drawable-xxxhdpi │ ├── ic_access_time_black_18dp.png │ ├── ic_access_time_white_18dp.png │ ├── ic_filter_list_black_24dp.png │ ├── ic_keyboard_arrow_down_white_18dp.png │ ├── ic_keyboard_arrow_up_white_18dp.png │ ├── ic_payment_black_18dp.png │ └── ic_payment_white_18dp.png │ ├── drawable │ ├── back3.jpg │ └── fab_label_background.xml │ ├── layout │ ├── activity_fare_sorted.xml │ ├── activity_landing_sorted.xml │ ├── activity_main.xml │ └── activity_takeoff_sorted.xml │ ├── menu │ ├── menu_fare_sorted.xml │ ├── menu_landing_sorted.xml │ ├── menu_main.xml │ └── menu_time_sorted.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-v21 │ └── styles.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── color.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | Ixigo -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /FlightsData.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android Flight Listings Demo App 2 | Demo application for JSON Parsing, Sorting and Material Design 3 | 4 | This application parses a given JSON file with flight listings and presents them asynchronously in a card-list format adhering to the Material Design guidelines. 5 | Filters are also added to the list to allow for sorting based on flight time and airfare. 6 | 7 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 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 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 21 5 | buildToolsVersion "21.1.2" 6 | 7 | defaultConfig { 8 | applicationId "com.example.shivam.ixigo" 9 | minSdkVersion 14 10 | targetSdkVersion 21 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | compile 'com.android.support:appcompat-v7:21.0.3' 25 | compile 'com.github.dexafree:materiallist:2.4.0' 26 | compile 'com.getbase:floatingactionbutton:1.5.1' 27 | } 28 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/Shivam/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/shivam/flights/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.example.shivam.flights; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 24 | 28 | 29 | 33 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /app/src/main/assets/data.js: -------------------------------------------------------------------------------- 1 | { 2 | "airlineMap" : { 3 | "SJ" : "Spicejet", 4 | "AI" : "Air India", 5 | "G8" : "Go Air", 6 | "JA" : "Jet Airways", 7 | "IN" : "Indigo" 8 | }, 9 | 10 | "airportMap" : { 11 | "DEL" : "New Delhi", 12 | "MUM" : "Mumbai" 13 | }, 14 | 15 | 16 | "flightsData": [ 17 | { 18 | "originCode": "DEL", 19 | "destinationCode": "MUM", 20 | "takeoffTime": "1396614600000", 21 | "landingTime": "1396625400000", 22 | "price": "11500", 23 | "airlineCode": "G8", 24 | "class": "Business" 25 | }, 26 | { 27 | "originCode" : "DEL", 28 | "destinationCode" : "MUM", 29 | "takeoffTime" : "1396616400000", 30 | "landingTime" : "1396623600000", 31 | "price" : "14400", 32 | "airlineCode" : "AI", 33 | "class" : "Business" 34 | }, 35 | { 36 | "originCode" : "DEL", 37 | "destinationCode" : "MUM", 38 | "takeoffTime" : "1396618200000", 39 | "landingTime" : "1396629000000", 40 | "price" : "12300", 41 | "airlineCode" : "JA", 42 | "class" : "Business" 43 | }, 44 | 45 | { 46 | "originCode" : "DEL", 47 | "destinationCode" : "MUM", 48 | "takeoffTime" : "1396620000000", 49 | "landingTime" : "1396627200000", 50 | "price" : "15200", 51 | "airlineCode" : "SJ", 52 | "class" : "Business" 53 | }, 54 | 55 | { 56 | "originCode" : "DEL", 57 | "destinationCode" : "MUM", 58 | "takeoffTime" : "1396621800000", 59 | "landingTime" : "1396632600000", 60 | "price" : "16700", 61 | "airlineCode" : "IN", 62 | "class" : "Business" 63 | }, 64 | 65 | { 66 | "originCode" : "DEL", 67 | "destinationCode" : "MUM", 68 | "takeoffTime" : "1396596600000", 69 | "landingTime" : "1396607400000", 70 | "price" : "5500", 71 | "airlineCode" : "G8", 72 | "class" : "Economy" 73 | }, 74 | { 75 | "originCode" : "DEL", 76 | "destinationCode" : "MUM", 77 | "takeoffTime" : "1396598400000", 78 | "landingTime" : "1396605600000", 79 | "price" : "4400", 80 | "airlineCode" : "AI", 81 | "class" : "Economy" 82 | }, 83 | { 84 | "originCode" : "DEL", 85 | "destinationCode" : "MUM", 86 | "takeoffTime" : "1396600200000", 87 | "landingTime" : "1396611000000", 88 | "price" : "4600", 89 | "airlineCode" : "JA", 90 | "class" : "Economy" 91 | }, 92 | { 93 | "originCode" : "DEL", 94 | "destinationCode" : "MUM", 95 | "takeoffTime" : "1396602000000", 96 | "landingTime" : "1396609200000", 97 | "price" : "7800", 98 | "airlineCode" : "SJ", 99 | "class" : "Economy" 100 | }, 101 | { 102 | "originCode" : "DEL", 103 | "destinationCode" : "MUM", 104 | "takeoffTime" : "1396603800000", 105 | "landingTime" : "1396614600000", 106 | "price" : "8700", 107 | "airlineCode" : "IN", 108 | "class" : "Economy" 109 | }, 110 | { 111 | "originCode" : "DEL", 112 | "destinationCode" : "MUM", 113 | "takeoffTime" : "1396605600000", 114 | "landingTime" : "1396612800000", 115 | "price" : "5000", 116 | "airlineCode" : "G8", 117 | "class" : "Economy" 118 | }, 119 | { 120 | "originCode" : "DEL", 121 | "destinationCode" : "MUM", 122 | "takeoffTime" : "1396607400000", 123 | "landingTime" : "1396618200000", 124 | "price" : "9800", 125 | "airlineCode" : "AI", 126 | "class" : "Economy" 127 | }, 128 | { 129 | "originCode" : "DEL", 130 | "destinationCode" : "MUM", 131 | "takeoffTime" : "1396609200000", 132 | "landingTime" : "1396616400000", 133 | "price" : "4100", 134 | "airlineCode" : "JA", 135 | "class" : "Economy" 136 | }, 137 | { 138 | "originCode" : "DEL", 139 | "destinationCode" : "MUM", 140 | "takeoffTime" : "1396611000000", 141 | "landingTime" : "1396621800000", 142 | "price" : "4600", 143 | "airlineCode" : "SJ", 144 | "class" : "Economy" 145 | }, 146 | { 147 | "originCode" : "DEL", 148 | "destinationCode" : "MUM", 149 | "takeoffTime" : "1396612800000", 150 | "landingTime" : "1396620000000", 151 | "price" : "5700", 152 | "airlineCode" : "IN", 153 | "class" : "Economy" 154 | } 155 | ] 156 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/shivam/flights/FareSortedActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.shivam.flights; 2 | 3 | import android.app.ProgressDialog; 4 | import android.content.res.Resources; 5 | import android.graphics.drawable.Drawable; 6 | import android.os.AsyncTask; 7 | import android.support.v7.app.ActionBar; 8 | import android.support.v7.app.ActionBarActivity; 9 | import android.os.Bundle; 10 | import android.view.Menu; 11 | import android.view.MenuItem; 12 | import android.widget.Toast; 13 | 14 | import com.dexafree.materialList.cards.BigImageButtonsCard; 15 | import com.dexafree.materialList.controller.OnDismissCallback; 16 | import com.dexafree.materialList.model.Card; 17 | import com.dexafree.materialList.view.MaterialListView; 18 | 19 | import org.json.JSONArray; 20 | import org.json.JSONException; 21 | import org.json.JSONObject; 22 | 23 | import java.io.IOException; 24 | import java.io.InputStream; 25 | import java.util.ArrayList; 26 | import java.util.Collections; 27 | import java.util.List; 28 | 29 | 30 | /*This activity contains a list of flights sorted in increasing order of their airfare*/ 31 | public class FareSortedActivity extends ActionBarActivity { 32 | 33 | MaterialListView fareCardList; 34 | JSONArray mJSONArr,mSortedJSONArr; 35 | JSONObject JSONobj,ob,airlineMapob,airportMapob; 36 | @Override 37 | protected void onCreate(Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | setContentView(R.layout.activity_fare_sorted); 40 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 41 | ActionBar ab=getSupportActionBar(); 42 | Resources r=getResources(); 43 | Drawable d=r.getDrawable(R.color.royalBlue); 44 | ab.setBackgroundDrawable(d); 45 | fareCardList = (MaterialListView)findViewById(R.id.fareCardList); 46 | fareCardList.setOnDismissCallback(new OnDismissCallback() { 47 | @Override 48 | public void onDismiss(Card card, int i) { 49 | 50 | } 51 | }); 52 | new JSONTask().execute(); 53 | } 54 | 55 | public class JSONTask extends AsyncTask { 56 | private ProgressDialog pDialog; 57 | 58 | @Override 59 | protected void onPreExecute() { 60 | super.onPreExecute(); 61 | pDialog = new ProgressDialog(FareSortedActivity.this); 62 | pDialog.setMessage("Getting Data ..."); 63 | pDialog.setIndeterminate(false); 64 | pDialog.setCancelable(true); 65 | pDialog.show(); 66 | } 67 | 68 | @Override 69 | protected JSONObject doInBackground(String... params) { 70 | try { 71 | JSONobj = new JSONObject(loadJSONFromAsset()); 72 | } catch (JSONException e) { 73 | e.printStackTrace(); 74 | } 75 | return JSONobj; 76 | } 77 | 78 | @Override 79 | protected void onPostExecute(JSONObject jsonObject) { 80 | try { 81 | mJSONArr = JSONobj.getJSONArray("flightsData"); 82 | mSortedJSONArr = getSortedList(mJSONArr); 83 | airlineMapob = JSONobj.getJSONObject("airlineMap"); 84 | airportMapob = JSONobj.getJSONObject("airportMap"); 85 | for(int i=0;i list = new ArrayList(); 149 | for (int i = 0; i < array.length(); i++) { 150 | list.add(array.getJSONObject(i)); 151 | } 152 | Collections.sort(list, new FareSorter()); 153 | 154 | JSONArray resultArray = new JSONArray(list); 155 | 156 | return resultArray; 157 | 158 | } 159 | 160 | 161 | @Override 162 | public boolean onCreateOptionsMenu(Menu menu) { 163 | getMenuInflater().inflate(R.menu.menu_fare_sorted, menu); 164 | return true; 165 | } 166 | 167 | public String loadJSONFromAsset() { 168 | String json = null; 169 | try { 170 | 171 | InputStream is = getAssets().open("data.js"); 172 | int size = is.available(); 173 | byte[] buffer = new byte[size]; 174 | is.read(buffer); 175 | is.close(); 176 | json = new String(buffer, "UTF-8"); 177 | } catch (IOException ex) { 178 | ex.printStackTrace(); 179 | return null; 180 | } 181 | return json; 182 | 183 | } 184 | 185 | 186 | @Override 187 | public boolean onOptionsItemSelected(MenuItem item) { 188 | int id = item.getItemId(); 189 | if (id == R.id.action_settings) { 190 | Toast.makeText(FareSortedActivity.this,"This doesn't do anything at the moment",Toast.LENGTH_SHORT).show(); 191 | return true; 192 | } 193 | 194 | return super.onOptionsItemSelected(item); 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/shivam/flights/FareSorter.java: -------------------------------------------------------------------------------- 1 | package com.example.shivam.flights; 2 | 3 | import org.json.JSONException; 4 | import org.json.JSONObject; 5 | 6 | import java.util.Comparator; 7 | 8 | /** 9 | * Created by Shivam on 08/04/15 at 1:25 PM. 10 | */ 11 | public class FareSorter implements Comparator { 12 | 13 | @Override 14 | public int compare(JSONObject lhs, JSONObject rhs) { 15 | try { 16 | return lhs.getInt("price") > rhs.getInt("price") ? 1 : (lhs 17 | .getInt("price") < rhs.getInt("price") ? -1 : 0); 18 | } catch (JSONException e) { 19 | e.printStackTrace(); 20 | } 21 | return 0; 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/shivam/flights/LandSorter.java: -------------------------------------------------------------------------------- 1 | package com.example.shivam.flights; 2 | 3 | import org.json.JSONException; 4 | import org.json.JSONObject; 5 | 6 | import java.util.Comparator; 7 | 8 | /** 9 | * Created by Shivam on 08/04/15 at 1:25 PM. 10 | */ 11 | public class LandSorter implements Comparator { 12 | 13 | @Override 14 | public int compare(JSONObject lhs, JSONObject rhs) { 15 | try { 16 | return lhs.getLong("landingTime") > rhs.getLong("landingTime") ? 1 : (lhs 17 | .getLong("landingTime") < rhs.getLong("landingTime") ? -1 : 0); 18 | } catch (JSONException e) { 19 | e.printStackTrace(); 20 | } 21 | return 0; 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/shivam/flights/LandingSortedActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.shivam.flights; 2 | 3 | import android.app.ProgressDialog; 4 | import android.content.res.Resources; 5 | import android.graphics.drawable.Drawable; 6 | import android.os.AsyncTask; 7 | import android.support.v7.app.ActionBar; 8 | import android.support.v7.app.ActionBarActivity; 9 | import android.os.Bundle; 10 | import android.view.Menu; 11 | import android.view.MenuItem; 12 | import android.widget.Toast; 13 | 14 | import com.dexafree.materialList.cards.BigImageButtonsCard; 15 | import com.dexafree.materialList.view.MaterialListView; 16 | 17 | import org.json.JSONArray; 18 | import org.json.JSONException; 19 | import org.json.JSONObject; 20 | 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | import java.util.ArrayList; 24 | import java.util.Collections; 25 | import java.util.List; 26 | 27 | 28 | /*This activity contains a list of flights sorted from earliest landing time to last*/ 29 | public class LandingSortedActivity extends ActionBarActivity { 30 | 31 | MaterialListView takeOffCardList; 32 | JSONArray mJSONArr,mSortedJSONArr; 33 | JSONObject JSONobj,ob,airlineMapob,airportMapob; 34 | @Override 35 | protected void onCreate(Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | setContentView(R.layout.activity_takeoff_sorted); 38 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 39 | ActionBar ab=getSupportActionBar(); 40 | Resources r=getResources(); 41 | Drawable d=r.getDrawable(R.color.royalBlue); 42 | ab.setBackgroundDrawable(d); 43 | takeOffCardList = (MaterialListView)findViewById(R.id.timeCardList1); 44 | new JSONTask().execute(); 45 | } 46 | 47 | public class JSONTask extends AsyncTask { 48 | private ProgressDialog pDialog; 49 | 50 | @Override 51 | protected void onPreExecute() { 52 | super.onPreExecute(); 53 | pDialog = new ProgressDialog(LandingSortedActivity.this); 54 | pDialog.setMessage("Getting Data ..."); 55 | pDialog.setIndeterminate(false); 56 | pDialog.setCancelable(true); 57 | pDialog.show(); 58 | } 59 | 60 | @Override 61 | protected JSONObject doInBackground(String... params) { 62 | try { 63 | JSONobj = new JSONObject(loadJSONFromAsset()); 64 | } catch (JSONException e) { 65 | e.printStackTrace(); 66 | } 67 | return JSONobj; 68 | } 69 | 70 | @Override 71 | protected void onPostExecute(JSONObject jsonObject) { 72 | try { 73 | mJSONArr = JSONobj.getJSONArray("flightsData"); 74 | mSortedJSONArr = getSortedList(mJSONArr); 75 | airlineMapob = JSONobj.getJSONObject("airlineMap"); 76 | airportMapob = JSONobj.getJSONObject("airportMap"); 77 | for(int i=0;i list = new ArrayList(); 140 | for (int i = 0; i < array.length(); i++) { 141 | list.add(array.getJSONObject(i)); 142 | } 143 | Collections.sort(list, new LandSorter()); 144 | 145 | JSONArray resultArray = new JSONArray(list); 146 | 147 | return resultArray; 148 | 149 | } 150 | 151 | public String loadJSONFromAsset() { 152 | String json = null; 153 | try { 154 | 155 | InputStream is = getAssets().open("data.js"); 156 | int size = is.available(); 157 | byte[] buffer = new byte[size]; 158 | is.read(buffer); 159 | is.close(); 160 | json = new String(buffer, "UTF-8"); 161 | } catch (IOException ex) { 162 | ex.printStackTrace(); 163 | return null; 164 | } 165 | return json; 166 | 167 | } 168 | 169 | 170 | 171 | 172 | @Override 173 | public boolean onCreateOptionsMenu(Menu menu) { 174 | getMenuInflater().inflate(R.menu.menu_time_sorted, menu); 175 | return true; 176 | } 177 | 178 | @Override 179 | public boolean onOptionsItemSelected(MenuItem item) { 180 | int id = item.getItemId(); 181 | if (id == R.id.action_settings) { 182 | Toast.makeText(LandingSortedActivity.this, "This doesn't do anything at the moment", Toast.LENGTH_SHORT).show(); 183 | return true; 184 | } 185 | 186 | return super.onOptionsItemSelected(item); 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/shivam/flights/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.shivam.flights; 2 | 3 | import android.app.ProgressDialog; 4 | import android.content.Intent; 5 | import android.content.res.Resources; 6 | import android.graphics.drawable.Drawable; 7 | import android.os.AsyncTask; 8 | import android.support.v7.app.ActionBar; 9 | import android.support.v7.app.ActionBarActivity; 10 | import android.os.Bundle; 11 | import android.view.Menu; 12 | import android.view.MenuItem; 13 | import android.view.View; 14 | import android.widget.Toast; 15 | 16 | import com.dexafree.materialList.cards.BigImageButtonsCard; 17 | import com.dexafree.materialList.cards.OnButtonPressListener; 18 | import com.dexafree.materialList.controller.OnDismissCallback; 19 | import com.dexafree.materialList.model.Card; 20 | import com.dexafree.materialList.view.MaterialListView; 21 | import com.getbase.floatingactionbutton.FloatingActionButton; 22 | import com.getbase.floatingactionbutton.FloatingActionsMenu; 23 | 24 | import org.json.JSONArray; 25 | import org.json.JSONException; 26 | import org.json.JSONObject; 27 | 28 | import java.io.IOException; 29 | import java.io.InputStream; 30 | 31 | 32 | public class MainActivity extends ActionBarActivity { 33 | 34 | JSONArray mJSONArr; 35 | JSONObject JSONobj,ob,airlineMapob,airportMapob; 36 | FloatingActionsMenu menu; 37 | MaterialListView cardList; 38 | @Override 39 | protected void onCreate(Bundle savedInstanceState) { 40 | super.onCreate(savedInstanceState); 41 | setContentView(R.layout.activity_main); 42 | cardList = (MaterialListView)findViewById(R.id.cardList); 43 | cardList.getLayoutManager().offsetChildrenVertical(30); 44 | menu = (FloatingActionsMenu)findViewById(R.id.fab1); 45 | /* 46 | To set the ActionBar color for API<21 47 | For API 21, see values-v21/styles.xml 48 | */ 49 | ActionBar ab=getSupportActionBar(); 50 | Resources r=getResources(); 51 | Drawable d=r.getDrawable(R.color.royalBlue); 52 | ab.setBackgroundDrawable(d); 53 | 54 | new JSONTask().execute(); 55 | FloatingActionButton fare = (FloatingActionButton)findViewById(R.id.sortFare); 56 | fare.setOnClickListener(new View.OnClickListener() { 57 | @Override 58 | public void onClick(View v) { 59 | menu.collapse(); 60 | Intent i = new Intent(MainActivity.this,FareSortedActivity.class); 61 | startActivity(i); 62 | } 63 | }); 64 | FloatingActionButton time = (FloatingActionButton)findViewById(R.id.sortTime); 65 | time.setOnClickListener(new View.OnClickListener() { 66 | @Override 67 | public void onClick(View v) { 68 | menu.collapse(); 69 | Intent i = new Intent(MainActivity.this, TakeoffSortedActivity.class); 70 | startActivity(i); 71 | } 72 | }); 73 | FloatingActionButton time2 = (FloatingActionButton)findViewById(R.id.sortTime2); 74 | time2.setOnClickListener(new View.OnClickListener() { 75 | @Override 76 | public void onClick(View v) { 77 | menu.collapse(); 78 | Intent i = new Intent(MainActivity.this,LandingSortedActivity.class); 79 | startActivity(i); 80 | } 81 | }); 82 | cardList.setOnDismissCallback(new OnDismissCallback() { 83 | @Override 84 | public void onDismiss(Card card, int i) { 85 | //Toast.makeText(MainActivity.this,) 86 | } 87 | }); 88 | } 89 | 90 | 91 | 92 | /* 93 | Loads the JSON and adds list items on a background thread 94 | Displays a progress dialog while loading and shows the result once done 95 | */ 96 | public class JSONTask extends AsyncTask { 97 | private ProgressDialog pDialog; 98 | 99 | @Override 100 | protected void onPreExecute() { 101 | super.onPreExecute(); 102 | pDialog = new ProgressDialog(MainActivity.this); 103 | pDialog.setMessage("Getting Data ..."); 104 | pDialog.setIndeterminate(false); 105 | pDialog.setCancelable(true); 106 | pDialog.show(); 107 | } 108 | 109 | @Override 110 | protected JSONObject doInBackground(String... params) { 111 | try { 112 | JSONobj = new JSONObject(loadJSONFromAsset()); 113 | } catch (JSONException e) { 114 | e.printStackTrace(); 115 | } 116 | return JSONobj; 117 | } 118 | 119 | @Override 120 | protected void onPostExecute(JSONObject jsonObject) { 121 | try { 122 | mJSONArr = JSONobj.getJSONArray("flightsData"); 123 | airlineMapob = JSONobj.getJSONObject("airlineMap"); 124 | airportMapob = JSONobj.getJSONObject("airportMap"); 125 | for(int i=0;i { 14 | 15 | @Override 16 | public int compare(JSONObject lhs, JSONObject rhs) { 17 | try { 18 | return lhs.getDouble("takeoffTime") > rhs.getDouble("takeoffTime") ? 1 : (lhs 19 | .getDouble("takeoffTime") < rhs.getDouble("takeoffTime") ? -1 : 0); 20 | } catch (JSONException e) { 21 | e.printStackTrace(); 22 | } 23 | return 0; 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/shivam/flights/TakeoffSortedActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.shivam.flights; 2 | 3 | import android.app.ProgressDialog; 4 | import android.content.res.Resources; 5 | import android.graphics.drawable.Drawable; 6 | import android.os.AsyncTask; 7 | import android.support.v7.app.ActionBar; 8 | import android.support.v7.app.ActionBarActivity; 9 | import android.os.Bundle; 10 | import android.view.Menu; 11 | import android.view.MenuItem; 12 | import android.widget.Toast; 13 | 14 | import com.dexafree.materialList.cards.BigImageButtonsCard; 15 | import com.dexafree.materialList.view.MaterialListView; 16 | 17 | import org.json.JSONArray; 18 | import org.json.JSONException; 19 | import org.json.JSONObject; 20 | 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | import java.util.ArrayList; 24 | import java.util.Collections; 25 | import java.util.List; 26 | 27 | /*This activity contains a list of flights sorted from earliest takeoff time to last*/ 28 | public class TakeoffSortedActivity extends ActionBarActivity { 29 | 30 | MaterialListView takeOffCardList; 31 | JSONArray mJSONArr,mSortedJSONArr; 32 | JSONObject JSONobj,ob,airlineMapob,airportMapob; 33 | @Override 34 | protected void onCreate(Bundle savedInstanceState) { 35 | super.onCreate(savedInstanceState); 36 | setContentView(R.layout.activity_takeoff_sorted); 37 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 38 | ActionBar ab=getSupportActionBar(); 39 | Resources r=getResources(); 40 | Drawable d=r.getDrawable(R.color.royalBlue); 41 | ab.setBackgroundDrawable(d); 42 | takeOffCardList = (MaterialListView)findViewById(R.id.timeCardList1); 43 | new JSONTask().execute(); 44 | } 45 | public class JSONTask extends AsyncTask { 46 | private ProgressDialog pDialog; 47 | 48 | @Override 49 | protected void onPreExecute() { 50 | super.onPreExecute(); 51 | pDialog = new ProgressDialog(TakeoffSortedActivity.this); 52 | pDialog.setMessage("Getting Data ..."); 53 | pDialog.setIndeterminate(false); 54 | pDialog.setCancelable(true); 55 | pDialog.show(); 56 | } 57 | 58 | @Override 59 | protected JSONObject doInBackground(String... params) { 60 | try { 61 | JSONobj = new JSONObject(loadJSONFromAsset()); 62 | } catch (JSONException e) { 63 | e.printStackTrace(); 64 | } 65 | return JSONobj; 66 | } 67 | 68 | @Override 69 | protected void onPostExecute(JSONObject jsonObject) { 70 | try { 71 | mJSONArr = JSONobj.getJSONArray("flightsData"); 72 | mSortedJSONArr = getSortedList(mJSONArr); 73 | airlineMapob = JSONobj.getJSONObject("airlineMap"); 74 | airportMapob = JSONobj.getJSONObject("airportMap"); 75 | for(int i=0;i list = new ArrayList(); 139 | for (int i = 0; i < array.length(); i++) { 140 | list.add(array.getJSONObject(i)); 141 | } 142 | Collections.sort(list, new TakeOffSorter()); 143 | 144 | JSONArray resultArray = new JSONArray(list); 145 | 146 | return resultArray; 147 | 148 | } 149 | 150 | public String loadJSONFromAsset() { 151 | String json = null; 152 | try { 153 | 154 | InputStream is = getAssets().open("data.js"); 155 | int size = is.available(); 156 | byte[] buffer = new byte[size]; 157 | is.read(buffer); 158 | is.close(); 159 | json = new String(buffer, "UTF-8"); 160 | } catch (IOException ex) { 161 | ex.printStackTrace(); 162 | return null; 163 | } 164 | return json; 165 | 166 | } 167 | 168 | @Override 169 | public boolean onCreateOptionsMenu(Menu menu) { 170 | getMenuInflater().inflate(R.menu.menu_time_sorted, menu); 171 | return true; 172 | } 173 | 174 | @Override 175 | public boolean onOptionsItemSelected(MenuItem item) { 176 | int id = item.getItemId(); 177 | if (id == R.id.action_settings) { 178 | Toast.makeText(TakeoffSortedActivity.this, "This doesn't do anything at the moment", Toast.LENGTH_SHORT).show(); 179 | return true; 180 | } 181 | return super.onOptionsItemSelected(item); 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_access_time_black_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-hdpi/ic_access_time_black_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_access_time_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-hdpi/ic_access_time_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_filter_list_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-hdpi/ic_filter_list_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_keyboard_arrow_down_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-hdpi/ic_keyboard_arrow_down_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_keyboard_arrow_up_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-hdpi/ic_keyboard_arrow_up_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_payment_black_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-hdpi/ic_payment_black_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_payment_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-hdpi/ic_payment_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_access_time_black_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-mdpi/ic_access_time_black_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_access_time_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-mdpi/ic_access_time_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_filter_list_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-mdpi/ic_filter_list_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_keyboard_arrow_down_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-mdpi/ic_keyboard_arrow_down_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_keyboard_arrow_up_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-mdpi/ic_keyboard_arrow_up_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_payment_black_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-mdpi/ic_payment_black_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_payment_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-mdpi/ic_payment_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_access_time_black_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xhdpi/ic_access_time_black_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_access_time_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xhdpi/ic_access_time_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_filter_list_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xhdpi/ic_filter_list_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_keyboard_arrow_down_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xhdpi/ic_keyboard_arrow_down_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_keyboard_arrow_up_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xhdpi/ic_keyboard_arrow_up_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_payment_black_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xhdpi/ic_payment_black_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_payment_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xhdpi/ic_payment_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_access_time_black_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xxhdpi/ic_access_time_black_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_access_time_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xxhdpi/ic_access_time_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_filter_list_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xxhdpi/ic_filter_list_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_down_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_down_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_up_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_up_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_payment_black_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xxhdpi/ic_payment_black_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_payment_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xxhdpi/ic_payment_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_access_time_black_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xxxhdpi/ic_access_time_black_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_access_time_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xxxhdpi/ic_access_time_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_filter_list_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xxxhdpi/ic_filter_list_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_down_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_down_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_up_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_up_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_payment_black_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xxxhdpi/ic_payment_black_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_payment_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable-xxxhdpi/ic_payment_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/back3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/drawable/back3.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/fab_label_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_fare_sorted.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_landing_sorted.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 15 | 16 | 28 | 29 | 37 | 38 | 39 | 46 | 47 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_takeoff_sorted.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_fare_sorted.xml: -------------------------------------------------------------------------------- 1 | 5 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_landing_sorted.xml: -------------------------------------------------------------------------------- 1 | 5 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_time_sorted.xml: -------------------------------------------------------------------------------- 1 | 5 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #4CAF50 5 | #388E3C 6 | #FF5252 7 | #e96767 8 | #fafafa 9 | #FFEB3B 10 | #FFF9C4 11 | #f1f1f1 12 | #e91e63 13 | #ec407a 14 | #808080 15 | #B2000000 16 | #FFC107 17 | #2196F3 18 | #1976D2 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Flights 3 | 4 | Hello world! 5 | Settings 6 | \u20B9 7 | \u20B9 8 | \u2192 9 | Flights sorted by Takeoff Time 10 | Flights sorted by Fare 11 | Flights sorted by Landing Time 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.1.0' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shivam101/Android-Flight-Listings/c1e24e474b8bccd1f6780380953cfd2b4756e382/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------