use of com.naman14.timber.utils.SlideTrackSwitcher in project Timber by naman14.
the class QuickControlsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_playback_controls, container, false);
this.rootView = rootView;
mPlayPause = (PlayPauseButton) rootView.findViewById(R.id.play_pause);
mPlayPauseExpanded = (PlayPauseButton) rootView.findViewById(R.id.playpause);
playPauseWrapper = rootView.findViewById(R.id.play_pause_wrapper);
playPauseWrapperExpanded = rootView.findViewById(R.id.playpausewrapper);
playPauseWrapper.setOnClickListener(mPlayPauseListener);
playPauseWrapperExpanded.setOnClickListener(mPlayPauseExpandedListener);
mProgress = (ProgressBar) rootView.findViewById(R.id.song_progress_normal);
mSeekBar = (SeekBar) rootView.findViewById(R.id.song_progress);
mTitle = (TextView) rootView.findViewById(R.id.title);
mArtist = (TextView) rootView.findViewById(R.id.artist);
mTitleExpanded = (TextView) rootView.findViewById(R.id.song_title);
mArtistExpanded = (TextView) rootView.findViewById(R.id.song_artist);
mAlbumArt = (ImageView) rootView.findViewById(R.id.album_art_nowplayingcard);
mBlurredArt = (ImageView) rootView.findViewById(R.id.blurredAlbumart);
next = (MaterialIconView) rootView.findViewById(R.id.next);
previous = (MaterialIconView) rootView.findViewById(R.id.previous);
topContainer = rootView.findViewById(R.id.topContainer);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mProgress.getLayoutParams();
mProgress.measure(0, 0);
layoutParams.setMargins(0, -(mProgress.getMeasuredHeight() / 2), 0, 0);
mProgress.setLayoutParams(layoutParams);
mPlayPause.setColor(Config.accentColor(getActivity(), Helpers.getATEKey(getActivity())));
mPlayPauseExpanded.setColor(Color.WHITE);
mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
if (b) {
MusicPlayer.seek((long) i);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
MusicPlayer.next();
}
}, 200);
}
});
previous.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
MusicPlayer.previous(getActivity(), false);
}
}, 200);
}
});
((BaseActivity) getActivity()).setMusicStateListenerListener(this);
if (PreferencesUtility.getInstance(getActivity()).isGesturesEnabled()) {
new SlideTrackSwitcher() {
@Override
public void onClick() {
NavigationUtils.navigateToNowplaying(getActivity(), false);
}
}.attach(rootView.findViewById(R.id.root_view));
}
return rootView;
}
Aggregations