Browse Source

Android端量表相关 提交

贾艺驰 4 years ago
parent
commit
dce3e76be8

+ 2 - 0
app/build.gradle

@@ -49,4 +49,6 @@ dependencies {
     annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
 
     implementation 'com.github.sephiroth74:NumberSlidingPicker:v.1.1.1'
+
+    implementation 'org.greenrobot:eventbus:3.2.0'
 }

+ 5 - 3
app/src/main/AndroidManifest.xml

@@ -7,7 +7,7 @@
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
-    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
+    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
 
     <application
         android:name=".App"
@@ -15,10 +15,11 @@
         android:icon="@mipmap/ic_launcher"
         android:label="@string/app_name"
         android:persistent="true"
+        android:requestLegacyExternalStorage="true"
         android:supportsRtl="true"
         android:theme="@style/AppTheme"
-        android:requestLegacyExternalStorage="true"
         android:usesCleartextTraffic="true">
+        <activity android:name=".activity.InputParamActivity"></activity>
         <activity android:name=".activity.WelcomeActivity">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -29,7 +30,7 @@
         <activity
             android:name=".activity.ScaleActivity"
             android:launchMode="singleTask"
-            android:screenOrientation="portrait"/>
+            android:screenOrientation="portrait" />
         <activity
             android:name=".activity.GameActivity"
             android:launchMode="singleTask"
@@ -44,6 +45,7 @@
             android:screenOrientation="portrait" />
         <activity android:name=".activity.NormalUserActivity" />
         <activity android:name=".activity.RingActivity" />
+
         <service android:name=".service.GameService" />
     </application>
 

+ 2 - 1
app/src/main/java/com/jyc/threegames/activity/AdminActivity.java

@@ -6,6 +6,7 @@ import android.os.Bundle;
 import com.jyc.threegames.R;
 import com.jyc.threegames.activity.base.BaseActivity;
 import com.jyc.threegames.bean.GameInfo;
+import com.jyc.threegames.bean.result.ResGameInfo;
 
 import butterknife.OnClick;
 
@@ -43,7 +44,7 @@ public class AdminActivity extends BaseActivity {
 
     @OnClick(R.id.scale)
     public void goToScale(){
-        startActivity(new Intent(this, ScaleActivity.class));
+        RingActivity.LAUNCH(this, new ResGameInfo());
     }
 
     @OnClick(R.id.logout)

+ 16 - 0
app/src/main/java/com/jyc/threegames/activity/InputParamActivity.java

@@ -0,0 +1,16 @@
+package com.jyc.threegames.activity;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.os.Bundle;
+
+import com.jyc.threegames.R;
+import com.jyc.threegames.activity.base.BaseActivity;
+
+public class InputParamActivity extends BaseActivity {
+
+    @Override
+    protected int getRootLayout() {
+        return R.layout.activity_input_param;
+    }
+}

+ 140 - 0
app/src/main/java/com/jyc/threegames/activity/NormalUserActivity.java

@@ -2,15 +2,46 @@ package com.jyc.threegames.activity;
 
 import android.content.Intent;
 import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.BaseAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
 
 import com.jyc.threegames.R;
 import com.jyc.threegames.activity.base.BaseActivity;
+import com.jyc.threegames.bean.EventMessage;
 import com.jyc.threegames.bean.result.ResGameInfo;
+import com.jyc.threegames.bean.result.ResGamePlayTime;
+import com.jyc.threegames.controller.GameController;
+import com.jyc.threegames.net.SimpleRequest;
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
 import butterknife.OnClick;
 
 public class NormalUserActivity extends BaseActivity {
 
+    @BindView(R.id.swipe)
+    SwipeRefreshLayout mSRF;
+    @BindView(R.id.list)
+    ListView mList;
+
+    private Adapter mAdapter;
+
+    private List<ResGamePlayTime> mData = new ArrayList<>();
+
     @Override
     protected String getPageTitle() {
         return "歡迎使用";
@@ -20,6 +51,32 @@ public class NormalUserActivity extends BaseActivity {
     protected void init(Bundle instance) {
         super.init(instance);
 
+        mAdapter = new Adapter();
+        mList.setAdapter(mAdapter);
+
+        mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+            @Override
+            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
+                ScaleActivity.LAUNCH(NormalUserActivity.this, mAdapter.getItem(i).id, mAdapter.getItem(i).gameTime.split(" ")[0]);
+            }
+        });
+
+        mSRF.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+            @Override
+            public void onRefresh() {
+                loadData();
+            }
+        });
+
+        mSRF.post(new Runnable() {
+            @Override
+            public void run() {
+                mSRF.setRefreshing(true);
+                loadData();
+            }
+        });
+
+        EventBus.getDefault().register(this);
     }
 
     @Override
@@ -27,8 +84,91 @@ public class NormalUserActivity extends BaseActivity {
         return R.layout.activity_normal_user;
     }
 
+    @Override
+    protected void onDestroy() {
+        EventBus.getDefault().unregister(this);
+        super.onDestroy();
+    }
+
     @OnClick(R.id.logout)
     public void clickLogout(){
         doLogout();
     }
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void onEvent(EventMessage eventMessage){
+        if (mData != null && mAdapter != null && mSRF != null){
+            mData = new ArrayList<>();
+            mAdapter.notifyDataSetChanged();
+            mSRF.post(new Runnable() {
+                @Override
+                public void run() {
+                    mSRF.setRefreshing(true);
+                    loadData();
+                }
+            });
+        }
+    }
+
+    private void loadData(){
+        new SimpleRequest<List<ResGamePlayTime>>()
+            .request(this, GameController.getInstance().listOverDate(), new SimpleRequest.Executor<List<ResGamePlayTime>>() {
+                @Override
+                public void execute(List<ResGamePlayTime> obj) {
+                    mSRF.setRefreshing(false);
+                    if (obj != null) {
+                        mData = obj;
+                        mAdapter.notifyDataSetChanged();
+                    }
+                }
+            }, new SimpleRequest.Executor<Throwable>() {
+                @Override
+                public void execute(Throwable obj) {
+                    mSRF.setRefreshing(false);
+                }
+            });
+    }
+
+    public class Adapter extends BaseAdapter{
+
+        @Override
+        public int getCount() {
+            return mData.size();
+        }
+
+        @Override
+        public ResGamePlayTime getItem(int i) {
+            return mData.get(i);
+        }
+
+        @Override
+        public long getItemId(int i) {
+            return i;
+        }
+
+        @Override
+        public View getView(int i, View view, ViewGroup viewGroup) {
+            ViewHolder holder;
+            if (view == null){
+                view = getLayoutInflater().inflate(R.layout.item_scale, null);
+                holder = new ViewHolder(view);
+                view.setTag(holder);
+            } else
+                holder = (ViewHolder) view.getTag();
+
+            if (!TextUtils.isEmpty(getItem(i).gameTime))
+                holder.label.setText(getItem(i).gameTime.split(" ")[0]);
+
+            return view;
+        }
+
+        public class ViewHolder{
+            @BindView(R.id.label)
+            TextView label;
+
+            public ViewHolder(View root){
+                ButterKnife.bind(this, root);
+            }
+        }
+    }
 }

+ 30 - 16
app/src/main/java/com/jyc/threegames/activity/RingActivity.java

@@ -6,6 +6,7 @@ import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.res.AssetFileDescriptor;
+import android.icu.util.Calendar;
 import android.media.AudioManager;
 import android.media.MediaPlayer;
 import android.media.Ringtone;
@@ -24,9 +25,12 @@ import com.jyc.threegames.R;
 import com.jyc.threegames.activity.base.BaseActivity;
 import com.jyc.threegames.bean.result.ResGameInfo;
 import com.jyc.threegames.controller.GameController;
+import com.jyc.threegames.controller.LoginController;
 import com.jyc.threegames.net.SimpleRequest;
 
 import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Locale;
 
 import butterknife.BindView;
 import butterknife.OnClick;
@@ -35,9 +39,6 @@ import timber.log.Timber;
 public class RingActivity extends BaseActivity {
     private static final String PARAM_GAME_INFO = "info";
 
-    public static final int TYPE_GAME = 0;
-    public static final int TYPE_SCALE = 1;
-
     @BindView(R.id.label)
     TextView mTVLabel;
 
@@ -106,6 +107,11 @@ public class RingActivity extends BaseActivity {
         if (mGameInfo.playGameType == ResGameInfo.GAME_TYPE_GAME){
             GameActivity.LAUNCH_GAME(this, mGameInfo);
             finish();
+        } else {
+            Calendar calendar = Calendar.getInstance();
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
+            ScaleActivity.LAUNCH(this, mGameInfo.playGameId, simpleDateFormat.format(calendar.getTime()));
+            finish();
         }
     }
 
@@ -117,21 +123,29 @@ public class RingActivity extends BaseActivity {
             .setItems(items, new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialogInterface, int i) {
-                    if (mGameInfo.playGameType == ResGameInfo.GAME_TYPE_GAME){
-                        dialogInterface.dismiss();
-                        Dialog loading = new ProgressDialog(RingActivity.this);
-                        loading.setTitle("正在延遲");
-                        loading.show();
-                        new SimpleRequest<>().request(RingActivity.this,
-                            GameController.getInstance().delayGame(mGameInfo.playGameId, mGameInfo.gameConfigId, getDelayMin(i)), "延遲失敗!請檢查網絡連接狀態", loading, new SimpleRequest.Executor<Object>() {
-                                @Override
-                                public void execute(Object obj) {
-                                    Toast.makeText(RingActivity.this, "延遲成功", Toast.LENGTH_LONG).show();
-                                    finish();
-                                }
-                            });
+                    dialogInterface.dismiss();
+
+                    if (LoginController.getInstance().isCurrentUserAdmin()){
+                        Toast.makeText(RingActivity.this, "延遲成功", Toast.LENGTH_LONG).show();
+                        finish();
+                        return;
                     }
 
+                    Dialog loading = new ProgressDialog(RingActivity.this);
+                    loading.setTitle("正在延遲");
+                    loading.show();
+                    new SimpleRequest<>().request(RingActivity.this,
+                        mGameInfo.playGameType == ResGameInfo.GAME_TYPE_GAME ?
+                        GameController.getInstance().delayGame(mGameInfo.playGameId, mGameInfo.gameConfigId, getDelayMin(i)) :
+                        GameController.getInstance().delayScale(mGameInfo.playGameId, getDelayMin(i)),
+                        "延遲失敗!請檢查網絡連接狀態", loading, new SimpleRequest.Executor<Object>() {
+                        @Override
+                        public void execute(Object obj) {
+                            Toast.makeText(RingActivity.this, "延遲成功", Toast.LENGTH_LONG).show();
+                            finish();
+                        }
+                    });
+
                 }
             }).create().show();
     }

+ 211 - 0
app/src/main/java/com/jyc/threegames/activity/ScaleActivity.java

@@ -1,19 +1,100 @@
 package com.jyc.threegames.activity;
 
+import androidx.annotation.NonNull;
 import androidx.appcompat.app.AppCompatActivity;
 
+import android.app.Activity;
+import android.app.Dialog;
+import android.app.ProgressDialog;
+import android.app.TimePickerDialog;
+import android.content.Intent;
+import android.icu.util.Calendar;
 import android.os.Bundle;
+import android.text.TextUtils;
+import android.widget.TextView;
+import android.widget.TimePicker;
+import android.widget.Toast;
 
 import com.jyc.threegames.App;
 import com.jyc.threegames.R;
 import com.jyc.threegames.activity.base.BaseActivity;
+import com.jyc.threegames.bean.EventMessage;
+import com.jyc.threegames.bean.result.ResGameInfo;
+import com.jyc.threegames.controller.GameController;
+import com.jyc.threegames.controller.LoginController;
+import com.jyc.threegames.net.SimpleRequest;
+
+import org.greenrobot.eventbus.EventBus;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+import butterknife.BindView;
+import butterknife.OnClick;
 
 public class ScaleActivity extends BaseActivity {
 
+    private static final String PARAM_PLAY_GAME_ID = "playGameId";
+    private static final String PARAM_EVENT_DATE = "eventDate";
+
+    private long mPlayGameId = -1;
+    private String mEventDate = "";
+
+    private String mGetUp = "";
+    private String mContact = "";
+    private String mWork = "";
+    private String mDinner = "";
+    private String mSleep = "";
+
+    @BindView(R.id.get_up)
+    TextView mTVGetUp;
+    @BindView(R.id.contact)
+    TextView mTVContact;
+    @BindView(R.id.work)
+    TextView mTVWork;
+    @BindView(R.id.dinner)
+    TextView mTVDinner;
+    @BindView(R.id.sleep)
+    TextView mTVSleep;
+
+    private long mCurrentDate = System.currentTimeMillis();
+
     @Override
     protected void init(Bundle instance) {
         super.init(instance);
         App.CAN_PLAY_GAME = false;
+
+        if (instance != null){
+            mPlayGameId = instance.getLong(PARAM_PLAY_GAME_ID);
+            mEventDate = instance.getString(PARAM_EVENT_DATE);
+        }else{
+            mPlayGameId = getIntent().getLongExtra(PARAM_PLAY_GAME_ID, -1);
+            mEventDate = getIntent().getStringExtra(PARAM_EVENT_DATE);
+        }
+
+        if (!LoginController.getInstance().isCurrentUserAdmin() && (mPlayGameId == -1 || TextUtils.isEmpty(mEventDate))) {
+            finish();
+        }
+    }
+
+    @Override
+    protected String getPageTitle() {
+        return "填寫量表";
+    }
+
+    @Override
+    protected void onSaveInstanceState(@NonNull Bundle outState) {
+        super.onSaveInstanceState(outState);
+        outState.putLong(PARAM_PLAY_GAME_ID, mPlayGameId);
+        outState.putString(PARAM_EVENT_DATE, mEventDate);
+    }
+
+    @Override
+    protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
+        super.onRestoreInstanceState(savedInstanceState);
+        mPlayGameId = savedInstanceState.getLong(PARAM_PLAY_GAME_ID);
+        mEventDate = savedInstanceState.getString(PARAM_EVENT_DATE);
     }
 
     @Override
@@ -26,4 +107,134 @@ public class ScaleActivity extends BaseActivity {
         super.onDestroy();
         App.CAN_PLAY_GAME = true;
     }
+
+    @OnClick(R.id.get_up)
+    public void clickGetUp(){
+        Dialog dialog = getTimeDialog(new TimePickerDialog.OnTimeSetListener() {
+            @Override
+            public void onTimeSet(TimePicker timePicker, int hour, int min) {
+                mGetUp = hour + ":" + min;
+                mTVGetUp.setText(mGetUp);
+            }
+        });
+        dialog.show();
+    }
+
+    @OnClick(R.id.get_up_none)
+    public void clickGetUpNone(){
+        mGetUp = "";
+        mTVGetUp.setText("沒做");
+    }
+
+    @OnClick(R.id.contact)
+    public void clickContact(){
+        Dialog dialog = getTimeDialog(new TimePickerDialog.OnTimeSetListener() {
+            @Override
+            public void onTimeSet(TimePicker timePicker, int hour, int min) {
+                mContact = hour + ":" + min;
+                mTVContact.setText(mContact);
+            }
+        });
+        dialog.show();
+    }
+
+    @OnClick(R.id.contact_none)
+    public void clickContactNone(){
+        mContact = "";
+        mTVContact.setText("沒做");
+    }
+
+    @OnClick(R.id.work)
+    public void clickWork(){
+        Dialog dialog = getTimeDialog(new TimePickerDialog.OnTimeSetListener() {
+            @Override
+            public void onTimeSet(TimePicker timePicker, int hour, int min) {
+                mWork = hour + ":" + min;
+                mTVWork.setText(mWork);
+            }
+        });
+        dialog.show();
+    }
+
+    @OnClick(R.id.work_none)
+    public void clickWorkNone(){
+        mWork = "";
+        mTVWork.setText("沒做");
+    }
+
+    @OnClick(R.id.dinner)
+    public void clickDinner(){
+        Dialog dialog = getTimeDialog(new TimePickerDialog.OnTimeSetListener() {
+            @Override
+            public void onTimeSet(TimePicker timePicker, int hour, int min) {
+                mDinner = hour + ":" + min;
+                mTVDinner.setText(mDinner);
+            }
+        });
+        dialog.show();
+    }
+
+    @OnClick(R.id.dinner_none)
+    public void clickDinnerNone(){
+        mDinner = "";
+        mTVDinner.setText("沒做");
+    }
+
+    @OnClick(R.id.sleep)
+    public void clickSleep(){
+        Dialog dialog = getTimeDialog(new TimePickerDialog.OnTimeSetListener() {
+            @Override
+            public void onTimeSet(TimePicker timePicker, int hour, int min) {
+                mSleep = hour + ":" + min;
+                mTVSleep.setText(mSleep);
+            }
+        });
+        dialog.show();
+    }
+
+    @OnClick(R.id.sleep_none)
+    public void clickSleepNone(){
+        mSleep = "";
+        mTVSleep.setText("沒做");
+    }
+
+    @OnClick(R.id.save)
+    public void save(){
+        if (LoginController.getInstance().isCurrentUserAdmin()){
+            Toast.makeText(ScaleActivity.this, "提交量表成功", Toast.LENGTH_LONG).show();
+            finish();
+            return;
+        }
+
+        Dialog dialog = new ProgressDialog(this);
+        dialog.setTitle("正在提交量表");
+        dialog.show();
+
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
+        Calendar calendar = Calendar.getInstance();
+        String endDate = simpleDateFormat.format(calendar.getTime());
+        calendar.setTime(new Date(mCurrentDate));
+        String startDate = simpleDateFormat.format(calendar.getTime());
+        new SimpleRequest<>().request(this, GameController.getInstance().addScale(
+                    mPlayGameId, startDate, endDate, mEventDate, mContact, mDinner, mGetUp, mSleep, mWork
+            ), "提交量表失敗!請檢查網絡狀態", dialog, new SimpleRequest.Executor<Object>() {
+                @Override
+                public void execute(Object obj) {
+                    EventBus.getDefault().post(new EventMessage());
+                    Toast.makeText(ScaleActivity.this, "提交量表成功", Toast.LENGTH_LONG).show();
+                    finish();
+                }
+            });
+    }
+
+    private Dialog getTimeDialog(TimePickerDialog.OnTimeSetListener listener){
+        return new TimePickerDialog(this, listener, 0, 0, true);
+    }
+
+    public static void LAUNCH(Activity context, long playGameId, String eventDate){
+        Intent intent = new Intent(context, ScaleActivity.class);
+        intent.putExtra(PARAM_PLAY_GAME_ID, playGameId);
+        intent.putExtra(PARAM_EVENT_DATE, eventDate);
+        context.startActivity(intent);
+    }
 }

+ 4 - 0
app/src/main/java/com/jyc/threegames/bean/EventMessage.java

@@ -0,0 +1,4 @@
+package com.jyc.threegames.bean;
+
+public class EventMessage {
+}

+ 8 - 0
app/src/main/java/com/jyc/threegames/bean/result/ResGamePlayTime.java

@@ -0,0 +1,8 @@
+package com.jyc.threegames.bean.result;
+
+public class ResGamePlayTime {
+    public long id;
+    public long uid;
+    public String gameTime;
+    public int type;
+}

+ 28 - 1
app/src/main/java/com/jyc/threegames/controller/GameController.java

@@ -6,6 +6,7 @@ import com.jyc.threegames.bean.ControllerMessage;
 import com.jyc.threegames.bean.GameAnswer;
 import com.jyc.threegames.bean.GameInfo;
 import com.jyc.threegames.bean.result.ResGameInfo;
+import com.jyc.threegames.bean.result.ResGamePlayTime;
 import com.jyc.threegames.net.ResData;
 import com.jyc.threegames.net.RetrofitHelper;
 import com.jyc.threegames.net.api.GameService;
@@ -18,6 +19,7 @@ import java.util.List;
 import java.util.Locale;
 
 import io.reactivex.Observable;
+import retrofit2.http.Field;
 
 public class GameController extends BaseController {
     private static GameController mInstance;
@@ -49,7 +51,32 @@ public class GameController extends BaseController {
 
     public Observable<ControllerMessage<ResGameInfo>> needPlayGame(){
         return getGameService().questNeedPlayGame()
-            .map(new SimpleDataHandleFunction<ResData<ResGameInfo>, ControllerMessage<ResGameInfo>>());
+            .map(new SimpleDataHandleFunction<>());
+    }
+
+    public Observable<ControllerMessage<List<ResGamePlayTime>>> listOverDate(){
+        return getGameService().listOverDate()
+            .map(new SimpleDataHandleFunction<>());
+    }
+
+    public Observable<ControllerMessage<Object>> addScale(
+        long gamePlayId,
+        String startDate,
+        String endDate,
+        String eventDate,
+        String contact,
+        String dinner,
+        String getUp,
+        String sleep,
+        String work
+    ){
+        return getGameService().addScale(gamePlayId, startDate, endDate, eventDate, contact, dinner, getUp, sleep, work)
+            .map(new SimpleDataHandleFunction<>());
+    }
+
+    public Observable<ControllerMessage<Object>> delayScale(long gamePlayTimeId, int delayMin){
+        return getGameService().delayScale(gamePlayTimeId, delayMin)
+            .map(new SimpleDataHandleFunction<>());
     }
 
     public Observable<ControllerMessage<Object>> delayGame(long gamePlayTimeId, long gameConfigId, int delayMin){

+ 27 - 1
app/src/main/java/com/jyc/threegames/net/api/GameService.java

@@ -1,8 +1,11 @@
 package com.jyc.threegames.net.api;
 
 import com.jyc.threegames.bean.result.ResGameInfo;
+import com.jyc.threegames.bean.result.ResGamePlayTime;
 import com.jyc.threegames.net.ResData;
 
+import java.util.List;
+
 import io.reactivex.Observable;
 import retrofit2.http.Field;
 import retrofit2.http.FormUrlEncoded;
@@ -13,8 +16,26 @@ public interface GameService {
     @GET("push/log/needPlayGame")
     Observable<ResData<ResGameInfo>> questNeedPlayGame();
 
+    @GET("scale/log/list/over_date")
+    Observable<ResData<List<ResGamePlayTime>>> listOverDate();
+
+    @FormUrlEncoded
+    @POST("scale/log/add/new")
+    Observable<ResData<Object>> addScale(
+        @Field("gamePlayId") long gamePlayId,
+        @Field("startDate") String startDate,
+        @Field("endDate") String endDate,
+        @Field("eventDate") String eventDate,
+        @Field("contact") String contact,
+        @Field("dinner") String dinner,
+        @Field("getUp") String getUp,
+        @Field("sleep") String sleep,
+        @Field("work") String work
+    );
+
+
     @FormUrlEncoded
-    @POST("/game/answer/add/real")
+    @POST("game/answer/add/real")
     Observable<ResData<Object>> addGameAnswer(
             @Field("gamePlayId") long gamePlayId,
             @Field("userId") long userId,
@@ -30,4 +51,9 @@ public interface GameService {
     @FormUrlEncoded
     @POST("push/log/delay/game")
     Observable<ResData<Object>> delayGame(@Field("gamePlayTimeId") long gamePlayId, @Field("gameConfigId") long gameConfigId, @Field("delayMin") int delayMin);
+
+
+    @FormUrlEncoded
+    @POST("push/log/delay/scale")
+    Observable<ResData<Object>> delayScale(@Field("gamePlayTimeId") long gamePlayId, @Field("delayMin") int delayMin);
 }

+ 37 - 0
app/src/main/res/layout/activity_input_param.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".activity.InputParamActivity">
+    <androidx.appcompat.widget.Toolbar
+        android:id="@+id/toolbar"
+        android:layout_width="0dp"
+        android:fitsSystemWindows="true"
+        android:layout_height="wrap_content"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        android:background="@color/colorAccent"
+        android:minHeight="?attr/actionBarSize" >
+        <TextView
+            android:id="@+id/title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center"
+            android:textSize="20sp"
+            android:textStyle="bold"/>
+
+        <TextView
+            android:id="@+id/go_game"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="end"
+            android:textSize="14sp"
+            android:text="保存"
+            android:layout_marginEnd="10dp"
+            android:textStyle="bold"/>
+    </androidx.appcompat.widget.Toolbar>
+    
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 23 - 0
app/src/main/res/layout/activity_normal_user.xml

@@ -35,4 +35,27 @@
             android:textStyle="bold"/>
     </androidx.appcompat.widget.Toolbar>
 
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:id="@+id/view_list_title"
+        android:text="逾期量表"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/toolbar"/>
+
+    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        android:id="@+id/swipe"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/view_list_title"
+        app:layout_constraintBottom_toBottomOf="parent">
+        <ListView
+            android:id="@+id/list"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent" />
+    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
+
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 200 - 0
app/src/main/res/layout/activity_scale.xml

@@ -6,4 +6,204 @@
     android:layout_height="match_parent"
     tools:context=".activity.ScaleActivity">
 
+    <androidx.appcompat.widget.Toolbar
+        android:id="@+id/toolbar"
+        android:layout_width="0dp"
+        android:fitsSystemWindows="true"
+        android:layout_height="wrap_content"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        android:background="@color/colorAccent"
+        android:minHeight="?attr/actionBarSize" >
+        <TextView
+            android:id="@+id/title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center"
+            android:textSize="20sp"
+            android:textStyle="bold"/>
+
+        <TextView
+            android:id="@+id/save"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="end"
+            android:textSize="14sp"
+            android:text="保存"
+            android:layout_marginEnd="10dp"
+            android:textStyle="bold"/>
+    </androidx.appcompat.widget.Toolbar>
+
+    <ScrollView
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/toolbar">
+        <androidx.constraintlayout.widget.ConstraintLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+            <TextView
+                android:id="@+id/view_title_get_up"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:text="下床:"
+                android:textColor="#000"
+                android:textStyle="bold"
+                app:layout_constraintTop_toTopOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintEnd_toStartOf="@id/get_up_none"
+                android:layout_marginTop="10dp"
+                android:textSize="24sp"
+                android:layout_marginStart="10dp"/>
+            <TextView
+                android:id="@+id/get_up"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                app:layout_constraintStart_toStartOf="@id/view_title_get_up"
+                app:layout_constraintTop_toBottomOf="@id/view_title_get_up"
+                android:textSize="24sp"
+                android:text="請選擇時間"/>
+            <Button
+                android:id="@+id/get_up_none"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="沒做"
+                android:layout_marginEnd="10dp"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintTop_toTopOf="@id/view_title_get_up"
+                app:layout_constraintBottom_toBottomOf="@id/get_up"/>
+
+
+            <TextView
+                android:id="@+id/view_title_contact"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:text="第一次與人接觸(見面或電話):"
+                android:textColor="#000"
+                android:textStyle="bold"
+                app:layout_constraintTop_toBottomOf="@id/get_up"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintEnd_toStartOf="@id/contact_none"
+                android:layout_marginTop="10dp"
+                android:textSize="24sp"
+                android:layout_marginStart="10dp"/>
+            <TextView
+                android:id="@+id/contact"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                app:layout_constraintStart_toStartOf="@id/view_title_contact"
+                app:layout_constraintTop_toBottomOf="@id/view_title_contact"
+                android:textSize="24sp"
+                android:text="請選擇時間"/>
+            <Button
+                android:id="@+id/contact_none"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="沒做"
+                android:layout_marginEnd="10dp"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintTop_toTopOf="@id/view_title_contact"
+                app:layout_constraintBottom_toBottomOf="@id/contact"/>
+
+
+            <TextView
+                android:id="@+id/view_title_work"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:text="開始工作,上學,家務,義工活動,照顧家庭或小孩:"
+                android:textColor="#000"
+                android:textStyle="bold"
+                app:layout_constraintTop_toBottomOf="@id/contact"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintEnd_toStartOf="@id/work_none"
+                android:layout_marginTop="10dp"
+                android:textSize="24sp"
+                android:layout_marginStart="10dp"/>
+            <TextView
+                android:id="@+id/work"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                app:layout_constraintStart_toStartOf="@id/view_title_work"
+                app:layout_constraintTop_toBottomOf="@id/view_title_work"
+                android:textSize="24sp"
+                android:text="請選擇時間"/>
+            <Button
+                android:id="@+id/work_none"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="沒做"
+                android:layout_marginEnd="10dp"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintTop_toTopOf="@id/view_title_work"
+                app:layout_constraintBottom_toBottomOf="@id/work"/>
+
+
+            <TextView
+                android:id="@+id/view_title_dinner"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:text="吃晚餐:"
+                android:textColor="#000"
+                android:textStyle="bold"
+                app:layout_constraintTop_toBottomOf="@id/work"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintEnd_toStartOf="@id/dinner_none"
+                android:layout_marginTop="10dp"
+                android:textSize="24sp"
+                android:layout_marginStart="10dp"/>
+            <TextView
+                android:id="@+id/dinner"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                app:layout_constraintStart_toStartOf="@id/view_title_dinner"
+                app:layout_constraintTop_toBottomOf="@id/view_title_dinner"
+                android:textSize="24sp"
+                android:text="請選擇時間"/>
+            <Button
+                android:id="@+id/dinner_none"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="沒做"
+                android:layout_marginEnd="10dp"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintTop_toTopOf="@id/view_title_dinner"
+                app:layout_constraintBottom_toBottomOf="@id/dinner"/>
+
+
+            <TextView
+                android:id="@+id/view_title_sleep"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:text="睡覺:"
+                android:textColor="#000"
+                android:textStyle="bold"
+                app:layout_constraintTop_toBottomOf="@id/dinner"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintEnd_toStartOf="@id/sleep_none"
+                android:layout_marginTop="10dp"
+                android:textSize="24sp"
+                android:layout_marginStart="10dp"/>
+            <TextView
+                android:id="@+id/sleep"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                app:layout_constraintStart_toStartOf="@id/view_title_sleep"
+                app:layout_constraintTop_toBottomOf="@id/view_title_sleep"
+                android:textSize="24sp"
+                android:text="請選擇時間"/>
+            <Button
+                android:id="@+id/sleep_none"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="沒做"
+                android:layout_marginEnd="10dp"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintTop_toTopOf="@id/view_title_sleep"
+                app:layout_constraintBottom_toBottomOf="@id/sleep"/>
+
+        </androidx.constraintlayout.widget.ConstraintLayout>
+    </ScrollView>
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 14 - 0
app/src/main/res/layout/item_scale.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+    <TextView
+        android:id="@+id/label"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        android:layout_margin="20dp"/>
+</androidx.constraintlayout.widget.ConstraintLayout>