Initial commit
This commit is contained in:
234
sources/com/ubt/jimu/BaseActivity.java
Normal file
234
sources/com/ubt/jimu/BaseActivity.java
Normal file
@@ -0,0 +1,234 @@
|
||||
package com.ubt.jimu;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import com.recyclelib.URecyclerView;
|
||||
import com.ubt.jimu.base.http.ApiObserver;
|
||||
import com.ubt.jimu.base.http.manager.Manager;
|
||||
import com.ubt.jimu.base.networkstate.NetworkStateObserver;
|
||||
import com.ubt.jimu.base.networkstate.NetworkType;
|
||||
import com.ubt.jimu.utils.InputMethod;
|
||||
import com.ubt.jimu.widgets.JAlertDialog;
|
||||
import com.ubtech.utils.DensityUtils;
|
||||
import com.ubtech.view.widget.ToastView;
|
||||
import com.ubtrobot.log.ALog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class BaseActivity extends ScreenRotationManageActivity implements DeviceStateListener, NetworkStateObserver {
|
||||
private String mActivityJumpTag;
|
||||
private long mClickTime;
|
||||
protected JAlertDialog mJAlertDialog;
|
||||
public NavigationBarStatusListener navigationBarStatusListener;
|
||||
protected final String TAG = getClass().getSimpleName();
|
||||
private int orientation = -1;
|
||||
private int navigationBarHeight = 0;
|
||||
|
||||
public interface NavigationBarStatusListener {
|
||||
}
|
||||
|
||||
static /* synthetic */ void a(URecyclerView uRecyclerView, Throwable th) {
|
||||
uRecyclerView.y();
|
||||
uRecyclerView.A();
|
||||
}
|
||||
|
||||
protected boolean checkDoubleClick(Intent intent) {
|
||||
String action;
|
||||
boolean z = true;
|
||||
if (intent.getComponent() == null) {
|
||||
if (intent.getAction() != null) {
|
||||
action = intent.getAction();
|
||||
}
|
||||
return z;
|
||||
}
|
||||
action = intent.getComponent().getClassName();
|
||||
if (action.equals(this.mActivityJumpTag) && this.mClickTime >= SystemClock.uptimeMillis() - 250) {
|
||||
z = false;
|
||||
Log.e(this.TAG, "double fast call startActivity to a same activity, ignore this call.");
|
||||
}
|
||||
this.mActivityJumpTag = action;
|
||||
this.mClickTime = SystemClock.uptimeMillis();
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override // android.app.Activity, android.view.Window.Callback
|
||||
public boolean dispatchTouchEvent(MotionEvent motionEvent) {
|
||||
if (motionEvent.getAction() == 0 && InputMethod.a(getCurrentFocus(), motionEvent)) {
|
||||
InputMethod.a(this);
|
||||
}
|
||||
return super.dispatchTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public float[] getRatios() {
|
||||
int[] a = DensityUtils.a(this);
|
||||
return new float[]{Math.max(a[0], a[1]) / 1536.0f, Math.min(a[0], a[1]) / 2048.0f};
|
||||
}
|
||||
|
||||
public int getScreenHeight() {
|
||||
int[] a = DensityUtils.a(this);
|
||||
return Math.min(a[0], a[1]);
|
||||
}
|
||||
|
||||
public int getScreenWidth() {
|
||||
int[] a = DensityUtils.a(this);
|
||||
return Math.max(a[0], a[1]) + this.navigationBarHeight;
|
||||
}
|
||||
|
||||
protected void hideLoading() {
|
||||
JAlertDialog jAlertDialog = this.mJAlertDialog;
|
||||
if (jAlertDialog == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
jAlertDialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isHorizontal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void loadComplete(final URecyclerView uRecyclerView, ApiObserver apiObserver) {
|
||||
if (uRecyclerView == null || apiObserver == null) {
|
||||
return;
|
||||
}
|
||||
apiObserver.setNetErrorListener(new ApiObserver.NetErrorListener() { // from class: com.ubt.jimu.b
|
||||
@Override // com.ubt.jimu.base.http.ApiObserver.NetErrorListener
|
||||
public final void onError(Throwable th) {
|
||||
BaseActivity.a(URecyclerView.this, th);
|
||||
}
|
||||
});
|
||||
apiObserver.setRequestComplete(new ApiObserver.RequestComplete() { // from class: com.ubt.jimu.a
|
||||
@Override // com.ubt.jimu.base.http.ApiObserver.RequestComplete
|
||||
public final void onComplete() {
|
||||
BaseActivity.a(URecyclerView.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onCharging() {
|
||||
ALog.a(this.TAG).d("Jimu Robot:onCharging");
|
||||
}
|
||||
|
||||
public void onConnected() {
|
||||
ALog.a(this.TAG).d("Jimu Robot:onConnected");
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.core.app.ComponentActivity, android.app.Activity
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onDestroy() {
|
||||
Manager.mList.clear();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public void onDisConnected() {
|
||||
ALog.a(this.TAG).d("Jimu Robot:onFail");
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.app.AppCompatActivity, android.app.Activity, android.view.KeyEvent.Callback
|
||||
public boolean onKeyDown(int i, KeyEvent keyEvent) {
|
||||
if (i == 111) {
|
||||
onBackPressed();
|
||||
}
|
||||
return super.onKeyDown(i, keyEvent);
|
||||
}
|
||||
|
||||
public void onLowpower() {
|
||||
ALog.a(this.TAG).d("Jimu Robot:onLowpower");
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.networkstate.NetworkStateObserver
|
||||
public void onNetworkConnected(NetworkType networkType) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.networkstate.NetworkStateObserver
|
||||
public void onNetworkDisconnected() {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
JimuApplication.l().a();
|
||||
}
|
||||
|
||||
protected void relayout() {
|
||||
}
|
||||
|
||||
public void setNavigationBarStatusListener(NavigationBarStatusListener navigationBarStatusListener) {
|
||||
this.navigationBarStatusListener = navigationBarStatusListener;
|
||||
}
|
||||
|
||||
protected void showLoading(String str) {
|
||||
JAlertDialog jAlertDialog = this.mJAlertDialog;
|
||||
if (jAlertDialog == null) {
|
||||
JAlertDialog.Builder builder = new JAlertDialog.Builder(this);
|
||||
builder.a(R.drawable.ic_loading);
|
||||
builder.a(str);
|
||||
builder.a(true);
|
||||
this.mJAlertDialog = builder.a();
|
||||
} else {
|
||||
jAlertDialog.a(str);
|
||||
}
|
||||
this.mJAlertDialog.show();
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
@SuppressLint({"RestrictedApi"})
|
||||
public void startActivityForResult(Intent intent, int i, Bundle bundle) {
|
||||
if (checkDoubleClick(intent)) {
|
||||
super.startActivityForResult(intent, i, bundle);
|
||||
}
|
||||
}
|
||||
|
||||
public void startActivityForResultWithAnim(Intent intent, int i) {
|
||||
startActivityForResult(intent, i);
|
||||
overridePendingTransition(R.anim.slide_in_from_right, R.anim.slide_out_from_left);
|
||||
}
|
||||
|
||||
public void startActivityWithAnim(Class<?> cls) {
|
||||
startActivityWithAnim(new Intent(this, cls));
|
||||
}
|
||||
|
||||
public void toast(String str) {
|
||||
ToastView.a(JimuApplication.k, str, ToastView.Type.NORMAL).a();
|
||||
}
|
||||
|
||||
public void toastError(String str) {
|
||||
ToastView.a(JimuApplication.k, str, ToastView.Type.ERROR).a();
|
||||
}
|
||||
|
||||
public void toastSuccess(String str) {
|
||||
ToastView.a(JimuApplication.k, str, ToastView.Type.SUCCESS).a();
|
||||
}
|
||||
|
||||
static /* synthetic */ void a(URecyclerView uRecyclerView) {
|
||||
uRecyclerView.y();
|
||||
uRecyclerView.A();
|
||||
}
|
||||
|
||||
public void startActivityWithAnim(Intent intent) {
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.slide_in_from_right, R.anim.slide_out_from_left);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user