Merge pull request '整合已有代码,生成可运行的最初版本' (#13) from p86231950/ShowMe:master into master

pull/16/head
p28679143 4 years ago
commit 561898494b

@ -1 +0,0 @@
My Application

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.showme.myapplication">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyApplication">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

@ -1,115 +0,0 @@
package com.showme.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.widget.TextView;
import com.idealist.calendarview.CalendarAttr;
import com.idealist.calendarview.CalendarDay;
import com.idealist.calendarview.CalendarPager;
import com.idealist.calendarview.CalendarUtils;
import com.idealist.calendarview.CalendarView;
import com.idealist.calendarview.CalendarViewAdapter;
import com.idealist.calendarview.State;
import com.idealist.calendarview.interf.OnSelectDateListener;
import java.util.TimeZone;
public class MainActivity extends AppCompatActivity {
private TextView tvMonth;
private TextView tvYear;
private CalendarDay currentDay;
private CalendarView currentView;
private CalendarPager pager;
private CalendarViewAdapter viewAdapter;
private CalendarAttr attr;
private OnSelectDateListener onSelectDateListener;
private CalendarView.OnCalendarClickListener clickListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getRealMetrics(dm);
int height = dm.heightPixels;
State.setDefaultItemHeightFull((height - 42 - 3*State.DEFAULT_ITEM_HEIGHT) / 6);
initCalendar();
attr = new CalendarAttr();
attr.setCalendarType(State.VIEW_MONTH);
attr.setScrollLevel(State.LEVEL_MEDIUM);
initListener();
viewAdapter = new CalendarViewAdapter(this, attr, onSelectDateListener,
clickListener);
initPager();
}
private void initCalendar() {
tvMonth = findViewById(R.id.custom_month_view);
tvYear = findViewById(R.id.custom_year_view);
currentDay = CalendarUtils.getCurrDay();
updateCalendar();
}
private void initPager() {
pager = findViewById(R.id.custom_vp);
pager.setAttr(attr);
pager.setAdapter(viewAdapter);
pager.setmOnPageChangeListener(new CalendarPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
currentView = viewAdapter.getViews().get(position % 3);
currentDay = currentView.getSeedDay();
updateCalendar();
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
private void initListener() {
onSelectDateListener = offset -> pager.selectOtherMonth(offset);
clickListener = new CalendarView.OnCalendarClickListener() {
@Override
public void OnClick(CalendarDay day) {
// updateSchedule(day);
}
@Override
public void OnLongClick(CalendarDay day) {
}
};
}
@SuppressLint("SetTextI18n")
private void updateCalendar() {
tvMonth.setText(currentDay.getMonth() + "");
tvYear.setText(currentDay.getYear() + "");
}
}

@ -1,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,3 +0,0 @@
<resources>
<string name="app_name">My Application</string>
</resources>

@ -1,4 +0,0 @@
include ':DataBase'
include ':app'
rootProject.name = "My Application"
include ':CalendarView'

@ -12,7 +12,8 @@
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/CalendarView" />
<option value="$PROJECT_DIR$/DataBase" />
<option value="$PROJECT_DIR$/Database" />
<option value="$PROJECT_DIR$/Zone" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>

@ -21,5 +21,15 @@
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
<remote-repository>
<option name="id" value="MavenRepo" />
<option name="name" value="MavenRepo" />
<option name="url" value="https://repo.maven.apache.org/maven2/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="https://oss.sonatype.org/content/repositories/snapshots/" />
</remote-repository>
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>

@ -1,13 +1,14 @@
plugins {
id 'com.android.library'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
buildToolsVersion "30.0.2"
defaultConfig {
minSdkVersion 29
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
@ -30,10 +31,10 @@ android {
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation project(path: ':DataBase')
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
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'
}
}

@ -0,0 +1,26 @@
package com.diary.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.diary.calendarview.test", appContext.getPackageName());
}
}

@ -133,7 +133,7 @@ public class CalendarPager extends ViewPager {
/**
*
*a
*
* @return
*/
public int getTopMovableDistance() {

@ -15,7 +15,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.showme.database.utils.ScheduleSQLUtils;
import com.diary.database.utils.ScheduleSQLUtils;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -132,9 +132,9 @@ public class CalendarUtils {
if (date.equals(CalendarViewAdapter.loadSelectedDate())) {
date.setSelectState(State.DAY_SELECT);
}
// if (ScheduleSQLUtils.isScheduleMarked(date.toString())) {
// date.setMarkSchedule(true);
// }
if (ScheduleSQLUtils.isScheduleMarked(date.toString())) {
date.setMarkSchedule(true);
}
}
return dates;
}

@ -0,0 +1,66 @@
package com.idealist.calendarview;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.diary.database.utils.ScheduleSQLUtils;
import java.util.ArrayList;
import java.util.List;
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements
View.OnClickListener{
private List<String> mDatabase;
private OnItemClickListener onItemClickListener = null;
public RecyclerViewAdapter(List<String> mDatabase) {
super();
this.mDatabase = mDatabase;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = View.inflate(parent.getContext(), R.layout.schedule_item, null);
view.setOnClickListener(this);
return new RecyclerViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (!(holder instanceof RecyclerViewHolder))
return;
holder.itemView.setTag(position);
String text = mDatabase.get(position);
((RecyclerViewHolder) holder).timeTextView.setText(ScheduleSQLUtils.extractScheduleTime(text));
((RecyclerViewHolder) holder).titleTextView.setText(ScheduleSQLUtils.extractScheduleName(text));
}
@Override
public int getItemCount() {
return mDatabase.size();
}
@Override
public void onClick(View v) {
if (onItemClickListener != null) {
onItemClickListener.onItemClick(v, (int) v.getTag());
}
}
public void setmDatabase(List<String> mDatabase) {
this.mDatabase = mDatabase;
}
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
this.onItemClickListener = onItemClickListener;
}
public interface OnItemClickListener {
void onItemClick(View view, int position);
}
}

@ -0,0 +1,141 @@
package com.idealist.calendarview;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import static android.content.ContentValues.TAG;
public class RecyclerViewBehavior extends CoordinatorLayout.Behavior<RecyclerView> {
private int initOffset = -1;
private int minOffset = -1;
private int bottomOffset = -1;
private Context context;
private boolean initiated = false;
boolean hidingTop = false;
boolean showingTop = false;
public RecyclerViewBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
}
@Override
public boolean onLayoutChild(@NonNull CoordinatorLayout parent, @NonNull RecyclerView child, int layoutDirection) {
parent.onLayoutChild(child, layoutDirection);
CalendarPager calendarPager = getCalendarPager(parent);
initMinOffsetAndInitOffset(parent, child, calendarPager);
return true;
}
private void initMinOffsetAndInitOffset(CoordinatorLayout parent, RecyclerView child, CalendarPager pager) {
if (pager.getBottom() > 0 && initOffset == -1) {
initOffset = pager.getMeasuredHeight();
CalendarAttr.setRecTop(initOffset);
}
if (pager.getBottom() > 0 && bottomOffset == -1) {
bottomOffset = State.DEFAULT_ITEM_HEIGHT_FULL * 6;
}
if (!initiated) {
initOffset = pager.getMeasuredHeight();
CalendarAttr.setRecTop(initOffset);
initiated = true;
}
child.offsetTopAndBottom(CalendarAttr.getRecTop());
minOffset = getCalendarPager(parent).getItemHeight();
}
@Override
public boolean onStartNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull RecyclerView child, @NonNull View directTargetChild, @NonNull View target, int axes, int type) {
return (axes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0;
}
@Override
public void onNestedPreScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull RecyclerView child, @NonNull View target, int dx, int dy, @NonNull int[] consumed, int type) {
super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type);
child.setVerticalScrollBarEnabled(true);
CalendarPager pager = (CalendarPager) coordinatorLayout.getChildAt(0);
if (pager.getPageScrollState() != ViewPager.SCROLL_STATE_IDLE) {
consumed[1] = dy;
Log.w("ldf", "onNestedPreScroll: MonthPager dragging");
Toast.makeText(context, "loading month data", Toast.LENGTH_SHORT).show();
return;
}
// 上滑,正在隐藏顶部的日历
hidingTop = dy > 0;
// 下滑,正在展示顶部的日历
showingTop = dy < 0 && !target.canScrollVertically(-1);
Log.i("recycleBehavior", "hidingTop: " + hidingTop + " showingTop: " + showingTop);
if (hidingTop || showingTop) {
if (pager.getScrollLevel() == State.LEVEL_TOP) {
consumed[1] = CalendarUtils.scroll(child, dy,
State.DEFAULT_ITEM_HEIGHT,
State.DEFAULT_ITEM_HEIGHT * 6 + 10);
} else if (pager.getScrollLevel() == State.LEVEL_MEDIUM) {
consumed[1] = CalendarUtils.scroll(child, dy,
State.DEFAULT_ITEM_HEIGHT,
State.DEFAULT_ITEM_HEIGHT_FULL * 6);
}
CalendarAttr.setRecTop(child.getTop());
}
}
@Override
public void onStopNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull RecyclerView child, @NonNull View target, int type) {
super.onStopNestedScroll(coordinatorLayout, child, target, type);
CalendarPager pager = (CalendarPager) getCalendarPager(coordinatorLayout);
CalendarViewAdapter adapter = (CalendarViewAdapter) pager.getAdapter();
if (pager.getScrollLevel() == State.LEVEL_TOP) {
if (CalendarAttr.getRecTop() - minOffset > CalendarUtils.getTouchSlop(context) && showingTop
&& CalendarAttr.getRecTop() < initOffset + 110) {
pager.setScrollLevel(State.LEVEL_MEDIUM);
adapter.changeCalendarType(State.VIEW_MONTH);
CalendarUtils.scrollTo(coordinatorLayout, child, getCalendarPager(coordinatorLayout).getViewHeight(), 500);
CalendarUtils.forceStopRecyclerViewScroll(child);
} else {
CalendarUtils.scrollTo(coordinatorLayout, child, getCalendarPager(coordinatorLayout).getItemHeight(), 150);
}
} else if (pager.getScrollLevel() == State.LEVEL_MEDIUM) {
if (initOffset - CalendarAttr.getRecTop() > CalendarUtils.getTouchSlop(context) && hidingTop) {
pager.setScrollLevel(State.LEVEL_TOP);
adapter.changeCalendarType(State.VIEW_WEEK);
CalendarUtils.scrollTo(coordinatorLayout, child, getCalendarPager(coordinatorLayout).getItemHeight(), 500);
CalendarUtils.forceStopRecyclerViewScroll(child);
} else if (CalendarAttr.getRecTop() - initOffset > CalendarUtils.getTouchSlop(context) && showingTop) {
pager.setScrollLevel(State.LEVEL_BOTTOM);
adapter.changeCalendarType(State.VIEW_FULL);
CalendarUtils.scrollTo(coordinatorLayout, child, getCalendarPager(coordinatorLayout).getViewHeight(), 500);
CalendarUtils.forceStopRecyclerViewScroll(child);
} else {
CalendarUtils.scrollTo(coordinatorLayout, child, getCalendarPager(coordinatorLayout).getViewHeight(), 150);
}
}
}
@Override
public boolean onNestedFling(@NonNull CoordinatorLayout coordinatorLayout, @NonNull RecyclerView child, @NonNull View target, float velocityX, float velocityY, boolean consumed) {
return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
}
@Override
public boolean onNestedPreFling(@NonNull CoordinatorLayout coordinatorLayout, @NonNull RecyclerView child, @NonNull View target, float velocityX, float velocityY) {
return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY);
}
private CalendarPager getCalendarPager(CoordinatorLayout parent) {
return (CalendarPager) parent.getChildAt(0);
}
}

@ -0,0 +1,20 @@
package com.idealist.calendarview;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
public class RecyclerViewHolder extends RecyclerView.ViewHolder {
public TextView timeTextView;
public TextView titleTextView;
public RecyclerViewHolder(@NonNull View itemView) {
super(itemView);
timeTextView = itemView.findViewById(R.id.schedule_time);
titleTextView = itemView.findViewById(R.id.schedule_title);
}
}

@ -0,0 +1,30 @@
package com.idealist.calendarview;
import android.graphics.Rect;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
import java.util.HashMap;
public class SpaceItemDecoration extends RecyclerView.ItemDecoration {
private int mSpace;
public SpaceItemDecoration(int mSpace) {
this.mSpace = mSpace;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
outRect.left = mSpace;
outRect.right = mSpace;
outRect.bottom = mSpace;
if (parent.getChildAdapterPosition(view) == 0) {
outRect.top = mSpace;
}
}
}

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="#000000"/>
</shape>
</item>
<item
android:left="1dp">
<shape>
<solid android:color="#ffffff"/>
</shape>
</item>
</layer-list>

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingEnd="10dp">
<TextView
android:id="@+id/schedule_time"
android:layout_width="40dp"
android:layout_height="match_parent"
android:text="1:00\n7:00"
android:textSize="14sp"
android:gravity="center"/>
<TextView
android:id="@+id/schedule_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="12dp"
android:layout_marginLeft="12dp"
android:layout_toEndOf="@+id/schedule_time"
android:layout_toRightOf="@+id/schedule_time"
android:gravity="center_vertical"
android:paddingLeft="20dp"
android:text="schedule"
android:textSize="24sp"
android:textStyle="bold"
android:background="@drawable/schedule_border"/>
</RelativeLayout>
</LinearLayout>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="MyView">
<attr name="item_height" format="dimension"/>
<attr name="text_size" format="dimension"/>
</declare-styleable>
</resources>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="weekIndicatorStyle">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_weight">1</item>
<item name="android:gravity">center</item>
<item name="android:textSize">13sp</item>
<item name="android:textColor">#ff25adff</item>
</style>
</resources>

@ -4,10 +4,10 @@ plugins {
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
buildToolsVersion "30.0.2"
defaultConfig {
minSdkVersion 29
minSdkVersion 17
targetSdkVersion 30
versionCode 1
versionName "1.0"

@ -1,4 +1,4 @@
package com.showme.database;
package com.diary.database;
import android.content.Context;
@ -21,6 +21,6 @@ public class ExampleInstrumentedTest {
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.showme.database.test", appContext.getPackageName());
assertEquals("com.diary.database.test", appContext.getPackageName());
}
}

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.showme.database">
package="com.diary.database">
</manifest>

@ -1,4 +1,4 @@
package com.showme.database.DatabaseHelper;
package com.diary.database.DatabaseHelper;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

@ -1,4 +1,4 @@
package com.showme.database.DatabaseHelper;
package com.diary.database.DatabaseHelper;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

@ -1,7 +1,9 @@
package com.showme.database;
package com.diary.database;
import android.database.sqlite.SQLiteDatabase;
import java.util.List;
public class MySQLiteDatabase {
public static SQLiteDatabase scheduleSQL;

@ -1,8 +1,8 @@
package com.showme.database.utils;
package com.diary.database.utils;
import android.database.sqlite.SQLiteDatabase;
import com.showme.database.MySQLiteDatabase;
import com.diary.database.MySQLiteDatabase;
public class CourseSQLUtils {
private static SQLiteDatabase courseSQL = MySQLiteDatabase.courseSQL;

@ -1,9 +1,9 @@
package com.showme.database.utils;
package com.diary.database.utils;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.showme.database.MySQLiteDatabase;
import com.diary.database.MySQLiteDatabase;
import java.util.ArrayList;
import java.util.List;

@ -7,8 +7,8 @@ android {
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.showme.myapplication"
minSdkVersion 29
applicationId "com.diary.showme"
minSdkVersion 17
targetSdkVersion 30
versionCode 1
versionName "1.0"
@ -33,8 +33,13 @@ 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 'cc.trity.floatingactionbutton:library:1.0.0'
implementation 'org.greenrobot:eventbus:3.0.0'
implementation 'com.chanven.lib:cptr:1.1.0'
implementation 'com.jakewharton:butterknife:8.0.1'
implementation project(path: ':Database')
annotationProcessor 'com.jakewharton:butterknife-compiler:8.0.1'
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'

@ -0,0 +1,18 @@
{
"version": 2,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.diary.showme",
"variantName": "processReleaseResources",
"elements": [
{
"type": "SINGLE",
"filters": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
]
}

@ -1,4 +1,4 @@
package com.showme.myapplication;
package com.diary.showme;
import android.content.Context;
@ -21,6 +21,6 @@ public class ExampleInstrumentedTest {
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.showme.myapplication", appContext.getPackageName());
assertEquals("com.diary.showme", appContext.getPackageName());
}
}

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.diary.showme">
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Showme">
<activity android:name=".Zone.AddZoneActivity"></activity>
<activity android:name=".Zone.ZoneActivity" />
<activity android:name=".Zone.VideoBrowerActivity" />
<activity android:name=".Zone.AddActivity" />
<activity android:name=".diary.ui.UpdateDiaryActivity" />
<activity android:name=".diary.ui.DiaryActivity" />
<activity android:name=".diary.ui.AddDiaryActivity" />
<activity android:name=".Course.AddCourseActivity" />
<activity android:name=".Course.CourseActivity" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Schedule.AddScheduleActivity" />
<activity android:name=".Schedule.EditScheduleActivity" />
</application>
</manifest>

@ -0,0 +1,220 @@
package com.diary.showme;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.diary.database.DatabaseHelper.CourseSQLHelper;
import com.diary.database.DatabaseHelper.ScheduleSQLHelper;
import com.diary.database.MySQLiteDatabase;
import com.diary.database.utils.ScheduleSQLUtils;
import com.diary.showme.Course.CourseActivity;
import com.diary.showme.Schedule.AddScheduleActivity;
import com.diary.showme.Schedule.EditScheduleActivity;
import com.diary.showme.diary.ui.DiaryActivity;
import com.idealist.calendarview.CalendarAttr;
import com.idealist.calendarview.CalendarDay;
import com.idealist.calendarview.CalendarPager;
import com.idealist.calendarview.CalendarUtils;
import com.idealist.calendarview.CalendarView;
import com.idealist.calendarview.CalendarViewAdapter;
import com.idealist.calendarview.RecyclerViewAdapter;
import com.idealist.calendarview.SpaceItemDecoration;
import com.idealist.calendarview.State;
import com.idealist.calendarview.interf.OnSelectDateListener;
import java.util.List;
import java.util.TimeZone;
import cc.trity.floatingactionbutton.FloatingActionButton;
public class MainActivity extends AppCompatActivity {
private TextView tvMonth;
private TextView tvYear;
private CalendarDay currentDay;
private CalendarView currentView;
private CalendarPager pager;
private RecyclerView schedule;
private CalendarViewAdapter viewAdapter;
private CalendarAttr attr;
private OnSelectDateListener onSelectDateListener;
private CalendarView.OnCalendarClickListener clickListener;
private FloatingActionButton scheduleFAB, courseFAB, diaryFAB, zoneFAB;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getRealMetrics(dm);
int height = dm.heightPixels;
State.setDefaultItemHeightFull((height - 42 - 3*State.DEFAULT_ITEM_HEIGHT) / 6);
initSQL();
initCalendar();
initFAB();
initCourseB();
initDiaryB();
attr = new CalendarAttr();
attr.setCalendarType(State.VIEW_MONTH);
attr.setScrollLevel(State.LEVEL_MEDIUM);
initListener();
viewAdapter = new CalendarViewAdapter(this, attr, onSelectDateListener,
clickListener);
initPager();
initSchedule();
}
private void initSQL() {
ScheduleSQLHelper myScheduleSQLHelper = new ScheduleSQLHelper(this);
SQLiteDatabase scheduleSQL = myScheduleSQLHelper.getWritableDatabase();
CourseSQLHelper myCourseSQLHelper = new CourseSQLHelper(this);
SQLiteDatabase courseSQL = myCourseSQLHelper.getWritableDatabase();
MySQLiteDatabase.scheduleSQL = scheduleSQL;
MySQLiteDatabase.courseSQL = courseSQL;
}
private void initFAB() {
scheduleFAB = findViewById(R.id.add_schedule);
scheduleFAB.setOnClickListener(v -> {
Toast.makeText(getApplicationContext(), viewAdapter.getSelectDay().toString(), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(MainActivity.this, AddScheduleActivity.class);
intent.putExtra("date", viewAdapter.getSelectDay().toString());
startActivityForResult(intent, 0);
});
}
private void initCourseB() {
courseFAB = findViewById(R.id.course_entry);
courseFAB.setOnClickListener(v -> {
Intent intent = new Intent(MainActivity.this, CourseActivity.class);
startActivity(intent);
});
}
private void initDiaryB() {
diaryFAB = findViewById(R.id.diary_entry);
diaryFAB.setOnClickListener(v -> {
Intent intent = new Intent(MainActivity.this, DiaryActivity.class);
startActivity(intent);
});
}
private void initCalendar() {
tvMonth = findViewById(R.id.custom_month_view);
tvYear = findViewById(R.id.custom_year_view);
currentDay = CalendarUtils.getCurrDay();
updateCalendar();
}
private void initPager() {
pager = findViewById(R.id.custom_vp);
pager.setAttr(attr);
pager.setAdapter(viewAdapter);
pager.setmOnPageChangeListener(new CalendarPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
currentView = viewAdapter.getViews().get(position % 3);
currentDay = currentView.getSeedDay();
updateCalendar();
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
private void initListener() {
onSelectDateListener = offset -> pager.selectOtherMonth(offset);
clickListener = new CalendarView.OnCalendarClickListener() {
@Override
public void OnClick(CalendarDay day) {
updateSchedule(day);
}
@Override
public void OnLongClick(CalendarDay day) {
}
};
}
private void initSchedule() {
schedule = findViewById(R.id.list_item);
List<String> mData = ScheduleSQLUtils.queryByDate(currentDay.toString());
RecyclerViewAdapter adapter = new RecyclerViewAdapter(mData);
adapter.setOnItemClickListener((view, position) -> {
Intent intent = new Intent(MainActivity.this, EditScheduleActivity.class);
intent.putExtra("date", viewAdapter.getSelectDay().toString());
String name = ((TextView) view.findViewById(R.id.schedule_title)).getText().toString();
intent.putExtra("scheduleName", name);
startActivityForResult(intent, 0);
});
schedule.setAdapter(adapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
schedule.setLayoutManager(layoutManager);
schedule.addItemDecoration(new SpaceItemDecoration(30));
}
@SuppressLint("SetTextI18n")
private void updateCalendar() {
tvMonth.setText(currentDay.getMonth() + "");
tvYear.setText(currentDay.getYear() + "");
}
private void updateSchedule(CalendarDay day) {
ScheduleSQLUtils.queryByDate(day.toString());
List<String> mData = ScheduleSQLUtils.queryByDate(day.toString());
RecyclerViewAdapter adapter = (RecyclerViewAdapter) schedule.getAdapter();
adapter.setmDatabase(mData);
adapter.notifyDataSetChanged();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0 && resultCode == Activity.RESULT_OK) {
updateSchedule(viewAdapter.getSelectDay());
viewAdapter.updateViewScheduleChange();
}
}
}

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save