【首发】开发了一款多彩校园简易版App(功能可用)

起因:原版多彩校园app阻挡了我打热水的速度,还有广告,这怎么能忍?

主要作用:方便快速使用,并且无广告,速度可以说提升了好几倍。

代码

登录界面xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".LoginActivity"
    android:orientation="vertical"
    android:gravity="center"
    android:background="@color/white">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="多彩校园"
        android:textStyle="bold"
        android:textSize="30sp"
        android:textColor="#7379c2"
        android:layout_marginBottom="10dp"/>

    <LinearLayout
        android:layout_margin="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <EditText
            android:id="@+id/login_phone_et"
            android:layout_width="match_parent"
            android:layout_marginBottom="30dp"
            android:layout_height="50dp"
            android:hint="请输入手机号"
            android:inputType="number"
            android:background="@drawable/edite_background"
            android:padding="10dp"
            tools:ignore="TextFields" />

        <EditText
            android:id="@+id/login_pwd_et"
            android:layout_width="match_parent"
            android:layout_marginBottom="30dp"
            android:layout_height="50dp"
            android:inputType="textPassword"
            android:hint="请输入密码"
            android:background="@drawable/edite_background"
            android:padding="10dp"/>

        <Button
            android:id="@+id/login_btn"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="登录"
            android:background="@drawable/login_btn_background"
            android:textStyle="bold"
            android:textColor="@color/white"
            android:textSize="18sp"
            android:padding="15dp"
            android:onClick="click"
            />
        <TextView
            android:id="@+id/login_rjsm"
            android:onClick="rjsm"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="软件说明"
            android:layout_gravity="right"
            android:textColor="@color/zhise"
            android:textSize="16sp"
            android:layout_marginTop="15dp"
            android:layout_marginRight="5dp"/>


    </LinearLayout>


</LinearLayout>

java代码:

package com.chance.duocaixiaoyuan;


import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.chance.duocaixiaoyuan.util.Account;
import com.chance.duocaixiaoyuan.util.LoadingDialog;

public class LoginActivity extends AppCompatActivity {
    private EditText phoneET;
    private EditText pwdET;
    //全局化
    private LoadingDialog dialog;
    // 本地存储
    public SharedPreferences preferences;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        preferences = getSharedPreferences("dcxy", Activity.MODE_PRIVATE);
        init();
    }

    public void init() {

        // 检查上一次是否登录成功,如果登录成功,直接跳转主界面,否则进行登录
        // 读取存储内容
        preferences = getSharedPreferences("dcxy", Activity.MODE_PRIVATE);
        String phone = "";
        if (preferences != null) {
            phone = preferences.getString("phone", "");
        }
        // 存储有数据进行主界面跳转
        if (!phone.equals("")) {
            Intent intent = new Intent();
            intent.setClass(LoginActivity.this, MainActivity.class);
            startActivity(intent);
            finish();
        }else {
            setStatusBar();
            setContentView(R.layout.activity_login);
            phoneET = findViewById(R.id.login_phone_et);
            pwdET = findViewById(R.id.login_pwd_et);
        }
    }


    /* 显示加载对话框 */
    private void loadingDialog() {
        dialog = new LoadingDialog(this);
        dialog.show();
    }

    protected void setStatusBar() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            getWindow().setStatusBarColor(getResources().getColor(R.color.white));//设置状态栏颜色
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);//实现状态栏图标和文字颜色为暗色
        }
    }

    public void click(View view) {
        // 显示加载界面
        loadingDialog();
        new Thread(new Runnable() {
            boolean flag = false;
            @Override
            public void run() {
                try {
                    flag = Account.doLogin(phoneET.getText().toString(), pwdET.getText().toString(), LoginActivity.this);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        // 取消加载界面
                        dialog.dismiss();
                        if(flag) {
                            // 跳转到主界面
                            Intent intent = new Intent();
                            intent.setClass(LoginActivity.this, MainActivity.class);
                            startActivity(intent);
                        }else {
                            Toast.makeText(LoginActivity.this, Account.msg, Toast.LENGTH_LONG).show();
                        }
                    }
                });
            }
        }).start();
    }

    public void rjsm(View view) {
        Intent intent = new Intent();
        intent.setClass(this, InstructionsActivity.class);
        startActivity(intent);
    }


}

​​​​​​​



开源地址:https://gitee.com/JieKuiChance/DuoCaiXiaoYuanFastApp
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值