Fix IllegalStateException of ViewGroup
Bug: 10629042 Change-Id: I111d092fb2f7dca47328127a155c981aa1c55906main
parent
1b5b0a3ebc
commit
7f8345d59a
|
@ -932,11 +932,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
@Override
|
@Override
|
||||||
public void onShowMoreKeysPanel(final MoreKeysPanel panel) {
|
public void onShowMoreKeysPanel(final MoreKeysPanel panel) {
|
||||||
locatePreviewPlacerView();
|
locatePreviewPlacerView();
|
||||||
// TODO: Remove this check
|
panel.showInParent(mPreviewPlacerView);
|
||||||
if (panel.isShowingInParent()) {
|
|
||||||
panel.dismissMoreKeysPanel();
|
|
||||||
}
|
|
||||||
mPreviewPlacerView.addView(panel.getContainerView());
|
|
||||||
mMoreKeysPanel = panel;
|
mMoreKeysPanel = panel;
|
||||||
dimEntireKeyboard(true /* dimmed */);
|
dimEntireKeyboard(true /* dimmed */);
|
||||||
}
|
}
|
||||||
|
@ -954,7 +950,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
public void onDismissMoreKeysPanel(final MoreKeysPanel panel) {
|
public void onDismissMoreKeysPanel(final MoreKeysPanel panel) {
|
||||||
dimEntireKeyboard(false /* dimmed */);
|
dimEntireKeyboard(false /* dimmed */);
|
||||||
if (isShowingMoreKeysPanel()) {
|
if (isShowingMoreKeysPanel()) {
|
||||||
mPreviewPlacerView.removeView(mMoreKeysPanel.getContainerView());
|
mMoreKeysPanel.removeFromParent();
|
||||||
mMoreKeysPanel = null;
|
mMoreKeysPanel = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.content.res.Resources;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.Constants;
|
import com.android.inputmethod.latin.Constants;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
|
@ -216,11 +217,25 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private View getContainerView() {
|
||||||
public View getContainerView() {
|
|
||||||
return (View)getParent();
|
return (View)getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showInParent(final ViewGroup parentView) {
|
||||||
|
removeFromParent();
|
||||||
|
parentView.addView(getContainerView());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeFromParent() {
|
||||||
|
final View containerView = getContainerView();
|
||||||
|
final ViewGroup currentParent = (ViewGroup)containerView.getParent();
|
||||||
|
if (currentParent != null) {
|
||||||
|
currentParent.removeView(containerView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isShowingInParent() {
|
public boolean isShowingInParent() {
|
||||||
return (getContainerView().getParent() != null);
|
return (getContainerView().getParent() != null);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package com.android.inputmethod.keyboard;
|
package com.android.inputmethod.keyboard;
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
public interface MoreKeysPanel {
|
public interface MoreKeysPanel {
|
||||||
public interface Controller {
|
public interface Controller {
|
||||||
|
@ -119,9 +120,16 @@ public interface MoreKeysPanel {
|
||||||
public int translateY(int y);
|
public int translateY(int y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the view containing the more keys panel.
|
* Show this {@link MoreKeysPanel} in the parent view.
|
||||||
|
*
|
||||||
|
* @param parentView the {@link ViewGroup} that hosts this {@link MoreKeysPanel}.
|
||||||
*/
|
*/
|
||||||
public View getContainerView();
|
public void showInParent(ViewGroup parentView);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove this {@link MoreKeysPanel} from the parent view.
|
||||||
|
*/
|
||||||
|
public void removeFromParent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether the panel is currently being shown.
|
* Return whether the panel is currently being shown.
|
||||||
|
|
Loading…
Reference in New Issue