将创建签到部分的时间选择,设置成了24小时制

master
呗 呗 3 years ago
parent 81ba7cb270
commit fc12817d5b

@ -86,7 +86,6 @@ public class CheckCourseSign extends AppCompatActivity {
initPage(); initPage();
} }
private void initView(){ private void initView(){
CommonUtils.changeStatusBar(CheckCourseSign.this); CommonUtils.changeStatusBar(CheckCourseSign.this);
@ -117,16 +116,13 @@ public class CheckCourseSign extends AppCompatActivity {
}); });
getCourseSignMsg(); getCourseSignMsg();
shareImageHandler = new Handler(new Handler.Callback() { shareImageHandler = new Handler(msg -> {
@Override if(msg.arg1 == 200){
public boolean handleMessage(@NonNull Message msg) { Intent shareIntent = (Intent) msg.obj;
if(msg.arg1 == 200){ System.out.println("Here...............shareImageHandler.....");
Intent shareIntent = (Intent) msg.obj; startActivity(Intent.createChooser(shareIntent, "分享图片"));
System.out.println("Here...............shareImageHandler.....");
startActivity(Intent.createChooser(shareIntent, "分享图片"));
}
return false;
} }
return false;
}); });
// 意图函数加载器 // 意图函数加载器
@ -174,13 +170,11 @@ public class CheckCourseSign extends AppCompatActivity {
ivCode.setVisibility(View.VISIBLE); ivCode.setVisibility(View.VISIBLE);
}); });
ivCodeBig.setOnLongClickListener(v12 -> { ivCodeBig.setOnLongClickListener(v12 -> {
Toast.makeText(CheckCourseSign.this, "长按", Toast.LENGTH_SHORT).show();
shareImage(); shareImage();
return true; return true;
}); });
}); });
ivCode.setOnLongClickListener(v -> { ivCode.setOnLongClickListener(v -> {
Toast.makeText(CheckCourseSign.this, "长按", Toast.LENGTH_SHORT).show();
shareImage(); shareImage();
return true; return true;
}); });

@ -2,6 +2,7 @@ package com.example.stlink.activitys.fragmentChild.activityTeaHome;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
@ -15,6 +16,7 @@ import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts; import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatButton; import androidx.appcompat.widget.AppCompatButton;
@ -33,6 +35,8 @@ import com.google.android.material.timepicker.MaterialTimePicker;
import com.google.android.material.timepicker.TimeFormat; import com.google.android.material.timepicker.TimeFormat;
import java.text.ParseException; import java.text.ParseException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Objects; import java.util.Objects;
public class CreateSign extends AppCompatActivity { public class CreateSign extends AppCompatActivity {
@ -109,7 +113,7 @@ public class CreateSign extends AppCompatActivity {
Long curTimeStamp = System.currentTimeMillis(); Long curTimeStamp = System.currentTimeMillis();
String currTime = CommonUtils.stampToDate(String.valueOf(curTimeStamp), "yyyy-MM-dd-hh-mm-ss"); String currTime = CommonUtils.stampToDate(String.valueOf(curTimeStamp), "yyyy-MM-dd-HH-mm-ss");
String[] timeStrs = currTime.split("-"); String[] timeStrs = currTime.split("-");
currYear = Integer.parseInt(timeStrs[0]); currYear = Integer.parseInt(timeStrs[0]);
currMonth = Integer.parseInt(timeStrs[1]); currMonth = Integer.parseInt(timeStrs[1]);
@ -119,7 +123,7 @@ public class CreateSign extends AppCompatActivity {
currSecond = Integer.parseInt(timeStrs[5]); currSecond = Integer.parseInt(timeStrs[5]);
startTimePicker = new MaterialTimePicker.Builder() startTimePicker = new MaterialTimePicker.Builder()
.setTimeFormat(TimeFormat.CLOCK_12H) .setTimeFormat(TimeFormat.CLOCK_24H)
.setHour(currHour) .setHour(currHour)
.setMinute(currMin) .setMinute(currMin)
.setTitleText("开始时间选择") .setTitleText("开始时间选择")
@ -127,7 +131,7 @@ public class CreateSign extends AppCompatActivity {
.setNegativeButtonText("取消") .setNegativeButtonText("取消")
.build(); .build();
endTimePicker = new MaterialTimePicker.Builder() endTimePicker = new MaterialTimePicker.Builder()
.setTimeFormat(TimeFormat.CLOCK_12H) .setTimeFormat(TimeFormat.CLOCK_24H)
.setHour(currHour) .setHour(currHour)
.setMinute(currMin) .setMinute(currMin)
.setTitleText("结束时间选择") .setTitleText("结束时间选择")
@ -190,7 +194,7 @@ public class CreateSign extends AppCompatActivity {
startHour + ":" + startHour + ":" +
startMin + ":" + "00"; startMin + ":" + "00";
try { try {
startTimeStamp = Long.parseLong(CommonUtils.dateToStamp(startTime, "yyyy-MM-dd hh:mm:ss")); startTimeStamp = Long.parseLong(CommonUtils.dateToStamp(startTime, "yyyy-MM-dd HH:mm:ss"));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -208,7 +212,7 @@ public class CreateSign extends AppCompatActivity {
endHour + ":" + endHour + ":" +
endMin + ":" + "00"; endMin + ":" + "00";
try { try {
endTimeStamp = Long.parseLong(CommonUtils.dateToStamp(endTime, "yyyy-MM-dd hh:mm:ss")); endTimeStamp = Long.parseLong(CommonUtils.dateToStamp(endTime, "yyyy-MM-dd HH:mm:ss"));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }

@ -257,7 +257,7 @@ public class CommonUtils {
String res; String res;
@SuppressLint("SimpleDateFormat") @SuppressLint("SimpleDateFormat")
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(fprmat); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(fprmat);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8:00")); // simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
//如果它本来就是long类型的,则不用写这一步 //如果它本来就是long类型的,则不用写这一步
long lt = Long.parseLong(s); long lt = Long.parseLong(s);
Date date = new Date(lt); Date date = new Date(lt);

Loading…
Cancel
Save