jump method
boostRoute true:来自首页跳转。首页由于嵌入到业务方页面,来自首页的所有跳转都将以boost方式打开,即新起一个页面。
boostRoute false:非首页跳转。非首页的跳转使用Navigator跳转即可。
Implementation
Future? jump(BuildContext context, AdModel? adModel, {boostRoute = true}) {
if (null == context) {
return null;
}
_log("jump $adModel");
if (null != adModel && TextUtils.isNotEmpty(adModel.adType)) {
String adLink = adModel.adLink ?? "";
switch (adModel.adType) {
case AdModel.adTypeInternal:
if (_checkAdLink(adLink)) {
_launchUrlByInternal(adLink);
}
break;
case AdModel.adTypeExternal:
if (_checkAdLink(adLink)) {
_launchUrlByExternal(adLink);
}
break;
case AdModel.adTypeLiveRoom:
if (_checkAdLink(adLink)) {
AudienceLiveRoomPage.startSingle(context, adLink);
}
break;
case AdModel.adTypeSdkCustom:
if (TextUtils.isEmpty(adLink)) {
ToastUtils.showToast(Strings.adJumpParamMissing.tr);
return null;
}
SdkCustomAd sdkCustomAd = SdkCustomAd.fromJson(json.decode(adLink));
CallbackManager.callCustomAdClick(
context, adModel.id, adModel.getCustomAdType(), adModel.getCustomLocation(), sdkCustomAd.adKey, sdkCustomAd.adValue);
break;
case AdModel.adTypeSdkSetCustom:
CallbackManager.callCustomAdClick(
context, adModel.id, adModel.getCustomAdType(), adModel.getCustomLocation(), adModel.customKey, adModel.customValue);
break;
case AdModel.adTypeLiveRoomGame:
if (_checkAdLink(adLink)) {
_jumpToLiveGame(context, adLink);
}
break;
default:
ToastUtils.showToast(Strings.adJumpNotSupportNeedUpdate.tr);
break;
}
} else {
ToastUtils.showToast(Strings.adJumpParamMissing.tr);
}
return null;
}