diff --git a/app/build.gradle b/app/build.gradle index b9b5de53..cf3adee6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,9 +13,8 @@ android { } buildTypes { debug { - minifyEnabled true + minifyEnabled false useProguard false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } release { shrinkResources true diff --git a/app/src/main/java/de/nicidienase/chaosflix/activities/ExoPlayerActivity.java b/app/src/main/java/de/nicidienase/chaosflix/activities/ExoPlayerActivity.java index 54d4e133..28ba7a93 100644 --- a/app/src/main/java/de/nicidienase/chaosflix/activities/ExoPlayerActivity.java +++ b/app/src/main/java/de/nicidienase/chaosflix/activities/ExoPlayerActivity.java @@ -5,6 +5,7 @@ import android.os.Handler; import android.support.annotation.Nullable; import android.support.v17.leanback.app.PlaybackFragment; import android.view.TextureView; +import android.view.View; import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.ExoPlayerFactory; @@ -19,17 +20,21 @@ import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; import butterknife.BindView; import butterknife.ButterKnife; import de.nicidienase.chaosflix.R; +import de.nicidienase.chaosflix.entities.recording.Event; +import de.nicidienase.chaosflix.entities.recording.Recording; +import de.nicidienase.chaosflix.fragments.PlaybackOverlayFragment; /** * Created by felix on 26.03.17. */ -public class ExoPlayerActivity extends AbstractServiceConnectedAcitivty { +public class ExoPlayerActivity extends AbstractServiceConnectedAcitivty + implements PlaybackOverlayFragment.OnPlayPauseClickedListener{ @BindView(R.id.videoView) TextureView mTextureView; @BindView(R.id.playback_controls_fragment) - PlaybackFragment mPlaybackControllFragment; + View mPlaybackControllFragment; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -51,4 +56,9 @@ public class ExoPlayerActivity extends AbstractServiceConnectedAcitivty { player.setVideoTextureView(mTextureView); } + + @Override + public void onFragmentPlayPause(Event event, Recording recording, int position, Boolean playPause) { + + } } diff --git a/app/src/main/java/de/nicidienase/chaosflix/fragments/ExoOverlayFragment.java b/app/src/main/java/de/nicidienase/chaosflix/fragments/ExoOverlayFragment.java new file mode 100644 index 00000000..866f3255 --- /dev/null +++ b/app/src/main/java/de/nicidienase/chaosflix/fragments/ExoOverlayFragment.java @@ -0,0 +1,140 @@ +package de.nicidienase.chaosflix.fragments; + +import android.content.Intent; +import android.os.Bundle; +import android.os.Parcelable; +import android.support.v17.leanback.app.PlaybackFragment; +import android.support.v17.leanback.widget.Action; +import android.support.v17.leanback.widget.ArrayObjectAdapter; +import android.support.v17.leanback.widget.ClassPresenterSelector; +import android.support.v17.leanback.widget.ControlButtonPresenterSelector; +import android.support.v17.leanback.widget.ListRow; +import android.support.v17.leanback.widget.ListRowPresenter; +import android.support.v17.leanback.widget.OnActionClickedListener; +import android.support.v17.leanback.widget.PlaybackControlsRow; +import android.support.v17.leanback.widget.PlaybackControlsRowPresenter; +import android.widget.Toast; + +import de.nicidienase.chaosflix.activities.AbstractServiceConnectedAcitivty; +import de.nicidienase.chaosflix.activities.DetailsActivity; +import de.nicidienase.chaosflix.entities.recording.Event; +import de.nicidienase.chaosflix.entities.recording.Recording; + +/** + * Created by felix on 26.03.17. + */ + +public class ExoOverlayFragment extends PlaybackFragment { + + private static final boolean HIDE_MORE_ACTIONS = false; + + private Recording mSelectedRecording; + private Event mSelectedEvent; + private ArrayObjectAdapter mRowsAdapter; + private PlaybackControlsRow mPlaybackControlsRow; + private ArrayObjectAdapter mPrimaryActionsAdapter; + private ArrayObjectAdapter mSecondaryActionsAdapter; + private PlaybackControlsRow.PlayPauseAction mPlayPauseAction; + private PlaybackControlsRow.FastForwardAction mFastForwardAction; + private PlaybackControlsRow.RewindAction mRewindAction; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Intent intent = getActivity() + .getIntent(); + mSelectedEvent = intent.getParcelableExtra(DetailsActivity.EVENT); + final int mRecordingID = (int) intent.getLongExtra(DetailsActivity.RECORDING, 0); + + ((AbstractServiceConnectedAcitivty)getActivity()).getmApiServiceObservable() + .subscribe(mediaApiService -> { +// mMediaApiService = mediaApiService; + + mediaApiService.getEvent(mSelectedEvent.getApiID()) + .subscribe(event -> { + for(Recording r : event.getRecordings()){ + if(r.getApiID() == mRecordingID){ + mSelectedRecording = r; + } + } + }); + }); + + setBackgroundType(PlaybackFragment.BG_LIGHT); + setFadingEnabled(false); + + setupRows(); + addPlaybackControlsRow(); + addOtherRows(); + + setAdapter(mRowsAdapter); + + } + + private void setupRows() { + + ClassPresenterSelector ps = new ClassPresenterSelector(); + + PlaybackControlsRowPresenter playbackControlsRowPresenter; + playbackControlsRowPresenter = new PlaybackControlsRowPresenter( + new PlaybackOverlayFragment.DescriptionPresenter()); + playbackControlsRowPresenter.setOnActionClickedListener(new PlaybackControlClickedListener()); + playbackControlsRowPresenter.setSecondaryActionsHidden(HIDE_MORE_ACTIONS); + + ps.addClassPresenter(PlaybackControlsRow.class, playbackControlsRowPresenter); + ps.addClassPresenter(ListRow.class, new ListRowPresenter()); + mRowsAdapter = new ArrayObjectAdapter(ps); + + + + + } + + private void addOtherRows() { +// ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter()); +// for (Movie movie : mItems) { +// listRowAdapter.add(movie); +// } +// HeaderItem header = new HeaderItem(0, getString(R.string.related_movies)); +// mRowsAdapter.add(new ListRow(header, listRowAdapter)); + } + + private void addPlaybackControlsRow() { + mPlaybackControlsRow = new PlaybackControlsRow(mSelectedEvent); + mRowsAdapter.add(mPlaybackControlsRow); + +// updatePlaybackRow(mCurrentItem); + + ControlButtonPresenterSelector presenterSelector = new ControlButtonPresenterSelector(); + mPrimaryActionsAdapter = new ArrayObjectAdapter(presenterSelector); + mSecondaryActionsAdapter = new ArrayObjectAdapter(presenterSelector); + mPlaybackControlsRow.setPrimaryActionsAdapter(mPrimaryActionsAdapter); + mPlaybackControlsRow.setSecondaryActionsAdapter(mSecondaryActionsAdapter); + + mPlayPauseAction = new PlaybackControlsRow.PlayPauseAction(getActivity()); +// mRepeatAction = new RepeatAction(getActivity()); + mFastForwardAction = new PlaybackControlsRow.FastForwardAction(getActivity()); + mRewindAction = new PlaybackControlsRow.RewindAction(getActivity()); + + mPrimaryActionsAdapter.add(new PlaybackControlsRow.RewindAction(getActivity())); + mPrimaryActionsAdapter.add(mPlayPauseAction); + mPrimaryActionsAdapter.add(new PlaybackControlsRow.FastForwardAction(getActivity())); + +// mSecondaryActionsAdapter.add(mRepeatAction); + // The place to toggle audiotracks, subtitles, etc.. + } + + private class PlaybackControlClickedListener implements OnActionClickedListener { + public void onActionClicked(Action action) { + if (action.getId() == mPlayPauseAction.getId()) { + // TODO play/pause + //(mPlayPauseAction.getIndex() == PlaybackControlsRow.PlayPauseAction.PLAY) + } else if (action.getId() == mFastForwardAction.getId()) { + // TODO fast forward + } else if (action.getId() == mRewindAction.getId()) { + // TODO rewind + } + } + } +} diff --git a/app/src/main/java/de/nicidienase/chaosflix/fragments/PlaybackOverlayFragment.java b/app/src/main/java/de/nicidienase/chaosflix/fragments/PlaybackOverlayFragment.java index 1fc720e3..8c56f0eb 100644 --- a/app/src/main/java/de/nicidienase/chaosflix/fragments/PlaybackOverlayFragment.java +++ b/app/src/main/java/de/nicidienase/chaosflix/fragments/PlaybackOverlayFragment.java @@ -70,7 +70,6 @@ public class PlaybackOverlayFragment extends PlaybackFragment { private ArrayObjectAdapter mSecondaryActionsAdapter; private PlayPauseAction mPlayPauseAction; -// private RepeatAction mRepeatAction; private FastForwardAction mFastForwardAction; private RewindAction mRewindAction; @@ -184,6 +183,7 @@ public class PlaybackOverlayFragment extends PlaybackFragment { mRowsAdapter.add(mPlaybackControlsRow); // updatePlaybackRow(mCurrentItem); + updateVideoImage(mSelectedEvent.getThumbUrl()); ControlButtonPresenterSelector presenterSelector = new ControlButtonPresenterSelector(); mPrimaryActionsAdapter = new ArrayObjectAdapter(presenterSelector); @@ -216,7 +216,7 @@ public class PlaybackOverlayFragment extends PlaybackFragment { } } - private void updatePlaybackRow(int index) { + private void updatePlaybackRow(Event event) { if (mPlaybackControlsRow.getItem() != null) { Event item = (Event) mPlaybackControlsRow.getItem(); item.setTitle(mSelectedEvent.getTitle()); diff --git a/app/src/main/res/layout/exoplayback_activity.xml b/app/src/main/res/layout/exoplayback_activity.xml index 7fc612a8..81aed77a 100644 --- a/app/src/main/res/layout/exoplayback_activity.xml +++ b/app/src/main/res/layout/exoplayback_activity.xml @@ -12,7 +12,7 @@ - \ No newline at end of file