forked from p28679143/ShowMe
Compare commits
22 Commits
Author | SHA1 | Date |
---|---|---|
|
cc25ac71aa | 4 years ago |
|
2f154bc36b | 4 years ago |
|
7e7d93e3f4 | 4 years ago |
|
2360930176 | 4 years ago |
|
7f5205804b | 4 years ago |
|
ee8f4f23a8 | 4 years ago |
|
e59024139d | 4 years ago |
|
c7e2ad4910 | 4 years ago |
|
519719336c | 4 years ago |
|
6a4f80f8e6 | 4 years ago |
|
ddf89e35da | 4 years ago |
|
5e7e4d69d1 | 4 years ago |
|
6e50be2883 | 4 years ago |
|
8bf0bd9b4a | 4 years ago |
|
561898494b | 4 years ago |
|
66797be1dc | 4 years ago |
|
bd2b879be3 | 4 years ago |
|
bb177f62a1 | 4 years ago |
|
f27fd32235 | 4 years ago |
|
1c5fa39d6b | 4 years ago |
|
7857e30487 | 4 years ago |
|
4d92e44671 | 4 years ago |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
@ -1 +0,0 @@
|
|||||||
My Application
|
|
@ -1,9 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<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" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectType">
|
|
||||||
<option name="id" value="Android" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
Binary file not shown.
@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
package="com.showme.myapplication">
|
|
||||||
|
|
||||||
<application
|
|
||||||
android:allowBackup="true"
|
|
||||||
android:icon="@mipmap/ic_launcher"
|
|
||||||
android:label="@string/app_name"
|
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
|
||||||
android:supportsRtl="true"
|
|
||||||
android:theme="@style/Theme.MyApplication">
|
|
||||||
<activity android:name=".MainActivity">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
</application>
|
|
||||||
|
|
||||||
</manifest>
|
|
@ -1,115 +0,0 @@
|
|||||||
package com.showme.myapplication;
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.idealist.calendarview.CalendarAttr;
|
|
||||||
import com.idealist.calendarview.CalendarDay;
|
|
||||||
import com.idealist.calendarview.CalendarPager;
|
|
||||||
import com.idealist.calendarview.CalendarUtils;
|
|
||||||
import com.idealist.calendarview.CalendarView;
|
|
||||||
import com.idealist.calendarview.CalendarViewAdapter;
|
|
||||||
import com.idealist.calendarview.State;
|
|
||||||
import com.idealist.calendarview.interf.OnSelectDateListener;
|
|
||||||
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
private TextView tvMonth;
|
|
||||||
private TextView tvYear;
|
|
||||||
|
|
||||||
private CalendarDay currentDay;
|
|
||||||
|
|
||||||
private CalendarView currentView;
|
|
||||||
|
|
||||||
private CalendarPager pager;
|
|
||||||
|
|
||||||
private CalendarViewAdapter viewAdapter;
|
|
||||||
|
|
||||||
private CalendarAttr attr;
|
|
||||||
|
|
||||||
private OnSelectDateListener onSelectDateListener;
|
|
||||||
|
|
||||||
private CalendarView.OnCalendarClickListener clickListener;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_main);
|
|
||||||
|
|
||||||
TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
|
|
||||||
DisplayMetrics dm = new DisplayMetrics();
|
|
||||||
getWindowManager().getDefaultDisplay().getRealMetrics(dm);
|
|
||||||
int height = dm.heightPixels;
|
|
||||||
State.setDefaultItemHeightFull((height - 42 - 3*State.DEFAULT_ITEM_HEIGHT) / 6);
|
|
||||||
|
|
||||||
initCalendar();
|
|
||||||
|
|
||||||
attr = new CalendarAttr();
|
|
||||||
attr.setCalendarType(State.VIEW_MONTH);
|
|
||||||
attr.setScrollLevel(State.LEVEL_MEDIUM);
|
|
||||||
|
|
||||||
initListener();
|
|
||||||
viewAdapter = new CalendarViewAdapter(this, attr, onSelectDateListener,
|
|
||||||
clickListener);
|
|
||||||
initPager();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initCalendar() {
|
|
||||||
tvMonth = findViewById(R.id.custom_month_view);
|
|
||||||
tvYear = findViewById(R.id.custom_year_view);
|
|
||||||
currentDay = CalendarUtils.getCurrDay();
|
|
||||||
updateCalendar();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initPager() {
|
|
||||||
pager = findViewById(R.id.custom_vp);
|
|
||||||
pager.setAttr(attr);
|
|
||||||
pager.setAdapter(viewAdapter);
|
|
||||||
|
|
||||||
pager.setmOnPageChangeListener(new CalendarPager.OnPageChangeListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageSelected(int position) {
|
|
||||||
currentView = viewAdapter.getViews().get(position % 3);
|
|
||||||
currentDay = currentView.getSeedDay();
|
|
||||||
updateCalendar();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageScrollStateChanged(int state) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initListener() {
|
|
||||||
onSelectDateListener = offset -> pager.selectOtherMonth(offset);
|
|
||||||
clickListener = new CalendarView.OnCalendarClickListener() {
|
|
||||||
@Override
|
|
||||||
public void OnClick(CalendarDay day) {
|
|
||||||
// updateSchedule(day);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void OnLongClick(CalendarDay day) {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
|
||||||
private void updateCalendar() {
|
|
||||||
tvMonth.setText(currentDay.getMonth() + "");
|
|
||||||
tvYear.setText(currentDay.getYear() + "");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<string name="app_name">My Application</string>
|
|
||||||
</resources>
|
|
@ -1,4 +0,0 @@
|
|||||||
include ':DataBase'
|
|
||||||
include ':app'
|
|
||||||
rootProject.name = "My Application"
|
|
||||||
include ':CalendarView'
|
|
@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="NullableNotNullManager">
|
||||||
|
<option name="myDefaultNullable" value="org.jetbrains.annotations.Nullable" />
|
||||||
|
<option name="myDefaultNotNull" value="androidx.annotation.NonNull" />
|
||||||
|
<option name="myNullables">
|
||||||
|
<value>
|
||||||
|
<list size="14">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||||
|
<item index="1" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||||
|
<item index="2" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||||
|
<item index="3" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
|
||||||
|
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
|
||||||
|
<item index="5" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
|
||||||
|
<item index="6" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||||
|
<item index="7" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||||
|
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
|
||||||
|
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
|
||||||
|
<item index="10" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
|
||||||
|
<item index="11" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.Nullable" />
|
||||||
|
<item index="12" class="java.lang.String" itemvalue="io.reactivex.annotations.Nullable" />
|
||||||
|
<item index="13" class="java.lang.String" itemvalue="io.reactivex.rxjava3.annotations.Nullable" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="myNotNulls">
|
||||||
|
<value>
|
||||||
|
<list size="13">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||||
|
<item index="1" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||||
|
<item index="2" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||||
|
<item index="3" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
|
||||||
|
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
|
||||||
|
<item index="5" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
|
||||||
|
<item index="6" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||||
|
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
|
||||||
|
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
|
||||||
|
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
|
||||||
|
<item index="10" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.NonNull" />
|
||||||
|
<item index="11" class="java.lang.String" itemvalue="io.reactivex.annotations.NonNull" />
|
||||||
|
<item index="12" class="java.lang.String" itemvalue="io.reactivex.rxjava3.annotations.NonNull" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<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" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -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,62 @@
|
|||||||
|
Index: app/src/main/java/com/diary/showme/diary/ui/CardActivity.java
|
||||||
|
IDEA additional info:
|
||||||
|
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
||||||
|
<+>package com.diary.showme.diary.ui;\r\n\r\nimport android.app.Activity;\r\nimport android.content.Intent;\r\nimport android.os.Bundle;\r\nimport android.view.View;\r\nimport android.widget.Button;\r\nimport android.content.Context;\r\nimport android.graphics.Color;\r\nimport android.os.Environment;\r\nimport android.widget.EditText;\r\nimport android.widget.Toast;\r\n\r\nimport androidx.annotation.Nullable;\r\nimport androidx.appcompat.app.AppCompatActivity;\r\n\r\nimport com.diary.showme.Course.AddCourseActivity;\r\nimport com.diary.showme.Course.Course;\r\nimport com.diary.showme.Course.CourseActivity;\r\nimport com.diary.showme.R;\r\n\r\n\r\npublic class CardActivity extends AppCompatActivity {\r\n\r\n private Button card1;\r\n\r\n private Button card2;\r\n\r\n private Button card3;\r\n\r\n @Override\r\n protected void onCreate(Bundle savedInstanceState) {\r\n super.onCreate(savedInstanceState);\r\n setContentView(R.layout.card);\r\n\r\n card1 = findViewById(R.id.card1);\r\n card2 = findViewById(R.id.card2);\r\n card3 = findViewById(R.id.card3);\r\n card1.setOnClickListener(new View.OnClickListener() {\r\n @Override\r\n public void onClick(View v) {\r\n startActivityForResult(new Intent(CardActivity.this, AddDiaryActivity.class), 0);\r\n }\r\n });\r\n card2.setOnClickListener(new View.OnClickListener() {\r\n @Override\r\n public void onClick(View v) {\r\n startActivityForResult(new Intent(CardActivity.this, AddDiaryActivity.class), 0);\r\n }\r\n });\r\n card3.setOnClickListener(new View.OnClickListener() {\r\n @Override\r\n public void onClick(View v) {\r\n startActivityForResult(new Intent(CardActivity.this, AddDiaryActivity.class), 0);\r\n }\r\n });\r\n }\r\n\r\n public static void startActivity(Context context) {\r\n Intent intent = new Intent(context, CardActivity.class);\r\n context.startActivity(intent);\r\n }\r\n\r\n\r\n}\r\n
|
||||||
|
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||||||
|
<+>UTF-8
|
||||||
|
===================================================================
|
||||||
|
--- app/src/main/java/com/diary/showme/diary/ui/CardActivity.java (revision c7e2ad49109864f6c4a19759f6af43db764bb204)
|
||||||
|
+++ app/src/main/java/com/diary/showme/diary/ui/CardActivity.java (date 1626049324133)
|
||||||
|
@@ -39,19 +39,22 @@
|
||||||
|
card1.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
- startActivityForResult(new Intent(CardActivity.this, AddDiaryActivity.class), 0);
|
||||||
|
+ Intent intent = new Intent(CardActivity.this, AddDiaryActivity.class);
|
||||||
|
+ startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
card2.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
- startActivityForResult(new Intent(CardActivity.this, AddDiaryActivity.class), 0);
|
||||||
|
+ Intent intent = new Intent(CardActivity.this, AddDiaryActivity.class);
|
||||||
|
+ startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
card3.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
- startActivityForResult(new Intent(CardActivity.this, AddDiaryActivity.class), 0);
|
||||||
|
+ Intent intent = new Intent(CardActivity.this, AddDiaryActivity.class);
|
||||||
|
+ startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Index: app/src/main/res/layout/question_item.xml
|
||||||
|
IDEA additional info:
|
||||||
|
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
||||||
|
<+><?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\r\n android:layout_width=\"match_parent\"\r\n android:layout_height=\"wrap_content\">\r\n\r\n <LinearLayout\r\n android:layout_width=\"match_parent\"\r\n android:layout_height=\"match_parent\"\r\n android:orientation=\"horizontal\">\r\n\r\n <TextView\r\n android:id=\"@+id/question_content\"\r\n android:layout_width=\"match_parent\"\r\n android:layout_height=\"wrap_content\"\r\n android:gravity=\"center\"\r\n android:textSize=\"24sp\"/>\r\n\r\n </LinearLayout>\r\n\r\n</FrameLayout>
|
||||||
|
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||||||
|
<+>UTF-8
|
||||||
|
===================================================================
|
||||||
|
--- app/src/main/res/layout/question_item.xml (revision c7e2ad49109864f6c4a19759f6af43db764bb204)
|
||||||
|
+++ app/src/main/res/layout/question_item.xml (date 1626048966859)
|
||||||
|
@@ -8,12 +8,14 @@
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
- <TextView
|
||||||
|
+ <Button
|
||||||
|
android:id="@+id/question_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
- android:gravity="center"
|
||||||
|
- android:textSize="24sp"/>
|
||||||
|
+ android:layout_weight="1"
|
||||||
|
+ android:background="#A4CF2626"
|
||||||
|
+ android:text="今天有遇到什么开心的事情吗?"
|
||||||
|
+ />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
@ -0,0 +1,4 @@
|
|||||||
|
<changelist name="Uncommitted_changes_before_Update_at_2021_7_12_8_40_[Default_Changelist]" date="1626050458233" recycled="true" deleted="true">
|
||||||
|
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_2021_7_12_8_40_[Default_Changelist]/shelved.patch" />
|
||||||
|
<option name="DESCRIPTION" value="Uncommitted changes before Update at 2021/7/12 8:40 [Default Changelist]" />
|
||||||
|
</changelist>
|
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -0,0 +1,14 @@
|
|||||||
|
<changelist name="Uncommitted_changes_before_Update_at_2021_7_12_9_04_[Default_Changelist]" date="1626051883392" recycled="true" deleted="true">
|
||||||
|
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_2021_7_12_9_04_[Default_Changelist]/shelved.patch" />
|
||||||
|
<option name="DESCRIPTION" value="Uncommitted changes before Update at 2021/7/12 9:04 [Default Changelist]" />
|
||||||
|
<binary>
|
||||||
|
<option name="BEFORE_PATH" value="../app-release.apk" />
|
||||||
|
<option name="AFTER_PATH" value="../app-release.apk" />
|
||||||
|
<option name="SHELVED_PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_2021_7_12_9_04_[Default_Changelist]/app-release.apk" />
|
||||||
|
</binary>
|
||||||
|
<binary>
|
||||||
|
<option name="BEFORE_PATH" value="app/release/app-release.apk" />
|
||||||
|
<option name="AFTER_PATH" />
|
||||||
|
<option name="SHELVED_PATH" />
|
||||||
|
</binary>
|
||||||
|
</changelist>
|
@ -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="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>showme</name>
|
||||||
|
<comment>Project showme created by Buildship.</comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||||
|
</natures>
|
||||||
|
<filteredResources>
|
||||||
|
<filter>
|
||||||
|
<id>1625906374722</id>
|
||||||
|
<name></name>
|
||||||
|
<type>30</type>
|
||||||
|
<matcher>
|
||||||
|
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||||
|
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||||
|
</matcher>
|
||||||
|
</filter>
|
||||||
|
</filteredResources>
|
||||||
|
</projectDescription>
|
@ -0,0 +1,13 @@
|
|||||||
|
arguments=
|
||||||
|
auto.sync=false
|
||||||
|
build.scans.enabled=false
|
||||||
|
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
|
||||||
|
connection.project.dir=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
gradle.user.home=
|
||||||
|
java.home=C\:/Software/StayHungry/JDK15
|
||||||
|
jvm.arguments=
|
||||||
|
offline.mode=false
|
||||||
|
override.workspace.settings=true
|
||||||
|
show.console.view=true
|
||||||
|
show.executions.view=true
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15/"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||||
|
<classpathentry kind="output" path="bin/default"/>
|
||||||
|
</classpath>
|
@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>CalendarView</name>
|
||||||
|
<comment>Project CalendarView created by Buildship.</comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||||
|
</natures>
|
||||||
|
<filteredResources>
|
||||||
|
<filter>
|
||||||
|
<id>1625906374711</id>
|
||||||
|
<name></name>
|
||||||
|
<type>30</type>
|
||||||
|
<matcher>
|
||||||
|
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||||
|
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||||
|
</matcher>
|
||||||
|
</filter>
|
||||||
|
</filteredResources>
|
||||||
|
</projectDescription>
|
@ -0,0 +1,2 @@
|
|||||||
|
connection.project.dir=..
|
||||||
|
eclipse.preferences.version=1
|
@ -1,5 +1,6 @@
|
|||||||
package com.idealist.calendarview;
|
package com.idealist.calendarview;
|
||||||
|
|
||||||
|
|
||||||
public class CalendarAttr {
|
public class CalendarAttr {
|
||||||
|
|
||||||
static int RecTop;
|
static int RecTop;
|
@ -0,0 +1,66 @@
|
|||||||
|
package com.idealist.calendarview;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.diary.database.utils.ScheduleSQLUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements
|
||||||
|
View.OnClickListener{
|
||||||
|
private List<String> mDatabase;
|
||||||
|
|
||||||
|
private OnItemClickListener onItemClickListener = null;
|
||||||
|
|
||||||
|
public RecyclerViewAdapter(List<String> mDatabase) {
|
||||||
|
super();
|
||||||
|
this.mDatabase = mDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View view = View.inflate(parent.getContext(), R.layout.schedule_item, null);
|
||||||
|
view.setOnClickListener(this);
|
||||||
|
return new RecyclerViewHolder(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
|
if (!(holder instanceof RecyclerViewHolder))
|
||||||
|
return;
|
||||||
|
holder.itemView.setTag(position);
|
||||||
|
String text = mDatabase.get(position);
|
||||||
|
((RecyclerViewHolder) holder).timeTextView.setText(ScheduleSQLUtils.extractScheduleTime(text));
|
||||||
|
((RecyclerViewHolder) holder).titleTextView.setText(ScheduleSQLUtils.extractScheduleName(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return mDatabase.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick(v, (int) v.getTag());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setmDatabase(List<String> mDatabase) {
|
||||||
|
this.mDatabase = mDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
|
||||||
|
this.onItemClickListener = onItemClickListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnItemClickListener {
|
||||||
|
void onItemClick(View view, int position);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,141 @@
|
|||||||
|
package com.idealist.calendarview;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
|
import static android.content.ContentValues.TAG;
|
||||||
|
|
||||||
|
public class RecyclerViewBehavior extends CoordinatorLayout.Behavior<RecyclerView> {
|
||||||
|
|
||||||
|
private int initOffset = -1;
|
||||||
|
private int minOffset = -1;
|
||||||
|
private int bottomOffset = -1;
|
||||||
|
private Context context;
|
||||||
|
private boolean initiated = false;
|
||||||
|
boolean hidingTop = false;
|
||||||
|
boolean showingTop = false;
|
||||||
|
|
||||||
|
public RecyclerViewBehavior(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLayoutChild(@NonNull CoordinatorLayout parent, @NonNull RecyclerView child, int layoutDirection) {
|
||||||
|
parent.onLayoutChild(child, layoutDirection);
|
||||||
|
CalendarPager calendarPager = getCalendarPager(parent);
|
||||||
|
initMinOffsetAndInitOffset(parent, child, calendarPager);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initMinOffsetAndInitOffset(CoordinatorLayout parent, RecyclerView child, CalendarPager pager) {
|
||||||
|
if (pager.getBottom() > 0 && initOffset == -1) {
|
||||||
|
initOffset = pager.getMeasuredHeight();
|
||||||
|
CalendarAttr.setRecTop(initOffset);
|
||||||
|
}
|
||||||
|
if (pager.getBottom() > 0 && bottomOffset == -1) {
|
||||||
|
bottomOffset = State.DEFAULT_ITEM_HEIGHT_FULL * 6;
|
||||||
|
}
|
||||||
|
if (!initiated) {
|
||||||
|
initOffset = pager.getMeasuredHeight();
|
||||||
|
CalendarAttr.setRecTop(initOffset);
|
||||||
|
initiated = true;
|
||||||
|
}
|
||||||
|
child.offsetTopAndBottom(CalendarAttr.getRecTop());
|
||||||
|
minOffset = getCalendarPager(parent).getItemHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onStartNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull RecyclerView child, @NonNull View directTargetChild, @NonNull View target, int axes, int type) {
|
||||||
|
return (axes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNestedPreScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull RecyclerView child, @NonNull View target, int dx, int dy, @NonNull int[] consumed, int type) {
|
||||||
|
super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type);
|
||||||
|
child.setVerticalScrollBarEnabled(true);
|
||||||
|
|
||||||
|
CalendarPager pager = (CalendarPager) coordinatorLayout.getChildAt(0);
|
||||||
|
if (pager.getPageScrollState() != ViewPager.SCROLL_STATE_IDLE) {
|
||||||
|
consumed[1] = dy;
|
||||||
|
Log.w("ldf", "onNestedPreScroll: MonthPager dragging");
|
||||||
|
Toast.makeText(context, "loading month data", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 上滑,正在隐藏顶部的日历
|
||||||
|
hidingTop = dy > 0;
|
||||||
|
// 下滑,正在展示顶部的日历
|
||||||
|
showingTop = dy < 0 && !target.canScrollVertically(-1);
|
||||||
|
Log.i("recycleBehavior", "hidingTop: " + hidingTop + " showingTop: " + showingTop);
|
||||||
|
if (hidingTop || showingTop) {
|
||||||
|
if (pager.getScrollLevel() == State.LEVEL_TOP) {
|
||||||
|
consumed[1] = CalendarUtils.scroll(child, dy,
|
||||||
|
State.DEFAULT_ITEM_HEIGHT,
|
||||||
|
State.DEFAULT_ITEM_HEIGHT * 6 + 10);
|
||||||
|
} else if (pager.getScrollLevel() == State.LEVEL_MEDIUM) {
|
||||||
|
consumed[1] = CalendarUtils.scroll(child, dy,
|
||||||
|
State.DEFAULT_ITEM_HEIGHT,
|
||||||
|
State.DEFAULT_ITEM_HEIGHT_FULL * 6);
|
||||||
|
}
|
||||||
|
CalendarAttr.setRecTop(child.getTop());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStopNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull RecyclerView child, @NonNull View target, int type) {
|
||||||
|
super.onStopNestedScroll(coordinatorLayout, child, target, type);
|
||||||
|
CalendarPager pager = (CalendarPager) getCalendarPager(coordinatorLayout);
|
||||||
|
CalendarViewAdapter adapter = (CalendarViewAdapter) pager.getAdapter();
|
||||||
|
|
||||||
|
if (pager.getScrollLevel() == State.LEVEL_TOP) {
|
||||||
|
if (CalendarAttr.getRecTop() - minOffset > CalendarUtils.getTouchSlop(context) && showingTop
|
||||||
|
&& CalendarAttr.getRecTop() < initOffset + 110) {
|
||||||
|
pager.setScrollLevel(State.LEVEL_MEDIUM);
|
||||||
|
adapter.changeCalendarType(State.VIEW_MONTH);
|
||||||
|
CalendarUtils.scrollTo(coordinatorLayout, child, getCalendarPager(coordinatorLayout).getViewHeight(), 500);
|
||||||
|
CalendarUtils.forceStopRecyclerViewScroll(child);
|
||||||
|
} else {
|
||||||
|
CalendarUtils.scrollTo(coordinatorLayout, child, getCalendarPager(coordinatorLayout).getItemHeight(), 150);
|
||||||
|
}
|
||||||
|
} else if (pager.getScrollLevel() == State.LEVEL_MEDIUM) {
|
||||||
|
if (initOffset - CalendarAttr.getRecTop() > CalendarUtils.getTouchSlop(context) && hidingTop) {
|
||||||
|
pager.setScrollLevel(State.LEVEL_TOP);
|
||||||
|
adapter.changeCalendarType(State.VIEW_WEEK);
|
||||||
|
CalendarUtils.scrollTo(coordinatorLayout, child, getCalendarPager(coordinatorLayout).getItemHeight(), 500);
|
||||||
|
CalendarUtils.forceStopRecyclerViewScroll(child);
|
||||||
|
} else if (CalendarAttr.getRecTop() - initOffset > CalendarUtils.getTouchSlop(context) && showingTop) {
|
||||||
|
pager.setScrollLevel(State.LEVEL_BOTTOM);
|
||||||
|
adapter.changeCalendarType(State.VIEW_FULL);
|
||||||
|
CalendarUtils.scrollTo(coordinatorLayout, child, getCalendarPager(coordinatorLayout).getViewHeight(), 500);
|
||||||
|
CalendarUtils.forceStopRecyclerViewScroll(child);
|
||||||
|
} else {
|
||||||
|
CalendarUtils.scrollTo(coordinatorLayout, child, getCalendarPager(coordinatorLayout).getViewHeight(), 150);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onNestedFling(@NonNull CoordinatorLayout coordinatorLayout, @NonNull RecyclerView child, @NonNull View target, float velocityX, float velocityY, boolean consumed) {
|
||||||
|
return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onNestedPreFling(@NonNull CoordinatorLayout coordinatorLayout, @NonNull RecyclerView child, @NonNull View target, float velocityX, float velocityY) {
|
||||||
|
return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CalendarPager getCalendarPager(CoordinatorLayout parent) {
|
||||||
|
return (CalendarPager) parent.getChildAt(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.idealist.calendarview;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
public class RecyclerViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
public TextView timeTextView;
|
||||||
|
public TextView titleTextView;
|
||||||
|
|
||||||
|
public RecyclerViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
timeTextView = itemView.findViewById(R.id.schedule_time);
|
||||||
|
titleTextView = itemView.findViewById(R.id.schedule_title);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.idealist.calendarview;
|
||||||
|
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class SpaceItemDecoration extends RecyclerView.ItemDecoration {
|
||||||
|
private int mSpace;
|
||||||
|
|
||||||
|
public SpaceItemDecoration(int mSpace) {
|
||||||
|
this.mSpace = mSpace;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
||||||
|
super.getItemOffsets(outRect, view, parent, state);
|
||||||
|
outRect.left = mSpace;
|
||||||
|
outRect.right = mSpace;
|
||||||
|
outRect.bottom = mSpace;
|
||||||
|
if (parent.getChildAdapterPosition(view) == 0) {
|
||||||
|
outRect.top = mSpace;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item>
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#000000"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:left="1dp">
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#ffffff"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="10dp"
|
||||||
|
android:paddingEnd="10dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/schedule_time"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="1:00\n7:00"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:gravity="center"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/schedule_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_toEndOf="@+id/schedule_time"
|
||||||
|
android:layout_toRightOf="@+id/schedule_time"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingLeft="20dp"
|
||||||
|
android:text="schedule"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:background="@drawable/schedule_border"/>
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<declare-styleable name="MyView">
|
||||||
|
<attr name="item_height" format="dimension"/>
|
||||||
|
<attr name="text_size" format="dimension"/>
|
||||||
|
</declare-styleable>
|
||||||
|
</resources>
|
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<style name="weekIndicatorStyle">
|
||||||
|
<item name="android:layout_width">0dp</item>
|
||||||
|
<item name="android:layout_height">match_parent</item>
|
||||||
|
<item name="android:layout_weight">1</item>
|
||||||
|
<item name="android:gravity">center</item>
|
||||||
|
<item name="android:textSize">13sp</item>
|
||||||
|
<item name="android:textColor">#ff25adff</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15/"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||||
|
<classpathentry kind="output" path="bin/default"/>
|
||||||
|
</classpath>
|
@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>Database</name>
|
||||||
|
<comment>Project Database created by Buildship.</comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||||
|
</natures>
|
||||||
|
<filteredResources>
|
||||||
|
<filter>
|
||||||
|
<id>1625906374715</id>
|
||||||
|
<name></name>
|
||||||
|
<type>30</type>
|
||||||
|
<matcher>
|
||||||
|
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||||
|
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||||
|
</matcher>
|
||||||
|
</filter>
|
||||||
|
</filteredResources>
|
||||||
|
</projectDescription>
|
@ -0,0 +1,2 @@
|
|||||||
|
connection.project.dir=..
|
||||||
|
eclipse.preferences.version=1
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.showme.database">
|
package="com.diary.database">
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -1,4 +1,4 @@
|
|||||||
package com.showme.database.DatabaseHelper;
|
package com.diary.database.DatabaseHelper;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
@ -1,4 +1,4 @@
|
|||||||
package com.showme.database.DatabaseHelper;
|
package com.diary.database.DatabaseHelper;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
@ -1,7 +1,9 @@
|
|||||||
package com.showme.database;
|
package com.diary.database;
|
||||||
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MySQLiteDatabase {
|
public class MySQLiteDatabase {
|
||||||
public static SQLiteDatabase scheduleSQL;
|
public static SQLiteDatabase scheduleSQL;
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
package com.showme.database.utils;
|
package com.diary.database.utils;
|
||||||
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
import com.showme.database.MySQLiteDatabase;
|
import com.diary.database.MySQLiteDatabase;
|
||||||
|
|
||||||
public class CourseSQLUtils {
|
public class CourseSQLUtils {
|
||||||
private static SQLiteDatabase courseSQL = MySQLiteDatabase.courseSQL;
|
private static SQLiteDatabase courseSQL = MySQLiteDatabase.courseSQL;
|
@ -1,9 +1,9 @@
|
|||||||
package com.showme.database.utils;
|
package com.diary.database.utils;
|
||||||
|
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
import com.showme.database.MySQLiteDatabase;
|
import com.diary.database.MySQLiteDatabase;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package com.showme.database;
|
package com.diary.database;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15/"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||||
|
<classpathentry kind="output" path="bin/default"/>
|
||||||
|
</classpath>
|
@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>app</name>
|
||||||
|
<comment>Project app created by Buildship.</comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||||
|
</natures>
|
||||||
|
<filteredResources>
|
||||||
|
<filter>
|
||||||
|
<id>1625906374719</id>
|
||||||
|
<name></name>
|
||||||
|
<type>30</type>
|
||||||
|
<matcher>
|
||||||
|
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||||
|
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||||
|
</matcher>
|
||||||
|
</filter>
|
||||||
|
</filteredResources>
|
||||||
|
</projectDescription>
|
@ -0,0 +1,2 @@
|
|||||||
|
connection.project.dir=..
|
||||||
|
eclipse.preferences.version=1
|
Binary file not shown.
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"version": 2,
|
||||||
|
"artifactType": {
|
||||||
|
"type": "APK",
|
||||||
|
"kind": "Directory"
|
||||||
|
},
|
||||||
|
"applicationId": "com.diary.showme",
|
||||||
|
"variantName": "release",
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"type": "SINGLE",
|
||||||
|
"filters": [],
|
||||||
|
"versionCode": 1,
|
||||||
|
"versionName": "1.0",
|
||||||
|
"outputFile": "app-release.apk"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
package="com.diary.showme">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
|
||||||
|
<uses-permission
|
||||||
|
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||||
|
tools:ignore="ScopedStorage" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/Theme.Showme">
|
||||||
|
<activity android:name=".diary.ui.UpdateDiaryActivity" />
|
||||||
|
<activity android:name=".diary.ui.DiaryActivity" />
|
||||||
|
<activity android:name=".diary.ui.AddDiaryActivity" />
|
||||||
|
<activity android:name=".diary.ui.CardActivity" />
|
||||||
|
<activity android:name=".diary.ui.QuestionActivity"/>
|
||||||
|
<activity android:name=".Course.AddCourseActivity" />
|
||||||
|
<activity android:name=".Course.CourseActivity" />
|
||||||
|
<activity android:name=".MainActivity">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<activity android:name=".Schedule.AddScheduleActivity" />
|
||||||
|
<activity android:name=".Schedule.EditScheduleActivity" />
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
@ -0,0 +1,56 @@
|
|||||||
|
package com.diary.showme.Course;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.diary.showme.R;
|
||||||
|
|
||||||
|
public class AddCourseActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_add_course);
|
||||||
|
setFinishOnTouchOutside(false);
|
||||||
|
|
||||||
|
final EditText inputCourseName = (EditText) findViewById(R.id.course_name);
|
||||||
|
final EditText inputTeacher = (EditText) findViewById(R.id.teacher_name);
|
||||||
|
final EditText inputClassRoom = (EditText) findViewById(R.id.class_room);
|
||||||
|
final EditText inputDay = (EditText) findViewById(R.id.week);
|
||||||
|
final EditText inputStart = (EditText) findViewById(R.id.classes_begin);
|
||||||
|
final EditText inputEnd = (EditText) findViewById(R.id.classes_ends);
|
||||||
|
final EditText inputWeeks = (EditText) findViewById(R.id.weeks);
|
||||||
|
|
||||||
|
Button okButton = (Button) findViewById(R.id.button);
|
||||||
|
okButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
String courseName = inputCourseName.getText().toString();
|
||||||
|
String teacher = inputTeacher.getText().toString();
|
||||||
|
String classRoom = inputClassRoom.getText().toString();
|
||||||
|
String day = inputDay.getText().toString();
|
||||||
|
String start = inputStart.getText().toString();
|
||||||
|
String end = inputEnd.getText().toString();
|
||||||
|
String weeks = inputWeeks.getText().toString();
|
||||||
|
|
||||||
|
if (courseName.equals("") || day.equals("") || start.equals("") || end.equals("")) {
|
||||||
|
Toast.makeText(AddCourseActivity.this, "基本课程信息未填写", Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
Course course = new Course(courseName, teacher, classRoom,
|
||||||
|
Integer.valueOf(day), Integer.valueOf(start), Integer.valueOf(end), weeks);
|
||||||
|
Intent intent = new Intent(AddCourseActivity.this, CourseActivity.class);
|
||||||
|
intent.putExtra("course", course);
|
||||||
|
setResult(Activity.RESULT_OK, intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
package com.diary.showme.Course;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Course implements Serializable {
|
||||||
|
|
||||||
|
private String courseName;
|
||||||
|
private String teacher;
|
||||||
|
private String classRoom;
|
||||||
|
private int day;
|
||||||
|
private int classStart;
|
||||||
|
private int classEnd;
|
||||||
|
private String weeks;
|
||||||
|
|
||||||
|
public Course(String courseName, String teacher, String classRoom, int day, int classStart, int classEnd, String weeks) {
|
||||||
|
this.courseName = courseName;
|
||||||
|
this.teacher = teacher;
|
||||||
|
this.classRoom = classRoom;
|
||||||
|
this.day = day;
|
||||||
|
this.classStart = classStart;
|
||||||
|
this.classEnd = classEnd;
|
||||||
|
this.weeks = weeks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCourseName() {
|
||||||
|
return courseName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCourseName(String courseName) {
|
||||||
|
this.courseName = courseName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTeacher() {
|
||||||
|
return teacher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTeacher(String teacher) {
|
||||||
|
this.teacher = teacher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClassRoom() {
|
||||||
|
return classRoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClassRoom(String classRoom) {
|
||||||
|
this.classRoom = classRoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDay() {
|
||||||
|
return day;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDay(int day) {
|
||||||
|
this.day = day;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStart() {
|
||||||
|
return classStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStart(int classStart) {
|
||||||
|
this.classEnd = classStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEnd() {
|
||||||
|
return classEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnd(int classEnd) {
|
||||||
|
this.classEnd = classEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWeeks() {
|
||||||
|
return weeks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWeeks(String weeks) {
|
||||||
|
this.weeks = weeks;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,171 @@
|
|||||||
|
package com.diary.showme.Course;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.diary.database.DatabaseHelper.CourseSQLHelper;
|
||||||
|
import com.diary.database.utils.CourseSQLUtils;
|
||||||
|
import com.diary.showme.R;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class CourseActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private RelativeLayout day;
|
||||||
|
|
||||||
|
private Button addCourse;
|
||||||
|
|
||||||
|
private Button backToCalendar;
|
||||||
|
|
||||||
|
//SQLite Helper类
|
||||||
|
private CourseSQLHelper databaseHelper = new CourseSQLHelper(this);
|
||||||
|
|
||||||
|
int currentCoursesNumber = 0;
|
||||||
|
int maxCoursesNumber = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_course);
|
||||||
|
//从数据库读取数据
|
||||||
|
|
||||||
|
addCourse = findViewById(R.id.add_courses);
|
||||||
|
backToCalendar = findViewById(R.id.back_to_calendar);
|
||||||
|
|
||||||
|
addCourse.setOnClickListener(v -> {
|
||||||
|
Intent intent = new Intent(CourseActivity.this, AddCourseActivity.class);
|
||||||
|
startActivityForResult(intent, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
backToCalendar.setOnClickListener(v -> finish());
|
||||||
|
|
||||||
|
loadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadData() {
|
||||||
|
ArrayList<Course> coursesList = new ArrayList<>(); //课程列表
|
||||||
|
SQLiteDatabase courseSQL = databaseHelper.getReadableDatabase();
|
||||||
|
Cursor cursor = courseSQL.rawQuery("select * from courses", null);
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
coursesList.add(new Course(
|
||||||
|
cursor.getString(cursor.getColumnIndex("course_name")),
|
||||||
|
cursor.getString(cursor.getColumnIndex("teacher")),
|
||||||
|
cursor.getString(cursor.getColumnIndex("class_room")),
|
||||||
|
cursor.getInt(cursor.getColumnIndex("day")),
|
||||||
|
cursor.getInt(cursor.getColumnIndex("class_start")),
|
||||||
|
cursor.getInt(cursor.getColumnIndex("class_end")),
|
||||||
|
cursor.getString(cursor.getColumnIndex("weeks"))));
|
||||||
|
} while(cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
|
||||||
|
//使用从数据库读取出来的课程信息来加载课程表视图
|
||||||
|
for (Course course : coursesList) {
|
||||||
|
createLeftView(course);
|
||||||
|
createItemCourseView(course);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//创建"第几节数"视图
|
||||||
|
private void createLeftView(Course course) {
|
||||||
|
int endNumber = course.getEnd();
|
||||||
|
if (endNumber > maxCoursesNumber) {
|
||||||
|
for (int i = 0; i < endNumber-maxCoursesNumber; i++) {
|
||||||
|
View view = LayoutInflater.from(this).inflate(R.layout.course_left_view, null);
|
||||||
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(110,180);
|
||||||
|
view.setLayoutParams(params);
|
||||||
|
|
||||||
|
TextView text = view.findViewById(R.id.class_number_text);
|
||||||
|
text.setText(String.valueOf(++currentCoursesNumber));
|
||||||
|
|
||||||
|
LinearLayout leftViewLayout = findViewById(R.id.left_view_layout);
|
||||||
|
leftViewLayout.addView(view);
|
||||||
|
}
|
||||||
|
maxCoursesNumber = endNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//创建单个课程视图
|
||||||
|
private void createItemCourseView(final Course course) {
|
||||||
|
int getDay = course.getDay();
|
||||||
|
if ((getDay < 1 || getDay > 7) || course.getStart() > course.getEnd())
|
||||||
|
Toast.makeText(this, "星期几没写对,或课程结束时间比开始时间还早~~", Toast.LENGTH_LONG).show();
|
||||||
|
else {
|
||||||
|
int dayId = 0;
|
||||||
|
switch (getDay) {
|
||||||
|
case 1: dayId = R.id.monday; break;
|
||||||
|
case 2: dayId = R.id.tuesday; break;
|
||||||
|
case 3: dayId = R.id.wednesday; break;
|
||||||
|
case 4: dayId = R.id.thursday; break;
|
||||||
|
case 5: dayId = R.id.friday; break;
|
||||||
|
case 6: dayId = R.id.saturday; break;
|
||||||
|
case 7: dayId = R.id.weekday; break;
|
||||||
|
}
|
||||||
|
day = findViewById(dayId);
|
||||||
|
|
||||||
|
int height = 180;
|
||||||
|
final View v = LayoutInflater.from(this).inflate(R.layout.course_card, null); //加载单个课程布局
|
||||||
|
v.setY(height * (course.getStart()-1)); //设置开始高度,即第几节课开始
|
||||||
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams
|
||||||
|
(ViewGroup.LayoutParams.MATCH_PARENT,(course.getEnd()-course.getStart()+1)*height - 8); //设置布局高度,即跨多少节课
|
||||||
|
v.setLayoutParams(params);
|
||||||
|
TextView text = v.findViewById(R.id.text_view);
|
||||||
|
text.setText(course.getCourseName() + "\n" + course.getTeacher() + "\n" + course.getClassRoom() + "\n" + course.getWeeks() ); //显示课程名
|
||||||
|
day.addView(v);
|
||||||
|
//长按删除课程
|
||||||
|
v.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
v.setVisibility(View.GONE);//先隐藏
|
||||||
|
day.removeView(v);//再移除课程视图
|
||||||
|
SQLiteDatabase sqLiteDatabase = databaseHelper.getWritableDatabase();
|
||||||
|
sqLiteDatabase.execSQL("delete from courses where course_name = ?", new String[] {course.getCourseName()});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
if (requestCode == 0 && resultCode == Activity.RESULT_OK && data != null) {
|
||||||
|
Course course = (Course) data.getSerializableExtra("course");
|
||||||
|
//创建课程表左边视图(节数)
|
||||||
|
createLeftView(course);
|
||||||
|
//创建课程表视图
|
||||||
|
createItemCourseView(course);
|
||||||
|
//存储数据到数据库
|
||||||
|
saveData(course);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//保存数据到数据库
|
||||||
|
private void saveData(Course course) {
|
||||||
|
SQLiteDatabase sqLiteDatabase = databaseHelper.getWritableDatabase();
|
||||||
|
sqLiteDatabase.execSQL
|
||||||
|
("insert into courses(course_name, teacher, class_room, day, class_start, class_end, weeks) " + "values(?, ?, ?, ?, ?, ?, ?)",
|
||||||
|
new String[] {course.getCourseName(),
|
||||||
|
course.getTeacher(),
|
||||||
|
course.getClassRoom(),
|
||||||
|
course.getDay()+"",
|
||||||
|
course.getStart()+"",
|
||||||
|
course.getEnd()+"",
|
||||||
|
course.getWeeks()}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,225 @@
|
|||||||
|
package com.diary.showme;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.diary.database.DatabaseHelper.CourseSQLHelper;
|
||||||
|
import com.diary.database.DatabaseHelper.ScheduleSQLHelper;
|
||||||
|
import com.diary.database.MySQLiteDatabase;
|
||||||
|
import com.diary.database.utils.ScheduleSQLUtils;
|
||||||
|
import com.diary.showme.Course.CourseActivity;
|
||||||
|
import com.diary.showme.Schedule.AddScheduleActivity;
|
||||||
|
import com.diary.showme.Schedule.EditScheduleActivity;
|
||||||
|
import com.diary.showme.diary.ui.QuestionActivity;
|
||||||
|
import com.diary.showme.diary.ui.DiaryActivity;
|
||||||
|
import com.idealist.calendarview.CalendarAttr;
|
||||||
|
import com.idealist.calendarview.CalendarDay;
|
||||||
|
import com.idealist.calendarview.CalendarPager;
|
||||||
|
import com.idealist.calendarview.CalendarUtils;
|
||||||
|
import com.idealist.calendarview.CalendarView;
|
||||||
|
import com.idealist.calendarview.CalendarViewAdapter;
|
||||||
|
//import com.idealist.calendarview.RecyclerViewAdapter;
|
||||||
|
//import com.idealist.calendarview.SpaceItemDecoration;
|
||||||
|
import com.idealist.calendarview.RecyclerViewAdapter;
|
||||||
|
import com.idealist.calendarview.SpaceItemDecoration;
|
||||||
|
import com.idealist.calendarview.State;
|
||||||
|
import com.idealist.calendarview.interf.OnSelectDateListener;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import cc.trity.floatingactionbutton.FloatingActionButton;
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private TextView tvMonth;
|
||||||
|
private TextView tvYear;
|
||||||
|
|
||||||
|
private CalendarDay currentDay;
|
||||||
|
|
||||||
|
private CalendarView currentView;
|
||||||
|
|
||||||
|
private CalendarPager pager;
|
||||||
|
|
||||||
|
private RecyclerView schedule;
|
||||||
|
|
||||||
|
private CalendarViewAdapter viewAdapter;
|
||||||
|
|
||||||
|
private CalendarAttr attr;
|
||||||
|
|
||||||
|
private OnSelectDateListener onSelectDateListener;
|
||||||
|
|
||||||
|
private CalendarView.OnCalendarClickListener clickListener;
|
||||||
|
|
||||||
|
private FloatingActionButton scheduleFAB, courseFAB, diaryFAB;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
|
||||||
|
DisplayMetrics dm = new DisplayMetrics();
|
||||||
|
getWindowManager().getDefaultDisplay().getRealMetrics(dm);
|
||||||
|
int height = dm.heightPixels;
|
||||||
|
State.setDefaultItemHeightFull((height - 42 - 3*State.DEFAULT_ITEM_HEIGHT) / 6);
|
||||||
|
|
||||||
|
initSQL();
|
||||||
|
initCalendar();
|
||||||
|
initFAB();
|
||||||
|
initCourseB();
|
||||||
|
initDiaryB();
|
||||||
|
|
||||||
|
attr = new CalendarAttr();
|
||||||
|
attr.setCalendarType(State.VIEW_MONTH);
|
||||||
|
attr.setScrollLevel(State.LEVEL_MEDIUM);
|
||||||
|
|
||||||
|
initListener();
|
||||||
|
|
||||||
|
viewAdapter = new CalendarViewAdapter(this, attr, onSelectDateListener,
|
||||||
|
clickListener);
|
||||||
|
initPager();
|
||||||
|
initSchedule();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initSQL() {
|
||||||
|
ScheduleSQLHelper myScheduleSQLHelper = new ScheduleSQLHelper(this);
|
||||||
|
SQLiteDatabase scheduleSQL = myScheduleSQLHelper.getWritableDatabase();
|
||||||
|
CourseSQLHelper myCourseSQLHelper = new CourseSQLHelper(this);
|
||||||
|
SQLiteDatabase courseSQL = myCourseSQLHelper.getWritableDatabase();
|
||||||
|
|
||||||
|
MySQLiteDatabase.scheduleSQL = scheduleSQL;
|
||||||
|
MySQLiteDatabase.courseSQL = courseSQL;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initFAB() {
|
||||||
|
scheduleFAB = findViewById(R.id.add_schedule);
|
||||||
|
scheduleFAB.setOnClickListener(v -> {
|
||||||
|
Toast.makeText(getApplicationContext(), viewAdapter.getSelectDay().toString(), Toast.LENGTH_SHORT).show();
|
||||||
|
Intent intent = new Intent(MainActivity.this, AddScheduleActivity.class);
|
||||||
|
intent.putExtra("date", viewAdapter.getSelectDay().toString());
|
||||||
|
startActivityForResult(intent, 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initCourseB() {
|
||||||
|
courseFAB = findViewById(R.id.course_entry);
|
||||||
|
courseFAB.setOnClickListener(v -> {
|
||||||
|
Intent intent = new Intent(MainActivity.this, CourseActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initDiaryB() {
|
||||||
|
diaryFAB = findViewById(R.id.diary_entry);
|
||||||
|
diaryFAB.setOnClickListener(v -> {
|
||||||
|
Intent intent = new Intent(MainActivity.this, DiaryActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void initCalendar() {
|
||||||
|
tvMonth = findViewById(R.id.custom_month_view);
|
||||||
|
tvYear = findViewById(R.id.custom_year_view);
|
||||||
|
currentDay = CalendarUtils.getCurrDay();
|
||||||
|
updateCalendar();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initPager() {
|
||||||
|
pager = findViewById(R.id.custom_vp);
|
||||||
|
pager.setAttr(attr);
|
||||||
|
pager.setAdapter(viewAdapter);
|
||||||
|
|
||||||
|
pager.setmOnPageChangeListener(new CalendarPager.OnPageChangeListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
currentView = viewAdapter.getViews().get(position % 3);
|
||||||
|
currentDay = currentView.getSeedDay();
|
||||||
|
updateCalendar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged(int state) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initListener() {
|
||||||
|
onSelectDateListener = offset -> pager.selectOtherMonth(offset);
|
||||||
|
clickListener = new CalendarView.OnCalendarClickListener() {
|
||||||
|
@Override
|
||||||
|
public void OnClick(CalendarDay day) {
|
||||||
|
updateSchedule(day);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void OnLongClick(CalendarDay day) {
|
||||||
|
Intent intent = new Intent(MainActivity.this, QuestionActivity.class);
|
||||||
|
intent.putExtra("date", viewAdapter.getSelectDay().toString());
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initSchedule() {
|
||||||
|
|
||||||
|
schedule = findViewById(R.id.list_item);
|
||||||
|
List<String> mData = ScheduleSQLUtils.queryByDate(currentDay.toString());
|
||||||
|
|
||||||
|
RecyclerViewAdapter adapter = new RecyclerViewAdapter(mData);
|
||||||
|
adapter.setOnItemClickListener((view, position) -> {
|
||||||
|
Intent intent = new Intent(MainActivity.this, EditScheduleActivity.class);
|
||||||
|
intent.putExtra("date", viewAdapter.getSelectDay().toString());
|
||||||
|
String name = ((TextView) view.findViewById(R.id.schedule_title)).getText().toString();
|
||||||
|
intent.putExtra("scheduleName", name);
|
||||||
|
startActivityForResult(intent, 0);
|
||||||
|
});
|
||||||
|
schedule.setAdapter(adapter);
|
||||||
|
|
||||||
|
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
||||||
|
schedule.setLayoutManager(layoutManager);
|
||||||
|
schedule.addItemDecoration(new SpaceItemDecoration(30));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
private void updateCalendar() {
|
||||||
|
tvMonth.setText(currentDay.getMonth() + "");
|
||||||
|
tvYear.setText(currentDay.getYear() + "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSchedule(CalendarDay day) {
|
||||||
|
ScheduleSQLUtils.queryByDate(day.toString());
|
||||||
|
List<String> mData = ScheduleSQLUtils.queryByDate(day.toString());
|
||||||
|
RecyclerViewAdapter adapter = (RecyclerViewAdapter) schedule.getAdapter();
|
||||||
|
adapter.setmDatabase(mData);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
if (requestCode == 0 && resultCode == Activity.RESULT_OK) {
|
||||||
|
updateSchedule(viewAdapter.getSelectDay());
|
||||||
|
viewAdapter.updateViewScheduleChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,139 @@
|
|||||||
|
package com.diary.showme.Schedule;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.diary.database.DatabaseHelper.ScheduleSQLHelper;
|
||||||
|
import com.diary.showme.R;
|
||||||
|
|
||||||
|
|
||||||
|
public class AddScheduleActivity extends AppCompatActivity implements View.OnClickListener{
|
||||||
|
private EditText scheduleNameInput;
|
||||||
|
private EditText schedulePlaceInput;
|
||||||
|
private EditText scheduleStartHourInput;
|
||||||
|
private EditText scheduleStartMinInput;
|
||||||
|
private EditText scheduleEndHourInput;
|
||||||
|
private EditText scheduleEndMinInput;
|
||||||
|
private Button checkAdd1;
|
||||||
|
private ScheduleSQLHelper mySQLiteOpenHelper;
|
||||||
|
private SQLiteDatabase myDatabase;
|
||||||
|
private Context context;
|
||||||
|
private TextView mySchedule2;
|
||||||
|
private String date;
|
||||||
|
private Integer cnt=0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_schedule_add);
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
|
mySQLiteOpenHelper = new ScheduleSQLHelper(this);
|
||||||
|
myDatabase = mySQLiteOpenHelper.getWritableDatabase();
|
||||||
|
|
||||||
|
context = this;
|
||||||
|
scheduleNameInput = findViewById(R.id.scheduleNameInput);
|
||||||
|
schedulePlaceInput = findViewById(R.id.schedulePlaceInput);
|
||||||
|
scheduleStartHourInput = findViewById(R.id.scheduleStartHourInput);
|
||||||
|
scheduleStartMinInput = findViewById(R.id.scheduleStartMinInput);
|
||||||
|
scheduleEndHourInput = findViewById(R.id.scheduleEndHourInput);
|
||||||
|
scheduleEndMinInput = findViewById(R.id.scheduleEndMinInput);
|
||||||
|
|
||||||
|
checkAdd1 = findViewById(R.id.checkAdd1);
|
||||||
|
checkAdd1.setOnClickListener(this);
|
||||||
|
|
||||||
|
mySchedule2 = findViewById(R.id.schedule2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
switch (v.getId()){
|
||||||
|
case R.id.checkAdd1:
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
Intent intent = getIntent();
|
||||||
|
date = intent.getStringExtra("date");
|
||||||
|
Integer cnt1=0;
|
||||||
|
if(scheduleNameInput.getText().toString().equals("")){
|
||||||
|
Toast.makeText(this, "日程标题未填写", Toast.LENGTH_SHORT).show();
|
||||||
|
}else if((scheduleStartHourInput.getText().toString().equals("") && !scheduleStartMinInput.getText().toString().equals("")) || (!scheduleStartHourInput.getText().toString().equals("") && scheduleStartMinInput.getText().toString().equals(""))){
|
||||||
|
Toast.makeText(this, "开始时间未填写完全", Toast.LENGTH_SHORT).show();
|
||||||
|
}else if((scheduleEndHourInput.getText().toString().equals("") && !scheduleEndMinInput.getText().toString().equals("")) || (!scheduleEndHourInput.getText().toString().equals("") && scheduleEndMinInput.getText().toString().equals(""))){
|
||||||
|
Toast.makeText(this, "结束时间未填写完全", Toast.LENGTH_SHORT).show();
|
||||||
|
}else if(!scheduleStartHourInput.getText().toString().equals("") && !scheduleStartMinInput.getText().toString().equals("") && !scheduleEndHourInput.getText().toString().equals("") && !scheduleEndMinInput.getText().toString().equals("")){
|
||||||
|
if(Integer.parseInt(scheduleEndHourInput.getText().toString())<Integer.parseInt(scheduleStartHourInput.getText().toString())){
|
||||||
|
Toast.makeText(this, "时间输入不合法", Toast.LENGTH_SHORT).show();
|
||||||
|
cnt1+=1;
|
||||||
|
}
|
||||||
|
if(Integer.parseInt(scheduleEndHourInput.getText().toString())==Integer.parseInt(scheduleStartHourInput.getText().toString()) && Integer.parseInt(scheduleEndMinInput.getText().toString())<Integer.parseInt(scheduleStartMinInput.getText().toString()) && cnt==0){
|
||||||
|
Toast.makeText(this, "时间输入不合法", Toast.LENGTH_SHORT).show();
|
||||||
|
cnt1+=1;
|
||||||
|
}
|
||||||
|
if(Integer.parseInt(scheduleStartHourInput.getText().toString())<0 || Integer.parseInt(scheduleStartHourInput.getText().toString())>24){
|
||||||
|
Toast.makeText(this, "开始时输入不合法", Toast.LENGTH_SHORT).show();
|
||||||
|
cnt1+=1;
|
||||||
|
}
|
||||||
|
if(Integer.parseInt(scheduleStartMinInput.getText().toString())<0 || Integer.parseInt(scheduleStartMinInput.getText().toString())>60){
|
||||||
|
Toast.makeText(this, "开始分输入不合法", Toast.LENGTH_SHORT).show();
|
||||||
|
cnt1+=1;
|
||||||
|
}
|
||||||
|
if(Integer.parseInt(scheduleEndHourInput.getText().toString())<0 || Integer.parseInt(scheduleEndHourInput.getText().toString())>24){
|
||||||
|
Toast.makeText(this, "结束时输入不合法", Toast.LENGTH_SHORT).show();
|
||||||
|
cnt1+=1;
|
||||||
|
}
|
||||||
|
if(Integer.parseInt(scheduleEndMinInput.getText().toString())<0 || Integer.parseInt(scheduleEndMinInput.getText().toString())>60){
|
||||||
|
Toast.makeText(this, "结束分输入不合法", Toast.LENGTH_SHORT).show();
|
||||||
|
cnt1+=1;
|
||||||
|
}
|
||||||
|
if(cnt1==0){
|
||||||
|
cnt=1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
cnt = 1;
|
||||||
|
}
|
||||||
|
if(cnt==1) {
|
||||||
|
//第一个参数是表中的列名
|
||||||
|
values.put("scheduleName", scheduleNameInput.getText().toString());
|
||||||
|
if(schedulePlaceInput.getText().toString().equals("")){
|
||||||
|
values.put("ifSchedulePlace", 0);
|
||||||
|
}else {
|
||||||
|
values.put("ifSchedulePlace", 1);
|
||||||
|
}
|
||||||
|
if(scheduleStartHourInput.getText().toString().equals("") && scheduleStartMinInput.getText().toString().equals("")){
|
||||||
|
values.put("ifStartTime", 0);
|
||||||
|
}else {
|
||||||
|
values.put("ifStartTime", 1);
|
||||||
|
}
|
||||||
|
if(scheduleEndHourInput.getText().toString().equals("") && scheduleEndMinInput.getText().toString().equals("")){
|
||||||
|
values.put("ifEndTime", 0);
|
||||||
|
}else {
|
||||||
|
values.put("ifEndTime", 1);
|
||||||
|
}
|
||||||
|
values.put("schedulePlace", schedulePlaceInput.getText().toString());
|
||||||
|
values.put("startTime", scheduleStartHourInput.getText().toString() + ":" + scheduleStartMinInput.getText().toString());
|
||||||
|
values.put("endTime", scheduleEndHourInput.getText().toString() + ":" + scheduleEndMinInput.getText().toString());
|
||||||
|
values.put("time", date);
|
||||||
|
myDatabase.insert("schedules", null, values);
|
||||||
|
// Intent intent2 = new Intent(AddSchedule.this, MainActivity.class);
|
||||||
|
// startActivity(intent2);
|
||||||
|
setResult(Activity.RESULT_OK);
|
||||||
|
finish();
|
||||||
|
//queryByDate(date);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,199 @@
|
|||||||
|
package com.diary.showme.Schedule;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.diary.database.DatabaseHelper.ScheduleSQLHelper;
|
||||||
|
import com.diary.showme.R;
|
||||||
|
|
||||||
|
public class EditScheduleActivity extends AppCompatActivity implements View.OnClickListener{
|
||||||
|
private Button editBtn,deleteBtn;
|
||||||
|
private EditText scheduleNameInput;
|
||||||
|
private EditText schedulePlaceInput;
|
||||||
|
private EditText scheduleStartHourInput;
|
||||||
|
private EditText scheduleStartMinInput;
|
||||||
|
private EditText scheduleEndHourInput;
|
||||||
|
private EditText scheduleEndMinInput;
|
||||||
|
private ScheduleSQLHelper mySQLiteOpenHelper;
|
||||||
|
private SQLiteDatabase myDatabase;
|
||||||
|
private String scheduleName;
|
||||||
|
private String date;
|
||||||
|
private Integer cnt;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_schedule_edit);
|
||||||
|
|
||||||
|
// 首先获取到意图对象
|
||||||
|
Intent intent = getIntent();
|
||||||
|
// 获取到传递过来的姓名
|
||||||
|
scheduleName = intent.getStringExtra("scheduleName");
|
||||||
|
//获得时间
|
||||||
|
date = intent.getStringExtra("date");
|
||||||
|
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
|
mySQLiteOpenHelper = new ScheduleSQLHelper(this);
|
||||||
|
myDatabase = mySQLiteOpenHelper.getWritableDatabase();
|
||||||
|
|
||||||
|
editBtn = findViewById(R.id.editBtn);
|
||||||
|
editBtn.setOnClickListener(this);
|
||||||
|
deleteBtn = findViewById(R.id.deleteSchedule);
|
||||||
|
deleteBtn.setOnClickListener(this);
|
||||||
|
|
||||||
|
Cursor cursor = myDatabase.query("schedules",null,"scheduleName=? and time=?",new String[]{scheduleName,date},null,null,null);
|
||||||
|
|
||||||
|
if(cursor.moveToFirst()){
|
||||||
|
String aScheduleName = cursor.getString(cursor.getColumnIndex("scheduleName"));
|
||||||
|
String aSchedulePlace = cursor.getString(cursor.getColumnIndex("schedulePlace"));
|
||||||
|
String aStartTime = cursor.getString(cursor.getColumnIndex("startTime"));
|
||||||
|
String aEndTime = cursor.getString(cursor.getColumnIndex("endTime"));
|
||||||
|
Integer ifSchedulePlace = cursor.getInt(cursor.getColumnIndex("ifSchedulePlace"));
|
||||||
|
Integer ifStartTime = cursor.getInt(cursor.getColumnIndex("ifStartTime"));
|
||||||
|
Integer ifEndTime = cursor.getInt(cursor.getColumnIndex("ifEndTime"));
|
||||||
|
String[] aStartTime1; //=aStartTime.split(":");
|
||||||
|
String[] aEndTime1; //=aEndTime.split(":");
|
||||||
|
|
||||||
|
scheduleNameInput = findViewById(R.id.scheduleNameInput);
|
||||||
|
schedulePlaceInput = findViewById(R.id.schedulePlaceInput);
|
||||||
|
scheduleStartHourInput = findViewById(R.id.scheduleStartHourInput);
|
||||||
|
scheduleStartMinInput = findViewById(R.id.scheduleStartMinInput);
|
||||||
|
scheduleEndHourInput = findViewById(R.id.scheduleEndHourInput);
|
||||||
|
scheduleEndMinInput = findViewById(R.id.scheduleEndMinInput);
|
||||||
|
scheduleNameInput.setText(aScheduleName);
|
||||||
|
if(ifSchedulePlace==1){
|
||||||
|
schedulePlaceInput.setText(aSchedulePlace);
|
||||||
|
}
|
||||||
|
if(ifStartTime == 1) {
|
||||||
|
aStartTime1=aStartTime.split(":");
|
||||||
|
scheduleStartHourInput.setText(aStartTime1[0]);
|
||||||
|
scheduleStartMinInput.setText(aStartTime1[1]);
|
||||||
|
}
|
||||||
|
if(ifEndTime == 1) {
|
||||||
|
aEndTime1=aEndTime.split(":");
|
||||||
|
scheduleEndHourInput.setText(aEndTime1[0]);
|
||||||
|
scheduleEndMinInput.setText(aEndTime1[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v){
|
||||||
|
switch (v.getId()){
|
||||||
|
case R.id.deleteSchedule:
|
||||||
|
deleteMySchedule();
|
||||||
|
break;
|
||||||
|
case R.id.editBtn:
|
||||||
|
editSchedule();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void editSchedule() {
|
||||||
|
// ContentValues values = new ContentValues();
|
||||||
|
// values.put("scheduleName",scheduleNameInput.getText().toString());
|
||||||
|
// values.put("scheduleName",scheduleNameInput.getText().toString());
|
||||||
|
// values.put("schedulePlace",schedulePlaceInput.getText().toString());
|
||||||
|
// values.put("startTime",scheduleStartHourInput.getText().toString()+":"+scheduleStartMinInput.getText().toString());
|
||||||
|
// values.put("endTime",scheduleEndHourInput.getText().toString()+":"+scheduleEndMinInput.getText().toString());
|
||||||
|
//
|
||||||
|
// myDatabase.update("schedules",values,"scheduleName=?",new String[]{scheduleName});
|
||||||
|
//
|
||||||
|
// Intent intent = new Intent(EditScheduleActivity.this, MainActivity.class);
|
||||||
|
// startActivity(intent);
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
Intent intent = getIntent();
|
||||||
|
Integer cnt1 = 0;
|
||||||
|
date = intent.getStringExtra("date");
|
||||||
|
if(scheduleNameInput.getText().toString().equals("")){
|
||||||
|
Toast.makeText(this, "日程标题未填写", Toast.LENGTH_SHORT).show();
|
||||||
|
}else if((scheduleStartHourInput.getText().toString().equals("") && !scheduleStartMinInput.getText().toString().equals("")) || (!scheduleStartHourInput.getText().toString().equals("") && scheduleStartMinInput.getText().toString().equals(""))){
|
||||||
|
Toast.makeText(this, "开始时间未填写完全", Toast.LENGTH_SHORT).show();
|
||||||
|
}else if((scheduleEndHourInput.getText().toString().equals("") && !scheduleEndMinInput.getText().toString().equals("")) || (!scheduleEndHourInput.getText().toString().equals("") && scheduleEndMinInput.getText().toString().equals(""))){
|
||||||
|
Toast.makeText(this, "结束时间未填写完全", Toast.LENGTH_SHORT).show();
|
||||||
|
}else if(!scheduleStartHourInput.getText().toString().equals("") && !scheduleStartMinInput.getText().toString().equals("") && !scheduleEndHourInput.getText().toString().equals("") && !scheduleEndMinInput.getText().toString().equals("")){
|
||||||
|
if(Integer.parseInt(scheduleEndHourInput.getText().toString())<Integer.parseInt(scheduleStartHourInput.getText().toString())){
|
||||||
|
Toast.makeText(this, "时间输入不合法", Toast.LENGTH_SHORT).show();
|
||||||
|
cnt1+=1;
|
||||||
|
}
|
||||||
|
if(Integer.parseInt(scheduleEndHourInput.getText().toString())==Integer.parseInt(scheduleStartHourInput.getText().toString()) && Integer.parseInt(scheduleEndMinInput.getText().toString())<Integer.parseInt(scheduleStartMinInput.getText().toString()) && cnt==0){
|
||||||
|
Toast.makeText(this, "时间输入不合法", Toast.LENGTH_SHORT).show();
|
||||||
|
cnt1+=1;
|
||||||
|
}
|
||||||
|
if(Integer.parseInt(scheduleStartHourInput.getText().toString())<0 || Integer.parseInt(scheduleStartHourInput.getText().toString())>24){
|
||||||
|
Toast.makeText(this, "开始时输入不合法", Toast.LENGTH_SHORT).show();
|
||||||
|
cnt1+=1;
|
||||||
|
}
|
||||||
|
if(Integer.parseInt(scheduleStartMinInput.getText().toString())<0 || Integer.parseInt(scheduleStartMinInput.getText().toString())>60){
|
||||||
|
Toast.makeText(this, "开始分输入不合法", Toast.LENGTH_SHORT).show();
|
||||||
|
cnt1+=1;
|
||||||
|
}
|
||||||
|
if(Integer.parseInt(scheduleEndHourInput.getText().toString())<0 || Integer.parseInt(scheduleEndHourInput.getText().toString())>24){
|
||||||
|
Toast.makeText(this, "结束时输入不合法", Toast.LENGTH_SHORT).show();
|
||||||
|
cnt1+=1;
|
||||||
|
}
|
||||||
|
if(Integer.parseInt(scheduleEndMinInput.getText().toString())<0 || Integer.parseInt(scheduleEndMinInput.getText().toString())>60){
|
||||||
|
Toast.makeText(this, "结束分输入不合法", Toast.LENGTH_SHORT).show();
|
||||||
|
cnt1+=1;
|
||||||
|
}
|
||||||
|
if(cnt1==0){
|
||||||
|
cnt=1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
cnt = 1;
|
||||||
|
}
|
||||||
|
if(cnt==1) {
|
||||||
|
//第一个参数是表中的列名
|
||||||
|
values.put("scheduleName", scheduleNameInput.getText().toString());
|
||||||
|
if (schedulePlaceInput.getText().toString().equals("")) {
|
||||||
|
values.put("ifSchedulePlace", 0);
|
||||||
|
} else {
|
||||||
|
values.put("ifSchedulePlace", 1);
|
||||||
|
}
|
||||||
|
if (scheduleStartHourInput.getText().toString().equals("") && scheduleStartMinInput.getText().toString().equals("")) {
|
||||||
|
values.put("ifStartTime", 0);
|
||||||
|
} else {
|
||||||
|
values.put("ifStartTime", 1);
|
||||||
|
}
|
||||||
|
if (scheduleEndHourInput.getText().toString().equals("") && scheduleEndMinInput.getText().toString().equals("")) {
|
||||||
|
values.put("ifEndTime", 0);
|
||||||
|
} else {
|
||||||
|
values.put("ifEndTime", 1);
|
||||||
|
}
|
||||||
|
values.put("schedulePlace", schedulePlaceInput.getText().toString());
|
||||||
|
values.put("startTime", scheduleStartHourInput.getText().toString() + ":" + scheduleStartMinInput.getText().toString());
|
||||||
|
values.put("endTime", scheduleEndHourInput.getText().toString() + ":" + scheduleEndMinInput.getText().toString());
|
||||||
|
values.put("time", date);
|
||||||
|
// myDatabase.insert("schedules", null, values);
|
||||||
|
myDatabase.update("schedules",values,"scheduleName=?",new String[]{scheduleName});
|
||||||
|
// Intent intent2 = new Intent(AddSchedule.this, MainActivity.class);
|
||||||
|
// startActivity(intent2);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteMySchedule() {
|
||||||
|
myDatabase.delete("schedules","scheduleName=?",new String[]{scheduleName});
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finish() {
|
||||||
|
setResult(Activity.RESULT_OK);
|
||||||
|
super.finish();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.diary.showme.diary.bean;
|
||||||
|
|
||||||
|
public class QuestionBean {
|
||||||
|
private String content;
|
||||||
|
private String tag;
|
||||||
|
private String category;
|
||||||
|
|
||||||
|
public QuestionBean(String content, String category, String tagz) {
|
||||||
|
this.content = content;
|
||||||
|
this.category = category;
|
||||||
|
this.tag = tagz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTag() {
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTag(String tag) {
|
||||||
|
this.tag = tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategory(String category) {
|
||||||
|
this.category = category;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
package com.diary.showme.diary.ui;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.diary.showme.Course.AddCourseActivity;
|
||||||
|
import com.diary.showme.Course.Course;
|
||||||
|
import com.diary.showme.Course.CourseActivity;
|
||||||
|
import com.diary.showme.R;
|
||||||
|
import com.diary.showme.diary.utils.AppManager;
|
||||||
|
|
||||||
|
|
||||||
|
public class CardActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private Button card1;
|
||||||
|
|
||||||
|
private Button card2;
|
||||||
|
|
||||||
|
private Button card3;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.card);
|
||||||
|
|
||||||
|
AppManager.getAppManager().addActivity(this);
|
||||||
|
card1 = findViewById(R.id.card1);
|
||||||
|
card2 = findViewById(R.id.card2);
|
||||||
|
card3 = findViewById(R.id.card3);
|
||||||
|
card1.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(CardActivity.this, AddDiaryActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
card2.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(CardActivity.this, AddDiaryActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
card3.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(CardActivity.this, AddDiaryActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void startActivity(Context context) {
|
||||||
|
Intent intent = new Intent(context, CardActivity.class);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
AppManager.getAppManager().findActivity(CardActivity.class);
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
package com.diary.showme.diary.ui;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.chanven.lib.cptr.PtrClassicFrameLayout;
|
||||||
|
import com.chanven.lib.cptr.PtrDefaultHandler;
|
||||||
|
import com.chanven.lib.cptr.PtrFrameLayout;
|
||||||
|
import com.chanven.lib.cptr.recyclerview.RecyclerAdapterWithHF;
|
||||||
|
import com.diary.showme.R;
|
||||||
|
import com.diary.showme.diary.bean.QuestionBean;
|
||||||
|
import com.idealist.calendarview.SpaceItemDecoration;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class QuestionActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private Button back;
|
||||||
|
|
||||||
|
private RecyclerView question_view;
|
||||||
|
|
||||||
|
private QuestionAdapter questionAdapter;
|
||||||
|
|
||||||
|
private List<QuestionBean> mData = new ArrayList<>();
|
||||||
|
|
||||||
|
private RecyclerAdapterWithHF mQuestionAdapter;
|
||||||
|
|
||||||
|
private PtrClassicFrameLayout frameLayout;
|
||||||
|
|
||||||
|
private Handler handler;
|
||||||
|
|
||||||
|
private int page = 0;
|
||||||
|
|
||||||
|
private String date;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_question);
|
||||||
|
frameLayout = findViewById(R.id.question_frame);
|
||||||
|
handler = new Handler();
|
||||||
|
initBtn();
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initBtn() {
|
||||||
|
back = findViewById(R.id.back_calendar);
|
||||||
|
back.setOnClickListener(v -> finish());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
|
Intent intent = getIntent();
|
||||||
|
date = intent.getStringExtra("date");
|
||||||
|
|
||||||
|
question_view = findViewById(R.id.question_list);
|
||||||
|
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
||||||
|
question_view.setLayoutManager(layoutManager);
|
||||||
|
question_view.addItemDecoration(new SpaceItemDecoration(20));
|
||||||
|
|
||||||
|
mData.add(new QuestionBean("test", "curr", "test"));
|
||||||
|
mData.add(new QuestionBean("test", "curr", "test"));
|
||||||
|
mData.add(new QuestionBean("test", "curr", "test"));
|
||||||
|
mData.add(new QuestionBean("test", "curr", "test"));
|
||||||
|
mData.add(new QuestionBean("test", "curr", "test"));
|
||||||
|
mData.add(new QuestionBean("test", "curr", "test"));
|
||||||
|
mData.add(new QuestionBean("test", "curr", "test"));
|
||||||
|
mData.add(new QuestionBean("test", "curr", "test"));
|
||||||
|
|
||||||
|
questionAdapter = new QuestionAdapter(this, mData);
|
||||||
|
mQuestionAdapter = new RecyclerAdapterWithHF(questionAdapter);
|
||||||
|
question_view.setAdapter(mQuestionAdapter);
|
||||||
|
|
||||||
|
frameLayout.postDelayed(() -> frameLayout.autoRefresh(true), 150);
|
||||||
|
|
||||||
|
frameLayout.setPtrHandler(new PtrDefaultHandler() {
|
||||||
|
@Override
|
||||||
|
public void onRefreshBegin(PtrFrameLayout frame) {
|
||||||
|
handler.postDelayed(() -> {
|
||||||
|
page = 0;
|
||||||
|
mData.clear();
|
||||||
|
for (int i=0; i<10; i++) {
|
||||||
|
mData.add(new QuestionBean("test", "curr", "test"));
|
||||||
|
}
|
||||||
|
mQuestionAdapter.notifyDataSetChanged();
|
||||||
|
frameLayout.refreshComplete();
|
||||||
|
frameLayout.setLoadMoreEnable(true);
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
frameLayout.setOnLoadMoreListener(() -> handler.postDelayed(() -> {
|
||||||
|
mData.add(new QuestionBean("test", "curr", "test"));
|
||||||
|
mQuestionAdapter.notifyDataSetChanged();
|
||||||
|
frameLayout.loadMoreComplete(true);
|
||||||
|
page++;
|
||||||
|
Toast.makeText(QuestionActivity.this, "loading more complete", Toast.LENGTH_SHORT).show();
|
||||||
|
}, 1000));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.diary.showme.diary.ui;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.diary.showme.R;
|
||||||
|
import com.diary.showme.diary.bean.QuestionBean;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class QuestionAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements View.OnClickListener {
|
||||||
|
private Context context;
|
||||||
|
private List<QuestionBean> items;
|
||||||
|
|
||||||
|
public QuestionAdapter(Context context, List<QuestionBean> items) {
|
||||||
|
super();
|
||||||
|
this.items = items;
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View view = LayoutInflater.from(context).inflate(R.layout.question_item, parent, false);
|
||||||
|
return new QuestionViewHolder(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
|
if (!(holder instanceof QuestionViewHolder))
|
||||||
|
return;
|
||||||
|
QuestionBean item = items.get(position);
|
||||||
|
((QuestionViewHolder) holder).question_content.setText(item.getContent());
|
||||||
|
((QuestionViewHolder) holder).question_content.setOnClickListener(this::onClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return items.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(context, AddDiaryActivity.class);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.diary.showme.diary.ui;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.diary.showme.R;
|
||||||
|
|
||||||
|
public class QuestionViewHolder extends RecyclerView.ViewHolder{
|
||||||
|
public TextView question_content;
|
||||||
|
|
||||||
|
public QuestionViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
question_content = itemView.findViewById(R.id.question_content);
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue