use of com.peterjosling.scroball.db.ScroballDB in project scroball by peterjosling.
the class ScroballApplication method onCreate.
@Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics());
FlowManager.init(this);
MobileAds.initialize(this, "ca-app-pub-9985743520520066~4279780475");
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
String userAgent = String.format(Locale.UK, "%s.%d", BuildConfig.APPLICATION_ID, BuildConfig.VERSION_CODE);
String sessionKeyKey = getString(R.string.saved_session_key);
LastfmApi api = new LastfmApi();
Caller caller = Caller.getInstance();
if (sharedPreferences.contains(sessionKeyKey)) {
String sessionKey = sharedPreferences.getString(sessionKeyKey, null);
lastfmClient = new LastfmClient(api, caller, userAgent, sessionKey);
} else {
lastfmClient = new LastfmClient(api, caller, userAgent);
}
scroballDB = new ScroballDB();
eventBus.register(this);
}
use of com.peterjosling.scroball.db.ScroballDB in project scroball by peterjosling.
the class ListenerService method onCreate.
@Override
public void onCreate() {
ScroballApplication application = (ScroballApplication) getApplication();
sharedPreferences = application.getSharedPreferences();
ConnectivityManager connectivityManager = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
ScroballDB scroballDB = application.getScroballDB();
ScrobbleNotificationManager scrobbleNotificationManager = new ScrobbleNotificationManager(this, sharedPreferences, scroballDB);
LastfmClient lastfmClient = application.getLastfmClient();
TrackLover trackLover = new TrackLover(lastfmClient, scroballDB, connectivityManager);
Scrobbler scrobbler = new Scrobbler(lastfmClient, scrobbleNotificationManager, scroballDB, connectivityManager, trackLover);
playbackTracker = new PlaybackTracker(scrobbleNotificationManager, scrobbler);
Log.d(TAG, "NotificationListenerService started");
MediaSessionManager mediaSessionManager = (MediaSessionManager) getApplicationContext().getSystemService(Context.MEDIA_SESSION_SERVICE);
ComponentName componentName = new ComponentName(this, this.getClass());
mediaSessionManager.addOnActiveSessionsChangedListener(this, componentName);
NetworkStateReceiver networkStateReceiver = new NetworkStateReceiver(scrobbler);
IntentFilter filter = new IntentFilter(android.net.ConnectivityManager.CONNECTIVITY_ACTION);
this.registerReceiver(networkStateReceiver, filter);
// Trigger change event with existing set of sessions.
List<MediaController> initialSessions = mediaSessionManager.getActiveSessions(componentName);
onActiveSessionsChanged(initialSessions);
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
}
Aggregations