Issue #20 - network failure during repo update shouldn't empty the app list
This commit is contained in:
parent
6fddf13fb3
commit
4be4b8ddaa
@ -172,7 +172,7 @@ public class FDroid extends TabActivity implements OnItemClickListener {
|
||||
case SEARCH:
|
||||
onSearchRequested();
|
||||
return true;
|
||||
|
||||
|
||||
case ABOUT:
|
||||
LayoutInflater li = LayoutInflater.from(this);
|
||||
View view = li.inflate(R.layout.about, null);
|
||||
@ -363,8 +363,8 @@ public class FDroid extends TabActivity implements OnItemClickListener {
|
||||
|| netstate.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED) {
|
||||
new Thread() {
|
||||
public void run() {
|
||||
RepoXMLHandler.doUpdates(FDroid.this, db);
|
||||
update_handler.sendEmptyMessage(0);
|
||||
boolean success = RepoXMLHandler.doUpdates(FDroid.this, db);
|
||||
update_handler.sendEmptyMessage(success ? 0 : 1);
|
||||
}
|
||||
}.start();
|
||||
return true;
|
||||
@ -382,7 +382,13 @@ public class FDroid extends TabActivity implements OnItemClickListener {
|
||||
private Handler update_handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
populateLists(true);
|
||||
if (msg.what == 1) {
|
||||
Toast.makeText(FDroid.this,
|
||||
getString(R.string.connection_error_msg),
|
||||
Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
populateLists(true);
|
||||
}
|
||||
if (pd.isShowing())
|
||||
pd.dismiss();
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public static void doUpdates(Context ctx, DB db) {
|
||||
public static boolean doUpdates(Context ctx, DB db) {
|
||||
db.beginUpdate();
|
||||
Vector<DB.Repo> repos = db.getRepos();
|
||||
for (DB.Repo repo : repos) {
|
||||
@ -233,6 +233,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
} catch (Exception e) {
|
||||
Log.d("FDroid", "Exception updating from " + repo.address
|
||||
+ " - " + e.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
ctx.deleteFile("tempindex.xml");
|
||||
}
|
||||
@ -240,7 +241,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
}
|
||||
}
|
||||
db.endUpdate();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -116,9 +116,10 @@ public class UpdateService extends Service {
|
||||
if (notify)
|
||||
prevUpdates = db.getNumUpdates();
|
||||
|
||||
RepoXMLHandler.doUpdates(getBaseContext(), db);
|
||||
boolean success = RepoXMLHandler.doUpdates(
|
||||
getBaseContext(), db);
|
||||
|
||||
if (notify) {
|
||||
if (success && notify) {
|
||||
if (db.getNumUpdates() > prevUpdates) {
|
||||
// And the user wants to know.
|
||||
NotificationManager n = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user