Bläddra i källkod

时钟显示
签到登记首页页面调整

ifengouy 2 år sedan
förälder
incheckning
ea0771856e

+ 2 - 0
app/src/main/java/com/sunwin/visitorapp/activity/HomeAc.java

@@ -19,6 +19,7 @@ import com.sunwin.visitorapp.R;
 import com.sunwin.visitorapp.db.LogModel;
 import com.sunwin.visitorapp.fragment.HomeFr;
 import com.sunwin.visitorapp.fragment.RegTypeFragment;
+import com.sunwin.visitorapp.fragment.TimeFragment;
 import com.sunwin.visitorapp.fragment.VisitSignFragment;
 import com.sunwin.visitorapp.manage.RunDataManage;
 import com.sunwin.visitorapp.utils.Constant;
@@ -50,6 +51,7 @@ public class HomeAc extends BaseActivity implements View.OnClickListener, RegTyp
         FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
         //添加fragment
         fragmentTransaction.add(R.id.FragmentView, isLogin ? new HomeFr() : new RegTypeFragment(this));
+        fragmentTransaction.add(R.id.ViewClock, new TimeFragment());
 
         fragmentTransaction.commit();
         fragmentManager.executePendingTransactions();

+ 17 - 3
app/src/main/java/com/sunwin/visitorapp/activity/VisitSignActivity.java

@@ -5,7 +5,9 @@ import android.os.Bundle;
 import android.text.TextUtils;
 import android.view.View;
 import android.widget.LinearLayout;
-import android.widget.TextView;
+
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
 
 import com.sunwin.visitorapp.BaseActivity;
 import com.sunwin.visitorapp.BaseApplication;
@@ -16,6 +18,7 @@ import com.sunwin.visitorapp.db.UserInfoModel;
 import com.sunwin.visitorapp.face.CameraPreviewData;
 import com.sunwin.visitorapp.face.IDCardReaderUtil;
 import com.sunwin.visitorapp.face.IdCardReadCallback;
+import com.sunwin.visitorapp.fragment.TimeFragment;
 import com.sunwin.visitorapp.model.OpenDoorByFaceNetResultInfo;
 import com.sunwin.visitorapp.model.UploadRecordRequsetModel;
 import com.sunwin.visitorapp.net.ApiService;
@@ -30,6 +33,7 @@ import com.sunwin.visitorapp.utils.LogUtil;
 import com.sunwin.visitorapp.utils.TimeUtils;
 import com.sunwin.visitorapp.utils.ToastUtils;
 import com.sunwin.visitorapp.view.FaceDetecterView;
+import com.sunwin.visitorapp.view.UINav;
 
 import java.util.List;
 
@@ -43,7 +47,7 @@ import retrofit2.Response;
  * 访客签到/签离
  */
 public class VisitSignActivity extends BaseActivity implements IdCardReadCallback, FaceDetecterView.Listener {
-    private TextView mTvDate;
+
     private LinearLayout mLlIdCardReg;
     private FaceDetecterView mFaceDetecterView;
 
@@ -81,7 +85,9 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
     }
 
     private void initView() {
-        mTvDate = (TextView) findViewById(R.id.tv_date);
+        addTimeFragment();
+        UINav UINav = findViewById(R.id.UINav);
+        UINav.setData(this, visitType == 1 ? "访客签到" : "访客签离");
         mLlIdCardReg = (LinearLayout) findViewById(R.id.ll_id_card_reg);
         mFaceDetecterView = findViewById(R.id.faceDetecterView);
         mLlIdCardReg.setVisibility(visitSignType == 1 ? View.VISIBLE : View.GONE);
@@ -94,6 +100,14 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
         }
     }
 
+    private void addTimeFragment() {
+        FragmentManager fragmentManager = getSupportFragmentManager();
+        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
+        //添加fragment
+        fragmentTransaction.add(R.id.fl_time, new TimeFragment());
+        fragmentTransaction.commit();
+    }
+
 
     /**
      * 读取身份证回调

+ 17 - 16
app/src/main/java/com/sunwin/visitorapp/activity/VisitorRegActivity.java

@@ -3,23 +3,21 @@ package com.sunwin.visitorapp.activity;
 import android.content.Intent;
 import android.os.Bundle;
 import android.view.View;
-import android.widget.AdapterView;
 import android.widget.TextView;
 
 import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
 
 import com.sunwin.visitorapp.BaseActivity;
-import com.sunwin.visitorapp.BaseApplication;
 import com.sunwin.visitorapp.R;
-import com.sunwin.visitorapp.adapter.CardAdapter;
 import com.sunwin.visitorapp.adapter.VisitorRegAdapter;
 import com.sunwin.visitorapp.fragment.IdcardRegFragment;
-import com.sunwin.visitorapp.fragment.NoCardRegFragment;
 import com.sunwin.visitorapp.fragment.RegTypeFragment;
-import com.sunwin.visitorapp.service.PullDataService;
+import com.sunwin.visitorapp.fragment.TimeFragment;
 import com.sunwin.visitorapp.utils.Constant;
-import com.sunwin.visitorapp.utils.ToastUtils;
 import com.sunwin.visitorapp.view.MyGridView;
+import com.sunwin.visitorapp.view.UINav;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -27,9 +25,8 @@ import java.util.List;
 /**
  * 访客登记页面
  */
-public class VisitorRegActivity extends BaseActivity implements View.OnClickListener, RegTypeFragment.Listener {
+public class VisitorRegActivity extends BaseActivity implements  RegTypeFragment.Listener {
 
-    private TextView mTvHeadTitle;
     //    private MyGridView mGridview;
     private MyGridView mGridviewBottom;
     private TextView mTvDate;
@@ -73,8 +70,9 @@ public class VisitorRegActivity extends BaseActivity implements View.OnClickList
     }
 
     private void initView() {
-        findViewById(R.id.head_iv_back).setOnClickListener(this);
-        mTvHeadTitle = (TextView) findViewById(R.id.tv_head_title);
+        addTimeFragment();
+        UINav UINav = findViewById(R.id.UINav);
+        UINav.setData(this, "访客登记");
         mTvDate = (TextView) findViewById(R.id.tv_date);
 //        mGridview = findViewById(R.id.gridview);
         VisitorRegAdapter adapter = new VisitorRegAdapter(itemList, iconList);
@@ -87,20 +85,23 @@ public class VisitorRegActivity extends BaseActivity implements View.OnClickList
 //        mGridviewBottom.setOnItemClickListener(this);
 //        mGridviewBottom.setVisibility(isLoginUser ? View.VISIBLE : View.GONE);
 //        RegTypeFragment regTypeFragment = new RegTypeFragment(this);
-        if (visitRegType==1){
+        if (visitRegType == 1) {
             showFragment(new IdcardRegFragment());
-        }else{
+        } else {
 //            showFragment(new NoCardRegFragment());
         }
 
 
     }
 
-    @Override
-    public void onClick(View view) {
-        switch (view.getId()) {
-        }
+    private void addTimeFragment() {
+        FragmentManager fragmentManager = getSupportFragmentManager();
+        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
+        //添加fragment
+        fragmentTransaction.add(R.id.fl_time, new TimeFragment());
+        fragmentTransaction.commit();
     }
+
 //
 //    @Override
 //    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

+ 54 - 0
app/src/main/java/com/sunwin/visitorapp/fragment/TimeFragment.java

@@ -0,0 +1,54 @@
+package com.sunwin.visitorapp.fragment;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextClock;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.sunwin.visitorapp.BaseFragment;
+import com.sunwin.visitorapp.R;
+
+import org.jetbrains.annotations.NotNull;
+
+public class TimeFragment extends BaseFragment {
+    private TextClock mTcTime;
+    private TextClock mTcDate;
+
+    @Nullable
+    @Override
+    public View onCreateView(@NonNull @NotNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
+        View view = inflater.inflate(R.layout.fragment_time, container, false);
+
+
+        return view;
+    }
+
+    @Override
+    public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
+        super.onViewCreated(view, savedInstanceState);
+        initView(view);
+    }
+
+    private void initView(@NotNull View view) {
+        mTcTime =  view.findViewById(R.id.tc_time);
+        mTcDate =  view.findViewById(R.id.tc_date);
+//        setFormatHour(mTcTime);
+    }
+
+    /**
+     * 设置时钟
+     * @param v
+     * @param
+     */
+    private void setFormatHour(TextClock v){
+        if (v.is24HourModeEnabled()){
+            v.setFormat24Hour("yyyy/MM/dd hh:mm:ss");
+        }else {
+            v.setFormat24Hour("yyyy/MM/dd h:mm:ss");
+        }
+    }
+}

+ 12 - 32
app/src/main/res/layout/activity_visit_sign.xml

@@ -5,7 +5,10 @@
     android:background="@mipmap/bg_app"
     android:orientation="vertical">
 
-    <include layout="@layout/title_layout" />
+  <com.sunwin.visitorapp.view.UINav
+      android:id="@+id/UINav"
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"/>
 
     <LinearLayout
         android:layout_width="match_parent"
@@ -17,50 +20,27 @@
         android:layout_marginBottom="120dp"
         android:orientation="horizontal">
 
-        <LinearLayout
+        <FrameLayout
+            android:id="@+id/fl_time"
             android:layout_width="0dp"
             android:layout_height="match_parent"
-            android:layout_weight="1"
-            android:background="@color/color_efeeee"
+            android:layout_weight="2"
+            android:background="@drawable/card_white"
             android:gravity="center_horizontal"
-            android:orientation="vertical"
-            android:paddingTop="30dp"
-            android:paddingBottom="30dp">
-
-            <ImageView
-                android:layout_width="180dp"
-                android:layout_height="180dp"
-                android:src="@mipmap/ic_launcher" />
+            android:orientation="vertical" />
 
-            <TextClock
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="15dp"
-                android:text="fadsgadgadsg"
-                android:textColor="@color/color_333333"
-                android:textSize="@dimen/sp_25" />
-
-            <TextView
-                android:id="@+id/tv_date"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="15dp"
-                android:text="2022-8-26"
-                android:textColor="@color/color_333333"
-                android:textSize="@dimen/sp_20" />
-        </LinearLayout>
 
         <FrameLayout
             android:layout_width="0dp"
             android:layout_height="match_parent"
             android:layout_marginLeft="40dp"
-            android:layout_weight="2"
-            android:background="@color/color_efeeee"
+            android:layout_weight="5"
+            android:background="@drawable/card_white"
             android:orientation="horizontal"
             android:padding="50dp">
 
 
-          <include layout="@layout/fragment_id_card_reg"/>
+            <include layout="@layout/fragment_id_card_reg" />
         </FrameLayout>
 
     </LinearLayout>

+ 16 - 39
app/src/main/res/layout/activity_visitor_reg.xml

@@ -4,62 +4,39 @@
     android:layout_height="match_parent"
     android:background="@mipmap/bg_app"
     android:orientation="vertical">
-
-    <include layout="@layout/title_layout" />
+    <com.sunwin.visitorapp.view.UINav
+        android:id="@+id/UINav"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"/>
 
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="match_parent"
+        android:layout_gravity="center_horizontal"
         android:layout_marginStart="40dp"
-        android:layout_marginEnd="40dp"
         android:layout_marginTop="50dp"
+        android:layout_marginEnd="40dp"
         android:layout_marginBottom="120dp"
-        android:layout_gravity="center_horizontal"
         android:orientation="horizontal">
-        <LinearLayout
+
+        <FrameLayout
+            android:id="@+id/fl_time"
             android:layout_width="0dp"
             android:layout_height="match_parent"
-            android:layout_weight="1"
-            android:background="@color/color_efeeee"
+            android:layout_weight="2"
+            android:background="@drawable/card_white"
             android:gravity="center_horizontal"
-            android:orientation="vertical"
-            android:paddingTop="20dp"
-            android:paddingBottom="20dp">
-
-            <ImageView
-                android:layout_width="180dp"
-                android:layout_height="180dp"
-                android:src="@mipmap/ic_launcher" />
-
-            <TextClock
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="15dp"
-                android:text="fadsgadgadsg"
-                android:textColor="@color/color_333333"
-                android:textSize="@dimen/sp_25" />
-
-            <TextView
-                android:id="@+id/tv_date"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="15dp"
-                android:text="2022-8-26"
-                android:textColor="@color/color_333333"
-                android:textSize="@dimen/sp_20" />
-        </LinearLayout>
+            android:orientation="vertical" />
 
         <FrameLayout
             android:id="@+id/fl_content"
             android:layout_width="0dp"
             android:layout_height="match_parent"
             android:layout_marginLeft="40dp"
-            android:layout_weight="2"
-            android:padding="50dp"
-            android:background="@color/color_efeeee"
-            android:orientation="horizontal">
-
-
+            android:layout_weight="5"
+            android:background="@drawable/card_white"
+            android:orientation="horizontal"
+            android:padding="50dp">
 
 
         </FrameLayout>

+ 33 - 0
app/src/main/res/layout/fragment_time.xml

@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:gravity="center"
+    android:orientation="vertical">
+
+    <ImageView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:src="@mipmap/time" />
+
+    <TextClock
+        android:id="@+id/tc_time"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="20dp"
+        android:format12Hour="HH:mm:ss"
+        android:format24Hour="HH:mm:ss"
+        android:textColor="@color/black"
+        android:textSize="@dimen/sp_25"
+        android:textStyle="bold" />
+
+    <TextClock
+        android:id="@+id/tc_date"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="20dp"
+        android:format12Hour="yyyy-MM-dd"
+        android:format24Hour="yyyy-MM-dd"
+        android:textColor="@color/black"
+        android:textSize="@dimen/sp_25" />
+</LinearLayout>

BIN
app/src/main/res/mipmap-xhdpi/time.png