@Override
public void onDestroy() {
super.onDestroy();
// Remove all pending runnables
mHandler.removeMessages(ADVANCE_MSG);
mHandler.removeMessages(0);
mWorkspace.removeCallbacks(mBuildLayersRunnable);
mWorkspace.removeFolderListeners();
// Stop callbacks from LauncherModel
// It's possible to receive onDestroy after a new Launcher activity has
// been created. In this case, don't interfere with the new Launcher.
if (mModel.isCurrentCallbacks(this)) {
mModel.stopLoader();
LauncherAppState.getInstance().setLauncher(null);
}
if (mRotationPrefChangeHandler != null) {
mSharedPrefs.unregisterOnSharedPreferenceChangeListener(mRotationPrefChangeHandler);
}
try {
mAppWidgetHost.stopListening();
} catch (NullPointerException ex) {
Log.w(TAG, "problem while stopping AppWidgetHost during Launcher destruction", ex);
}
mAppWidgetHost = null;
mWidgetsToAdvance.clear();
TextKeyListener.getInstance().release();
((AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE))
.removeAccessibilityStateChangeListener(this);
unregisterReceiver(mUiBroadcastReceiver);
LauncherAnimUtils.onDestroyActivity();
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onDestroy();
}
}
java类android.text.method.TextKeyListener的实例源码
Launcher.java 文件源码
项目:SimpleUILauncher
阅读 32
收藏 0
点赞 0
评论 0
Launcher.java 文件源码
项目:SimplOS
阅读 33
收藏 0
点赞 0
评论 0
@Override
public void onDestroy() {
super.onDestroy();
// Remove all pending runnables
mHandler.removeMessages(ADVANCE_MSG);
mHandler.removeMessages(0);
mWorkspace.removeCallbacks(mBuildLayersRunnable);
// Stop callbacks from LauncherModel
LauncherAppState app = (LauncherAppState.getInstance());
// It's possible to receive onDestroy after a new Launcher activity has
// been created. In this case, don't interfere with the new Launcher.
if (mModel.isCurrentCallbacks(this)) {
mModel.stopLoader();
app.setLauncher(null);
}
try {
mAppWidgetHost.stopListening();
} catch (NullPointerException ex) {
Log.w(TAG, "problem while stopping AppWidgetHost during Launcher destruction", ex);
}
mAppWidgetHost = null;
mWidgetsToAdvance.clear();
TextKeyListener.getInstance().release();
unregisterReceiver(mCloseSystemDialogsReceiver);
mDragLayer.clearAllResizeFrames();
((ViewGroup) mWorkspace.getParent()).removeAllViews();
mWorkspace.removeAllWorkspaceScreens();
mWorkspace = null;
mDragController = null;
LauncherAnimUtils.onDestroyActivity();
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onDestroy();
}
}
Launcher.java 文件源码
项目:Trebuchet
阅读 28
收藏 0
点赞 0
评论 0
@Override
public void onDestroy() {
super.onDestroy();
// Remove all pending runnables
mHandler.removeMessages(ADVANCE_MSG);
mHandler.removeMessages(0);
mWorkspace.removeCallbacks(mBuildLayersRunnable);
// Stop callbacks from LauncherModel
LauncherAppState app = (LauncherAppState.getInstance());
// It's possible to receive onDestroy after a new Launcher activity has
// been created. In this case, don't interfere with the new Launcher.
if (mModel.isCurrentCallbacks(this)) {
mModel.stopLoader();
app.setLauncher(null);
}
try {
mAppWidgetHost.stopListening();
} catch (NullPointerException ex) {
Log.w(TAG, "problem while stopping AppWidgetHost during Launcher destruction", ex);
}
mAppWidgetHost = null;
mWidgetsToAdvance.clear();
TextKeyListener.getInstance().release();
unregisterReceiver(mCloseSystemDialogsReceiver);
unregisterReceiver(mConnectionReceiver);
unregisterReceiver(mDeviceUnlockedReceiver);
mDragLayer.clearAllResizeFrames();
((ViewGroup) mWorkspace.getParent()).removeAllViews();
mWorkspace.removeAllWorkspaceScreens();
mWorkspace = null;
mDragController = null;
LauncherAnimUtils.onDestroyActivity();
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onDestroy();
}
unregisterReceiver(protectedAppsChangedReceiver);
unregisterReceiver(searchBarVisibilityChangedReceiver);
}
TextView.java 文件源码
项目:Tada
阅读 20
收藏 0
点赞 0
评论 0
private void setInputType(int type, boolean direct) {
final int cls = type & EditorInfo.TYPE_MASK_CLASS;
KeyListener input;
if (cls == EditorInfo.TYPE_CLASS_TEXT) {
boolean autotext = (type & EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT) != 0;
TextKeyListener.Capitalize cap;
if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_CHARACTERS) != 0) {
cap = TextKeyListener.Capitalize.CHARACTERS;
} else if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_WORDS) != 0) {
cap = TextKeyListener.Capitalize.WORDS;
} else if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES) != 0) {
cap = TextKeyListener.Capitalize.SENTENCES;
} else {
cap = TextKeyListener.Capitalize.NONE;
}
input = TextKeyListener.getInstance(autotext, cap);
} else if (cls == EditorInfo.TYPE_CLASS_NUMBER) {
input = DigitsKeyListener.getInstance(
(type & EditorInfo.TYPE_NUMBER_FLAG_SIGNED) != 0,
(type & EditorInfo.TYPE_NUMBER_FLAG_DECIMAL) != 0);
} else if (cls == EditorInfo.TYPE_CLASS_DATETIME) {
switch (type & EditorInfo.TYPE_MASK_VARIATION) {
case EditorInfo.TYPE_DATETIME_VARIATION_DATE:
input = DateKeyListener.getInstance();
break;
case EditorInfo.TYPE_DATETIME_VARIATION_TIME:
input = TimeKeyListener.getInstance();
break;
default:
input = DateTimeKeyListener.getInstance();
break;
}
} else if (cls == EditorInfo.TYPE_CLASS_PHONE) {
input = DialerKeyListener.getInstance();
} else {
input = TextKeyListener.getInstance();
}
setRawInputType(type);
if (direct) {
createEditorIfNeeded();
mEditor.mKeyListener = input;
} else {
setKeyListenerOnly(input);
}
}
StringWidget.java 文件源码
项目:ODK-Liberia
阅读 24
收藏 0
点赞 0
评论 0
protected StringWidget(Context context, FormEntryPrompt prompt, boolean readOnlyOverride, boolean derived) {
super(context, prompt);
mAnswer = new EditText(context);
mAnswer.setId(QuestionWidget.newUniqueId());
mReadOnly = prompt.isReadOnly() || readOnlyOverride;
mAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);
TableLayout.LayoutParams params = new TableLayout.LayoutParams();
/**
* If a 'rows' attribute is on the input tag, set the minimum number of lines
* to display in the field to that value.
*
* I.e.,
* <input ref="foo" rows="5">
* ...
* </input>
*
* will set the height of the EditText box to 5 rows high.
*/
String height = prompt.getQuestion().getAdditionalAttribute(null, ROWS);
if ( height != null && height.length() != 0 ) {
try {
int rows = Integer.valueOf(height);
mAnswer.setMinLines(rows);
mAnswer.setGravity(Gravity.TOP); // to write test starting at the top of the edit area
} catch (Exception e) {
Log.e(this.getClass().getName(), "Unable to process the rows setting for the answer field: " + e.toString());
}
}
params.setMargins(7, 5, 7, 5);
mAnswer.setLayoutParams(params);
// capitalize the first letter of the sentence
mAnswer.setKeyListener(new TextKeyListener(Capitalize.SENTENCES, false));
// needed to make long read only text scroll
mAnswer.setHorizontallyScrolling(false);
mAnswer.setSingleLine(false);
String s = prompt.getAnswerText();
if (s != null) {
mAnswer.setText(s);
}
if (mReadOnly) {
mAnswer.setBackgroundDrawable(null);
mAnswer.setFocusable(false);
mAnswer.setClickable(false);
}
addView(mAnswer);
}
Launcher.java 文件源码
项目:TurboLauncher
阅读 30
收藏 0
点赞 0
评论 0
@Override
public void onDestroy() {
super.onDestroy();
// Remove all pending runnables
mHandler.removeMessages(ADVANCE_MSG);
mHandler.removeMessages(0);
mWorkspace.removeCallbacks(mBuildLayersRunnable);
// Stop callbacks from LauncherModel
LauncherAppState app = (LauncherAppState.getInstance());
mModel.stopLoader();
app.setLauncher(null);
try {
mAppWidgetHost.stopListening();
} catch (NullPointerException ex) {
Log.w(TAG,
"problem while stopping AppWidgetHost during Launcher destruction",
ex);
}
mAppWidgetHost = null;
mWidgetsToAdvance.clear();
TextKeyListener.getInstance().release();
// Disconnect any of the callbacks and drawables associated with
// ItemInfos on the workspace
// to prevent leaking Launcher activities on orientation change.
if (mModel != null) {
mModel.unbindItemInfosAndClearQueuedBindRunnables();
}
getContentResolver().unregisterContentObserver(mWidgetObserver);
unregisterReceiver(mCloseSystemDialogsReceiver);
mDragLayer.clearAllResizeFrames();
((ViewGroup) mWorkspace.getParent()).removeAllViews();
mWorkspace.removeAllWorkspaceScreens();
mWorkspace = null;
mDragController = null;
LauncherAnimUtils.onDestroyActivity();
unregisterReceiver(protectedAppsChangedReceiver);
}
Launcher.java 文件源码
项目:FLauncher
阅读 50
收藏 0
点赞 0
评论 0
@Override
public void onDestroy() {
super.onDestroy();
// Remove all pending runnables
mHandler.removeMessages(ADVANCE_MSG);
mHandler.removeMessages(0);
mWorkspace.removeCallbacks(mBuildLayersRunnable);
// Stop callbacks from LauncherModel
LauncherAppState app = (LauncherAppState.getInstance());
// It's possible to receive onDestroy after a new Launcher activity has
// been created. In this case, don't interfere with the new Launcher.
if (mModel.isCurrentCallbacks(this)) {
mModel.stopLoader();
app.setLauncher(null);
}
try {
mAppWidgetHost.stopListening();
} catch (NullPointerException ex) {
Log.w(TAG, "problem while stopping AppWidgetHost during Launcher destruction", ex);
}
mAppWidgetHost = null;
mWidgetsToAdvance.clear();
TextKeyListener.getInstance().release();
unregisterReceiver(mCloseSystemDialogsReceiver);
mDragLayer.clearAllResizeFrames();
((ViewGroup) mWorkspace.getParent()).removeAllViews();
mWorkspace.removeAllWorkspaceScreens();
mWorkspace = null;
mDragController = null;
LauncherAnimUtils.onDestroyActivity();
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onDestroy();
}
}
GeckoInputConnection.java 文件源码
项目:mc_backup
阅读 21
收藏 0
点赞 0
评论 0
private boolean processKey(int keyCode, KeyEvent event, boolean down) {
if (GamepadUtils.isSonyXperiaGamepadKeyEvent(event)) {
event = GamepadUtils.translateSonyXperiaGamepadKeys(keyCode, event);
keyCode = event.getKeyCode();
}
if (keyCode > KeyEvent.getMaxKeyCode() ||
!shouldProcessKey(keyCode, event)) {
return false;
}
final int action = down ? KeyEvent.ACTION_DOWN : KeyEvent.ACTION_UP;
event = translateKey(keyCode, event);
keyCode = event.getKeyCode();
View view = getView();
if (view == null) {
InputThreadUtils.sInstance.sendEventFromUiThread(ThreadUtils.getUiHandler(),
mEditableClient, GeckoEvent.createKeyEvent(event, action, 0));
return true;
}
// KeyListener returns true if it handled the event for us. KeyListener is only
// safe to use on the UI thread; therefore we need to pass a proxy Editable to it
KeyListener keyListener = TextKeyListener.getInstance();
Handler uiHandler = view.getRootView().getHandler();
Editable uiEditable = InputThreadUtils.sInstance.
getEditableForUiThread(uiHandler, mEditableClient);
boolean skip = shouldSkipKeyListener(keyCode, event);
if (down) {
mEditableClient.setSuppressKeyUp(true);
}
if (skip ||
(down && !keyListener.onKeyDown(view, uiEditable, keyCode, event)) ||
(!down && !keyListener.onKeyUp(view, uiEditable, keyCode, event))) {
InputThreadUtils.sInstance.sendEventFromUiThread(uiHandler, mEditableClient,
GeckoEvent.createKeyEvent(event, action, TextKeyListener.getMetaState(uiEditable)));
if (skip && down) {
// Usually, the down key listener call above adjusts meta states for us.
// However, if we skip that call above, we have to manually adjust meta
// states so the meta states remain consistent
TextKeyListener.adjustMetaAfterKeypress(uiEditable);
}
}
if (down) {
mEditableClient.setSuppressKeyUp(false);
}
return true;
}
TextView.java 文件源码
项目:JotaTextEditor
阅读 27
收藏 0
点赞 0
评论 0
private void setInputType(int type, boolean direct) {
final int cls = type & EditorInfo.TYPE_MASK_CLASS;
KeyListener input;
if (cls == EditorInfo.TYPE_CLASS_TEXT) {
boolean autotext = (type & EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT) != 0;
TextKeyListener.Capitalize cap;
if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_CHARACTERS) != 0) {
cap = TextKeyListener.Capitalize.CHARACTERS;
} else if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_WORDS) != 0) {
cap = TextKeyListener.Capitalize.WORDS;
} else if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES) != 0) {
cap = TextKeyListener.Capitalize.SENTENCES;
} else {
cap = TextKeyListener.Capitalize.NONE;
}
input = JotaTextKeyListener.getInstance(autotext, cap);
} else if (cls == EditorInfo.TYPE_CLASS_NUMBER) {
input = DigitsKeyListener.getInstance(
(type & EditorInfo.TYPE_NUMBER_FLAG_SIGNED) != 0,
(type & EditorInfo.TYPE_NUMBER_FLAG_DECIMAL) != 0);
} else if (cls == EditorInfo.TYPE_CLASS_DATETIME) {
switch (type & EditorInfo.TYPE_MASK_VARIATION) {
case EditorInfo.TYPE_DATETIME_VARIATION_DATE:
input = DateKeyListener.getInstance();
break;
case EditorInfo.TYPE_DATETIME_VARIATION_TIME:
input = TimeKeyListener.getInstance();
break;
default:
input = DateTimeKeyListener.getInstance();
break;
}
} else if (cls == EditorInfo.TYPE_CLASS_PHONE) {
input = DialerKeyListener.getInstance();
} else {
input = JotaTextKeyListener.getInstance();
}
setRawInputType(type);
if (direct) mInput = input;
else {
setKeyListenerOnly(input);
}
}
Layout.java 文件源码
项目:JotaTextEditor
阅读 25
收藏 0
点赞 0
评论 0
/**
* Fills in the specified Path with a representation of a cursor
* at the specified offset. This will often be a vertical line
* but can be multiple discontinous lines in text with multiple
* directionalities.
*/
public void getCursorPath(int point, Path dest,
CharSequence editingBuffer) {
dest.reset();
int line = getLineForOffset(point);
int top = getLineTop(line);
int bottom = getLineTop(line+1);
float h1 = getPrimaryHorizontal(point) - 0.5f;
float h2 = getSecondaryHorizontal(point) - 0.5f;
int caps = TextKeyListener.getMetaState(editingBuffer,
KeyEvent.META_SHIFT_ON) |
JotaTextKeyListener.getMetaStateSelecting(editingBuffer);
int fn = TextKeyListener.getMetaState(editingBuffer,
KeyEvent.META_ALT_ON);
int dist = 0;
if (caps != 0 || fn != 0) {
dist = (bottom - top) >> 2;
if (fn != 0)
top += dist;
if (caps != 0)
bottom -= dist;
}
if (h1 < 0.5f)
h1 = 0.5f;
if (h2 < 0.5f)
h2 = 0.5f;
if (h1 == h2) {
dest.moveTo(h1, top);
dest.lineTo(h1, bottom);
} else {
dest.moveTo(h1, top);
dest.lineTo(h1, (top + bottom) >> 1);
dest.moveTo(h2, (top + bottom) >> 1);
dest.lineTo(h2, bottom);
}
if (caps == 2) {
dest.moveTo(h2, bottom);
dest.lineTo(h2 - dist, bottom + dist);
dest.lineTo(h2, bottom);
dest.lineTo(h2 + dist, bottom + dist);
} else if (caps == 1) {
dest.moveTo(h2, bottom);
dest.lineTo(h2 - dist, bottom + dist);
dest.moveTo(h2 - dist, bottom + dist - 0.5f);
dest.lineTo(h2 + dist, bottom + dist - 0.5f);
dest.moveTo(h2 + dist, bottom + dist);
dest.lineTo(h2, bottom);
}
if (fn == 2) {
dest.moveTo(h1, top);
dest.lineTo(h1 - dist, top - dist);
dest.lineTo(h1, top);
dest.lineTo(h1 + dist, top - dist);
} else if (fn == 1) {
dest.moveTo(h1, top);
dest.lineTo(h1 - dist, top - dist);
dest.moveTo(h1 - dist, top - dist + 0.5f);
dest.lineTo(h1 + dist, top - dist + 0.5f);
dest.moveTo(h1 + dist, top - dist);
dest.lineTo(h1, top);
}
}