@Override public void run() { if ((SystemClock.uptimeMillis() - lastActivity) > TIMEOUT_PERIOD) { content.setKeepScreenOn(false); } content.postDelayed(this, TIMEOUT_POLL_PERIOD); }
@Override public void onBuffering() { super.onBuffering(); getRootView().setKeepScreenOn(true); }
@Override public void onBlocked() { super.onBlocked(); playPauseButton.setImageResource(R.drawable.ic_pause_white); animatePlayButtons(false, 100); getRootView().setKeepScreenOn(true); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); content=findViewById(android.R.id.content); content.setKeepScreenOn(true); run(); }
@Override public void initViews(View rootView) { super.initViews(rootView); this.titleTextView = rootView.findViewById(R.id.titleTextView); this.channelTextView = rootView.findViewById(R.id.channelTextView); this.volumeRelativeLayout = rootView.findViewById(R.id.volumeRelativeLayout); this.volumeProgressBar = rootView.findViewById(R.id.volumeProgressBar); this.volumeImageView = rootView.findViewById(R.id.volumeImageView); this.brightnessRelativeLayout = rootView.findViewById(R.id.brightnessRelativeLayout); this.brightnessProgressBar = rootView.findViewById(R.id.brightnessProgressBar); this.brightnessImageView = rootView.findViewById(R.id.brightnessImageView); this.queueButton = rootView.findViewById(R.id.queueButton); this.repeatButton = rootView.findViewById(R.id.repeatButton); this.shuffleButton = rootView.findViewById(R.id.shuffleButton); this.playPauseButton = rootView.findViewById(R.id.playPauseButton); this.playPreviousButton = rootView.findViewById(R.id.playPreviousButton); this.playNextButton = rootView.findViewById(R.id.playNextButton); this.moreOptionsButton = rootView.findViewById(R.id.moreOptionsButton); this.secondaryControls = rootView.findViewById(R.id.secondaryControls); this.toggleOrientationButton = rootView.findViewById(R.id.toggleOrientation); this.switchBackgroundButton = rootView.findViewById(R.id.switchBackground); this.switchPopupButton = rootView.findViewById(R.id.switchPopup); this.queueLayout = findViewById(R.id.playQueuePanel); this.itemsListCloseButton = findViewById(R.id.playQueueClose); this.itemsList = findViewById(R.id.playQueue); titleTextView.setSelected(true); channelTextView.setSelected(true); getRootView().setKeepScreenOn(true); }
@Override public void onCompleted() { animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 0, 0, () -> { playPauseButton.setImageResource(R.drawable.ic_replay_white); animatePlayButtons(true, DEFAULT_CONTROLS_DURATION); }); getRootView().setKeepScreenOn(false); super.onCompleted(); }
@Override public void onPausedSeek() { super.onPausedSeek(); animatePlayButtons(false, 100); getRootView().setKeepScreenOn(true); }
@Override public void onPlaying() { super.onPlaying(); animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 80, 0, () -> { playPauseButton.setImageResource(R.drawable.ic_pause_white); animatePlayButtons(true, 200); }); getRootView().setKeepScreenOn(true); }
@Override public void onPaused() { super.onPaused(); animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 80, 0, () -> { playPauseButton.setImageResource(R.drawable.ic_play_arrow_white); animatePlayButtons(true, 200); }); showSystemUi(); getRootView().setKeepScreenOn(false); }
private void mySetVisibility(View v, int visibility) { v.setVisibility(visibility); if (visibility == View.GONE) { v.setKeepScreenOn(false); } else { v.setKeepScreenOn(true); } }
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { View view = viewToKeepScreenOn.get(); if (view == null) { return; } if (playbackState == Player.STATE_IDLE || playbackState == Player.STATE_ENDED || !playWhenReady) { view.setKeepScreenOn(false); } else { // This prevents the screen from getting dim/lock view.setKeepScreenOn(true); } } }
View view = ...; // I guess something with findViewById() happens here view.setVisibility(View.GONE); view.setKeepScreenOn(false); ... view.setVisibility(View.VISIBLE); view.setKeepScreenOn(true);
public void run(RapidParserObject object, Object view, Var value) { ((View)view).setKeepScreenOn(value.getBoolean()); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // prevent the screen going to sleep while app is on foreground findViewById(android.R.id.content).setKeepScreenOn(true); // instantiate IALocationManager mIALocationManager = IALocationManager.create(this); }
private void setKeepScreenOn(boolean keepOn) { getScreenOnView().setKeepScreenOn(keepOn); if (keepOn) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } else { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); // prevent the screen going to sleep while app is on foreground findViewById(android.R.id.content).setKeepScreenOn(true); // instantiate IALocationManager mIALocationManager = IALocationManager.create(this); // disable indoor-outdoor detection (assume we're indoors) mIALocationManager.lockIndoors(true); // Request GPS locations if (ActivityCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, MY_PERMISSION_ACCESS_FINE_LOCATION); return; } // Try to obtain the map from the SupportMapFragment. ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map)) .getMapAsync(this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); // prevent the screen going to sleep while app is on foreground findViewById(android.R.id.content).setKeepScreenOn(true); // instantiate IALocationManager mIALocationManager = IALocationManager.create(this); startListeningPlatformLocations(); // Try to obtain the map from the SupportMapFragment. ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map)) .getMapAsync(this); }
trackLoggerView.setKeepScreenOn(prefs.getBoolean(OSMTracker.Preferences.KEY_UI_DISPLAY_KEEP_ON, OSMTracker.Preferences.VAL_UI_DISPLAY_KEEP_ON));
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_image_view); // prevent the screen going to sleep while app is on foreground findViewById(android.R.id.content).setKeepScreenOn(true); mImageView = (BlueDotView) findViewById(R.id.imageView); mDownloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); mIALocationManager = IALocationManager.create(this); /* optional setup of floor plan id if setLocation is not called, then location manager tries to find location automatically */ final String floorPlanId = getString(R.string.indooratlas_floor_plan_id); if (!TextUtils.isEmpty(floorPlanId)) { final IALocation location = IALocation.from(IARegion.floorPlan(floorPlanId)); mIALocationManager.setLocation(location); } // Setup long click listener for sharing traceId ExampleUtils.shareTraceId(findViewById(R.id.imageView), ImageViewActivity.this, mIALocationManager); }
activity.view.getView().setKeepScreenOn(newSettings.keepScreenOn);