Browse Source

页面之前逻辑处理

ifengouy 2 years ago
parent
commit
616175d3b2

+ 1 - 3
app/src/main/java/com/sunwin/visitorapp/LoginActivity.java

@@ -40,14 +40,12 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
         switch (view.getId()) {
             case R.id.btn_login_by_self:
                 SharePrefenceUtils.putBoolean(Constant.ISharePrefence.LOGINTAG, false);
-                Intent intent = new Intent(this, VisitorRegActivity.class);
-                intent.putExtra(Constant.IIntentValue.ISLOGINUSER, false);
+                Intent intent = new Intent(this, HomeAc.class);
                 startActivity(intent);
                 break;
             case R.id.btn_login:
                 SharePrefenceUtils.putBoolean(Constant.ISharePrefence.LOGINTAG, true);
                 Intent intent2 = new Intent(this, HomeAc.class);
-                intent2.putExtra(Constant.IIntentValue.ISLOGINUSER, true);
                 startActivity(intent2);
                 break;
         }

+ 45 - 8
app/src/main/java/com/sunwin/visitorapp/activity/HomeAc.java

@@ -3,6 +3,8 @@ package com.sunwin.visitorapp.activity;
 import android.content.Intent;
 import android.os.Bundle;
 import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
 
@@ -13,27 +15,30 @@ import androidx.fragment.app.FragmentTransaction;
 import com.sunwin.visitorapp.BaseActivity;
 import com.sunwin.visitorapp.R;
 import com.sunwin.visitorapp.fragment.HomeFr;
+import com.sunwin.visitorapp.fragment.RegTypeFragment;
 import com.sunwin.visitorapp.fragment.VisitSignFragment;
 import com.sunwin.visitorapp.utils.Constant;
+import com.sunwin.visitorapp.utils.SharePrefenceUtils;
 import com.sunwin.visitorapp.utils.ToastUtils;
 import com.sunwin.visitorapp.view.UINav;
 
-public class HomeAc extends BaseActivity implements View.OnClickListener {
+public class HomeAc extends BaseActivity implements View.OnClickListener, RegTypeFragment.Listener {
 
     private UINav mUINav;
     private RelativeLayout mLlHomeTitle;
     private TextView mTextTitle;
+    private LinearLayout mViewMenu;
+    private ImageView mImageSetting;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_home);
 
-
         FragmentManager fragmentManager = getSupportFragmentManager();
         FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
         //添加fragment
-        fragmentTransaction.add(R.id.FragmentView, new HomeFr());
+        fragmentTransaction.add(R.id.FragmentView, isLogin ? new HomeFr() : new RegTypeFragment(this));
 
         fragmentTransaction.commit();
         fragmentManager.executePendingTransactions();
@@ -71,9 +76,12 @@ public class HomeAc extends BaseActivity implements View.OnClickListener {
                 replaceFragment(VisitSignFragment.newInstance(1));
                 break;
             case R.id.MenuItemRegister://登记
-                intent = new Intent(this, VisitorRegActivity.class);
-                intent.putExtra(Constant.IIntentValue.ISLOGINUSER, true);
-                startActivity(intent);
+                showHome(false);
+                updateTitle("访客登记");
+                replaceFragment(RegTypeFragment.newInstance(this));
+//                intent = new Intent(this, VisitorRegActivity.class);
+//                intent.putExtra(Constant.IIntentValue.ISLOGINUSER, true);
+//                startActivity(intent);
                 break;
             case R.id.MenuItemLeave://签离
                 showHome(false);
@@ -92,7 +100,10 @@ public class HomeAc extends BaseActivity implements View.OnClickListener {
     private void initView() {
         mUINav = (UINav) findViewById(R.id.UINav);
         mLlHomeTitle = (RelativeLayout) findViewById(R.id.ll_home_title);
-        mTextTitle =  findViewById(R.id.TextTitle);
+        mLlHomeTitle = (RelativeLayout) findViewById(R.id.ll_home_title);
+        mTextTitle = findViewById(R.id.TextTitle);
+        mViewMenu = findViewById(R.id.ViewMenu);
+        mImageSetting = findViewById(R.id.ImageSetting);
 
         findViewById(R.id.MenuItemRecord).setOnClickListener(this);
         findViewById(R.id.MenuItemSign).setOnClickListener(this);
@@ -102,6 +113,9 @@ public class HomeAc extends BaseActivity implements View.OnClickListener {
         findViewById(R.id.ImageSetting).setOnClickListener(this);
         showHome(true);
 
+        mViewMenu.setVisibility(isLogin ? View.VISIBLE : View.INVISIBLE);
+        mImageSetting.setVisibility(isLogin ? View.VISIBLE : View.INVISIBLE);
+
 
     }
 
@@ -110,7 +124,7 @@ public class HomeAc extends BaseActivity implements View.OnClickListener {
         mUINav.setVisibility(showHome ? View.GONE : View.VISIBLE);
     }
 
-    private void updateTitle(String title){
+    private void updateTitle(String title) {
         mUINav.setMainData(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
@@ -119,4 +133,27 @@ public class HomeAc extends BaseActivity implements View.OnClickListener {
             }
         }, title);
     }
+
+    /**
+     * RegTypeFragment  Listener
+     */
+    @Override
+    public void showIdCardReg() {
+        SharePrefenceUtils.putBoolean(Constant.ISharePrefence.LOGINTAG, false);
+        Intent intent = new Intent(this, VisitorRegActivity.class);
+        intent.putExtra(Constant.IIntentValue.VISIT_REG_TYPE, 1);
+        intent.putExtra(Constant.IIntentValue.ISLOGINUSER, isLogin);
+        startActivity(intent);
+    }
+
+    @Override
+    public void showNoCardReg() {
+//        SharePrefenceUtils.putBoolean(Constant.ISharePrefence.LOGINTAG, false);
+//        Intent intent = new Intent(this, VisitorRegActivity.class);
+//        intent.putExtra(Constant.IIntentValue.VISIT_REG_TYPE, 2);
+//        intent.putExtra(Constant.IIntentValue.ISLOGINUSER, isLogin);
+//        startActivity(intent);
+        Intent intent = new Intent(this, VisitInputActivity.class);
+        startActivity(intent);
+    }
 }

+ 8 - 1
app/src/main/java/com/sunwin/visitorapp/activity/NoCardRegActivity.java

@@ -8,6 +8,8 @@ import com.sunwin.visitorapp.BaseActivity;
 import com.sunwin.visitorapp.BaseApplication;
 import com.sunwin.visitorapp.R;
 import com.sunwin.visitorapp.fragment.NoCardRegFragment;
+import com.sunwin.visitorapp.model.OpenDoorByFaceNetResultInfo;
+import com.sunwin.visitorapp.utils.Constant;
 
 /**
  *
@@ -15,11 +17,16 @@ import com.sunwin.visitorapp.fragment.NoCardRegFragment;
 public class NoCardRegActivity extends BaseActivity implements View.OnClickListener{
 
     private TextView mTvHeadTitle;
+    private OpenDoorByFaceNetResultInfo userInfo;
+    private String currentFacePath;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_no_card_reg);
+        currentFacePath = getIntent().getStringExtra(Constant.IIntentValue.CURRENTFACEPATH);
+        userInfo = (OpenDoorByFaceNetResultInfo) getIntent().getSerializableExtra(Constant.IIntentValue.RECOGNIZE_INFO);
+
         initView();
     }
 
@@ -30,7 +37,7 @@ public class NoCardRegActivity extends BaseActivity implements View.OnClickListe
         mTvHeadTitle.setText("访客登记");
         BaseApplication.getSystemTTS().playText("请看摄像头");
         getSupportFragmentManager().beginTransaction().add(R.id.fl_content,
-                new NoCardRegFragment()).commit();
+                 NoCardRegFragment.newInstance(currentFacePath,userInfo)).commit();
     }
 
     @Override

+ 1 - 1
app/src/main/java/com/sunwin/visitorapp/activity/VisitInputActivity.java

@@ -56,7 +56,7 @@ public class VisitInputActivity extends BaseActivity implements View.OnClickList
             return;
         }
         OpenDoorByFaceNetResultInfo info = new OpenDoorByFaceNetResultInfo();
-        Intent intent = new Intent(mContext, VisitorRegisterAc.class);
+        Intent intent = new Intent(mContext, NoCardRegActivity.class);
         intent.putExtra(Constant.IIntentValue.CURRENTFACEPATH,currentFacePath);
         intent.putExtra(Constant.IIntentValue.RECOGNIZE_INFO,info);
         startActivity(intent);

+ 9 - 2
app/src/main/java/com/sunwin/visitorapp/activity/VisitorRegActivity.java

@@ -40,12 +40,14 @@ public class VisitorRegActivity extends BaseActivity implements View.OnClickList
     private int[] bottomIcon;
     private String[] bottomItemArray;
     public boolean isLoginUser;
+    private int visitRegType;//访客登记类型:1,身份证,2 无证,3驾驶证
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_visitor_reg);
         isLoginUser = getIntent().getBooleanExtra(Constant.IIntentValue.ISLOGINUSER, false);
+        visitRegType = getIntent().getIntExtra(Constant.IIntentValue.VISIT_REG_TYPE, 1);
         initialData();
         initView();
         PullDataService.enqueueWork(this, new Intent());
@@ -85,9 +87,14 @@ public class VisitorRegActivity extends BaseActivity implements View.OnClickList
 //        mGridviewBottom.setAdapter(cardAdapter);
 //        mGridviewBottom.setOnItemClickListener(this);
 //        mGridviewBottom.setVisibility(isLoginUser ? View.VISIBLE : View.GONE);
-        RegTypeFragment regTypeFragment = new RegTypeFragment(this);
+//        RegTypeFragment regTypeFragment = new RegTypeFragment(this);
+        if (visitRegType==1){
+            showFragment(new IdcardRegFragment());
+        }else{
+//            showFragment(new NoCardRegFragment());
+        }
+
 
-        showFragment(regTypeFragment);
     }
 
     @Override

+ 18 - 2
app/src/main/java/com/sunwin/visitorapp/fragment/NoCardRegFragment.java

@@ -13,7 +13,7 @@ import androidx.annotation.Nullable;
 import com.sunwin.visitorapp.BaseApplication;
 import com.sunwin.visitorapp.BaseFragment;
 import com.sunwin.visitorapp.R;
-import com.sunwin.visitorapp.activity.VisitInputActivity;
+import com.sunwin.visitorapp.activity.NoCardRegActivity;
 import com.sunwin.visitorapp.activity.VisitorRegisterAc;
 import com.sunwin.visitorapp.face.CameraPreviewData;
 import com.sunwin.visitorapp.model.OpenDoorByFaceNetResultInfo;
@@ -27,9 +27,21 @@ import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
 import java.io.IOException;
+import java.io.Serializable;
 
 public class NoCardRegFragment extends BaseFragment implements FaceDetecterView.Listener {
     private FaceDetecterView mFaceDetecterView;
+    private OpenDoorByFaceNetResultInfo userInfo;
+
+    public static NoCardRegFragment newInstance(String facePath, OpenDoorByFaceNetResultInfo info) {
+        NoCardRegFragment fragment = new NoCardRegFragment();
+        Bundle bundle = new Bundle();
+        bundle.putString(Constant.IIntentValue.CURRENTFACEPATH, facePath);
+        bundle.putSerializable(Constant.IIntentValue.RECOGNIZE_INFO, info);
+        fragment.setArguments(bundle);
+
+        return fragment;
+    }
 
     @Nullable
     @Override
@@ -44,6 +56,8 @@ public class NoCardRegFragment extends BaseFragment implements FaceDetecterView.
     @Override
     public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
+        Bundle arguments = getArguments();
+        userInfo = (OpenDoorByFaceNetResultInfo) arguments.getSerializable(Constant.IIntentValue.RECOGNIZE_INFO);
         initView(view);
     }
 
@@ -99,8 +113,10 @@ public class NoCardRegFragment extends BaseFragment implements FaceDetecterView.
                 new Handler().postDelayed(new Runnable() {
                     @Override
                     public void run() {
-                        Intent intent = new Intent(mContext, VisitInputActivity.class);
+                        OpenDoorByFaceNetResultInfo info = new OpenDoorByFaceNetResultInfo();
+                        Intent intent = new Intent(mContext, VisitorRegisterAc.class);
                         intent.putExtra(Constant.IIntentValue.CURRENTFACEPATH, saveFilePath);
+                        intent.putExtra(Constant.IIntentValue.RECOGNIZE_INFO, userInfo);
                         startActivity(intent);
                     }
                 }, 500);

+ 13 - 0
app/src/main/java/com/sunwin/visitorapp/fragment/RegTypeFragment.java

@@ -22,6 +22,9 @@ import org.jetbrains.annotations.NotNull;
 import java.util.ArrayList;
 import java.util.List;
 
+/**
+ * 访客登记fragment
+ */
 public class RegTypeFragment extends BaseFragment implements AdapterView.OnItemClickListener {
 
     private List<String> itemList;
@@ -33,6 +36,16 @@ public class RegTypeFragment extends BaseFragment implements AdapterView.OnItemC
         this.mListener = mListener;
     }
 
+    public static RegTypeFragment newInstance(Listener mListener) {
+        RegTypeFragment fragment = new RegTypeFragment(mListener);
+
+        Bundle bundle = new Bundle();
+//        bundle.putInt(Constant.IIntentValue.VISIT_TYPE, visitType);
+        fragment.setArguments(bundle);
+
+        return fragment;
+    }
+
     @Nullable
     @Override
     public View onCreateView(@NonNull @NotNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {

+ 1 - 0
app/src/main/java/com/sunwin/visitorapp/utils/Constant.java

@@ -49,6 +49,7 @@ public class Constant {
         String CURRENTFACEPATH = "currentFacePath";
         String ISLOGINUSER = "isLoginUser";
         String VISIT_SIGN_TYPE = "visitSignType";//1,身份证,2 人脸
+        String VISIT_REG_TYPE = "visitRegType";//访客登记类型:1,身份证,2 无证,3驾驶证
         String VISIT_TYPE = "visitType";//1,签到,2 签离
         String RECOGNIZE_INFO = "recognizeInfo";
     }

+ 6 - 5
app/src/main/res/layout/activity_visitor_reg.xml

@@ -9,11 +9,12 @@
 
     <LinearLayout
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_marginLeft="80dp"
-        android:layout_marginRight="80dp"
-        android:layout_marginTop="50dp"
-        android:layout_marginBottom="40dp"
+        android:layout_height="match_parent"
+        android:layout_marginStart="40dp"
+        android:layout_marginTop="10dp"
+        android:layout_marginEnd="40dp"
+        android:paddingTop="30dp"
+        android:layout_marginBottom="30dp"
         android:layout_gravity="center_horizontal"
         android:orientation="horizontal">
         <LinearLayout

+ 1 - 1
app/src/main/res/layout/adapter_visitor_reg.xml

@@ -8,7 +8,7 @@
     <ImageView
         android:id="@+id/item_icon"
         android:layout_width="match_parent"
-        android:layout_height="80dp"
+        android:layout_height="100dp"
         android:scaleType="fitXY"
         android:src="@mipmap/visitor_reg_default" />
 

+ 1 - 1
app/src/main/res/layout/fragment_reg_type.xml

@@ -10,7 +10,7 @@
         android:horizontalSpacing="20dp"
         android:numColumns="3"
         android:overScrollMode="never"
-        android:paddingBottom="10dp"
+        android:padding="20dp"
         android:scrollbars="none"
         android:verticalSpacing="5dp" />
 </FrameLayout>