Skip to content

Commit

Permalink
First try to fix #73 and #75
Browse files Browse the repository at this point in the history
  • Loading branch information
pietrorampini committed Jul 6, 2014
1 parent f592a35 commit b2a8419
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
21 changes: 12 additions & 9 deletions library/src/main/java/com/rampo/updatechecker/ASyncCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ASyncCheck extends AsyncTask<String, Integer, Integer> {
private static final int MULTIPLE_APKS_PUBLISHED = 1;
private static final int NETWORK_ERROR = 2;
private static final int PACKAGE_NOT_PUBLISHED = 3;
private static final int PLAY_ERROR = 4;
private static final int STORE_ERROR = 4;

Store mStore;
Context mContext;
Expand Down Expand Up @@ -91,9 +91,9 @@ protected Integer doInBackground(String... notused) {
return PACKAGE_NOT_PUBLISHED;
}
}
if (mVersionDownloadable == null) { //If page format change
return PLAY_ERROR;
} else if (containsNumber(mVersionDownloadable)) {
if (mVersionDownloadable == null) {
return STORE_ERROR;
} else if (containsNumber(mVersionDownloadable)) {
return VERSION_DOWNLOADABLE_FOUND;
} else {
return MULTIPLE_APKS_PUBLISHED;
Expand All @@ -108,7 +108,9 @@ protected Integer doInBackground(String... notused) {
if (line.contains(AMAZON_STORE_HTML_TAGS_TO_GET_RIGHT_LINE)) { // Obtain HTML line contaning version available in Amazon App Store
String versionDownloadableWithTags = line.substring(38); // Get the String starting with version available + Other HTML tags
mVersionDownloadable = versionDownloadableWithTags.substring(0, versionDownloadableWithTags.length() - 5); // Remove useless HTML tags
return VERSION_DOWNLOADABLE_FOUND;
if (mVersionDownloadable == null) {
return STORE_ERROR;
} else return VERSION_DOWNLOADABLE_FOUND;
} else if (line.contains(AMAZON_STORE_PACKAGE_NOT_PUBLISHED_IDENTIFIER)) { // This packages has not been found in Amazon App Store
return PACKAGE_NOT_PUBLISHED;
}
Expand All @@ -125,7 +127,7 @@ protected Integer doInBackground(String... notused) {
}

/**
* Return to the Fragment to work with the versionDownloadable if the library found it.
* Return to UpdateChecker class to work with the versionDownloadable if the library found it.
*
* @param result
*/
Expand All @@ -142,9 +144,10 @@ protected void onPostExecute(Integer result) {
} else if (result == PACKAGE_NOT_PUBLISHED) {
mResultInterface.appUnpublished();
Log.e(LOG_TAG, "App unpublished");
} else if (result == PLAY_ERROR) {
Log.e(LOG_TAG, "Play page format error");
}
} else if (result == STORE_ERROR) {
mResultInterface.storeError();
Log.e(LOG_TAG, "Store page format error");
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

/**
* Returns the result of ASyncCheck to UpdateChecker.
*
* @author Pietro Rampini ([email protected])
*/
public interface ASyncCheckResult {
Expand All @@ -34,13 +35,20 @@ public interface ASyncCheckResult {
* @see <a href="https://github.com/rampo/UpdateChecker/issues/1">Issue #1</a>
*/
public void multipleApksPublished();

/**
* Can't download the store page.
*/
public void networkError();

/**
* Can't find the store page for this app.
*/
public void appUnpublished();

/**
* The check returns null for new version downloadble
*/
public void storeError();

}

0 comments on commit b2a8419

Please sign in to comment.