Merge "Fix IllegalStateException of ViewGroup"
commit
f3b92fb952
|
@ -932,11 +932,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
|||
@Override
|
||||
public void onShowMoreKeysPanel(final MoreKeysPanel panel) {
|
||||
locatePreviewPlacerView();
|
||||
// TODO: Remove this check
|
||||
if (panel.isShowingInParent()) {
|
||||
panel.dismissMoreKeysPanel();
|
||||
}
|
||||
mPreviewPlacerView.addView(panel.getContainerView());
|
||||
panel.showInParent(mPreviewPlacerView);
|
||||
mMoreKeysPanel = panel;
|
||||
dimEntireKeyboard(true /* dimmed */);
|
||||
}
|
||||
|
@ -954,7 +950,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
|||
public void onDismissMoreKeysPanel(final MoreKeysPanel panel) {
|
||||
dimEntireKeyboard(false /* dimmed */);
|
||||
if (isShowingMoreKeysPanel()) {
|
||||
mPreviewPlacerView.removeView(mMoreKeysPanel.getContainerView());
|
||||
mMoreKeysPanel.removeFromParent();
|
||||
mMoreKeysPanel = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.content.res.Resources;
|
|||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.android.inputmethod.latin.Constants;
|
||||
import com.android.inputmethod.latin.R;
|
||||
|
@ -216,11 +217,25 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getContainerView() {
|
||||
private View getContainerView() {
|
||||
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
|
||||
public boolean isShowingInParent() {
|
||||
return (getContainerView().getParent() != null);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package com.android.inputmethod.keyboard;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
public interface MoreKeysPanel {
|
||||
public interface Controller {
|
||||
|
@ -119,9 +120,16 @@ public interface MoreKeysPanel {
|
|||
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.
|
||||
|
|
Loading…
Reference in New Issue