Make sure DB helpers and preferences are initialized
This commit is contained in:
parent
844dd17cb1
commit
acbda70e28
|
@ -8,11 +8,8 @@ import com.joanzapata.iconify.Iconify;
|
|||
import com.joanzapata.iconify.fonts.FontAwesomeModule;
|
||||
import com.joanzapata.iconify.fonts.MaterialModule;
|
||||
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.spa.SPAUtil;
|
||||
|
||||
/** Main application class. */
|
||||
|
@ -56,11 +53,8 @@ public class PodcastApp extends Application {
|
|||
|
||||
singleton = this;
|
||||
|
||||
PodDBAdapter.init(this);
|
||||
UserPreferences.init(this);
|
||||
UpdateManager.init(this);
|
||||
PlaybackPreferences.init(this);
|
||||
NetworkUtils.init(this);
|
||||
ClientConfig.initialize(this);
|
||||
|
||||
EventDistributor.getInstance();
|
||||
Iconify.with(new FontAwesomeModule());
|
||||
Iconify.with(new MaterialModule());
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.net.NetworkInfo;
|
|||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.storage.DownloadRequester;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
|
@ -20,7 +21,8 @@ public class ConnectivityActionReceiver extends BroadcastReceiver {
|
|||
if (TextUtils.equals(intent.getAction(), ConnectivityManager.CONNECTIVITY_ACTION)) {
|
||||
Log.d(TAG, "Received intent");
|
||||
|
||||
if (NetworkUtils.autodownloadNetworkAvailable()) {
|
||||
ClientConfig.initialize(context);
|
||||
if (NetworkUtils.autodownloadNetworkAvailable()) {
|
||||
Log.d(TAG, "auto-dl network available, starting auto-download");
|
||||
DBTasks.autodownloadUndownloadedItems(context);
|
||||
} else { // if new network is Wi-Fi, finish ongoing downloads,
|
||||
|
|
|
@ -3,10 +3,9 @@ package de.danoeh.antennapod.receiver;
|
|||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.BatteryManager;
|
||||
import android.util.Log;
|
||||
|
||||
import de.danoeh.antennapod.core.BuildConfig;
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.storage.DownloadRequester;
|
||||
|
@ -25,6 +24,7 @@ public class PowerConnectionReceiver extends BroadcastReceiver {
|
|||
|
||||
Log.d(TAG, "charging intent: " + action);
|
||||
|
||||
ClientConfig.initialize(context);
|
||||
if (Intent.ACTION_POWER_CONNECTED.equals(action)) {
|
||||
Log.d(TAG, "charging, starting auto-download");
|
||||
// we're plugged in, this is a great time to auto-download if everything else is
|
||||
|
|
|
@ -49,6 +49,7 @@ public class SPAReceiver extends BroadcastReceiver{
|
|||
}
|
||||
} else {
|
||||
Log.e(TAG, "Received invalid SP_APPS_QUERY_RESPONSE: Contains no extra");
|
||||
ClientConfig.initialize(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
package de.danoeh.antennapod.core;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
|
||||
/**
|
||||
* Stores callbacks for core classes like Services, DB classes etc. and other configuration variables.
|
||||
* Apps using the core module of AntennaPod should register implementations of all interfaces here.
|
||||
|
@ -22,4 +29,19 @@ public class ClientConfig {
|
|||
public static FlattrCallbacks flattrCallbacks;
|
||||
|
||||
public static DBTasksCallbacks dbTasksCallbacks;
|
||||
|
||||
private static boolean initialized = false;
|
||||
|
||||
public static synchronized void initialize(Context context) {
|
||||
if(initialized) {
|
||||
return;
|
||||
}
|
||||
PodDBAdapter.init(context);
|
||||
UserPreferences.init(context);
|
||||
UpdateManager.init(context);
|
||||
PlaybackPreferences.init(context);
|
||||
NetworkUtils.init(context);
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod;
|
||||
package de.danoeh.antennapod.core;
|
||||
|
||||
|
||||
import android.content.Context;
|
|
@ -6,7 +6,7 @@ import android.content.Intent;
|
|||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
|
||||
/** Listens for events that make it necessary to reset the update alarm. */
|
||||
|
@ -22,8 +22,7 @@ public class AlarmUpdateReceiver extends BroadcastReceiver {
|
|||
} else if (TextUtils.equals(intent.getAction(), Intent.ACTION_PACKAGE_REPLACED)) {
|
||||
Log.d(TAG, "Resetting update alarm after app upgrade");
|
||||
}
|
||||
PlaybackPreferences.init(context);
|
||||
UserPreferences.init(context);
|
||||
ClientConfig.initialize(context);
|
||||
UserPreferences.restartUpdateAlarm(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
|
@ -19,6 +20,7 @@ public class FeedUpdateReceiver extends BroadcastReceiver {
|
|||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.d(TAG, "Received intent");
|
||||
ClientConfig.initialize(context);
|
||||
if (NetworkUtils.isDownloadAllowed()) {
|
||||
DBTasks.refreshAllFeeds(context, null);
|
||||
} else {
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.content.Intent;
|
|||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import de.danoeh.antennapod.core.BuildConfig;
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
|
||||
/** Receives media button events. */
|
||||
|
@ -21,6 +22,7 @@ public class MediaButtonReceiver extends BroadcastReceiver {
|
|||
KeyEvent event = (KeyEvent) intent.getExtras().get(
|
||||
Intent.EXTRA_KEY_EVENT);
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
ClientConfig.initialize(context);
|
||||
Intent serviceIntent = new Intent(context, PlaybackService.class);
|
||||
int keycode = event.getKeyCode();
|
||||
serviceIntent.putExtra(EXTRA_KEYCODE, keycode);
|
||||
|
|
Loading…
Reference in New Issue