@@ -67,7 +67,7 @@ public static final UpdateChecker getInstance(Context ctx)
6767 * new updates when connected to the internet.
6868 * Default is false.
6969 *
70- *@param autoRun
70+ *@param autoRun - Default is false
7171 *@return UpdateChecker.class
7272 */
7373 public UpdateChecker shouldAutoRun (boolean autoRun )
@@ -84,7 +84,7 @@ public UpdateChecker shouldAutoRun(boolean autoRun)
8484 * The url where the new info of the app
8585 * will be read to.
8686 *
87- *@param updateLogsUrl
87+ *@param updateLogsUrl - The url of the json-encoded info of the new update
8888 *@return UpdateChecker.class
8989 */
9090 public UpdateChecker setUpdateLogsUrl (String updateLogsUrl )
@@ -98,7 +98,7 @@ public UpdateChecker setUpdateLogsUrl(String updateLogsUrl)
9898 * install the new app after it has been
9999 * downloaded.
100100 *
101- *@param autoInstall
101+ *@param autoInstall - Default is false
102102 *@return UpdateChecker.class
103103 */
104104 public UpdateChecker shouldAutoInstall (boolean autoInstall )
@@ -111,7 +111,7 @@ public UpdateChecker shouldAutoInstall(boolean autoInstall)
111111 * Sets an OnUpdateDetectedListener, when a new update
112112 * is detected, this listener will be triggered.
113113 *
114- *@param listener
114+ *@param listener - The listener to be triggered
115115 *@return UpdateChecker.class
116116 */
117117 public UpdateChecker setOnUpdateDetectedListener (UpdateChecker .OnUpdateDetectedListener listener )
@@ -123,7 +123,7 @@ public UpdateChecker setOnUpdateDetectedListener(UpdateChecker.OnUpdateDetectedL
123123 /*
124124 * Sets a custom json reader to suit your needs
125125 *
126- *@param jsonReader
126+ *@param jsonReader - A custom class that extends {com.cdph.app.json.JSONReader}
127127 *@return UpdateChecker.class
128128 */
129129 public <T extends JSONReader > UpdateChecker setJsonReader (T jsonReader )
@@ -153,7 +153,7 @@ public void runUpdateChecker()
153153 /*
154154 * Installs the application
155155 *
156- *@param filePath
156+ *@param filePath - The path of the apk to be installed
157157 *@return null
158158 */
159159 public void installApp (String path )
@@ -190,6 +190,7 @@ public File downloadUpdate(String url)
190190 file = down .execute (url ).get ();
191191 } catch (Exception e ) {
192192 e .printStackTrace ();
193+ Toast .makeText (ctx , String .format ("[ERROR]: %s" , e .getMessage ()), Toast .LENGTH_LONG ).show ();
193194 }
194195
195196 return file ;
@@ -229,9 +230,6 @@ protected void onPreExecute()
229230 {
230231 super .onPreExecute ();
231232
232- if (jsonReader == null )
233- jsonReader = new JSONReader ();
234-
235233 dlg = new ProgressDialog (ctx );
236234 dlg .setCancelable (false );
237235 dlg .setCanceledOnTouchOutside (false );
@@ -294,17 +292,18 @@ protected void onPostExecute(NewUpdateInfo result)
294292 if (ctx .getPackageManager ().getPackageInfo (ctx .getPackageName (), 0 ).versionCode < result .app_version )
295293 listener .onUpdateDetected (result , autoInstall );
296294 else
297- Toast .makeText (ctx , errMsg , Toast .LENGTH_LONG ).show ();
295+ Toast .makeText (ctx , String . format ( "[ERROR]: %s" , errMsg ) , Toast .LENGTH_LONG ).show ();
298296 } catch (Exception e ) {
299297 e .printStackTrace ();
300- Toast .makeText (ctx , e .getMessage (), Toast .LENGTH_LONG ).show ();
298+ Toast .makeText (ctx , String . format ( "[ERROR]: %s" , e .getMessage () ), Toast .LENGTH_LONG ).show ();
301299 }
302300 }
303301 }
304302
305303 private static final class TaskDownloadUpdate extends AsyncTask <String , Void , File >
306304 {
307305 private ProgressDialog dlg ;
306+ private String errMsg ;
308307
309308 @ Override
310309 protected void onPreExecute ()
@@ -361,6 +360,7 @@ protected File doInBackground(String[] params)
361360 }
362361 } catch (Exception e ) {
363362 e .printStackTrace ();
363+ errMsg += e .getMessage ();
364364 }
365365
366366 return file ;
@@ -373,6 +373,9 @@ protected void onPostExecute(File result)
373373
374374 if (dlg != null )
375375 dlg .dismiss ();
376+
377+ if (errMsg != null )
378+ Toast .makeText (ctx , String .format ("[ERROR]: %s" , errMsg ), Toast .LENGTH_LONG ).show ();
376379 }
377380 }
378381
0 commit comments