This commit is contained in:
2025-11-18 15:12:24 +08:00
parent c173c425ce
commit a7d2035e70
1361 changed files with 367452 additions and 0 deletions
@@ -0,0 +1,347 @@
package cn.shangyu.gdxzExpert.polyvplayer;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.google.gson.Gson;
import com.gyf.immersionbar.ImmersionBar;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
import cn.shangyu.gdxzExpert.R;
import cn.shangyu.gdxzExpert.base.BaseActivity;
import cn.shangyu.gdxzExpert.bean.VideoOrderBean;
import cn.shangyu.gdxzExpert.http.OnCallBackFromNet;
import cn.shangyu.gdxzExpert.pointsmall.BuyIntegerActivty;
import cn.shangyu.gdxzExpert.utils.Constant;
import cn.shangyu.gdxzExpert.utils.LogUtil;
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
import cn.shangyu.gdxzExpert.utils.ToastUtil;
import cn.shangyu.gdxzExpert.utils.UIUtils;
import cn.shangyu.gdxzExpert.utils.Url;
import cn.shangyu.gdxzExpert.widget.ECAlertDialog;
import cn.shangyu.gdxzExpert.widget.LoadingPage;
/**
* Created by WANGChengXin on 2019/3/27.
*/
public class OnlineVideoExchangeActivity extends BaseActivity implements OnCallBackFromNet,View.OnClickListener{
private TextView tv_exchange;
private String series_type_uuid;
private Dialog dialog;
private String title;
private String paid_num;
private String price;
private String order_uuid;
private Intent intent;
private ECAlertDialog dilaog2;
public static final int GETWELFARENUM = 201;
public static final int USEWELFARENUM = 202;
public static final int CREATESERIESVIDEOORDER = 101;
public static final int PAYSERIESVIDEOORDER = 102;
private int welfareNum;
private AlertDialog dialog1;
private boolean is_welfareNum;
@Override
public void setTitle() {
top_title.setText("在线兑换");
}
@Override
public View onCreateSuccessedView() {
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
View view = UIUtils.inflate(R.layout.activity_onlinevideoexchange);
TextView tv_name = view.findViewById(R.id.tv_name);
TextView tv_jifen = view.findViewById(R.id.tv_jifen);
TextView tv_duihuan = view.findViewById(R.id.tv_duihuan);
TextView tv_needpoint = view.findViewById(R.id.tv_needpoint);
intent = getIntent();
series_type_uuid = getIntent().getStringExtra("series_type_uuid");
title = getIntent().getStringExtra("title");
paid_num = getIntent().getStringExtra("paid_num");
price = getIntent().getStringExtra("price");
tv_exchange = view.findViewById(R.id.tv_exchange);
tv_name.setText(title);
if ("0".equals(paid_num)){
tv_duihuan.setVisibility(View.GONE);
}else {
tv_duihuan.setText(paid_num);
}
tv_jifen.setText(price);
tv_needpoint.setText(price);
tv_exchange.setOnClickListener(this);
getWelfareNum();
return view;
}
//查询福利剩余次数
//参数type (1视频2课件3精品4万方5U盘)
private void getWelfareNum() {
Map<String,String> map = new HashMap<>();
map.put("type","3");
sendJsonPostParamtoNetSignMD5(Url.getWelfareNum,map,GETWELFARENUM,this);
}
//使用福利操作
private void useWelfareNum() {
Map<String,String> map = new HashMap<>();
map.put("type","3");
map.put("other_uuid",order_uuid);
sendJsonPostParamtoNetSignMD5(Url.useWelfareNum,map,USEWELFARENUM,this);
}
//创建订单
private void createSeriesVideoOrder() {
Map<String,String> map = new HashMap<>();
map.put("series_type_uuid",series_type_uuid);
sendJsonPostParamtoNetSignMD5(Url.createSeriesVideoOrder,map,CREATESERIESVIDEOORDER,OnlineVideoExchangeActivity.this);
}
@Override
public LoadingPage.ResultState onLoad() {
return LoadingPage.ResultState.STATE_SUCCESSED;
}
@Override
protected void processClick(View v) {
switch (v.getId()){
case R.id.tv_exchange:
if (welfareNum>0){
LayoutInflater inflater = LayoutInflater.from(this);
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.dailog_videoexcheng, null);
dialog1 = new AlertDialog.Builder(OnlineVideoExchangeActivity.this).create();
TextView tv_infotitle = layout.findViewById(R.id.tv_infotitle);
TextView tv_1 = layout.findViewById(R.id.tv_1);
TextView tv_2 = layout.findViewById(R.id.tv_2);
TextView tv_3 = layout.findViewById(R.id.tv_3);
Button btn_sure1 = (Button) layout.findViewById(R.id.btn_sure);
Button btn_cancel1 = (Button) layout.findViewById(R.id.btn_cancel);
tv_infotitle.setText("温馨提示");
tv_1.setText("您还可以免费下载精品课程"+welfareNum+"次,本次是否使用免费下载?");
tv_2.setVisibility(View.GONE);
tv_3.setVisibility(View.GONE);
dialog1.show();
Window window =dialog1.getWindow();
// window.setGravity(Gravity.CENTER);
WindowManager.LayoutParams layoutParams = window.getAttributes();
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
window.setAttributes(layoutParams);
dialog1.getWindow().setContentView(layout);
btn_sure1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
is_welfareNum = true;
createSeriesVideoOrder();
dialog1.dismiss();
}
});
btn_cancel1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
createSeriesVideoOrder();
dialog1.dismiss();
}
});
}else {
createSeriesVideoOrder();
}
break;
case R.id.btn_sure:
Map<String,String> map1 = new HashMap<>();
map1.put("order_uuid",order_uuid);
sendJsonPostParamtoNetSignMD5(Url.paySeriesVideoOrder,map1,PAYSERIESVIDEOORDER,OnlineVideoExchangeActivity.this);
break;
case R.id.btn_cancel:
// Map<String,String> map2 = new HashMap<>();
// map2.put("order_uuid",order_uuid);
// sendJsonPostParamtoNetSignMD5(Url.cancleSeriesVideoOrder,map2,3,OnlineVideoExchangeActivity.this);
//
dialog.dismiss();
// setResult(1,intent);
// Intent intent2 = PolyvPlayerActivity.newIntent(OnlineVideoExchangeActivity.this, PolyvPlayerActivity.PlayMode.portrait, "");
// intent2.putExtra("isVlmsOnline", false);
// intent2.putExtra("series_type_uuid", series_type_uuid);
// startActivity(intent2);
// OnlineVideoExchangeActivity.this.finish();
break;
}
}
@Override
public void onCallbackFromThread(String resultJson) {
}
@Override
public void onCallBackFromThread(String resultJson, int resultCode) {
Gson gson = new Gson();
VideoOrderBean videoOrderBean = gson.fromJson(resultJson, VideoOrderBean.class);
switch (resultCode){
case CREATESERIESVIDEOORDER://106积分不足
LogUtil.i("CREATESERIESVIDEOORDER = "+resultJson);
if (videoOrderBean.getCode().equals("200")){
order_uuid = videoOrderBean.getOrder_uuid();
if (is_welfareNum){
useWelfareNum();
}else {
LayoutInflater inflater = LayoutInflater.from(this);
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.dailog_videoexcheng, null);
dialog = new AlertDialog.Builder(OnlineVideoExchangeActivity.this).create();
TextView tv_2 = layout.findViewById(R.id.tv_2);
Button btn_sure = (Button) layout.findViewById(R.id.btn_sure);
Button btn_cancel = (Button) layout.findViewById(R.id.btn_cancel);
tv_2.setText(price.replace("积分",""));
dialog.show();
Window window =dialog.getWindow();
// window.setGravity(Gravity.CENTER);
WindowManager.LayoutParams layoutParams = window.getAttributes();
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
window.setAttributes(layoutParams);
dialog.getWindow().setContentView(layout);
btn_sure.setOnClickListener(this);
btn_cancel.setOnClickListener(this);
}
}else if (videoOrderBean.getCode().equals("106")){
dilaog2 = ECAlertDialog.buildAlert(OnlineVideoExchangeActivity.this,
"您的积分不足,是否购买积分?", "取消", "确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dilaog2.dismiss();
}
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dilaog2.dismiss();
startActivity(new Intent(OnlineVideoExchangeActivity.this,BuyIntegerActivty.class));
}
});
dilaog2.setTitle("温馨提示");
dilaog2.setCancelable(false);
dilaog2.getWindow();
dilaog2.show();
// ToastUtil.showMessage("积分不足");
}else {
ToastUtil.showMessage("创建订单失败");
}
break;
case PAYSERIESVIDEOORDER:
LogUtil.i("PAYSERIESVIDEOORDER = "+resultJson);
dialog.dismiss();
if (videoOrderBean.getCode().equals("200")){
Constant.fragmentHeight1=0;
Constant.fragmentHeight2=0;
Constant.fragmentHeight3=0;
SharePrefUtil.saveInt(OnlineVideoExchangeActivity.this,"fragmentHeight1",0);
LogUtil.i("SharePrefUtil OnlineVideoExchangeActivity = 0");
setResult(1,intent);
Intent intent2 = PolyvPlayerActivity.newIntent(OnlineVideoExchangeActivity.this, PolyvPlayerActivity.PlayMode.portrait, "");
intent2.putExtra("isVlmsOnline", false);
intent2.putExtra("series_type_uuid", series_type_uuid);
startActivity(intent2);
OnlineVideoExchangeActivity.this.finish();
ToastUtil.showMessage("兑换成功");
}else if (videoOrderBean.getCode().equals("106")) {
dilaog2 = ECAlertDialog.buildAlert(OnlineVideoExchangeActivity.this,
"您的积分不足,是否购买积分?", "取消", "确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dilaog2.dismiss();
}
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dilaog2.dismiss();
startActivity(new Intent(OnlineVideoExchangeActivity.this,BuyIntegerActivty.class));
}
});
dilaog2.setTitle("温馨提示");
dilaog2.setCancelable(false);
dilaog2.getWindow();
dilaog2.show();
}
break;
case 3:
// LogUtil.i("取消订单 = "+resultJson);
// if (videoOrderBean.getCode().equals("200")){
// dialog.dismiss();
// }
break;
case USEWELFARENUM://{"code":"1","message":"使用成功"}
LogUtil.i("USEWELFARENUM = "+resultJson);
try {
JSONObject jsonObject = new JSONObject(resultJson);
String code = jsonObject.optString("code");
if("1".equals(code)){
LogUtil.i("USEWELFARENUM = "+resultJson);
Constant.fragmentHeight1=0;
Constant.fragmentHeight2=0;
Constant.fragmentHeight3=0;
SharePrefUtil.saveInt(OnlineVideoExchangeActivity.this,"fragmentHeight1",0);
LogUtil.i("SharePrefUtil OnlineVideoExchangeActivity = 0");
setResult(1,intent);
Intent intent2 = PolyvPlayerActivity.newIntent(OnlineVideoExchangeActivity.this, PolyvPlayerActivity.PlayMode.portrait, "");
intent2.putExtra("isVlmsOnline", false);
intent2.putExtra("series_type_uuid", series_type_uuid);
startActivity(intent2);
ToastUtil.showMessage("兑换成功");
OnlineVideoExchangeActivity.this.finish();
}else {
ToastUtil.showMessage(jsonObject.optString("message"));
}
} catch (JSONException e) {
e.printStackTrace();
}
break;
case GETWELFARENUM://{"WelfareNum":0,"code":"1","message":"查询成功"}
LogUtil.i("GETWELFARENUM = "+resultJson);
try {
JSONObject jsonObject = new JSONObject(resultJson);
welfareNum = jsonObject.optInt("WelfareNum");
if(welfareNum>0){
tv_exchange.setText("我要兑换"+"(剩余免费下载"+welfareNum+"次)");
}
} catch (JSONException e) {
e.printStackTrace();
}
break;
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
Map<String,String> map2 = new HashMap<>();
map2.put("order_uuid",series_type_uuid);
sendJsonPostParamtoNetSignMD5(Url.cancleSeriesVideoOrder,map2,3,OnlineVideoExchangeActivity.this);
}
return super.onKeyDown(keyCode, event);
}
}