Commit 871f0abe authored by Geoffrey Métais's avatar Geoffrey Métais

Get rid of ViewSwitcher

parent e19a1a8e
......@@ -6,8 +6,9 @@
type="org.videolan.vlc.gui.audio.AudioPlayer" />
</data>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/background_default_darker" >
<ProgressBar
android:id="@+id/progressBar"
......@@ -144,28 +145,26 @@
</LinearLayout>
<ViewSwitcher
android:id="@+id/view_switcher"
android:layout_width="match_parent"
<android.support.v7.widget.RecyclerView
android:id="@+id/songs_list"
android:layout_width="@dimen/playlist_width"
android:layout_height="match_parent"
android:layout_below="@+id/header"
android:layout_above="@+id/player_controls"
android:background="?attr/background_default_darker">
<android.support.v7.widget.RecyclerView
android:id="@+id/songs_list"
android:layout_width="@dimen/playlist_width"
android:layout_height="match_parent"
android:clipToPadding="false"
android:layout_gravity="center_horizontal"
android:background="?attr/background_default"
android:paddingBottom="@dimen/listview_bottom_padding" />
android:layout_centerHorizontal="true"
android:clipToPadding="false"
android:layout_gravity="center_horizontal"
android:background="?attr/background_default"
android:paddingBottom="@dimen/listview_bottom_padding" />
<org.videolan.vlc.gui.view.CoverMediaSwitcher
android:id="@+id/cover_media_switcher"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</ViewSwitcher>
<org.videolan.vlc.gui.view.CoverMediaSwitcher
android:id="@+id/cover_media_switcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_below="@+id/header"
android:layout_above="@+id/player_controls"
android:visibility="gone"/>
<include layout="@layout/shadow_top"
android:layout_width="match_parent"
......
......@@ -113,9 +113,6 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
touchHelper.attachToRecyclerView(mBinding.songsList);
mBinding.viewSwitcher.setInAnimation(view.getContext(), android.R.anim.fade_in);
mBinding.viewSwitcher.setOutAnimation(view.getContext(), android.R.anim.fade_out);
setHeaderVisibilities(false, false, true, false, true, false);
mBinding.setFragment(this);
......@@ -355,9 +352,11 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
}
public void onPlaylistSwitchClick(View view) {
mBinding.viewSwitcher.showNext();
boolean showCover = mBinding.songsList.getVisibility() == View.VISIBLE;
mBinding.playlistSwitch.setImageResource(UiTools.getResourceFromAttribute(view.getContext(),
mBinding.viewSwitcher.getDisplayedChild() == 0 ? R.attr.ic_playlist_on : R.attr.ic_playlist));
showCover ? R.attr.ic_playlist : R.attr.ic_playlist_on));
mBinding.songsList.setVisibility(showCover ? View.GONE : View.VISIBLE);
mBinding.coverMediaSwitcher.setVisibility(showCover ? View.VISIBLE : View.GONE);
}
public void onShuffleClick(View view) {
......@@ -396,7 +395,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
activity.hideAudioPlayer();
}
public void setHeaderVisibilities(boolean advFuncVisible, boolean playlistSwitchVisible,
public void setHeaderVisibilities(boolean advFuncVisible, boolean playlistSwitchVisible,
boolean headerPlayPauseVisible, boolean progressBarVisible,
boolean headerTimeVisible, boolean searchVisible) {
mAdvFuncVisible = advFuncVisible;
......@@ -575,7 +574,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
public void run() {
if(!vibrated) {
((android.os.Vibrator) VLCApplication.getAppContext().getSystemService(Context.VIBRATOR_SERVICE))
.vibrate(80);
.vibrate(80);
vibrated = true;
}
......@@ -601,42 +600,42 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
if (mService == null)
return false;
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
(forward ? mBinding.next : mBinding.previous).setImageResource(this.pressed);
case MotionEvent.ACTION_DOWN:
(forward ? mBinding.next : mBinding.previous).setImageResource(this.pressed);
possibleSeek = (int) mService.getTime();
possibleSeek = (int) mService.getTime();
mPreviewingSeek = true;
vibrated = false;
length = mService.getLength();
mPreviewingSeek = true;
vibrated = false;
length = mService.getLength();
mHandler.postDelayed(seekRunnable, 1000);
return true;
mHandler.postDelayed(seekRunnable, 1000);
return true;
case MotionEvent.ACTION_UP:
(forward ? mBinding.next : mBinding.previous).setImageResource(this.normal);
mHandler.removeCallbacks(seekRunnable);
mPreviewingSeek = false;
case MotionEvent.ACTION_UP:
(forward ? mBinding.next : mBinding.previous).setImageResource(this.normal);
mHandler.removeCallbacks(seekRunnable);
mPreviewingSeek = false;
if(event.getEventTime()-event.getDownTime() < 1000) {
if(forward)
onNextClick(v);
else
onPreviousClick(v);
} else {
if(forward) {
if(possibleSeek < mService.getLength())
mService.setTime(possibleSeek);
else
if(event.getEventTime()-event.getDownTime() < 1000) {
if(forward)
onNextClick(v);
} else {
if(possibleSeek > 0)
mService.setTime(possibleSeek);
else
onPreviousClick(v);
} else {
if(forward) {
if(possibleSeek < mService.getLength())
mService.setTime(possibleSeek);
else
onNextClick(v);
} else {
if(possibleSeek > 0)
mService.setTime(possibleSeek);
else
onPreviousClick(v);
}
}
}
return true;
return true;
}
return false;
}
......@@ -657,14 +656,14 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
public void onStateChanged(int newState) {
mPlayerState = newState;
switch (newState) {
case BottomSheetBehavior.STATE_COLLAPSED:
setHeaderVisibilities(false, false, true, true, true, false);
break;
case BottomSheetBehavior.STATE_EXPANDED:
setHeaderVisibilities(true, true, false, false, false, true);
showPlaylistTips();
mPlaylistAdapter.setCurrentIndex(mService.getCurrentMediaPosition());
break;
case BottomSheetBehavior.STATE_COLLAPSED:
setHeaderVisibilities(false, false, true, true, true, false);
break;
case BottomSheetBehavior.STATE_EXPANDED:
setHeaderVisibilities(true, true, false, false, false, true);
showPlaylistTips();
mPlaylistAdapter.setCurrentIndex(mService.getCurrentMediaPosition());
break;
}
}
......
......@@ -28,7 +28,6 @@ import android.view.LayoutInflater;
import android.widget.ImageView;
import org.videolan.vlc.R;
import org.videolan.vlc.gui.view.AudioMediaSwitcher;
public class CoverMediaSwitcher extends AudioMediaSwitcher {
......@@ -43,7 +42,7 @@ public class CoverMediaSwitcher extends AudioMediaSwitcher {
ImageView imageView = new ImageView(getContext());
imageView.setImageBitmap(cover);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
addView(imageView);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment