use of android.view.ActionMode in project android_frameworks_base by AOSPA.
the class WindowDecorActionBarTest method testStartActionModeFinishesPreviousMode.
@UiThreadTest
public void testStartActionModeFinishesPreviousMode() {
ActionMode mode1 = mWindowDecorActionBar.startActionMode(mCallback);
ActionMode mode2 = mWindowDecorActionBar.startActionMode(new MockActionModeCallback());
assertNotNull(mode1);
assertNotNull(mode2);
assertTrue(mCallback.mIsDestroyActionModeCalled);
}
use of android.view.ActionMode in project android_frameworks_base by AOSPA.
the class WindowDecorActionBarTest method testStartActionModeWhenCreateReturnsFalse.
@UiThreadTest
public void testStartActionModeWhenCreateReturnsFalse() {
mCallback.mShouldCreateActionMode = false;
ActionMode mode = mWindowDecorActionBar.startActionMode(mCallback);
assertNull(mode);
assertTrue(mCallback.mIsCreateActionModeCalled);
}
use of android.view.ActionMode in project android_frameworks_base by AOSPA.
the class WindowDecorActionBarTest method testStartActionMode.
@UiThreadTest
public void testStartActionMode() {
ActionMode mode = mWindowDecorActionBar.startActionMode(mCallback);
assertNotNull(mode);
assertTrue(mCallback.mIsCreateActionModeCalled);
}
use of android.view.ActionMode in project android_frameworks_base by AOSPA.
the class DecorView method startActionMode.
private ActionMode startActionMode(View originatingView, ActionMode.Callback callback, int type) {
ActionMode.Callback2 wrappedCallback = new ActionModeCallback2Wrapper(callback);
ActionMode mode = null;
if (mWindow.getCallback() != null && !mWindow.isDestroyed()) {
try {
mode = mWindow.getCallback().onWindowStartingActionMode(wrappedCallback, type);
} catch (AbstractMethodError ame) {
// Older apps might not implement the typed version of this method.
if (type == ActionMode.TYPE_PRIMARY) {
try {
mode = mWindow.getCallback().onWindowStartingActionMode(wrappedCallback);
} catch (AbstractMethodError ame2) {
// Older apps might not implement this callback method at all.
}
}
}
}
if (mode != null) {
if (mode.getType() == ActionMode.TYPE_PRIMARY) {
cleanupPrimaryActionMode();
mPrimaryActionMode = mode;
} else if (mode.getType() == ActionMode.TYPE_FLOATING) {
if (mFloatingActionMode != null) {
mFloatingActionMode.finish();
}
mFloatingActionMode = mode;
}
} else {
mode = createActionMode(type, wrappedCallback, originatingView);
if (mode != null && wrappedCallback.onCreateActionMode(mode, mode.getMenu())) {
setHandledActionMode(mode);
} else {
mode = null;
}
}
if (mode != null && mWindow.getCallback() != null && !mWindow.isDestroyed()) {
try {
mWindow.getCallback().onActionModeStarted(mode);
} catch (AbstractMethodError ame) {
// Older apps might not implement this callback method.
}
}
return mode;
}
use of android.view.ActionMode in project platform_frameworks_base by android.
the class DecorView method startActionMode.
private ActionMode startActionMode(View originatingView, ActionMode.Callback callback, int type) {
ActionMode.Callback2 wrappedCallback = new ActionModeCallback2Wrapper(callback);
ActionMode mode = null;
if (mWindow.getCallback() != null && !mWindow.isDestroyed()) {
try {
mode = mWindow.getCallback().onWindowStartingActionMode(wrappedCallback, type);
} catch (AbstractMethodError ame) {
// Older apps might not implement the typed version of this method.
if (type == ActionMode.TYPE_PRIMARY) {
try {
mode = mWindow.getCallback().onWindowStartingActionMode(wrappedCallback);
} catch (AbstractMethodError ame2) {
// Older apps might not implement this callback method at all.
}
}
}
}
if (mode != null) {
if (mode.getType() == ActionMode.TYPE_PRIMARY) {
cleanupPrimaryActionMode();
mPrimaryActionMode = mode;
} else if (mode.getType() == ActionMode.TYPE_FLOATING) {
if (mFloatingActionMode != null) {
mFloatingActionMode.finish();
}
mFloatingActionMode = mode;
}
} else {
mode = createActionMode(type, wrappedCallback, originatingView);
if (mode != null && wrappedCallback.onCreateActionMode(mode, mode.getMenu())) {
setHandledActionMode(mode);
} else {
mode = null;
}
}
if (mode != null && mWindow.getCallback() != null && !mWindow.isDestroyed()) {
try {
mWindow.getCallback().onActionModeStarted(mode);
} catch (AbstractMethodError ame) {
// Older apps might not implement this callback method.
}
}
return mode;
}
Aggregations