Only do background updates when the main activities are not in the foreground
This commit is contained in:
parent
6b0a1db687
commit
4f864aaf10
@ -2,7 +2,8 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.fdroid.fdroid" android:versionCode="4"
|
||||
android:versionName="0.13" android:installLocation="auto">
|
||||
<application android:label="@string/app_name" android:icon="@drawable/icon">
|
||||
<application android:name="FDroidApp" android:label="@string/app_name"
|
||||
android:icon="@drawable/icon">
|
||||
<uses-sdk android:minSdkVersion="3" />
|
||||
|
||||
<activity android:name="FDroid">
|
||||
@ -29,6 +30,6 @@
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
|
||||
</manifest>
|
||||
|
@ -170,13 +170,19 @@ public class AppDetails extends ListActivity {
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
((FDroidApp) getApplication()).inActivity++;
|
||||
// Get the preferences we're going to use in this Activity...
|
||||
SharedPreferences prefs = PreferenceManager
|
||||
.getDefaultSharedPreferences(getBaseContext());
|
||||
pref_cacheDownloaded = prefs.getBoolean("cacheDownloaded", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
((FDroidApp) getApplication()).inActivity--;
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
// Reset the display and list contents. Used when entering the activity, and
|
||||
// also when something has been installed/uninstalled. In the latter case,
|
||||
// 'update' is true to make the installed status get refreshed.
|
||||
@ -381,7 +387,7 @@ public class AppDetails extends ListActivity {
|
||||
msg.arg2 = 1;
|
||||
msg.obj = new String(localfile);
|
||||
download_handler.sendMessage(msg);
|
||||
msg=new Message();
|
||||
msg = new Message();
|
||||
msg.arg1 = 1;
|
||||
download_handler.sendMessage(msg);
|
||||
} else {
|
||||
@ -526,9 +532,10 @@ public class AppDetails extends ListActivity {
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if(requestCode==REQUEST_INSTALL) {
|
||||
if (requestCode == REQUEST_INSTALL) {
|
||||
// If we're not meant to be caching, delete the apk file we just
|
||||
// installed (or maybe the user cancelled the install - doesn't matter)
|
||||
// installed (or maybe the user cancelled the install - doesn't
|
||||
// matter)
|
||||
// from the SD card...
|
||||
if (!pref_cacheDownloaded) {
|
||||
String apkname = curapk.apkName;
|
||||
|
@ -192,9 +192,16 @@ public class FDroid extends TabActivity implements OnItemClickListener {
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
((FDroidApp) getApplication()).inActivity++;
|
||||
populateLists(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
((FDroidApp) getApplication()).inActivity--;
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
||||
@ -300,6 +307,7 @@ public class FDroid extends TabActivity implements OnItemClickListener {
|
||||
// service accordingly. It's cheap, so no need to check if the particular setting has
|
||||
// actually been changed.
|
||||
UpdateService.schedule(getBaseContext());
|
||||
populateLists(false);
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -76,6 +76,12 @@ public class UpdateService extends Service {
|
||||
new Thread() {
|
||||
public void run() {
|
||||
|
||||
// If we're in one of our list activities, we don't want
|
||||
// to run an update because the database will be out of
|
||||
// sync with the display.
|
||||
if (((FDroidApp) getApplication()).inActivity != 0)
|
||||
return;
|
||||
|
||||
// See if it's time to actually do anything yet...
|
||||
SharedPreferences prefs = PreferenceManager
|
||||
.getDefaultSharedPreferences(getBaseContext());
|
||||
@ -99,8 +105,9 @@ public class UpdateService extends Service {
|
||||
try {
|
||||
db = new DB(getBaseContext());
|
||||
RepoXMLHandler.doUpdates(db);
|
||||
} catch(Exception e) {
|
||||
Log.d("FDroid","Exception during handleCommand() - " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
Log.d("FDroid", "Exception during handleCommand() - "
|
||||
+ e.getMessage());
|
||||
} finally {
|
||||
if (db != null)
|
||||
db.close();
|
||||
|
Loading…
x
Reference in New Issue
Block a user