use of org.gateshipone.malp.application.background.BackgroundServiceConnection in project malp by gateship-one.
the class NowPlayingView method onResume.
/**
* Resumes refreshing operation because the view is visible to the user again.
* Also registers to the NowPlayingInformation intends again.
*/
public void onResume() {
// Reenable scrolling views after resuming
if (mTrackName != null) {
mTrackName.setSelected(true);
}
if (mTrackAdditionalInfo != null) {
mTrackAdditionalInfo.setSelected(true);
}
if (mStreamingStatusReceiver == null) {
mStreamingStatusReceiver = new StreamingStatusReceiver();
}
if (null == mBackgroundServiceConnection) {
mBackgroundServiceConnection = new BackgroundServiceConnection(getContext().getApplicationContext(), new BackgroundServiceConnectionListener());
}
mBackgroundServiceConnection.openConnection();
IntentFilter filter = new IntentFilter();
filter.addAction(BackgroundService.ACTION_STREAMING_STATUS_CHANGED);
getContext().getApplicationContext().registerReceiver(mStreamingStatusReceiver, filter);
// Register with MPDStateMonitoring system
MPDStateMonitoringHandler.getHandler().registerStatusListener(mStateListener);
MPDInterface.mInstance.addMPDConnectionStateChangeListener(mConnectionStateListener);
mPlaylistView.onResume();
ArtworkManager.getInstance(getContext().getApplicationContext()).registerOnNewAlbumImageListener(this);
ArtworkManager.getInstance(getContext().getApplicationContext()).registerOnNewArtistImageListener(this);
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
sharedPref.registerOnSharedPreferenceChangeListener(this);
setVolumeControlSetting();
mUseEnglishWikipedia = sharedPref.getBoolean(getContext().getString(R.string.pref_use_english_wikipedia_key), getContext().getResources().getBoolean(R.bool.pref_use_english_wikipedia_default));
mShowArtistImage = sharedPref.getBoolean(getContext().getString(R.string.pref_show_npv_artist_image_key), getContext().getResources().getBoolean(R.bool.pref_show_npv_artist_image_default));
}
use of org.gateshipone.malp.application.background.BackgroundServiceConnection in project malp by gateship-one.
the class GenericActivity method onResume.
@Override
protected void onResume() {
super.onResume();
// Add error listener
MPDStateMonitoringHandler.getHandler().addErrorListener(mErrorListener);
MPDCommandHandler.getHandler().addErrorListener(mErrorListener);
MPDQueryHandler.getHandler().addErrorListener(mErrorListener);
mConnectionCallback = new MPDConnectionStateCallbackHandler(this, getMainLooper());
MPDInterface.mInstance.addMPDConnectionStateChangeListener(mConnectionCallback);
ConnectionManager.getInstance(getApplicationContext()).registerMPDUse(getApplicationContext());
if (null == mBackgroundServiceConnection) {
mBackgroundServiceConnection = new BackgroundServiceConnection(getApplicationContext(), new BackgroundServiceConnectionStateListener());
}
mBackgroundServiceConnection.openConnection();
if (mStreamingStatusReceiver == null) {
mStreamingStatusReceiver = new StreamingStatusReceiver();
}
IntentFilter filter = new IntentFilter();
filter.addAction(BackgroundService.ACTION_STREAMING_STATUS_CHANGED);
getApplicationContext().registerReceiver(mStreamingStatusReceiver, filter);
// Check if hardware key control is enabled by the user
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
sharedPref.registerOnSharedPreferenceChangeListener(this);
mHardwareControls = sharedPref.getBoolean(getString(R.string.pref_hardware_controls_key), getResources().getBoolean(R.bool.pref_hardware_controls_default));
HardwareKeyHandler.getInstance().setVolumeStepSize(sharedPref.getInt(getString(R.string.pref_volume_steps_key), getResources().getInteger(R.integer.pref_volume_steps_default)));
mKeepDisplayOn = sharedPref.getBoolean(getString(R.string.pref_keep_display_on_key), getResources().getBoolean(R.bool.pref_keep_display_on_default));
handleKeepDisplayOnSetting();
}
Aggregations