|
@@ -0,0 +1,390 @@
|
|
|
+package com.zkjc.policedemo.mvp.ui.activity;
|
|
|
+
|
|
|
+import android.content.Context;
|
|
|
+import android.content.Intent;
|
|
|
+import android.content.SharedPreferences;
|
|
|
+import android.media.Image;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.text.Editable;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.text.TextWatcher;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.EditText;
|
|
|
+import android.widget.ImageView;
|
|
|
+
|
|
|
+import androidx.annotation.NonNull;
|
|
|
+import androidx.annotation.Nullable;
|
|
|
+import androidx.recyclerview.widget.GridLayoutManager;
|
|
|
+import androidx.recyclerview.widget.RecyclerView;
|
|
|
+
|
|
|
+import com.amap.api.maps.MapsInitializer;
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.hjq.toast.ToastUtils;
|
|
|
+import com.jess.arms.base.BaseActivity;
|
|
|
+import com.jess.arms.di.component.AppComponent;
|
|
|
+import com.jess.arms.utils.ArmsUtils;
|
|
|
+
|
|
|
+import com.zkjc.common.base.ZkjcBaseActivity;
|
|
|
+import com.zkjc.common.utils.ApkUtils;
|
|
|
+import com.zkjc.policedemo.app.utils.FileUtils;
|
|
|
+import com.zkjc.policedemo.app.utils.ShareInfo;
|
|
|
+import com.zkjc.policedemo.di.component.DaggerSearchAppComponent;
|
|
|
+import com.zkjc.policedemo.mvp.contract.SearchAppContract;
|
|
|
+import com.zkjc.policedemo.mvp.model.api.Api;
|
|
|
+import com.zkjc.policedemo.mvp.model.entity.MenuEntity;
|
|
|
+import com.zkjc.policedemo.mvp.presenter.SearchAppPresenter;
|
|
|
+
|
|
|
+import com.zkjc.policedemo.R;
|
|
|
+import com.zkjc.policedemo.mvp.ui.adapter.BaseRecycleAdapter;
|
|
|
+import com.zkjc.policedemo.mvp.ui.adapter.HomeAppAdapter;
|
|
|
+
|
|
|
+
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
+import org.json.JSONObject;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.zip.ZipEntry;
|
|
|
+import java.util.zip.ZipInputStream;
|
|
|
+
|
|
|
+import butterknife.BindView;
|
|
|
+import io.dcloud.feature.sdk.DCUniMPSDK;
|
|
|
+import io.dcloud.feature.sdk.Interface.IUniMP;
|
|
|
+import io.dcloud.feature.unimp.config.UniMPOpenConfiguration;
|
|
|
+import io.reactivex.Observable;
|
|
|
+import io.reactivex.ObservableEmitter;
|
|
|
+import io.reactivex.ObservableOnSubscribe;
|
|
|
+import io.reactivex.Observer;
|
|
|
+import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
+import io.reactivex.disposables.Disposable;
|
|
|
+import io.reactivex.schedulers.Schedulers;
|
|
|
+
|
|
|
+import static com.jess.arms.utils.Preconditions.checkNotNull;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * ================================================
|
|
|
+ * Description:
|
|
|
+ * <p>
|
|
|
+ * Created by MVPArmsTemplate on 11/11/2024 16:12
|
|
|
+ * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
|
|
|
+ * <a href="https://github.com/JessYanCoding">Follow me</a>
|
|
|
+ * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
|
|
|
+ * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
|
|
|
+ * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
|
|
|
+ * ================================================
|
|
|
+ */
|
|
|
+public class SearchAppActivity extends ZkjcBaseActivity<SearchAppPresenter> implements SearchAppContract.View {
|
|
|
+
|
|
|
+ @BindView(R.id.search_et_content)
|
|
|
+ EditText etContent;
|
|
|
+ @BindView(R.id.search_iv_clear)
|
|
|
+ ImageView ivClear;
|
|
|
+ @BindView(R.id.recycler_view)
|
|
|
+ RecyclerView recyclerView;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setupActivityComponent(@NonNull AppComponent appComponent) {
|
|
|
+ DaggerSearchAppComponent //如找不到该类,请编译一下项目
|
|
|
+ .builder()
|
|
|
+ .appComponent(appComponent)
|
|
|
+ .view(this)
|
|
|
+ .build()
|
|
|
+ .inject(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int initView(@Nullable Bundle savedInstanceState) {
|
|
|
+ return R.layout.activity_search_app; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initData(@Nullable Bundle savedInstanceState) {
|
|
|
+ recyclerView.setLayoutManager(new GridLayoutManager(this, 4));
|
|
|
+ ivClear.setOnClickListener(v -> {
|
|
|
+ etContent.setText("");
|
|
|
+ });
|
|
|
+ etContent.addTextChangedListener(new TextWatcher() {
|
|
|
+ @Override
|
|
|
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable s) {
|
|
|
+ if (!TextUtils.isEmpty(s)) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("appName", s.toString());
|
|
|
+ mPresenter.getMenuData(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void showLoading() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void hideLoading() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void showMessage(@NonNull String message) {
|
|
|
+ checkNotNull(message);
|
|
|
+ ArmsUtils.snackbarText(message);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void launchActivity(@NonNull Intent intent) {
|
|
|
+ checkNotNull(intent);
|
|
|
+ ArmsUtils.startActivity(intent);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void killMyself() {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getMenuSuccess(String result) {
|
|
|
+ try {
|
|
|
+ MenuEntity entity = new Gson().fromJson(result, MenuEntity.class);
|
|
|
+ if (entity.getCode() == 200) {
|
|
|
+ List<MenuEntity.DataBean> menus = entity.getData();
|
|
|
+ recyclerView.setLayoutManager(new GridLayoutManager(this, 4));
|
|
|
+ HomeAppAdapter menuAdapter = new HomeAppAdapter(menus);
|
|
|
+ recyclerView.setAdapter(menuAdapter);
|
|
|
+ menuAdapter.setListener(new BaseRecycleAdapter.OnRecyclerViewListenerV2() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(View view, int position) {
|
|
|
+ MenuEntity.DataBean bean = menus.get(position);
|
|
|
+ switch (bean.getSort()) {
|
|
|
+ case "1": // 入户走访
|
|
|
+ ArmsUtils.startActivity(RhzfMainNewActivity.class);
|
|
|
+ break;
|
|
|
+ case "2": // 矛盾纠纷
|
|
|
+ ArmsUtils.startActivity(MdjfActivity.class);
|
|
|
+ break;
|
|
|
+ case "3": // 消防检查
|
|
|
+ ArmsUtils.startActivity(XfjcLbActivity.class);
|
|
|
+ break;
|
|
|
+ case "4": // 警务室(站)
|
|
|
+ ArmsUtils.startActivity(JwsLbActivity.class);
|
|
|
+ break;
|
|
|
+ case "5": // 任务核查
|
|
|
+ ArmsUtils.startActivity(RwhcActivity.class);
|
|
|
+ break;
|
|
|
+ case "6": // 标准地址
|
|
|
+ break;
|
|
|
+ case "7": // 巡逻防控
|
|
|
+ File file = new File(FileUtils.getGdMapFilePath() + "/data_v6/map/a56");
|
|
|
+ if (file.exists()) {
|
|
|
+ ArmsUtils.startActivity(XlfkActivity.class);
|
|
|
+ } else {
|
|
|
+ Observable.create(new ObservableOnSubscribe<Void>(){
|
|
|
+ @Override
|
|
|
+ public void subscribe(ObservableEmitter<Void> emitter) throws Exception {
|
|
|
+ try {
|
|
|
+ UnZipAssetsFolder(SearchAppActivity.this, "map.zip", FileUtils.getGdMapFilePath() + "/data_v6");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new Observer<Void>() {
|
|
|
+ @Override
|
|
|
+ public void onSubscribe(Disposable d) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNext(Void list) {
|
|
|
+ ArmsUtils.startActivity(XlfkActivity.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(Throwable e) {
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onComplete() {
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "8": // 审批
|
|
|
+ ArmsUtils.startActivity(FjGlySpActivity.class);
|
|
|
+ break;
|
|
|
+ case "9": // 反馈提示
|
|
|
+ ArmsUtils.startActivity(FktsActivity.class);
|
|
|
+ break;
|
|
|
+ case "10": // 矛盾指派
|
|
|
+ break;
|
|
|
+ case "11": // 风险排查
|
|
|
+ ArmsUtils.startActivity(FxpcListActivity.class);
|
|
|
+ break;
|
|
|
+ case "12": // 任务下发
|
|
|
+ ArmsUtils.startActivity(RwxfLbActivity.class);
|
|
|
+ break;
|
|
|
+ case "13": // 外国人核查
|
|
|
+ ArmsUtils.startActivity(WgrHcActivity.class);
|
|
|
+ break;
|
|
|
+ case "14": // 上门服务
|
|
|
+ ArmsUtils.startActivity(SmfwListActivity.class);
|
|
|
+ break;
|
|
|
+ case "15": // 委托服务
|
|
|
+ ArmsUtils.startActivity(WtfwListActivity.class);
|
|
|
+ break;
|
|
|
+ case "16": // 预约服务
|
|
|
+ ArmsUtils.startActivity(YyfwListActivity.class);
|
|
|
+ break;
|
|
|
+ case "201": // 辖区概况
|
|
|
+ openUnitApp("__UNI__0308C60");
|
|
|
+ break;
|
|
|
+ case "202": // 物建信息员
|
|
|
+ openUnitApp("__UNI__EF18237");
|
|
|
+ break;
|
|
|
+ case "203": // 办事指南
|
|
|
+ openUnitApp("__UNI__02E5E40");
|
|
|
+ break;
|
|
|
+ case "204": // 任务下发反馈
|
|
|
+ ArmsUtils.startActivity(RwxfLbActivity.class);
|
|
|
+ break;
|
|
|
+ case "99": // 更多
|
|
|
+// ToastUtils.show("功能开发中");
|
|
|
+// openUnitApp("__UNI__0308C60");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onItemLongClick(View view, int position) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ ToastUtils.show(entity.getMsg());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void openUnitApp(String name) {
|
|
|
+ try {
|
|
|
+ UniMPOpenConfiguration uniMPOpenConfiguration = new UniMPOpenConfiguration();
|
|
|
+// uniMPOpenConfiguration.extraData.put("darkmode", "auto");
|
|
|
+ ShareInfo shareInfo = getShareInfo();
|
|
|
+
|
|
|
+// uniMPOpenConfiguration.extraData.put("data", new Gson().toJson(shareInfo));
|
|
|
+ uniMPOpenConfiguration.extraData.put("data", new JSONObject(new Gson().toJson(shareInfo)));
|
|
|
+ uniMPOpenConfiguration.extraData.put("internet", !ApkUtils.isSqjw(this));
|
|
|
+ SharedPreferences sys = getSharedPreferences("sys", Context.MODE_PRIVATE);
|
|
|
+ String userName = sys.getString("zh", "");
|
|
|
+ String password = sys.getString("mm", "");
|
|
|
+ uniMPOpenConfiguration.extraData.put("xwkjUserName", userName);
|
|
|
+ uniMPOpenConfiguration.extraData.put("xwkjPassword", password);
|
|
|
+ uniMPOpenConfiguration.extraData.put("appId", "1846809831194980354");
|
|
|
+
|
|
|
+ Log.e("eee", uniMPOpenConfiguration.extraData.toString());
|
|
|
+// DCUniMPSDK.getInstance().openUniMP(getActivity(), packageName, uniMPOpenConfiguration);
|
|
|
+
|
|
|
+// IUniMP uniMP = DCUniMPSDK.getInstance().openUniMP(getActivity(),"__UNI__B61D13B");
|
|
|
+ IUniMP unimp = DCUniMPSDK.getInstance().openUniMP(this, name, uniMPOpenConfiguration);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private ShareInfo getShareInfo() {
|
|
|
+ ShareInfo shareInfo = new ShareInfo();
|
|
|
+ shareInfo.setAppCredential("应用凭证");
|
|
|
+ shareInfo.setDataObjId("资源id");
|
|
|
+ shareInfo.setDepCode("220000000000");
|
|
|
+ shareInfo.setDepName("吉林省公安厅");
|
|
|
+ shareInfo.setMobile("13122223331");
|
|
|
+ shareInfo.setPersonCode("106470");
|
|
|
+ shareInfo.setPersonId("410000000000");
|
|
|
+ shareInfo.setPersonIdentifier("12010119610707201X");
|
|
|
+ shareInfo.setPersonName("张胜男");
|
|
|
+ shareInfo.setPersonType("10");
|
|
|
+ shareInfo.setPolice("101470");
|
|
|
+ shareInfo.setSex("男");
|
|
|
+ shareInfo.setFields("data");
|
|
|
+ shareInfo.setNetworkCode("3");
|
|
|
+ List<ShareInfo.Resource> resourceList = new ArrayList<>();
|
|
|
+ ShareInfo.Resource resource = new ShareInfo.Resource();
|
|
|
+
|
|
|
+ resource.setResourceAddress(ApkUtils.isSqjw(this) ? "http://20.3.1.162:9105/drs/ppc/v1/appQuery.do" : Api.APP_DOMAIN);
|
|
|
+ resource.setResourceRegionalismCode("220000000000");
|
|
|
+ resource.setResourceId(" 120000000000-3-0100-b0e037d83ecc4d43be788a5e9ddcbbe5");
|
|
|
+ resource.setResourceServiceType("10");
|
|
|
+ resourceList.add(resource);
|
|
|
+ shareInfo.setResourceList(resourceList);
|
|
|
+ shareInfo.setUserCredential("用户凭证");
|
|
|
+ return shareInfo;
|
|
|
+ }
|
|
|
+ public static void UnZipAssetsFolder(Context context, String zipFileString, String
|
|
|
+ outPathString) throws Exception {
|
|
|
+ Log.d("文件路径", context.getAssets().open(zipFileString).toString());
|
|
|
+ ZipInputStream inPutZip = new ZipInputStream(context.getAssets().open(zipFileString));
|
|
|
+ ZipEntry zipEntry;
|
|
|
+ String szName = "";
|
|
|
+ while ((zipEntry = inPutZip.getNextEntry()) != null) {
|
|
|
+ Log.d("判断文件是否存在",zipEntry.isDirectory()+"");
|
|
|
+ szName = zipEntry.getName();
|
|
|
+ if (zipEntry.isDirectory()) {
|
|
|
+ szName = szName.substring(0, szName.length() - 1);
|
|
|
+ File folder = new File(outPathString + File.separator + szName);
|
|
|
+ //目前判断条件,如果包含解压过的文件就不再解压
|
|
|
+ if(!folder.exists()){
|
|
|
+ folder.mkdirs();
|
|
|
+ }else{
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Log.e("eee", outPathString + File.separator + szName);
|
|
|
+ File file = new File(outPathString + File.separator + szName);
|
|
|
+ if (!file.exists()) {
|
|
|
+ Log.e("eee", "Create the file:" + outPathString + File.separator + szName);
|
|
|
+ file.getParentFile().mkdirs();
|
|
|
+ file.createNewFile();
|
|
|
+ }
|
|
|
+ // 获取文件的输出流
|
|
|
+ FileOutputStream out = new FileOutputStream(file);
|
|
|
+ int len;
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
+ // 读取(字节)字节到缓冲区
|
|
|
+ while ((len = inPutZip.read(buffer)) != -1) {
|
|
|
+ // 从缓冲区(0)位置写入(字节)字节
|
|
|
+ out.write(buffer, 0, len);
|
|
|
+ out.flush();
|
|
|
+ }
|
|
|
+ out.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ inPutZip.close();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|