package com.haicaojie.android.ui.mine;
|
|
import android.content.DialogInterface;
|
import android.content.Intent;
|
import android.content.SharedPreferences;
|
import android.os.Build;
|
import android.os.Bundle;
|
import android.view.View;
|
import android.view.Window;
|
import android.view.WindowManager;
|
import android.widget.LinearLayout;
|
import android.widget.TextView;
|
|
import com.haicaojie.android.BasicTextHttpResponseHandler;
|
import com.haicaojie.android.R;
|
import com.haicaojie.android.ShoppingApi;
|
import com.haicaojie.android.ui.BaseActivity;
|
import com.haicaojie.android.util.ProfitEstimateDialog;
|
import com.lcjian.library.util.SingleToast;
|
|
import org.apache.http.Header;
|
import org.json.JSONObject;
|
|
/**
|
* Created by weikou2015 on 2018/1/18.
|
* 资金
|
*/
|
|
public class CapitalActivity extends BaseActivity implements View.OnClickListener {
|
TextView tv_left, tv_middle, tv_available_rebate, tv_rebate_total,
|
tv_unavailable_rebate, tv_withdraw_cash, tv_withdraw_hint, tv_percentage_total, tv_unavailable_percentage;
|
private TextView tv_estimate_today, tv_estimate_month, tv_last_month;
|
private LinearLayout ll_account_details, ll_estimate_today, ll_estimate_month, ll_last_month;
|
|
@Override
|
protected void onCreate(Bundle savedInstanceState) {
|
super.onCreate(savedInstanceState);
|
setContentView(R.layout.activity_rebate);
|
/*
|
* 计算状态栏高度并设置
|
*/
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
Window window = getWindow();
|
window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
|
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
int result = 0;
|
int resourceId = getResources().getIdentifier("status_bar_height",
|
"dimen", "android");
|
if (resourceId > 0) {
|
result = getResources().getDimensionPixelSize(resourceId);
|
}
|
//设置状态栏文字颜色及图标为深色
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
|
result);
|
findViewById(R.id.v_status_bar).setLayoutParams(params);
|
} else {
|
findViewById(R.id.v_status_bar).setVisibility(View.GONE);
|
}
|
tv_left = (TextView) findViewById(R.id.tv_top_bar_left);
|
tv_middle = (TextView) findViewById(R.id.tv_top_bar_middle);
|
ll_account_details = (LinearLayout) findViewById(R.id.ll_account_details);
|
tv_available_rebate = (TextView) findViewById(R.id.tv_available_rebate);
|
tv_rebate_total = (TextView) findViewById(R.id.tv_rebate_total);
|
tv_unavailable_rebate = (TextView) findViewById(R.id.tv_unavailable_rebate);
|
tv_withdraw_cash = (TextView) findViewById(R.id.tv_withdraw_cash);
|
tv_withdraw_hint = (TextView) findViewById(R.id.tv_withdraw_hint);
|
tv_estimate_today = (TextView) findViewById(R.id.tv_estimate_today);
|
tv_estimate_month = (TextView) findViewById(R.id.tv_estimate_month);
|
tv_last_month = (TextView) findViewById(R.id.tv_last_month);
|
tv_percentage_total = (TextView) findViewById(R.id.tv_percentage_total);
|
tv_unavailable_percentage = (TextView) findViewById(R.id.tv_unavailable_percentage);
|
ll_estimate_today = (LinearLayout) findViewById(R.id.ll_estimate_today);
|
ll_estimate_month = (LinearLayout) findViewById(R.id.ll_estimate_month);
|
ll_last_month = (LinearLayout) findViewById(R.id.ll_last_month);
|
tv_middle.setText("资金");
|
|
SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE);
|
String myHongBao = getIntent().getStringExtra("myHongBao");
|
String totalHongBao = getIntent().getStringExtra("totalHongBao");
|
String noOpenHongBao = getIntent().getStringExtra("noOpenHongBao");
|
tv_rebate_total.setText(totalHongBao);
|
tv_available_rebate.setText(myHongBao);
|
tv_unavailable_rebate.setText(noOpenHongBao);
|
tv_withdraw_hint.setText(sp.getString("Prompt", "") + "\n" + sp.getString("Prompt2", ""));
|
|
tv_left.setOnClickListener(this);
|
ll_account_details.setOnClickListener(this);
|
tv_withdraw_cash.setOnClickListener(this);
|
ll_estimate_today.setOnClickListener(this);
|
ll_estimate_month.setOnClickListener(this);
|
ll_last_month.setOnClickListener(this);
|
}
|
|
@Override
|
protected void onResume() {
|
super.onResume();
|
getUserMoney();
|
}
|
|
private void getUserMoney() {
|
String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", "0");
|
ShoppingApi.getUserMoney(this, uid, new BasicTextHttpResponseHandler() {
|
@Override
|
public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
|
if (jsonObject.optString("code").equalsIgnoreCase("0")) {
|
tv_available_rebate.setText(jsonObject.optJSONObject("data").optString("money"));
|
tv_rebate_total.setText(jsonObject.optJSONObject("data").optString("totalFanLiMoney"));
|
tv_unavailable_rebate.setText(jsonObject.optJSONObject("data").optString("unGetMoney"));
|
tv_estimate_today.setText(jsonObject.optJSONObject("data").optString("moneyToday"));
|
tv_estimate_month.setText(jsonObject.optJSONObject("data").optString("moneyMonth"));
|
tv_last_month.setText(jsonObject.optJSONObject("data").optString("moneyLastMonth"));
|
tv_percentage_total.setText(jsonObject.optJSONObject("data").optString("totalTiChengMoney"));
|
tv_unavailable_percentage.setText(jsonObject.optJSONObject("data").optString("totalUnGetTiChengMoney"));
|
}
|
}
|
});
|
}
|
|
@Override
|
public void onClick(View view) {
|
switch (view.getId()) {
|
case R.id.tv_top_bar_left:
|
finish();
|
break;
|
case R.id.ll_account_details:
|
startActivity(new Intent(CapitalActivity.this, AccountDetailActivity.class));
|
break;
|
case R.id.tv_withdraw_cash:
|
Intent intent = new Intent(CapitalActivity.this, WithdrawCashActivity.class);
|
startActivity(intent);
|
break;
|
case R.id.ll_estimate_today:
|
ProfitEstimateDialog.Builder builder = new ProfitEstimateDialog.Builder(CapitalActivity.this);
|
builder.setTitle("今日预估分享奖金").setMessage("今日新增的分享订单预估奖金").setPositiveButton("知道啦", new DialogInterface.OnClickListener() {
|
@Override
|
public void onClick(DialogInterface dialogInterface, int i) {
|
dialogInterface.dismiss();
|
}
|
}).create().show();
|
|
break;
|
case R.id.ll_estimate_month:
|
ProfitEstimateDialog.Builder builder1 = new ProfitEstimateDialog.Builder(CapitalActivity.this);
|
builder1.setTitle("本月预估分享奖金").setMessage("本月内产生的所有的分享订单预估奖金,会在订单确认收货后的次月25日后转入您的余额,以实际转入余额为准").setPositiveButton("知道啦", new DialogInterface.OnClickListener() {
|
@Override
|
public void onClick(DialogInterface dialogInterface, int i) {
|
dialogInterface.dismiss();
|
}
|
}).create().show();
|
break;
|
case R.id.ll_last_month:
|
ProfitEstimateDialog.Builder builder2 = new ProfitEstimateDialog.Builder(CapitalActivity.this);
|
builder2.setTitle("上月分享奖金").setMessage("上个月内确认收货的分享订单奖金会在每月25日结算后,自动转入您的余额").setPositiveButton("知道啦", new DialogInterface.OnClickListener() {
|
@Override
|
public void onClick(DialogInterface dialogInterface, int i) {
|
dialogInterface.dismiss();
|
}
|
}).create().show();
|
break;
|
}
|
}
|
}
|