mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
put keepScreenOn together getActivity()
This commit is contained in:
@@ -203,17 +203,6 @@ public class AudioSlidePlayer {
|
||||
.createMediaSource(uri);
|
||||
}
|
||||
|
||||
public void keepScreenOn(boolean keepOn) {
|
||||
Activity activity = getActivity(context);
|
||||
if (activity != null) {
|
||||
if (keepOn) {
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
} else {
|
||||
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void stop() {
|
||||
Log.i(TAG, "Stop called!");
|
||||
|
||||
@@ -303,6 +292,17 @@ public class AudioSlidePlayer {
|
||||
};
|
||||
}
|
||||
|
||||
public void keepScreenOn(boolean keepOn) {
|
||||
Activity activity = getActivity(context);
|
||||
if (activity != null) {
|
||||
if (keepOn) {
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
} else {
|
||||
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Activity getActivity(Context context) {
|
||||
if (context == null) return null;
|
||||
if (context instanceof Activity) return (Activity) context;
|
||||
|
||||
Reference in New Issue
Block a user