List of usage examples for android.view View setKeepScreenOn
public void setKeepScreenOn(boolean keepScreenOn)
From source file:net.zionsoft.obadiah.ui.activities.SearchActivity.java
private void populateUi() { settings.refresh();/*w w w. j a va2 s. c o m*/ final View rootView = getWindow().getDecorView(); rootView.setKeepScreenOn(settings.keepScreenOn()); rootView.setBackgroundColor(settings.getBackgroundColor()); final String selected = getSharedPreferences(Constants.PREF_NAME, MODE_PRIVATE) .getString(Constants.PREF_KEY_LAST_READ_TRANSLATION, null); setTitle(selected); if (!selected.equals(nonConfigurationData.currentTranslation)) { nonConfigurationData.currentTranslation = selected; searchResultListAdapter.setVerses(null); } searchResultListAdapter.notifyDataSetChanged(); }
From source file:es.rgmf.libresportgps.MainActivity.java
/** * This method is called when this activity is created. *//* w w w. ja v a 2 s . co m*/ @Override protected void onCreate(Bundle savedInstanceState) { /*************** * To create a copy of the database ***************** try { File * dbInFile = getDatabasePath("libresportgps.db"); File dbOutFile = new * File(Environment.getExternalStorageDirectory().getAbsolutePath() + * "/copy_libresportgps.db"); InputStream in = new * FileInputStream(dbInFile); OutputStream out = new * FileOutputStream(dbOutFile); * * // Transfer bytes from in to out byte[] buf = new byte[1024]; int * len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } * in.close(); out.close(); } catch (FileNotFoundException e) { // TODO * Auto-generated catch block e.printStackTrace(); } catch (IOException * e) { // TODO Auto-generated catch block e.printStackTrace(); } End to * create a copy of the database **************/ super.onCreate(savedInstanceState); if (mFragmentManager == null) { mFragmentManager = getFragmentManager(); } setContentView(R.layout.activity_main); serviceIntent = new Intent(this, GpsLoggerService.class); mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager() .findFragmentById(R.id.navigation_drawer); mTitle = getTitle(); // Set up the drawer. mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); // Check if external storage is available. checkExternalStorage(); // Set LibreSportGPS to keepScreenOn. View libresportgpsView = findViewById(R.id.drawer_layout); libresportgpsView.setKeepScreenOn(true); // Check GPS status provider to show a message if GPS is disabled. this.checkGpsProvider(); }
From source file:com.android.gpstest.GpsTestActivity.java
private void checkKeepScreenOn(SharedPreferences settings) { if (mViewPager != null) { if (settings.getBoolean(getString(R.string.pref_key_keep_screen_on), true)) { mViewPager.setKeepScreenOn(true); } else {/*w w w. j av a2 s . com*/ mViewPager.setKeepScreenOn(false); } } else { View v = findViewById(R.id.large_screen_layout); if (v != null && mIsLargeScreen) { if (settings.getBoolean(getString(R.string.pref_key_keep_screen_on), true)) { v.setKeepScreenOn(true); } else { v.setKeepScreenOn(false); } } } }
From source file:com.google.android.apps.santatracker.games.matching.MemoryMatchFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_memory_match, container, false); rootView.setKeepScreenOn(true); // Below ICS, display a special, simplified background for the entire fragment if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { rootView.findViewById(R.id.match_score_layout) .setBackgroundResource(R.drawable.score_background_gingerbread); }//from www.j av a2s. co m // Initialise the sound pool and all sound effects mSoundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); mSoundDoorOpen = mSoundPool.load(getActivity(), R.raw.mmg_open_door_3, 1); mSoundDoorClose = mSoundPool.load(getActivity(), R.raw.mmg_close_door, 1); mSoundMatchWrong = mSoundPool.load(getActivity(), R.raw.mmg_wrong, 1); mSoundMatchRight = mSoundPool.load(getActivity(), R.raw.mmg_right, 1); mSoundGameOver = mSoundPool.load(getActivity(), R.raw.gameover, 1); mSoundBeep = mSoundPool.load(getActivity(), R.raw.mmg_open_door_2, 1); // Set up all animations. loadAnimations(); // G+ sign-in views mViewGPlusSignIn = (ImageView) rootView.findViewById(R.id.gplus_button); mViewGPlusSignIn.setOnClickListener(this); mLayoutGPlus = rootView.findViewById(R.id.play_again_gplus); mLayoutGPlus.setVisibility(View.GONE); // 'Play again' screen views mTextPlayAgainScore = (TextView) rootView.findViewById(R.id.play_again_score); mTextPlayAgainScore.setText(String.valueOf(mMatchScore)); mTextPlayAgainLevel = (TextView) rootView.findViewById(R.id.play_again_level); mTextPlayAgainLevel.setText(String.valueOf(mLevelNumber)); mViewPlayAgainBackground = rootView.findViewById(R.id.play_again_bkgrd); mViewPlayAgainMain = rootView.findViewById(R.id.play_again_main); mPlayAgainBtn = (Button) rootView.findViewById(R.id.play_again_btn); mPlayAgainBtn.setOnClickListener(this); // Level, countdown and score views at the bottom of the screen mTimerTextView = (TextView) rootView.findViewById(R.id.match_timer); mLevelNumberText = (LevelTextView) rootView.findViewById(R.id.card_end_level_number); mLevelNumberText.setVisibility(View.GONE); mScoreText = (TextView) rootView.findViewById(R.id.match_score); mScoreText.setText(String.valueOf(mMatchScore)); // End of level animated circle mEndLevelCircle = (CircleView) rootView.findViewById(R.id.card_end_level_circle); mEndLevelCircle.setVisibility(View.GONE); // The snowman that is animated as a bonus when the player is particularly awesome mViewBonusSnowman = rootView.findViewById(R.id.match_snowman); // 'Pause' screen views mButtonMenu = (ImageButton) rootView.findViewById(R.id.main_menu_button); mButtonMenu.setOnClickListener(this); mButtonMenu.setVisibility(View.GONE); mButtonPlay = (ImageView) rootView.findViewById(R.id.match_play_button); mButtonPlay.setOnClickListener(this); mButtonPlay.setVisibility(View.GONE); mButtonPause = (ImageView) rootView.findViewById(R.id.match_pause_button); mButtonPause.setOnClickListener(this); mButtonPause.setVisibility(View.VISIBLE); mViewPauseOverlay = rootView.findViewById(R.id.match_pause_overlay); mViewPauseOverlay.setVisibility(View.GONE); mButtonBigPlay = (ImageButton) rootView.findViewById(R.id.match_big_play_button); mButtonBigPlay.setOnClickListener(this); mButtonCancelBar = (ImageButton) rootView.findViewById(R.id.match_cancel_bar); mButtonCancelBar.setOnClickListener(this); mButtonCancelBar.setVisibility(View.GONE); // Playing cards (doors) mViewCard[0] = rootView.findViewById(R.id.card_position_1); mViewCard[1] = rootView.findViewById(R.id.card_position_2); mViewCard[2] = rootView.findViewById(R.id.card_position_3); mViewCard[3] = rootView.findViewById(R.id.card_position_4); mViewCard[4] = rootView.findViewById(R.id.card_position_5); mViewCard[5] = rootView.findViewById(R.id.card_position_6); mViewCard[6] = rootView.findViewById(R.id.card_position_7); mViewCard[7] = rootView.findViewById(R.id.card_position_8); mViewCard[8] = rootView.findViewById(R.id.card_position_9); mViewCard[9] = rootView.findViewById(R.id.card_position_10); mViewCard[10] = rootView.findViewById(R.id.card_position_11); mViewCard[11] = rootView.findViewById(R.id.card_position_12); // Display the instructions if they haven't been seen by the player yet. mPreferences = getActivity().getSharedPreferences(MatchingGameConstants.PREFERENCES_FILENAME, Context.MODE_PRIVATE); if (!mPreferences.getBoolean(MatchingGameConstants.MATCH_INSTRUCTIONS_VIEWED, false)) { // Instructions haven't been viewed yet. Construct an AnimationDrawable with instructions. mInstructionDrawable = new AnimationDrawable(); mInstructionDrawable.addFrame(getResources().getDrawable(R.drawable.instructions_touch_1), 300); mInstructionDrawable.addFrame(getResources().getDrawable(R.drawable.instructions_touch_2), 300); mInstructionDrawable.setOneShot(false); mViewInstructions = (ImageView) rootView.findViewById(R.id.instructions); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { mViewInstructions.setImageResource(R.drawable.instructions_touch_1); } else { mViewInstructions.setImageDrawable(mInstructionDrawable); mInstructionDrawable.start(); } // Set a timer to hide the instructions after 2 seconds mViewInstructions.postDelayed(new StartGameDelay(), 2000); } else { //Instructions have already been viewed. Start the first level. setUpLevel(); } return rootView; }
From source file:com.evandroid.musica.fragment.LyricsViewFragment.java
public void checkPreferencesChanges() { boolean screenOn = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getBoolean("pref_force_screen_on", false); boolean dyslexic = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getBoolean("pref_opendyslexic", false); TextSwitcher switcher = (TextSwitcher) getActivity().findViewById(R.id.switcher); View lrcView = getActivity().findViewById(R.id.lrc_view); if (switcher != null) { switcher.setKeepScreenOn(screenOn); if (switcher.getCurrentView() != null) ((TextView) switcher.getCurrentView()).setTypeface( LyricsTextFactory.FontCache.get(dyslexic ? "dyslexic" : "light", getActivity())); View nextView = switcher.getNextView(); if (nextView != null) { ((TextView) nextView).setTypeface( LyricsTextFactory.FontCache.get(dyslexic ? "dyslexic" : "light", getActivity())); }//from www .j a va 2s. c o m } if (lrcView != null) lrcView.setKeepScreenOn(screenOn); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); TypedValue outValue = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.themeName, outValue, false); if ("Night".equals(outValue.string) != NightTimeVerifier.check(getActivity()) || "Dark".equals(outValue.string) == sharedPrefs.getString("pref_theme", "0").equals("0")) { getActivity().finish(); Intent intent = new Intent(getActivity(), MainLyricActivity.class); intent.setAction("android.intent.action.MAIN"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } }
From source file:com.geecko.QuickLyric.fragment.LyricsViewFragment.java
public void checkPreferencesChanges() { boolean screenOn = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getBoolean("pref_force_screen_on", false); boolean dyslexic = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getBoolean("pref_opendyslexic", false); TextSwitcher switcher = (TextSwitcher) getActivity().findViewById(R.id.switcher); View lrcView = getActivity().findViewById(R.id.lrc_view); if (switcher != null) { switcher.setKeepScreenOn(screenOn); if (switcher.getCurrentView() != null) ((TextView) switcher.getCurrentView()).setTypeface( LyricsTextFactory.FontCache.get(dyslexic ? "dyslexic" : "light", getActivity())); View nextView = switcher.getNextView(); if (nextView != null) { ((TextView) nextView).setTypeface( LyricsTextFactory.FontCache.get(dyslexic ? "dyslexic" : "light", getActivity())); }// w w w.j av a 2 s.c o m } if (lrcView != null) lrcView.setKeepScreenOn(screenOn); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); TypedValue outValue = new TypedValue(); MainActivity mainActivity = (MainActivity) getActivity(); mainActivity.getTheme().resolveAttribute(R.attr.themeName, outValue, false); if ("Night".equals(outValue.string) != NightTimeVerifier.check(getActivity()) || mainActivity.themeNum != Integer.valueOf(sharedPrefs.getString("pref_theme", "0"))) { getActivity().finish(); Intent intent = new Intent(getActivity(), MainActivity.class); intent.setAction("android.intent.action.MAIN"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); getActivity().overridePendingTransition(0, 0); } }
From source file:com.dish.browser.activity.BrowserActivity.java
@Override public void onShowCustomView(View view, int requestedOrientation, CustomViewCallback callback) { if (view == null) { return;/*from w w w .j a va 2 s . c o m*/ } if (mCustomView != null && callback != null) { callback.onCustomViewHidden(); return; } try { view.setKeepScreenOn(true); } catch (SecurityException e) { Log.e(Constants.TAG, "WebView is not allowed to keep the screen on"); } mOriginalOrientation = getRequestedOrientation(); FrameLayout decor = (FrameLayout) getWindow().getDecorView(); mFullscreenContainer = new FullscreenHolder(this); mCustomView = view; mFullscreenContainer.addView(mCustomView, COVER_SCREEN_PARAMS); decor.addView(mFullscreenContainer, COVER_SCREEN_PARAMS); setFullscreen(true); mCurrentView.setVisibility(View.GONE); if (view instanceof FrameLayout) { if (((FrameLayout) view).getFocusedChild() instanceof VideoView) { mVideoView = (VideoView) ((FrameLayout) view).getFocusedChild(); mVideoView.setOnErrorListener(new VideoCompletionListener()); mVideoView.setOnCompletionListener(new VideoCompletionListener()); } } mCustomViewCallback = callback; }