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; app/src/main/java/safeluck/drive/evaluation/customview/LoadProgressDialog.java
New file @@ -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="正在加载..."; 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); } } app/src/main/java/safeluck/drive/evaluation/customview/QRCodeDialog.java
New file @@ -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="正在加载..."; 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; } } 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; 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 获得物理卡号 发送JKMessage0201给平台,获取姓名、身份证、head_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); } } app/src/main/res/drawable/anim_loading.xml
New file @@ -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" /> app/src/main/res/drawable/dialog_round.xml
New file @@ -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> app/src/main/res/drawable/icon_loading.png
app/src/main/res/drawable/qrcode.jpg
app/src/main/res/layout/layout_dialog_loading.xml
New file @@ -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> app/src/main/res/layout/layout_dialog_qrcode.xml
New file @@ -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> 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>