package com.hdl.photovoltaic.push;
|
|
import android.content.Intent;
|
import android.os.Bundle;
|
import android.util.Log;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.sdk.android.push.popup.OnPushParseFailedListener;
|
import com.alibaba.sdk.android.push.popup.PopupNotifyClick;
|
import com.alibaba.sdk.android.push.popup.PopupNotifyClickListener;
|
import com.hdl.photovoltaic.HDLApp;
|
import com.hdl.photovoltaic.R;
|
import com.hdl.photovoltaic.base.CustomBaseActivity;
|
import com.hdl.photovoltaic.other.HdlPushLogic;
|
import com.hdl.photovoltaic.ui.me.AsRegardsActivity;
|
|
import java.util.Map;
|
|
/**
|
* 商厂通道专用Activity(透明中转页)
|
*/
|
public class VendorChannelActivity extends CustomBaseActivity implements PopupNotifyClickListener, OnPushParseFailedListener {
|
|
private final static String TAG = "VendorChannelActivity";
|
private final PopupNotifyClick mPopupNotifyClick = new PopupNotifyClick(this);
|
|
|
@Override
|
public Object getContentView() {
|
return R.layout.activity_vendor_channel;
|
}
|
|
@Override
|
public void onBindView(Bundle savedInstanceState) {
|
mPopupNotifyClick.onCreate(this, getIntent());
|
// // 延迟一小段时间确保数据处理好再finish,处理Intent
|
// handleIntent(getIntent());
|
// 尽快结束,不显示界面
|
|
}
|
|
@Override
|
protected void onNewIntent(Intent intent) {
|
super.onNewIntent(intent);
|
Log.d(TAG, "VendorChannelActivity onNewIntent");
|
mPopupNotifyClick.onNewIntent(intent);
|
|
}
|
|
|
/**
|
* 跳转到StartActivity
|
*/
|
private void jumpToStartActivity(String title, String content, Map<String, String> map) {
|
try {
|
String extra = JSONObject.toJSONString(map);
|
PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing(title, content, extra);
|
Intent launchIntent = CustomNotification.getInstance().createNotificationIntent(this, pushMessageInfoBean, CustomNotification.FromPush.AliYun);
|
// 启动真正的StartActivity
|
startActivity(launchIntent);
|
finish();
|
} catch (Exception e) {
|
try {
|
//Log.e(TAG, "跳转到StartActivity失败", e);
|
// 如果StartActivity不存在,跳转到MainActivity
|
Intent mainIntent = CustomNotification.getInstance().createNotificationIntent(this, null, CustomNotification.FromPush.AliYun);
|
startActivity(mainIntent);
|
finish();
|
} catch (Exception e2) {
|
Log.e(TAG, "跳转到MainActivity也失败", e2);
|
}
|
}
|
|
}
|
|
|
@Override
|
public void finish() {
|
super.finish();
|
// // 禁用Activity切换动画,实现无缝跳转
|
// overridePendingTransition(0, 0);
|
}
|
|
|
@Override
|
public void onSysNoticeOpened(String s, String s1, Map<String, String> map) {
|
//TODO 获取推送参数,根据业务需求处理
|
jumpToStartActivity(s, s1, map);
|
|
}
|
|
@Override
|
public void onPointerCaptureChanged(boolean hasCapture) {
|
super.onPointerCaptureChanged(hasCapture);
|
}
|
|
/**
|
* 不是推送数据的回调
|
*
|
* @param intent
|
*/
|
@Override
|
public void onNotPushData(Intent intent) {
|
//TODO 没有推送数据,可能是异常调用,需要异常处理
|
}
|
|
/**
|
* 是推送数据,但是又解密失败时的回调
|
*
|
* @param intent
|
*/
|
@Override
|
public void onParseFailed(Intent intent) {
|
//TODO 推送数据解密异常,需要异常处理
|
}
|
|
/**
|
* 解析厂商特定的数据
|
*/
|
private void parseVendorSpecificData(Intent intent) {
|
// 小米通道数据解析
|
if (intent.hasExtra("miPushMessage")) {
|
Log.d(TAG, "小米通道数据");
|
// 小米推送的数据结构
|
}
|
|
// 华为通道数据解析
|
if (intent.hasExtra("hms_message_id")) {
|
Log.d(TAG, "华为通道数据");
|
// 华为推送的数据结构
|
}
|
|
// OPPO通道数据解析
|
if (intent.hasExtra("oppo_push_message")) {
|
Log.d(TAG, "OPPO通道数据");
|
}
|
|
// vivo通道数据解析
|
if (intent.hasExtra("vivo_push_message")) {
|
Log.d(TAG, "vivo通道数据");
|
}
|
}
|
|
}
|