commit 50beff3dc7debd94c3fd2970764723b52b91a41e Author: Ming <18642047181@163.com> Date: Tue Mar 15 18:39:48 2022 +0800 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..7b57752 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,24 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..6560a98 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,36 @@ + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..2370474 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d5d35ec --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..295d3e2 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,41 @@ +plugins { + id 'com.android.application' +} + +android { + compileSdkVersion 28 + buildToolsVersion "29.0.2" + + defaultConfig { + applicationId "com.skipping" + minSdkVersion 21 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'com.google.android.material:material:1.3.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation project(path: ':libs') + testImplementation 'junit:junit:4.+' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + implementation 'com.github.felHR85:UsbSerial:6.1.0' +} \ No newline at end of file diff --git a/app/libs/loopminisdk.aar b/app/libs/loopminisdk.aar new file mode 100644 index 0000000..5653382 Binary files /dev/null and b/app/libs/loopminisdk.aar differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/com/skipping/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/skipping/ExampleInstrumentedTest.java new file mode 100644 index 0000000..7de2d20 --- /dev/null +++ b/app/src/androidTest/java/com/skipping/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.skipping; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.skipping", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..226b770 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/skipping/APP.java b/app/src/main/java/com/skipping/APP.java new file mode 100644 index 0000000..8c81dab --- /dev/null +++ b/app/src/main/java/com/skipping/APP.java @@ -0,0 +1,12 @@ +package com.skipping; + + + +import com.libs.fragment.BaseApplication; + +/** + * @author Ming + * 3/14/22 + */ +public class APP extends BaseApplication { +} diff --git a/app/src/main/java/com/skipping/Contants.java b/app/src/main/java/com/skipping/Contants.java new file mode 100644 index 0000000..61d2e81 --- /dev/null +++ b/app/src/main/java/com/skipping/Contants.java @@ -0,0 +1,20 @@ +package com.skipping; + +/** + * @author Ming + * 3/14/22 + */ +public class Contants { + + /** + * url路径 + */ + public final static String BASE_URL = "https://api.xintijiao.com/ijustjump/"; + + + public final static String CLASS = "class"; + + public final static String GRADE = "grade"; + + public final static String UNFINISHED = "未完成"; +} diff --git a/app/src/main/java/com/skipping/MainPresenter.java b/app/src/main/java/com/skipping/MainPresenter.java new file mode 100644 index 0000000..609de94 --- /dev/null +++ b/app/src/main/java/com/skipping/MainPresenter.java @@ -0,0 +1,10 @@ +package com.skipping; + +import com.libs.fragment.BaseApplication; + +/** + * @author Ming + * 3/14/22 + */ +public class MainPresenter extends BaseApplication { +} diff --git a/app/src/main/java/com/skipping/activity/HostActivity.java b/app/src/main/java/com/skipping/activity/HostActivity.java new file mode 100644 index 0000000..b30f11d --- /dev/null +++ b/app/src/main/java/com/skipping/activity/HostActivity.java @@ -0,0 +1,269 @@ +package com.skipping.activity; + +import android.content.BroadcastReceiver; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.ServiceConnection; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; + +import com.libs.fragment.BaseActivity; +import com.libs.utils.LogUtil; +import com.libs.utils.ToastUtil; +import com.loop.loopminisdk.LoopDevice; +import com.loop.loopminisdk.LoopHost; +import com.loop.loopminisdk.LoopMessage; +import com.loop.loopminisdk.LoopMini; +import com.skipping.R; +import com.skipping.utils.ThreadPoolUtil; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ScheduledFuture; +import java.util.stream.Collectors; + +/** + * @author Ming + * 3/15/22 + */ +public class HostActivity extends BaseActivity { + private LoopMini loopMax; + private Set loopDeviceSet = new HashSet<>(); + private LoopDevice loopDevice; + private EditText editText; + private LoopHost loopHost; + private MyHandler mHandler; + private int position; + private ScheduledFuture scheduledFuture; + private Button btn, btn2, btn3, btn4, btn5; + private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + switch (intent.getAction()) { + case LoopMini.ACTION_USB_PERMISSION_GRANTED: + ToastUtil.longToast("确认设备权限"); + break; + case LoopMini.ACTION_USB_PERMISSION_NOT_GRANTED: + ToastUtil.longToast("取消设备权限"); + break; + case LoopMini.ACTION_NO_USB: + ToastUtil.longToast("没有插入设备"); + break; + case LoopMini.ACTION_USB_DISCONNECTED: + ToastUtil.longToast("拔出设备"); + break; + case LoopMini.ACTION_USB_NOT_SUPPORTED: + ToastUtil.longToast("设备无法识别"); + break; + } + } + }; + private final ServiceConnection usbConnection = new ServiceConnection() { + @Override + public void onServiceConnected(ComponentName arg0, IBinder arg1) { + loopMax = ((LoopMini.UsbBinder) arg1).getService(); + loopMax.setHandler(mHandler); + } + + @Override + public void onServiceDisconnected(ComponentName arg0) { + loopMax = null; + } + }; + + @Override + protected int getContentViewResId() { + return R.layout.activity_host; + } + + @Override + protected void initView() { + btn = findViewById(R.id.btn); + btn2 = findViewById(R.id.btn2); + btn3 = findViewById(R.id.btn3); + btn4 = findViewById(R.id.btn4); + btn5 = findViewById(R.id.btn5); + editText = findViewById(R.id.edittext); + btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getHostInfo(); + openPairMode(); + } + }); + btn2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + pairDevice(Integer.valueOf(editText.getText().toString())); + } + }); + btn3.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + LogUtil.e("设备数据", loopDeviceSet); + } + }); + btn4.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + closePairMode(); + connectDevice(); + } + }); + btn5.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + closePairMode(); + disconnectDevice(); + } + }); + + + } + + @Override + protected void initData() { + mHandler = new MyHandler(); + } + + + /** + * 连接主机 + */ + private void getHostInfo() { + loopMax.getHostInfo(); + } + + /** + * 开启配对模式 + */ + private void openPairMode() { + loopMax.openPairMode(); + } + + /** + * 关闭配对模式 + */ + private void closePairMode() { + loopMax.closePairMode(); + } + + /** + * 匹配设备到指定id + * + * @param id + */ + private void pairDevice(int id) { + loopMax.pairDevice(id); + } + + /** + * 连接设备 + */ + private void connectDevice() { + connectDeviceInner(loopDevice -> loopMax.connectDevice(loopDevice)); + } + + private void disconnectDevice() { + connectDeviceInner(loopDevice -> loopMax.disconnectDevice(loopDevice)); + } + + + private void connectDeviceInner(ConnectInterface connectInterface) { + if (loopDeviceSet.size() == 0) { + return; + } + if (scheduledFuture != null) { + scheduledFuture.cancel(false); + } + List deviceList = loopDeviceSet.stream().collect(Collectors.toList()); + position = 0; + scheduledFuture = ThreadPoolUtil.getSingleton().scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + if (position > deviceList.size()) { + scheduledFuture.cancel(false); + } + connectInterface.connect(deviceList.get(position)); + position++; + } + }, 0, 10); + } + + public interface ConnectInterface { + void connect(LoopDevice loopDevice); + } + + @Override + protected void onResume() { + super.onResume(); + setFilters(); + startService(usbConnection); + } + + @Override + public void onPause() { + super.onPause(); + unregisterReceiver(mUsbReceiver); + unbindService(usbConnection); + } + + private void startService(ServiceConnection serviceConnection) { + if (!LoopMini.SERVICE_CONNECTED) { + Intent startService = new Intent(this, LoopMini.class); + startService(startService); + } + Intent bindingIntent = new Intent(this, LoopMini.class); + bindService(bindingIntent, serviceConnection, Context.BIND_AUTO_CREATE); + } + + private void setFilters() { + IntentFilter filter = new IntentFilter(); + filter.addAction(LoopMini.ACTION_USB_PERMISSION_GRANTED); + filter.addAction(LoopMini.ACTION_NO_USB); + filter.addAction(LoopMini.ACTION_USB_DISCONNECTED); + filter.addAction(LoopMini.ACTION_USB_NOT_SUPPORTED); + filter.addAction(LoopMini.ACTION_USB_PERMISSION_NOT_GRANTED); + registerReceiver(mUsbReceiver, filter); + } + + + private class MyHandler extends Handler { + @Override + public void handleMessage(Message msg) { + super.handleMessage(msg); + switch (msg.what) { + case LoopMini.LOOP_PAIR_DEVICE_INFO: + loopDevice = (LoopDevice) msg.obj; + addDevice(loopDevice); + LogUtil.e("连接LoopDevice", loopDevice.toString()); + break; + case LoopMini.Loop_GET_HOST_INFO: + loopHost = (LoopHost) msg.obj; + LogUtil.e("LoopHost", loopHost.toString()); + break; + case LoopMini.LOOP_GET_DEVICE_INFO: + loopDevice = (LoopDevice) msg.obj; + addDevice(loopDevice); + LogUtil.e("获取LoopDevice", loopDevice.toString()); + break; + case LoopMini.LOOP_MESSAGE: + LoopMessage loopMessage = (LoopMessage) msg.obj; + LogUtil.e("LoopMessage", loopMessage.toString()); + break; + } + } + } + + private void addDevice(LoopDevice loopDevice) { + loopDeviceSet.add(loopDevice); + } + +} diff --git a/app/src/main/java/com/skipping/activity/MainActivity.java b/app/src/main/java/com/skipping/activity/MainActivity.java new file mode 100644 index 0000000..aa15078 --- /dev/null +++ b/app/src/main/java/com/skipping/activity/MainActivity.java @@ -0,0 +1,70 @@ +package com.skipping.activity; + + +import android.content.Intent; +import android.view.View; +import android.widget.Button; + +import com.libs.fragment.BaseActivity; +import com.libs.network.CallBack; +import com.libs.network.Concise; +import com.skipping.Contants; +import com.skipping.R; +import com.skipping.net.API; +import com.skipping.net.BaseBean; +import com.skipping.net.TokenBean; +import com.skipping.net.TokenReqBean; + +public class MainActivity extends BaseActivity { + private Concise concise; + private Button btn, btn2; + + @Override + protected int getContentViewResId() { + return R.layout.activity_main; + } + + @Override + protected void initView() { + btn = findViewById(R.id.btn); + btn2 = findViewById(R.id.btn2); + btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(MainActivity.this, HostActivity.class); + startActivity(intent); + } + }); + btn2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(MainActivity.this, NetActivity.class); + startActivity(intent); + } + }); + } + + @Override + protected void initData() { + concise = new Concise(Contants.BASE_URL) { + } + .build(); + } + + + private void login() { + TokenReqBean tokenReqBean = new TokenReqBean(); + concise.request(this, concise.api.token(tokenReqBean), new CallBack>() { + @Override + public void onSuccess(BaseBean tokenBeanBaseBean) { + + } + + @Override + public void onFailed(Throwable e) { + + } + }); + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/skipping/activity/MainActivity2.java b/app/src/main/java/com/skipping/activity/MainActivity2.java new file mode 100644 index 0000000..356626a --- /dev/null +++ b/app/src/main/java/com/skipping/activity/MainActivity2.java @@ -0,0 +1,163 @@ +package com.skipping.activity; + +import android.content.BroadcastReceiver; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.ServiceConnection; +import android.os.Bundle; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; +import android.util.Log; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; + +import com.loop.loopminisdk.LoopDevice; +import com.loop.loopminisdk.LoopHost; +import com.loop.loopminisdk.LoopMessage; +import com.loop.loopminisdk.LoopMini; +import com.skipping.R; + +/** + * @author Ming + * 3/14/22 + */ +public class MainActivity2 extends AppCompatActivity { + private LoopMini loopMax; + private LoopDevice loopDevice; + private EditText editText; + private LoopHost loopHost; + private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + switch (intent.getAction()) { + case LoopMini.ACTION_USB_PERMISSION_GRANTED: // USB PERMISSION GRANTED + Toast.makeText(context, "USB Ready", Toast.LENGTH_SHORT).show(); + break; + case LoopMini.ACTION_USB_PERMISSION_NOT_GRANTED: // USB PERMISSION NOT GRANTED + Toast.makeText(context, "USB Permission not granted", Toast.LENGTH_SHORT).show(); + break; + case LoopMini.ACTION_NO_USB: // NO USB CONNECTED + Toast.makeText(context, "No USB connected", Toast.LENGTH_SHORT).show(); + break; + case LoopMini.ACTION_USB_DISCONNECTED: // USB DISCONNECTED + Toast.makeText(context, "USB disconnected", Toast.LENGTH_SHORT).show(); + break; + case LoopMini.ACTION_USB_NOT_SUPPORTED: // USB NOT SUPPORTED + Toast.makeText(context, "USB device not supported", Toast.LENGTH_SHORT).show(); + break; + } + } + }; + private MyHandler mHandler; + private final ServiceConnection usbConnection = new ServiceConnection() { + @Override + public void onServiceConnected(ComponentName arg0, IBinder arg1) { + loopMax = ((LoopMini.UsbBinder) arg1).getService(); + loopMax.setHandler(mHandler); + } + + @Override + public void onServiceDisconnected(ComponentName arg0) { + loopMax = null; + } + }; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main2); + mHandler = new MyHandler(); + editText = findViewById(R.id.edittext); + Button button1 = findViewById(R.id.button); + Button button2 = findViewById(R.id.button2); + Button button3 = findViewById(R.id.button3); + Button button4 = findViewById(R.id.button4); + Button button5 = findViewById(R.id.button5); + Button button6 = findViewById(R.id.button6); + Button button7 = findViewById(R.id.button7); + Button button8 = findViewById(R.id.button8); + Button button9 = findViewById(R.id.button9); + Button button10 = findViewById(R.id.button10); + button1.setOnClickListener(v -> loopMax.getHostInfo()); + button2.setOnClickListener(v -> loopMax.openPairMode()); + button3.setOnClickListener(v -> loopMax.closePairMode()); + button4.setOnClickListener(v -> loopMax.pairDevice(Integer.valueOf(editText.getText().toString()))); + button5.setOnClickListener(v -> { + if (loopDevice != null) { + loopMax.connectDevice(loopDevice); + } + }); + button6.setOnClickListener(v -> { + if (loopDevice != null) { + loopMax.disconnectDevice(loopDevice); + } + }); + button7.setOnClickListener(v -> loopMax.getPower()); + button8.setOnClickListener(v -> loopMax.getCount()); + button9.setOnClickListener(v -> loopMax.startJumpLimitTime(30)); + button10.setOnClickListener(v -> loopMax.stopJump()); + } + + @Override + protected void onResume() { + super.onResume(); + setFilters(); // Start listening notifications from UsbService + startService(usbConnection); // Start UsbService(if it was not started before) and Bind it + } + + @Override + public void onPause() { + super.onPause(); + unregisterReceiver(mUsbReceiver); + unbindService(usbConnection); + } + + private void startService(ServiceConnection serviceConnection) { + if (!LoopMini.SERVICE_CONNECTED) { + Intent startService = new Intent(this, LoopMini.class); + startService(startService); + } + Intent bindingIntent = new Intent(this, LoopMini.class); + bindService(bindingIntent, serviceConnection, Context.BIND_AUTO_CREATE); + } + + private void setFilters() { + IntentFilter filter = new IntentFilter(); + filter.addAction(LoopMini.ACTION_USB_PERMISSION_GRANTED); + filter.addAction(LoopMini.ACTION_NO_USB); + filter.addAction(LoopMini.ACTION_USB_DISCONNECTED); + filter.addAction(LoopMini.ACTION_USB_NOT_SUPPORTED); + filter.addAction(LoopMini.ACTION_USB_PERMISSION_NOT_GRANTED); + registerReceiver(mUsbReceiver, filter); + } + + private class MyHandler extends Handler { + @Override + public void handleMessage(Message msg) { + super.handleMessage(msg); + switch (msg.what) { + case LoopMini.LOOP_PAIR_DEVICE_INFO: + loopDevice = (LoopDevice) msg.obj; + Log.d("LoopDevice", loopDevice.toString()); + break; + case LoopMini.Loop_GET_HOST_INFO: + loopHost = (LoopHost) msg.obj; + Log.d("LoopHost", loopHost.toString()); + break; + case LoopMini.LOOP_GET_DEVICE_INFO: + LoopDevice loopDevice = (LoopDevice) msg.obj; + Log.d("LoopDevice", loopDevice.toString()); + break; + case LoopMini.LOOP_MESSAGE: + LoopMessage loopMessage = (LoopMessage) msg.obj; + Log.d("LoopMessage", loopMessage.toString()); + break; + } + } + } +} diff --git a/app/src/main/java/com/skipping/activity/NetActivity.java b/app/src/main/java/com/skipping/activity/NetActivity.java new file mode 100644 index 0000000..5e21509 --- /dev/null +++ b/app/src/main/java/com/skipping/activity/NetActivity.java @@ -0,0 +1,215 @@ +package com.skipping.activity; + +import android.view.View; +import android.widget.Button; + +import com.libs.fragment.BaseActivity; +import com.libs.network.CallBack; +import com.libs.network.Concise; +import com.libs.utils.LogUtil; +import com.skipping.Contants; +import com.skipping.R; +import com.skipping.net.API; +import com.skipping.net.ActivityBean; +import com.skipping.net.ActivityReqBean; +import com.skipping.net.AddActivityBean; +import com.skipping.net.AddActivityReqBean; +import com.skipping.net.BaseBean; +import com.skipping.net.DetailActivityBean; +import com.skipping.net.GradleBean; +import com.skipping.net.ScoreReqBean; +import com.skipping.net.TokenBean; +import com.skipping.net.TokenReqBean; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Ming + * 3/15/22 + */ +public class NetActivity extends BaseActivity { + private Button btn, btn2, btn3, btn4, btn5, btn6, btn7; + private Concise tokenConcise = new Concise(Contants.BASE_URL) { + }.build(); + private Concise concise; + + @Override + protected int getContentViewResId() { + return R.layout.activity_net; + } + + @Override + protected void initView() { + btn = findViewById(R.id.btn); + btn2 = findViewById(R.id.btn2); + btn3 = findViewById(R.id.btn3); + btn4 = findViewById(R.id.btn4); + btn5 = findViewById(R.id.btn5); + btn6 = findViewById(R.id.btn6); + btn7 = findViewById(R.id.btn7); + + btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + TokenReqBean tokenReqBean = new TokenReqBean(); + tokenReqBean.setDeviceID("466e9c"); + tokenReqBean.setLogName("loop"); + tokenReqBean.setLogPwd("123456"); + tokenConcise.request(NetActivity.this, tokenConcise.api.token(tokenReqBean), new CallBack>() { + @Override + public void onSuccess(BaseBean tokenBeanBaseBean) { + concise = new Concise(Contants.BASE_URL) { + }.addHeader("Token", tokenBeanBaseBean.getData().getToken()).build(); + } + + @Override + public void onFailed(Throwable e) { + + } + }); + } + }); + + btn2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + concise.request(NetActivity.this, concise.api.getGrade(), new CallBack>>() { + @Override + public void onSuccess(BaseBean> listBaseBean) { + } + + @Override + public void onFailed(Throwable e) { + + } + }); + } + }); + + btn3.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + concise.request(NetActivity.this, concise.api.getClass("6b76e9770a4eafbcee213121d4ad6b"), new CallBack>>() { + @Override + public void onSuccess(BaseBean> listBaseBean) { + LogUtil.e("数据",listBaseBean.getData()); + } + + @Override + public void onFailed(Throwable e) { + + } + }); + } + }); + + btn4.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ActivityReqBean bean = new ActivityReqBean(); + bean.setGenre(Contants.CLASS); + bean.setActivityType("timing"); + bean.setGroupID("77bba9124a4281bc9f92f965561cd5"); + bean.setIndex(1); + bean.setPageSize(10); + bean.setStatus(Contants.UNFINISHED); + concise.request(NetActivity.this, concise.api.getActivityList(bean), new CallBack>>() { + @Override + public void onSuccess(BaseBean> listBaseBean) { + + } + + @Override + public void onFailed(Throwable e) { + + } + }); + } + }); + + btn5.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + AddActivityReqBean bean = new AddActivityReqBean(); + bean.setName("test001"); + bean.setActivityType("timing"); + bean.setValue(60); + bean.setGroupID("77bba9124a4281bc9f92f965561cd5"); + bean.setPersonNumber(6); + bean.setStep(2); + concise.request(NetActivity.this, concise.api.addActivity(bean), new CallBack>>() { + @Override + public void onSuccess(BaseBean> listBaseBean) { + + } + + @Override + public void onFailed(Throwable e) { + + } + }); + } + }); + + btn6.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + concise.request(NetActivity.this, concise.api.detailActivity("15"), new CallBack>>() { + @Override + public void onSuccess(BaseBean> listBaseBean) { + + } + + @Override + public void onFailed(Throwable e) { + + } + }); + } + }); + + btn7.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ScoreReqBean bean = new ScoreReqBean(); + bean.setId(15); + bean.setStep(2); + List candidatesBeanList = new ArrayList<>(); + ScoreReqBean.CandidatesBean candidatesBean = new ScoreReqBean.CandidatesBean(); + candidatesBean.setComplateTime(1646975055); + ScoreReqBean.CandidatesBean.InfoBean infoBean = new ScoreReqBean.CandidatesBean.InfoBean(); + List list = new ArrayList<>(); + list.add(1); + list.add(1); + list.add(1); + list.add(1); + infoBean.setDetail(list); + infoBean.setPersonID("a12e6f5a4383855caa2bd36958a2"); + infoBean.setScore(10); + List infoBeans = new ArrayList<>(); + infoBeans.add(infoBean); + candidatesBean.setInfo(infoBeans); + candidatesBeanList.add(new ScoreReqBean.CandidatesBean()); + bean.setCandidates(candidatesBeanList); + concise.request(NetActivity.this, concise.api.score(bean), new CallBack() { + @Override + public void onSuccess(BaseBean baseBean) { + + } + + @Override + public void onFailed(Throwable e) { + + } + }); + } + }); + + } + + @Override + protected void initData() { + + } +} diff --git a/app/src/main/java/com/skipping/net/API.java b/app/src/main/java/com/skipping/net/API.java new file mode 100644 index 0000000..3125815 --- /dev/null +++ b/app/src/main/java/com/skipping/net/API.java @@ -0,0 +1,78 @@ +package com.skipping.net; + +import java.util.List; + +import io.reactivex.rxjava3.core.Observable; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.POST; +import retrofit2.http.Path; +import retrofit2.http.Query; + +/** + * @author Ming + * 1/24/22 + */ +public interface API { + + /** + * 登录 + * @param tokenReq + * @return + */ + @POST("auth") + Observable> token(@Body TokenReqBean tokenReq); + + + /** + * 获取年级列表 + * @return + */ + @GET("groupmap?genre=grade") + Observable>> getGrade(); + + + /** + * 获取班级列表 + * @param pid + * @return + */ + @GET("groupmap?genre=class") + Observable>> getClass(@Query("pid") String pid); + + + /** + * 获取活动列表 + * @param activityReqBean + * @return + */ + @POST("activity/list") + Observable>> getActivityList(@Body ActivityReqBean activityReqBean); + + + /** + * 添加活动 + * @param addActivityReqBean + * @return + */ + @POST("activity/create") + Observable>> addActivity(@Body AddActivityReqBean addActivityReqBean); + + /** + * 活动详情 + * @param id + * @return + */ + @GET("activity/detail") + Observable>> detailActivity(@Query("activityid") String id); + + /** + * 上报 + * @param scoreReqBean + * @return + */ + @POST("activity/score") + Observable score(@Body ScoreReqBean scoreReqBean); + + +} diff --git a/app/src/main/java/com/skipping/net/ActivityBean.java b/app/src/main/java/com/skipping/net/ActivityBean.java new file mode 100644 index 0000000..100dce7 --- /dev/null +++ b/app/src/main/java/com/skipping/net/ActivityBean.java @@ -0,0 +1,165 @@ +package com.skipping.net; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +/** + * @author Ming + * 3/15/22 + */ +public class ActivityBean implements Serializable { + + /** + * ID : 13 + * Name : loop2 + * ActivityType : timing + * Value : 60 + * OrgID : ae428145b8a466e9c72f6047b8 + * GreadID : 6b76e9770a4eafbcee213121d4ad6b + * ClassID : 77bba9124a4281bc9f92f965561cd5 + * Status : 未完成 + * Step : 2 + * CompleteTime : null + * PersonNumber : 6 + * GroupID : + * CreatedAt : 2022-03-14T08:38:21.495+08:00 + */ + + private Integer id; + private String Name; + private String ActivityType; + private Integer Value; + private String OrgID; + private String GreadID; + private String ClassID; + private String Status; + private Integer Step; + private Object CompleteTime; + private Integer PersonNumber; + private String GroupID; + private String CreatedAt; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return Name; + } + + public void setName(String name) { + Name = name; + } + + public String getActivityType() { + return ActivityType; + } + + public void setActivityType(String activityType) { + ActivityType = activityType; + } + + public Integer getValue() { + return Value; + } + + public void setValue(Integer value) { + Value = value; + } + + public String getOrgID() { + return OrgID; + } + + public void setOrgID(String orgID) { + OrgID = orgID; + } + + public String getGreadID() { + return GreadID; + } + + public void setGreadID(String greadID) { + GreadID = greadID; + } + + public String getClassID() { + return ClassID; + } + + public void setClassID(String classID) { + ClassID = classID; + } + + public String getStatus() { + return Status; + } + + public void setStatus(String status) { + Status = status; + } + + public Integer getStep() { + return Step; + } + + public void setStep(Integer step) { + Step = step; + } + + public Object getCompleteTime() { + return CompleteTime; + } + + public void setCompleteTime(Object completeTime) { + CompleteTime = completeTime; + } + + public Integer getPersonNumber() { + return PersonNumber; + } + + public void setPersonNumber(Integer personNumber) { + PersonNumber = personNumber; + } + + public String getGroupID() { + return GroupID; + } + + public void setGroupID(String groupID) { + GroupID = groupID; + } + + public String getCreatedAt() { + return CreatedAt; + } + + public void setCreatedAt(String createdAt) { + CreatedAt = createdAt; + } + + @Override + public String toString() { + return "ActivityBean{" + + "id=" + id + + ", Name='" + Name + '\'' + + ", ActivityType='" + ActivityType + '\'' + + ", Value=" + Value + + ", OrgID='" + OrgID + '\'' + + ", GreadID='" + GreadID + '\'' + + ", ClassID='" + ClassID + '\'' + + ", Status='" + Status + '\'' + + ", Step=" + Step + + ", CompleteTime=" + CompleteTime + + ", PersonNumber=" + PersonNumber + + ", GroupID='" + GroupID + '\'' + + ", CreatedAt='" + CreatedAt + '\'' + + '}'; + } +} diff --git a/app/src/main/java/com/skipping/net/ActivityReqBean.java b/app/src/main/java/com/skipping/net/ActivityReqBean.java new file mode 100644 index 0000000..9e4458c --- /dev/null +++ b/app/src/main/java/com/skipping/net/ActivityReqBean.java @@ -0,0 +1,108 @@ +package com.skipping.net; + +import java.io.Serializable; + +/** + * @author Ming + * 3/15/22 + */ +public class ActivityReqBean implements Serializable { + + /** + * Genre : class + * ActivityType : timing + * GroupID : f3f80d8e934e0d85a01f608978d64d + * Index : 1 + * PageSize : 10 + * Status : 未完成 + * STime : 1646975055 + * ETime : 1646986281 + */ + + private String Genre; + private String ActivityType; + private String GroupID; + private Integer Index; + private Integer PageSize; + private String Status; + private Integer STime; + private Integer ETime; + + public String getGenre() { + return Genre; + } + + public void setGenre(String genre) { + Genre = genre; + } + + public String getActivityType() { + return ActivityType; + } + + public void setActivityType(String activityType) { + ActivityType = activityType; + } + + public String getGroupID() { + return GroupID; + } + + public void setGroupID(String groupID) { + GroupID = groupID; + } + + public Integer getIndex() { + return Index; + } + + public void setIndex(Integer index) { + Index = index; + } + + public Integer getPageSize() { + return PageSize; + } + + public void setPageSize(Integer pageSize) { + PageSize = pageSize; + } + + public String getStatus() { + return Status; + } + + public void setStatus(String status) { + Status = status; + } + + public Integer getSTime() { + return STime; + } + + public void setSTime(Integer STime) { + this.STime = STime; + } + + public Integer getETime() { + return ETime; + } + + public void setETime(Integer ETime) { + this.ETime = ETime; + } + + @Override + public String toString() { + return "ActivityReqBean{" + + "Genre='" + Genre + '\'' + + ", ActivityType='" + ActivityType + '\'' + + ", GroupID='" + GroupID + '\'' + + ", Index=" + Index + + ", PageSize=" + PageSize + + ", Status='" + Status + '\'' + + ", STime=" + STime + + ", ETime=" + ETime + + '}'; + } +} diff --git a/app/src/main/java/com/skipping/net/AddActivityBean.java b/app/src/main/java/com/skipping/net/AddActivityBean.java new file mode 100644 index 0000000..1a61310 --- /dev/null +++ b/app/src/main/java/com/skipping/net/AddActivityBean.java @@ -0,0 +1,156 @@ +package com.skipping.net; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.List; + +/** + * @author Ming + * 3/15/22 + */ +public class AddActivityBean implements Serializable { + + /** + * ID : 14 + * ActivityName : test001 + * ActivityType : timing + * ActivityValue : 60 + * Step : 2 + * Candidates : [[{"PersonID":"4414550b40b38fd171ba2e319dc2","Name":"xiaowang","StudentID":"1005","Score":0,"Detail":[]},{"PersonID":"8d34508b457780a298efba2a9c28","Name":"xiaohua","StudentID":"1006","Score":0,"Detail":[]}]] + */ + + private Integer id; + private String ActivityName; + private String ActivityType; + private Integer ActivityValue; + private Integer Step; + private List> Candidates; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getActivityName() { + return ActivityName; + } + + public void setActivityName(String activityName) { + ActivityName = activityName; + } + + public String getActivityType() { + return ActivityType; + } + + public void setActivityType(String activityType) { + ActivityType = activityType; + } + + public Integer getActivityValue() { + return ActivityValue; + } + + public void setActivityValue(Integer activityValue) { + ActivityValue = activityValue; + } + + public Integer getStep() { + return Step; + } + + public void setStep(Integer step) { + Step = step; + } + + public List> getCandidates() { + return Candidates; + } + + public void setCandidates(List> candidates) { + Candidates = candidates; + } + + @Override + public String toString() { + return "AddActivityBean{" + + "id=" + id + + ", ActivityName='" + ActivityName + '\'' + + ", ActivityType='" + ActivityType + '\'' + + ", ActivityValue=" + ActivityValue + + ", Step=" + Step + + ", Candidates=" + Candidates + + '}'; + } + + public static class CandidatesBean implements Serializable { + /** + * PersonID : 4414550b40b38fd171ba2e319dc2 + * Name : xiaowang + * StudentID : 1005 + * Score : 0 + * Detail : [] + */ + + private String PersonID; + private String Name; + private String StudentID; + private Integer Score; + private List Detail; + + public String getPersonID() { + return PersonID; + } + + public void setPersonID(String personID) { + PersonID = personID; + } + + public String getName() { + return Name; + } + + public void setName(String name) { + Name = name; + } + + public String getStudentID() { + return StudentID; + } + + public void setStudentID(String studentID) { + StudentID = studentID; + } + + public Integer getScore() { + return Score; + } + + public void setScore(Integer score) { + Score = score; + } + + public List getDetail() { + return Detail; + } + + public void setDetail(List detail) { + Detail = detail; + } + + @Override + public String toString() { + return "CandidatesBean{" + + "PersonID='" + PersonID + '\'' + + ", Name='" + Name + '\'' + + ", StudentID='" + StudentID + '\'' + + ", Score=" + Score + + ", Detail=" + Detail + + '}'; + } + } +} diff --git a/app/src/main/java/com/skipping/net/AddActivityReqBean.java b/app/src/main/java/com/skipping/net/AddActivityReqBean.java new file mode 100644 index 0000000..9378e4e --- /dev/null +++ b/app/src/main/java/com/skipping/net/AddActivityReqBean.java @@ -0,0 +1,86 @@ +package com.skipping.net; + +import java.io.Serializable; + +/** + * @author Ming + * 3/15/22 + */ +public class AddActivityReqBean implements Serializable { + + /** + * Name : loop2 + * ActivityType : timing + * Value : 60 + * GroupID : f3f80d8e934e0d85a01f608978d64d + * PersonNumber : 6 + * Step : 2 + */ + + private String Name; + private String ActivityType; + private Integer Value; + private String GroupID; + private Integer PersonNumber; + private Integer Step; + + public String getName() { + return Name; + } + + public void setName(String name) { + Name = name; + } + + public String getActivityType() { + return ActivityType; + } + + public void setActivityType(String activityType) { + ActivityType = activityType; + } + + public Integer getValue() { + return Value; + } + + public void setValue(Integer value) { + Value = value; + } + + public String getGroupID() { + return GroupID; + } + + public void setGroupID(String groupID) { + GroupID = groupID; + } + + public Integer getPersonNumber() { + return PersonNumber; + } + + public void setPersonNumber(Integer personNumber) { + PersonNumber = personNumber; + } + + public Integer getStep() { + return Step; + } + + public void setStep(Integer step) { + Step = step; + } + + @Override + public String toString() { + return "AddActivityReqBean{" + + "Name='" + Name + '\'' + + ", ActivityType='" + ActivityType + '\'' + + ", Value=" + Value + + ", GroupID='" + GroupID + '\'' + + ", PersonNumber=" + PersonNumber + + ", Step=" + Step + + '}'; + } +} diff --git a/app/src/main/java/com/skipping/net/BaseBean.java b/app/src/main/java/com/skipping/net/BaseBean.java new file mode 100644 index 0000000..7fa54e7 --- /dev/null +++ b/app/src/main/java/com/skipping/net/BaseBean.java @@ -0,0 +1,47 @@ +package com.skipping.net; + +/** + * @author Ming + * 3/14/22 + */ +public class BaseBean { + private Integer code; + private String msg; + private T data; + + public BaseBean() { + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } + + @Override + public String toString() { + return "BaseBean{" + + "code=" + code + + ", msg='" + msg + '\'' + + ", data=" + data + + '}'; + } +} diff --git a/app/src/main/java/com/skipping/net/DetailActivityBean.java b/app/src/main/java/com/skipping/net/DetailActivityBean.java new file mode 100644 index 0000000..615c237 --- /dev/null +++ b/app/src/main/java/com/skipping/net/DetailActivityBean.java @@ -0,0 +1,189 @@ +package com.skipping.net; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.List; + +/** + * @author Ming + * 3/15/22 + */ +public class DetailActivityBean implements Serializable { + + /** + * ID : 1 + * ActivityName : 活动1 + * ActivityType : timing + * ActivityValue : 60 + * Step : 2 + * Max : 12 + * Avg : 9.75 + * Median : 9.5 + * Candidates : [[{"PersonID":"329b20b046f5888bcd5165d115f1","Name":"xiaofang","StudentID":"1002","Score":12,"Detail":null},{"PersonID":"4557de13408aaf9057752285c81a","Name":"xiaohai","StudentID":"1003","Score":8,"Detail":null},{"PersonID":"4dee38df466fa8469f0e62f672fb","Name":"xiaoli","StudentID":"1004","Score":9,"Detail":null}]] + */ + + private Integer id; + private String ActivityName; + private String ActivityType; + private Integer ActivityValue; + private Integer Step; + private Integer Max; + private Double Avg; + private Double Median; + private List> Candidates; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getActivityName() { + return ActivityName; + } + + public void setActivityName(String activityName) { + ActivityName = activityName; + } + + public String getActivityType() { + return ActivityType; + } + + public void setActivityType(String activityType) { + ActivityType = activityType; + } + + public Integer getActivityValue() { + return ActivityValue; + } + + public void setActivityValue(Integer activityValue) { + ActivityValue = activityValue; + } + + public Integer getStep() { + return Step; + } + + public void setStep(Integer step) { + Step = step; + } + + public Integer getMax() { + return Max; + } + + public void setMax(Integer max) { + Max = max; + } + + public Double getAvg() { + return Avg; + } + + public void setAvg(Double avg) { + Avg = avg; + } + + public Double getMedian() { + return Median; + } + + public void setMedian(Double median) { + Median = median; + } + + public List> getCandidates() { + return Candidates; + } + + public void setCandidates(List> candidates) { + Candidates = candidates; + } + + @Override + public String toString() { + return "DetailActivityBean{" + + "id=" + id + + ", ActivityName='" + ActivityName + '\'' + + ", ActivityType='" + ActivityType + '\'' + + ", ActivityValue=" + ActivityValue + + ", Step=" + Step + + ", Max=" + Max + + ", Avg=" + Avg + + ", Median=" + Median + + ", Candidates=" + Candidates + + '}'; + } + + public static class CandidatesBean implements Serializable { + /** + * PersonID : 329b20b046f5888bcd5165d115f1 + * Name : xiaofang + * StudentID : 1002 + * Score : 12 + * Detail : null + */ + + private String PersonID; + private String Name; + private String StudentID; + private Integer Score; + private Object Detail; + + public String getPersonID() { + return PersonID; + } + + public void setPersonID(String personID) { + PersonID = personID; + } + + public String getName() { + return Name; + } + + public void setName(String name) { + Name = name; + } + + public String getStudentID() { + return StudentID; + } + + public void setStudentID(String studentID) { + StudentID = studentID; + } + + public Integer getScore() { + return Score; + } + + public void setScore(Integer score) { + Score = score; + } + + public Object getDetail() { + return Detail; + } + + public void setDetail(Object detail) { + Detail = detail; + } + + @Override + public String toString() { + return "CandidatesBean{" + + "PersonID='" + PersonID + '\'' + + ", Name='" + Name + '\'' + + ", StudentID='" + StudentID + '\'' + + ", Score=" + Score + + ", Detail=" + Detail + + '}'; + } + } +} diff --git a/app/src/main/java/com/skipping/net/GradleBean.java b/app/src/main/java/com/skipping/net/GradleBean.java new file mode 100644 index 0000000..526d24f --- /dev/null +++ b/app/src/main/java/com/skipping/net/GradleBean.java @@ -0,0 +1,42 @@ +package com.skipping.net; + +import java.io.Serializable; + +/** + * @author Ming + * 3/15/22 + */ +public class GradleBean implements Serializable { + + /** + * GroupID : 6b76e9770a4eafbcee213121d4ad6b + * GroupName : 101 + */ + + private String GroupID; + private String GroupName; + + public String getGroupID() { + return GroupID; + } + + public void setGroupID(String groupID) { + GroupID = groupID; + } + + public String getGroupName() { + return GroupName; + } + + public void setGroupName(String groupName) { + GroupName = groupName; + } + + @Override + public String toString() { + return "GradleBean{" + + "GroupID='" + GroupID + '\'' + + ", GroupName='" + GroupName + '\'' + + '}'; + } +} diff --git a/app/src/main/java/com/skipping/net/ScoreReqBean.java b/app/src/main/java/com/skipping/net/ScoreReqBean.java new file mode 100644 index 0000000..175b4c7 --- /dev/null +++ b/app/src/main/java/com/skipping/net/ScoreReqBean.java @@ -0,0 +1,135 @@ +package com.skipping.net; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.List; + +/** + * @author Ming + * 3/15/22 + */ +public class ScoreReqBean implements Serializable { + + /** + * ID : 4 + * Step : 2 + * Candidates : [{"ComplateTime":1646975055,"Info":[{"PersonID":"a12e6f5a4383855caa2bd36958a2","Score":10,"Detail":[0,0,0,0,1,2,3,4]},{"PersonID":"329b20b046f5888bcd5165d115f1","Score":12,"Detail":[1,2,2,1,1,2,3,0]},{"PersonID":"4557de13408aaf9057752285c81a","Score":8,"Detail":[0,0,0,0,1,2,3,2]}]}] + */ + + private Integer id; + private Integer Step; + private List Candidates; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getStep() { + return Step; + } + + public void setStep(Integer step) { + Step = step; + } + + public List getCandidates() { + return Candidates; + } + + public void setCandidates(List candidates) { + Candidates = candidates; + } + + @Override + public String toString() { + return "ScoreReqBean{" + + "id=" + id + + ", Step=" + Step + + ", Candidates=" + Candidates + + '}'; + } + + public static class CandidatesBean implements Serializable { + /** + * ComplateTime : 1646975055 + * Info : [{"PersonID":"a12e6f5a4383855caa2bd36958a2","Score":10,"Detail":[0,0,0,0,1,2,3,4]},{"PersonID":"329b20b046f5888bcd5165d115f1","Score":12,"Detail":[1,2,2,1,1,2,3,0]},{"PersonID":"4557de13408aaf9057752285c81a","Score":8,"Detail":[0,0,0,0,1,2,3,2]}] + */ + + private Integer ComplateTime; + private List Info; + + public Integer getComplateTime() { + return ComplateTime; + } + + public void setComplateTime(Integer complateTime) { + ComplateTime = complateTime; + } + + public List getInfo() { + return Info; + } + + public void setInfo(List info) { + Info = info; + } + + @Override + public String toString() { + return "CandidatesBean{" + + "ComplateTime=" + ComplateTime + + ", Info=" + Info + + '}'; + } + + public static class InfoBean implements Serializable { + /** + * PersonID : a12e6f5a4383855caa2bd36958a2 + * Score : 10 + * Detail : [0,0,0,0,1,2,3,4] + */ + + private String PersonID; + private Integer Score; + private List Detail; + + public String getPersonID() { + return PersonID; + } + + public void setPersonID(String personID) { + PersonID = personID; + } + + public Integer getScore() { + return Score; + } + + public void setScore(Integer score) { + Score = score; + } + + public List getDetail() { + return Detail; + } + + public void setDetail(List detail) { + Detail = detail; + } + + @Override + public String toString() { + return "InfoBean{" + + "PersonID='" + PersonID + '\'' + + ", Score=" + Score + + ", Detail=" + Detail + + '}'; + } + } + } +} diff --git a/app/src/main/java/com/skipping/net/TokenBean.java b/app/src/main/java/com/skipping/net/TokenBean.java new file mode 100644 index 0000000..9498a60 --- /dev/null +++ b/app/src/main/java/com/skipping/net/TokenBean.java @@ -0,0 +1,40 @@ +package com.skipping.net; + +import java.io.Serializable; + +/** + * @author Ming + * 3/14/22 + */ +public class TokenBean implements Serializable { + + private String Token; + private Integer ExpireIn; + + public TokenBean() { + } + + public String getToken() { + return Token; + } + + public void setToken(String token) { + Token = token; + } + + public Integer getExpireIn() { + return ExpireIn; + } + + public void setExpireIn(Integer expireIn) { + ExpireIn = expireIn; + } + + @Override + public String toString() { + return "TokenBean{" + + "Token='" + Token + '\'' + + ", ExpireIn=" + ExpireIn + + '}'; + } +} diff --git a/app/src/main/java/com/skipping/net/TokenReqBean.java b/app/src/main/java/com/skipping/net/TokenReqBean.java new file mode 100644 index 0000000..96d021e --- /dev/null +++ b/app/src/main/java/com/skipping/net/TokenReqBean.java @@ -0,0 +1,44 @@ +package com.skipping.net; + +/** + * @author Ming + * 3/14/22 + */ +public class TokenReqBean { + private String LogName; + private String LogPwd; + private String DeviceID; + + public String getLogName() { + return LogName; + } + + public void setLogName(String logName) { + LogName = logName; + } + + public String getLogPwd() { + return LogPwd; + } + + public void setLogPwd(String logPwd) { + LogPwd = logPwd; + } + + public String getDeviceID() { + return DeviceID; + } + + public void setDeviceID(String deviceID) { + DeviceID = deviceID; + } + + @Override + public String toString() { + return "TokenReq{" + + "LogName='" + LogName + '\'' + + ", LogPwd='" + LogPwd + '\'' + + ", DeviceID='" + DeviceID + '\'' + + '}'; + } +} diff --git a/app/src/main/java/com/skipping/utils/ThreadPoolUtil.java b/app/src/main/java/com/skipping/utils/ThreadPoolUtil.java new file mode 100644 index 0000000..03c8087 --- /dev/null +++ b/app/src/main/java/com/skipping/utils/ThreadPoolUtil.java @@ -0,0 +1,130 @@ +package com.skipping.utils; + +import com.libs.threadpool.Pool; +import com.libs.threadpool.Type; +import com.libs.threadpool.callback.DefLogCallBack; +import com.libs.utils.MainLooper; + +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +/** + * @author Ming + * 12/22/21 + * 线程池管理类 + */ +public class ThreadPoolUtil { + private ScheduledExecutorService scheduledPool; + private static volatile ThreadPoolUtil threadPoolManager; + + public ThreadPoolUtil() { + initPool(); + } + + public static ThreadPoolUtil getSingleton() { + if (threadPoolManager == null) { + synchronized (ThreadPoolUtil.class) { + if (threadPoolManager == null) { + threadPoolManager = new ThreadPoolUtil(); + } + } + } + return threadPoolManager; + } + + + private void initPool() { + scheduledPool = (ScheduledExecutorService) new Pool.Builder() + .setThreadType(Type.SCHEDULED) + .setLog(new DefLogCallBack()) + .setSize(12) + .build() + .getThreadPool(); + } + + /** + * 单次延迟任务 + * + * @param command Runnable + * @param delay 延迟时间 + */ + public ScheduledFuture schedule(Runnable command, long delay) { + if (scheduledPool == null) { + initPool(); + } + return scheduledPool.schedule(command, delay, TimeUnit.MILLISECONDS); + } + + /** + * 单次延迟任务 + * + * @param command Runnable + * @param delay 延迟时间 + */ + public ScheduledFuture scheduleMain(Runnable command, long delay) { + if (scheduledPool == null) { + initPool(); + } + return scheduledPool.schedule(() -> MainLooper.runOnUiThread(command), delay, TimeUnit.MILLISECONDS); + } + + + + /** + * 重复任务 + * + * @param command Runnable + * @param initDelay 首次延迟时间 + * @param delay 间隔时间 + */ + public ScheduledFuture scheduleWithFixedDelay(Runnable command, long initDelay, long delay) { + if (scheduledPool == null) { + initPool(); + } + return scheduledPool.scheduleWithFixedDelay(command, initDelay, delay, TimeUnit.MILLISECONDS); + } + + /** + * 重复任务 + * + * @param command Runnable + * @param initDelay 首次延迟时间 + * @param delay 间隔时间 + */ + public ScheduledFuture scheduleWithFixedDelayMain(Runnable command, long initDelay, long delay) { + if (scheduledPool == null) { + initPool(); + } + return scheduledPool.scheduleWithFixedDelay(() -> MainLooper.runOnUiThread(command), initDelay, delay, TimeUnit.MILLISECONDS); + } + + /** + * 重复任务 第一个执行之后定时再执行 + * + * @param command Runnable + * @param initDelay 首次延迟时间 + * @param delay 间隔时间 + */ + public ScheduledFuture scheduleAtFixedRate(Runnable command, long initDelay, long delay) { + if (scheduledPool == null) { + initPool(); + } + return scheduledPool.scheduleAtFixedRate(command, initDelay, delay, TimeUnit.MILLISECONDS); + } + + + /** + * 重复任务 第一个执行之后定时再执行 + * + * @param command Runnable + * @param initDelay 首次延迟时间 + * @param delay 间隔时间 + */ + public ScheduledFuture scheduleAtFixedRateMain(Runnable command, long initDelay, long delay) { + if (scheduledPool == null) { + initPool(); + } + return scheduledPool.scheduleAtFixedRate(() -> MainLooper.runOnUiThread(command), initDelay, delay, TimeUnit.MILLISECONDS); + } +} diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_host.xml b/app/src/main/res/layout/activity_host.xml new file mode 100644 index 0000000..ad043f1 --- /dev/null +++ b/app/src/main/res/layout/activity_host.xml @@ -0,0 +1,47 @@ + + + + + +