Search in sources :

Example 1 with ScroballDB

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);
}
Also used : Caller(com.softartdev.lastfm.Caller) Crashlytics(com.crashlytics.android.Crashlytics) ScroballDB(com.peterjosling.scroball.db.ScroballDB)

Example 2 with ScroballDB

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);
}
Also used : IntentFilter(android.content.IntentFilter) MediaController(android.media.session.MediaController) ConnectivityManager(android.net.ConnectivityManager) MediaSessionManager(android.media.session.MediaSessionManager) ScroballDB(com.peterjosling.scroball.db.ScroballDB) ComponentName(android.content.ComponentName)

Aggregations

ScroballDB (com.peterjosling.scroball.db.ScroballDB)2 ComponentName (android.content.ComponentName)1 IntentFilter (android.content.IntentFilter)1 MediaController (android.media.session.MediaController)1 MediaSessionManager (android.media.session.MediaSessionManager)1 ConnectivityManager (android.net.ConnectivityManager)1 Crashlytics (com.crashlytics.android.Crashlytics)1 Caller (com.softartdev.lastfm.Caller)1