33
This commit is contained in:
@@ -0,0 +1,378 @@
|
||||
package cn.shangyu.gdxzExpert.fragment;
|
||||
|
||||
import static cn.shangyu.gdxzExpert.utils.CommonUtil.BigModule;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.activity.CoursewareActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.MyLibraryActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.UpanExchangeActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.VideoActivity;
|
||||
import cn.shangyu.gdxzExpert.base.BaseFragment;
|
||||
import cn.shangyu.gdxzExpert.bean.GetWelfarePageBean;
|
||||
import cn.shangyu.gdxzExpert.big.activity.BigCoursewareActivity;
|
||||
import cn.shangyu.gdxzExpert.big.activity.BigMyLibraryActivity;
|
||||
import cn.shangyu.gdxzExpert.big.activity.BigPointsMallActivity;
|
||||
import cn.shangyu.gdxzExpert.big.activity.BigVideoActivity;
|
||||
import cn.shangyu.gdxzExpert.http.OnCallBackFromNet;
|
||||
import cn.shangyu.gdxzExpert.pointsmall.PointsMallActivity;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.QualityCourseActivity;
|
||||
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.GsonTools;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage;
|
||||
|
||||
/**
|
||||
* Created by WANGChengXin on 2020/3/18.
|
||||
*/
|
||||
|
||||
public class GetWelfAreFragment extends BaseFragment implements View.OnClickListener,OnCallBackFromNet{
|
||||
private View view;
|
||||
private TextView tv_newpatient_num,tv_newpatient_num1,tv_shipin_newpatient_num,tv_kejian_newpatient_num,tv_kecheng_newpatient_num,wen,xinzeng7,tv_wnum,tv_duihuan;
|
||||
private TextView tv_num,tv_wfnum,tv_spnum,tv_kjnum,tv_kcnum,tv_unum;
|
||||
private RelativeLayout rl_jifen,rl_wanfang,rl_shipin,rl_kejian,rl_kecheng,rl_upan,rl_upan_null,rl_wenxian;
|
||||
private TextView tv_lijilingqu,tv_wflijilingqu,tv_splijilingqu,tv_kjlijilingqu,tv_kclijilingqu,tv_ulijilingqu;
|
||||
private TextView tv_num1,tv_wfnum1,tv_spnum1,tv_kjnum1,tv_kcnum1;
|
||||
private LinearLayout ll_jifen,ll_wanfang,ll_shipin,ll_kejian,ll_kecheng,ll_upan,ll_upannull;
|
||||
public static final int USEWELFAREPAGE = 201;
|
||||
private TextView xinzeng,xinzeng1,xinzeng2,xinzeng3,xinzeng4,xinzeng5;
|
||||
private TextView tv_wfdanwei,tv_spdanwei,tv_kjdanwei,tv_kcdanwei,tv_danwei;
|
||||
private int upnum=0,wenxiannum=0;
|
||||
|
||||
@Override
|
||||
public View onCreateSuccessedView() {
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
view = UIUtils.inflate(R.layout.fragment_welfare_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
view = UIUtils.inflate(R.layout.fragment_welfare);
|
||||
}
|
||||
initView();
|
||||
initOnClick();
|
||||
initData();
|
||||
return view;
|
||||
}
|
||||
private void initView() {
|
||||
tv_newpatient_num = view.findViewById(R.id.tv_newpatient_num);//积分新随访
|
||||
tv_newpatient_num1 = view.findViewById(R.id.tv_newpatient_num1);//万方新随访
|
||||
tv_shipin_newpatient_num = view.findViewById(R.id.tv_shipin_newpatient_num);//视频新随访
|
||||
tv_kejian_newpatient_num = view.findViewById(R.id.tv_kejian_newpatient_num);//课件新随访
|
||||
tv_kecheng_newpatient_num = view.findViewById(R.id.tv_kecheng_newpatient_num);//课程新随访
|
||||
rl_wenxian=view.findViewById(R.id.rl_wenxian);
|
||||
xinzeng7=view.findViewById(R.id.xinzeng7);
|
||||
tv_wnum=view.findViewById(R.id.tv_wnum);
|
||||
tv_duihuan=view.findViewById(R.id.tv_duihuan);
|
||||
wen=view.findViewById(R.id.wen);
|
||||
rl_jifen = view.findViewById(R.id.rl_jifen);//积分
|
||||
rl_wanfang = view.findViewById(R.id.rl_wanfang);//万方
|
||||
rl_shipin = view.findViewById(R.id.rl_shipin);//视频
|
||||
rl_kejian = view.findViewById(R.id.rl_kejian);//课件
|
||||
rl_kecheng = view.findViewById(R.id.rl_kecheng);//课程
|
||||
rl_upan = view.findViewById(R.id.rl_upan);//U盘
|
||||
rl_upan_null = view.findViewById(R.id.rl_upan_null);//U盘null
|
||||
|
||||
tv_num = view.findViewById(R.id.tv_num);//积分个数
|
||||
tv_wfnum = view.findViewById(R.id.tv_wfnum);//万方个数
|
||||
tv_spnum = view.findViewById(R.id.tv_spnum);//视频个数
|
||||
|
||||
tv_kjnum = view.findViewById(R.id.tv_kjnum);//课件个数
|
||||
tv_kcnum = view.findViewById(R.id.tv_kcnum);//课程个数
|
||||
tv_unum = view.findViewById(R.id.tv_unum);//U盘个数
|
||||
|
||||
|
||||
tv_lijilingqu = view.findViewById(R.id.tv_lijilingqu);//积分立即领取
|
||||
tv_wflijilingqu = view.findViewById(R.id.tv_wflijilingqu);//万方立即领取
|
||||
tv_splijilingqu = view.findViewById(R.id.tv_splijilingqu);//视频立即领取
|
||||
tv_kjlijilingqu = view.findViewById(R.id.tv_kjlijilingqu);//课件立即领取
|
||||
tv_kclijilingqu = view.findViewById(R.id.tv_kclijilingqu);//课程立即领取
|
||||
tv_ulijilingqu = view.findViewById(R.id.tv_ulijilingqu);//U盘立即领取
|
||||
|
||||
|
||||
tv_num1 = view.findViewById(R.id.tv_num1);//赠送积分
|
||||
tv_wfnum1 = view.findViewById(R.id.tv_wfnum1);//赠送万方
|
||||
tv_spnum1 = view.findViewById(R.id.tv_spnum1);//赠送视频
|
||||
tv_kjnum1 = view.findViewById(R.id.tv_kjnum1);//赠送课件
|
||||
tv_kcnum1 = view.findViewById(R.id.tv_kcnum1);//赠送课程
|
||||
|
||||
ll_jifen = view.findViewById(R.id.ll_jifen);//积分赠送
|
||||
ll_wanfang = view.findViewById(R.id.ll_wanfang);//万方赠送
|
||||
ll_shipin = view.findViewById(R.id.ll_shipin);//视频赠送
|
||||
ll_kejian = view.findViewById(R.id.ll_kejian);//课件赠送
|
||||
ll_kecheng = view.findViewById(R.id.ll_kecheng);//课程赠送
|
||||
ll_upan = view.findViewById(R.id.ll_upan);//U赠送
|
||||
ll_upannull = view.findViewById(R.id.ll_upannull);//U赠送null
|
||||
|
||||
|
||||
xinzeng = view.findViewById(R.id.xinzeng);//积分新增
|
||||
xinzeng1 = view.findViewById(R.id.xinzeng1);//万方新增
|
||||
xinzeng2 = view.findViewById(R.id.xinzeng2);//视频新增
|
||||
xinzeng3 = view.findViewById(R.id.xinzeng3);//课件新增
|
||||
xinzeng4 = view.findViewById(R.id.xinzeng4);//精品新增
|
||||
xinzeng5 = view.findViewById(R.id.xinzeng5);//U盘新增
|
||||
|
||||
tv_wfdanwei = view.findViewById(R.id.tv_wfdanwei);//万方单位
|
||||
tv_spdanwei = view.findViewById(R.id.tv_spdanwei);//视频单位
|
||||
tv_kjdanwei = view.findViewById(R.id.tv_kjdanwei);//课件单位
|
||||
tv_kcdanwei = view.findViewById(R.id.tv_kcdanwei);//精品单位
|
||||
tv_danwei = view.findViewById(R.id.tv_danwei);//积分单位
|
||||
|
||||
ll_jifen.setVisibility(View.GONE);
|
||||
ll_wanfang.setVisibility(View.GONE);
|
||||
ll_shipin.setVisibility(View.GONE);
|
||||
ll_kejian.setVisibility(View.GONE);
|
||||
ll_kecheng.setVisibility(View.GONE);
|
||||
|
||||
tv_lijilingqu.setVisibility(View.VISIBLE);
|
||||
tv_wflijilingqu.setVisibility(View.VISIBLE);
|
||||
tv_splijilingqu.setVisibility(View.VISIBLE);
|
||||
tv_kjlijilingqu.setVisibility(View.VISIBLE);
|
||||
tv_kclijilingqu.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
tv_newpatient_num.setVisibility(View.GONE);
|
||||
tv_newpatient_num1.setVisibility(View.GONE);
|
||||
tv_shipin_newpatient_num.setVisibility(View.GONE);
|
||||
tv_kejian_newpatient_num.setVisibility(View.GONE);
|
||||
tv_kecheng_newpatient_num.setVisibility(View.GONE);
|
||||
|
||||
rl_upan_null.setVisibility(View.GONE);
|
||||
|
||||
tv_lijilingqu.setText("兑换礼品");
|
||||
tv_wflijilingqu.setText("前往下载");
|
||||
tv_splijilingqu.setText("前往下载");
|
||||
tv_kjlijilingqu.setText("前往下载");
|
||||
tv_kclijilingqu.setText("前往兑换");
|
||||
tv_ulijilingqu.setText("前往兑换");
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
Map<String,String> map = new HashMap<>();
|
||||
sendJsonPostParamtoNetSignMD5(Url.useWelfarePage,map,USEWELFAREPAGE,this);
|
||||
}
|
||||
|
||||
private void initOnClick() {
|
||||
tv_lijilingqu.setOnClickListener(this);
|
||||
tv_wflijilingqu.setOnClickListener(this);
|
||||
tv_splijilingqu.setOnClickListener(this);
|
||||
tv_kjlijilingqu.setOnClickListener(this);
|
||||
tv_kclijilingqu.setOnClickListener(this);
|
||||
tv_ulijilingqu.setOnClickListener(this);
|
||||
tv_duihuan.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoadingPage.ResultState onLoad() {
|
||||
return LoadingPage.ResultState.STATE_SUCCESSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// AGP 8.0+ R.id 不再是 final 常量,不能用于 switch,改用 if-else
|
||||
int id = v.getId();
|
||||
if (id == R.id.tv_lijilingqu) {
|
||||
if(BigModule())
|
||||
{
|
||||
startActivity(new Intent(getActivity(), BigPointsMallActivity.class));
|
||||
}
|
||||
else
|
||||
{
|
||||
startActivity(new Intent(getActivity(), PointsMallActivity.class));
|
||||
}
|
||||
} else if (id == R.id.tv_splijilingqu) {
|
||||
if(BigModule())
|
||||
{
|
||||
startActivity(new Intent(getActivity(), BigVideoActivity.class));
|
||||
}
|
||||
else
|
||||
{
|
||||
startActivity(new Intent(getActivity(), VideoActivity.class));
|
||||
}
|
||||
} else if (id == R.id.tv_kjlijilingqu) {
|
||||
if(BigModule())
|
||||
{
|
||||
startActivity(new Intent(getActivity(), BigCoursewareActivity.class));
|
||||
}
|
||||
else
|
||||
{
|
||||
startActivity(new Intent(getActivity(), CoursewareActivity.class));
|
||||
}
|
||||
} else if (id == R.id.tv_kclijilingqu) {
|
||||
startActivity(new Intent(getActivity(), QualityCourseActivity.class));
|
||||
} else if (id == R.id.tv_wflijilingqu) {
|
||||
Intent intentwf = new Intent();
|
||||
if(BigModule())
|
||||
{
|
||||
intentwf.setClass(getActivity(), BigMyLibraryActivity.class);
|
||||
}
|
||||
else
|
||||
{
|
||||
intentwf.setClass(getActivity(),MyLibraryActivity.class);
|
||||
}
|
||||
// Intent intentwf = new Intent(getActivity(),MyLibraryActivity.class);
|
||||
intentwf.putExtra("search", "searchStr");
|
||||
startActivity(intentwf);
|
||||
} else if (id == R.id.tv_ulijilingqu) {
|
||||
Intent intent = new Intent(getActivity(),UpanExchangeActivity.class);
|
||||
intent.putExtra("upannum",upnum);
|
||||
startActivity(intent);
|
||||
} else if (id == R.id.tv_duihuan) {
|
||||
if(wenxiannum<1)
|
||||
{
|
||||
LayoutInflater inflater = LayoutInflater.from(getActivity());
|
||||
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.dialog_notification, null);
|
||||
AlertDialog dialog4 = new AlertDialog.Builder(
|
||||
getActivity()).create();
|
||||
TextView tv_tishi = layout.findViewById(R.id.tv_tishi);
|
||||
tv_tishi.setText("肝胆相照平台协助查找文献次数已经用完,谢谢您的支持");
|
||||
Button btn_sure = (Button) layout.findViewById(R.id.btn_sure);
|
||||
Button btn_cancel = (Button) layout.findViewById(R.id.btn_cancel);
|
||||
dialog4.show();
|
||||
Window window =dialog4.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);
|
||||
dialog4.getWindow().setContentView(layout);
|
||||
|
||||
btn_cancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
dialog4.dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
btn_sure.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
dialog4.dismiss();
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
Intent intentwf1 = new Intent(getActivity(),
|
||||
BigMyLibraryActivity.class);
|
||||
intentwf1.putExtra("search", "searchStr");
|
||||
startActivity(intentwf1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Intent intentwf1 = new Intent(getActivity(),
|
||||
MyLibraryActivity.class);
|
||||
intentwf1.putExtra("search", "searchStr");
|
||||
startActivity(intentwf1);
|
||||
}
|
||||
// Intent intent1 = new Intent(getActivity(), FindHelpActivity.class);
|
||||
// startActivity(intent1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallbackFromThread(String resultJson) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallBackFromThread(String resultJson, int resultCode) {
|
||||
switch (resultCode){
|
||||
case USEWELFAREPAGE:
|
||||
LogUtil.i("USEWELFAREPAGE = "+resultJson);
|
||||
GetWelfarePageBean getWelfarePageBean = GsonTools.fromGsonToBean(resultJson, GetWelfarePageBean.class);
|
||||
if (getWelfarePageBean!=null&&"200".equals(getWelfarePageBean.getCode())){
|
||||
for (int i = 0;i<getWelfarePageBean.getData().size();i++){
|
||||
GetWelfarePageBean.DataBean dataBean = getWelfarePageBean.getData().get(i);
|
||||
String name =dataBean .getName();
|
||||
if ("jifen".equals(name)){
|
||||
xinzeng.setText(dataBean.getLeft_tip());
|
||||
tv_lijilingqu.setText(dataBean.getRight_tip());
|
||||
tv_danwei.setText(dataBean.getLeft_result().substring(dataBean.getLeft_result().length()-2));
|
||||
tv_num.setText(dataBean.getLeft_result().substring(0,dataBean.getLeft_result().length()-2));
|
||||
rl_jifen.setVisibility(View.VISIBLE);
|
||||
}
|
||||
// else if ("wanfang".equals(name)){
|
||||
// rl_wanfang.setVisibility(View.VISIBLE);
|
||||
// xinzeng1.setText(dataBean.getLeft_tip());
|
||||
// tv_wflijilingqu.setText(dataBean.getRight_tip());
|
||||
// tv_wfdanwei.setText(dataBean.getLeft_result().substring(dataBean.getLeft_result().length()-1));
|
||||
// tv_wfnum.setText(dataBean.getLeft_result().substring(0,dataBean.getLeft_result().length()-1));
|
||||
// }
|
||||
else if ("video".equals(name)){
|
||||
rl_shipin.setVisibility(View.VISIBLE);
|
||||
xinzeng2.setText(dataBean.getLeft_tip());
|
||||
tv_splijilingqu.setText(dataBean.getRight_tip());
|
||||
tv_spdanwei.setText(dataBean.getLeft_result().substring(dataBean.getLeft_result().length()-1));
|
||||
tv_spnum.setText(dataBean.getLeft_result().substring(0,dataBean.getLeft_result().length()-1));
|
||||
}else if ("kejian".equals(name)){
|
||||
rl_kejian.setVisibility(View.VISIBLE);
|
||||
xinzeng3.setText(dataBean.getLeft_tip());
|
||||
tv_kjlijilingqu.setText(dataBean.getRight_tip());
|
||||
tv_kjdanwei.setText(dataBean.getLeft_result().substring(dataBean.getLeft_result().length()-1));
|
||||
tv_kjnum.setText(dataBean.getLeft_result().substring(0,dataBean.getLeft_result().length()-1));
|
||||
}else if("daicha".equals(name))
|
||||
{
|
||||
wenxiannum=dataBean.getNum();
|
||||
rl_wenxian.setVisibility(View.VISIBLE);
|
||||
wen.setText(dataBean.getTitle());
|
||||
xinzeng7.setText(dataBean.getLeft_tip());
|
||||
tv_wnum.setText(dataBean.getNum()+"");
|
||||
// tv_wdanwei.setText();
|
||||
tv_duihuan.setText(dataBean.getRight_tip());
|
||||
}
|
||||
else if ("jingpin".equals(name)){
|
||||
// rl_kecheng.setVisibility(View.VISIBLE);
|
||||
// xinzeng4.setText(dataBean.getLeft_tip());
|
||||
// tv_kclijilingqu.setText(dataBean.getRight_tip());
|
||||
// tv_kcdanwei.setText(dataBean.getLeft_result().substring(dataBean.getLeft_result().length()-1));
|
||||
// tv_kcnum.setText(dataBean.getLeft_result().substring(0,dataBean.getLeft_result().length()-1));
|
||||
}else if ("upan".equals(name)){
|
||||
// upnum = dataBean.getNum();
|
||||
if(!StringUtil.isEmpty(dataBean.getLeft_result())&&dataBean.getLeft_result().length()>1)
|
||||
{
|
||||
upnum=Integer.valueOf(dataBean.getLeft_result().substring(0,dataBean.getLeft_result().length()-1));
|
||||
}
|
||||
if (upnum>0){
|
||||
rl_upan.setVisibility(View.VISIBLE);
|
||||
xinzeng5.setText("剩余兑换");
|
||||
tv_unum.setText(upnum+"");
|
||||
tv_ulijilingqu.setVisibility(View.VISIBLE);
|
||||
ll_upan.setVisibility(View.GONE);
|
||||
}else {
|
||||
upnum=0;
|
||||
rl_upan.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user