diff options
Diffstat (limited to 'app/src')
5 files changed, 34 insertions, 20 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 12f354fc..66c76e03 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,6 +33,7 @@ android:usesCleartextTraffic="true" tools:replace="android:label"> <activity android:name=".activities.RPANActivity" + android:configChanges="orientation|screenSize|layoutDirection" android:label="@string/rpan_activity_label" android:parentActivityName=".activities.MainActivity" android:theme="@style/AppTheme.TranslucentStatusBar" /> diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java index 7d041d21..57b419ee 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java @@ -1,11 +1,14 @@ package ml.docilealligator.infinityforreddit.activities; import android.content.SharedPreferences; +import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.media.AudioManager; import android.os.Bundle; import android.os.Handler; +import android.view.View; +import android.widget.ProgressBar; import android.widget.Toast; import androidx.annotation.NonNull; @@ -18,6 +21,9 @@ import androidx.fragment.app.FragmentActivity; import androidx.viewpager2.adapter.FragmentStateAdapter; import androidx.viewpager2.widget.ViewPager2; +import com.evernote.android.state.State; +import com.livefront.bridge.Bridge; + import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -53,6 +59,8 @@ public class RPANActivity extends AppCompatActivity { CoordinatorLayout coordinatorLayout; @BindView(R.id.view_pager_2_rpan_activity) ViewPager2 viewPager2; + @BindView(R.id.progress_bar_rpan_activity) + ProgressBar progressBar; @Inject @Named("strapi") Retrofit strapiRetrofit; @@ -68,8 +76,10 @@ public class RPANActivity extends AppCompatActivity { Executor mExecutor; private String mAccessToken; private String mAccountName; - private ArrayList<RPANBroadcast> rpanBroadcasts; - private String nextCursor; + @State + ArrayList<RPANBroadcast> rpanBroadcasts; + @State + String nextCursor; private SectionsPagerAdapter sectionsPagerAdapter; @Override @@ -93,23 +103,30 @@ public class RPANActivity extends AppCompatActivity { setVolumeControlStream(AudioManager.STREAM_MUSIC); + Bridge.restoreInstanceState(this, savedInstanceState); + ButterKnife.bind(this); ActionBar actionBar = getSupportActionBar(); Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp); actionBar.setHomeAsUpIndicator(upArrow); - actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor))); + actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00000000"))); mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null); mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null); - loadRPANVideos(); + if (rpanBroadcasts == null) { + loadRPANVideos(); + } else { + initializeViewPager(); + } } private void loadRPANVideos() { strapiRetrofit.create(Strapi.class).getAllBroadcasts(APIUtils.getOAuthHeader(mAccessToken)).enqueue(new Callback<String>() { @Override public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) { + progressBar.setVisibility(View.GONE); if (response.isSuccessful()) { parseRPANBroadcasts(response.body()); } else { @@ -120,6 +137,7 @@ public class RPANActivity extends AppCompatActivity { @Override public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) { + progressBar.setVisibility(View.GONE); Toast.makeText(RPANActivity.this, R.string.load_rpan_broadcasts_failed, Toast.LENGTH_SHORT).show(); } @@ -199,7 +217,6 @@ public class RPANActivity extends AppCompatActivity { sectionsPagerAdapter = new SectionsPagerAdapter(this); viewPager2.setAdapter(sectionsPagerAdapter); viewPager2.setOffscreenPageLimit(3); - viewPager2.setUserInputEnabled(!mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false)); //fixViewPager2Sensitivity(viewPager2); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java index 468a931f..80f98cee 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java @@ -8,7 +8,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageButton; -import android.widget.ProgressBar; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; @@ -50,8 +49,6 @@ public class ViewRPANBroadcastFragment extends Fragment { @BindView(R.id.player_view_view_rpan_broadcast_fragment) PlayerView playerView; - @BindView(R.id.progress_bar_view_rpan_broadcast_fragment) - ProgressBar progressBar; @BindView(R.id.mute_exo_playback_control_view) ImageButton muteButton; @BindView(R.id.hd_exo_playback_control_view) @@ -124,7 +121,6 @@ public class ViewRPANBroadcastFragment extends Fragment { if (resumePosition > 0) { player.seekTo(resumePosition); } - player.setPlayWhenReady(true); wasPlaying = true; boolean muteVideo = mSharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_VIDEO, false) || @@ -214,16 +210,16 @@ public class ViewRPANBroadcastFragment extends Fragment { } @Override - public void onStart() { - super.onStart(); + public void onResume() { + super.onResume(); if (wasPlaying) { player.setPlayWhenReady(true); } } @Override - public void onStop() { - super.onStop(); + public void onPause() { + super.onPause(); wasPlaying = player.getPlayWhenReady(); player.setPlayWhenReady(false); } diff --git a/app/src/main/res/layout/activity_rpanactivity.xml b/app/src/main/res/layout/activity_rpanactivity.xml index 570fddb2..b7e22b40 100644 --- a/app/src/main/res/layout/activity_rpanactivity.xml +++ b/app/src/main/res/layout/activity_rpanactivity.xml @@ -6,6 +6,7 @@ android:layout_height="match_parent" android:background="#000000" android:id="@+id/coordinator_layout_rpan_activity" + android:keepScreenOn="true" tools:context=".activities.RPANActivity"> <androidx.viewpager2.widget.ViewPager2 @@ -13,4 +14,10 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> + <ProgressBar + android:id="@+id/progress_bar_rpan_activity" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" /> + </androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/fragment_view_rpan_broadcast.xml b/app/src/main/res/layout/fragment_view_rpan_broadcast.xml index fdfe62c6..bab40403 100644 --- a/app/src/main/res/layout/fragment_view_rpan_broadcast.xml +++ b/app/src/main/res/layout/fragment_view_rpan_broadcast.xml @@ -12,11 +12,4 @@ android:layout_height="match_parent" app:controller_layout_id="@layout/exo_playback_control_view" /> - <ProgressBar - android:id="@+id/progress_bar_view_rpan_broadcast_fragment" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="center" - android:visibility="gone" /> - </FrameLayout>
\ No newline at end of file |