154 lines
5.1 KiB
Java
154 lines
5.1 KiB
Java
package com.sl.house_property;
|
|
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.internal.LinkedTreeMap;
|
|
import com.google.gson.reflect.TypeToken;
|
|
import com.sl.house_property.databinding.ActivityEntranceguardBinding;
|
|
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
import java.lang.reflect.Type;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
import entity.HomelistitemEntity;
|
|
import entity.RegisterUser;
|
|
import my_loader.Loader;
|
|
import my_loader.Resultcode;
|
|
import tools.Config;
|
|
import http.ApiConfig;
|
|
import rx.Subscription;
|
|
import rx.functions.Action1;
|
|
import utils.Md5;
|
|
|
|
public class EntranceguardActivity extends BaseActivity<ActivityEntranceguardBinding> {
|
|
|
|
private Loader mGankLoader;
|
|
|
|
@Override
|
|
protected int getLayoutResId() {
|
|
return R.layout.activity_entranceguard;
|
|
}
|
|
ArrayList<HomelistitemEntity> list;
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
setAbr("门禁系统", new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View view) {
|
|
finish();
|
|
}
|
|
},0,null,0,null,0,null,"");
|
|
mDataBinding.control1.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View view) {
|
|
if(list==null||list.size()==0){
|
|
setToast(2,"您没有房屋");
|
|
return;
|
|
}
|
|
Intent intent=new Intent(EntranceguardActivity.this,EntranceguardControl1Activity.class);
|
|
intent.putExtra("list",list);
|
|
intent.putExtra("titile","授权访客密码");
|
|
startActivity(intent);
|
|
}
|
|
});
|
|
mDataBinding.control2.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View view) {
|
|
if(list==null||list.size()==0){
|
|
setToast(2,"您没有房屋");
|
|
return;
|
|
}
|
|
Intent intent=new Intent(EntranceguardActivity.this,EntranceguardControl2Activity.class);
|
|
intent.putExtra("titile","授权访客二维码");
|
|
intent.putExtra("list",list);
|
|
startActivity(intent);
|
|
|
|
}
|
|
});
|
|
Map<String,String> map=new HashMap<>();
|
|
RegisterUser registerUser= Config.getInstance(EntranceguardActivity.this).getUser();
|
|
if(registerUser!=null){
|
|
map.put("userid",registerUser.getUserid());
|
|
}
|
|
else {
|
|
map.put("userid",0+"");
|
|
}
|
|
|
|
map.put("sign", Md5.md5("Cas"+"GetMyAddress"+Md5.secret));
|
|
map.put("app", "Cas");
|
|
map.put("class", "GetMyAddress");
|
|
getGankList(ApiConfig.BASE_URL,map, getResources().getString(R.string.registering),0);
|
|
}
|
|
private void getGankList(final String myurl, Map<String, String> map, String string, final int getcode1) {
|
|
progressDialog.setMessage(string);
|
|
|
|
//map.put("")
|
|
progressDialog.setCancelable(false);
|
|
progressDialog.show();
|
|
mDataBinding.getRoot().postDelayed(new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
progressDialog.dismiss();
|
|
//setToast(1, getString(R.string.timeout));
|
|
}
|
|
},13000);
|
|
mGankLoader = new Loader();
|
|
/* Map<String,String> map=new HashMap<String,String>();
|
|
map.put("phone");*/
|
|
Subscription subscription = mGankLoader.getMovie(myurl,map).subscribe(new Action1<Resultcode>() {
|
|
@Override
|
|
public void call(Resultcode resultcode) {
|
|
progressDialog.dismiss();
|
|
//setToast(0,resultcode.status);
|
|
if((!(resultcode.status==0))){
|
|
setToast(1, resultcode.msg);
|
|
return;
|
|
}
|
|
switch (getcode1) {
|
|
|
|
case 0:
|
|
Gson gs = new Gson();
|
|
LinkedTreeMap adta= (LinkedTreeMap) resultcode.data;
|
|
String s = gs.toJson(adta);
|
|
try {
|
|
JSONObject jsonObject=new JSONObject(s);
|
|
JSONArray jsonArray=jsonObject.getJSONArray("home");
|
|
Type type = new TypeToken<ArrayList<HomelistitemEntity>>(){}.getType();
|
|
list = new Gson().fromJson(jsonArray.toString(), type);
|
|
|
|
|
|
|
|
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}, new Action1<Throwable>() {
|
|
@Override
|
|
public void call(Throwable throwable) {
|
|
progressDialog.dismiss();
|
|
setToast(2,getString(R.string.getdatafailure));
|
|
throwable.printStackTrace();
|
|
}
|
|
});
|
|
|
|
addSubscription(subscription);
|
|
}
|
|
}
|