@ -1,21 +0,0 @@
|
|||||||
# ---> Vim
|
|
||||||
# Swap
|
|
||||||
[._]*.s[a-v][a-z]
|
|
||||||
!*.svg # comment out if you don't need vector files
|
|
||||||
[._]*.sw[a-p]
|
|
||||||
[._]s[a-rt-v][a-z]
|
|
||||||
[._]ss[a-gi-z]
|
|
||||||
[._]sw[a-p]
|
|
||||||
|
|
||||||
# Session
|
|
||||||
Session.vim
|
|
||||||
Sessionx.vim
|
|
||||||
|
|
||||||
# Temporary
|
|
||||||
.netrwhist
|
|
||||||
*~
|
|
||||||
# Auto-generated tag files
|
|
||||||
tags
|
|
||||||
# Persistent undo
|
|
||||||
[._]*.un~
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
|||||||
GCC RUNTIME LIBRARY EXCEPTION
|
|
||||||
|
|
||||||
Version 3.1, 31 March 2009
|
|
||||||
|
|
||||||
General information: http://www.gnu.org/licenses/gcc-exception.html
|
|
||||||
|
|
||||||
Copyright (C) 2009 Free Software Foundation, Inc. <http://fsf.org/>
|
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
This GCC Runtime Library Exception ("Exception") is an additional permission under section 7 of the GNU General Public License, version 3 ("GPLv3"). It applies to a given file (the "Runtime Library") that bears a notice placed by the copyright holder of the file stating that the file is governed by GPLv3 along with this Exception.
|
|
||||||
|
|
||||||
When you use GCC to compile a program, GCC may combine portions of certain GCC header files and runtime libraries with the compiled program. The purpose of this Exception is to allow compilation of non-GPL (including proprietary) programs to use, in this way, the header files and runtime libraries covered by this Exception.
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
A file is an "Independent Module" if it either requires the Runtime Library for execution after a Compilation Process, or makes use of an interface provided by the Runtime Library, but is not otherwise based on the Runtime Library.
|
|
||||||
|
|
||||||
"GCC" means a version of the GNU Compiler Collection, with or without modifications, governed by version 3 (or a specified later version) of the GNU General Public License (GPL) with the option of using any subsequent versions published by the FSF.
|
|
||||||
|
|
||||||
"GPL-compatible Software" is software whose conditions of propagation, modification and use would permit combination with GCC in accord with the license of GCC.
|
|
||||||
|
|
||||||
"Target Code" refers to output from any compiler for a real or virtual target processor architecture, in executable form or suitable for input to an assembler, loader, linker and/or execution phase. Notwithstanding that, Target Code does not include data in any format that is used as a compiler intermediate representation, or used for producing a compiler intermediate representation.
|
|
||||||
|
|
||||||
The "Compilation Process" transforms code entirely represented in non-intermediate languages designed for human-written code, and/or in Java Virtual Machine byte code, into Target Code. Thus, for example, use of source code generators and preprocessors need not be considered part of the Compilation Process, since the Compilation Process can be understood as starting with the output of the generators or preprocessors.
|
|
||||||
|
|
||||||
A Compilation Process is "Eligible" if it is done using GCC, alone or with other GPL-compatible software, or if it is done without using any work based on GCC. For example, using non-GPL-compatible Software to optimize any GCC intermediate representations would not qualify as an Eligible Compilation Process.
|
|
||||||
|
|
||||||
1. Grant of Additional Permission.
|
|
||||||
|
|
||||||
You have permission to propagate a work of Target Code formed by combining the Runtime Library with Independent Modules, even if such propagation would otherwise violate the terms of GPLv3, provided that all Target Code was generated by Eligible Compilation Processes. You may then convey such a combination under terms of your choice, consistent with the licensing of the Independent Modules.
|
|
||||||
|
|
||||||
2. No Weakening of GCC Copyleft.
|
|
||||||
|
|
||||||
The availability of this Exception does not imply any general presumption that third-party software is unaffected by the copyleft requirements of the license of GCC.
|
|
@ -1,19 +0,0 @@
|
|||||||
#### 从命令行创建一个新的仓库
|
|
||||||
|
|
||||||
```bash
|
|
||||||
touch README.md
|
|
||||||
git init
|
|
||||||
git add README.md
|
|
||||||
git commit -m "first commit"
|
|
||||||
git remote add origin https://bdgit.educoder.net/p28679143/ShowMe.git
|
|
||||||
git push -u origin master
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 从命令行推送已经创建的仓库
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git remote add origin https://bdgit.educoder.net/p28679143/ShowMe.git
|
|
||||||
git push -u origin master
|
|
||||||
|
|
||||||
```
|
|
@ -1,15 +0,0 @@
|
|||||||
*.iml
|
|
||||||
.gradle
|
|
||||||
/local.properties
|
|
||||||
/.idea/caches
|
|
||||||
/.idea/libraries
|
|
||||||
/.idea/modules.xml
|
|
||||||
/.idea/workspace.xml
|
|
||||||
/.idea/navEditor.xml
|
|
||||||
/.idea/assetWizardSettings.xml
|
|
||||||
.DS_Store
|
|
||||||
/build
|
|
||||||
/captures
|
|
||||||
.externalNativeBuild
|
|
||||||
.cxx
|
|
||||||
local.properties
|
|
@ -1,3 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
@ -1 +0,0 @@
|
|||||||
My Application
|
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="CompilerConfiguration">
|
|
||||||
<bytecodeTargetLevel target="11" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
|
||||||
<component name="GradleSettings">
|
|
||||||
<option name="linkedExternalProjectsSettings">
|
|
||||||
<GradleProjectSettings>
|
|
||||||
<option name="testRunner" value="PLATFORM" />
|
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
|
||||||
<option name="gradleJvm" value="1.8" />
|
|
||||||
<option name="modules">
|
|
||||||
<set>
|
|
||||||
<option value="$PROJECT_DIR$" />
|
|
||||||
<option value="$PROJECT_DIR$/CalendarView" />
|
|
||||||
<option value="$PROJECT_DIR$/DataBase" />
|
|
||||||
<option value="$PROJECT_DIR$/app" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
|
||||||
<option name="useQualifiedModuleNames" value="true" />
|
|
||||||
</GradleProjectSettings>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1,25 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="RemoteRepositoriesConfiguration">
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="central" />
|
|
||||||
<option name="name" value="Maven Central repository" />
|
|
||||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="jboss.community" />
|
|
||||||
<option name="name" value="JBoss Community repository" />
|
|
||||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="BintrayJCenter" />
|
|
||||||
<option name="name" value="BintrayJCenter" />
|
|
||||||
<option name="url" value="https://jcenter.bintray.com/" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="Google" />
|
|
||||||
<option name="name" value="Google" />
|
|
||||||
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
|
||||||
</remote-repository>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -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>
|
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1 +0,0 @@
|
|||||||
/build
|
|
@ -1,39 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'com.android.library'
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
compileSdkVersion 30
|
|
||||||
buildToolsVersion "30.0.3"
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
minSdkVersion 29
|
|
||||||
targetSdkVersion 30
|
|
||||||
versionCode 1
|
|
||||||
versionName "1.0"
|
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
||||||
consumerProguardFiles "consumer-rules.pro"
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
|
|
||||||
implementation 'androidx.appcompat:appcompat:1.3.0'
|
|
||||||
implementation 'com.google.android.material:material:1.3.0'
|
|
||||||
implementation project(path: ':DataBase')
|
|
||||||
testImplementation 'junit:junit:4.+'
|
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
# Add project specific ProGuard rules here.
|
|
||||||
# You can control the set of applied configuration files using the
|
|
||||||
# proguardFiles setting in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
|
|
||||||
# Uncomment this to preserve the line number information for
|
|
||||||
# debugging stack traces.
|
|
||||||
#-keepattributes SourceFile,LineNumberTable
|
|
||||||
|
|
||||||
# If you keep the line number information, uncomment this to
|
|
||||||
# hide the original source file name.
|
|
||||||
#-renamesourcefileattribute SourceFile
|
|
@ -1,26 +0,0 @@
|
|||||||
package com.idealist.calendarview;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.test.platform.app.InstrumentationRegistry;
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instrumented test, which will execute on an Android device.
|
|
||||||
*
|
|
||||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
|
||||||
*/
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class ExampleInstrumentedTest {
|
|
||||||
@Test
|
|
||||||
public void useAppContext() {
|
|
||||||
// Context of the app under test.
|
|
||||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
|
||||||
assertEquals("com.idealist.calendarview.test", appContext.getPackageName());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
package="com.idealist.calendarview">
|
|
||||||
|
|
||||||
</manifest>
|
|
@ -1,85 +0,0 @@
|
|||||||
package com.idealist.calendarview;
|
|
||||||
|
|
||||||
public class CalendarAttr {
|
|
||||||
|
|
||||||
static int RecTop;
|
|
||||||
|
|
||||||
private int mItemHeight;
|
|
||||||
|
|
||||||
private int mRowCount;
|
|
||||||
|
|
||||||
private int mViewHeight;
|
|
||||||
|
|
||||||
private int mCalendarType;
|
|
||||||
|
|
||||||
private int mTextSize;
|
|
||||||
|
|
||||||
private int mScrollLevel;
|
|
||||||
|
|
||||||
private int TouchSlop;
|
|
||||||
|
|
||||||
public CalendarAttr() {
|
|
||||||
mItemHeight = State.DEFAULT_ITEM_HEIGHT;
|
|
||||||
mTextSize = State.DEFAULT_TEXT_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRowCount() {
|
|
||||||
return mRowCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setRowCount(int mRowCount) {
|
|
||||||
this.mRowCount = mRowCount;
|
|
||||||
mViewHeight = mItemHeight * mRowCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getItemHeight() {
|
|
||||||
return mItemHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItemHeight(int mItemHeight) {
|
|
||||||
this.mItemHeight = mItemHeight;
|
|
||||||
mViewHeight = mRowCount * mItemHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getViewHeight() {
|
|
||||||
return mViewHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setViewHeight(int mViewHeight) {
|
|
||||||
this.mViewHeight = mViewHeight;
|
|
||||||
mItemHeight = mViewHeight / mRowCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTextSize() {
|
|
||||||
return mTextSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTextSize(int mTextSize) {
|
|
||||||
this.mTextSize = mTextSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCalendarType() {
|
|
||||||
return mCalendarType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCalendarType(int mCalendarType) {
|
|
||||||
this.mCalendarType = mCalendarType;
|
|
||||||
setRowCount((mCalendarType == State.VIEW_WEEK) ? 1 : 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getRecTop() {
|
|
||||||
return RecTop;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setRecTop(int recTop) {
|
|
||||||
RecTop = recTop;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getScrollLevel() {
|
|
||||||
return mScrollLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setScrollLevel(int mScrollLevel) {
|
|
||||||
this.mScrollLevel = mScrollLevel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,97 +0,0 @@
|
|||||||
package com.idealist.calendarview;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
public class CalendarDay {
|
|
||||||
private int year;
|
|
||||||
|
|
||||||
private int month;
|
|
||||||
|
|
||||||
private int day;
|
|
||||||
|
|
||||||
private boolean isCurrDay;
|
|
||||||
|
|
||||||
private boolean markSchedule;
|
|
||||||
|
|
||||||
private int mMonthState;
|
|
||||||
|
|
||||||
private int mSelectState;
|
|
||||||
|
|
||||||
public CalendarDay() {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getYear() {
|
|
||||||
return year;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setYear(int year) {
|
|
||||||
this.year = year;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMonth() {
|
|
||||||
return month;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMonth(int month) {
|
|
||||||
this.month = month;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDay() {
|
|
||||||
return day;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDay(int day) {
|
|
||||||
this.day = day;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCurrDay() {
|
|
||||||
return isCurrDay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrDay(boolean currDay) {
|
|
||||||
this.isCurrDay = currDay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMonthState() {
|
|
||||||
return mMonthState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMonthState(int mMonthState) {
|
|
||||||
this.mMonthState = mMonthState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSelectState() {
|
|
||||||
return mSelectState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelectState(int mSelectState) {
|
|
||||||
this.mSelectState = mSelectState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMarkSchedule() {
|
|
||||||
return markSchedule;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMarkSchedule(boolean markSchedule) {
|
|
||||||
this.markSchedule = markSchedule;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(@Nullable Object obj) {
|
|
||||||
if (obj instanceof CalendarDay) {
|
|
||||||
return ((CalendarDay) obj).day == this.day && ((CalendarDay) obj).month == this.month &&
|
|
||||||
((CalendarDay) obj).year == this.year;
|
|
||||||
}
|
|
||||||
return super.equals(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return this.year + "-" + this.month + "-" + this.day;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,152 +0,0 @@
|
|||||||
package com.idealist.calendarview;
|
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|
||||||
import androidx.viewpager.widget.PagerAdapter;
|
|
||||||
import androidx.viewpager.widget.ViewPager;
|
|
||||||
|
|
||||||
@CoordinatorLayout.DefaultBehavior(CalendarPagerBehavior.class)
|
|
||||||
public class CalendarPager extends ViewPager {
|
|
||||||
|
|
||||||
private CalendarAttr attr;
|
|
||||||
|
|
||||||
private OnPageChangeListener mOnPageChangeListener;
|
|
||||||
|
|
||||||
public static int CURRENT_DAY_INDEX = 1000;
|
|
||||||
|
|
||||||
private int mCurrPosition = CURRENT_DAY_INDEX;
|
|
||||||
|
|
||||||
private int pageScrollState = ViewPager.SCROLL_STATE_IDLE;
|
|
||||||
|
|
||||||
public CalendarPager(Context context) {
|
|
||||||
super(context, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CalendarPager(@NonNull Context context, @Nullable AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
initPager();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initPager() {
|
|
||||||
ViewPager.OnPageChangeListener pageChangeListener = new ViewPager.OnPageChangeListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageSelected(int position) {
|
|
||||||
mCurrPosition = position;
|
|
||||||
if (mOnPageChangeListener != null) {
|
|
||||||
CalendarViewAdapter adapter = (CalendarViewAdapter) getAdapter();
|
|
||||||
assert adapter != null;
|
|
||||||
adapter.updateViewByScrollHorizontally(position);
|
|
||||||
mOnPageChangeListener.onPageSelected(position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageScrollStateChanged(int state) {
|
|
||||||
pageScrollState = state;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
addOnPageChangeListener(pageChangeListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAttr(CalendarAttr attr) {
|
|
||||||
this.attr = attr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAdapter(@Nullable PagerAdapter adapter) {
|
|
||||||
super.setAdapter(adapter);
|
|
||||||
setCurrentItem(1000);
|
|
||||||
mCurrPosition = 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
||||||
if (attr != null && attr.getCalendarType() == State.VIEW_FULL) {
|
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int height = 0xffffff;
|
|
||||||
for (int i = 0; i < getChildCount(); i++) {
|
|
||||||
View child = getChildAt(i);
|
|
||||||
child.measure(widthMeasureSpec,
|
|
||||||
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
|
|
||||||
int h = child.getMeasuredHeight();
|
|
||||||
height = Math.min(h, height);
|
|
||||||
}
|
|
||||||
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
|
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setmOnPageChangeListener(OnPageChangeListener mOnPageChangeListener) {
|
|
||||||
this.mOnPageChangeListener = mOnPageChangeListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectOtherMonth(int offset) {
|
|
||||||
CalendarViewAdapter adapter = (CalendarViewAdapter) getAdapter();
|
|
||||||
adapter.saveSelectedDate();
|
|
||||||
adapter.updateDayInViewState(mCurrPosition + offset);
|
|
||||||
setCurrentItem(mCurrPosition + offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getViewHeight() {
|
|
||||||
return attr.getViewHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getItemHeight() {
|
|
||||||
return attr.getItemHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getScrollLevel() {
|
|
||||||
return attr.getScrollLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setScrollLevel(int scrollLevel) {
|
|
||||||
attr.setScrollLevel(scrollLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPageScrollState() {
|
|
||||||
return pageScrollState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPageScrollState(int pageScrollState) {
|
|
||||||
this.pageScrollState = pageScrollState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CalendarAttr getAttr() {
|
|
||||||
return attr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getmCurrPosition() {
|
|
||||||
return mCurrPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 月视图到周视图可向上滑动距离距离
|
|
||||||
*a
|
|
||||||
* @return 距离
|
|
||||||
*/
|
|
||||||
public int getTopMovableDistance() {
|
|
||||||
CalendarViewAdapter adapter = (CalendarViewAdapter) getAdapter();
|
|
||||||
assert adapter != null;
|
|
||||||
return attr.getItemHeight() * (CalendarUtils.getWeekOfMonth(adapter.getSelectDay()) - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface OnPageChangeListener {
|
|
||||||
void onPageScrolled(int position, float positionOffset, int positionOffsetPixels);
|
|
||||||
|
|
||||||
void onPageSelected(int position);
|
|
||||||
|
|
||||||
void onPageScrollStateChanged(int state);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,182 +0,0 @@
|
|||||||
package com.idealist.calendarview;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import static android.content.ContentValues.TAG;
|
|
||||||
|
|
||||||
public class CalendarPagerBehavior extends CoordinatorLayout.Behavior<CalendarPager> {
|
|
||||||
private int mTop = 0;
|
|
||||||
private int touchSlop = 1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean layoutDependsOn(@NonNull CoordinatorLayout parent, @NonNull CalendarPager child, @NonNull View dependency) {
|
|
||||||
return dependency instanceof RecyclerView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onLayoutChild(@NonNull CoordinatorLayout parent, @NonNull CalendarPager child, int layoutDirection) {
|
|
||||||
parent.onLayoutChild(child, layoutDirection);
|
|
||||||
child.offsetTopAndBottom(mTop);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int confirm = 0;
|
|
||||||
private float downX, downY, lastY, lastTop;
|
|
||||||
private boolean isVerticalScroll;
|
|
||||||
private boolean directionUpa;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onTouchEvent(@NonNull CoordinatorLayout parent, @NonNull CalendarPager child, @NonNull MotionEvent ev) {
|
|
||||||
if (downY > lastTop) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Log.i(TAG, "onTouchEvent: onTouchEvent");
|
|
||||||
switch (ev.getAction()) {
|
|
||||||
case MotionEvent.ACTION_DOWN:
|
|
||||||
break;
|
|
||||||
case MotionEvent.ACTION_MOVE:
|
|
||||||
if (isVerticalScroll) {
|
|
||||||
directionUpa = ev.getY() < lastY;
|
|
||||||
if (child.getScrollLevel() == State.LEVEL_TOP) {
|
|
||||||
CalendarAttr.setRecTop(State.DEFAULT_ITEM_HEIGHT + (int) (ev.getY() - downY));
|
|
||||||
CalendarUtils.scroll(parent.getChildAt(1), (int) (lastY - ev.getY()),
|
|
||||||
State.DEFAULT_ITEM_HEIGHT, State.DEFAULT_ITEM_HEIGHT * 6);
|
|
||||||
} else if (child.getScrollLevel() == State.LEVEL_MEDIUM) {
|
|
||||||
CalendarAttr.setRecTop(State.DEFAULT_ITEM_HEIGHT * 6 + (int) (ev.getY() - downY));
|
|
||||||
if (directionUpa) {
|
|
||||||
CalendarUtils.scroll(parent.getChildAt(1), (int) (lastY - ev.getY()),
|
|
||||||
State.DEFAULT_ITEM_HEIGHT, State.DEFAULT_ITEM_HEIGHT * 6);
|
|
||||||
} else {
|
|
||||||
CalendarUtils.scroll(parent.getChildAt(1), (int) (lastY - ev.getY()),
|
|
||||||
State.DEFAULT_ITEM_HEIGHT * 6, State.DEFAULT_ITEM_HEIGHT_FULL * 6);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
CalendarAttr.setRecTop(child.getViewHeight() + (int) (ev.getY() - downY));
|
|
||||||
CalendarUtils.scroll(parent.getChildAt(1), (int) (lastY - ev.getY()),
|
|
||||||
State.DEFAULT_ITEM_HEIGHT * 6, State.DEFAULT_ITEM_HEIGHT_FULL * 6);
|
|
||||||
}
|
|
||||||
lastY = ev.getY();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MotionEvent.ACTION_UP:
|
|
||||||
if (isVerticalScroll) {
|
|
||||||
CalendarViewAdapter adapter = (CalendarViewAdapter) child.getAdapter();
|
|
||||||
if (adapter != null) {
|
|
||||||
if (directionUpa) {
|
|
||||||
if (adapter.getCalendarType() == State.VIEW_MONTH) {
|
|
||||||
child.setScrollLevel(State.LEVEL_TOP);
|
|
||||||
adapter.changeCalendarType(State.VIEW_WEEK);
|
|
||||||
CalendarUtils.scrollTo(parent, (RecyclerView) parent.getChildAt(1),
|
|
||||||
State.DEFAULT_ITEM_HEIGHT, 300);
|
|
||||||
} else if (adapter.getCalendarType() == State.VIEW_FULL) {
|
|
||||||
child.setScrollLevel(State.LEVEL_MEDIUM);
|
|
||||||
adapter.changeCalendarType(State.VIEW_MONTH);
|
|
||||||
CalendarUtils.scrollTo(parent, (RecyclerView) parent.getChildAt(1),
|
|
||||||
State.DEFAULT_ITEM_HEIGHT * 6, 300);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (adapter.getCalendarType() == State.VIEW_WEEK) {
|
|
||||||
child.setScrollLevel(State.LEVEL_MEDIUM);
|
|
||||||
adapter.changeCalendarType(State.VIEW_MONTH);
|
|
||||||
CalendarUtils.scrollTo(parent, (RecyclerView) parent.getChildAt(1),
|
|
||||||
State.DEFAULT_ITEM_HEIGHT * 6, 300);
|
|
||||||
} else if (adapter.getCalendarType() == State.VIEW_MONTH) {
|
|
||||||
child.setScrollLevel(State.LEVEL_BOTTOM);
|
|
||||||
adapter.changeCalendarType(State.VIEW_FULL);
|
|
||||||
CalendarUtils.scrollTo(parent, (RecyclerView) parent.getChildAt(1),
|
|
||||||
State.DEFAULT_ITEM_HEIGHT_FULL * 6, 300);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
isVerticalScroll = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
isVerticalScroll = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onInterceptTouchEvent(@NonNull CoordinatorLayout parent, @NonNull CalendarPager child, @NonNull MotionEvent ev) {
|
|
||||||
Log.i(TAG, "onInterceptTouchEvent: Try to intercept!" + isVerticalScroll);
|
|
||||||
switch (ev.getAction()) {
|
|
||||||
case MotionEvent.ACTION_DOWN:
|
|
||||||
downX = ev.getX();
|
|
||||||
downY = ev.getY();
|
|
||||||
lastTop = CalendarAttr.getRecTop();
|
|
||||||
lastY = downY;
|
|
||||||
break;
|
|
||||||
case MotionEvent.ACTION_MOVE:
|
|
||||||
if (downY > lastTop) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (Math.abs(ev.getY() - downY) > 25 && Math.abs(ev.getX() - downX) <= 25 && !isVerticalScroll) {
|
|
||||||
isVerticalScroll = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MotionEvent.ACTION_UP:
|
|
||||||
if (isVerticalScroll) {
|
|
||||||
isVerticalScroll = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return isVerticalScroll;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int dependencyViewTop = -1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onDependentViewChanged(@NonNull CoordinatorLayout parent, @NonNull CalendarPager child, @NonNull View dependency) {
|
|
||||||
Log.i(TAG, "onDependentViewChanged: !");
|
|
||||||
CalendarViewAdapter adapter = (CalendarViewAdapter) child.getAdapter();
|
|
||||||
|
|
||||||
if (dependencyViewTop != -1) {
|
|
||||||
int dy = dependency.getTop() - dependencyViewTop;
|
|
||||||
int top = child.getTop();
|
|
||||||
|
|
||||||
if (dy > touchSlop) {
|
|
||||||
assert adapter != null;
|
|
||||||
adapter.changeCalendarType(State.VIEW_MONTH);
|
|
||||||
} else if (dy < -touchSlop) {
|
|
||||||
assert adapter != null;
|
|
||||||
adapter.changeCalendarType(State.VIEW_WEEK);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dy > -top)
|
|
||||||
dy = -top;
|
|
||||||
|
|
||||||
if (dy < -top - child.getTopMovableDistance()) {
|
|
||||||
dy = -top - child.getTopMovableDistance();
|
|
||||||
}
|
|
||||||
|
|
||||||
child.offsetTopAndBottom(dy);
|
|
||||||
// adapter.changeCalendarType(State.VIEW_WEEK);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dependencyViewTop > child.getItemHeight() - 24
|
|
||||||
&& dependencyViewTop < child.getItemHeight() + 24
|
|
||||||
&& mTop > -touchSlop - child.getTopMovableDistance()
|
|
||||||
&& mTop < touchSlop - child.getTopMovableDistance()) {
|
|
||||||
child.setScrollLevel(State.LEVEL_TOP);
|
|
||||||
adapter.changeCalendarType(State.VIEW_WEEK);
|
|
||||||
}
|
|
||||||
if (dependencyViewTop > child.getViewHeight() - 24
|
|
||||||
&& dependencyViewTop < child.getViewHeight() + 24
|
|
||||||
&& mTop < touchSlop
|
|
||||||
&& mTop > -touchSlop) {
|
|
||||||
child.setScrollLevel(State.LEVEL_MEDIUM);
|
|
||||||
adapter.changeCalendarType(State.VIEW_MONTH);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,272 +0,0 @@
|
|||||||
package com.idealist.calendarview;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import com.idealist.calendarview.interf.OnSelectDateListener;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CalendarView extends View implements View.OnLongClickListener {
|
|
||||||
|
|
||||||
private CalendarViewAdapter adapter;
|
|
||||||
|
|
||||||
private CalendarAttr attr;
|
|
||||||
|
|
||||||
private int mItemHeight;
|
|
||||||
|
|
||||||
private int mItemWidth;
|
|
||||||
|
|
||||||
private int mViewHeight;
|
|
||||||
|
|
||||||
private int mBaseLine;
|
|
||||||
|
|
||||||
private boolean isClick;
|
|
||||||
|
|
||||||
private boolean isScroll;
|
|
||||||
|
|
||||||
private int mTextSize;
|
|
||||||
|
|
||||||
private int mCurrItem;
|
|
||||||
|
|
||||||
private int mRowCount;
|
|
||||||
|
|
||||||
MotionEvent event;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 点击坐标
|
|
||||||
*/
|
|
||||||
private float mX, mY;
|
|
||||||
|
|
||||||
private List<CalendarDay> items = new ArrayList<>();
|
|
||||||
|
|
||||||
private CalendarDay seedDay;
|
|
||||||
|
|
||||||
private OnSelectDateListener onSelectDateListener;
|
|
||||||
|
|
||||||
private OnCalendarClickListener clickListener;
|
|
||||||
|
|
||||||
public CalendarView(Context context,
|
|
||||||
CalendarAttr attr,
|
|
||||||
CalendarViewAdapter adapter,
|
|
||||||
OnSelectDateListener onSelectDateListener,
|
|
||||||
OnCalendarClickListener clickListener) {
|
|
||||||
super(context);
|
|
||||||
this.attr = attr;
|
|
||||||
this.adapter = adapter;
|
|
||||||
this.clickListener = clickListener;
|
|
||||||
this.onSelectDateListener = onSelectDateListener;
|
|
||||||
this.setOnLongClickListener(this);
|
|
||||||
initView();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化 View
|
|
||||||
*/
|
|
||||||
private void initView() {
|
|
||||||
mRowCount = attr.getRowCount();
|
|
||||||
mViewHeight = attr.getViewHeight();
|
|
||||||
mItemHeight = attr.getItemHeight();
|
|
||||||
mTextSize = attr.getTextSize();
|
|
||||||
mBaseLine = (int) (mTextSize + mItemHeight) / 2;
|
|
||||||
mCurrItem = CalendarUtils.getIndexOfCurrDay(State.VIEW_MONTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 为对应视图生成对应日历项, 以SeedDay为对应
|
|
||||||
*/
|
|
||||||
final int generateItem() {
|
|
||||||
if (attr.getCalendarType() != State.VIEW_WEEK)
|
|
||||||
items = CalendarUtils.generateItemForMonthView(seedDay.getYear(), seedDay.getMonth());
|
|
||||||
else
|
|
||||||
items = CalendarUtils.generateItemForWeekView(seedDay.getYear(), seedDay.getMonth(), seedDay.getDay());
|
|
||||||
return items.indexOf(seedDay);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 当视图变化时变化 UI
|
|
||||||
*/
|
|
||||||
public void changeViewType() {
|
|
||||||
if (attr.getCalendarType() == State.VIEW_FULL) {
|
|
||||||
attr.setItemHeight(State.DEFAULT_ITEM_HEIGHT_FULL);
|
|
||||||
} else {
|
|
||||||
attr.setItemHeight(State.DEFAULT_ITEM_HEIGHT);
|
|
||||||
}
|
|
||||||
mItemHeight = attr.getItemHeight();
|
|
||||||
mViewHeight = attr.getViewHeight();
|
|
||||||
setViewHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
||||||
mCurrItem = generateItem();
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateView() {
|
|
||||||
mCurrItem = generateItem();
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public CalendarDay getSeedDay() {
|
|
||||||
return seedDay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSeedDay(CalendarDay seedDay) {
|
|
||||||
this.seedDay = seedDay;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
||||||
if (attr.getCalendarType() != State.VIEW_FULL) {
|
|
||||||
setMeasuredDimension(widthMeasureSpec, mViewHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
|
||||||
@Override
|
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
|
||||||
float touchX = event.getX();
|
|
||||||
float touchY = event.getY();
|
|
||||||
int action = event.getAction();
|
|
||||||
float disX, disY;
|
|
||||||
switch (action) {
|
|
||||||
case MotionEvent.ACTION_DOWN:
|
|
||||||
mX = touchX;
|
|
||||||
mY = touchY;
|
|
||||||
isClick = true;
|
|
||||||
break;
|
|
||||||
case MotionEvent.ACTION_MOVE:
|
|
||||||
disX = touchX - mX;
|
|
||||||
disY = touchY - mY;
|
|
||||||
if (Math.abs(disX) > 2 * mItemWidth || Math.abs(disY) > 2 * mItemHeight) {
|
|
||||||
isScroll = true;
|
|
||||||
}
|
|
||||||
isClick = false;
|
|
||||||
break;
|
|
||||||
case MotionEvent.ACTION_UP:
|
|
||||||
if (isClick) {
|
|
||||||
items.get(mCurrItem).setSelectState(State.DAY_UN_SELECT);
|
|
||||||
mCurrItem = getIndexOnView();
|
|
||||||
adapter.setSelectDay(items.get(mCurrItem));
|
|
||||||
if (items.get(mCurrItem).getMonthState() != State.DAY_CURR_MONTH) {
|
|
||||||
items.get(mCurrItem).setSelectState(State.DAY_UN_SELECT);
|
|
||||||
onSelectDateListener.onSelectOtherMonth(items.get(mCurrItem).getMonthState());
|
|
||||||
mCurrItem = 0;
|
|
||||||
} else {
|
|
||||||
items.get(mCurrItem).setSelectState(State.DAY_SELECT);
|
|
||||||
}
|
|
||||||
if (adapter.getSelectDay().isMarkSchedule()) {
|
|
||||||
clickListener.OnClick(adapter.getSelectDay());
|
|
||||||
}
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return super.onTouchEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CalendarDay> getItems() {
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItems(List<CalendarDay> items) {
|
|
||||||
this.items = items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setmCurrItem(int mCurrItem) {
|
|
||||||
this.mCurrItem = mCurrItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getIndexOnView() {
|
|
||||||
int indexX = (int) mX / mItemWidth;
|
|
||||||
int indexY = (int) mY / mItemHeight;
|
|
||||||
int position = -1;
|
|
||||||
if (isClick) {
|
|
||||||
if (indexX > 6) indexX = 6;
|
|
||||||
position = 7 * indexY + indexX;
|
|
||||||
}
|
|
||||||
if (position > 41)
|
|
||||||
position = 41;
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDraw(Canvas canvas) {
|
|
||||||
mItemWidth = getWidth() / 7;
|
|
||||||
mItemHeight = attr.getItemHeight();
|
|
||||||
mRowCount = attr.getRowCount();
|
|
||||||
mBaseLine = (int) (mTextSize * 1.5);
|
|
||||||
int sW = mItemWidth / 2;
|
|
||||||
int sH = mBaseLine;
|
|
||||||
for (int i = 0; i < mRowCount; ++i) {
|
|
||||||
for (int j = 0; j < 7; ++j) {
|
|
||||||
draw(canvas, items.get(7 * i + j), sW + mItemWidth * j, sH + mItemHeight * i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void draw(Canvas canvas, CalendarDay day, int x, int y) {
|
|
||||||
onDrawText(canvas, day, x, y);
|
|
||||||
onDrawMark(canvas, day, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onDrawText(Canvas canvas, CalendarDay day, int x, int y) {
|
|
||||||
Paint paint = new Paint();
|
|
||||||
paint.setTextSize(mTextSize);
|
|
||||||
paint.setColor(Color.GRAY);
|
|
||||||
paint.setTextAlign(Paint.Align.CENTER);
|
|
||||||
// Log.e("View", day.toString());
|
|
||||||
if (day.isCurrDay()) {
|
|
||||||
paint.setColor(Color.BLUE);
|
|
||||||
} else if (day.getSelectState() == State.DAY_SELECT) {
|
|
||||||
paint.setColor(Color.GREEN);
|
|
||||||
} else if (day.getMonthState() == State.DAY_CURR_MONTH) {
|
|
||||||
paint.setColor(Color.BLACK);
|
|
||||||
}
|
|
||||||
canvas.drawText(Integer.toString(day.getDay()), x, y, paint);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onDrawMark(Canvas canvas, CalendarDay day, int x, int y) {
|
|
||||||
if (day.isMarkSchedule()) {
|
|
||||||
Paint paint = new Paint();
|
|
||||||
paint.setColor(Color.BLUE);
|
|
||||||
canvas.drawCircle(x, y+20, 10, paint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置 View 高度
|
|
||||||
*
|
|
||||||
* @param height 高度
|
|
||||||
*/
|
|
||||||
private void setViewHeight(int height) {
|
|
||||||
Log.e(null, "setViewHeight");
|
|
||||||
ViewGroup.LayoutParams params = (ViewGroup.LayoutParams) this.getLayoutParams();
|
|
||||||
params.height = height;
|
|
||||||
this.setLayoutParams(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onLongClick(View v) {
|
|
||||||
if (clickListener != null) {
|
|
||||||
clickListener.OnLongClick(adapter.getSelectDay());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface OnCalendarClickListener {
|
|
||||||
void OnClick(CalendarDay day);
|
|
||||||
void OnLongClick(CalendarDay day);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,188 +0,0 @@
|
|||||||
package com.idealist.calendarview;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.viewpager.widget.PagerAdapter;
|
|
||||||
|
|
||||||
import com.idealist.calendarview.interf.OnSelectDateListener;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CalendarViewAdapter extends PagerAdapter {
|
|
||||||
|
|
||||||
private CalendarAttr attr;
|
|
||||||
private List<CalendarView> mViews = new ArrayList<>();
|
|
||||||
private int mCurrPosition = CalendarPager.CURRENT_DAY_INDEX;
|
|
||||||
|
|
||||||
// 保存上一次点击的日期
|
|
||||||
private static CalendarDay mRecDate;
|
|
||||||
private CalendarDay mSelectDay;
|
|
||||||
private OnCalendarTypeChangeListener typeChangeListener;
|
|
||||||
|
|
||||||
public CalendarViewAdapter(Context context, CalendarAttr attr,
|
|
||||||
OnSelectDateListener dateListener,
|
|
||||||
CalendarView.OnCalendarClickListener longClickListener) {
|
|
||||||
super();
|
|
||||||
this.attr = attr;
|
|
||||||
initViewAdapter(context, dateListener, longClickListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void initViewAdapter(Context context, OnSelectDateListener dateListener,
|
|
||||||
CalendarView.OnCalendarClickListener longClickListener) {
|
|
||||||
mSelectDay = CalendarUtils.getCurrDay();
|
|
||||||
CalendarDay day;
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
CalendarView view = new CalendarView(context, attr, this, dateListener, longClickListener);
|
|
||||||
day = CalendarUtils.getNearMonthDay(mSelectDay, i - 1);
|
|
||||||
view.setSeedDay(day);
|
|
||||||
mViews.add(view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过滑动更新 View
|
|
||||||
*
|
|
||||||
* @param position 需要更新的 View 的 position
|
|
||||||
*/
|
|
||||||
public void updateViewByScrollHorizontally(int position) {
|
|
||||||
Log.e("adapter", "position: " + position + " mCurrPosition: " + mCurrPosition);
|
|
||||||
CalendarDay seedDay = mViews.get(position % 3).getSeedDay();
|
|
||||||
int offset = 0;
|
|
||||||
if (position > mCurrPosition) {
|
|
||||||
offset = 1;
|
|
||||||
} else if (position < mCurrPosition) {
|
|
||||||
offset = -1;
|
|
||||||
}
|
|
||||||
CalendarView view = mViews.get((position + offset) % 3);
|
|
||||||
//TODO 注意视图
|
|
||||||
if (attr.getCalendarType() != State.VIEW_WEEK)
|
|
||||||
view.setSeedDay(CalendarUtils.getNearMonthDay(seedDay, offset));
|
|
||||||
else
|
|
||||||
view.setSeedDay(CalendarUtils.getNearWeekDay(seedDay, offset));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getCalendarType() {
|
|
||||||
return attr.getCalendarType();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 当视图类型改变时更新 View 的显示模式
|
|
||||||
*
|
|
||||||
* @param updateType 更新的显示模式
|
|
||||||
*/
|
|
||||||
public void changeCalendarType(int updateType) {
|
|
||||||
attr.setCalendarType(updateType);
|
|
||||||
CalendarDay seedDay = mViews.get(mCurrPosition % 3).getSeedDay();
|
|
||||||
saveSelectedDate();
|
|
||||||
for (int i = -1; i < 2; ++i) {
|
|
||||||
CalendarView view = mViews.get((mCurrPosition + i) % 3);
|
|
||||||
if (updateType == State.VIEW_WEEK) {
|
|
||||||
view.setSeedDay(CalendarUtils.getNearWeekDay(mSelectDay, i));
|
|
||||||
} else {
|
|
||||||
view.setSeedDay(CalendarUtils.getNearMonthDay(mSelectDay, i));
|
|
||||||
}
|
|
||||||
view.changeViewType();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 由 pager 通知 adapter 发生点击事件更改,进行处理
|
|
||||||
// * @param day 选中 CalendarDay
|
|
||||||
// */
|
|
||||||
// public void notifyDataChanged() {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void saveSelectedDate() {
|
|
||||||
mRecDate = mSelectDay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CalendarDay loadSelectedDate() {
|
|
||||||
return mRecDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCount() {
|
|
||||||
// 实现无限循环
|
|
||||||
return Integer.MAX_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPrimaryItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
|
|
||||||
super.setPrimaryItem(container, position % 3, object);
|
|
||||||
this.mCurrPosition = position;
|
|
||||||
Log.e("adapterPri", Integer.toString(position));
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public Object instantiateItem(@NonNull ViewGroup container, int position) {
|
|
||||||
// if (position < 2) return null;
|
|
||||||
|
|
||||||
CalendarView view = mViews.get(position % 3);
|
|
||||||
view.generateItem();
|
|
||||||
view.invalidate();
|
|
||||||
|
|
||||||
int mChildNum = container.getChildCount();
|
|
||||||
if (mChildNum == mViews.size()) {
|
|
||||||
container.removeView(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (container.getChildCount() < mViews.size()) {
|
|
||||||
container.addView(view, 0);
|
|
||||||
} else {
|
|
||||||
container.addView(view, position % 3);
|
|
||||||
}
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateDayInViewState(int position) {
|
|
||||||
CalendarView view = mViews.get(position % 3);
|
|
||||||
view.setSeedDay(mSelectDay);
|
|
||||||
view.updateView();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateViewScheduleChange() {
|
|
||||||
CalendarView view = mViews.get(mCurrPosition % 3);
|
|
||||||
view.updateView();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTypeChangeListener(OnCalendarTypeChangeListener typeChangeListener) {
|
|
||||||
this.typeChangeListener = typeChangeListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public CalendarDay getSelectDay() {
|
|
||||||
return mSelectDay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelectDay(CalendarDay mSelectDay) {
|
|
||||||
this.mSelectDay = mSelectDay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CalendarView> getViews() {
|
|
||||||
return mViews;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface OnCalendarTypeChangeListener {
|
|
||||||
void onCalendarTypeChanged(int Calendar_Type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isViewFromObject(@NonNull android.view.View view, @NonNull Object object) {
|
|
||||||
return view == ((View) object);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package com.idealist.calendarview;
|
|
||||||
|
|
||||||
public final class State {
|
|
||||||
|
|
||||||
public static final int DAY_UN_SELECT = 0;
|
|
||||||
|
|
||||||
public static final int DAY_SELECT = 1;
|
|
||||||
|
|
||||||
public static final int DAY_CURR_MONTH = 0;
|
|
||||||
|
|
||||||
public static final int DAY_PAST_MONTH = -1;
|
|
||||||
|
|
||||||
public static final int DAY_NEXT_MONTH = 1;
|
|
||||||
|
|
||||||
public static final int VIEW_WEEK = 1;
|
|
||||||
|
|
||||||
public static final int VIEW_MONTH = 2;
|
|
||||||
|
|
||||||
public static final int VIEW_FULL = 3;
|
|
||||||
|
|
||||||
public static final int LEVEL_TOP = 1;
|
|
||||||
|
|
||||||
public static final int LEVEL_MEDIUM = 2;
|
|
||||||
|
|
||||||
public static final int LEVEL_BOTTOM = 3;
|
|
||||||
|
|
||||||
public static final int DEFAULT_ITEM_HEIGHT = 180;
|
|
||||||
|
|
||||||
public static final int DEFAULT_TEXT_SIZE = 80;
|
|
||||||
|
|
||||||
public static int DEFAULT_ITEM_HEIGHT_FULL;
|
|
||||||
|
|
||||||
public static void setDefaultItemHeightFull(int defaultItemHeightFull) {
|
|
||||||
DEFAULT_ITEM_HEIGHT_FULL = defaultItemHeightFull;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package com.idealist.calendarview.interf;
|
|
||||||
|
|
||||||
import com.idealist.calendarview.CalendarDay;
|
|
||||||
|
|
||||||
public interface OnSelectDateListener {
|
|
||||||
void onSelectOtherMonth(int offset);//点击其它月份日期
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package com.idealist.calendarview;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Example local unit test, which will execute on the development machine (host).
|
|
||||||
*
|
|
||||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
|
||||||
*/
|
|
||||||
public class ExampleUnitTest {
|
|
||||||
@Test
|
|
||||||
public void addition_isCorrect() {
|
|
||||||
assertEquals(4, 2 + 2);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
/build
|
|
@ -1,38 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'com.android.library'
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
compileSdkVersion 30
|
|
||||||
buildToolsVersion "30.0.3"
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
minSdkVersion 29
|
|
||||||
targetSdkVersion 30
|
|
||||||
versionCode 1
|
|
||||||
versionName "1.0"
|
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
||||||
consumerProguardFiles "consumer-rules.pro"
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
|
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
|
||||||
implementation 'com.google.android.material:material:1.2.1'
|
|
||||||
testImplementation 'junit:junit:4.+'
|
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
# Add project specific ProGuard rules here.
|
|
||||||
# You can control the set of applied configuration files using the
|
|
||||||
# proguardFiles setting in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
|
|
||||||
# Uncomment this to preserve the line number information for
|
|
||||||
# debugging stack traces.
|
|
||||||
#-keepattributes SourceFile,LineNumberTable
|
|
||||||
|
|
||||||
# If you keep the line number information, uncomment this to
|
|
||||||
# hide the original source file name.
|
|
||||||
#-renamesourcefileattribute SourceFile
|
|
@ -1,26 +0,0 @@
|
|||||||
package com.showme.database;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.test.platform.app.InstrumentationRegistry;
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instrumented test, which will execute on an Android device.
|
|
||||||
*
|
|
||||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
|
||||||
*/
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class ExampleInstrumentedTest {
|
|
||||||
@Test
|
|
||||||
public void useAppContext() {
|
|
||||||
// Context of the app under test.
|
|
||||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
|
||||||
assertEquals("com.showme.database.test", appContext.getPackageName());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
package="com.showme.database">
|
|
||||||
|
|
||||||
</manifest>
|
|
@ -1,33 +0,0 @@
|
|||||||
package com.showme.database.DatabaseHelper;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
|
||||||
|
|
||||||
public class CourseSQLHelper extends SQLiteOpenHelper {
|
|
||||||
private static final String db_name = "course";//自定义的数据库名;
|
|
||||||
private static final int version = 2;//版本号
|
|
||||||
|
|
||||||
public CourseSQLHelper(Context context) {
|
|
||||||
super(context, db_name, null, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(SQLiteDatabase db) {
|
|
||||||
db.execSQL("create table courses(" +
|
|
||||||
"id integer primary key autoincrement," +
|
|
||||||
"course_name text," +
|
|
||||||
"teacher text," +
|
|
||||||
"class_room text," +
|
|
||||||
"day integer," +
|
|
||||||
"class_start integer," +
|
|
||||||
"class_end integer," +
|
|
||||||
"weeks text)");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
|
||||||
db.execSQL("drop table if exists schedules");
|
|
||||||
onCreate(db);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
package com.showme.database;
|
|
||||||
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
|
|
||||||
public class MySQLiteDatabase {
|
|
||||||
public static SQLiteDatabase scheduleSQL;
|
|
||||||
|
|
||||||
public static SQLiteDatabase courseSQL;
|
|
||||||
|
|
||||||
public static SQLiteDatabase zoneSQL;
|
|
||||||
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package com.showme.database.utils;
|
|
||||||
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
|
|
||||||
import com.showme.database.MySQLiteDatabase;
|
|
||||||
|
|
||||||
public class CourseSQLUtils {
|
|
||||||
private static SQLiteDatabase courseSQL = MySQLiteDatabase.courseSQL;
|
|
||||||
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
package com.showme.database.utils;
|
|
||||||
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
|
|
||||||
import com.showme.database.MySQLiteDatabase;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ScheduleSQLUtils {
|
|
||||||
private static SQLiteDatabase database = MySQLiteDatabase.scheduleSQL;
|
|
||||||
|
|
||||||
public static List<String> queryByDate(String date) {
|
|
||||||
//columns为null 查询所有列
|
|
||||||
List<String> res = new ArrayList<>();
|
|
||||||
String aScheduleName;
|
|
||||||
Cursor cursor = database.query("schedules",null,"time=?",new String[]{date},null,null,null);
|
|
||||||
if(cursor.moveToFirst()){
|
|
||||||
int scheduleCount = 0;
|
|
||||||
do{
|
|
||||||
aScheduleName = cursor.getString(cursor.getColumnIndex("scheduleName"));
|
|
||||||
String aStartTime = cursor.getString(cursor.getColumnIndex("startTime"));
|
|
||||||
Integer ifStartTime = cursor.getInt(cursor.getColumnIndex("ifStartTime"));
|
|
||||||
String aEndTime = cursor.getString(cursor.getColumnIndex("endTime"));
|
|
||||||
Integer ifEndTime = cursor.getInt(cursor.getColumnIndex("ifEndTime"));
|
|
||||||
String scheduleText = aScheduleName;
|
|
||||||
|
|
||||||
if(ifStartTime == 1){
|
|
||||||
scheduleText += "($时间:"+aStartTime;
|
|
||||||
|
|
||||||
if(ifEndTime ==1){
|
|
||||||
scheduleText += "\n"+aEndTime;
|
|
||||||
} else {
|
|
||||||
scheduleText += "\n24:00";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
scheduleText += "($时间: 00:00\n24:00";
|
|
||||||
}
|
|
||||||
|
|
||||||
scheduleCount++;
|
|
||||||
res.add(scheduleText);
|
|
||||||
}while (cursor.moveToNext());
|
|
||||||
}
|
|
||||||
cursor.close();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String extractScheduleName(String scheduleText) {
|
|
||||||
int index = scheduleText.indexOf("($时间:");
|
|
||||||
if (index != -1) {
|
|
||||||
return scheduleText.substring(0, index);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String extractScheduleTime(String scheduleText) {
|
|
||||||
int index = scheduleText.indexOf("($时间:");
|
|
||||||
if (index != -1) {
|
|
||||||
return scheduleText.substring(index+5);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isScheduleMarked(String date) {
|
|
||||||
Cursor cursor = database.query("schedules",null,"time=?",new String[]{date},null,null,null);
|
|
||||||
return cursor.moveToFirst();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package com.showme.database;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Example local unit test, which will execute on the development machine (host).
|
|
||||||
*
|
|
||||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
|
||||||
*/
|
|
||||||
public class ExampleUnitTest {
|
|
||||||
@Test
|
|
||||||
public void addition_isCorrect() {
|
|
||||||
assertEquals(4, 2 + 2);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
/build
|
|
@ -1,41 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'com.android.application'
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
compileSdkVersion 30
|
|
||||||
buildToolsVersion "30.0.2"
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
applicationId "com.showme.myapplication"
|
|
||||||
minSdkVersion 29
|
|
||||||
targetSdkVersion 30
|
|
||||||
versionCode 1
|
|
||||||
versionName "1.0"
|
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
|
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
|
||||||
implementation 'com.google.android.material:material:1.2.1'
|
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
|
||||||
implementation project(path: ':CalendarView')
|
|
||||||
implementation project(path: ':DataBase')
|
|
||||||
testImplementation 'junit:junit:4.+'
|
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
# Add project specific ProGuard rules here.
|
|
||||||
# You can control the set of applied configuration files using the
|
|
||||||
# proguardFiles setting in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
|
|
||||||
# Uncomment this to preserve the line number information for
|
|
||||||
# debugging stack traces.
|
|
||||||
#-keepattributes SourceFile,LineNumberTable
|
|
||||||
|
|
||||||
# If you keep the line number information, uncomment this to
|
|
||||||
# hide the original source file name.
|
|
||||||
#-renamesourcefileattribute SourceFile
|
|
@ -1,26 +0,0 @@
|
|||||||
package com.showme.myapplication;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.test.platform.app.InstrumentationRegistry;
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instrumented test, which will execute on an Android device.
|
|
||||||
*
|
|
||||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
|
||||||
*/
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class ExampleInstrumentedTest {
|
|
||||||
@Test
|
|
||||||
public void useAppContext() {
|
|
||||||
// Context of the app under test.
|
|
||||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
|
||||||
assertEquals("com.showme.myapplication", appContext.getPackageName());
|
|
||||||
}
|
|
||||||
}
|
|
@ -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,56 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,81 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,171 +0,0 @@
|
|||||||
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()}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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,139 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,199 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
package com.diary.showme.diary.bean;
|
|
||||||
|
|
||||||
public class DiaryBean {
|
|
||||||
private String date;
|
|
||||||
private String title;
|
|
||||||
private String content;
|
|
||||||
private String tag;
|
|
||||||
|
|
||||||
public DiaryBean(String date, String title, String content, String tagz) {
|
|
||||||
this.date = date;
|
|
||||||
this.title = title;
|
|
||||||
this.content = content;
|
|
||||||
this.tag = tag;
|
|
||||||
}
|
|
||||||
public String getTag() {
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTag(String tag) {
|
|
||||||
this.tag = tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDate() {
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDate(String date) {
|
|
||||||
this.date = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getContent() {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setContent(String content) {
|
|
||||||
this.content = content;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
|||||||
package com.diary.showme.diary.db;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
|
||||||
|
|
||||||
public class DiaryDatabaseHelper extends SQLiteOpenHelper {
|
|
||||||
|
|
||||||
public static final String CREATE_DIARY = "create table Diary("
|
|
||||||
+ "id integer primary key autoincrement, "
|
|
||||||
+ "date text, "
|
|
||||||
+ "title text, "
|
|
||||||
+ "tag text, "
|
|
||||||
+ "content text)";
|
|
||||||
|
|
||||||
private Context mContext;
|
|
||||||
public DiaryDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version){
|
|
||||||
super(context, name, factory, version);
|
|
||||||
mContext = context;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onCreate(SQLiteDatabase db) {
|
|
||||||
db.execSQL(CREATE_DIARY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
|
||||||
|
|
||||||
db.execSQL("drop table if exists Diary");
|
|
||||||
onCreate(db);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
package com.diary.showme.diary.event;
|
|
||||||
|
|
||||||
public class StartUpdateDiaryEvent {
|
|
||||||
|
|
||||||
private int position;
|
|
||||||
|
|
||||||
public StartUpdateDiaryEvent(int position) {
|
|
||||||
this.position = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPosition(int position) {
|
|
||||||
this.position = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPosition() {
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,502 +0,0 @@
|
|||||||
package com.diary.showme.diary.ui;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.content.ContentValues;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Message;
|
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import android.provider.MediaStore;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.app.ActionBar;
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.core.content.FileProvider;
|
|
||||||
|
|
||||||
|
|
||||||
import com.diary.showme.diary.db.DiaryDatabaseHelper;
|
|
||||||
import com.diary.showme.diary.utils.AppManager;
|
|
||||||
import com.diary.showme.diary.utils.GetDate;
|
|
||||||
import com.diary.showme.diary.utils.StatusBarCompat;
|
|
||||||
import com.diary.showme.diary.widget.LinedEditText;
|
|
||||||
import com.diary.showme.R;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import butterknife.OnClick;
|
|
||||||
|
|
||||||
import cc.trity.floatingactionbutton.FloatingActionButton;
|
|
||||||
import cc.trity.floatingactionbutton.FloatingActionsMenu;
|
|
||||||
public class AddDiaryActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
@BindView(R.id.add_diary_tv_date)
|
|
||||||
TextView mAddDiaryTvDate;
|
|
||||||
@BindView(R.id.add_diary_et_title)
|
|
||||||
EditText mAddDiaryEtTitle;
|
|
||||||
@BindView(R.id.add_diary_et_content)
|
|
||||||
LinedEditText mAddDiaryEtContent;
|
|
||||||
@BindView(R.id.add_diary_fab_back)
|
|
||||||
FloatingActionButton mAddDiaryFabBack;
|
|
||||||
@BindView(R.id.add_diary_fab_add)
|
|
||||||
FloatingActionButton mAddDiaryFabAdd;
|
|
||||||
@BindView(R.id.add_diary_fab_picture)
|
|
||||||
FloatingActionButton mAddDiaryPicture;
|
|
||||||
@BindView(R.id.picture1)
|
|
||||||
ImageView mPicture1;
|
|
||||||
|
|
||||||
|
|
||||||
@BindView(R.id.right_labels)
|
|
||||||
FloatingActionsMenu mRightLabels;
|
|
||||||
@BindView(R.id.common_tv_title)
|
|
||||||
TextView mCommonTvTitle;
|
|
||||||
@BindView(R.id.common_title_ll)
|
|
||||||
LinearLayout mCommonTitleLl;
|
|
||||||
@BindView(R.id.common_iv_back)
|
|
||||||
ImageView mCommonIvBack;
|
|
||||||
@BindView(R.id.common_iv_test)
|
|
||||||
ImageView mCommonIvTest;
|
|
||||||
|
|
||||||
private DiaryDatabaseHelper mHelper;
|
|
||||||
private AlertDialog.Builder builder;
|
|
||||||
private AlertDialog dialog;
|
|
||||||
public static final int NONE = 0;
|
|
||||||
public static final int CAMERA = 11;// 拍照
|
|
||||||
public static final int PHOTO =22;
|
|
||||||
public static final int CAMERAZOOM = 33; // 相机拍照缩放
|
|
||||||
public static final int PHOTOZOOM = 44;//照片缩放
|
|
||||||
public static final int PHOTORESOULT = 55;// 结果
|
|
||||||
public static final String IMAGE_UNSPECIFIED = "image/*";
|
|
||||||
private static final String TAG = "AddM1Activity";
|
|
||||||
|
|
||||||
private static final int WRITE_PERMISSION = 0x01;
|
|
||||||
private Uri uritempFile=null;
|
|
||||||
|
|
||||||
|
|
||||||
private String cameraSavePath=null;
|
|
||||||
|
|
||||||
String[] permissions = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.CAMERA,Manifest.permission.READ_EXTERNAL_STORAGE};
|
|
||||||
List<String> mPermissionList = new ArrayList<>();
|
|
||||||
private static final int PERMISSION_REQUEST = 1010;
|
|
||||||
|
|
||||||
|
|
||||||
private void initPermission(){
|
|
||||||
mPermissionList.clear();
|
|
||||||
/**
|
|
||||||
* 判断哪些权限未授予
|
|
||||||
*/
|
|
||||||
for (int i = 0; i < permissions.length; i++) {
|
|
||||||
if (ContextCompat.checkSelfPermission(this, permissions[i]) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
mPermissionList.add(permissions[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 判断是否为空
|
|
||||||
*/
|
|
||||||
if (mPermissionList.isEmpty()) {//未授予的权限为空,表示都授予了
|
|
||||||
} else {//请求权限方法
|
|
||||||
String[] permissions = mPermissionList.toArray(new String[mPermissionList.size()]);//将List转为数组
|
|
||||||
ActivityCompat.requestPermissions(this, permissions, PERMISSION_REQUEST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Message message = null;
|
|
||||||
private Handler handler = new Handler() {
|
|
||||||
public void handleMessage(Message msg) {
|
|
||||||
switch (msg.what) {
|
|
||||||
case 1000:
|
|
||||||
Bitmap bitmap = (Bitmap) msg.obj;
|
|
||||||
|
|
||||||
mPicture1.setImageBitmap(bitmap);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 1001:
|
|
||||||
mPicture1.setImageBitmap(BitmapFactory.decodeResource(
|
|
||||||
getResources(), R.mipmap.ic_add_contact_holo_light));
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
public static void startActivity(Context context) {
|
|
||||||
Intent intent = new Intent(context, AddDiaryActivity.class);
|
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void startActivity(Context context, String title, String content) {
|
|
||||||
Intent intent = new Intent(context, AddDiaryActivity.class);
|
|
||||||
intent.putExtra("title", title);
|
|
||||||
intent.putExtra("content", content);
|
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_add_diary);
|
|
||||||
AppManager.getAppManager().addActivity(this);
|
|
||||||
ButterKnife.bind(this);
|
|
||||||
// ActionBar actionBar = getSupportActionBar();
|
|
||||||
// actionBar.hide();
|
|
||||||
Intent intent = getIntent();
|
|
||||||
mAddDiaryEtTitle.setText(intent.getStringExtra("title"));
|
|
||||||
StatusBarCompat.compat(this, Color.parseColor("#161414"));
|
|
||||||
mCommonTvTitle.setText("添加日记");
|
|
||||||
mAddDiaryTvDate.setText("今天," + GetDate.getDate());
|
|
||||||
mAddDiaryEtContent.setText(intent.getStringExtra("content"));
|
|
||||||
mHelper = new DiaryDatabaseHelper(this, "Diary.db", null, 1);
|
|
||||||
initPermission();
|
|
||||||
File f = new File(Environment.getExternalStorageDirectory()
|
|
||||||
, "qwert.jpg");
|
|
||||||
if (f.exists()) {
|
|
||||||
// Bitmap bitmap=BitmapFactory.decodeFile(f.getPath());
|
|
||||||
// icon.setImageBitmap(bitmap);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@OnClick({R.id.common_iv_back, R.id.add_diary_et_title, R.id.add_diary_et_content, R.id.add_diary_fab_back, R.id.add_diary_fab_add, R.id.add_diary_fab_picture})
|
|
||||||
public void onClick(View view) {
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.common_iv_back:
|
|
||||||
DiaryActivity.startActivity(this);
|
|
||||||
case R.id.add_diary_et_title:
|
|
||||||
break;
|
|
||||||
case R.id.add_diary_et_content:
|
|
||||||
break;
|
|
||||||
case R.id.add_diary_fab_back:
|
|
||||||
String date = GetDate.getDate().toString();
|
|
||||||
String tag = String.valueOf(System.currentTimeMillis());
|
|
||||||
String title = mAddDiaryEtTitle.getText().toString() + "";
|
|
||||||
String content = mAddDiaryEtContent.getText().toString() + "";
|
|
||||||
if (!title.equals("") || !content.equals("")) {
|
|
||||||
SQLiteDatabase db = mHelper.getWritableDatabase();
|
|
||||||
ContentValues values = new ContentValues();
|
|
||||||
values.put("date", date);
|
|
||||||
values.put("title", title);
|
|
||||||
values.put("content", content);
|
|
||||||
values.put("tag", tag);
|
|
||||||
db.insert("Diary", null, values);
|
|
||||||
values.clear();
|
|
||||||
}
|
|
||||||
DiaryActivity.startActivity(this);
|
|
||||||
break;
|
|
||||||
case R.id.add_diary_fab_add:
|
|
||||||
final String dateBack = GetDate.getDate().toString();
|
|
||||||
final String titleBack = mAddDiaryEtTitle.getText().toString();
|
|
||||||
final String contentBack = mAddDiaryEtContent.getText().toString();
|
|
||||||
if(!titleBack.isEmpty() || !contentBack.isEmpty()){
|
|
||||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
|
|
||||||
alertDialogBuilder.setMessage("是否保存日记内容?").setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
SQLiteDatabase db = mHelper.getWritableDatabase();
|
|
||||||
ContentValues values = new ContentValues();
|
|
||||||
values.put("date", dateBack);
|
|
||||||
values.put("title", titleBack);
|
|
||||||
values.put("content", contentBack);
|
|
||||||
db.insert("Diary", null, values);
|
|
||||||
values.clear();
|
|
||||||
DiaryActivity.startActivity(AddDiaryActivity.this);
|
|
||||||
}
|
|
||||||
}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
DiaryActivity.startActivity(AddDiaryActivity.this);
|
|
||||||
}
|
|
||||||
}).show();
|
|
||||||
}else{
|
|
||||||
DiaryActivity.startActivity(this);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case R.id.add_diary_fab_picture:
|
|
||||||
selectOperator();// 拍照或者调用图库
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveimage(Bitmap bmp){
|
|
||||||
File f = new File(Environment.getExternalStorageDirectory()
|
|
||||||
, "qwert.jpg");
|
|
||||||
try {
|
|
||||||
FileOutputStream fos = new FileOutputStream(f);
|
|
||||||
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
|
|
||||||
fos.flush();
|
|
||||||
fos.close();
|
|
||||||
System.out.println("111111111111111111==="+f.length());
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
super.onResume();
|
|
||||||
Intent intent =getIntent();
|
|
||||||
String action=intent.getStringExtra("android_manage_type");
|
|
||||||
|
|
||||||
if(action!=null)
|
|
||||||
{
|
|
||||||
if(action.equals("add"))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
super.onPause();
|
|
||||||
if(dialog!=null){
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void openCamera(){
|
|
||||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
|
||||||
cameraSavePath =Environment.getExternalStorageDirectory()+ File.separator + "Android"+File.separator+"xx.jpg";
|
|
||||||
File f_camera =new File(cameraSavePath);
|
|
||||||
Uri uri_camera;
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
||||||
//test.xxx.com.myapplication.fileprovider 是在清单文件配置的 android:authorities
|
|
||||||
uri_camera = FileProvider.getUriForFile(this, "com.example.dairyexanple.fileprovider", f_camera);
|
|
||||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
||||||
System.out.println("openCamera cameraSavePath length=="+f_camera.length());
|
|
||||||
}else {
|
|
||||||
uri_camera = Uri.fromFile(f_camera);
|
|
||||||
}
|
|
||||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri_camera);
|
|
||||||
startActivityForResult(intent, CAMERA);
|
|
||||||
}
|
|
||||||
private void choosePhoto() {
|
|
||||||
Intent intent = new Intent(Intent.ACTION_PICK, null);
|
|
||||||
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
|
||||||
IMAGE_UNSPECIFIED);
|
|
||||||
startActivityForResult(intent, PHOTO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
||||||
switch (requestCode) {
|
|
||||||
case PERMISSION_REQUEST:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
||||||
|
|
||||||
}
|
|
||||||
private void startPhotoZoom2(Uri uri) {
|
|
||||||
// 调用系统中自带的图片剪裁
|
|
||||||
Intent intent = new Intent("com.android.camera.action.CROP");
|
|
||||||
intent.setDataAndType(uri, "image/*");
|
|
||||||
|
|
||||||
uritempFile = Uri.parse("file://" + "/" + Environment.getExternalStorageDirectory()+ File.separator + "Android" + "/icon_temp1.jpg");
|
|
||||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, uritempFile);
|
|
||||||
|
|
||||||
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
|
|
||||||
intent.putExtra("noFaceDetection", true);
|
|
||||||
|
|
||||||
intent.putExtra("crop", "true");
|
|
||||||
// aspectX aspectY 是宽高的比例
|
|
||||||
intent.putExtra("aspectX", 1);
|
|
||||||
intent.putExtra("aspectY", 1);
|
|
||||||
// outputX outputY 是裁剪图片宽高
|
|
||||||
intent.putExtra("outputX", 250);
|
|
||||||
intent.putExtra("outputY", 250);
|
|
||||||
intent.putExtra("return-data", true);
|
|
||||||
startActivityForResult(intent, PHOTOZOOM);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 调用系统裁剪的方法
|
|
||||||
*/
|
|
||||||
private void startPhoneZoom(Uri uri) {
|
|
||||||
Intent intent = new Intent("com.android.camera.action.CROP");
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
||||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
||||||
}
|
|
||||||
intent.setDataAndType(uri, "image/*");
|
|
||||||
//是否可裁剪
|
|
||||||
intent.putExtra("corp", "true");
|
|
||||||
//裁剪器高宽比
|
|
||||||
intent.putExtra("aspectY", 1);
|
|
||||||
intent.putExtra("aspectX", 1);
|
|
||||||
//设置裁剪框高宽
|
|
||||||
intent.putExtra("outputX", 150);
|
|
||||||
intent.putExtra("outputY", 150);
|
|
||||||
|
|
||||||
|
|
||||||
// Uri temp =Uri.parse(cameraSavePath); //Uri.parse("file://" + "/" + Environment.getExternalStorageDirectory().getPath() + "/" + System.currentTimeMillis() + ".jpg");
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
||||||
|
|
||||||
Uri temp =Uri.parse("file://" + "/" + Environment.getExternalStorageDirectory().getPath()+ File.separator + "Android"+File.separator+"xx.jpg");
|
|
||||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
|
|
||||||
intent.putExtra("noFaceDetection", true);
|
|
||||||
//返回数据
|
|
||||||
intent.putExtra("return-data", true);
|
|
||||||
startActivityForResult(intent, CAMERAZOOM);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
System.out.println("onActivityResult== requestCode="+requestCode+" data ="+data);
|
|
||||||
// 读取相册缩放图片
|
|
||||||
if (requestCode == PHOTO) {
|
|
||||||
startPhotoZoom2(data.getData());
|
|
||||||
}else if(requestCode==PHOTOZOOM){
|
|
||||||
File file = null;
|
|
||||||
try {
|
|
||||||
file = new File(new URI(uritempFile.toString()));
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
System.out.println("uritempFile.toString()=="+uritempFile.toString()+" "+file.length());
|
|
||||||
Bitmap photo = BitmapFactory.decodeFile(file.toString());
|
|
||||||
saveimage(photo);
|
|
||||||
|
|
||||||
message =new Message();
|
|
||||||
message.what=1000;
|
|
||||||
message.obj =photo;
|
|
||||||
handler.sendMessageDelayed(message, 100);
|
|
||||||
}else if(requestCode==CAMERAZOOM){
|
|
||||||
Bitmap photo=null;
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
|
|
||||||
File file = null;
|
|
||||||
Uri temp =Uri.parse("file://" + "/" + Environment.getExternalStorageDirectory().getPath()+ File.separator + "Android"+File.separator+"xx.jpg");
|
|
||||||
try {
|
|
||||||
file = new File(new URI(temp.toString()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
photo = BitmapFactory.decodeFile(file.toString());
|
|
||||||
|
|
||||||
}else{
|
|
||||||
File f =new File(cameraSavePath);
|
|
||||||
System.out.println("文件大小 =="+f.length());
|
|
||||||
photo = BitmapFactory.decodeFile(f.toString());
|
|
||||||
|
|
||||||
}
|
|
||||||
saveimage(photo);
|
|
||||||
message =new Message();
|
|
||||||
message.what=1000;
|
|
||||||
message.obj =photo;
|
|
||||||
handler.sendMessageDelayed(message, 100);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
System.out.println("qqqqqqqqqq =");
|
|
||||||
|
|
||||||
|
|
||||||
}else if(requestCode==CAMERA){
|
|
||||||
//相机返回结果
|
|
||||||
File mAvatarFile = new File(cameraSavePath);
|
|
||||||
Uri uri;
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
||||||
//test.xxx.com.myapplication.fileprovider 是在清单文件配置的 android:authorities
|
|
||||||
uri = FileProvider.getUriForFile(this, "com.example.dairyexanple.fileprovider", mAvatarFile);
|
|
||||||
|
|
||||||
System.out.println("open camera 2222222 mAvatarFile length=="+mAvatarFile.length());
|
|
||||||
}else {
|
|
||||||
uri = Uri.fromFile(mAvatarFile);
|
|
||||||
}
|
|
||||||
startPhoneZoom(uri);
|
|
||||||
System.out.println("uritempFile.toString()==");
|
|
||||||
}
|
|
||||||
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
}
|
|
||||||
private void selectOperator(){
|
|
||||||
List<String> list = new ArrayList<String>();
|
|
||||||
list.add(0, "从相册中选择");
|
|
||||||
list.add(1, "相机");
|
|
||||||
builder = new AlertDialog.Builder(this);
|
|
||||||
builder.setTitle("请选择获取图片的方式");
|
|
||||||
builder.setItems(list.toArray(new String[list.size()]), new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
if (which == 0) {
|
|
||||||
|
|
||||||
choosePhoto();
|
|
||||||
} else if (which == 1) {
|
|
||||||
openCamera();
|
|
||||||
|
|
||||||
}else{
|
|
||||||
/*new Utils(AddM1Activity.this)
|
|
||||||
.deleteIcon_temp_01();
|
|
||||||
//deleteIcon_temp();
|
|
||||||
|
|
||||||
message =new Message();
|
|
||||||
message.what=1001;
|
|
||||||
handler.sendMessageDelayed(message, 100);*/
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setCancelable(true);
|
|
||||||
builder.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
|
||||||
System.out.println("clicked----"+keyCode);
|
|
||||||
dialog.dismiss();
|
|
||||||
// finish();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
|
||||||
@Override
|
|
||||||
public void onCancel(DialogInterface dialog) {
|
|
||||||
System.out.println("click onCancel");
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.create().show();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
super.onBackPressed();
|
|
||||||
DiaryActivity.startActivity(this);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,260 +0,0 @@
|
|||||||
package com.diary.showme.diary.ui;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.media.MediaPlayer;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.diary.showme.diary.bean.DiaryBean;
|
|
||||||
import com.diary.showme.diary.db.DiaryDatabaseHelper;
|
|
||||||
import com.diary.showme.diary.event.StartUpdateDiaryEvent;
|
|
||||||
import com.diary.showme.diary.utils.AppManager;
|
|
||||||
import com.diary.showme.diary.utils.GetDate;
|
|
||||||
import com.diary.showme.diary.utils.SpHelper;
|
|
||||||
import com.diary.showme.diary.utils.StatusBarCompat;
|
|
||||||
import com.diary.showme.R;
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import butterknife.OnClick;
|
|
||||||
|
|
||||||
public class DiaryActivity extends AppCompatActivity implements View.OnClickListener{
|
|
||||||
|
|
||||||
@BindView(R.id.common_iv_back)
|
|
||||||
ImageView mCommonIvBack;
|
|
||||||
@BindView(R.id.common_tv_title)
|
|
||||||
TextView mCommonTvTitle;
|
|
||||||
@BindView(R.id.common_iv_test)
|
|
||||||
ImageView mCommonIvTest;
|
|
||||||
@BindView(R.id.common_title_ll)
|
|
||||||
LinearLayout mCommonTitleLl;
|
|
||||||
@BindView(R.id.main_iv_circle)
|
|
||||||
ImageView mMainIvCircle;
|
|
||||||
@BindView(R.id.main_tv_date)
|
|
||||||
TextView mMainTvDate;
|
|
||||||
@BindView(R.id.main_tv_content)
|
|
||||||
TextView mMainTvContent;
|
|
||||||
@BindView(R.id.item_ll_control)
|
|
||||||
LinearLayout mItemLlControl;
|
|
||||||
|
|
||||||
@BindView(R.id.main_rv_show_diary)
|
|
||||||
RecyclerView mMainRvShowDiary;
|
|
||||||
@BindView(R.id.main_pause)
|
|
||||||
FloatingActionButton mMainpause;
|
|
||||||
@BindView(R.id.main_play)
|
|
||||||
FloatingActionButton mMainplay;
|
|
||||||
@BindView(R.id.main_stop)
|
|
||||||
FloatingActionButton mMainstop;
|
|
||||||
@BindView(R.id.main_fab_enter_edit)
|
|
||||||
FloatingActionButton mMainFabEnterEdit;
|
|
||||||
@BindView(R.id.main_rl_main)
|
|
||||||
RelativeLayout mMainRlMain;
|
|
||||||
@BindView(R.id.item_first)
|
|
||||||
LinearLayout mItemFirst;
|
|
||||||
@BindView(R.id.main_ll_main)
|
|
||||||
LinearLayout mMainLlMain;
|
|
||||||
private List<DiaryBean> mDiaryBeanList;
|
|
||||||
|
|
||||||
private DiaryDatabaseHelper mHelper;
|
|
||||||
|
|
||||||
private static String IS_WRITE = "true";
|
|
||||||
|
|
||||||
private int mEditPosition = -1;
|
|
||||||
|
|
||||||
private MediaPlayer mediaPlayer = new MediaPlayer();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 标识今天是否已经写了日记
|
|
||||||
*/
|
|
||||||
private boolean isWrite = false;
|
|
||||||
private static TextView mTvTest;
|
|
||||||
|
|
||||||
public static void startActivity(Context context) {
|
|
||||||
Intent intent = new Intent(context, DiaryActivity.class);
|
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_diary);
|
|
||||||
AppManager.getAppManager().addActivity(this);
|
|
||||||
ButterKnife.bind(this);
|
|
||||||
StatusBarCompat.compat(this, Color.parseColor("#161414"));
|
|
||||||
mHelper = new DiaryDatabaseHelper(this, "Diary.db", null, 1);
|
|
||||||
// ActionBar actionBar = getSupportActionBar();
|
|
||||||
// actionBar.hide();
|
|
||||||
EventBus.getDefault().register(this);
|
|
||||||
SpHelper spHelper = SpHelper.getInstance(this);
|
|
||||||
getDiaryBeanList();
|
|
||||||
initTitle();
|
|
||||||
mMainRvShowDiary.setLayoutManager(new LinearLayoutManager(this));
|
|
||||||
mMainRvShowDiary.setAdapter(new DiaryAdapter(this, mDiaryBeanList));
|
|
||||||
mTvTest = new TextView(this);
|
|
||||||
mTvTest.setText("hello world");
|
|
||||||
mMainplay.setOnClickListener(this);
|
|
||||||
mMainpause.setOnClickListener(this);
|
|
||||||
mMainstop.setOnClickListener(this);
|
|
||||||
//权限判断,如果没有权限就请求权限
|
|
||||||
if (ContextCompat.checkSelfPermission(DiaryActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
ActivityCompat.requestPermissions(DiaryActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
|
|
||||||
} else {
|
|
||||||
initMediaPlayer();//初始化播放器 MediaPlayer
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initTitle() {
|
|
||||||
mMainTvDate.setText("今天," + GetDate.getDate());
|
|
||||||
mCommonTvTitle.setText("日记");
|
|
||||||
mCommonIvBack.setVisibility(View.INVISIBLE);
|
|
||||||
mCommonIvTest.setVisibility(View.INVISIBLE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<DiaryBean> getDiaryBeanList() {
|
|
||||||
|
|
||||||
mDiaryBeanList = new ArrayList<>();
|
|
||||||
List<DiaryBean> diaryList = new ArrayList<>();
|
|
||||||
SQLiteDatabase sqLiteDatabase = mHelper.getWritableDatabase();
|
|
||||||
Cursor cursor = sqLiteDatabase.query("Diary", null, null, null, null, null, null);
|
|
||||||
|
|
||||||
if (cursor.moveToFirst()) {
|
|
||||||
do {
|
|
||||||
String date = cursor.getString(cursor.getColumnIndex("date"));
|
|
||||||
String dateSystem = GetDate.getDate().toString();
|
|
||||||
if (date.equals(dateSystem)) {
|
|
||||||
mMainLlMain.removeView(mItemFirst);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while (cursor.moveToNext());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (cursor.moveToFirst()) {
|
|
||||||
do {
|
|
||||||
String date = cursor.getString(cursor.getColumnIndex("date"));
|
|
||||||
String title = cursor.getString(cursor.getColumnIndex("title"));
|
|
||||||
String content = cursor.getString(cursor.getColumnIndex("content"));
|
|
||||||
String tag = cursor.getString(cursor.getColumnIndex("tag"));
|
|
||||||
mDiaryBeanList.add(new DiaryBean(date, title, content, tag));
|
|
||||||
} while (cursor.moveToNext());
|
|
||||||
}
|
|
||||||
cursor.close();
|
|
||||||
|
|
||||||
for (int i = mDiaryBeanList.size() - 1; i >= 0; i--) {
|
|
||||||
diaryList.add(mDiaryBeanList.get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
mDiaryBeanList = diaryList;
|
|
||||||
return mDiaryBeanList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initMediaPlayer() {
|
|
||||||
try {
|
|
||||||
File file = new File(Environment.getExternalStorageDirectory(), "music.mp3");
|
|
||||||
mediaPlayer.setDataSource(file.getPath());//指定音频文件路径
|
|
||||||
mediaPlayer.setLooping(true);//设置为循环播放
|
|
||||||
mediaPlayer.prepare();//初始化播放器MediaPlayer
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
||||||
switch (requestCode){
|
|
||||||
case 1:
|
|
||||||
if(grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){
|
|
||||||
initMediaPlayer();
|
|
||||||
}else{
|
|
||||||
Toast.makeText(this, "拒绝权限,将无法使用程序。", Toast.LENGTH_LONG).show();
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick({R.id.main_play, R.id.main_pause, R.id.main_stop, R.id.main_fab_enter_edit})
|
|
||||||
public void onClick(View view) {
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.main_play:
|
|
||||||
//如果没在播放中,立刻开始播放。
|
|
||||||
if(!mediaPlayer.isPlaying()){
|
|
||||||
mediaPlayer.start();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case R.id.main_pause:
|
|
||||||
//如果在播放中,立刻暂停。
|
|
||||||
if(mediaPlayer.isPlaying()){
|
|
||||||
mediaPlayer.pause();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case R.id.main_stop:
|
|
||||||
//如果在播放中,立刻停止。
|
|
||||||
if(mediaPlayer.isPlaying()){
|
|
||||||
mediaPlayer.reset();
|
|
||||||
initMediaPlayer();//初始化播放器 MediaPlayer
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case R.id.main_fab_enter_edit:
|
|
||||||
AddDiaryActivity.startActivity(this);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void startUpdateDiaryActivity(StartUpdateDiaryEvent event) {
|
|
||||||
String title = mDiaryBeanList.get(event.getPosition()).getTitle();
|
|
||||||
String content = mDiaryBeanList.get(event.getPosition()).getContent();
|
|
||||||
String tag = mDiaryBeanList.get(event.getPosition()).getTag();
|
|
||||||
UpdateDiaryActivity.startActivity(this, title, content, tag);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
EventBus.getDefault().unregister(this);
|
|
||||||
if(mediaPlayer != null){
|
|
||||||
mediaPlayer.stop();
|
|
||||||
mediaPlayer.release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
super.onBackPressed();
|
|
||||||
AppManager.getAppManager().AppExit(this);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,108 +0,0 @@
|
|||||||
package com.diary.showme.diary.ui;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import com.diary.showme.diary.bean.DiaryBean;
|
|
||||||
import com.diary.showme.diary.event.StartUpdateDiaryEvent;
|
|
||||||
import com.diary.showme.diary.utils.GetDate;
|
|
||||||
import com.diary.showme.R;
|
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DiaryAdapter extends RecyclerView.Adapter<DiaryAdapter.DiaryViewHolder> {
|
|
||||||
|
|
||||||
private Context mContext;
|
|
||||||
private LayoutInflater mLayoutInflater;
|
|
||||||
private List<DiaryBean> mDiaryBeanList;
|
|
||||||
private int mEditPosition = -1;
|
|
||||||
|
|
||||||
public DiaryAdapter(Context context, List<DiaryBean> mDiaryBeanList){
|
|
||||||
mContext = context;
|
|
||||||
this.mLayoutInflater = LayoutInflater.from(context);
|
|
||||||
this.mDiaryBeanList = mDiaryBeanList;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public DiaryViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
|
||||||
return new DiaryViewHolder(mLayoutInflater.inflate(R.layout.item_rv_diary, parent, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(final DiaryViewHolder holder, final int position) {
|
|
||||||
|
|
||||||
String dateSystem = GetDate.getDate().toString();
|
|
||||||
if(mDiaryBeanList.get(position).getDate().equals(dateSystem)){
|
|
||||||
holder.mIvCircle.setImageResource(R.drawable.circle_orange);
|
|
||||||
}
|
|
||||||
holder.mTvDate.setText(mDiaryBeanList.get(position).getDate());
|
|
||||||
holder.mTvTitle.setText(mDiaryBeanList.get(position).getTitle());
|
|
||||||
holder.mTvContent.setText(" " + mDiaryBeanList.get(position).getContent());
|
|
||||||
holder.mIvEdit.setVisibility(View.INVISIBLE);
|
|
||||||
if(mEditPosition == position){
|
|
||||||
holder.mIvEdit.setVisibility(View.VISIBLE);
|
|
||||||
}else {
|
|
||||||
holder.mIvEdit.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
holder.mLl.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if(holder.mIvEdit.getVisibility() == View.VISIBLE){
|
|
||||||
holder.mIvEdit.setVisibility(View.GONE);
|
|
||||||
}else {
|
|
||||||
holder.mIvEdit.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
if(mEditPosition != position){
|
|
||||||
notifyItemChanged(mEditPosition);
|
|
||||||
}
|
|
||||||
mEditPosition = position;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
holder.mIvEdit.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
EventBus.getDefault().post(new StartUpdateDiaryEvent(position));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return mDiaryBeanList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class DiaryViewHolder extends RecyclerView.ViewHolder{
|
|
||||||
|
|
||||||
TextView mTvDate;
|
|
||||||
TextView mTvTitle;
|
|
||||||
TextView mTvContent;
|
|
||||||
ImageView mIvEdit;
|
|
||||||
LinearLayout mLlTitle;
|
|
||||||
LinearLayout mLl;
|
|
||||||
ImageView mIvCircle;
|
|
||||||
LinearLayout mLlControl;
|
|
||||||
RelativeLayout mRlEdit;
|
|
||||||
|
|
||||||
DiaryViewHolder(View view){
|
|
||||||
super(view);
|
|
||||||
mIvCircle = (ImageView) view.findViewById(R.id.main_iv_circle);
|
|
||||||
mTvDate = (TextView) view.findViewById(R.id.main_tv_date);
|
|
||||||
mTvTitle = (TextView) view.findViewById(R.id.main_tv_title);
|
|
||||||
mTvContent = (TextView) view.findViewById(R.id.main_tv_content);
|
|
||||||
mIvEdit = (ImageView) view.findViewById(R.id.main_iv_edit);
|
|
||||||
mLlTitle = (LinearLayout) view.findViewById(R.id.main_ll_title);
|
|
||||||
mLl = (LinearLayout) view.findViewById(R.id.item_ll);
|
|
||||||
mLlControl = (LinearLayout) view.findViewById(R.id.item_ll_control);
|
|
||||||
mRlEdit = (RelativeLayout) view.findViewById(R.id.item_rl_edit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,496 +0,0 @@
|
|||||||
package com.diary.showme.diary.ui;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.content.ContentValues;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Message;
|
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import android.provider.MediaStore;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.app.ActionBar;
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.core.content.FileProvider;
|
|
||||||
|
|
||||||
import com.diary.showme.diary.db.DiaryDatabaseHelper;
|
|
||||||
import com.diary.showme.diary.utils.AppManager;
|
|
||||||
import com.diary.showme.diary.utils.GetDate;
|
|
||||||
import com.diary.showme.diary.utils.StatusBarCompat;
|
|
||||||
import com.diary.showme.diary.widget.LinedEditText;
|
|
||||||
import com.diary.showme.R;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import butterknife.OnClick;
|
|
||||||
import butterknife.BindView;
|
|
||||||
|
|
||||||
import cc.trity.floatingactionbutton.FloatingActionButton;
|
|
||||||
import cc.trity.floatingactionbutton.FloatingActionsMenu;
|
|
||||||
|
|
||||||
public class UpdateDiaryActivity extends AppCompatActivity {
|
|
||||||
@BindView(R.id.picture2)
|
|
||||||
ImageView mPicture2;
|
|
||||||
@BindView(R.id.update_diary_fab_picture)
|
|
||||||
FloatingActionButton mUpdateDiaryPicture;
|
|
||||||
@BindView(R.id.update_diary_tv_date)
|
|
||||||
TextView mUpdateDiaryTvDate;
|
|
||||||
@BindView(R.id.update_diary_et_title)
|
|
||||||
EditText mUpdateDiaryEtTitle;
|
|
||||||
@BindView(R.id.update_diary_et_content)
|
|
||||||
LinedEditText mUpdateDiaryEtContent;
|
|
||||||
@BindView(R.id.update_diary_fab_back)
|
|
||||||
FloatingActionButton mUpdateDiaryFabBack;
|
|
||||||
@BindView(R.id.update_diary_fab_add)
|
|
||||||
FloatingActionButton mUpdateDiaryFabAdd;
|
|
||||||
@BindView(R.id.update_diary_fab_delete)
|
|
||||||
FloatingActionButton mUpdateDiaryFabDelete;
|
|
||||||
@BindView(R.id.right_labels)
|
|
||||||
FloatingActionsMenu mRightLabels;
|
|
||||||
@BindView(R.id.common_tv_title)
|
|
||||||
TextView mCommonTvTitle;
|
|
||||||
@BindView(R.id.common_title_ll)
|
|
||||||
LinearLayout mCommonTitleLl;
|
|
||||||
@BindView(R.id.common_iv_back)
|
|
||||||
ImageView mCommonIvBack;
|
|
||||||
@BindView(R.id.common_iv_test)
|
|
||||||
ImageView mCommonIvTest;
|
|
||||||
@BindView(R.id.update_diary_tv_tag)
|
|
||||||
TextView mTvTag;
|
|
||||||
private AlertDialog.Builder builder;
|
|
||||||
private AlertDialog dialog;
|
|
||||||
public static final int NONE = 0;
|
|
||||||
public static final int CAMERA = 11;// 拍照
|
|
||||||
public static final int PHOTO =22;
|
|
||||||
public static final int CAMERAZOOM = 33; // 相机拍照缩放
|
|
||||||
public static final int PHOTOZOOM = 44;//照片缩放
|
|
||||||
public static final int PHOTORESOULT = 55;// 结果
|
|
||||||
public static final String IMAGE_UNSPECIFIED = "image/*";
|
|
||||||
private static final String TAG = "AddM1Activity";
|
|
||||||
|
|
||||||
private static final int WRITE_PERMISSION = 0x01;
|
|
||||||
private Uri uritempFile=null;
|
|
||||||
|
|
||||||
private String cameraSavePath=null;
|
|
||||||
|
|
||||||
String[] permissions = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.CAMERA,Manifest.permission.READ_EXTERNAL_STORAGE};
|
|
||||||
List<String> mPermissionList = new ArrayList<>();
|
|
||||||
private static final int PERMISSION_REQUEST = 1010;
|
|
||||||
|
|
||||||
|
|
||||||
private void initPermission(){
|
|
||||||
mPermissionList.clear();
|
|
||||||
/**
|
|
||||||
* 判断哪些权限未授予
|
|
||||||
*/
|
|
||||||
for (int i = 0; i < permissions.length; i++) {
|
|
||||||
if (ContextCompat.checkSelfPermission(this, permissions[i]) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
mPermissionList.add(permissions[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 判断是否为空
|
|
||||||
*/
|
|
||||||
if (mPermissionList.isEmpty()) {//未授予的权限为空,表示都授予了
|
|
||||||
} else {//请求权限方法
|
|
||||||
String[] permissions = mPermissionList.toArray(new String[mPermissionList.size()]);//将List转为数组
|
|
||||||
ActivityCompat.requestPermissions(this, permissions, PERMISSION_REQUEST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Message message = null;
|
|
||||||
private Handler handler = new Handler() {
|
|
||||||
public void handleMessage(Message msg) {
|
|
||||||
switch (msg.what) {
|
|
||||||
case 1000:
|
|
||||||
Bitmap bitmap = (Bitmap) msg.obj;
|
|
||||||
|
|
||||||
mPicture2.setImageBitmap(bitmap);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 1001:
|
|
||||||
mPicture2.setImageBitmap(BitmapFactory.decodeResource(
|
|
||||||
getResources(), R.mipmap.ic_add_contact_holo_light));
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
private DiaryDatabaseHelper mHelper;
|
|
||||||
|
|
||||||
public static void startActivity(Context context, String title, String content, String tag) {
|
|
||||||
Intent intent = new Intent(context, UpdateDiaryActivity.class);
|
|
||||||
intent.putExtra("title", title);
|
|
||||||
intent.putExtra("content", content);
|
|
||||||
intent.putExtra("tag", tag);
|
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_update_diary);
|
|
||||||
AppManager.getAppManager().addActivity(this);
|
|
||||||
ButterKnife.bind(this);
|
|
||||||
mHelper = new DiaryDatabaseHelper(this, "Diary.db", null, 1);
|
|
||||||
initTitle();
|
|
||||||
StatusBarCompat.compat(this, Color.parseColor("#161414"));
|
|
||||||
|
|
||||||
Intent intent = getIntent();
|
|
||||||
mUpdateDiaryTvDate.setText("今天," + GetDate.getDate());
|
|
||||||
mUpdateDiaryEtTitle.setText(intent.getStringExtra("title"));
|
|
||||||
mUpdateDiaryEtContent.setText(intent.getStringExtra("content"));
|
|
||||||
mTvTag.setText(intent.getStringExtra("tag"));
|
|
||||||
initPermission();
|
|
||||||
File f = new File(Environment.getExternalStorageDirectory()
|
|
||||||
, "qwert.jpg");
|
|
||||||
if (f.exists()) {
|
|
||||||
// Bitmap bitmap=BitmapFactory.decodeFile(f.getPath());
|
|
||||||
// icon.setImageBitmap(bitmap);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initTitle() {
|
|
||||||
// ActionBar actionBar = getSupportActionBar();
|
|
||||||
// actionBar.hide();
|
|
||||||
mCommonTvTitle.setText("修改日记");
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick({R.id.common_iv_back, R.id.update_diary_tv_date, R.id.update_diary_et_title, R.id.update_diary_et_content, R.id.update_diary_fab_back, R.id.update_diary_fab_add, R.id.update_diary_fab_delete, R.id.update_diary_fab_picture})
|
|
||||||
public void onClick(View view) {
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.common_iv_back:
|
|
||||||
DiaryActivity.startActivity(this);
|
|
||||||
case R.id.update_diary_tv_date:
|
|
||||||
break;
|
|
||||||
case R.id.update_diary_et_title:
|
|
||||||
break;
|
|
||||||
case R.id.update_diary_et_content:
|
|
||||||
break;
|
|
||||||
case R.id.update_diary_fab_back:
|
|
||||||
androidx.appcompat.app.AlertDialog.Builder alertDialogBuilder = new androidx.appcompat.app.AlertDialog.Builder(this);
|
|
||||||
alertDialogBuilder.setMessage("确定要删除该日记吗?").setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
|
|
||||||
// String title = mUpdateDiaryEtTitle.getText().toString();
|
|
||||||
String tag = mTvTag.getText().toString();
|
|
||||||
SQLiteDatabase dbDelete = mHelper.getWritableDatabase();
|
|
||||||
dbDelete.delete("Diary", "tag = ?", new String[]{tag});
|
|
||||||
DiaryActivity.startActivity(UpdateDiaryActivity.this);
|
|
||||||
}
|
|
||||||
}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
}
|
|
||||||
}).show();
|
|
||||||
break;
|
|
||||||
case R.id.update_diary_fab_add:
|
|
||||||
SQLiteDatabase dbUpdate = mHelper.getWritableDatabase();
|
|
||||||
ContentValues valuesUpdate = new ContentValues();
|
|
||||||
String title = mUpdateDiaryEtTitle.getText().toString();
|
|
||||||
String content = mUpdateDiaryEtContent.getText().toString();
|
|
||||||
valuesUpdate.put("title", title);
|
|
||||||
valuesUpdate.put("content", content);
|
|
||||||
dbUpdate.update("Diary", valuesUpdate, "title = ?", new String[]{title});
|
|
||||||
dbUpdate.update("Diary", valuesUpdate, "content = ?", new String[]{content});
|
|
||||||
DiaryActivity.startActivity(this);
|
|
||||||
break;
|
|
||||||
case R.id.update_diary_fab_delete:
|
|
||||||
DiaryActivity.startActivity(this);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case R.id.update_diary_fab_picture:
|
|
||||||
selectOperator();// 拍照或者调用图库
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void saveimage(Bitmap bmp){
|
|
||||||
File f = new File(Environment.getExternalStorageDirectory()
|
|
||||||
, "qwert.jpg");
|
|
||||||
try {
|
|
||||||
FileOutputStream fos = new FileOutputStream(f);
|
|
||||||
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
|
|
||||||
fos.flush();
|
|
||||||
fos.close();
|
|
||||||
System.out.println("111111111111111111==="+f.length());
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
super.onResume();
|
|
||||||
Intent intent =getIntent();
|
|
||||||
String action=intent.getStringExtra("android_manage_type");
|
|
||||||
|
|
||||||
if(action!=null)
|
|
||||||
{
|
|
||||||
if(action.equals("add"))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
super.onPause();
|
|
||||||
if(dialog!=null){
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void openCamera(){
|
|
||||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
|
||||||
cameraSavePath =Environment.getExternalStorageDirectory()+ File.separator + "Android"+File.separator+"xx.jpg";
|
|
||||||
File f_camera =new File(cameraSavePath);
|
|
||||||
Uri uri_camera;
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
||||||
//test.xxx.com.myapplication.fileprovider 是在清单文件配置的 android:authorities
|
|
||||||
uri_camera = FileProvider.getUriForFile(this, "com.example.dairyexanple.fileprovider", f_camera);
|
|
||||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
||||||
System.out.println("openCamera cameraSavePath length=="+f_camera.length());
|
|
||||||
}else {
|
|
||||||
uri_camera = Uri.fromFile(f_camera);
|
|
||||||
}
|
|
||||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri_camera);
|
|
||||||
startActivityForResult(intent, CAMERA);
|
|
||||||
}
|
|
||||||
private void choosePhoto() {
|
|
||||||
Intent intent = new Intent(Intent.ACTION_PICK, null);
|
|
||||||
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
|
||||||
IMAGE_UNSPECIFIED);
|
|
||||||
startActivityForResult(intent, PHOTO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
||||||
switch (requestCode) {
|
|
||||||
case PERMISSION_REQUEST:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
||||||
|
|
||||||
}
|
|
||||||
private void startPhotoZoom2(Uri uri) {
|
|
||||||
// 调用系统中自带的图片剪裁
|
|
||||||
Intent intent = new Intent("com.android.camera.action.CROP");
|
|
||||||
intent.setDataAndType(uri, "image/*");
|
|
||||||
|
|
||||||
uritempFile = Uri.parse("file://" + "/" + Environment.getExternalStorageDirectory()+ File.separator + "Android" + "/icon_temp1.jpg");
|
|
||||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, uritempFile);
|
|
||||||
|
|
||||||
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
|
|
||||||
intent.putExtra("noFaceDetection", true);
|
|
||||||
|
|
||||||
intent.putExtra("crop", "true");
|
|
||||||
// aspectX aspectY 是宽高的比例
|
|
||||||
intent.putExtra("aspectX", 1);
|
|
||||||
intent.putExtra("aspectY", 1);
|
|
||||||
// outputX outputY 是裁剪图片宽高
|
|
||||||
intent.putExtra("outputX", 250);
|
|
||||||
intent.putExtra("outputY", 250);
|
|
||||||
intent.putExtra("return-data", true);
|
|
||||||
startActivityForResult(intent, PHOTOZOOM);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 调用系统裁剪的方法
|
|
||||||
*/
|
|
||||||
private void startPhoneZoom(Uri uri) {
|
|
||||||
Intent intent = new Intent("com.android.camera.action.CROP");
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
||||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
||||||
}
|
|
||||||
intent.setDataAndType(uri, "image/*");
|
|
||||||
//是否可裁剪
|
|
||||||
intent.putExtra("corp", "true");
|
|
||||||
//裁剪器高宽比
|
|
||||||
intent.putExtra("aspectY", 1);
|
|
||||||
intent.putExtra("aspectX", 1);
|
|
||||||
//设置裁剪框高宽
|
|
||||||
intent.putExtra("outputX", 150);
|
|
||||||
intent.putExtra("outputY", 150);
|
|
||||||
|
|
||||||
|
|
||||||
// Uri temp =Uri.parse(cameraSavePath); //Uri.parse("file://" + "/" + Environment.getExternalStorageDirectory().getPath() + "/" + System.currentTimeMillis() + ".jpg");
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
||||||
|
|
||||||
Uri temp =Uri.parse("file://" + "/" + Environment.getExternalStorageDirectory().getPath()+ File.separator + "Android"+File.separator+"xx.jpg");
|
|
||||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
|
|
||||||
intent.putExtra("noFaceDetection", true);
|
|
||||||
//返回数据
|
|
||||||
intent.putExtra("return-data", true);
|
|
||||||
startActivityForResult(intent, CAMERAZOOM);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
System.out.println("onActivityResult== requestCode="+requestCode+" data ="+data);
|
|
||||||
// 读取相册缩放图片
|
|
||||||
if (requestCode == PHOTO) {
|
|
||||||
startPhotoZoom2(data.getData());
|
|
||||||
}else if(requestCode==PHOTOZOOM){
|
|
||||||
File file = null;
|
|
||||||
try {
|
|
||||||
file = new File(new URI(uritempFile.toString()));
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
System.out.println("uritempFile.toString()=="+uritempFile.toString()+" "+file.length());
|
|
||||||
Bitmap photo = BitmapFactory.decodeFile(file.toString());
|
|
||||||
saveimage(photo);
|
|
||||||
|
|
||||||
message =new Message();
|
|
||||||
message.what=1000;
|
|
||||||
message.obj =photo;
|
|
||||||
handler.sendMessageDelayed(message, 100);
|
|
||||||
}else if(requestCode==CAMERAZOOM){
|
|
||||||
Bitmap photo=null;
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
|
|
||||||
File file = null;
|
|
||||||
Uri temp =Uri.parse("file://" + "/" + Environment.getExternalStorageDirectory().getPath()+ File.separator + "Android"+File.separator+"xx.jpg");
|
|
||||||
try {
|
|
||||||
file = new File(new URI(temp.toString()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
photo = BitmapFactory.decodeFile(file.toString());
|
|
||||||
|
|
||||||
}else{
|
|
||||||
File f =new File(cameraSavePath);
|
|
||||||
System.out.println("文件大小 =="+f.length());
|
|
||||||
photo = BitmapFactory.decodeFile(f.toString());
|
|
||||||
|
|
||||||
}
|
|
||||||
saveimage(photo);
|
|
||||||
message =new Message();
|
|
||||||
message.what=1000;
|
|
||||||
message.obj =photo;
|
|
||||||
handler.sendMessageDelayed(message, 100);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
System.out.println("qqqqqqqqqq =");
|
|
||||||
|
|
||||||
|
|
||||||
}else if(requestCode==CAMERA){
|
|
||||||
//相机返回结果
|
|
||||||
File mAvatarFile = new File(cameraSavePath);
|
|
||||||
Uri uri;
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
||||||
//test.xxx.com.myapplication.fileprovider 是在清单文件配置的 android:authorities
|
|
||||||
uri = FileProvider.getUriForFile(this, "com.example.dairyexanple.fileprovider", mAvatarFile);
|
|
||||||
|
|
||||||
System.out.println("open camera 2222222 mAvatarFile length=="+mAvatarFile.length());
|
|
||||||
}else {
|
|
||||||
uri = Uri.fromFile(mAvatarFile);
|
|
||||||
}
|
|
||||||
startPhoneZoom(uri);
|
|
||||||
System.out.println("uritempFile.toString()==");
|
|
||||||
}
|
|
||||||
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
}
|
|
||||||
private void selectOperator(){
|
|
||||||
List<String> list = new ArrayList<String>();
|
|
||||||
list.add(0, "从相册中选择");
|
|
||||||
list.add(1, "相机");
|
|
||||||
builder = new AlertDialog.Builder(this);
|
|
||||||
builder.setTitle("请选择获取图片的方式");
|
|
||||||
builder.setItems(list.toArray(new String[list.size()]), new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
if (which == 0) {
|
|
||||||
|
|
||||||
choosePhoto();
|
|
||||||
} else if (which == 1) {
|
|
||||||
openCamera();
|
|
||||||
|
|
||||||
}else{
|
|
||||||
/*new Utils(AddM1Activity.this)
|
|
||||||
.deleteIcon_temp_01();
|
|
||||||
//deleteIcon_temp();
|
|
||||||
|
|
||||||
message =new Message();
|
|
||||||
message.what=1001;
|
|
||||||
handler.sendMessageDelayed(message, 100);*/
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setCancelable(true);//
|
|
||||||
builder.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
|
||||||
System.out.println("clicked----"+keyCode);
|
|
||||||
dialog.dismiss();
|
|
||||||
// finish();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
|
||||||
@Override
|
|
||||||
public void onCancel(DialogInterface dialog) {
|
|
||||||
System.out.println("click onCancel");
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.create().show();
|
|
||||||
}
|
|
||||||
@OnClick(R.id.common_tv_title)
|
|
||||||
public void onClick() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
super.onBackPressed();
|
|
||||||
DiaryActivity.startActivity(this);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,96 +0,0 @@
|
|||||||
package com.diary.showme.diary.utils;
|
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import java.util.Stack;
|
|
||||||
|
|
||||||
|
|
||||||
public class AppManager {
|
|
||||||
private static Stack<AppCompatActivity> activityStack;
|
|
||||||
private static AppManager instance;
|
|
||||||
|
|
||||||
private AppManager(){}
|
|
||||||
|
|
||||||
public static AppManager getAppManager(){
|
|
||||||
if(instance == null){
|
|
||||||
synchronized (AppManager.class){
|
|
||||||
if(instance == null){
|
|
||||||
instance = new AppManager();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addActivity(AppCompatActivity activity){
|
|
||||||
if(activityStack == null){
|
|
||||||
activityStack = new Stack<>();
|
|
||||||
}
|
|
||||||
activityStack.add(activity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public AppCompatActivity currentActivity(){
|
|
||||||
|
|
||||||
if(activityStack == null || activityStack.isEmpty()){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
AppCompatActivity acitivity = activityStack.lastElement();
|
|
||||||
return acitivity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AppCompatActivity findActivity(Class<?> cls){
|
|
||||||
AppCompatActivity activity = null;
|
|
||||||
for (AppCompatActivity appCompatActivity : activityStack) {
|
|
||||||
if(appCompatActivity.getClass().equals(cls)){
|
|
||||||
activity = appCompatActivity;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return activity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void finishActivity(){
|
|
||||||
AppCompatActivity activity = activityStack.lastElement();
|
|
||||||
finishActivity(activity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void finishActivity(AppCompatActivity activity){
|
|
||||||
if(activity != null){
|
|
||||||
activityStack.remove(activity);
|
|
||||||
activity.finish();
|
|
||||||
activity = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void finishActivity(Class<?> cls){
|
|
||||||
for (AppCompatActivity activity : activityStack) {
|
|
||||||
if(activity.getClass().equals(cls)){
|
|
||||||
finishActivity(activity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void finishAllActivity(){
|
|
||||||
for (int i = 0, size = activityStack.size(); i < size; i++) {
|
|
||||||
if (null != activityStack.get(i)) {
|
|
||||||
activityStack.get(i).finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
activityStack.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AppExit(Context context){
|
|
||||||
try{
|
|
||||||
finishAllActivity();
|
|
||||||
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
|
||||||
activityManager.killBackgroundProcesses(context.getPackageName());
|
|
||||||
System.exit(0);
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
|||||||
package com.diary.showme.diary.utils;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
public class GetDate {
|
|
||||||
|
|
||||||
public static StringBuilder getDate(){
|
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
Calendar now = Calendar.getInstance();
|
|
||||||
stringBuilder.append(now.get(Calendar.YEAR) + "年");
|
|
||||||
stringBuilder.append((int)(now.get(Calendar.MONTH) + 1) + "月");
|
|
||||||
stringBuilder.append(now.get(Calendar.DAY_OF_MONTH) + "日");
|
|
||||||
return stringBuilder;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
package com.diary.showme.diary.utils;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
|
|
||||||
public class SpHelper {
|
|
||||||
|
|
||||||
private static final String SP_NAME = "sp_name";
|
|
||||||
private static SpHelper mSpHelper;
|
|
||||||
private Context mAppContext;
|
|
||||||
private SharedPreferences mSharedPreferences;
|
|
||||||
private String info;
|
|
||||||
|
|
||||||
private SpHelper(Context context){
|
|
||||||
mAppContext = context.getApplicationContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取SpHelper的实例
|
|
||||||
public static SpHelper getInstance(Context context){
|
|
||||||
if(mSpHelper == null){
|
|
||||||
synchronized (SpHelper.class){
|
|
||||||
if(mSpHelper == null){
|
|
||||||
mSpHelper = new SpHelper(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mSpHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("WrongConstant")
|
|
||||||
private SharedPreferences getSharePreferences(){
|
|
||||||
if(mSharedPreferences == null){
|
|
||||||
mSharedPreferences = mAppContext.getSharedPreferences(SP_NAME, Context.MODE_APPEND);
|
|
||||||
}
|
|
||||||
return mSharedPreferences;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInfo(String info){
|
|
||||||
this.info = info;
|
|
||||||
getSharePreferences().edit().putString("info", info).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getInfo(){
|
|
||||||
if(info.equals("") || info.length() == 0){
|
|
||||||
info = getSharePreferences().getString("info", "");
|
|
||||||
}
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
package com.diary.showme.diary.utils;
|
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 用于修改标题栏的颜色
|
|
||||||
*/
|
|
||||||
public class StatusBarCompat
|
|
||||||
{
|
|
||||||
private static final int INVALID_VAL = -1;
|
|
||||||
private static final int COLOR_DEFAULT = Color.parseColor("#20000000");
|
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
public static void compat(Activity activity, int statusColor)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
{
|
|
||||||
if (statusColor != INVALID_VAL)
|
|
||||||
{
|
|
||||||
activity.getWindow().setStatusBarColor(statusColor);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
{
|
|
||||||
int color = COLOR_DEFAULT;
|
|
||||||
ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
|
|
||||||
if (statusColor != INVALID_VAL)
|
|
||||||
{
|
|
||||||
color = statusColor;
|
|
||||||
}
|
|
||||||
View statusBarView = contentView.getChildAt(0);
|
|
||||||
//改变颜色时避免重复添加statusBarView
|
|
||||||
if (statusBarView != null && statusBarView.getMeasuredHeight() == getStatusBarHeight(activity))
|
|
||||||
{
|
|
||||||
statusBarView.setBackgroundColor(color);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
statusBarView = new View(activity);
|
|
||||||
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
|
||||||
getStatusBarHeight(activity));
|
|
||||||
statusBarView.setBackgroundColor(color);
|
|
||||||
contentView.addView(statusBarView, lp);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void compat(Activity activity)
|
|
||||||
{
|
|
||||||
compat(activity, INVALID_VAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static int getStatusBarHeight(Context context)
|
|
||||||
{
|
|
||||||
int result = 0;
|
|
||||||
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
|
|
||||||
if (resourceId > 0)
|
|
||||||
{
|
|
||||||
result = context.getResources().getDimensionPixelSize(resourceId);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
package com.diary.showme.diary.widget;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.DashPathEffect;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.PathEffect;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint({ "ResourceAsColor", "DrawAllocation" })
|
|
||||||
|
|
||||||
public class LinedEditText extends androidx.appcompat.widget.AppCompatEditText {
|
|
||||||
|
|
||||||
public LinedEditText(Context context) {
|
|
||||||
super(context);
|
|
||||||
initPaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
public LinedEditText(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
initPaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
public LinedEditText(Context context, AttributeSet attrs, int defStyle) {
|
|
||||||
super(context, attrs, defStyle);
|
|
||||||
initPaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initPaint() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDraw(Canvas canvas) {
|
|
||||||
|
|
||||||
Paint mPaint = new Paint();
|
|
||||||
|
|
||||||
mPaint.setStyle(Paint.Style.STROKE);
|
|
||||||
|
|
||||||
mPaint.setColor(Color.LTGRAY);
|
|
||||||
|
|
||||||
PathEffect effects = new DashPathEffect(new float[]{5, 5, 5, 5}, 5);
|
|
||||||
|
|
||||||
mPaint.setPathEffect(effects);
|
|
||||||
|
|
||||||
int left = getLeft();
|
|
||||||
|
|
||||||
int right = getRight();
|
|
||||||
|
|
||||||
int paddingTop = getPaddingTop();
|
|
||||||
|
|
||||||
int paddingBottom = getPaddingBottom();
|
|
||||||
|
|
||||||
int paddingLeft = getPaddingLeft();
|
|
||||||
|
|
||||||
int paddingRight = getPaddingRight();
|
|
||||||
|
|
||||||
int height = getHeight();
|
|
||||||
|
|
||||||
int lineHeight = getLineHeight();
|
|
||||||
|
|
||||||
int spcingHeight = (int) getLineSpacingExtra();
|
|
||||||
|
|
||||||
int count = (height - paddingTop - paddingBottom) / lineHeight;
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
|
|
||||||
int baseline = lineHeight * (i + 1) + paddingTop - spcingHeight / 2;
|
|
||||||
|
|
||||||
canvas.drawLine(paddingLeft, (int) (baseline * 1.0), right - paddingRight * (int) 1.8, (int) (baseline * 1.0), mPaint);
|
|
||||||
|
|
||||||
}
|
|
||||||
super.onDraw(canvas);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:aapt="http://schemas.android.com/aapt"
|
|
||||||
android:width="108dp"
|
|
||||||
android:height="108dp"
|
|
||||||
android:viewportWidth="108"
|
|
||||||
android:viewportHeight="108">
|
|
||||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
|
||||||
<aapt:attr name="android:fillColor">
|
|
||||||
<gradient
|
|
||||||
android:endX="85.84757"
|
|
||||||
android:endY="92.4963"
|
|
||||||
android:startX="42.9492"
|
|
||||||
android:startY="49.59793"
|
|
||||||
android:type="linear">
|
|
||||||
<item
|
|
||||||
android:color="#44000000"
|
|
||||||
android:offset="0.0" />
|
|
||||||
<item
|
|
||||||
android:color="#00000000"
|
|
||||||
android:offset="1.0" />
|
|
||||||
</gradient>
|
|
||||||
</aapt:attr>
|
|
||||||
</path>
|
|
||||||
<path
|
|
||||||
android:fillColor="#FFFFFF"
|
|
||||||
android:fillType="nonZero"
|
|
||||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
|
||||||
android:strokeWidth="1"
|
|
||||||
android:strokeColor="#00000000" />
|
|
||||||
</vector>
|
|
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 210 B |
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<vector android:alpha="0.8" android:height="24dp"
|
|
||||||
android:tint="?attr/colorControlNormal" android:viewportHeight="24"
|
|
||||||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
|
|
||||||
</vector>
|
|
@ -1,170 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="108dp"
|
|
||||||
android:height="108dp"
|
|
||||||
android:viewportWidth="108"
|
|
||||||
android:viewportHeight="108">
|
|
||||||
<path
|
|
||||||
android:fillColor="#3DDC84"
|
|
||||||
android:pathData="M0,0h108v108h-108z" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M9,0L9,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,0L19,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M29,0L29,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M39,0L39,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M49,0L49,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M59,0L59,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M69,0L69,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M79,0L79,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M89,0L89,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M99,0L99,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,9L108,9"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,19L108,19"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,29L108,29"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,39L108,39"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,49L108,49"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,59L108,59"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,69L108,69"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,79L108,79"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,89L108,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,99L108,99"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,29L89,29"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,39L89,39"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,49L89,49"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,59L89,59"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,69L89,69"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,79L89,79"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M29,19L29,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M39,19L39,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M49,19L49,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M59,19L59,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M69,19L69,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M79,19L79,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
</vector>
|
|
@ -1,18 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<!-- 边框颜色值 --><item>
|
|
||||||
<shape>
|
|
||||||
<solid android:color="#a3a8a4" />
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
<!-- 主体背景颜色值 -->
|
|
||||||
<item android:right="1dp">
|
|
||||||
<shape>
|
|
||||||
<solid android:color="#ffffff" />
|
|
||||||
<padding android:bottom="10dp"
|
|
||||||
android:left="10dp"
|
|
||||||
android:right="10dp"
|
|
||||||
android:top="10dp" />
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
</layer-list>
|
|
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 120 KiB |
Before Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 29 KiB |
@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="rectangle">
|
|
||||||
|
|
||||||
<solid android:color="#FFFFFF"/>
|
|
||||||
|
|
||||||
<stroke
|
|
||||||
android:width="0.5dp"
|
|
||||||
android:color="#dddddd"/>
|
|
||||||
|
|
||||||
<padding
|
|
||||||
android:bottom="10dp"
|
|
||||||
android:left="10dp"
|
|
||||||
android:right="10dp"
|
|
||||||
android:top="10dp"/>
|
|
||||||
|
|
||||||
<corners android:radius="10dp"/>
|
|
||||||
|
|
||||||
</shape>
|
|
Before Width: | Height: | Size: 53 KiB |
@ -1,125 +0,0 @@
|
|||||||
<?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">
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="300dp"
|
|
||||||
android:layout_height="300dp"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:scrollbars="vertical"
|
|
||||||
android:scrollbarAlwaysDrawHorizontalTrack="true">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:text="\n课程名:" />
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/course_name"
|
|
||||||
android:layout_width="90dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:imeOptions="actionNext"
|
|
||||||
android:singleLine="true" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:text="\n星期几:" />
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/week"
|
|
||||||
android:layout_width="30dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:inputType="number" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:text="\n第几节课开始:" />
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/classes_begin"
|
|
||||||
android:layout_width="30dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:inputType="number" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:text="\n第几节课结束:" />
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/classes_ends"
|
|
||||||
android:layout_width="30dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:inputType="number" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:text="\n周次:" />
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/weeks"
|
|
||||||
android:layout_width="90dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:imeOptions="actionNext"
|
|
||||||
android:singleLine="true" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:text="\n教师名:" />
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/teacher_name"
|
|
||||||
android:layout_width="90dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:imeOptions="actionNext"
|
|
||||||
android:singleLine="true" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:text="\n课室:" />
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/class_room"
|
|
||||||
android:layout_width="90dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:imeOptions="actionNext"
|
|
||||||
android:singleLine="true" />
|
|
||||||
</LinearLayout>
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="15dp"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:text="完成" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:text="\n 在课程表界面长按一个课程可以删除它 \n"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -1,184 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/CLayout"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:background="@drawable/bg"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="41dp"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/back_to_calendar"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="#0D000000"
|
|
||||||
android:text="返回"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="28"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:textSize="28sp"
|
|
||||||
android:background="#0D000000"
|
|
||||||
android:text="课程表" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/add_courses"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="#0D000000"
|
|
||||||
android:text="添加课程"
|
|
||||||
android:layout_weight="1"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<!--星期条-->
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
android:background="#0DA993C5">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="120px"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="节/周"/>
|
|
||||||
<TextView
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="周一"/>
|
|
||||||
<TextView
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="周二"/>
|
|
||||||
<TextView
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="周三"/>
|
|
||||||
<TextView
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="周四"/>
|
|
||||||
<TextView
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="周五"/>
|
|
||||||
<TextView
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="周六"/>
|
|
||||||
<TextView
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="周日"/>
|
|
||||||
</LinearLayout>
|
|
||||||
<!--课程表-->
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<!--左侧"节数"布局-->
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/left_view_layout"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"/>
|
|
||||||
<!--星期一到星期天的布局-->
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/monday"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_margin="1dp"/>
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/tuesday"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_margin="1dp"/>
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/wednesday"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_margin="1dp"/>
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/thursday"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_margin="1dp"/>
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/friday"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_margin="1dp"/>
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/saturday"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_margin="1dp"/>
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/weekday"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_marginTop="1dp"
|
|
||||||
android:layout_marginLeft="1dp"
|
|
||||||
android:layout_marginBottom="1dp"/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -1,200 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:id="@+id/main_rl_main"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="#ffffff"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:paddingBottom="10dp"
|
|
||||||
tools:context=".diary.ui.DiaryActivity"
|
|
||||||
>
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/main_ll_main"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
>
|
|
||||||
|
|
||||||
<include
|
|
||||||
layout="@layout/part_common_title"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="20dp"/>
|
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/item_first"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="#ffffff"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:paddingRight="10dp"
|
|
||||||
>
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="25dp"
|
|
||||||
android:background="#ffffff"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:paddingLeft="10.8dp"
|
|
||||||
>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/main_iv_circle"
|
|
||||||
android:layout_width="22dp"
|
|
||||||
android:layout_height="22dp"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:paddingTop="2dp"
|
|
||||||
android:src="@drawable/circle_orange"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/main_tv_date"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="25dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:paddingLeft="4dp"
|
|
||||||
android:paddingTop="5dp"
|
|
||||||
android:text="2017年01月18日"
|
|
||||||
android:textSize="14sp"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="23dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="@drawable/linear_style"
|
|
||||||
>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/item_ll_control"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/main_tv_content"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="50dp"
|
|
||||||
android:background="#ffffff"
|
|
||||||
android:lineSpacingExtra="4dp"
|
|
||||||
android:paddingLeft="33dp"
|
|
||||||
android:paddingRight="15dp"
|
|
||||||
android:paddingTop="5dp"
|
|
||||||
android:text="今天,你什么都没写下..."
|
|
||||||
android:textColor="@color/gray"
|
|
||||||
android:textSize="16sp"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/main_rv_show_diary"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
>
|
|
||||||
|
|
||||||
</androidx.recyclerview.widget.RecyclerView>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
android:id="@+id/main_fab_enter_edit"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_marginBottom="36dp"
|
|
||||||
android:layout_marginLeft="30dp"
|
|
||||||
android:layout_marginStart="30dp"
|
|
||||||
android:src="@drawable/add"
|
|
||||||
app:backgroundTint="#ee722f"
|
|
||||||
app:borderWidth="0dp"
|
|
||||||
app:elevation="6dp"
|
|
||||||
app:fabSize="normal"
|
|
||||||
app:layout_anchorGravity="bottom|right"
|
|
||||||
app:pressedTranslationZ="12dp"
|
|
||||||
app:rippleColor="#a6a6a6"/>
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
android:id="@+id/main_play"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_marginBottom="36dp"
|
|
||||||
android:layout_marginLeft="30dp"
|
|
||||||
android:layout_marginStart="150dp"
|
|
||||||
android:layout_toRightOf="@id/main_fab_enter_edit"
|
|
||||||
android:src="@drawable/play"
|
|
||||||
app:backgroundTint="#ffffff"
|
|
||||||
app:borderWidth="0dp"
|
|
||||||
app:elevation="6dp"
|
|
||||||
app:fabSize="normal"
|
|
||||||
app:layout_anchorGravity="bottom|right"
|
|
||||||
app:pressedTranslationZ="12dp"
|
|
||||||
app:rippleColor="#a6a6a6"/>
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
android:id="@+id/main_pause"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_marginBottom="36dp"
|
|
||||||
android:layout_marginLeft="30dp"
|
|
||||||
android:layout_marginStart="220dp"
|
|
||||||
android:layout_toRightOf="@id/main_fab_enter_edit"
|
|
||||||
android:src="@drawable/pause"
|
|
||||||
app:backgroundTint="#ffffff"
|
|
||||||
app:borderWidth="0dp"
|
|
||||||
app:elevation="6dp"
|
|
||||||
app:fabSize="normal"
|
|
||||||
app:layout_anchorGravity="bottom|right"
|
|
||||||
app:pressedTranslationZ="12dp"
|
|
||||||
app:rippleColor="#a6a6a6"/>
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
android:id="@+id/main_stop"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_marginBottom="36dp"
|
|
||||||
android:layout_marginLeft="30dp"
|
|
||||||
android:layout_marginStart="290dp"
|
|
||||||
android:layout_toRightOf="@id/main_fab_enter_edit"
|
|
||||||
android:src="@drawable/stop"
|
|
||||||
app:backgroundTint="#ffffff"
|
|
||||||
|
|
||||||
app:borderWidth="0dp"
|
|
||||||
app:elevation="6dp"
|
|
||||||
app:fabSize="normal"
|
|
||||||
app:layout_anchorGravity="bottom|right"
|
|
||||||
app:pressedTranslationZ="12dp"
|
|
||||||
app:rippleColor="#a6a6a6"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
@ -1,142 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/CLayout"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/custom_date_view"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="42dp"
|
|
||||||
android:orientation="horizontal" >
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/custom_year_view"
|
|
||||||
android:layout_width="72sp"
|
|
||||||
android:layout_marginLeft="30dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:textColor="#ff25adff"
|
|
||||||
android:textSize="27sp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/custom_month_view"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="bottom"
|
|
||||||
android:textColor="#26ADFF"
|
|
||||||
android:textSize="20sp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
<TextView
|
|
||||||
style="@style/weekIndicatorStyle"
|
|
||||||
android:text="日"/>
|
|
||||||
<TextView
|
|
||||||
style="@style/weekIndicatorStyle"
|
|
||||||
android:text="一"/>
|
|
||||||
<TextView
|
|
||||||
style="@style/weekIndicatorStyle"
|
|
||||||
android:text="二"/>
|
|
||||||
<TextView
|
|
||||||
style="@style/weekIndicatorStyle"
|
|
||||||
android:text="三"/>
|
|
||||||
<TextView
|
|
||||||
style="@style/weekIndicatorStyle"
|
|
||||||
android:text="四"/>
|
|
||||||
<TextView
|
|
||||||
style="@style/weekIndicatorStyle"
|
|
||||||
android:text="五"/>
|
|
||||||
<TextView
|
|
||||||
style="@style/weekIndicatorStyle"
|
|
||||||
android:text="六"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
|
||||||
android:id="@+id/cdLayout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<com.idealist.calendarview.CalendarPager
|
|
||||||
android:id="@+id/custom_vp"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
|
|
||||||
<!-- <androidx.recyclerview.widget.RecyclerView-->
|
|
||||||
<!-- android:id="@+id/list_item"-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="match_parent"-->
|
|
||||||
<!-- app:layout_behavior="com.idealist.calendarview.RecyclerViewBehavior"/>-->
|
|
||||||
|
|
||||||
<!-- <cc.trity.floatingactionbutton.FloatingActionButton-->
|
|
||||||
<!-- android:id="@+id/add_schedule"-->
|
|
||||||
<!-- android:layout_width="40dp"-->
|
|
||||||
<!-- android:layout_height="40dp"-->
|
|
||||||
<!-- android:layout_gravity="bottom|start"-->
|
|
||||||
<!-- app:fab_size="mini"-->
|
|
||||||
<!-- app:fab_title="FAB 0"-->
|
|
||||||
<!-- app:fab_colorNormal="#e41c1c"-->
|
|
||||||
<!-- app:fab_icon="@drawable/schedule"-->
|
|
||||||
<!-- />-->
|
|
||||||
|
|
||||||
<!-- <cc.trity.floatingactionbutton.FloatingActionsMenu-->
|
|
||||||
<!-- android:id="@+id/right_labels"-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="wrap_content"-->
|
|
||||||
<!-- android:layout_gravity="bottom|end"-->
|
|
||||||
<!-- app:fab_expandDirection="up"-->
|
|
||||||
<!-- app:fab_colorNormal="#f0f01a"-->
|
|
||||||
<!-- app:fab_icon = "@drawable/ic_baseline_add_24"-->
|
|
||||||
<!-- app:fab_addButtonSize="mini"-->
|
|
||||||
<!-- >-->
|
|
||||||
|
|
||||||
<!-- <cc.trity.floatingactionbutton.FloatingActionButton-->
|
|
||||||
<!-- android:id="@+id/diary_entry"-->
|
|
||||||
<!-- android:layout_width="30dp"-->
|
|
||||||
<!-- android:layout_height="30dp"-->
|
|
||||||
<!-- android:background="@drawable/ic_baseline_add_24"-->
|
|
||||||
<!-- app:fab_size="normal"-->
|
|
||||||
<!-- app:fab_title="FAB 3"-->
|
|
||||||
<!-- app:fab_colorNormal="#09F7F7"-->
|
|
||||||
<!-- app:fab_icon="@drawable/diary"-->
|
|
||||||
<!-- />-->
|
|
||||||
|
|
||||||
<!-- <cc.trity.floatingactionbutton.FloatingActionButton-->
|
|
||||||
<!-- android:id="@+id/course_entry"-->
|
|
||||||
<!-- android:layout_width="50dp"-->
|
|
||||||
<!-- android:layout_height="50dp"-->
|
|
||||||
<!-- app:fab_colorNormal="#24d63c"-->
|
|
||||||
<!-- app:fab_size="normal"-->
|
|
||||||
<!-- app:fab_icon="@drawable/course"-->
|
|
||||||
<!-- />-->
|
|
||||||
|
|
||||||
<!-- <cc.trity.floatingactionbutton.FloatingActionButton-->
|
|
||||||
<!-- android:id="@+id/zone_entry"-->
|
|
||||||
<!-- android:layout_width="50dp"-->
|
|
||||||
<!-- android:layout_height="50dp"-->
|
|
||||||
<!-- app:fab_colorNormal="#501161"-->
|
|
||||||
<!-- app:fab_size="normal"-->
|
|
||||||
<!-- app:fab_icon="@drawable/zone"-->
|
|
||||||
<!-- />-->
|
|
||||||
|
|
||||||
<!-- </cc.trity.floatingactionbutton.FloatingActionsMenu>-->
|
|
||||||
<!-- <com.google.android.material.floatingactionbutton.FloatingActionButton-->
|
|
||||||
<!-- android:id="@+id/addSchedule"-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="wrap_content"-->
|
|
||||||
<!-- android:layout_gravity="end|bottom"-->
|
|
||||||
<!-- android:layout_margin="30dp"-->
|
|
||||||
<!-- android:backgroundTint="#7575EF"-->
|
|
||||||
<!-- android:src="@drawable/ic_baseline_add_24"-->
|
|
||||||
<!-- android:contentDescription="@string/add"-->
|
|
||||||
<!-- app:fabSize="normal"-->
|
|
||||||
<!-- />-->
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -1,132 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:id="@+id/addSchedulePage">
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
tools:ignore="MissingConstraints">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/scheduleNameInput"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="请输入日程"/>
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/schedulePlaceInput"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="请输入地点"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="40dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_st"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:textSize="18sp"
|
|
||||||
android:hint="请输入开始时间"
|
|
||||||
android:gravity="center"/>
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/scheduleStartHourInput"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_toRightOf="@id/tv_st"
|
|
||||||
android:hint="时"
|
|
||||||
android:layout_marginLeft="10dp"
|
|
||||||
android:paddingRight="40dp"
|
|
||||||
android:inputType="number"/>
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/scheduleStartMinInput"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_toRightOf="@id/scheduleStartHourInput"
|
|
||||||
android:hint="分"
|
|
||||||
android:layout_marginLeft="10dp"
|
|
||||||
android:paddingRight="40dp"
|
|
||||||
android:inputType="number"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="40dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_et"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:textSize="18sp"
|
|
||||||
android:hint="请输入结束时间"
|
|
||||||
android:gravity="center"/>
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/scheduleEndHourInput"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="时"
|
|
||||||
android:layout_toRightOf="@id/tv_et"
|
|
||||||
android:layout_marginLeft="10dp"
|
|
||||||
android:paddingRight="40dp"
|
|
||||||
android:inputType="number"/>/>
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/scheduleEndMinInput"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_toRightOf="@id/scheduleEndHourInput"
|
|
||||||
android:hint="分"
|
|
||||||
android:layout_marginLeft="10dp"
|
|
||||||
android:paddingRight="40dp"
|
|
||||||
android:inputType="number"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/checkAdd1"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="确认添加"
|
|
||||||
android:clickable="true"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/schedule2"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:clickable="true"
|
|
||||||
android:textSize="30dp"
|
|
||||||
android:layout_marginLeft="20dp"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|