commit
982d3d18e7
@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="RunConfigurationProducerService">
|
|
||||||
<option name="ignoredProducers">
|
|
||||||
<set>
|
|
||||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -0,0 +1 @@
|
|||||||
|
/build
|
@ -0,0 +1,38 @@
|
|||||||
|
plugins {
|
||||||
|
id 'com.android.library'
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 30
|
||||||
|
buildToolsVersion "30.0.3"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion 29
|
||||||
|
targetSdkVersion 30
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
consumerProguardFiles "consumer-rules.pro"
|
||||||
|
}
|
||||||
|
|
||||||
|
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 'androidx.appcompat:appcompat:1.2.0'
|
||||||
|
implementation 'com.google.android.material:material:1.2.1'
|
||||||
|
testImplementation 'junit:junit:4.+'
|
||||||
|
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||||
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||||
|
}
|
@ -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
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.showme.database;
|
||||||
|
|
||||||
|
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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
public void useAppContext() {
|
||||||
|
// Context of the app under test.
|
||||||
|
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
|
assertEquals("com.showme.database.test", appContext.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.showme.database">
|
||||||
|
|
||||||
|
</manifest>
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.showme.database.DatabaseHelper;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
public class CourseSQLHelper extends SQLiteOpenHelper {
|
||||||
|
private static final String db_name = "course";//自定义的数据库名;
|
||||||
|
private static final int version = 2;//版本号
|
||||||
|
|
||||||
|
public CourseSQLHelper(Context context) {
|
||||||
|
super(context, db_name, null, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(SQLiteDatabase db) {
|
||||||
|
db.execSQL("create table courses(" +
|
||||||
|
"id integer primary key autoincrement," +
|
||||||
|
"course_name text," +
|
||||||
|
"teacher text," +
|
||||||
|
"class_room text," +
|
||||||
|
"day integer," +
|
||||||
|
"class_start integer," +
|
||||||
|
"class_end integer," +
|
||||||
|
"weeks text)");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
db.execSQL("drop table if exists schedules");
|
||||||
|
onCreate(db);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.showme.database;
|
||||||
|
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
|
public class MySQLiteDatabase {
|
||||||
|
public static SQLiteDatabase scheduleSQL;
|
||||||
|
|
||||||
|
public static SQLiteDatabase courseSQL;
|
||||||
|
|
||||||
|
public static SQLiteDatabase zoneSQL;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.showme.database.utils;
|
||||||
|
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
|
import com.showme.database.MySQLiteDatabase;
|
||||||
|
|
||||||
|
public class CourseSQLUtils {
|
||||||
|
private static SQLiteDatabase courseSQL = MySQLiteDatabase.courseSQL;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
package com.showme.database.utils;
|
||||||
|
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
|
import com.showme.database.MySQLiteDatabase;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ScheduleSQLUtils {
|
||||||
|
private static SQLiteDatabase database = MySQLiteDatabase.scheduleSQL;
|
||||||
|
|
||||||
|
public static List<String> queryByDate(String date) {
|
||||||
|
//columns为null 查询所有列
|
||||||
|
List<String> res = new ArrayList<>();
|
||||||
|
String aScheduleName;
|
||||||
|
Cursor cursor = database.query("schedules",null,"time=?",new String[]{date},null,null,null);
|
||||||
|
if(cursor.moveToFirst()){
|
||||||
|
int scheduleCount = 0;
|
||||||
|
do{
|
||||||
|
aScheduleName = cursor.getString(cursor.getColumnIndex("scheduleName"));
|
||||||
|
String aStartTime = cursor.getString(cursor.getColumnIndex("startTime"));
|
||||||
|
Integer ifStartTime = cursor.getInt(cursor.getColumnIndex("ifStartTime"));
|
||||||
|
String aEndTime = cursor.getString(cursor.getColumnIndex("endTime"));
|
||||||
|
Integer ifEndTime = cursor.getInt(cursor.getColumnIndex("ifEndTime"));
|
||||||
|
String scheduleText = aScheduleName;
|
||||||
|
|
||||||
|
if(ifStartTime == 1){
|
||||||
|
scheduleText += "($时间:"+aStartTime;
|
||||||
|
|
||||||
|
if(ifEndTime ==1){
|
||||||
|
scheduleText += "\n"+aEndTime;
|
||||||
|
} else {
|
||||||
|
scheduleText += "\n24:00";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
scheduleText += "($时间: 00:00\n24:00";
|
||||||
|
}
|
||||||
|
|
||||||
|
scheduleCount++;
|
||||||
|
res.add(scheduleText);
|
||||||
|
}while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String extractScheduleName(String scheduleText) {
|
||||||
|
int index = scheduleText.indexOf("($时间:");
|
||||||
|
if (index != -1) {
|
||||||
|
return scheduleText.substring(0, index);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String extractScheduleTime(String scheduleText) {
|
||||||
|
int index = scheduleText.indexOf("($时间:");
|
||||||
|
if (index != -1) {
|
||||||
|
return scheduleText.substring(index+5);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isScheduleMarked(String date) {
|
||||||
|
Cursor cursor = database.query("schedules",null,"time=?",new String[]{date},null,null,null);
|
||||||
|
return cursor.moveToFirst();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.showme.database;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
public class ExampleUnitTest {
|
||||||
|
@Test
|
||||||
|
public void addition_isCorrect() {
|
||||||
|
assertEquals(4, 2 + 2);
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
include ':DataBase'
|
||||||
include ':app'
|
include ':app'
|
||||||
rootProject.name = "My Application"
|
rootProject.name = "My Application"
|
||||||
include ':CalendarView'
|
include ':CalendarView'
|
||||||
|
Loading…
Reference in new issue