178 lines
6.8 KiB
Java
178 lines
6.8 KiB
Java
package com.ubt.jimu.connect;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.util.Log;
|
|
import android.view.KeyEvent;
|
|
import android.view.MotionEvent;
|
|
import androidx.fragment.app.FragmentTransaction;
|
|
import com.ubt.jimu.BaseActivity;
|
|
import com.ubt.jimu.JimuApplication;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.base.entities.RobotLite;
|
|
import com.ubt.jimu.connect.presenter.ConnectPresenterImpl;
|
|
import com.ubt.jimu.connect.view.ConnectFragment;
|
|
import com.ubt.jimu.connect.view.DisconnectFragment;
|
|
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
|
import com.ubtrobot.jimu.robotapi.JimuManager;
|
|
import com.ubtrobot.log.ALog;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class ConnectActivity extends BaseActivity {
|
|
private JimuManager a;
|
|
private boolean h;
|
|
private int b = 0;
|
|
private boolean c = false;
|
|
private String d = null;
|
|
private String e = null;
|
|
private boolean f = true;
|
|
private String g = null;
|
|
private boolean i = true;
|
|
private int j = -10;
|
|
|
|
private void D0() {
|
|
this.a.c();
|
|
}
|
|
|
|
public static void a(Context context, RobotLite robotLite) {
|
|
b(context, -10, false, robotLite);
|
|
}
|
|
|
|
public static void b(Context context, int i, boolean z, RobotLite robotLite) {
|
|
Intent a = a(context, i, z, robotLite);
|
|
a.putExtra("KEY_PAGE_NUM", 0);
|
|
context.startActivity(a);
|
|
}
|
|
|
|
public static void c(Context context, int i, boolean z, RobotLite robotLite) {
|
|
Intent a = a(context, i, z, robotLite);
|
|
a.putExtra("KEY_PAGE_NUM", 1);
|
|
context.startActivity(a);
|
|
}
|
|
|
|
@Override // android.app.Activity, android.view.Window.Callback
|
|
public boolean dispatchGenericMotionEvent(MotionEvent motionEvent) {
|
|
if ((motionEvent.getSource() & 16777232) == 16777232 && motionEvent.getAction() == 2) {
|
|
return true;
|
|
}
|
|
return super.dispatchGenericMotionEvent(motionEvent);
|
|
}
|
|
|
|
@Override // androidx.appcompat.app.AppCompatActivity, androidx.core.app.ComponentActivity, android.app.Activity, android.view.Window.Callback
|
|
public boolean dispatchKeyEvent(KeyEvent keyEvent) {
|
|
if ((keyEvent.getSource() & 1025) == 1025) {
|
|
return true;
|
|
}
|
|
return super.dispatchKeyEvent(keyEvent);
|
|
}
|
|
|
|
public void l(int i) {
|
|
ALog.a(this.TAG).d("ActivityFinish");
|
|
Intent intent = new Intent();
|
|
intent.putExtra("KEY_MODEL_ID", this.d);
|
|
setResult(i, intent);
|
|
if (!this.c) {
|
|
finish();
|
|
return;
|
|
}
|
|
UnityActivity.start(this, 7, this.d, this.e, this.g, this.i, this.h ? 1 : 0);
|
|
finish();
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentActivity, android.app.Activity
|
|
public void onBackPressed() {
|
|
Log.i(this.TAG, "onBackPressed");
|
|
l(0);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.core.app.ComponentActivity, android.app.Activity
|
|
protected void onCreate(Bundle bundle) {
|
|
Bundle bundle2;
|
|
super.onCreate(bundle);
|
|
setContentView(R.layout.activity_connect);
|
|
this.a = JimuApplication.l().f();
|
|
FragmentTransaction a = getSupportFragmentManager().a();
|
|
Intent intent = getIntent();
|
|
if (intent != null) {
|
|
this.g = intent.getStringExtra("KEY_PIC_PATH");
|
|
this.d = intent.getStringExtra("KEY_MODEL_ID");
|
|
this.e = intent.getStringExtra("KEY_MODEL_NAME");
|
|
this.f = intent.getBooleanExtra("KEY_IS_AUTO_CONNECT", true);
|
|
this.c = intent.getBooleanExtra("KEY_IS_FROM_UNITY", false);
|
|
this.h = intent.getBooleanExtra("KEY_IS_DIY_MODEL", false);
|
|
this.i = intent.getBooleanExtra("KEY_IS_DIY_CAN_EDIT", true);
|
|
this.j = intent.getIntExtra("KEY_MODEL_CODE", -10);
|
|
this.b = intent.getIntExtra("KEY_PAGE_NUM", 0);
|
|
bundle2 = new Bundle();
|
|
bundle2.putString("KEY_PIC_PATH", this.g);
|
|
bundle2.putString("KEY_MODEL_ID", this.d);
|
|
bundle2.putBoolean("KEY_IS_AUTO_CONNECT", this.f);
|
|
bundle2.putBoolean("KEY_IS_FROM_UNITY", this.c);
|
|
bundle2.putBoolean("KEY_IS_DIY_MODEL", this.h);
|
|
bundle2.putString("KEY_MODEL_NAME", this.e);
|
|
bundle2.putInt("KEY_MODEL_CODE", this.j);
|
|
} else {
|
|
bundle2 = null;
|
|
}
|
|
if (this.j == 1) {
|
|
D0();
|
|
}
|
|
if (this.b == 0) {
|
|
if (this.a.g()) {
|
|
Log.i(this.TAG, "goto connect page, but bluetooth is connected, disconnect first");
|
|
D0();
|
|
}
|
|
ALog.a(this.TAG).d("new ConnectFragment");
|
|
ConnectFragment connectFragment = new ConnectFragment();
|
|
if (bundle2 != null) {
|
|
connectFragment.setArguments(bundle2);
|
|
}
|
|
ConnectPresenterImpl connectPresenterImpl = new ConnectPresenterImpl(this, connectFragment);
|
|
connectPresenterImpl.b(this.d);
|
|
if (!this.f) {
|
|
connectPresenterImpl.b(false);
|
|
}
|
|
a.a(R.id.rl_connect, connectFragment);
|
|
} else {
|
|
DisconnectFragment disconnectFragment = new DisconnectFragment();
|
|
if (bundle2 != null) {
|
|
disconnectFragment.setArguments(bundle2);
|
|
}
|
|
a.a(R.id.rl_connect, disconnectFragment);
|
|
}
|
|
ALog.a(this.TAG).d("ConnectFragment transaction commit");
|
|
a.a();
|
|
}
|
|
|
|
public static void a(int i, Activity activity, RobotLite robotLite) {
|
|
Intent a = a(activity, -10, false, robotLite);
|
|
a.putExtra("KEY_PAGE_NUM", 0);
|
|
activity.startActivityForResult(a, i);
|
|
}
|
|
|
|
public static void b(Context context, RobotLite robotLite) {
|
|
c(context, -10, false, robotLite);
|
|
}
|
|
|
|
private static Intent a(Context context, int i, boolean z, RobotLite robotLite) {
|
|
Intent intent = new Intent(context, (Class<?>) ConnectActivity.class);
|
|
intent.putExtra("KEY_PIC_PATH", robotLite.getPicPath());
|
|
intent.putExtra("KEY_MODEL_ID", robotLite.getModelId());
|
|
intent.putExtra("KEY_MODEL_NAME", robotLite.getModelName());
|
|
intent.putExtra("KEY_IS_FROM_UNITY", z);
|
|
intent.putExtra("KEY_IS_DIY_MODEL", !robotLite.isOfficial());
|
|
intent.putExtra("KEY_IS_DIY_CAN_EDIT", robotLite.isDiyCanEdit());
|
|
intent.putExtra("KEY_MODEL_CODE", i);
|
|
intent.putExtra("KEY_IS_AUTO_CONNECT", true);
|
|
return intent;
|
|
}
|
|
|
|
public static void b(int i, Activity activity, RobotLite robotLite) {
|
|
Intent a = a(activity, -10, false, robotLite);
|
|
a.putExtra("KEY_PAGE_NUM", 1);
|
|
activity.startActivityForResult(a, i);
|
|
}
|
|
}
|