jimu-decompiled/sources/com/ubt/jimu/ScreenRotationManageActivity.java
2025-05-13 19:24:51 +02:00

107 lines
3.8 KiB
Java

package com.ubt.jimu;
import android.content.ContentResolver;
import android.database.ContentObserver;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
import androidx.appcompat.app.AppCompatActivity;
import com.ubt.jimu.utils.LogUtils;
import com.ubt.jimu.utils.UiUtils;
import com.ubtrobot.log.ALog;
/* loaded from: classes.dex */
public class ScreenRotationManageActivity extends AppCompatActivity {
private static final String TAG = "BaseActivity";
private String mCurrentName;
private RotationObserver mRotationObserver;
private class RotationObserver extends ContentObserver {
ContentResolver a;
public RotationObserver(Handler handler) {
super(handler);
this.a = ScreenRotationManageActivity.this.getContentResolver();
}
public void a() {
try {
if (Settings.System.getInt(ScreenRotationManageActivity.this.getContentResolver(), "accelerometer_rotation") == 1) {
ScreenRotationManageActivity.this.setRequestedOrientation(6);
} else {
ScreenRotationManageActivity.this.setRequestedOrientation(0);
}
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
this.a.registerContentObserver(Settings.System.getUriFor("accelerometer_rotation"), false, this);
}
public void b() {
this.a.unregisterContentObserver(this);
}
@Override // android.database.ContentObserver
public void onChange(boolean z) {
super.onChange(z);
LogUtils.c("selfChange:" + z);
try {
int i = Settings.System.getInt(this.a, "accelerometer_rotation");
LogUtils.c("screenchange:" + i);
if (i == 1) {
ScreenRotationManageActivity.this.setRequestedOrientation(6);
} else {
ScreenRotationManageActivity.this.setRequestedOrientation(0);
}
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
}
}
@Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.core.app.ComponentActivity, android.app.Activity
protected void onCreate(Bundle bundle) {
if (Build.VERSION.SDK_INT >= 26 && UiUtils.b(this)) {
UiUtils.a(this);
}
super.onCreate(bundle);
this.mRotationObserver = new RotationObserver(new Handler());
this.mCurrentName = toString();
ALog.a(TAG).d(this.mCurrentName + "OnCreate");
}
@Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
protected void onDestroy() {
super.onDestroy();
this.mRotationObserver.b();
ALog.a(TAG).d(this.mCurrentName + "OnDestroy");
}
@Override // androidx.fragment.app.FragmentActivity, android.app.Activity
protected void onPause() {
super.onPause();
ALog.a(TAG).d(this.mCurrentName + "OnPause");
}
@Override // androidx.fragment.app.FragmentActivity, android.app.Activity
protected void onResume() {
super.onResume();
this.mRotationObserver.a();
ALog.a(TAG).d(this.mCurrentName + "OnResume");
}
@Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
protected void onStop() {
super.onStop();
ALog.a(TAG).d(this.mCurrentName + "OnStop");
}
@Override // android.app.Activity
public void setRequestedOrientation(int i) {
if (Build.VERSION.SDK_INT < 26 || !UiUtils.b(this)) {
super.setRequestedOrientation(i);
}
}
}