finally fixed
This commit is contained in:
parent
0cad3bce68
commit
dba3aee7b0
|
@ -1,9 +1,11 @@
|
||||||
package de.danoeh.antennapod.fragment;
|
package de.danoeh.antennapod.fragment;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -69,7 +71,7 @@ public class CoverFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
configureForOrientation(getResources().getConfiguration().orientation);
|
configureForOrientation(getResources().getConfiguration().orientation, getResources().getConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadMediaInfo() {
|
private void loadMediaInfo() {
|
||||||
|
@ -106,6 +108,7 @@ public class CoverFragment extends Fragment {
|
||||||
root = null;
|
root = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
@ -172,34 +175,44 @@ public class CoverFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
|
|
||||||
if (orientation != newConfig.orientation) {
|
if (orientation != newConfig.orientation) {
|
||||||
orientation = newConfig.orientation;
|
orientation = newConfig.orientation;
|
||||||
configureForOrientation(orientation);
|
|
||||||
}
|
}
|
||||||
|
configureForOrientation(orientation, newConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureForOrientation(int orientation) {
|
public float convertDpToPixel(float dp) {
|
||||||
|
Context context = this.getActivity().getApplicationContext();
|
||||||
|
return dp * ((float) context.getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configureForOrientation(int orientation, Configuration newConfig) {
|
||||||
View textContainer = getView().findViewById(R.id.cover_fragment_text_container);
|
View textContainer = getView().findViewById(R.id.cover_fragment_text_container);
|
||||||
LinearLayout mainContainer = getView().findViewById(R.id.cover_fragment);
|
LinearLayout mainContainer = getView().findViewById(R.id.cover_fragment);
|
||||||
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textContainer.getLayoutParams();
|
|
||||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||||
mainContainer.setOrientation(LinearLayout.VERTICAL);
|
mainContainer.setOrientation(LinearLayout.VERTICAL);
|
||||||
params.weight = 0;
|
if (newConfig.screenWidthDp > 0) {
|
||||||
|
imgvCover.getLayoutParams().width = (int) (convertDpToPixel(newConfig.screenWidthDp) * .80);
|
||||||
|
imgvCover.getLayoutParams().height = imgvCover.getLayoutParams().width;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mainContainer.setOrientation(LinearLayout.HORIZONTAL);
|
mainContainer.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
params.weight = 1;
|
if (newConfig.screenHeightDp > 0) {
|
||||||
|
imgvCover.getLayoutParams().height = (int) (convertDpToPixel(newConfig.screenHeightDp) * .40);
|
||||||
|
imgvCover.getLayoutParams().width = imgvCover.getLayoutParams().height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (_position > -1) {
|
if (_position > -1) {
|
||||||
displayCoverImage(_position);
|
displayCoverImage(_position);
|
||||||
}
|
}
|
||||||
textContainer.setLayoutParams(params);
|
imgvCover.requestLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
|
|
||||||
<de.danoeh.antennapod.view.SquareImageView
|
<de.danoeh.antennapod.view.SquareImageView
|
||||||
android:id="@+id/imgvCover"
|
android:id="@+id/imgvCover"
|
||||||
android:layout_width="0dp"
|
android:layout_width="200dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="200dp"
|
||||||
android:layout_marginLeft="32dp"
|
android:layout_marginLeft="8dp"
|
||||||
android:layout_marginRight="32dp"
|
android:layout_marginRight="8dp"
|
||||||
android:layout_weight="0"
|
android:layout_weight="0"
|
||||||
android:foreground="?attr/selectableItemBackgroundBorderless"
|
android:foreground="?attr/selectableItemBackgroundBorderless"
|
||||||
android:importantForAccessibility="no"
|
android:importantForAccessibility="no"
|
||||||
|
|
Loading…
Reference in New Issue