Skip to content

Commit

Permalink
Bugfixing: trying to prevent crash
Browse files Browse the repository at this point in the history
  • Loading branch information
pulce committed Jan 18, 2015
1 parent ed5dfdb commit cb7bdc3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.windnow"
android:versionCode="3"
android:versionName="1.1.1" >
android:versionCode="4"
android:versionName="1.1.2" >

<uses-sdk
android:minSdkVersion="8"
Expand Down
2 changes: 1 addition & 1 deletion src/com/windnow/LoadSaveOps.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static ArrayList<Station> loadStations() {
if (saveFile) {
saveStations(stations);
}
} catch (IOException e) {
} catch (Exception e) {
printErrorToLog(e);
}
return stations;
Expand Down
7 changes: 2 additions & 5 deletions src/com/windnow/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
@SuppressLint({ "InflateParams", "NewApi" })
public class MainActivity extends ActionBarActivity {

private static final String VERSIONID = "1.1.1";
private static final String VERSIONID = "1.1.2";
private static final String APPURL = "https://github.com/pulce/WindNow/releases/latest";

private StationListAdapter stAda;
Expand Down Expand Up @@ -224,10 +224,7 @@ protected Void doInBackground(Void... v) {
station.setStatus(Station.LOADED);
station.setDate(Calendar.getInstance().getTime());

if (station.getType() == Station.PIC) {
} else if (station.getType() == Station.BZ) {
station.parseCache();
} else {
if (station.getType() != Station.PIC) {
station.parseCache();
}
break;
Expand Down
11 changes: 7 additions & 4 deletions src/com/windnow/Station.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public Station(String name, String url) {
if (!url.startsWith("http")) {
this.url = "http://" + this.url;
}
if (url.contains("wetteronline") && url.contains("aktuelles-wetter"))
if (url.contains("wetteronline") && (url.contains("aktuelles-wetter") || url.contains("wetter-aktuell")))
this.type = WC;
else if (url.contains("provinz.bz.it") && url.endsWith(".asp"))
this.type = BZ;
Expand Down Expand Up @@ -207,10 +207,13 @@ public void parseCache() {
}
} catch (IOException e) {
LoadSaveOps.printErrorToLog(e);
} catch (Exception e) {
LoadSaveOps.printErrorToLog(e);
this.status = PARSE_ERROR;
}
}

private static ArrayList<String> parseWC(Document doc) {
private static ArrayList<String> parseWC(Document doc) throws Exception {
ArrayList<String> patschText = new ArrayList<String>();
Elements tableElements = doc
.select("table[class=hourly]:has(th:contains(Spitze))");
Expand Down Expand Up @@ -261,7 +264,7 @@ private static ArrayList<String> parseWC(Document doc) {
return patschText;
}

private static ArrayList<String> parseBZ(Document doc) {
private static ArrayList<String> parseBZ(Document doc) throws Exception {
ArrayList<String> patschText = new ArrayList<String>();
Elements tableElements = doc
.select("table[class=avalanches-stations]:contains(Messstationen)");
Expand Down Expand Up @@ -320,7 +323,7 @@ private static ArrayList<String> parseBZ(Document doc) {
}

// Wetterdienst.de
public static ArrayList<String> parseWD(Document doc) {
public static ArrayList<String> parseWD(Document doc) throws Exception {
ArrayList<String> patschText = new ArrayList<String>();
Elements tableElements = doc.select("table[class=weather-table]");
// Headers
Expand Down
9 changes: 4 additions & 5 deletions src/com/windnow/StationPicActivity.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.windnow;

import java.io.FileInputStream;
import java.io.IOException;

import android.support.v4.app.NavUtils;
import android.support.v7.app.ActionBarActivity;
Expand Down Expand Up @@ -73,12 +72,12 @@ protected void onCreate(Bundle savedInstanceState) {
FileInputStream is = this.openFileInput(filename);
pic = BitmapFactory.decodeStream(is);
is.close();
} catch (IOException e) {
imageDetail.setImageBitmap(pic);
} catch (Exception e) {
LoadSaveOps.printErrorToLog(e);
}
imageDetail.setImageBitmap(pic);
imageDetail.setOnTouchListener(new View.OnTouchListener() {

imageDetail.setOnTouchListener(new View.OnTouchListener() {
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {
Expand Down Expand Up @@ -123,7 +122,7 @@ public boolean onTouch(View v, MotionEvent event) {
matrix.postScale(scale, scale, midPoint.x,
midPoint.y);
matrix.postTranslate(event.getX() - startPoint.x,
event.getY() - startPoint.y); //new
event.getY() - startPoint.y); // new
}
}
break;
Expand Down

0 comments on commit cb7bdc3

Please sign in to comment.