511 lines
24 KiB
Plaintext
511 lines
24 KiB
Plaintext
|
package com.example.administrator.ximengjianyu.activity.home;
|
|||
|
|
|||
|
import android.app.Activity;
|
|||
|
import android.app.Dialog;
|
|||
|
import android.content.BroadcastReceiver;
|
|||
|
import android.content.Context;
|
|||
|
import android.content.Intent;
|
|||
|
import android.content.IntentFilter;
|
|||
|
import android.graphics.drawable.AnimationDrawable;
|
|||
|
import android.os.Bundle;
|
|||
|
import android.os.Handler;
|
|||
|
import android.os.Message;
|
|||
|
import android.os.SystemClock;
|
|||
|
import android.support.v7.app.AppCompatActivity;
|
|||
|
import android.util.Log;
|
|||
|
import android.view.View;
|
|||
|
import android.view.Window;
|
|||
|
import android.view.WindowManager;
|
|||
|
import android.widget.AdapterView;
|
|||
|
import android.widget.Button;
|
|||
|
import android.widget.Chronometer;
|
|||
|
import android.widget.ImageView;
|
|||
|
import android.widget.ListView;
|
|||
|
import android.widget.TextView;
|
|||
|
import android.widget.Toast;
|
|||
|
|
|||
|
import com.bumptech.glide.Glide;
|
|||
|
import com.cm.utils.net.HttpUtils;
|
|||
|
import com.cm.utils.net.response.GsonResponseHandler;
|
|||
|
import com.example.administrator.ximengjianyu.R;
|
|||
|
import com.example.administrator.ximengjianyu.activity.LoginActivity;
|
|||
|
import com.example.administrator.ximengjianyu.adapter.HomeAdapter;
|
|||
|
import com.example.administrator.ximengjianyu.base.MyApplication;
|
|||
|
import com.example.administrator.ximengjianyu.beans.BoDaPhoneBean;
|
|||
|
import com.example.administrator.ximengjianyu.beans.ContactBean;
|
|||
|
import com.example.administrator.ximengjianyu.beans.FenJiZhuanTaiBean;
|
|||
|
import com.example.administrator.ximengjianyu.beans.GuanDuanPhoneBean;
|
|||
|
import com.example.administrator.ximengjianyu.beans.TuiChuBean;
|
|||
|
import com.example.administrator.ximengjianyu.beans.WebCTIStatus;
|
|||
|
import com.example.administrator.ximengjianyu.global.Constants;
|
|||
|
import com.example.administrator.ximengjianyu.global.UserInfo;
|
|||
|
import com.example.administrator.ximengjianyu.mqtt.push.MQTTService;
|
|||
|
import com.example.administrator.ximengjianyu.mqtt.push.MessageBean;
|
|||
|
import com.example.administrator.ximengjianyu.utils.CacheUtils;
|
|||
|
import com.example.administrator.ximengjianyu.utils.MDialog;
|
|||
|
|
|||
|
import org.json.JSONObject;
|
|||
|
|
|||
|
import java.io.Serializable;
|
|||
|
import java.util.HashMap;
|
|||
|
import java.util.List;
|
|||
|
import java.util.Map;
|
|||
|
|
|||
|
public class HomeActivity extends AppCompatActivity {
|
|||
|
/**
|
|||
|
* 声明activity,当做上下文使用
|
|||
|
*/
|
|||
|
public Activity mActivity;
|
|||
|
private ImageView person_touxiang;
|
|||
|
private TextView person_name;
|
|||
|
private TextView home_mouth_cishu;
|
|||
|
private TextView home_xiala;
|
|||
|
private TextView home_btn_newpwd;
|
|||
|
private View inflate;
|
|||
|
private List<ContactBean.ListBean> list;
|
|||
|
private ListView listView;
|
|||
|
private Dialog dialog;
|
|||
|
public Dialog guaduan_dialog;
|
|||
|
public Dialog baseDialog;
|
|||
|
private AnimationDrawable animationDrawable;
|
|||
|
/**
|
|||
|
* 声明点击返回按钮的时间
|
|||
|
*/
|
|||
|
private long clickBactButtonTime = 0;
|
|||
|
private Button home_btn_boda;
|
|||
|
private String status;
|
|||
|
private Button home_btn_guaduan;
|
|||
|
private Chronometer timer;
|
|||
|
private int surplusCount;
|
|||
|
private Button home_btn_tuichu;
|
|||
|
private Map<String, String> tuichumap;
|
|||
|
public View home_guaduan_dialog;
|
|||
|
private MessageBoradCast mBroadCast;
|
|||
|
private String tel = "";
|
|||
|
Handler mHandler = new Handler() {
|
|||
|
@Override
|
|||
|
public void handleMessage(Message msg) {
|
|||
|
GuanDuanPhoneBean response = (GuanDuanPhoneBean) msg.obj;
|
|||
|
// Toast.makeText(mActivity, "剩余次数" + response.getData().getSurplusCount(), Toast.LENGTH_LONG).show();
|
|||
|
MQTTService.actionStop(HomeActivity.this);
|
|||
|
//跳转登录页面
|
|||
|
if (guaduan_dialog != null && guaduan_dialog.isShowing()) {
|
|||
|
guaduan_dialog.dismiss();
|
|||
|
}
|
|||
|
tuichulogin();
|
|||
|
}
|
|||
|
};
|
|||
|
private Dialog progressDialog;
|
|||
|
private String home_guaduan_name;
|
|||
|
private String home_guaduan_relation;
|
|||
|
|
|||
|
@Override
|
|||
|
protected void onCreate(Bundle savedInstanceState) {
|
|||
|
super.onCreate(savedInstanceState);
|
|||
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|||
|
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|||
|
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
|||
|
mActivity = this;
|
|||
|
setContentView(R.layout.activity_home);
|
|||
|
getSupportActionBar().hide();//隐藏标题栏
|
|||
|
intiView();
|
|||
|
IntentFilter intentFilter = new IntentFilter();
|
|||
|
intentFilter.addAction("com.jianyu.open");
|
|||
|
mBroadCast = new MessageBoradCast();
|
|||
|
this.registerReceiver(mBroadCast, intentFilter);
|
|||
|
}
|
|||
|
|
|||
|
public void showCallDialog() {
|
|||
|
home_guaduan_dialog = View.inflate(mActivity, R.layout.home_guaduan_dialog, null);
|
|||
|
guaduan_dialog = new MDialog().mDialog(mActivity, home_guaduan_dialog);
|
|||
|
home_btn_guaduan = home_guaduan_dialog.findViewById(R.id.home_btn_guaduan);
|
|||
|
TextView guaduan_name = home_guaduan_dialog.findViewById(R.id.guaduan_name);
|
|||
|
timer = home_guaduan_dialog.findViewById(R.id.timer);
|
|||
|
timer.setBase(SystemClock.elapsedRealtime());//计时器清零
|
|||
|
timer.start();
|
|||
|
guaduan_name.setText(home_guaduan_name);
|
|||
|
TextView guaduan_guanxi = home_guaduan_dialog.findViewById(R.id.guaduan_guanxi);
|
|||
|
guaduan_guanxi.setText(" "+"("+home_guaduan_relation+")");
|
|||
|
TextView guaduan_phone = home_guaduan_dialog.findViewById(R.id.guaduan_phone);
|
|||
|
guaduan_phone.setText(home_xiala.getText().toString());
|
|||
|
|
|||
|
//挂断电话
|
|||
|
home_btn_guaduan.setOnClickListener(new View.OnClickListener() {
|
|||
|
@Override
|
|||
|
public void onClick(View view) {
|
|||
|
guaduan_dialog.dismiss();
|
|||
|
timer.stop();
|
|||
|
showEndDialog();
|
|||
|
Map<String, String> map = new HashMap<>();
|
|||
|
map.put("token", UserInfo.getToken(mActivity));
|
|||
|
map.put("phone", home_xiala.getText().toString());
|
|||
|
Log.e("TAG", "onClick: =Phone=" + UserInfo.getTel(mActivity));
|
|||
|
HttpUtils.getInstance().post(Constants.GUADUANPHONE, map, new GsonResponseHandler<GuanDuanPhoneBean>() {
|
|||
|
@Override
|
|||
|
public void onSuccess(int statusCode, GuanDuanPhoneBean response) {
|
|||
|
Log.e("==挂断成功==", response.toString());
|
|||
|
if (progressDialog != null && progressDialog.isShowing()) {
|
|||
|
progressDialog.dismiss();
|
|||
|
}
|
|||
|
if ("200".equals(response.getState())) {
|
|||
|
surplusCount = response.getData().getSurplusCount();
|
|||
|
// Toast.makeText(mActivity, "剩余次数" + response.getData().getSurplusCount(), Toast.LENGTH_SHORT).show();
|
|||
|
guaduan_dialog.dismiss();
|
|||
|
//停止服务
|
|||
|
MQTTService.actionStop(HomeActivity.this);
|
|||
|
tuichulogin();
|
|||
|
// Intent intent = new Intent(HomeActivity.this, LoginActivity.class);
|
|||
|
// startActivity(intent);
|
|||
|
//finish();
|
|||
|
} else if ("400".equals(response.getState())) {
|
|||
|
Toast.makeText(mActivity, response.getMsg(), Toast.LENGTH_SHORT).show();
|
|||
|
} else if ("202".equals(response.getState())) { //跳转到登录页面,并关闭其他activity
|
|||
|
//token会话失效,需要进入登录页面重新登录
|
|||
|
Intent intent = new Intent(HomeActivity.this, LoginActivity.class);
|
|||
|
startActivity(intent);
|
|||
|
finish();
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public void onFailure(int statusCode, String error_msg) {
|
|||
|
Log.e("==挂断error", error_msg);
|
|||
|
Toast.makeText(mActivity, "挂断失败", Toast.LENGTH_SHORT).show();
|
|||
|
if (progressDialog != null && progressDialog.isShowing()) {
|
|||
|
progressDialog.dismiss();
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
});
|
|||
|
guaduan_dialog.setCanceledOnTouchOutside(false);
|
|||
|
//设置Dialog窗口大小
|
|||
|
WindowManager.LayoutParams params = guaduan_dialog.getWindow().getAttributes();
|
|||
|
|
|||
|
params.width = 600;
|
|||
|
params.height = 450;
|
|||
|
guaduan_dialog.getWindow().setAttributes(params);
|
|||
|
guaduan_dialog.show();
|
|||
|
}
|
|||
|
|
|||
|
private void showEndDialog() {
|
|||
|
progressDialog = new Dialog(mActivity);
|
|||
|
//隐藏Dialog标题
|
|||
|
progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|||
|
View view = View.inflate(mActivity, R.layout.dialog_load, null);
|
|||
|
progressDialog.setContentView(view);
|
|||
|
TextView text = view.findViewById(R.id.progress_message);
|
|||
|
ImageView imge = view.findViewById(R.id.progress_view);
|
|||
|
animationDrawable = (AnimationDrawable) imge.getDrawable();
|
|||
|
if (animationDrawable != null) {
|
|||
|
animationDrawable.setOneShot(false);
|
|||
|
animationDrawable.start();
|
|||
|
}
|
|||
|
progressDialog.setCanceledOnTouchOutside(false);
|
|||
|
progressDialog.show();
|
|||
|
//设置Dialog窗口大小
|
|||
|
WindowManager.LayoutParams params = progressDialog.getWindow().getAttributes();
|
|||
|
params.width = 500;
|
|||
|
params.height = 200;
|
|||
|
progressDialog.getWindow().setAttributes(params);
|
|||
|
progressDialog.show();
|
|||
|
}
|
|||
|
|
|||
|
//初始化控件
|
|||
|
private void intiView() {
|
|||
|
home_btn_guaduan = (Button) findViewById(R.id.home_btn_guaduan);
|
|||
|
person_touxiang = (ImageView) findViewById(R.id.person_touxiang);
|
|||
|
person_name = (TextView) findViewById(R.id.person_name);
|
|||
|
home_mouth_cishu = (TextView) findViewById(R.id.home_mouth_cishu);
|
|||
|
home_xiala = (TextView) findViewById(R.id.home_xiala);
|
|||
|
home_btn_newpwd = (TextView) findViewById(R.id.home_btn_newpwd);
|
|||
|
home_btn_boda = (Button) findViewById(R.id.home_btn_boda);
|
|||
|
home_btn_tuichu = (Button) findViewById(R.id.home_btn_tuichu);
|
|||
|
|
|||
|
//点击退回到登录页面
|
|||
|
home_btn_tuichu.setOnClickListener(new View.OnClickListener() {
|
|||
|
@Override
|
|||
|
public void onClick(View view) {
|
|||
|
tuichulogin();
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
//拨打电话
|
|||
|
home_btn_boda.setOnClickListener(new View.OnClickListener() {
|
|||
|
@Override
|
|||
|
public void onClick(View view) {
|
|||
|
|
|||
|
if (home_xiala.getText().toString().equals("")) {
|
|||
|
Toast.makeText(mActivity, "请选择联系人", Toast.LENGTH_SHORT).show();
|
|||
|
return;
|
|||
|
}
|
|||
|
if (UserInfo.getSurplusCount(mActivity) <= 0) {
|
|||
|
Toast.makeText(mActivity, "通话次数已用完", Toast.LENGTH_SHORT).show();
|
|||
|
} else {
|
|||
|
if (status.equals("1")) {
|
|||
|
intDialog("正在呼叫...");
|
|||
|
final Map<String, String> map = new HashMap<>();
|
|||
|
map.put("token", UserInfo.getToken(mActivity));
|
|||
|
map.put("phone", home_xiala.getText().toString());
|
|||
|
HttpUtils.getInstance().post(Constants.PHONE, map, new GsonResponseHandler<BoDaPhoneBean>() {
|
|||
|
@Override
|
|||
|
public void onSuccess(int statusCode, BoDaPhoneBean response) {
|
|||
|
// Log.e("==呼出成功==",response.toString());
|
|||
|
Log.e("==getState==", response.getState());
|
|||
|
dismissDialog();
|
|||
|
if ("400".equals(response.getState())) {
|
|||
|
Toast.makeText(mActivity, response.getMsg(), Toast.LENGTH_SHORT).show();
|
|||
|
} else if ("202".equals(response.getState())) { //跳转到登录页面,并关闭其他activity
|
|||
|
//token会话失效,需要进入登录页面重新登录
|
|||
|
Intent intent = new Intent(HomeActivity.this, LoginActivity.class);
|
|||
|
startActivity(intent);
|
|||
|
finish();
|
|||
|
// judgeHasClickedSave();
|
|||
|
} else if ("200".equals(response.getState())) {
|
|||
|
Toast.makeText(mActivity, "成功呼出", Toast.LENGTH_SHORT).show();
|
|||
|
//调用通知启动方法
|
|||
|
// Intent intent = new Intent(HomeActivity.this, MQTTService.class);
|
|||
|
// HomeActivity.this.startService(intent);
|
|||
|
MQTTService.actionStart(HomeActivity.this);
|
|||
|
showCallDialog();
|
|||
|
} else if ("400".equals(response.getState())) {
|
|||
|
Toast.makeText(mActivity, response.getMsg(), Toast.LENGTH_SHORT).show();
|
|||
|
} else if ("202".equals(response.getState())) { //跳转到登录页面,并关闭其他activity
|
|||
|
//token会话失效,需要进入登录页面重新登录
|
|||
|
Intent intent = new Intent(HomeActivity.this, LoginActivity.class);
|
|||
|
startActivity(intent);
|
|||
|
finish();
|
|||
|
// judgeHasClickedSave();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public void onFailure(int statusCode, String error_msg) {
|
|||
|
// Toast.makeText(mActivity,error_msg,Toast.LENGTH_SHORT).show();
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
if (status.equals("0")) {
|
|||
|
Toast.makeText(mActivity, "禁止呼出", Toast.LENGTH_SHORT).show();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
|
|||
|
//点击修改密码
|
|||
|
home_btn_newpwd.setOnClickListener(new View.OnClickListener() {
|
|||
|
@Override
|
|||
|
public void onClick(View view) {
|
|||
|
Intent intent = new Intent(HomeActivity.this, NewPwdActivity.class);
|
|||
|
startActivity(intent);
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
//亲情列表
|
|||
|
Map<String, String> map = new HashMap<>();
|
|||
|
map.put("token", UserInfo.getToken(mActivity));
|
|||
|
HttpUtils.getInstance().post(Constants.CONSTANTS, map, new GsonResponseHandler<ContactBean>() {
|
|||
|
@Override
|
|||
|
public void onSuccess(int statusCode, ContactBean response) {
|
|||
|
Log.e("亲情列表:", response.toString());
|
|||
|
if ("200".equals(response.getState())) {
|
|||
|
list = response.getList();
|
|||
|
} else if ("400".equals(response.getState())) {
|
|||
|
Toast.makeText(mActivity, response.getMsg(), Toast.LENGTH_SHORT).show();
|
|||
|
} else if ("202".equals(response.getState())) { //跳转到登录页面,并关闭其他activity
|
|||
|
//token会话失效,需要进入登录页面重新登录
|
|||
|
Intent intent = new Intent(HomeActivity.this, LoginActivity.class);
|
|||
|
startActivity(intent);
|
|||
|
finish();
|
|||
|
// judgeHasClickedSave();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public void onFailure(int statusCode, String error_msg) {
|
|||
|
Toast.makeText(mActivity, "请检查网络", Toast.LENGTH_SHORT).show();
|
|||
|
}
|
|||
|
});
|
|||
|
Glide.with(mActivity).load(UserInfo.getIcon(mActivity)).into(person_touxiang);
|
|||
|
person_name.setText(UserInfo.getName(mActivity));
|
|||
|
home_mouth_cishu.setText("本月剩余次数 " + UserInfo.getBirthday(mActivity));
|
|||
|
// if (UserInfo.getSurplusCount(mActivity)<=0){
|
|||
|
// Toast.makeText(mActivity,"当前通话次数为0",Toast.LENGTH_SHORT).show();
|
|||
|
// }
|
|||
|
//点击弹出对话框
|
|||
|
home_xiala.setOnClickListener(new View.OnClickListener() {
|
|||
|
|
|||
|
@Override
|
|||
|
public void onClick(View view) {
|
|||
|
View inflate = View.inflate(mActivity, R.layout.home_dialog, null);
|
|||
|
listView = inflate.findViewById(R.id.dialog_listview);
|
|||
|
//点击条目
|
|||
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|||
|
@Override
|
|||
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|||
|
|
|||
|
// for (int j = 0; j <list.size() ; j++) {
|
|||
|
// home_xiala.setText(list.get(i).getPhone());
|
|||
|
// status = list.get(i).getStatus();
|
|||
|
// }
|
|||
|
home_xiala.setText(list.get(i).getPhone());
|
|||
|
home_guaduan_name = list.get(i).getName();
|
|||
|
home_guaduan_relation = list.get(i).getRelation();
|
|||
|
Log.e("选择联系人",list.get(i).getPhone());
|
|||
|
status = list.get(i).getStatus();
|
|||
|
Log.e("判断是否可以呼出1为可以0为禁止 ", status.toString());
|
|||
|
dialog.dismiss();
|
|||
|
}
|
|||
|
});
|
|||
|
listView.setAdapter(new HomeAdapter(mActivity, list));
|
|||
|
dialog = new MDialog().mDialog(mActivity, inflate);
|
|||
|
dialog.setCanceledOnTouchOutside(true);
|
|||
|
//设置Dialog窗口大小
|
|||
|
WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
|
|||
|
// params.width = 500;
|
|||
|
// params.height = 400 ;
|
|||
|
params.width = 1000;
|
|||
|
params.height = 700;
|
|||
|
dialog.getWindow().setAttributes(params);
|
|||
|
dialog.show();
|
|||
|
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* 退出登录
|
|||
|
*/
|
|||
|
public void tuichulogin() {
|
|||
|
tuichumap = new HashMap<String, String>();
|
|||
|
tuichumap.put("token", UserInfo.getToken(mActivity));
|
|||
|
HttpUtils.getInstance().post(mActivity, Constants.TUICHUDENGLU, tuichumap, new GsonResponseHandler<TuiChuBean>() {
|
|||
|
@Override
|
|||
|
public void onSuccess(int statusCode, TuiChuBean response) {
|
|||
|
if ("200".equals(response.getState())) {
|
|||
|
Intent intent = new Intent(HomeActivity.this, LoginActivity.class);
|
|||
|
startActivity(intent);
|
|||
|
finish();
|
|||
|
} else if ("400".equals(response.getState())) {
|
|||
|
Toast.makeText(mActivity, response.getMsg(), Toast.LENGTH_SHORT).show();
|
|||
|
} else if ("202".equals(response.getState())) { //跳转到登录页面,并关闭其他activity
|
|||
|
//token会话失效,需要进入登录页面重新登录
|
|||
|
Intent intent = new Intent(HomeActivity.this, LoginActivity.class);
|
|||
|
startActivity(intent);
|
|||
|
finish();
|
|||
|
// judgeHasClickedSave();
|
|||
|
}
|
|||
|
}
|
|||
|
@Override
|
|||
|
public void onFailure(int statusCode, String error_msg) {
|
|||
|
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* 广播接收
|
|||
|
*/
|
|||
|
public class MessageBoradCast extends BroadcastReceiver {
|
|||
|
@Override
|
|||
|
public void onReceive(Context context, Intent intent) {
|
|||
|
MessageBean bean = (MessageBean) intent.getSerializableExtra("Bean");
|
|||
|
Log.e("Message", "onReceive: " + bean);
|
|||
|
String messageFlag = bean.getMessageFlag();
|
|||
|
String sextensionState = bean.getSextensionState();
|
|||
|
String extensionNumber = bean.getExtensionNumber();
|
|||
|
// UserInfo.getExtensionNumber(mActivity))
|
|||
|
Log.e("分机号",extensionNumber);
|
|||
|
if ("1".equals(messageFlag) && extensionNumber.equals(bean.getExtensionNumber())) {
|
|||
|
if (WebCTIStatus.UNAVAILABLE.equals(sextensionState) | WebCTIStatus.IDLE.equals(sextensionState)) {
|
|||
|
final Map<String, String> map = new HashMap<>();
|
|||
|
map.put("token", UserInfo.getToken(mActivity));
|
|||
|
map.put("phone", home_xiala.getText().toString());
|
|||
|
showEndDialog();
|
|||
|
HttpUtils.getInstance().post(Constants.GUADUANPHONE, map, new GsonResponseHandler<GuanDuanPhoneBean>() {
|
|||
|
@Override
|
|||
|
public void onSuccess(int statusCode, GuanDuanPhoneBean response) {
|
|||
|
if (progressDialog != null && progressDialog.isShowing()){
|
|||
|
progressDialog.dismiss();
|
|||
|
}
|
|||
|
Log.e("==挂断成功==", response.toString());
|
|||
|
if ("200".equals(response.getState())) {
|
|||
|
Message msg = new Message();
|
|||
|
msg.obj = response;
|
|||
|
mHandler.sendMessage(msg);
|
|||
|
} else if ("400".equals(response.getState())) {
|
|||
|
Toast.makeText(mActivity, response.getMsg(), Toast.LENGTH_SHORT).show();
|
|||
|
} else if ("202".equals(response.getState())) { //跳转到登录页面,并关闭其他activity
|
|||
|
//token会话失效,需要进入登录页面重新登录
|
|||
|
Intent intent = new Intent(HomeActivity.this, LoginActivity.class);
|
|||
|
startActivity(intent);
|
|||
|
finish();
|
|||
|
}
|
|||
|
}
|
|||
|
@Override
|
|||
|
public void onFailure(int statusCode, String error_msg) {
|
|||
|
Log.e("Error", "onFailure: " + error_msg);
|
|||
|
if (progressDialog != null && progressDialog.isShowing()){
|
|||
|
progressDialog.dismiss();
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* 呼叫Dialog
|
|||
|
*
|
|||
|
* @param content
|
|||
|
* @return
|
|||
|
*/
|
|||
|
public Dialog intDialog(String content) {
|
|||
|
Log.i("------------", mActivity.toString());
|
|||
|
baseDialog = new Dialog(mActivity);
|
|||
|
//隐藏Dialog标题
|
|||
|
baseDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|||
|
View view = View.inflate(mActivity, R.layout.dialog_load, null);
|
|||
|
baseDialog.setContentView(view);
|
|||
|
TextView text = view.findViewById(R.id.progress_message);
|
|||
|
ImageView imge = view.findViewById(R.id.progress_view);
|
|||
|
animationDrawable = (AnimationDrawable) imge.getDrawable();
|
|||
|
if (animationDrawable != null) {
|
|||
|
animationDrawable.setOneShot(false);
|
|||
|
animationDrawable.start();
|
|||
|
}
|
|||
|
baseDialog.setCanceledOnTouchOutside(false);
|
|||
|
text.setText(content);
|
|||
|
baseDialog.show();
|
|||
|
//设置Dialog窗口大小
|
|||
|
WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
|
|||
|
params.width = 500;
|
|||
|
params.height = 200;
|
|||
|
dialog.getWindow().setAttributes(params);
|
|||
|
return baseDialog;
|
|||
|
}
|
|||
|
/**
|
|||
|
* 隐藏Dialog
|
|||
|
*/
|
|||
|
public void dismissDialog() {
|
|||
|
if (baseDialog != null) {
|
|||
|
baseDialog.dismiss();
|
|||
|
}
|
|||
|
}
|
|||
|
@Override
|
|||
|
protected void onDestroy() {
|
|||
|
if (mBroadCast != null) {
|
|||
|
unregisterReceiver(mBroadCast);
|
|||
|
}
|
|||
|
guaduan_dialog = null;
|
|||
|
home_guaduan_dialog = null;
|
|||
|
dialog = null;
|
|||
|
super.onDestroy();
|
|||
|
}
|
|||
|
}
|