From d3fcef0d3d3b7c6c7380c4343f8d061a2766eee2 Mon Sep 17 00:00:00 2001
From: lizhanwei <Dana_Lee1016@126.com>
Date: 星期四, 16 四月 2020 13:06:27 +0800
Subject: [PATCH] http请求等待loading,二维码生成,dialog展示
---
app/src/main/res/drawable/qrcode.jpg | 0
app/src/androidTest/java/safeluck/drive/evaluation/ExampleInstrumentedTest.java | 5
app/src/main/res/layout/layout_dialog_loading.xml | 40 ++++++++
app/src/main/res/values/styles.xml | 5 +
app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java | 9 +
app/src/main/res/drawable/dialog_round.xml | 6 +
app/src/main/java/safeluck/drive/evaluation/customview/QRCodeDialog.java | 84 ++++++++++++++++
app/src/main/java/safeluck/drive/evaluation/customview/LoadProgressDialog.java | 73 ++++++++++++++
app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java | 25 ++++-
app/src/main/res/drawable/anim_loading.xml | 7 +
app/src/main/res/layout/layout_dialog_qrcode.xml | 36 +++++++
app/src/main/res/drawable/icon_loading.png | 0
12 files changed, 279 insertions(+), 11 deletions(-)
diff --git a/app/src/androidTest/java/safeluck/drive/evaluation/ExampleInstrumentedTest.java b/app/src/androidTest/java/safeluck/drive/evaluation/ExampleInstrumentedTest.java
index 30135cd..9357019 100644
--- a/app/src/androidTest/java/safeluck/drive/evaluation/ExampleInstrumentedTest.java
+++ b/app/src/androidTest/java/safeluck/drive/evaluation/ExampleInstrumentedTest.java
@@ -1,8 +1,9 @@
package safeluck.drive.evaluation;
import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/app/src/main/java/safeluck/drive/evaluation/customview/LoadProgressDialog.java b/app/src/main/java/safeluck/drive/evaluation/customview/LoadProgressDialog.java
new file mode 100644
index 0000000..b89fcda
--- /dev/null
+++ b/app/src/main/java/safeluck/drive/evaluation/customview/LoadProgressDialog.java
@@ -0,0 +1,73 @@
+package safeluck.drive.evaluation.customview;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.DialogFragment;
+
+import safeluck.drive.evaluation.R;
+
+/**
+ * @ProjectName: DriveJudge
+ * @Package: safeluck.drive.evaluation.customview
+ * @ClassName: LoadProgressDialog
+ * @Description: java绫讳綔鐢ㄦ弿杩�
+ * @Author: 鏉庡崰浼�
+ * @CreateDate: 2020-04-16 09:57
+ * @UpdateUser: 鏇存柊鑰�
+ * @UpdateDate: 2020-04-16 09:57
+ * @UpdateRemark: 鏇存柊璇存槑
+ * @Version: 1.0
+ */
+
+public class LoadProgressDialog extends DialogFragment {
+ private String message="姝e湪鍔犺浇...";
+ private boolean canCancel= false;
+ private TextView textView;
+
+ private Handler handler = new Handler(Looper.getMainLooper()){
+ @Override
+ public void handleMessage(Message msg) {
+ super.handleMessage(msg);
+ if (msg.what==1)
+ dismiss();
+ }
+ };
+ @Nullable
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.layout_dialog_loading,container,false);
+ initView(view);
+ setCancelable(canCancel);
+ Message message = Message.obtain();
+ message.what = 1;
+ handler.sendMessageDelayed(message,10*1000);
+ return view;
+ }
+
+ private void initView(View view) {
+ textView =view.findViewById(R.id.tv_message);
+ }
+
+ public static LoadProgressDialog newInstance(String message){
+ LoadProgressDialog fragment = new LoadProgressDialog();
+ Bundle bundle = new Bundle();
+ bundle.putString("tittle", message);
+ fragment.setArguments(bundle);
+ return fragment;
+ }
+
+ @Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ message = getArguments().getString("title");
+ textView.setText(message);
+ }
+}
diff --git a/app/src/main/java/safeluck/drive/evaluation/customview/QRCodeDialog.java b/app/src/main/java/safeluck/drive/evaluation/customview/QRCodeDialog.java
new file mode 100644
index 0000000..9c6d241
--- /dev/null
+++ b/app/src/main/java/safeluck/drive/evaluation/customview/QRCodeDialog.java
@@ -0,0 +1,84 @@
+package safeluck.drive.evaluation.customview;
+
+import android.app.Dialog;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.DialogFragment;
+
+import java.nio.charset.Charset;
+
+import safeluck.drive.evaluation.R;
+import safeluck.drive.evaluation.util.QRCodeUtil;
+
+/**
+ * @ProjectName: DriveJudge
+ * @Package: safeluck.drive.evaluation.customview
+ * @ClassName: LoadProgressDialog
+ * @Description: java绫讳綔鐢ㄦ弿杩�
+ * @Author: 鏉庡崰浼�
+ * @CreateDate: 2020-04-16 09:57
+ * @UpdateUser: 鏇存柊鑰�
+ * @UpdateDate: 2020-04-16 09:57
+ * @UpdateRemark: 鏇存柊璇存槑
+ * @Version: 1.0
+ */
+
+public class QRCodeDialog extends DialogFragment {
+ private String message="姝e湪鍔犺浇...";
+ private boolean canCancel= true;
+ private ImageView iv_qrCode;
+ private Button btn;
+
+ private Handler handler = new Handler(Looper.getMainLooper()){
+ @Override
+ public void handleMessage(Message msg) {
+ super.handleMessage(msg);
+ if (msg.what==1)
+ dismiss();
+ }
+ };
+ @Nullable
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.layout_dialog_qrcode,container,false);
+ initView(view);
+ setCancelable(canCancel);
+ Bundle bundle =getArguments();
+ message = bundle.getString("title");
+ Message message = Message.obtain();
+ message.what = 1;
+ handler.sendMessageDelayed(message,15*1000);
+ return view;
+ }
+
+ private void initView(View view) {
+ btn = view.findViewById(R.id.btn_qr_sure);
+ btn.setOnClickListener(v -> {
+ dismiss();
+ });
+ }
+
+
+ public static QRCodeDialog newInstance(String message){
+ QRCodeDialog fragment = new QRCodeDialog();
+ Bundle bundle = new Bundle();
+ bundle.putString("tittle", message);
+ fragment.setArguments(bundle);
+ return fragment;
+ }
+
+
+
+}
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java
index 2fa1dfe..78f59ae 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java
@@ -15,6 +15,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.DialogFragment;
import com.anyun.exam.lib.AYSdk;
@@ -24,6 +25,7 @@
import safeluck.drive.evaluation.BuildConfig;
import safeluck.drive.evaluation.R;
import safeluck.drive.evaluation.bean.ExamPlatformData;
+import safeluck.drive.evaluation.customview.LoadProgressDialog;
/**
@@ -82,6 +84,8 @@
}
}
+
+
break;
case R.id.network_train:
if (ExamPlatformData.getInstance().getTrainingMode()==ExamPlatformData.TRAINING_MODE){
@@ -106,11 +110,8 @@
public void onClick(DialogInterface dialog, int which) {
_mActivity.finish();
}
- }).setNegativeButton("鍙栨秷", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
+ }).setNegativeButton("鍙栨秷", (DialogInterface dialog, int which)-> {
dialog.dismiss();
- }
}).show();
break;
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java
index e4ee2f4..982c815 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java
@@ -21,6 +21,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.fragment.app.DialogFragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import androidx.work.OneTimeWorkRequest;
@@ -58,11 +59,15 @@
import safeluck.drive.evaluation.cEventCenter.ICEventListener;
import safeluck.drive.evaluation.customview.ArrowView;
import safeluck.drive.evaluation.customview.HouseView;
+import safeluck.drive.evaluation.customview.LoadProgressDialog;
import safeluck.drive.evaluation.customview.MyDialogFragment;
+import safeluck.drive.evaluation.customview.QRCodeDialog;
+import safeluck.drive.evaluation.httpmodule.RetrofitCreator;
import safeluck.drive.evaluation.im.MessageProcessor;
import safeluck.drive.evaluation.platformMessage.JKMessage0201;
import safeluck.drive.evaluation.platformMessage.JKMessage0202;
import safeluck.drive.evaluation.platformMessage.JKMessage0204;
+import safeluck.drive.evaluation.platformMessage.PlatFormConstant;
import safeluck.drive.evaluation.util.Utils;
import safeluck.drive.evaluation.viewmodels.TimeViewModel;
@@ -108,6 +113,8 @@
public static SupportFragment newInstance() {
return new NetWorkTrainFragment();
}
+
+
private Handler mHandler = new Handler(new Handler.Callback() {
@@ -586,9 +593,8 @@
}
-
+private LoadProgressDialog loadProgressDialog;
MyDialogFragment myDialogFragment;
- SimulateNightBean simulateNightBean = null;
@Override
public void onClick(View v) {
switch (v.getId()) {
@@ -642,13 +648,20 @@
break;
case R.id.btn_return:
- _mActivity.onBackPressed();
+// _mActivity.onBackPressed();
+ QRCodeDialog qrCodeDialog = QRCodeDialog.newInstance("f");
+ qrCodeDialog.setStyle(DialogFragment.STYLE_NORMAL,R.style.Dialog_FullScreen);
+ qrCodeDialog.show(getFragmentManager(),"qrcode");
break;
case R.id.iv_head:
- MyLog.i(TAG,"绛惧埌锛岃幏鍙栬韩浠借瘉鐗╃悊鍗″彿");
- AYSdk.getInstance().sendCmd(Constant.READ_PHYSICAL_ID,"");
+ MyLog.i(PlatFormConstant.HTTPTAG,"绛惧埌");
+// AYSdk.getInstance().sendCmd(Constant.READ_PHYSICAL_ID,"");
//TODO 鑾峰緱鐗╃悊鍗″彿 鍙戦�丣KMessage0201缁欏钩鍙帮紝鑾峰彇濮撳悕銆佽韩浠借瘉銆乭ead_url
+ loadProgressDialog = LoadProgressDialog.newInstance("璇风◢鍚�...");
+ loadProgressDialog.setStyle(DialogFragment.STYLE_NORMAL,R.style.Dialog_FullScreen);
+ loadProgressDialog.showNow(getFragmentManager(),"loadingdiaolog");
+ //浠庢湇鍔″櫒鑾峰彇鐢ㄤ簬鐢熸垚绛惧埌浜岀淮鐮佺殑url
break;
}
}
@@ -756,4 +769,6 @@
super.onDetach();
CEventCenter.onBindEvent(false,icEventListener,Constant.BIND_SPEED_TOPIC);
}
+
+
}
diff --git a/app/src/main/res/drawable/anim_loading.xml b/app/src/main/res/drawable/anim_loading.xml
new file mode 100644
index 0000000..125d033
--- /dev/null
+++ b/app/src/main/res/drawable/anim_loading.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
+ android:drawable="@drawable/icon_loading"
+ android:fromDegrees="0.0"
+ android:pivotX="50.0%"
+ android:pivotY="50.0%"
+ android:toDegrees="360.0" />
\ No newline at end of file
diff --git a/app/src/main/res/drawable/dialog_round.xml b/app/src/main/res/drawable/dialog_round.xml
new file mode 100644
index 0000000..4810941
--- /dev/null
+++ b/app/src/main/res/drawable/dialog_round.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle" >
+<solid android:color="#333333"/>
+ <corners android:radius="8dp"/>
+</shape>
\ No newline at end of file
diff --git a/app/src/main/res/drawable/icon_loading.png b/app/src/main/res/drawable/icon_loading.png
new file mode 100644
index 0000000..e04c045
--- /dev/null
+++ b/app/src/main/res/drawable/icon_loading.png
Binary files differ
diff --git a/app/src/main/res/drawable/qrcode.jpg b/app/src/main/res/drawable/qrcode.jpg
new file mode 100644
index 0000000..1ca9b6d
--- /dev/null
+++ b/app/src/main/res/drawable/qrcode.jpg
Binary files differ
diff --git a/app/src/main/res/layout/layout_dialog_loading.xml b/app/src/main/res/layout/layout_dialog_loading.xml
new file mode 100644
index 0000000..1cb7cb9
--- /dev/null
+++ b/app/src/main/res/layout/layout_dialog_loading.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:background="@android:color/transparent"
+ android:gravity="center"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:id="@+id/linearLayout"
+ android:layout_width="100dp"
+ android:layout_height="100dp"
+ android:background="#333333"
+ android:gravity="center"
+ android:orientation="vertical" >
+
+ <ProgressBar
+ android:id="@+id/progressBar1"
+ style="?android:attr/progressBarStyleInverse"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:indeterminateBehavior="repeat"
+ android:indeterminateDrawable="@drawable/anim_loading"
+ android:background="@android:color/transparent" />
+
+ <TextView
+ android:id="@+id/tv_message"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:paddingTop="5dp"
+ android:text="Message"
+ android:visibility="gone"
+ android:textColor="@android:color/holo_red_dark"
+ />
+ </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/layout_dialog_qrcode.xml b/app/src/main/res/layout/layout_dialog_qrcode.xml
new file mode 100644
index 0000000..fd6494c
--- /dev/null
+++ b/app/src/main/res/layout/layout_dialog_qrcode.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:background="@android:color/transparent"
+ android:gravity="center"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:id="@+id/linearLayout"
+ android:layout_width="210dp"
+ android:layout_height="210dp"
+ android:gravity="center"
+ android:background="@android:color/white"
+ android:orientation="vertical" >
+
+ <ImageView
+ android:id="@+id/iv_qr_code"
+ android:layout_width="125dp"
+ android:layout_height="125dp"
+ android:layout_margin="10dp"
+ android:scaleType="fitCenter"
+ android:src="@drawable/qrcode"
+ />
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="纭畾"
+ android:padding="10dp"
+ android:background="@drawable/ic_btn_daikao"
+ android:textColor="@android:color/white"
+ android:id="@+id/btn_qr_sure"/>
+
+ </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 0bbdc2b..16fc81d 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -52,4 +52,9 @@
<item name="android:ems">6</item>
<item name="android:background">@android:drawable/edit_text</item>
</style>
+
+ <style name="Dialog.FullScreen" parent="Theme.AppCompat.Dialog">
+ <item name="android:padding">0dp</item>
+ <item name="android:windowBackground">@android:color/transparent</item>
+ </style>
</resources>
--
Gitblit v1.8.0