List of usage examples for android.view View FOCUS_UP
int FOCUS_UP
To view the source code for android.view View FOCUS_UP.
Click Source Link
From source file:Main.java
/** * E.g. when using previous-next facility you need to make sure the scroll view's position is back at the top of the screen *//*w w w .j a v a 2s . c o m*/ public static void scrollToTop(int scrollViewId, Activity activity) { ScrollView sv = (ScrollView) activity.findViewById(scrollViewId); sv.fullScroll(View.FOCUS_UP); sv.setSmoothScrollingEnabled(true); }
From source file:org.mozilla.mozstumbler.client.subactivities.LogActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.scroll_to_start: this.mConsoleView.fullScroll(View.FOCUS_UP); return true; case R.id.scroll_to_end: this.mConsoleView.fullScroll(View.FOCUS_DOWN); return true; default:// w w w .java 2 s . c om return super.onOptionsItemSelected(item); } }
From source file:space.linuxdeveloper.osum.DisplayStatsActivity.java
/** * Perform fullScroll UP or DOWN/*from w ww . j ava 2 s . c om*/ */ public void onScrollViewChildClick(View v) { if (!mScrollView.fullScroll(View.FOCUS_DOWN)) mScrollView.fullScroll(View.FOCUS_UP); }
From source file:com.greatspeeches.slides.ScreenSlidePageFragment.java
public void update() { scroll.fullScroll(View.FOCUS_UP); if (mPersonObj.getType().equalsIgnoreCase("Popular") && !mPersonObj.getVideourl().contains("youtube")) { personImg.setVisibility(View.GONE); videoRel.setVisibility(View.VISIBLE); cVideoView.setVisibility(View.VISIBLE); cVideoView.setPlayPauseListener(new CustomVideoView.PlayPauseListener() { @Override//from w w w. ja v a2 s. c o m public void onPlay() { System.out.println("Play!"); } @Override public void onPause() { System.out.println("Pause!"); } }); cVideoView.setMediaController(new MediaController(getActivity())); cVideoView .setVideoURI(Uri.parse("android.resource://com.greatspeeches/raw/" + mPersonObj.getVideourl())); cVideoView.start(); cVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { public void onCompletion(MediaPlayer mp) { // finish(); // finish current activity closeVplayer(); } }); } else { playYutubeVideo(); } }
From source file:com.example.android.google.wearable.app.MainActivity.java
@Override public void onTimerFinished(View v) { Log.d(TAG, "onTimerFinished is called."); scroll(View.FOCUS_UP); }
From source file:com.example.android.google.wearable.app.MainActivity.java
@Override public void onTimerSelected(View v) { Log.d(TAG, "onTimerSelected is called."); scroll(View.FOCUS_UP); }
From source file:com.google.android.apps.location.gps.gnsslogger.LoggerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View newView = inflater.inflate(R.layout.fragment_log, container, false /* attachToRoot */); mLogView = (TextView) newView.findViewById(R.id.log_view); mScrollView = (ScrollView) newView.findViewById(R.id.log_scroll); getActivity().bindService(new Intent(getActivity(), TimerService.class), mConnection, Context.BIND_AUTO_CREATE); UiLogger currentUiLogger = mUiLogger; if (currentUiLogger != null) { currentUiLogger.setUiFragmentComponent(mUiComponent); }/*from w w w. ja va 2 s. co m*/ FileLogger currentFileLogger = mFileLogger; if (currentFileLogger != null) { currentFileLogger.setUiComponent(mUiComponent); } Button start = (Button) newView.findViewById(R.id.start_log); Button end = (Button) newView.findViewById(R.id.end_log); Button clear = (Button) newView.findViewById(R.id.clear_log); start.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { mScrollView.fullScroll(View.FOCUS_UP); } }); end.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { mScrollView.fullScroll(View.FOCUS_DOWN); } }); clear.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { mLogView.setText(""); } }); mTimerDisplay = (TextView) newView.findViewById(R.id.timer_display); mTimer = (Button) newView.findViewById(R.id.timer); mStartLog = (Button) newView.findViewById(R.id.start_logs); mSendFile = (Button) newView.findViewById(R.id.send_file); displayTimer(mTimerValues, false /* countdownStyle */); enableOptions(true /* start */); mStartLog.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { enableOptions(false /* start */); Toast.makeText(getContext(), R.string.start_message, Toast.LENGTH_LONG).show(); mFileLogger.startNewLog(); if (!mTimerValues.isZero() && (mTimerService != null)) { mTimerService.startTimer(); } } }); mSendFile.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { stopAndSend(); } }); mTimer.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { launchTimerDialog(); } }); return newView; }
From source file:com.moonpi.tapunlock.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get lobster_two asset and create typeface // Set action bar title to lobster_two typeface lobsterTwo = Typeface.createFromAsset(getAssets(), "lobster_two.otf"); int actionBarTitle = Resources.getSystem().getIdentifier("action_bar_title", "id", "android"); actionBarTitleView = (TextView) getWindow().findViewById(actionBarTitle); if (actionBarTitleView != null) { actionBarTitleView.setTypeface(lobsterTwo); actionBarTitleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 28f); actionBarTitleView.setTextColor(getResources().getColor(R.color.blue)); }//w w w .j av a 2 s.c o m setContentView(R.layout.activity_main); // Hide keyboard on app launch this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Get NFC service and adapter NfcManager nfcManager = (NfcManager) this.getSystemService(Context.NFC_SERVICE); nfcAdapter = nfcManager.getDefaultAdapter(); // Create PendingIntent for enableForegroundDispatch for NFC tag discovery pIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); readFromJSON(); writeToJSON(); readFromJSON(); // If Android 4.2 or bigger if (Build.VERSION.SDK_INT > 16) { // Check if TapUnlock folder exists, if not, create directory File folder = new File(Environment.getExternalStorageDirectory() + "/TapUnlock"); boolean folderSuccess = true; if (!folder.exists()) { folderSuccess = folder.mkdir(); } try { // If blur var bigger than 0 if (settings.getInt("blur") > 0) { // If folder exists or successfully created if (folderSuccess) { // If blurred wallpaper file doesn't exist if (!ImageUtils.doesBlurredWallpaperExist()) { // Get default wallpaper WallpaperManager wallpaperManager = WallpaperManager.getInstance(this); final Drawable wallpaperDrawable = wallpaperManager.peekFastDrawable(); if (wallpaperDrawable != null) { // Default wallpaper to bitmap - fastBlur the bitmap - store bitmap new Thread(new Runnable() { @Override public void run() { Bitmap bitmapToBlur = ImageUtils.drawableToBitmap(wallpaperDrawable); Bitmap blurredWallpaper = null; if (bitmapToBlur != null) blurredWallpaper = ImageUtils.fastBlur(MainActivity.this, bitmapToBlur, blur); if (blurredWallpaper != null) { ImageUtils.storeImage(blurredWallpaper); } } }).start(); } } } } } catch (JSONException e) { e.printStackTrace(); } } // Initialize layout items pinEdit = (EditText) findViewById(R.id.pinEdit); pinEdit.setImeOptions(EditorInfo.IME_ACTION_DONE); Button setPin = (Button) findViewById(R.id.setPin); ImageButton newTag = (ImageButton) findViewById(R.id.newTag); enabled_disabled = (TextView) findViewById(R.id.enabled_disabled); Switch toggle = (Switch) findViewById(R.id.toggle); seekBar = (SeekBar) findViewById(R.id.seekBar); progressBar = (ProgressBar) findViewById(R.id.progressBar); Button refreshWallpaper = (Button) findViewById(R.id.refreshWallpaper); listView = (ListView) findViewById(R.id.listView); backgroundBlurValue = (TextView) findViewById(R.id.backgroundBlurValue); noTags = (TextView) findViewById(R.id.noTags); // Initialize TagAdapter adapter = new TagAdapter(this, tags); registerForContextMenu(listView); // Set listView adapter to TapAdapter object listView.setAdapter(adapter); // Set click, check and seekBar listeners setPin.setOnClickListener(this); newTag.setOnClickListener(this); refreshWallpaper.setOnClickListener(this); toggle.setOnCheckedChangeListener(this); seekBar.setOnSeekBarChangeListener(this); // Set seekBar progress to blur var try { seekBar.setProgress(settings.getInt("blur")); } catch (JSONException e) { e.printStackTrace(); } // Refresh the listView height updateListViewHeight(listView); // If no tags, show 'Press + to add Tags' textView if (tags.length() == 0) noTags.setVisibility(View.VISIBLE); else noTags.setVisibility(View.INVISIBLE); // Scroll up scrollView = (ScrollView) findViewById(R.id.scrollView); scrollView.post(new Runnable() { public void run() { scrollView.scrollTo(0, scrollView.getTop()); scrollView.fullScroll(View.FOCUS_UP); } }); // If lockscreen enabled, initialize switch, text and start service try { if (settings.getBoolean("lockscreen")) { onStart = true; enabled_disabled.setText(R.string.lockscreen_enabled); enabled_disabled.setTextColor(getResources().getColor(R.color.green)); toggle.setChecked(true); } } catch (JSONException e1) { e1.printStackTrace(); } }
From source file:com.hippo.widget.BothScrollView.java
/** * You can call this function yourself to have the scroll view perform * scrolling from a key event, just as if the event had been dispatched to * it by the view hierarchy./* w w w . j a v a 2s . co m*/ * * @param event The key event to execute. * @return Return true if the event was handled, else false. */ public boolean executeKeyEvent(KeyEvent event) { mTempRect.setEmpty(); if (!canScrollHorizontally()) { if (isFocused() && event.getKeyCode() != KeyEvent.KEYCODE_BACK) { View currentFocused = findFocus(); if (currentFocused == this) { currentFocused = null; } View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, View.FOCUS_RIGHT); return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_RIGHT); } return false; } if (!canScrollVertically()) { if (isFocused() && event.getKeyCode() != KeyEvent.KEYCODE_BACK) { View currentFocused = findFocus(); if (currentFocused == this) { currentFocused = null; } View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, View.FOCUS_DOWN); return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_DOWN); } return false; } boolean handled = false; if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_DPAD_LEFT: if (!event.isAltPressed()) { handled = arrowScrollHorizontally(View.FOCUS_LEFT); } else { handled = fullScroll(View.FOCUS_LEFT); } break; case KeyEvent.KEYCODE_DPAD_RIGHT: if (!event.isAltPressed()) { handled = arrowScrollHorizontally(View.FOCUS_RIGHT); } else { handled = fullScroll(View.FOCUS_RIGHT); } break; case KeyEvent.KEYCODE_DPAD_UP: if (!event.isAltPressed()) { handled = arrowScrollVertically(View.FOCUS_UP); } else { handled = fullScroll(View.FOCUS_UP); } break; case KeyEvent.KEYCODE_DPAD_DOWN: if (!event.isAltPressed()) { handled = arrowScrollVertically(View.FOCUS_DOWN); } else { handled = fullScroll(View.FOCUS_DOWN); } break; case KeyEvent.KEYCODE_SPACE: if (event.isCtrlPressed()) { pageScroll(event.isShiftPressed() ? View.FOCUS_LEFT : View.FOCUS_RIGHT); } else { pageScroll(event.isShiftPressed() ? View.FOCUS_UP : View.FOCUS_DOWN); } break; } } return handled; }
From source file:com.hxqc.mall.thirdshop.views.CustomScrollView.java
/** * You can call this function yourself to have the scroll view perform * scrolling from a key event, just as if the event had been dispatched to * it by the view hierarchy.// w w w .j av a 2s.c om * * @param event The key event to execute. * @return Return true if the event was handled, else false. */ public boolean executeKeyEvent(KeyEvent event) { mTempRect.setEmpty(); if (!canScroll()) { if (isFocused() && event.getKeyCode() != KeyEvent.KEYCODE_BACK) { View currentFocused = findFocus(); if (currentFocused == this) currentFocused = null; View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, View.FOCUS_DOWN); return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_DOWN); } return false; } boolean handled = false; if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_DPAD_UP: if (!event.isAltPressed()) { handled = arrowScroll(View.FOCUS_UP); } else { handled = fullScroll(View.FOCUS_UP); } break; case KeyEvent.KEYCODE_DPAD_DOWN: if (!event.isAltPressed()) { handled = arrowScroll(View.FOCUS_DOWN); } else { handled = fullScroll(View.FOCUS_DOWN); } break; case KeyEvent.KEYCODE_SPACE: pageScroll(event.isShiftPressed() ? View.FOCUS_UP : View.FOCUS_DOWN); break; default: break; } } return handled; }