From f10f1aa77cc029aaea8d27ab9a2126f5e080d68a Mon Sep 17 00:00:00 2001
From: lizhanwei <Dana_Lee1016@126.com>
Date: 星期四, 27 八月 2020 18:33:24 +0800
Subject: [PATCH] 提交训练模式不含灯光

---
 app/src/main/java/safeluck/drive/evaluation/util/DataInit.kt                  |    2 
 app/src/main/res/layout/layout_select_dlg_three.xml                           |   61 +++++++++++++++
 app/src/main/java/safeluck/drive/evaluation/customview/SelectDialogThree.java |  166 +++++++++++++++++++++++++++++++++++++++++
 app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java       |    9 +
 app/src/main/res/values/dimens.xml                                            |    1 
 5 files changed, 235 insertions(+), 4 deletions(-)

diff --git a/app/src/main/java/safeluck/drive/evaluation/customview/SelectDialogThree.java b/app/src/main/java/safeluck/drive/evaluation/customview/SelectDialogThree.java
new file mode 100644
index 0000000..2a8adaf
--- /dev/null
+++ b/app/src/main/java/safeluck/drive/evaluation/customview/SelectDialogThree.java
@@ -0,0 +1,166 @@
+package safeluck.drive.evaluation.customview;
+
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Build;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.DialogFragment;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import safeluck.drive.evaluation.R;
+
+/**
+ * @ProjectName: DriveJudge
+ * @Package: safeluck.drive.evaluation.customview
+ * @ClassName: SelectDialog
+ * @Description: java绫讳綔鐢ㄦ弿杩�
+ * @Author: 鏉庡崰浼�
+ * @CreateDate: 2020-04-23 15:03
+ * @UpdateUser: 鏇存柊鑰�
+ * @UpdateDate: 2020-04-23 15:03
+ * @UpdateRemark: 鏇存柊璇存槑
+ * @Version: 1.0
+ */
+
+public class SelectDialogThree extends DialogFragment implements View.OnClickListener {
+
+    private static final String TAG = "SelectDialog";
+    private Button button;
+    private RadioGroup rgb;
+    public static final int FIRST = 0;
+    public static final int SECOND = 1;
+    public static final int THIRD = 2;
+    public static final int SELECT_NONE = -1;
+    private int result = SELECT_NONE;
+    private RadioButton rb_1,rb_2;
+    private ArrayList<String> stringArrayList;
+
+
+    @Nullable
+    @Override
+    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+
+        if (getDialog() != null) {
+            Window window = getDialog().getWindow();
+
+            if (window != null) {
+                window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+                window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
+
+                getDialog().setOnShowListener(dialog ->  {
+                        window.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
+                        hideBottomUIMenu();
+                });
+            }
+        }
+        View view = inflater.inflate(R.layout.layout_select_dlg_three,container,false);
+        Bundle bundle = getArguments();
+        if (bundle != null){
+            stringArrayList = bundle.getStringArrayList("content");
+        }
+        initView(view);
+        return view;
+    }
+
+    private void initView(View view) {
+        button = view.findViewById(R.id.btn_sure_);
+        rb_1 = view.findViewById(R.id.rb1);
+        rb_2 = view.findViewById(R.id.rb2);
+        if (stringArrayList != null){
+            rb_1.setText(stringArrayList.get(0));
+            rb_2.setText(stringArrayList.get(1));
+        }
+        rgb = view.findViewById(R.id.radiogroub);
+        rgb.setOnCheckedChangeListener((RadioGroup group, int checkedId)-> {
+            switch (checkedId){
+                case R.id.rb1:
+                    Log.i(TAG,"绗竴涓閫変腑");
+                    result = FIRST;
+                    break;
+                case R.id.rb2:
+                    Log.i(TAG,"绗簩涓閫変腑");
+                    result = SECOND;
+                    break;
+                case R.id.rb3:
+                    result = THIRD;
+                    break;
+                    default:break;
+            }
+        });
+        button.setOnClickListener(this);
+    }
+
+    @Override
+    public void onClick(View v) {
+        switch (v.getId()){
+            case R.id.btn_sure_:
+                    if (onSelectedListener != null){
+                        onSelectedListener.makeYourChoice(result);
+                    }
+                dismiss();
+                break;
+        }
+    }
+
+    public interface OnSelectedListener{
+        void makeYourChoice(int res);
+    }
+
+    private OnSelectedListener onSelectedListener;
+
+    public void setSelectedListener(OnSelectedListener onSelectedListener){
+        this.onSelectedListener = onSelectedListener;
+    }
+
+    public static SelectDialogThree newInstance(String... args){
+
+        SelectDialogThree sle = new SelectDialogThree();
+        if (args != null && args.length>=2){
+            List<String> strs = Arrays.asList(args);
+            ArrayList<String> list = new ArrayList<>(strs);
+            Bundle bundle = new Bundle();
+            bundle.putStringArrayList("content",list);
+            sle.setArguments(bundle);
+        }
+
+
+        return sle;
+    }
+    /**
+     * 闅愯棌铏氭嫙鎸夐敭锛屽苟涓斿叏灞�
+     */
+    protected void hideBottomUIMenu() {
+        //闅愯棌铏氭嫙鎸夐敭锛屽苟涓斿叏灞�
+        if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
+            View v = this.getDialog().getWindow().getDecorView();
+            v.setSystemUiVisibility(View.GONE);
+        } else if (Build.VERSION.SDK_INT >= 19) {
+            //for new api versions.
+            View decorView = getDialog().getWindow().getDecorView();
+            int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN;
+            decorView.setSystemUiVisibility(uiOptions);
+        }
+    }
+
+    @Override
+    public void dismiss() {
+
+        super.dismiss();
+    }
+}
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
index ed112ef..bf01010 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
@@ -68,6 +68,7 @@
 
 import safeluck.drive.evaluation.customview.QRCodeDialog;
 import safeluck.drive.evaluation.customview.SelectDialog;
+import safeluck.drive.evaluation.customview.SelectDialogThree;
 import safeluck.drive.evaluation.im.MessageProcessor;
 import safeluck.drive.evaluation.platformMessage.JKMessage0201;
 import safeluck.drive.evaluation.platformMessage.JKMessage0202;
@@ -574,13 +575,15 @@
 //                //TODO 鍙戦�丣KMessage0202 缁欏钩鍙帮紝寮�濮嬭�冭瘯
                 if (btn_start_exam.getText().toString().equalsIgnoreCase("寮�濮嬭缁�")){
 
-                    SelectDialog selectDialog = SelectDialog.newInstance("杩涜鍦哄湴璁粌","杩涜閬撹矾璁粌");
+                    SelectDialogThree selectDialog = SelectDialogThree.newInstance("鍦哄湴璁粌","閬撹矾璁粌","閬撹矾璁粌(涓嶅惈鐏厜)");
                     selectDialog.setSelectedListener((int res)->{
                         if (res != SelectDialog.SELECT_NONE){
-                            if (res== SelectDialog.FIRST){
+                            if (res== SelectDialogThree.FIRST){
                                 sendJK0202(2);
-                            }else{
+                            }else if (res== SelectDialogThree.SECOND){
                                 sendJK0202(3);
+                            }else {
+                                sendJK0202(4);
                             }
                         }
                     });
diff --git a/app/src/main/java/safeluck/drive/evaluation/util/DataInit.kt b/app/src/main/java/safeluck/drive/evaluation/util/DataInit.kt
index a80b6d4..a5883a3 100644
--- a/app/src/main/java/safeluck/drive/evaluation/util/DataInit.kt
+++ b/app/src/main/java/safeluck/drive/evaluation/util/DataInit.kt
@@ -85,7 +85,7 @@
 
     tempQs.add(list[list.size-2])//鎻愮ず涓嬮潰灏嗚繘琛岀伅鍏夎�冭瘯
     tempQs.add(list[0])
-    val a = Utils.getRandomInts(4, 11)
+    val a = Utils.getRandomInts(4, 10)
     for (i in a.indices) {
         tempQs.add(list[a[i]])
     }
diff --git a/app/src/main/res/layout/layout_select_dlg_three.xml b/app/src/main/res/layout/layout_select_dlg_three.xml
new file mode 100644
index 0000000..2216de2
--- /dev/null
+++ b/app/src/main/res/layout/layout_select_dlg_three.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="260dp"
+
+    android:layout_height="320dp"
+    android:gravity="center"
+
+    android:background="@drawable/bg_select_dlg"
+    android:orientation="vertical" >
+<TextView
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:textSize="@dimen/network_train_textsize20px"
+    android:textColor="@android:color/white"
+    android:padding="@dimen/ui_margin_10dp"
+    android:background="@drawable/bg_select_dlg"
+    android:text="璇烽�夋嫨涓�涓」鐩細"/>
+        <RadioGroup
+
+            android:layout_width="match_parent"
+            android:id="@+id/radiogroub"
+            android:layout_marginRight="@dimen/ui_margin_10dp"
+            android:layout_height="wrap_content">
+            <RadioButton
+                android:layout_width="match_parent"
+                android:layout_height="@dimen/ui_margin_70dp"
+                android:id="@+id/rb1"
+                android:text="鍦鸿�冨湴鍥�"
+                android:textSize="@dimen/network_train_textsize24px"
+                android:layout_marginLeft="@dimen/ui_margin_10dp"
+                android:textColor="@android:color/white"/>
+            <RadioButton
+                android:layout_width="match_parent"
+                android:layout_height="@dimen/ui_margin_70dp"
+                android:id="@+id/rb2"
+                android:textSize="@dimen/network_train_textsize24px"
+                android:text="璺�冨湴鍥�"
+                android:layout_marginLeft="@dimen/ui_margin_10dp"
+                android:textColor="@android:color/white"/>
+            <RadioButton
+                android:layout_width="match_parent"
+                android:layout_height="@dimen/ui_margin_70dp"
+                android:id="@+id/rb3"
+                android:textSize="@dimen/network_train_textsize24px"
+                android:text="璺�冨湴鍥�(涓嶅惈鐏厜)"
+                android:layout_marginLeft="@dimen/ui_margin_10dp"
+                android:textColor="@android:color/white"/>
+
+
+        </RadioGroup>
+        <Button
+            android:background="@drawable/bg_select_dlg"
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/ui_margin_70dp"
+            android:layout_marginTop="@dimen/ui_margin_10dp"
+            android:text="纭畾"
+            android:textSize="@dimen/network_train_textsize26px"
+            android:textColor="@android:color/white"
+            android:id="@+id/btn_sure_"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 0252eb5..8f6ea85 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -21,4 +21,5 @@
     <dimen name="ui_margin_40dp">40dp</dimen>
     <dimen name="ui_margin_45dp">45dp</dimen>
     <dimen name="ui_margin_35dp">35dp</dimen>
+    <dimen name="ui_margin_70dp">70dp</dimen>
 </resources>
\ No newline at end of file

--
Gitblit v1.8.0