添加CalendarView模块同时添加实体类CalendarDay及其相关类

pull/9/head
harvey 4 years ago
parent ee240c206c
commit 0a17871cf8

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="CompilerConfiguration"> <component name="CompilerConfiguration">
<bytecodeTargetLevel target="16" /> <bytecodeTargetLevel target="11" />
</component> </component>
</project> </project>

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
@ -10,11 +11,11 @@
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/CalendarView" />
<option value="$PROJECT_DIR$/app" /> <option value="$PROJECT_DIR$/app" />
</set> </set>
</option> </option>
<option name="resolveModulePerSourceSet" value="false" /> <option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings> </GradleProjectSettings>
</option> </option>
</component> </component>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_14" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

@ -0,0 +1,10 @@
<?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.3.0'
implementation 'com.google.android.material:material:1.3.0'
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.idealist.calendarview;
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.idealist.calendarview.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.idealist.calendarview">
</manifest>

@ -0,0 +1,86 @@
package com.idealist.calendarview;
public class CalendarAttr {
static int RecTop;
private int mItemHeight;
private int mRowCount;
private int mViewHeight;
private int mCalendarType;
private int mTextSize;
private int mScrollLevel;
private int TouchSlop;
public CalendarAttr() {
mItemHeight = State.DEFAULT_ITEM_HEIGHT;
mTextSize = State.DEFAULT_TEXT_SIZE;
}
public int getRowCount() {
return mRowCount;
}
private void setRowCount(int mRowCount) {
this.mRowCount = mRowCount;
mViewHeight = mItemHeight * mRowCount;
}
public int getItemHeight() {
return mItemHeight;
}
public void setItemHeight(int mItemHeight) {
this.mItemHeight = mItemHeight;
mViewHeight = mRowCount * mItemHeight;
}
public int getViewHeight() {
return mViewHeight;
}
public void setViewHeight(int mViewHeight) {
this.mViewHeight = mViewHeight;
mItemHeight = mViewHeight / mRowCount;
}
public int getTextSize() {
return mTextSize;
}
public void setTextSize(int mTextSize) {
this.mTextSize = mTextSize;
}
public int getCalendarType() {
return mCalendarType;
}
public void setCalendarType(int mCalendarType) {
this.mCalendarType = mCalendarType;
setRowCount((mCalendarType == State.VIEW_WEEK) ? 1 : 6);
}
public static int getRecTop() {
return RecTop;
}
public static void setRecTop(int recTop) {
RecTop = recTop;
}
public int getScrollLevel() {
return mScrollLevel;
}
public void setScrollLevel(int mScrollLevel) {
this.mScrollLevel = mScrollLevel;
}
}

@ -0,0 +1,97 @@
package com.idealist.calendarview;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public class CalendarDay {
private int year;
private int month;
private int day;
private boolean isCurrDay;
private boolean markSchedule;
private int mMonthState;
private int mSelectState;
public CalendarDay() {
;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
public int getDay() {
return day;
}
public void setDay(int day) {
this.day = day;
}
public boolean isCurrDay() {
return isCurrDay;
}
public void setCurrDay(boolean currDay) {
this.isCurrDay = currDay;
}
public int getMonthState() {
return mMonthState;
}
public void setMonthState(int mMonthState) {
this.mMonthState = mMonthState;
}
public int getSelectState() {
return mSelectState;
}
public void setSelectState(int mSelectState) {
this.mSelectState = mSelectState;
}
public boolean isMarkSchedule() {
return markSchedule;
}
public void setMarkSchedule(boolean markSchedule) {
this.markSchedule = markSchedule;
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof CalendarDay) {
return ((CalendarDay) obj).day == this.day && ((CalendarDay) obj).month == this.month &&
((CalendarDay) obj).year == this.year;
}
return super.equals(obj);
}
@NonNull
@Override
public String toString() {
return this.year + "-" + this.month + "-" + this.day;
}
}

@ -0,0 +1,36 @@
package com.idealist.calendarview;
public final class State {
public static final int DAY_UN_SELECT = 0;
public static final int DAY_SELECT = 1;
public static final int DAY_CURR_MONTH = 0;
public static final int DAY_PAST_MONTH = -1;
public static final int DAY_NEXT_MONTH = 1;
public static final int VIEW_WEEK = 1;
public static final int VIEW_MONTH = 2;
public static final int VIEW_FULL = 3;
public static final int LEVEL_TOP = 1;
public static final int LEVEL_MEDIUM = 2;
public static final int LEVEL_BOTTOM = 3;
public static final int DEFAULT_ITEM_HEIGHT = 180;
public static final int DEFAULT_TEXT_SIZE = 80;
public static int DEFAULT_ITEM_HEIGHT_FULL;
public static void setDefaultItemHeightFull(int defaultItemHeightFull) {
DEFAULT_ITEM_HEIGHT_FULL = defaultItemHeightFull;
}
}

@ -0,0 +1,17 @@
package com.idealist.calendarview;
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,2 +1,3 @@
include ':app' include ':app'
rootProject.name = "My Application" rootProject.name = "My Application"
include ':CalendarView'

Loading…
Cancel
Save