From eff076a27014f0315151a68cd7f1659d1f9cf1cd Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Thu, 29 Aug 2019 14:08:32 +0800 Subject: Fixed controller position and margin in ViewVideoActivity. Minor UI tweaks. --- .../infinityforreddit/PostFragment.java | 10 ++++++---- .../infinityforreddit/ViewVideoActivity.java | 20 +++++++++++++++----- 2 files changed, 21 insertions(+), 9 deletions(-) (limited to 'app/src/main/java/ml') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java index 23b24de2..b2c0e12a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java @@ -325,12 +325,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator { filter, nsfw); } } else if(postType == PostDataSource.TYPE_USER) { - CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mFetchPostInfoLinearLayout.getLayoutParams(); - params.height = ViewGroup.LayoutParams.WRAP_CONTENT; - mFetchPostInfoLinearLayout.setLayoutParams(params); - String username = getArguments().getString(EXTRA_USER_NAME); String where = getArguments().getString(EXTRA_USER_WHERE); + if(where != null && where.equals(PostDataSource.USER_WHERE_SUBMITTED)) { + CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mFetchPostInfoLinearLayout.getLayoutParams(); + params.height = ViewGroup.LayoutParams.WRAP_CONTENT; + mFetchPostInfoLinearLayout.setLayoutParams(params); + } mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase, accessToken, postType, true, new PostRecyclerViewAdapter.Callback() { @@ -404,6 +405,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { this.hasPost = hasPost; if(hasPost) { mFetchPostInfoLinearLayout.setVisibility(View.GONE); + mProgressBar.setVisibility(View.GONE); } else { if(isInLazyMode) { stopLazyMode(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java index bffc0a9c..c3ed9951 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java @@ -8,6 +8,7 @@ import android.app.DownloadManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; +import android.content.res.Configuration; import android.graphics.PorterDuff; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; @@ -94,11 +95,20 @@ public class ViewVideoActivity extends AppCompatActivity { actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarColor))); setTitle(""); - //Set player controller margin bottom in order to display it above the navbar - int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android"); - LinearLayout controllerLinearLayout = findViewById(R.id.linear_layout_exo_playback_control_view); - ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams(); - params.bottomMargin = getResources().getDimensionPixelSize(resourceId); + + if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || getResources().getBoolean(R.bool.isTablet)) { + //Set player controller bottom margin in order to display it above the navbar + int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android"); + LinearLayout controllerLinearLayout = findViewById(R.id.linear_layout_exo_playback_control_view); + ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams(); + params.bottomMargin = getResources().getDimensionPixelSize(resourceId); + } else { + //Set player controller right margin in order to display it above the navbar + int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android"); + LinearLayout controllerLinearLayout = findViewById(R.id.linear_layout_exo_playback_control_view); + ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams(); + params.rightMargin = getResources().getDimensionPixelSize(resourceId); + } Intent intent = getIntent(); mVideoUri = intent.getData(); -- cgit v1.2.3