landscape layout
This commit is contained in:
parent
5da714ce9a
commit
62a6ac9078
|
@ -1,5 +1,6 @@
|
|||
package de.danoeh.antennapod.fragment;
|
||||
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
@ -8,9 +9,13 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.FitCenter;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
|
@ -47,6 +52,7 @@ public class CoverFragment extends Fragment {
|
|||
private Disposable disposable;
|
||||
private int displayedChapterIndex = -2;
|
||||
private Playable media;
|
||||
private int orientation = Configuration.ORIENTATION_UNDEFINED;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
|
@ -60,6 +66,11 @@ public class CoverFragment extends Fragment {
|
|||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
configureForOrientation(getResources().getConfiguration().orientation);
|
||||
}
|
||||
|
||||
private void loadMediaInfo() {
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
|
@ -72,12 +83,12 @@ public class CoverFragment extends Fragment {
|
|||
emitter.onComplete();
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(media -> {
|
||||
this.media = media;
|
||||
displayMediaInfo(media);
|
||||
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(media -> {
|
||||
this.media = media;
|
||||
displayMediaInfo(media);
|
||||
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||
}
|
||||
|
||||
private void displayMediaInfo(@NonNull Playable media) {
|
||||
|
@ -159,6 +170,31 @@ public class CoverFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
if (orientation != newConfig.orientation) {
|
||||
orientation = newConfig.orientation;
|
||||
configureForOrientation(orientation);
|
||||
}
|
||||
}
|
||||
|
||||
private void configureForOrientation(int orientation) {
|
||||
View textContainer = getView().findViewById(R.id.cover_fragment_text_container);
|
||||
LinearLayout mainContainer = getView().findViewById(R.id.cover_fragment);
|
||||
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textContainer.getLayoutParams();
|
||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
mainContainer.setOrientation(LinearLayout.VERTICAL);
|
||||
params.weight = 0;
|
||||
} else {
|
||||
mainContainer.setOrientation(LinearLayout.HORIZONTAL);
|
||||
params.weight = 1;
|
||||
}
|
||||
textContainer.setLayoutParams(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
|
|
@ -1,49 +1,57 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:squareImageView="http://schemas.android.com/apk/de.danoeh.antennapod"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/cover_fragment"
|
||||
android:padding="8dp"
|
||||
android:gravity="center">
|
||||
|
||||
<de.danoeh.antennapod.view.SquareImageView
|
||||
android:id="@+id/imgvCover"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_marginLeft="32dp"
|
||||
android:layout_marginRight="32dp"
|
||||
android:transitionName="coverTransition"
|
||||
tools:src="@android:drawable/sym_def_app_icon"
|
||||
android:foreground="?attr/selectableItemBackgroundBorderless"
|
||||
android:importantForAccessibility="no"
|
||||
squareImageView:direction="minimum" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvPodcastTitle"
|
||||
<LinearLayout
|
||||
android:id="@+id/cover_fragment_text_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxLines="2"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textIsSelectable="true"
|
||||
tools:text="Podcast" />
|
||||
android:layout_marginBottom="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvEpisodeTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxLines="2"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textIsSelectable="true"
|
||||
android:layout_marginBottom="8dp"
|
||||
tools:text="Episode" />
|
||||
<TextView
|
||||
android:id="@+id/txtvPodcastTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxLines="2"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textIsSelectable="true"
|
||||
tools:text="Podcast" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvEpisodeTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxLines="2"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textIsSelectable="true"
|
||||
tools:text="Episode" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Reference in New Issue