1
This commit is contained in:
@@ -300,6 +300,7 @@
|
||||
<activity android:name=".discovery.HistoryRecordActivity" />
|
||||
<activity android:name=".discovery.ShareCodeActivity" />
|
||||
<activity android:name=".discovery.PropertyActivity" android:theme="@style/TAppTheme" />
|
||||
<activity android:name=".CodeActivity" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
254
app/src/main/java/com/sl/house_property/CodeActivity.java
Normal file
254
app/src/main/java/com/sl/house_property/CodeActivity.java
Normal file
@@ -0,0 +1,254 @@
|
||||
package com.sl.house_property;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.internal.LinkedTreeMap;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.selectpicker.OptionsPopupWindow;
|
||||
import com.sl.house_property.databinding.ActivityCodeBinding;
|
||||
import com.sl.house_property.discovery.ShareCodeActivity;
|
||||
|
||||
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 http.ApiConfig;
|
||||
import my_loader.Loader;
|
||||
import my_loader.Resultcode;
|
||||
import rx.Subscription;
|
||||
import rx.functions.Action1;
|
||||
import tools.Config;
|
||||
import utils.Md5;
|
||||
import utils.QRCodeUtil;
|
||||
|
||||
public class CodeActivity extends BaseActivity<ActivityCodeBinding> {
|
||||
|
||||
private String address;
|
||||
public ProgressDialog progressDialog;
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.activity_code;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ImmersionBar.with(this)
|
||||
.keyboardEnable(true) //解决软键盘与底部输入框冲突问题
|
||||
// .keyboardEnable(true, WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
|
||||
// | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) //软键盘自动弹出
|
||||
.init();
|
||||
progressDialog = new ProgressDialog(this);
|
||||
progressDialog.setCanceledOnTouchOutside(false);
|
||||
mDataBinding.llAddress.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
RegisterUser registerUser = Config.getInstance(CodeActivity.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, "", 0);
|
||||
return;
|
||||
}
|
||||
final ArrayList<String> strings = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
strings.add(list.get(i).getAddress());
|
||||
}
|
||||
OptionsPopupWindow alarmOptionPop = new OptionsPopupWindow(CodeActivity.this);
|
||||
alarmOptionPop.setPicker(strings);
|
||||
|
||||
alarmOptionPop.setOnoptionsSelectListener(new OptionsPopupWindow.OnOptionsSelectListener() {
|
||||
@Override
|
||||
public void onOptionsSelect(int position, int option2, int options3) {
|
||||
|
||||
|
||||
if (list.size() > 0) {
|
||||
user_home_id = list.get(position).getUser_home_id();
|
||||
mDataBinding.tvAddress.setText(list.get(position).getAddress());
|
||||
address = list.get(position).getAddress();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
alarmOptionPop.showAtLocation(mDataBinding.getRoot(), Gravity.BOTTOM, 0, 0);
|
||||
}
|
||||
});
|
||||
Map<String, String> map = new HashMap<>();
|
||||
RegisterUser registerUser = Config.getInstance(CodeActivity.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, "", 0);
|
||||
getGankList();
|
||||
|
||||
mDataBinding.tvLs.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(CodeActivity.this, ShareCodeActivity.class);
|
||||
intent.putExtra("id", user_home_id);
|
||||
intent.putExtra("address", address);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
mDataBinding.tvSx.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getGankList();
|
||||
}
|
||||
});
|
||||
mDataBinding.left.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void getGankList() {
|
||||
String myurl = ApiConfig.BASE_URL;
|
||||
String msg = getResources().getString(R.string.requsting);
|
||||
RegisterUser user =
|
||||
Config.getInstance(CodeActivity.this).getUser();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (user != null) {
|
||||
map.put("userid", user.getUserid());
|
||||
} else {
|
||||
map.put("userid", 0 + "");
|
||||
}
|
||||
map.put("app", "Door");
|
||||
map.put("class", "GetownerCode");
|
||||
map.put("user_home_id", "GetownerCode");
|
||||
map.put("sign", Md5.md5("Door" + "GetownerCode" + Md5.secret));
|
||||
|
||||
|
||||
Loader mGankLoader = new Loader();
|
||||
progressDialog.show();
|
||||
Subscription subscription = mGankLoader.getMovie(myurl, map).subscribe(new Action1<Resultcode>() {
|
||||
@Override
|
||||
public void call(Resultcode resultcode) {
|
||||
progressDialog.dismiss();
|
||||
if (resultcode.status == 0) {
|
||||
// setToast(0, resultcode.msg);
|
||||
|
||||
Gson gs = new Gson();
|
||||
LinkedTreeMap adta = (LinkedTreeMap) resultcode.data;
|
||||
String qrcode = (String) adta.get("qrcode");
|
||||
Bitmap qrCodeBitmap = QRCodeUtil.createQRCodeBitmap(qrcode, QRCodeUtil.dip2px(CodeActivity.this, 200), QRCodeUtil.dip2px(CodeActivity.this, 200));
|
||||
mDataBinding.ivCode.setImageBitmap(qrCodeBitmap);
|
||||
mDataBinding.ivCode.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
setToast(1, resultcode.msg);
|
||||
}
|
||||
}
|
||||
}, new Action1<Throwable>() {
|
||||
@Override
|
||||
public void call(Throwable throwable) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
setToast(2, getString(R.string.getdatafailure));
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
});
|
||||
addSubscription(subscription);
|
||||
}
|
||||
|
||||
private ArrayList<HomelistitemEntity> list;
|
||||
private String user_home_id;
|
||||
|
||||
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);
|
||||
Loader 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);
|
||||
if (list != null && !list.isEmpty()) {
|
||||
mDataBinding.tvAddress.setText(list.get(0).getAddress());
|
||||
user_home_id = list.get(0).getUser_home_id();
|
||||
address = list.get(0).getAddress();
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
@@ -412,7 +412,7 @@ public class MainFragment extends BaseFragment<FragmentMainBinding> implements V
|
||||
if ((Config.getInstance(MainFragment.this.getContext()).getUser() == null)) {
|
||||
intent = new Intent(MainFragment.this.getContext(), LoginActivity.class);
|
||||
} else {
|
||||
intent = new Intent(getActivity(), ShareCodeActivity.class);
|
||||
intent = new Intent(getActivity(), CodeActivity.class);
|
||||
}
|
||||
startActivity(intent);
|
||||
break;
|
||||
|
||||
@@ -55,18 +55,20 @@ public class ShareCodeActivity extends BaseActivity<com.sl.house_property.databi
|
||||
finish();
|
||||
}
|
||||
}, 0, null, 0, null, 0, null, "");
|
||||
Map<String, String> map = new HashMap<>();
|
||||
RegisterUser registerUser = Config.getInstance(ShareCodeActivity.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, "", 0);
|
||||
// Map<String, String> map = new HashMap<>();
|
||||
// RegisterUser registerUser = Config.getInstance(ShareCodeActivity.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, "", 0);
|
||||
user_home_id= getIntent().getStringExtra("id");
|
||||
// String address = getIntent().getStringExtra("address");
|
||||
|
||||
|
||||
mDataBinding.myradio2.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||
|
||||
111
app/src/main/res/layout/activity_code.xml
Normal file
111
app/src/main/res/layout/activity_code.xml
Normal file
@@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="45dp"
|
||||
android:layout_marginTop="@dimen/mystatusbar"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/left"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:src="@mipmap/fanhui" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="我的门禁"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_address"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:background="@color/LightGraydddddd"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_address"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="14dp"
|
||||
android:layout_height="14dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="16dp"
|
||||
android:src="@mipmap/returnme"
|
||||
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_code"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="50dp"
|
||||
android:src="@mipmap/qrcode" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_sx"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="刷新"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="说明:请将二维码放于摄像头前"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_ls"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="16dp"
|
||||
android:drawableTop="@mipmap/menjing"
|
||||
android:drawablePadding="5dp"
|
||||
android:text="授权访客临时门禁"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</layout>
|
||||
@@ -29,6 +29,7 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:visibility="gone"
|
||||
android:id="@+id/ll_address"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
|
||||
Reference in New Issue
Block a user