List of usage examples for android.view View clearFocus
public void clearFocus()
From source file:org.telegram.ui.Components.PasscodeView.java
public void onShow() { Activity parentActivity = (Activity) getContext(); if (UserConfig.passcodeType == 1) { if (passwordEditText != null) { passwordEditText.requestFocus(); AndroidUtilities.showKeyboard(passwordEditText); }//ww w . j av a2 s .c om } else { if (parentActivity != null) { View currentFocus = parentActivity.getCurrentFocus(); if (currentFocus != null) { currentFocus.clearFocus(); AndroidUtilities.hideKeyboard(((Activity) getContext()).getCurrentFocus()); } } } checkFingerprint(); if (getVisibility() == View.VISIBLE) { return; } if (Build.VERSION.SDK_INT >= 14) { ViewProxy.setAlpha(this, 1.0f); ViewProxy.setTranslationY(this, 0); this.clearAnimation(); } SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); int selectedBackground = preferences.getInt("selectedBackground", 1000001); if (selectedBackground == 1000001) { backgroundFrameLayout.setBackgroundColor(0xffff8542); } else { backgroundDrawable = ApplicationLoader.getCachedWallpaper(); if (backgroundDrawable != null) { backgroundFrameLayout.setBackgroundColor(0xbf000000); } else { backgroundFrameLayout.setBackgroundColor(0xffff8542); } } passcodeTextView.setText(LocaleController.getString("EnterYourPasscode", R.string.EnterYourPasscode)); if (UserConfig.passcodeType == 0) { //InputFilter[] filterArray = new InputFilter[1]; //filterArray[0] = new InputFilter.LengthFilter(4); //passwordEditText.setFilters(filterArray); //passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE); //passwordEditText.setFocusable(false); //passwordEditText.setFocusableInTouchMode(false); numbersFrameLayout.setVisibility(VISIBLE); passwordEditText.setVisibility(GONE); passwordEditText2.setVisibility(VISIBLE); checkImage.setVisibility(GONE); } else if (UserConfig.passcodeType == 1) { passwordEditText.setFilters(new InputFilter[0]); passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); numbersFrameLayout.setVisibility(GONE); passwordEditText.setFocusable(true); passwordEditText.setFocusableInTouchMode(true); passwordEditText.setVisibility(VISIBLE); passwordEditText2.setVisibility(GONE); checkImage.setVisibility(VISIBLE); } setVisibility(VISIBLE); passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance()); passwordEditText.setText(""); passwordEditText2.eraseAllCharacters(false); setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); }
From source file:kr.wdream.ui.Components.PasscodeView.java
public void onShow() { Log.d("PassCodeView", "onShow"); Activity parentActivity = (Activity) getContext(); if (UserConfig.passcodeType == 1) { Log.d("PassCodeView", "passcodeType = 1"); if (passwordEditText != null) { Log.d("PassCodeView", "EditText not null"); passwordEditText.requestFocus(); AndroidUtilities.showKeyboard(passwordEditText); }// w ww.j a va2s. c o m } else { Log.d("PassCodeView", "passcodeType not 1"); if (parentActivity != null) { Log.d("PassCodeView", "parentActivity not null"); View currentFocus = parentActivity.getCurrentFocus(); if (currentFocus != null) { Log.d("PassCodeView", "current focus not null"); currentFocus.clearFocus(); AndroidUtilities.hideKeyboard(((Activity) getContext()).getCurrentFocus()); } } } checkFingerprint(); if (getVisibility() == View.VISIBLE) { return; } setAlpha(1.0f); setTranslationY(0); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); int selectedBackground = preferences.getInt("selectedBackground", 1000001); if (selectedBackground == 1000001) { backgroundFrameLayout.setBackgroundColor(0xff517c9e); } else { backgroundDrawable = ApplicationLoader.getCachedWallpaper(); if (backgroundDrawable != null) { backgroundFrameLayout.setBackgroundColor(0xbf000000); } else { backgroundFrameLayout.setBackgroundColor(0xff517c9e); } } passcodeTextView.setText( LocaleController.getString("EnterYourPasscode", kr.wdream.storyshop.R.string.EnterYourPasscode)); if (UserConfig.passcodeType == 0) { //InputFilter[] filterArray = new InputFilter[1]; //filterArray[0] = new InputFilter.LengthFilter(4); //passwordEditText.setFilters(filterArray); //passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE); //passwordEditText.setFocusable(false); //passwordEditText.setFocusableInTouchMode(false); numbersFrameLayout.setVisibility(VISIBLE); passwordEditText.setVisibility(GONE); passwordEditText2.setVisibility(VISIBLE); checkImage.setVisibility(GONE); } else if (UserConfig.passcodeType == 1) { passwordEditText.setFilters(new InputFilter[0]); passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); numbersFrameLayout.setVisibility(GONE); passwordEditText.setFocusable(true); passwordEditText.setFocusableInTouchMode(true); passwordEditText.setVisibility(VISIBLE); passwordEditText2.setVisibility(GONE); checkImage.setVisibility(VISIBLE); } setVisibility(VISIBLE); passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance()); passwordEditText.setText(""); passwordEditText2.eraseAllCharacters(false); setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); }
From source file:com.aviary.android.feather.sdk.widget.AviaryWorkspace.java
private void snapToScreen(int whichScreen, int velocity, boolean settle) { whichScreen = Math.max(0, Math.min(whichScreen, mItemCount - 1)); enableChildrenCache(mCurrentScreen, whichScreen); setNextSelectedPositionInt(whichScreen); View focusedChild = getFocusedChild(); if (focusedChild != null && whichScreen != mCurrentScreen && focusedChild == getChildAt(mCurrentScreen)) { focusedChild.clearFocus(); }//from w w w.j a va 2s. c om final int screenDelta = Math.max(1, Math.abs(whichScreen - mCurrentScreen)); final int newX = whichScreen * getWidth(); final int delta = newX - getScrollX(); int duration = (screenDelta + 1) * 100; if (!mScroller.isFinished()) { mScroller.abortAnimation(); } velocity = Math.abs(velocity); if (velocity > 0) { duration += (duration / (velocity / BASELINE_FLING_VELOCITY)) * FLING_VELOCITY_INFLUENCE; } else { duration += 100; } mScroller.startScroll(getScrollX(), 0, delta, 0, duration); int mode = getOverScroll(); if (delta != 0 && (mode == OVER_SCROLL_IF_CONTENT_SCROLLS)) { edgeReached(whichScreen, delta, velocity); } invalidate(); }
From source file:com.android.launcher2.PagedView.java
protected void snapToPage(int whichPage, int delta, int duration) { mNextPage = whichPage;//w w w . j a v a 2 s.co m View focusedChild = getFocusedChild(); if (focusedChild != null && whichPage != mCurrentPage && focusedChild == getPageAt(mCurrentPage)) { focusedChild.clearFocus(); } pageBeginMoving(); awakenScrollBars(duration); if (duration == 0) { duration = Math.abs(delta); } if (!mScroller.isFinished()) mScroller.abortAnimation(); mScroller.startScroll(mUnboundedScrollX, 0, delta, 0, duration); // Load associated pages immediately if someone else is handling the scroll, otherwise defer // loading associated pages until the scroll settles if (mDeferScrollUpdate) { loadAssociatedPages(mNextPage); } else { mDeferLoadAssociatedPagesUntilScrollCompletes = true; } notifyPageSwitchListener(); invalidate(); }
From source file:com.android.leanlauncher.Workspace.java
public void beginDragShared(View child, DragSource source) { child.clearFocus(); child.setPressed(false);/* ww w . j a v a 2 s.c o m*/ // The outline is used to visualize where the item will land if dropped mDragOutline = createDragOutline(child, DRAG_BITMAP_PADDING); mLauncher.onDragStarted(child); // The drag bitmap follows the touch point around on the screen AtomicInteger padding = new AtomicInteger(DRAG_BITMAP_PADDING); final Bitmap b = createDragBitmap(child, padding); final int bmpWidth = b.getWidth(); final int bmpHeight = b.getHeight(); float scale = mLauncher.getDragLayer().getLocationInDragLayer(child, mTempXY); int dragLayerX = Math.round(mTempXY[0] - (bmpWidth - scale * child.getWidth()) / 2); int dragLayerY = Math.round(mTempXY[1] - (bmpHeight - scale * bmpHeight) / 2 - padding.get() / 2); LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); Point dragVisualizeOffset = null; Rect dragRect = null; if (child instanceof BubbleTextView) { int iconSize = grid.iconSizePx; int top = child.getPaddingTop(); int left = (bmpWidth - iconSize) / 2; int right = left + iconSize; int bottom = top + iconSize; dragLayerY += top; // Note: The drag region is used to calculate drag layer offsets, but the // dragVisualizeOffset in addition to the dragRect (the size) to position the outline. dragVisualizeOffset = new Point(-padding.get() / 2, padding.get() / 2); dragRect = new Rect(left, top, right, bottom); } // Clear the pressed state if necessary if (child instanceof BubbleTextView) { BubbleTextView icon = (BubbleTextView) child; icon.clearPressedBackground(); } if (child.getTag() == null || !(child.getTag() instanceof ItemInfo)) { String msg = "Drag started with a view that has no tag set. This " + "will cause a crash (issue 11627249) down the line. " + "View: " + child + " tag: " + child.getTag(); throw new IllegalStateException(msg); } DragView dv = mDragController.startDrag(b, dragLayerX, dragLayerY, source, child.getTag(), DragController.DRAG_ACTION_MOVE, dragVisualizeOffset, dragRect, scale); dv.setIntrinsicIconScaleFactor(source.getIntrinsicIconScaleFactor()); b.recycle(); }
From source file:cc.flydev.launcher.Page.java
protected void snapToPage(int whichPage, int delta, int duration, boolean immediate) { mNextPage = whichPage;/*www. ja v a 2s .c o m*/ View focusedChild = getFocusedChild(); if (focusedChild != null && whichPage != mCurrentPage && focusedChild == getPageAt(mCurrentPage)) { focusedChild.clearFocus(); } sendScrollAccessibilityEvent(); pageBeginMoving(); awakenScrollBars(duration); if (immediate) { duration = 0; } else if (duration == 0) { duration = Math.abs(delta); } if (!mScroller.isFinished()) { mScroller.abortAnimation(); } mScroller.startScroll(mUnboundedScrollX, 0, delta, 0, duration); notifyPageSwitchListener(); // Trigger a compute() to finish switching pages if necessary if (immediate) { computeScroll(); } // Defer loading associated pages until the scroll settles mDeferLoadAssociatedPagesUntilScrollCompletes = true; mForceScreenScrolled = true; invalidate(); }
From source file:com.example.android_test.loopviewpager.LoopViewPager.java
Bitmap getViewBitmap(View v) { v.clearFocus(); v.setPressed(false);//from w ww. ja v a2s . c o m // ?????????? boolean willNotCache = v.willNotCacheDrawing(); int color = v.getDrawingCacheBackgroundColor(); // ??????? v.setWillNotCacheDrawing(false); // ??????? v.setDrawingCacheBackgroundColor(0); // ???? if (color != 0) { v.destroyDrawingCache(); } // ?????? v.buildDrawingCache(); // ? Bitmap ? Bitmap cacheBitmap = v.getDrawingCache(); if (cacheBitmap == null) { Log.e(TAG, "failed getViewBitmap(" + v + ")", new RuntimeException()); return null; } // ? Bitmap ???????? Bitmap ? Bitmap bitmap = Bitmap.createBitmap(cacheBitmap); // ?????????? v.destroyDrawingCache(); v.setWillNotCacheDrawing(willNotCache); v.setDrawingCacheBackgroundColor(color); return bitmap; }
From source file:org.chinenv.onroad.loopview.LoopViewPager.java
Bitmap getViewBitmap(View v) { v.clearFocus(); v.setPressed(false);/*from ww w. ja v a2 s . co m*/ // ?????????? boolean willNotCache = v.willNotCacheDrawing(); int color = v.getDrawingCacheBackgroundColor(); // ???????? v.setWillNotCacheDrawing(false); // ???????? v.setDrawingCacheBackgroundColor(0); // ????? if (color != 0) { v.destroyDrawingCache(); } // ?????? v.buildDrawingCache(); // ?Bitmap ?? Bitmap cacheBitmap = v.getDrawingCache(); if (cacheBitmap == null) { Log.e(TAG, "failed getViewBitmap(" + v + ")", new RuntimeException()); return null; } // ?Bitmap ???????? Bitmap ? Bitmap bitmap = Bitmap.createBitmap(cacheBitmap); // ?????????? v.destroyDrawingCache(); v.setWillNotCacheDrawing(willNotCache); v.setDrawingCacheBackgroundColor(color); return bitmap; }
From source file:com.baiiu.autoloopviewpager.loopvp.LoopViewPager.java
Bitmap getViewBitmap(View v) { v.clearFocus(); v.setPressed(false);//from w w w .j av a 2s .co m // ?????????? boolean willNotCache = v.willNotCacheDrawing(); int color = v.getDrawingCacheBackgroundColor(); // ??????? v.setWillNotCacheDrawing(false); // ??????? v.setDrawingCacheBackgroundColor(0); // ???? if (color != 0) { v.destroyDrawingCache(); } // ?????? v.buildDrawingCache(); // ? Bitmap ? Bitmap cacheBitmap = v.getDrawingCache(); if (cacheBitmap == null) { if (DEBUG) Log.e(TAG, "failed getViewBitmap(" + v + ")", new RuntimeException()); return null; } // ? Bitmap ???????? Bitmap ? Bitmap bitmap = Bitmap.createBitmap(cacheBitmap); // ?????????? v.destroyDrawingCache(); v.setWillNotCacheDrawing(willNotCache); v.setDrawingCacheBackgroundColor(color); return bitmap; }