Skip to content

Commit

Permalink
Merge pull request #2 from slheavner/bug_#1
Browse files Browse the repository at this point in the history
fixed issue #1, started proguard configuration
  • Loading branch information
Samuel Heavner committed Dec 24, 2015
2 parents 9de7a94 + d85e313 commit 82a03b1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 42 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {
applicationId "com.slheavner.wvubus"
minSdkVersion 14
targetSdkVersion 23
versionCode 18
versionName "3.0.0"
versionCode 19
versionName "3.0.1"
}

compileOptions {
Expand All @@ -32,6 +32,7 @@ android {
buildTypes {
release {
minifyEnabled false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Expand Down
4 changes: 4 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

-dontwarn com.squareup.**
-dontwarn okio.**
#-keep public class com.slheavner.wvubus.MainActivity
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private List<Bus> readBusJson() throws IOException {
fis.read(bytes);
String json = new String(bytes);
Bus[] buses = new Gson().fromJson(json, Bus[].class);
return orderBusList(buses);
return Arrays.asList(buses);
}

/**
Expand All @@ -149,29 +149,29 @@ private List<Bus> readBusJson() throws IOException {
* @param buses bus array to order
* @return order List of buses
*/
private List<Bus> orderBusList(Bus[] buses){
List<String> busIds = Arrays.asList(getResources().getStringArray(R.array.bus_ids));
Bus[] busList = new Bus[buses.length];
for(Bus b : buses){
busList[busIds.indexOf(b.getId())] = b;
}
return Arrays.asList(busList);
}

/**
* Not sure this is needed with the new way the adapter updates are handled.
* TODO: try to remove this
* @param buses bus list to order
* @return order List of buses
*/
private List<Bus> orderBusList(List<Bus> buses){
List<String> busIds = Arrays.asList(getResources().getStringArray(R.array.bus_ids));
Bus[] busList = new Bus[buses.size()];
for(Bus b : buses){
busList[busIds.indexOf(b.getId())] = b;
}
return Arrays.asList(busList);
}
// private List<Bus> orderBusList(Bus[] buses){
// List<String> busIds = Arrays.asList(getResources().getStringArray(R.array.bus_ids));
// Bus[] busList = new Bus[buses.length];
// for(Bus b : buses){
// busList[busIds.indexOf(b.getId())] = b;
// }
// return Arrays.asList(busList);
// }
//
// /**
// * Not sure this is needed with the new way the adapter updates are handled.
// * TODO: try to remove this
// * @param buses bus list to order
// * @return order List of buses
// */
// private List<Bus> orderBusList(List<Bus> buses){
// List<String> busIds = Arrays.asList(getResources().getStringArray(R.array.bus_ids));
// Bus[] busList = new Bus[buses.size()];
// for(Bus b : buses){
// busList[busIds.indexOf(b.getId())] = b;
// }
// return Arrays.asList(busList);
// }

/**
* Installs the json at res/raw/buses.json
Expand All @@ -194,37 +194,37 @@ protected List<Bus> doInBackground(String[] params) {
Gson gson = new Gson();
String busJson = getResponseBody(url);
buses.addAll(Arrays.asList(gson.fromJson(busJson, Bus[].class)));
if(buses.size() > 0){
if(buses.size() > 0 && getContext() != null){
//probably a better place to write this, while staying async.
FileOutputStream fos = getContext()
.openFileOutput("buses.json", Context.MODE_PRIVATE);
fos.write(busJson.getBytes());
fos.close();
}else{
return null;
}
}catch (Exception e){
e.printStackTrace();
}
}
return orderBusList(buses);
return buses;
}

@Override
protected void onPostExecute(List<Bus> buses) {
super.onPostExecute(buses);
if(swipeRefreshLayout != null){
swipeRefreshLayout.setRefreshing(false);
}
if (buses.size() == 0){
Logger.debug(this, "no buses");
Toast.makeText(getActivity(), "There was a problem getting bus data.", Toast.LENGTH_SHORT).show();
}else{
Logger.debug(this, "got " + buses.size() + " buses");
if(MainActivityFragment.this.busAdapter != null){
MainActivityFragment.this.busData = buses;
busAdapter.setData(buses);
//busAdapter.notifyDataSetChanged();
if(!MainActivityFragment.this.isResumed()){
if(swipeRefreshLayout != null){
swipeRefreshLayout.setRefreshing(false);
}
if (buses.size() == 0 && getActivity() != null){
Logger.debug(this, "no buses");
Toast.makeText(getActivity(), "There was a problem getting bus data.", Toast.LENGTH_SHORT).show();
}else{
Logger.debug(this, "got " + buses.size() + " buses");
if(MainActivityFragment.this.busAdapter != null){
MainActivityFragment.this.busData = buses;
busAdapter.setData(buses);
//busAdapter.notifyDataSetChanged();
}
}
}
}
Expand Down

0 comments on commit 82a03b1

Please sign in to comment.