安卓-学校图书馆签到fake图片

github上推不上去,就在这里发一些自己的做法啦。
做这个fake的原因就是,
1.图书馆阿姨看的紧
2.手机到图书馆前没有网
3.每星期违约3次不让进

其实就是4个页面,前3个页面可以理解为是过渡,给人一个假象。

核心部分在第4个页面,主要是4个TextView,分别是 左时间,右时间,日期,下时间。

左时间:就是当前时间的整点或者半点,比如当前15:23,那么左时间=15:00,如果当前时间是15:31,那么左时间=15:30;

右时间:左时间+4,最晚是21:30(因为图书馆21:30闭关,所以做这个系统的人,应该设置了最晚的时间)

日期:就是当前日期(这个一定不能马虎,阿姨检查核心就是看你日期对不对,所以这个必须没得问题)

下时间:就是当前时间,小时+分钟。

(一定要注意时间的格式!比如当早上9点时,不能是9:00,应该是09:00).


基本就是这么多了。

核心代码我贴到下面。

package com.example.myapp;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import org.w3c.dom.Text;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;


public class FourthActivity extends AppCompatActivity {
    //定义对象
    TextView textView_left;
    TextView textView_right;
    TextView textView_bottom;
    TextView textView_date;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //去掉顶部标题
        getSupportActionBar().hide();
        setContentView(R.layout.activity_fourth);

        //把定义的对象和控件关联到一起
        textView_left=findViewById(R.id.time_left);
        textView_right=findViewById(R.id.time_right);
        textView_bottom=findViewById(R.id.time_bottom);
        textView_date=findViewById(R.id.time_date);

        SimpleDateFormat formatter1 = new SimpleDateFormat("HH:mm");
        Date curDate1 = new Date(System.currentTimeMillis());
        String str1 = formatter1.format(curDate1);
        //将系统调用的时间显示到bottom中
        textView_bottom.setText(str1);

        //调用系统时间-分钟
        SimpleDateFormat formatter2 = new SimpleDateFormat("mm");
        Date curDate2 = new Date(System.currentTimeMillis());
        String str2 = formatter2.format(curDate2);
        int minute = 0;
        minute = Integer.parseInt(str2);


        //调用系统时间-小时
        SimpleDateFormat formatter3 = new SimpleDateFormat("HH");
        Date curDate3 = new Date(System.currentTimeMillis());
        String str3 = formatter3.format(curDate3);
        int hour = 0;
        hour = Integer.parseInt(str3);

        /*
         *   left和right时间的确定
         * 1.先判断left时间是多少,取整点或者半点,可以"余",放到left
         *
         * 2.判断left是否在7:00-17:30
         *           如果在,right=left+4
         *           如果晚于17:30,right=21:30
         *
         * */

        if( minute >= 0 && minute < 30){
            minute = 0;
            if(hour < 10){
                textView_left.setText("0"+hour+":00");
                textView_right.setText(4+hour+":00");
            }
            else if (hour > 10 && hour <=17){
                textView_left.setText(hour+":00");
                textView_right.setText(4+hour+":00");
            }
            else if (hour >17){
                textView_left.setText(hour+":00");
                textView_right.setText("21:30");
            }
        }
        else{
            minute = 30;
            if(hour < 10 ){
                textView_left.setText("0"+hour+":30");
                textView_right.setText(4+hour+":30");
            }
            else if (hour >10 &&hour <= 17){
                textView_left.setText(hour+":30");
                textView_right.setText(4+hour+":30");
            }
            else if(hour >=17){
                textView_left.setText(hour+":30");
                textView_right.setText("21:30");
            }
        }


        String mMonth;
        String mDay;
        int Month;
        int Day;
        Calendar calendar = Calendar.getInstance();
        mMonth = String.valueOf(calendar.get(Calendar.MONTH) + 1);        //获取日期的月
        mDay = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH));      //获取日期的天

        Month = Integer.parseInt(mMonth);
        Day = Integer.parseInt(mDay);

        if(Month < 10){
            if(Day < 10){
                textView_date.setText("2021-0"+Month+"-0"+Day);
            }
            else {
                textView_date.setText("2021-0"+Month+"-"+Day);
            }
        }
        else {
            if(Day < 10){
                textView_date.setText("2021-"+Month+"-0"+Day);
            }
            else {
                textView_date.setText("2021-"+Month+"-"+Day);
            }
        }




    }
}

 

再贴一张背景图片。

算了,有名字。
声明:没有任何的违反违纪的想法,如果有不妥,请第一时间联系我,马上道歉认错。

 

posted @ 2021-04-27 00:47  沉梦昂志_doc  阅读(123)  评论(0编辑  收藏  举报