169 lines
6.2 KiB
Java
169 lines
6.2 KiB
Java
package com.mogo.cloud;
|
||
|
||
import android.content.Intent;
|
||
import android.os.Bundle;
|
||
import android.text.TextUtils;
|
||
import android.widget.Button;
|
||
import android.widget.TextView;
|
||
|
||
import androidx.appcompat.app.AppCompatActivity;
|
||
|
||
import com.mogo.cloud.network.NetworkActivity;
|
||
import com.mogo.cloud.passport.IMoGoTokenCallback;
|
||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||
import com.mogo.cloud.trafficlive.api.ITrafficIntersectionLiveCallBack;
|
||
import com.mogo.cloud.trafficlive.api.MoGoAiCloudTrafficLive;
|
||
import com.mogo.cloud.utils.logger.Logger;
|
||
|
||
public class MainActivity extends AppCompatActivity {
|
||
|
||
private static final String TAG = "MainActivity";
|
||
|
||
private Button btnJumpPassPort;
|
||
private Button btnJumpConfigInfo;
|
||
private Button btnJumpNetWorkPort;
|
||
private Button btnJumpRealTime;
|
||
private Button btnJumpRoadCondition;
|
||
private Button btnJumpLivePlayAndPush;
|
||
private Button btnJumpLivePush;
|
||
private Button btnJumpLivePlay;
|
||
private Button btnRequestXINGLive;
|
||
|
||
private TextView tvSn;
|
||
private TextView tvToken;
|
||
private TextView tvAppKey;
|
||
private TextView tvDevicesId;
|
||
|
||
@Override
|
||
protected void onCreate(Bundle savedInstanceState) {
|
||
super.onCreate(savedInstanceState);
|
||
setContentView(R.layout.activity_main);
|
||
|
||
tvAppKey = findViewById(R.id.tvAppKey);
|
||
tvDevicesId = findViewById(R.id.tvDevicesId);
|
||
tvSn = findViewById(R.id.tvSn);
|
||
tvToken = findViewById(R.id.tvToken);
|
||
|
||
btnJumpPassPort = findViewById(R.id.btnJumpPassPort);
|
||
btnJumpPassPort.setOnClickListener(v -> {
|
||
MoGoAiCloudClient.getInstance().refreshToken();
|
||
});
|
||
|
||
btnJumpNetWorkPort = findViewById(R.id.btnJumpNetWorkPort);
|
||
btnJumpNetWorkPort.setOnClickListener(v -> {
|
||
Intent intent = new Intent(MainActivity.this, NetworkActivity.class);
|
||
startActivity(intent);
|
||
});
|
||
|
||
btnJumpRealTime = findViewById(R.id.btnJumpRealTime);
|
||
btnJumpRealTime.setOnClickListener(v -> {
|
||
Intent intent = new Intent(MainActivity.this, RealTimeActivity.class);
|
||
startActivity(intent);
|
||
});
|
||
|
||
btnJumpRoadCondition = findViewById(R.id.btnJumpRoadcondition);
|
||
btnJumpRoadCondition.setOnClickListener(v -> {
|
||
Intent intent = new Intent(MainActivity.this, RoadConditionActivity.class);
|
||
startActivity(intent);
|
||
});
|
||
|
||
btnJumpConfigInfo = findViewById(R.id.btnJumpConfigInfo);
|
||
btnJumpConfigInfo.setOnClickListener(v -> {
|
||
Intent intent = new Intent(MainActivity.this, ConfigInfoActivity.class);
|
||
startActivity(intent);
|
||
});
|
||
|
||
btnJumpLivePlayAndPush = findViewById(R.id.btnJumpLivePlayAndPush);
|
||
btnJumpLivePlayAndPush.setOnClickListener(v -> {
|
||
Intent intent = new Intent(MainActivity.this, LivePlayAndPushActivity.class);
|
||
startActivity(intent);
|
||
});
|
||
|
||
btnJumpLivePush = findViewById(R.id.btnJumpLivePush);
|
||
btnJumpLivePush.setOnClickListener(v -> {
|
||
Intent intent = new Intent(MainActivity.this, LivePushActivity.class);
|
||
startActivity(intent);
|
||
});
|
||
|
||
btnJumpLivePlay = findViewById(R.id.btnJumpLivePlay);
|
||
btnJumpLivePlay.setOnClickListener(v -> {
|
||
Intent intent = new Intent(MainActivity.this, LivePlayActivity.class);
|
||
startActivity(intent);
|
||
});
|
||
|
||
btnRequestXINGLive = findViewById(R.id.btnRequestXINGLive);
|
||
btnRequestXINGLive.setOnClickListener(v -> {
|
||
MoGoAiCloudTrafficLive.viewDesignativeIntersectionLive("556834859_trafficcamera_100514_89", new ITrafficIntersectionLiveCallBack() {
|
||
@Override
|
||
public void liveUrlResult(String liveUrl) {
|
||
Logger.i(TAG, "liveUrl : " + liveUrl);
|
||
}
|
||
|
||
@Override
|
||
public void onError(String errorMsg) {
|
||
Logger.e(TAG, "errorMsg : " + errorMsg);
|
||
}
|
||
});
|
||
// MoGoAiCloudTrafficLive.viewDesignativeIntersectionLive("POLE1617103029423", new ITrafficIntersectionLiveCallBack() {
|
||
// @Override
|
||
// public void liveUrlResult(String liveUrl) {
|
||
// Logger.d(TAG, "liveUrl : " + liveUrl);
|
||
// }
|
||
//
|
||
// @Override
|
||
// public void onError(String errorMsg) {
|
||
// Logger.e(TAG, "errorMsg : " + errorMsg);
|
||
// }
|
||
// });
|
||
// MoGoAiCloudTrafficLive.viewFrontIntersectionLive(40.11547, 116.22544, 60, new ITrafficIntersectionLiveCallBack() {
|
||
// @Override
|
||
// public void liveUrlResult(String liveUrl) {
|
||
// Logger.d(TAG, "liveUrl : " + liveUrl);
|
||
// }
|
||
//
|
||
// @Override
|
||
// public void onError(String errorMsg) {
|
||
// Logger.e(TAG, "errorMsg : " + errorMsg);
|
||
// }
|
||
// });
|
||
});
|
||
|
||
MoGoAiCloudClient.getInstance().addTokenCallbacks(new IMoGoTokenCallback() {
|
||
@Override
|
||
public void onTokenGot(String token, String sn) {
|
||
initPassportInfo();
|
||
}
|
||
|
||
@Override
|
||
public void onError(int code, String msg) {
|
||
initPassportInfo();
|
||
}
|
||
});
|
||
}
|
||
|
||
@Override
|
||
protected void onResume() {
|
||
super.onResume();
|
||
MoGoAiCloudClient.getInstance().refreshToken();
|
||
}
|
||
|
||
/**
|
||
* 初始化令牌信息
|
||
*/
|
||
private void initPassportInfo() {
|
||
tvAppKey.setText("AppKey:" + MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getThirdPartyAppKey());
|
||
tvDevicesId.setText("DevicesId:" + MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getThirdPartyDeviceId());
|
||
|
||
String sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
|
||
String token = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getToken();
|
||
|
||
if (TextUtils.isEmpty(sn)) {
|
||
sn = "获取失败,请重试";
|
||
}
|
||
if (TextUtils.isEmpty(token)) {
|
||
token = "获取失败,请重试";
|
||
}
|
||
tvSn.setText("SN:" + sn);
|
||
tvToken.setText("Token:" + token);
|
||
}
|
||
} |