[automerge] Use the orientation from the config object not resources 2p: b73f1acdab
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16763691 Bug: 216643100 Change-Id: If021132cd31b3213c66932b96056821661962afb
This commit is contained in:
@@ -103,7 +103,7 @@ public class DragLayout extends LinearLayout {
|
|||||||
MATCH_PARENT));
|
MATCH_PARENT));
|
||||||
((LayoutParams) mDropZoneView1.getLayoutParams()).weight = 1;
|
((LayoutParams) mDropZoneView1.getLayoutParams()).weight = 1;
|
||||||
((LayoutParams) mDropZoneView2.getLayoutParams()).weight = 1;
|
((LayoutParams) mDropZoneView2.getLayoutParams()).weight = 1;
|
||||||
updateContainerMargins();
|
updateContainerMargins(getResources().getConfiguration().orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -128,20 +128,18 @@ public class DragLayout extends LinearLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onConfigChanged(Configuration newConfig) {
|
public void onConfigChanged(Configuration newConfig) {
|
||||||
final int orientation = getResources().getConfiguration().orientation;
|
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE
|
||||||
if (orientation == Configuration.ORIENTATION_LANDSCAPE
|
|
||||||
&& getOrientation() != HORIZONTAL) {
|
&& getOrientation() != HORIZONTAL) {
|
||||||
setOrientation(LinearLayout.HORIZONTAL);
|
setOrientation(LinearLayout.HORIZONTAL);
|
||||||
updateContainerMargins();
|
updateContainerMargins(newConfig.orientation);
|
||||||
} else if (orientation == Configuration.ORIENTATION_PORTRAIT
|
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT
|
||||||
&& getOrientation() != VERTICAL) {
|
&& getOrientation() != VERTICAL) {
|
||||||
setOrientation(LinearLayout.VERTICAL);
|
setOrientation(LinearLayout.VERTICAL);
|
||||||
updateContainerMargins();
|
updateContainerMargins(newConfig.orientation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateContainerMargins() {
|
private void updateContainerMargins(int orientation) {
|
||||||
final int orientation = getResources().getConfiguration().orientation;
|
|
||||||
final float halfMargin = mDisplayMargin / 2f;
|
final float halfMargin = mDisplayMargin / 2f;
|
||||||
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
mDropZoneView1.setContainerMargin(
|
mDropZoneView1.setContainerMargin(
|
||||||
|
|||||||
Reference in New Issue
Block a user