package com.tejia.lijin.app.ui.mine;
|
|
import android.app.Dialog;
|
import android.content.Context;
|
import android.content.Intent;
|
import android.content.SharedPreferences;
|
import android.os.Bundle;
|
import android.view.View;
|
import android.widget.FrameLayout;
|
import android.widget.ImageView;
|
import android.widget.LinearLayout;
|
import android.widget.TextView;
|
|
import com.google.gson.Gson;
|
import com.tejia.lijin.app.BasicTextHttpResponseHandler;
|
import com.tejia.lijin.app.R;
|
import com.tejia.lijin.app.ShoppingApi;
|
import com.tejia.lijin.app.ShoppingApplication;
|
import com.tejia.lijin.app.entity.user.money.statistic.MoneyStatisticVO;
|
import com.tejia.lijin.app.ui.BaseActivity;
|
import com.tejia.lijin.app.ui.invite.ShareBrowserActivity;
|
import com.tejia.lijin.app.ui.main.MainActivity;
|
import com.tejia.lijin.app.util.ToolUtil;
|
import com.tejia.lijin.app.util.TopStatusSettings;
|
import com.tejia.lijin.app.util.umengCustomEvent.UserCustomEvent;
|
import com.tejia.lijin.app.util.user.UserUtil;
|
import com.wpc.library.util.common.StringUtils;
|
|
import org.apache.http.Header;
|
import org.json.JSONException;
|
import org.json.JSONObject;
|
|
import java.math.BigDecimal;
|
|
/**
|
* Created by weikou2015 on 2018/1/18.
|
* 资金
|
*/
|
|
public class LijinCapitalActivity extends BaseActivity implements View.OnClickListener {
|
TextView tv_left, tv_middle, tv_available_rebate,
|
tv_mine_drawcash;
|
private String TYPE = "lijinMoney";
|
private TextView tv_notice_content;
|
private LinearLayout ll_notice;
|
private ImageView iv_close;
|
private TextView tv_available_withdrawal;//提款中 显示余额
|
|
|
//账户明细,提现记录
|
private FrameLayout fl_account_detail, fl_withdraw_history;
|
|
|
@Override
|
protected void onCreate(Bundle savedInstanceState) {
|
super.onCreate(savedInstanceState);
|
setContentView(R.layout.activity_lijin_capital);
|
TopStatusSettings.setStatusViewAndDeepColor(this);
|
tv_left = findViewById(R.id.tv_top_bar_left);
|
tv_middle = findViewById(R.id.tv_top_bar_middle);
|
tv_available_rebate = findViewById(R.id.tv_available_rebate);
|
tv_mine_drawcash = findViewById(R.id.tv_mine_drawcash);
|
tv_available_withdrawal = findViewById(R.id.tv_available_withdrawal);
|
|
|
fl_account_detail = findViewById(R.id.fl_account_detail);
|
fl_withdraw_history = findViewById(R.id.fl_withdraw_history);
|
|
fl_account_detail.setOnClickListener(this);
|
fl_withdraw_history.setOnClickListener(this);
|
findViewById(R.id.tv_course).setOnClickListener(this);
|
findViewById(R.id.tv_rule).setOnClickListener(this);
|
|
|
tv_middle.setText("礼金红包");
|
|
|
tv_notice_content = findViewById(R.id.tv_notice_content);
|
ll_notice = findViewById(R.id.ll_notice);
|
iv_close = findViewById(R.id.iv_close);
|
getAppPageNotification();
|
|
tv_left.setOnClickListener(this);
|
tv_mine_drawcash.setOnClickListener(this);
|
}
|
|
|
@Override
|
protected void onResume() {
|
super.onResume();
|
getUserMoney();
|
}
|
|
private void getAppPageNotification() {
|
ShoppingApi.getAppPageNotification(this, TYPE, new BasicTextHttpResponseHandler() {
|
@Override
|
public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
|
if (jsonObject.optInt("code") == 0) {
|
boolean isClose = jsonObject.optJSONObject("data").optBoolean("canClose");
|
String content = jsonObject.optJSONObject("data").optString("content");
|
final String contentUrl = jsonObject.optJSONObject("data").optString("contentUrl");
|
final String md5 = jsonObject.optJSONObject("data").optString("md5");
|
|
tv_notice_content.setText(content);
|
final SharedPreferences sp = getSharedPreferences("notice", Context.MODE_PRIVATE);
|
if (!sp.getBoolean(md5, false)) {//false 展示,true不展示
|
ll_notice.setVisibility(View.VISIBLE);
|
} else {
|
ll_notice.setVisibility(View.GONE);
|
}
|
|
if (isClose) {
|
iv_close.setImageDrawable(getResources().getDrawable(R.drawable.ic_notice_close));
|
iv_close.setOnClickListener(new View.OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
ll_notice.setVisibility(View.GONE);
|
SharedPreferences.Editor editor = sp.edit();
|
editor.putBoolean(md5, true);
|
editor.commit();
|
}
|
});
|
} else {
|
iv_close.setImageDrawable(getResources().getDrawable(R.drawable.ic_notice_input));
|
}
|
ll_notice.setOnClickListener(new View.OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
if (StringUtils.isEmpty(contentUrl))
|
return;
|
Intent intent = new Intent(LijinCapitalActivity.this, ShareBrowserActivity.class);
|
intent.putExtra("url", contentUrl);
|
startActivity(intent);
|
}
|
});
|
}
|
}
|
});
|
}
|
|
private void getUserMoney() {
|
ShoppingApi.getHongBaoBalance(this, new BasicTextHttpResponseHandler() {
|
@Override
|
public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
|
super.onSuccessPerfect(statusCode, headers, jsonObject);
|
if (jsonObject.optInt("code") == 0) {
|
setUserMoneyInfo(jsonObject.optJSONObject("data"));
|
}
|
|
}
|
|
@Override
|
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
|
super.onFailure(statusCode, headers, responseString, throwable);
|
ToolUtil.showToast(tv_available_rebate.getContext(), "网络连接异常,请检测网络设置");
|
}
|
});
|
}
|
|
String ruleLink = null;
|
String courseLink = null;
|
String recordLink = null;
|
|
|
private void setUserMoneyInfo(JSONObject data) {
|
ruleLink = data.optString("ruleLink");
|
courseLink = data.optString("courseLink");
|
recordLink = data.optString("recordLink");
|
String balance = data.optString("balance");
|
tv_available_rebate.setText(balance);
|
String using = data.optString("using");
|
|
if (!StringUtils.isNullOrEmpty(using) && new BigDecimal(using).compareTo(new BigDecimal(0)) > 0) {
|
tv_available_withdrawal.setText("使用中:¥ " + data.optString("using"));//使用中
|
} else {
|
tv_available_withdrawal.setText("");
|
}
|
}
|
|
|
@Override
|
public void onClick(View view) {
|
switch (view.getId()) {
|
case R.id.tv_top_bar_left:
|
finish();
|
break;
|
case R.id.tv_top_bar_right://账目明细
|
|
break;
|
case R.id.tv_mine_drawcash://提现
|
Intent intent = new Intent(LijinCapitalActivity.this, MainActivity.class);
|
startActivity(intent);
|
break;
|
case R.id.fl_account_detail://账户明细
|
if (!StringUtils.isNullOrEmpty(recordLink)) {
|
startActivity(new Intent(LijinCapitalActivity.this, ShareBrowserActivity.class).putExtra("url", recordLink));
|
}
|
break;
|
case R.id.tv_course://教程
|
if (!StringUtils.isNullOrEmpty(courseLink)) {
|
startActivity(new Intent(LijinCapitalActivity.this, ShareBrowserActivity.class).putExtra("url", courseLink));
|
}
|
break;
|
case R.id.tv_rule://规则
|
if (!StringUtils.isNullOrEmpty(ruleLink)) {
|
startActivity(new Intent(LijinCapitalActivity.this, ShareBrowserActivity.class).putExtra("url", ruleLink));
|
}
|
break;
|
}
|
}
|
|
|
@Override
|
protected void onPause() {
|
super.onPause();
|
}
|
|
@Override
|
protected void onDestroy() {
|
super.onDestroy();
|
|
}
|
}
|