├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── drawable │ │ │ ├── add_main.png │ │ │ ├── today_button_bg.xml │ │ │ ├── alarm_toggle_button.xml │ │ │ ├── edit_text_bg.xml │ │ │ ├── shape_no_corner_without_bottom.xml │ │ │ ├── shape_top_corner_no_bottom_line.xml │ │ │ └── shape_bottom_corner_no_top_line.xml │ │ ├── drawable-hdpi │ │ │ ├── icon_ok.png │ │ │ ├── ic_alarm_off.png │ │ │ ├── ic_alarm_on.png │ │ │ ├── icon_delete.png │ │ │ ├── img_line_point.png │ │ │ ├── file_picker_file.png │ │ │ ├── file_picker_home.png │ │ │ ├── file_picker_updir.png │ │ │ ├── file_picker_folder.png │ │ │ ├── color_picker_cursor_top.png │ │ │ └── color_picker_cursor_bottom.png │ │ ├── drawable-xhdpi │ │ │ ├── bottom.png │ │ │ ├── frame.png │ │ │ ├── mask.png │ │ │ ├── btn_pressed.png │ │ │ ├── ic_dust_big.png │ │ │ ├── ic_fog_big.png │ │ │ ├── ic_haze_big.png │ │ │ ├── ic_snow_big.png │ │ │ ├── btn_unpressed.png │ │ │ ├── ic_cloudy_big.png │ │ │ ├── ic_shower_big.png │ │ │ ├── ic_sleet_big.png │ │ │ ├── ic_sunny_big.png │ │ │ ├── ic_default_big.png │ │ │ ├── ic_hailstone_big.png │ │ │ ├── ic_heavyrain_big.png │ │ │ ├── ic_heavysnow_big.png │ │ │ ├── ic_lightrain_big.png │ │ │ ├── ic_overcast_big.png │ │ │ ├── ic_rainsnow_big.png │ │ │ ├── ic_sandstorm_big.png │ │ │ ├── ic_dustblowing_big.png │ │ │ ├── hurricane_day_night.png │ │ │ ├── ic_moderraterain_big.png │ │ │ ├── ic_thundeshower_big.png │ │ │ ├── freezing_rain_day_night.png │ │ │ └── ic_thundeshowehail_big.png │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ ├── anim │ │ │ ├── slide_in_left.xml │ │ │ ├── slide_in_right.xml │ │ │ ├── slide_out_left.xml │ │ │ ├── slide_out_right.xml │ │ │ ├── slide_bottom_to_up.xml │ │ │ └── slide_up_to_bottom.xml │ │ ├── values │ │ │ ├── attrs.xml │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ └── styles.xml │ │ ├── values-v19 │ │ │ └── styles.xml │ │ ├── layout │ │ │ ├── toolbar.xml │ │ │ ├── activity_record_list.xml │ │ │ ├── listview_item_check.xml │ │ │ ├── item_alarm_notice.xml │ │ │ ├── item_time_line.xml │ │ │ ├── shifts_work_item.xml │ │ │ ├── activity_alarm_notice.xml │ │ │ ├── alarm_record_item.xml │ │ │ ├── toolbar_button.xml │ │ │ ├── activity_about.xml │ │ │ ├── activity_main.xml │ │ │ ├── activity_add_shifts_work.xml │ │ │ └── activity_add_daily.xml │ │ ├── values-v21 │ │ │ └── styles.xml │ │ ├── menu │ │ │ └── menu_main.xml │ │ └── layout-land │ │ │ └── content_main.xml │ │ ├── java │ │ └── com │ │ │ └── jjforever │ │ │ └── wgj │ │ │ └── maincalendar │ │ │ ├── Model │ │ │ ├── KeyValue.java │ │ │ ├── RecordShowType.java │ │ │ ├── RecordType.java │ │ │ ├── ICalendarRecord.java │ │ │ ├── LunarHoliday.java │ │ │ ├── SolarHoliday.java │ │ │ ├── AlarmTime.java │ │ │ ├── GlobalSetting.java │ │ │ ├── ShiftsWorkRecord.java │ │ │ ├── ShiftsWorkItem.java │ │ │ └── DailyRecord.java │ │ │ ├── RecordDateComparator.java │ │ │ ├── wheelpicker │ │ │ └── picker │ │ │ │ ├── SexPicker.java │ │ │ │ ├── ChineseZodiacPicker.java │ │ │ │ ├── ConstellationPicker.java │ │ │ │ ├── NumberPicker.java │ │ │ │ ├── WheelPicker.java │ │ │ │ ├── LunarMonthPicker.java │ │ │ │ ├── WeatherPicker.java │ │ │ │ └── OptionPicker.java │ │ │ ├── monthui │ │ │ ├── CalendarViewBuilder.java │ │ │ ├── FrameAnimationController.java │ │ │ ├── CalendarViewPagerAdapter.java │ │ │ ├── ThemeStyle.java │ │ │ └── CalendarViewPagerListener.java │ │ │ ├── services │ │ │ └── CalendarReceiver.java │ │ │ ├── CheckableRelativeLayout.java │ │ │ ├── filepicker │ │ │ ├── widget │ │ │ │ └── MarqueeTextView.java │ │ │ └── entity │ │ │ │ └── FileItem.java │ │ │ ├── MainApplication.java │ │ │ ├── weather │ │ │ └── util │ │ │ │ ├── WeatherConstants.java │ │ │ │ └── WeatherIconUtil.java │ │ │ ├── common │ │ │ ├── AppConfig.java │ │ │ ├── util │ │ │ │ ├── ScreenUtils.java │ │ │ │ └── CompatUtils.java │ │ │ └── popup │ │ │ │ └── Popup.java │ │ │ ├── GradientShaderTextView.java │ │ │ ├── toolbar │ │ │ ├── ToolBarHelper.java │ │ │ └── ToolBarActivity.java │ │ │ ├── AboutActivity.java │ │ │ ├── AlarmTipAdapter.java │ │ │ ├── BLL │ │ │ └── GlobalSettingMng.java │ │ │ ├── dialogpicker │ │ │ └── picker │ │ │ │ └── DialogPicker.java │ │ │ ├── AppConstants.java │ │ │ ├── listviewpicker │ │ │ └── picker │ │ │ │ ├── WeekAdapter.java │ │ │ │ └── WeekPicker.java │ │ │ ├── ShiftsWorkAdapter.java │ │ │ ├── RecordAdapter.java │ │ │ ├── util │ │ │ └── Holiday.java │ │ │ └── AlarmAdapter.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── doc └── screenshot │ ├── 0.jpg │ ├── 1.jpg │ ├── 2.jpg │ ├── 3.jpg │ └── 4.jpg ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /doc/screenshot/0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/doc/screenshot/0.jpg -------------------------------------------------------------------------------- /doc/screenshot/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/doc/screenshot/1.jpg -------------------------------------------------------------------------------- /doc/screenshot/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/doc/screenshot/2.jpg -------------------------------------------------------------------------------- /doc/screenshot/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/doc/screenshot/3.jpg -------------------------------------------------------------------------------- /doc/screenshot/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/doc/screenshot/4.jpg -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/add_main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable/add_main.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-hdpi/icon_ok.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/bottom.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/frame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/frame.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/mask.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_alarm_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-hdpi/ic_alarm_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_alarm_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-hdpi/ic_alarm_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-hdpi/icon_delete.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/btn_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/btn_pressed.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_dust_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_dust_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_fog_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_fog_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_haze_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_haze_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_snow_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_snow_big.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/img_line_point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-hdpi/img_line_point.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/btn_unpressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/btn_unpressed.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_cloudy_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_cloudy_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_shower_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_shower_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_sleet_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_sleet_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_sunny_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_sunny_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/file_picker_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-hdpi/file_picker_file.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/file_picker_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-hdpi/file_picker_home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/file_picker_updir.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-hdpi/file_picker_updir.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_default_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_default_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_hailstone_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_hailstone_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_heavyrain_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_heavyrain_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_heavysnow_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_heavysnow_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_lightrain_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_lightrain_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_overcast_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_overcast_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_rainsnow_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_rainsnow_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_sandstorm_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_sandstorm_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/file_picker_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-hdpi/file_picker_folder.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_dustblowing_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_dustblowing_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/hurricane_day_night.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/hurricane_day_night.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_moderraterain_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_moderraterain_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_thundeshower_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_thundeshower_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/color_picker_cursor_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-hdpi/color_picker_cursor_top.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/freezing_rain_day_night.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/freezing_rain_day_night.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_thundeshowehail_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-xhdpi/ic_thundeshowehail_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/color_picker_cursor_bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainh/MainCalendar/HEAD/app/src/main/res/drawable-hdpi/color_picker_cursor_bottom.png -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_in_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_in_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_out_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_out_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_bottom_to_up.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_up_to_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Mar 15 20:34:48 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/today_button_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/alarm_toggle_button.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/Model/KeyValue.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.Model; 2 | 3 | /** 4 | * Created by Wgj on 2016/9/29. 5 | * 键值类 6 | */ 7 | public class KeyValue { 8 | public long Index; 9 | public String Title; 10 | 11 | public KeyValue(){ 12 | } 13 | 14 | public KeyValue(long index, String title){ 15 | this.Index = index; 16 | this.Title = title; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/Model/RecordShowType.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.Model; 2 | 3 | /** 4 | * Created by Wgj on 2016/8/28. 5 | * 特殊日期的显示方式 6 | */ 7 | public final class RecordShowType { 8 | // 不在日历中显示 9 | public static int HIDE = 0; 10 | // 文字显示 11 | public static int TEXT = 1; 12 | // 特殊点显示 13 | public static int DOT = 2; 14 | // 文字显示+特殊颜色点显示 15 | public static int TEXT_DOT = TEXT | DOT; 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/Model/RecordType.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.Model; 2 | 3 | /** 4 | * Created by Wgj on 2016/8/28. 5 | * 记录类型定义 6 | */ 7 | public final class RecordType { 8 | // 阳历节日 9 | public static int SOLAR_HOLIDAY = 1; 10 | // 农历节日 11 | public static int LUNAR_HOLIDAY = 2; 12 | // 节气 13 | // public static int SOLAR_TERM = 3; 14 | // 日常记录 15 | public static int DAILY_RECORD = 7; 16 | // 闹钟记录 17 | public static int ALARM_RECORD = 8; 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/RecordDateComparator.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar; 2 | 3 | import com.jjforever.wgj.maincalendar.Model.ICalendarRecord; 4 | 5 | import java.util.Comparator; 6 | 7 | /** 8 | * Created by Wgj on 2016/8/29. 9 | * 日志记录时间比较器 10 | */ 11 | class RecordDateComparator implements Comparator { 12 | @Override 13 | public int compare(ICalendarRecord lhs, ICalendarRecord rhs) { 14 | return rhs.getRecordTime().compareTo(lhs.getRecordTime()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/edit_text_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/values-v19/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | 39 | # Keystore files 40 | *.jks 41 | .idea 42 | -------------------------------------------------------------------------------- /app/src/main/res/layout/toolbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\Apply\Work\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/Model/ICalendarRecord.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.Model; 2 | 3 | import com.jjforever.wgj.maincalendar.util.LunarCalendar; 4 | 5 | /** 6 | * Created by Wgj on 2016/8/28. 7 | * 日历记录接口 8 | */ 9 | public interface ICalendarRecord { 10 | /** 11 | * 获取该记录的类型 12 | * @return RecordType中定义的类型 13 | */ 14 | int getType(); 15 | 16 | /** 17 | * 获取记录的标题 18 | * @return 该记录的标题 19 | */ 20 | String getTitle(); 21 | 22 | /** 23 | * 获取记录时间 24 | * @return 记录时间 25 | */ 26 | LunarCalendar getRecordTime(); 27 | 28 | /** 29 | * 获取在日历中的显示方式 30 | * @return 是否显示在日历中 RecordShowType中定义方式 31 | */ 32 | int showType(); 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/wheelpicker/picker/SexPicker.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.wheelpicker.picker; 2 | 3 | import android.app.Activity; 4 | 5 | /** 6 | * 性别 7 | * 8 | * @author 李玉江[QQ :1032694760] 9 | * @version 2015 /12/15 10 | */ 11 | public class SexPicker extends OptionPicker { 12 | 13 | /** 14 | * Instantiates a new Sex picker. 15 | * 16 | * @param activity the activity 17 | */ 18 | public SexPicker(Activity activity) { 19 | super(activity, new String[]{ 20 | "男", 21 | "女", 22 | "保密" 23 | }); 24 | } 25 | 26 | /** 27 | * 仅仅提供男和女来选择 28 | */ 29 | public void onlyMaleAndFemale() { 30 | options.remove(options.size() - 1); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/monthui/CalendarViewBuilder.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.monthui; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * Created by Wgj on 2016/8/10. 7 | * 生成日历视图集合 8 | */ 9 | public class CalendarViewBuilder { 10 | /** 11 | * 创建多个CalendarView,默认视图为月视图样式 12 | * @param context 内容提供器 13 | * @param count 生成个数 14 | * @param callBack 回调函数 15 | * @return 日历视图集合 16 | */ 17 | public static CalendarView[] createMassCalendarViews(Context context, int count, CalendarView.CallBack callBack){ 18 | CalendarView[] calendarViews = new CalendarView[count]; 19 | for(int i = 0; i < count;i++){ 20 | calendarViews[i] = new CalendarView(context, callBack); 21 | } 22 | return calendarViews; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_no_corner_without_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/wheelpicker/picker/ChineseZodiacPicker.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.wheelpicker.picker; 2 | 3 | import android.app.Activity; 4 | 5 | /** 6 | * 生肖选择器 7 | * 8 | * @author 李玉江[QQ :1032694760] 9 | * @version 2015 /12/15 10 | */ 11 | public class ChineseZodiacPicker extends OptionPicker { 12 | 13 | /** 14 | * Instantiates a new Chinese zodiac picker. 15 | * 16 | * @param activity the activity 17 | */ 18 | public ChineseZodiacPicker(Activity activity) { 19 | super(activity, new String[]{ 20 | "鼠", 21 | "牛", 22 | "虎", 23 | "兔", 24 | "龙", 25 | "蛇", 26 | "马", 27 | "羊", 28 | "猴", 29 | "鸡", 30 | "狗", 31 | "猪", 32 | }); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/wheelpicker/picker/ConstellationPicker.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.wheelpicker.picker; 2 | 3 | import android.app.Activity; 4 | 5 | /** 6 | * 星座选择器 7 | * 8 | * @author 李玉江[QQ :1032694760] 9 | * @version 2015 /12/15 10 | */ 11 | public class ConstellationPicker extends OptionPicker { 12 | 13 | /** 14 | * Instantiates a new Constellation picker. 15 | * 16 | * @param activity the activity 17 | */ 18 | public ConstellationPicker(Activity activity) { 19 | super(activity, new String[]{ 20 | "水瓶", 21 | "双鱼", 22 | "白羊", 23 | "金牛", 24 | "双子", 25 | "巨蟹", 26 | "狮子", 27 | "处女", 28 | "天秤", 29 | "天蝎", 30 | "射手", 31 | "摩羯", 32 | }); 33 | setLabel("座"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_record_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/Model/LunarHoliday.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.Model; 2 | 3 | import com.jjforever.wgj.maincalendar.util.LunarCalendar; 4 | 5 | /** 6 | * Created by Wgj on 2016/8/28. 7 | * 农历节日实体类 8 | */ 9 | public class LunarHoliday implements ICalendarRecord { 10 | // 节日标题 11 | private String mTitle; 12 | 13 | public LunarHoliday(String title){ 14 | mTitle = title; 15 | } 16 | 17 | public int getType(){ 18 | return RecordType.LUNAR_HOLIDAY; 19 | } 20 | 21 | public String getTitle(){ 22 | return mTitle; 23 | } 24 | 25 | /** 26 | * 显示方式 27 | * @return RecordShowType.TEXT 28 | */ 29 | public int showType() { 30 | return RecordShowType.TEXT | RecordShowType.DOT; 31 | } 32 | 33 | /** 34 | * 该类是不包含记录时间的 35 | * @return null 36 | */ 37 | public LunarCalendar getRecordTime(){ 38 | return null; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/Model/SolarHoliday.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.Model; 2 | 3 | import com.jjforever.wgj.maincalendar.util.LunarCalendar; 4 | 5 | /** 6 | * Created by Wgj on 2016/8/28. 7 | * 阳历节日实体类定义 8 | */ 9 | public class SolarHoliday implements ICalendarRecord { 10 | // 节日标题 11 | private String mTitle; 12 | 13 | public SolarHoliday(String title){ 14 | mTitle = title; 15 | } 16 | 17 | public int getType(){ 18 | return RecordType.SOLAR_HOLIDAY; 19 | } 20 | 21 | public String getTitle(){ 22 | return mTitle; 23 | } 24 | 25 | /** 26 | * 显示方式 27 | * @return RecordShowType.TEXT 28 | */ 29 | public int showType() { 30 | return RecordShowType.TEXT | RecordShowType.DOT; 31 | } 32 | 33 | /** 34 | * 该类是不包含记录时间的 35 | * @return null 36 | */ 37 | public LunarCalendar getRecordTime(){ 38 | return null; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/services/CalendarReceiver.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.services; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | 7 | import com.jjforever.wgj.maincalendar.AppConstants; 8 | 9 | /** 10 | * Created by Wgj on 2016/10/5. 11 | * AlarmManager发送广播接收器 12 | */ 13 | public class CalendarReceiver extends BroadcastReceiver { 14 | /** 15 | * 每分钟检测启动一次后台服务 16 | * @param context 内容提供器 17 | * @param intent 传输数据 18 | */ 19 | @Override 20 | public void onReceive(Context context, Intent intent) { 21 | AppConstants.DLog("Receive start alarm service: " + intent.getAction()); 22 | // if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { 23 | // // 载入必须服务 24 | // AppConstants.loadGlobalService(context); 25 | // } 26 | context.startService(new Intent(context, CalendarService.class)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MainCalendar 2 | #### 一个小巧简洁的万年历,单纯的万年历 3 | 4 | ##### 基于Android Studio 2.3进行编译 5 | 本万年历主要实现了1900~2099年的阴阳历的共同显示及主要的节假日标示,在显示上方式过于臃肿。
6 | 实现的功能有日常的记录,闹钟功能,轮班功能。 7 | - 日常记录:记录指定日期的事情,可选择是否在日历界面中显示记录的事情; 8 | - 闹钟:实现了按指定阴阳历日期响一次闹钟,按周触发闹钟,阴阳历的每月触发闹钟,阴阳历的每年触发闹钟,指定天数为周期触发的闹钟(该闹钟可结合轮班功能使用); 9 | - 轮班:可根据设定周期的轮班设置哪一天是夜班或者白班,并在日历界面中显示出来。 10 | 11 | 其他的就是这些记录的管理,编辑,删除功能都已实现完善。
12 | 本项目借鉴并且使用了众多的开源项目,故在本软件基本完善并且使用了较长时间后进行开源,希望能帮助一些朋友。
13 | 项目中做了较详细的注释,有不足之处欢迎指出并帮助修改。
14 | 本项目在无意外情况下不会再做功能的增加,只做程序本身的加固及优化,如需添加功能可开分支或者另建项目。
15 | 项目运行图:
16 | ![主窗口](https://github.com/mainh/MainCalendar/blob/master/doc/screenshot/0.jpg "主窗口") 17 | ![闹钟添加窗口](https://github.com/mainh/MainCalendar/blob/master/doc/screenshot/1.jpg "闹钟添加窗口") 18 | ![轮班添加口](https://github.com/mainh/MainCalendar/blob/master/doc/screenshot/2.jpg "轮班添加窗口") 19 | ![闹钟记录窗口](https://github.com/mainh/MainCalendar/blob/master/doc/screenshot/3.jpg "闹钟记录窗口") 20 | ![系统设置窗口](https://github.com/mainh/MainCalendar/blob/master/doc/screenshot/4.jpg "系统设置窗口") 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/listview_item_check.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 17 | 18 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/CheckableRelativeLayout.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.widget.Checkable; 6 | import android.widget.RelativeLayout; 7 | 8 | import com.jjforever.wgj.maincalendar.monthui.ThemeStyle; 9 | 10 | /** 11 | * Created by Wgj on 2016/9/6. 12 | * 用于列表多选项定制 13 | */ 14 | public class CheckableRelativeLayout extends RelativeLayout implements Checkable { 15 | private boolean mChecked; 16 | 17 | public CheckableRelativeLayout(Context context, AttributeSet attrs) { 18 | super(context, attrs); 19 | } 20 | 21 | @Override 22 | public void setChecked(boolean checked) { 23 | mChecked = checked; 24 | setBackgroundColor(checked ? ThemeStyle.ItemSelected : ThemeStyle.BackColor); 25 | } 26 | 27 | @Override 28 | public boolean isChecked() { 29 | return mChecked; 30 | } 31 | 32 | @Override 33 | public void toggle() { 34 | setChecked(!mChecked); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_top_corner_no_bottom_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_bottom_corner_no_top_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 10 | 15 | 20 | 25 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/wheelpicker/picker/NumberPicker.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.wheelpicker.picker; 2 | 3 | import android.app.Activity; 4 | 5 | /** 6 | * 数字选择器 7 | * 8 | * @author 李玉江[QQ :1032694760] 9 | * @version 2015 /10/24 10 | */ 11 | public class NumberPicker extends OptionPicker { 12 | 13 | /** 14 | * Instantiates a new Number picker. 15 | * 16 | * @param activity the activity 17 | */ 18 | public NumberPicker(Activity activity) { 19 | super(activity, new String[]{}); 20 | } 21 | 22 | /** 23 | * Sets range. 24 | * 25 | * @param startNumber the start number 26 | * @param endNumber the end number 27 | */ 28 | public void setRange(int startNumber, int endNumber) { 29 | setRange(startNumber, endNumber, 1); 30 | } 31 | 32 | /** 33 | * Sets range. 34 | * 35 | * @param startNumber the start number 36 | * @param endNumber the end number 37 | * @param step the step 38 | */ 39 | public void setRange(int startNumber, int endNumber, int step) { 40 | for (int i = startNumber; i <= endNumber; i = i + step) { 41 | options.add(String.valueOf(i)); 42 | } 43 | } 44 | 45 | /** 46 | * Sets selected item. 47 | * 48 | * @param number the number 49 | */ 50 | public void setSelectedItem(int number) { 51 | setSelectedItem(String.valueOf(number)); 52 | } 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #fc4f4f 4 | #F24949 5 | #fc7531 6 | #fff6f2 7 | @color/colorPrimaryDark 8 | #66000000 9 | #fffffe 10 | #F7F7F7 11 | @color/colorAccent 12 | #c96e6e6e 13 | 14 | 15 | #80000000 16 | #66000000 17 | 19 | @color/colorPrimary 20 | @color/today 21 | #ff0095 22 | #fb5902 23 | #4201fbb8 24 | #4201fbb8 25 | #423701fb 26 | 27 | 28 | #cc333333 29 | @color/colorEditText 30 | #80000000 31 | #80000000 32 | 33 | #99000000 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/filepicker/widget/MarqueeTextView.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.filepicker.widget; 2 | 3 | import android.content.Context; 4 | import android.text.TextUtils; 5 | import android.util.AttributeSet; 6 | import android.view.Gravity; 7 | import android.widget.TextView; 8 | 9 | /** 10 | * 文本水平自动滚动(从右到左)。 11 | * 12 | * @author 李玉江[QQ :1023694760] 13 | * @version 2013 -1-11 14 | */ 15 | public class MarqueeTextView extends TextView { 16 | 17 | /** 18 | * Instantiates a new Marquee text view. 19 | * 20 | * @param context the context 21 | */ 22 | public MarqueeTextView(Context context) { 23 | this(context, null); 24 | } 25 | 26 | /** 27 | * Instantiates a new Marquee text view. 28 | * 29 | * @param context the context 30 | * @param attr the attr 31 | */ 32 | public MarqueeTextView(Context context, AttributeSet attr) { 33 | super(context, attr); 34 | setEllipsize(TextUtils.TruncateAt.MARQUEE); 35 | setMarqueeRepeatLimit(-1); 36 | setSingleLine(true); 37 | setHorizontallyScrolling(true); 38 | setClickable(true); 39 | setFocusable(true); 40 | setFocusableInTouchMode(true); 41 | setGravity(Gravity.CENTER); 42 | } 43 | 44 | /** 45 | * 必须已获取到焦点,才能即显滚动 46 | */ 47 | @Override 48 | public boolean isFocused() { 49 | return true; 50 | } 51 | 52 | @Override 53 | public boolean isPressed() { 54 | return true; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_alarm_notice.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 16 | 17 | 26 | 27 | 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/monthui/FrameAnimationController.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.monthui; 2 | 3 | import android.os.Handler; 4 | import android.os.Message; 5 | 6 | /** 7 | * Created by Wgj on 2016/8/20. 8 | * 开关按钮动画控制器 9 | */ 10 | public class FrameAnimationController { 11 | private static final int MSG_ANIMATE = 1000; 12 | 13 | public static final int ANIMATION_FRAME_DURATION = 1000 / 60; 14 | 15 | private static final Handler mHandler = new AnimationHandler(); 16 | 17 | private FrameAnimationController() { 18 | throw new UnsupportedOperationException(); 19 | } 20 | 21 | public static void requestAnimationFrame(Runnable runnable) { 22 | Message message = new Message(); 23 | message.what = MSG_ANIMATE; 24 | message.obj = runnable; 25 | mHandler.sendMessageDelayed(message, ANIMATION_FRAME_DURATION); 26 | } 27 | 28 | // public static void requestFrameDelay(Runnable runnable, long delay) { 29 | // Message message = new Message(); 30 | // message.what = MSG_ANIMATE; 31 | // message.obj = runnable; 32 | // mHandler.sendMessageDelayed(message, delay); 33 | // } 34 | 35 | private static class AnimationHandler extends Handler { 36 | public void handleMessage(Message m) { 37 | switch (m.what) { 38 | case MSG_ANIMATE: 39 | if (m.obj != null) { 40 | ((Runnable) m.obj).run(); 41 | } 42 | break; 43 | } 44 | } 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import android.os.StrictMode; 6 | 7 | import com.squareup.leakcanary.LeakCanary; 8 | import com.squareup.leakcanary.RefWatcher; 9 | 10 | import static android.os.Build.VERSION.SDK_INT; 11 | import static android.os.Build.VERSION_CODES.GINGERBREAD; 12 | 13 | /** 14 | * Created by Wgj on 2016/10/28. 15 | * 自定义的Application 16 | */ 17 | 18 | public class MainApplication extends Application { 19 | 20 | public static RefWatcher getRefWatcher(Context context) { 21 | MainApplication application = (MainApplication) context 22 | .getApplicationContext(); 23 | return application.refWatcher; 24 | } 25 | private RefWatcher refWatcher; 26 | 27 | @Override public void onCreate() { 28 | super.onCreate(); 29 | if (LeakCanary.isInAnalyzerProcess(this)) { 30 | // This process is dedicated to LeakCanary for heap analysis. 31 | // You should not init your app in this process. 32 | return; 33 | } 34 | 35 | enabledStrictMode(); 36 | refWatcher = LeakCanary.install(this); 37 | } 38 | 39 | private void enabledStrictMode() { 40 | if (SDK_INT >= GINGERBREAD) { 41 | StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() 42 | .detectAll() 43 | .penaltyLog() 44 | .penaltyDeath() 45 | .build()); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ?attr/actionBarSize 4 | 7dp 5 | 2dp 6 | 16dp 7 | 24dp 8 | 20sp 9 | 20dip 10 | 16sp 11 | @dimen/normal_font_size 12 | @dimen/normal_font_size 13 | 16dp 14 | 5dp 15 | 40dip 16 | 25dip 17 | 18dip 18 | 10dip 19 | 20 | 52dip 21 | 42dip 22 | 12dip 23 | 8dip 24 | 8dip 25 | 14sp 26 | 5dp 27 | 8dip 28 | 20dip 29 | 40dip 30 | 31 | 50dip 32 | 18sp 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/weather/util/WeatherConstants.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.weather.util; 2 | 3 | /** 4 | * Created by Wgj on 2016/8/24. 5 | * 天气情况定义 6 | */ 7 | public final class WeatherConstants { 8 | public static final int NO_VALUE_FLAG = -999;//无 9 | public static final int SUNNY = 0;//晴 10 | public static final int CLOUDY = 1;//多云 11 | public static final int OVERCAST = 2;//阴 12 | public static final int FOGGY = 3;//雾 13 | public static final int SEVERE_STORM = 4;//飓风 14 | public static final int HEAVY_STORM = 5;//大暴风雨 15 | public static final int STORM = 6;//暴风雨 16 | public static final int THUNDERSHOWER = 7;//雷阵雨 17 | public static final int SHOWER = 8;//阵雨 18 | public static final int HEAVY_RAIN = 9;//大雨 19 | public static final int MODERATE_RAIN = 10;//中雨 20 | public static final int LIGHT_RAIN = 11;//小雨 21 | public static final int SLEET = 12;//雨夹雪 22 | public static final int SNOWSTORM = 13;//暴雪 23 | public static final int SNOW_SHOWER = 14;//阵雪 24 | public static final int HEAVY_SNOW = 15;//大雪 25 | public static final int MODERATE_SNOW = 16;//中雪 26 | public static final int LIGHT_SNOW = 17;//小雪 27 | public static final int STRONG_SANDSTORM = 18;//强沙尘暴 28 | public static final int SANDSTORM = 19;//沙尘暴 29 | public static final int SAND = 20;//沙尘 30 | public static final int BLOWING_SAND = 21;//风沙 31 | public static final int ICE_RAIN = 22;//冻雨 32 | public static final int DUST = 23;//尘土 33 | public static final int HAZE = 24;//霾 34 | 35 | // 天气的开始结束代码 36 | public static final int START_CODE = SUNNY; 37 | public static final int END_CODE = HAZE; 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_time_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 18 | 19 | 27 | 28 | 29 | 37 | 38 | 44 | 45 | -------------------------------------------------------------------------------- /app/src/main/res/layout/shifts_work_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 19 | 29 | 40 | 41 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | signingConfigs { 5 | config { 6 | keyAlias 'Wgj' 7 | keyPassword '5075213' 8 | storeFile file('D:/Work/Android/JJForEverKey.jks') 9 | storePassword '823180671646' 10 | } 11 | } 12 | compileSdkVersion 23 13 | buildToolsVersion '25.0.0' 14 | defaultConfig { 15 | applicationId "com.jjforever.wgj.maincalendar" 16 | minSdkVersion 19 17 | targetSdkVersion 23 18 | versionName '1.2' 19 | versionCode 3 20 | } 21 | buildTypes { 22 | release { 23 | minifyEnabled true 24 | //是否移除无用的资源 25 | shrinkResources true 26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 27 | zipAlignEnabled true 28 | signingConfig signingConfigs.config 29 | } 30 | } 31 | //打包后应用名称 32 | applicationVariants.all { variant -> 33 | variant.outputs.each { output -> 34 | def outputFile = output.outputFile 35 | def fileName 36 | if (outputFile != null && outputFile.name.endsWith('.apk')) { 37 | if (variant.buildType.name.equals('release')) { 38 | fileName = "MainCalendar ${defaultConfig.versionName}.apk" 39 | output.outputFile = new File(outputFile.parent, fileName) 40 | } 41 | } 42 | } 43 | } 44 | productFlavors { 45 | } 46 | } 47 | 48 | dependencies { 49 | compile fileTree(include: ['*.jar'], dir: 'libs') 50 | compile 'com.android.support:design:23.4.0' 51 | compile 'com.android.support:support-v4:23.4.0' 52 | debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5' 53 | releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5' 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_alarm_notice.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 20 | 31 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/res/layout/alarm_record_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 22 | 23 | 32 | 33 | 39 | 40 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /app/src/main/res/layout/toolbar_button.xml: -------------------------------------------------------------------------------- 1 | 6 | 16 | 17 | 28 | 29 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 20 | 32 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 16 | 17 | 28 | 29 | 30 | 34 | 35 | 42 | 43 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/monthui/CalendarViewPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.monthui; 2 | 3 | import android.os.Parcelable; 4 | import android.support.v4.view.PagerAdapter; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.view.ViewParent; 8 | 9 | 10 | /** 11 | * Created by Wgj on 2016/8/10. 12 | * 自定义的页面视图适配器 13 | */ 14 | public class CalendarViewPagerAdapter extends PagerAdapter { 15 | 16 | private CalendarView[] mCalendarViews; 17 | 18 | public CalendarViewPagerAdapter(CalendarView[] views) { 19 | super(); 20 | this.mCalendarViews = views; 21 | } 22 | 23 | // @Override 24 | // public void finishUpdate(View arg0) { 25 | // } 26 | 27 | @Override 28 | public void notifyDataSetChanged() { 29 | super.notifyDataSetChanged(); 30 | } 31 | 32 | @Override 33 | public int getCount() { 34 | return Integer.MAX_VALUE; 35 | } 36 | 37 | @Override 38 | public Object instantiateItem(ViewGroup container, int position) { 39 | position %= mCalendarViews.length; 40 | if (position < 0){ 41 | position = mCalendarViews.length + position; 42 | } 43 | 44 | CalendarView tmpView = mCalendarViews[position]; 45 | ViewParent vp = tmpView.getParent(); 46 | if (vp != null){ 47 | ViewGroup parent = (ViewGroup)vp; 48 | parent.removeView(tmpView); 49 | } 50 | container.addView(tmpView); 51 | 52 | return tmpView; 53 | } 54 | 55 | @Override 56 | public boolean isViewFromObject(View arg0, Object arg1) { 57 | return arg0 == (arg1); 58 | } 59 | 60 | @Override 61 | public Parcelable saveState() { 62 | return null; 63 | } 64 | 65 | @Override 66 | public void destroyItem(ViewGroup container, int position, Object object) { 67 | // TODO Auto-generated method stub 68 | 69 | } 70 | 71 | // @Override 72 | // public void startUpdate(View arg0) { 73 | // } 74 | 75 | /** 76 | * 获取所有页面 77 | * @return 所有页面 78 | */ 79 | CalendarView[] getAllItems() { 80 | return mCalendarViews; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/common/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.common; 2 | 3 | import com.jjforever.wgj.maincalendar.BuildConfig; 4 | 5 | /** 6 | * ************************************************************************ 7 | * ** _oo0oo_ ** 8 | * ** o8888888o ** 9 | * ** 88" . "88 ** 10 | * ** (| -_- |) ** 11 | * ** 0\ = /0 ** 12 | * ** ___/'---'\___ ** 13 | * ** .' \\\| |// '. ** 14 | * ** / \\\||| : |||// \\ ** 15 | * ** / _ ||||| -:- |||||- \\ ** 16 | * ** | | \\\\ - /// | | ** 17 | * ** | \_| ''\---/'' |_/ | ** 18 | * ** \ .-\__ '-' __/-. / ** 19 | * ** ___'. .' /--.--\ '. .'___ ** 20 | * ** ."" '< '.___\_<|>_/___.' >' "". ** 21 | * ** | | : '- \'.;'\ _ /';.'/ - ' : | | ** 22 | * ** \ \ '_. \_ __\ /__ _/ .-' / / ** 23 | * ** ====='-.____'.___ \_____/___.-'____.-'===== ** 24 | * ** '=---=' ** 25 | * ************************************************************************ 26 | * ** 佛祖保佑 镇类之宝 ** 27 | * ************************************************************************ 28 | * 29 | * @author 李玉江[QQ :1032694760] 30 | * @version 2014-09-05 11:49 31 | */ 32 | public class AppConfig { 33 | /** 34 | * The constant DEBUG_ENABLE. 35 | */ 36 | public static final boolean DEBUG_ENABLE = BuildConfig.DEBUG;// 是否调试模式 37 | /** 38 | * The constant DEBUG_TAG. 39 | */ 40 | public static final String DEBUG_TAG = "liyujiang";// LogCat的标记 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/filepicker/entity/FileItem.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.filepicker.entity; 2 | 3 | /** 4 | * 文件项信息 5 | * 6 | * @author 李玉江[QQ :1032694760] 7 | * @version 2014 -05-23 18:02 8 | */ 9 | public class FileItem { 10 | private int icon; 11 | private String name; 12 | private String path = "/"; 13 | private long size = 0; 14 | private boolean isDirectory = false; 15 | 16 | /** 17 | * Sets icon. 18 | * 19 | * @param icon the icon 20 | */ 21 | public void setIcon(int icon) { 22 | this.icon = icon; 23 | } 24 | 25 | /** 26 | * Gets icon. 27 | * 28 | * @return the icon 29 | */ 30 | public int getIcon() { 31 | return icon; 32 | } 33 | 34 | /** 35 | * Gets name. 36 | * 37 | * @return the name 38 | */ 39 | public String getName() { 40 | return name; 41 | } 42 | 43 | /** 44 | * Sets name. 45 | * 46 | * @param name the name 47 | */ 48 | public void setName(String name) { 49 | this.name = name; 50 | } 51 | 52 | /** 53 | * Gets path. 54 | * 55 | * @return the path 56 | */ 57 | public String getPath() { 58 | return path; 59 | } 60 | 61 | /** 62 | * Sets path. 63 | * 64 | * @param path the path 65 | */ 66 | public void setPath(String path) { 67 | this.path = path; 68 | } 69 | 70 | /** 71 | * Gets size. 72 | * 73 | * @return the size 74 | */ 75 | public long getSize() { 76 | return size; 77 | } 78 | 79 | /** 80 | * Sets size. 81 | * 82 | * @param size the size 83 | */ 84 | public void setSize(long size) { 85 | this.size = size; 86 | } 87 | 88 | /** 89 | * Is directory boolean. 90 | * 91 | * @return the boolean 92 | */ 93 | public boolean isDirectory() { 94 | return isDirectory; 95 | } 96 | 97 | /** 98 | * Sets directory. 99 | * 100 | * @param isDirectory the is directory 101 | */ 102 | public void setDirectory(boolean isDirectory) { 103 | this.isDirectory = isDirectory; 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/Model/AlarmTime.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.Model; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import java.util.Locale; 7 | 8 | /** 9 | * Created by Wgj on 2016/9/8. 10 | * 报警用的时间类 11 | */ 12 | public class AlarmTime implements Parcelable { 13 | // 小时 14 | public int Hour; 15 | // 分钟 16 | public int Minute; 17 | 18 | public AlarmTime(int hour, int minute){ 19 | this.Hour = hour; 20 | this.Minute = minute; 21 | } 22 | 23 | /** 24 | * 根据时间分钟数创建对象 time=小时*60 + 分钟 25 | * @param time 设置的时间分钟数 26 | */ 27 | AlarmTime(int time){ 28 | setTime(time); 29 | } 30 | 31 | public void setTime(int time){ 32 | this.Hour = time/60; 33 | this.Minute = time%60; 34 | } 35 | 36 | /** 37 | * 获取时间分钟总数 38 | * @return 分钟总数 39 | */ 40 | public int getTime(){ 41 | return (this.Hour * 60 + this.Minute); 42 | } 43 | 44 | /** 45 | * 比较时间 46 | * @param hour 小时 47 | * @param minute 分钟 48 | * @return 相差时间 > 0 参数时间比该对象时间晚的分钟数 49 | * = 0说明时间相等 50 | * < 0 参数时间比该对象时间早的分钟数 51 | */ 52 | public int compareTime(int hour, int minute){ 53 | int alarmMinute = this.getTime(); 54 | int curMinute = hour * 60 + minute; 55 | 56 | return (curMinute - alarmMinute); 57 | } 58 | 59 | @Override 60 | public String toString(){ 61 | return String.format(Locale.getDefault(), 62 | "%02d:%02d", this.Hour, this.Minute); 63 | } 64 | 65 | @Override 66 | public int describeContents() { 67 | return 0; 68 | } 69 | 70 | @Override 71 | public void writeToParcel(Parcel dest, int flags) { 72 | dest.writeInt(this.Hour); 73 | dest.writeInt(this.Minute); 74 | } 75 | 76 | protected AlarmTime(Parcel in) { 77 | this.Hour = in.readInt(); 78 | this.Minute = in.readInt(); 79 | } 80 | 81 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { 82 | @Override 83 | public AlarmTime createFromParcel(Parcel source) { 84 | return new AlarmTime(source); 85 | } 86 | 87 | @Override 88 | public AlarmTime[] newArray(int size) { 89 | return new AlarmTime[size]; 90 | } 91 | }; 92 | } 93 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/GradientShaderTextView.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.LinearGradient; 6 | import android.graphics.Matrix; 7 | import android.graphics.Paint; 8 | import android.graphics.Shader; 9 | import android.util.AttributeSet; 10 | import android.widget.TextView; 11 | 12 | /** 13 | * Created by Wgj on 2016/10/7. 14 | * 文字渐变动画 15 | */ 16 | public class GradientShaderTextView extends TextView { 17 | private LinearGradient mLinearGradient; 18 | private Matrix mGradientMatrix; 19 | private int mViewWidth = 0; 20 | private int mTranslate = 0; 21 | private float mTextWidth = 0; 22 | 23 | private int delta = 15; 24 | public GradientShaderTextView(Context ctx) 25 | { 26 | this(ctx,null); 27 | } 28 | 29 | public GradientShaderTextView(Context context, AttributeSet attrs) { 30 | super(context, attrs); 31 | } 32 | 33 | @Override 34 | protected void onSizeChanged(int w, int h, int oldW, int oldH) { 35 | super.onSizeChanged(w, h, oldW, oldH); 36 | if (mViewWidth == 0) { 37 | mViewWidth = getMeasuredWidth(); 38 | if (mViewWidth > 0) { 39 | Paint paint = getPaint(); 40 | String text = getText().toString(); 41 | mTextWidth = paint.measureText(text); 42 | int size = (int)paint.measureText(text); 43 | int startX = (mViewWidth - size) / 2; 44 | mLinearGradient = new LinearGradient(startX + 1, 0, 0, 0, 45 | new int[] { 0x90ffffff, 0xffffffff, 0x90ffffff }, 46 | new float[] { 0, 0.5f, 1 }, Shader.TileMode.CLAMP); //边缘融合 47 | paint.setShader(mLinearGradient); 48 | mGradientMatrix = new Matrix(); 49 | } 50 | } 51 | } 52 | 53 | @Override 54 | protected void onDraw(Canvas canvas) { 55 | super.onDraw(canvas); 56 | 57 | if (mGradientMatrix != null && mTextWidth > 0) { 58 | mTranslate += delta; 59 | if (mTranslate > mTextWidth + 1 || mTranslate < 1) { 60 | delta = -delta; 61 | } 62 | mGradientMatrix.setTranslate(mTranslate, 0); 63 | mLinearGradient.setLocalMatrix(mGradientMatrix); 64 | postInvalidateDelayed(30); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/monthui/ThemeStyle.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.monthui; 2 | 3 | import android.content.Context; 4 | import android.support.v4.content.ContextCompat; 5 | 6 | import com.jjforever.wgj.maincalendar.BLL.GlobalSettingMng; 7 | import com.jjforever.wgj.maincalendar.Model.GlobalSetting; 8 | import com.jjforever.wgj.maincalendar.R; 9 | 10 | /** 11 | * Created by Wgj on 2016/8/15. 12 | * 界面颜色主题样式类 13 | */ 14 | public class ThemeStyle { 15 | // 主色调 16 | public static int Primary; 17 | // 主暗色调 18 | public static int PrimaryDark; 19 | // 悬浮按钮等的颜色 20 | public static int Accent; 21 | // 当前显示月份的字体颜色 22 | public static int CurrentMonth; 23 | public static int CurrentLunar; 24 | // 日历背景色 25 | public static int BackColor; 26 | // 当日字体颜色 27 | public static int Today; 28 | public static int TodayLunar; 29 | // 节日颜色 30 | public static int Holiday; 31 | // 日常记录颜色 32 | public static int Daily; 33 | // 列表项被选中的颜色 34 | public static int ItemSelected; 35 | // 白班背景色 36 | public static int WorkDay; 37 | // 夜班背景色 38 | public static int WorkNight; 39 | 40 | /** 41 | * 从资源中载入默认主题 42 | * @param context 内容提供器 43 | */ 44 | public static void LoadThemeResource(Context context) 45 | { 46 | PrimaryDark = ContextCompat.getColor(context, R.color.colorPrimaryDark); 47 | Accent = ContextCompat.getColor(context, R.color.colorAccent); 48 | CurrentMonth = ContextCompat.getColor(context, R.color.currentMonth); 49 | CurrentLunar = ContextCompat.getColor(context, R.color.currentLunar); 50 | BackColor = ContextCompat.getColor(context, R.color.backCalendar); 51 | Holiday = ContextCompat.getColor(context, R.color.holiday); 52 | Today = ContextCompat.getColor(context, R.color.today); 53 | TodayLunar = ContextCompat.getColor(context, R.color.todayLunar); 54 | Daily = ContextCompat.getColor(context, R.color.dailyRecord); 55 | ItemSelected = ContextCompat.getColor(context, R.color.itemSelected); 56 | WorkDay = ContextCompat.getColor(context, R.color.workDay); 57 | WorkNight = ContextCompat.getColor(context, R.color.workNight); 58 | } 59 | 60 | /** 61 | * 根据用户设置载入主题颜色 62 | */ 63 | public static void LoadGlobalTheme(){ 64 | GlobalSetting tmpSetting = GlobalSettingMng.getSetting(); 65 | Primary = tmpSetting.getPrimaryColor(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/weather/util/WeatherIconUtil.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.weather.util; 2 | 3 | import com.jjforever.wgj.maincalendar.R; 4 | 5 | /** 6 | * Created by Wgj on 2016/8/24. 7 | * 根据天气情况获取图标 8 | */ 9 | public final class WeatherIconUtil { 10 | // 天气图标集合,与天气代码一一对应 11 | private static final int[] mWeatherIcons = new int[]{ 12 | R.drawable.ic_sunny_big, R.drawable.ic_cloudy_big, 13 | R.drawable.ic_overcast_big, R.drawable.ic_fog_big, 14 | R.drawable.hurricane_day_night, R.drawable.ic_heavyrain_big, 15 | R.drawable.ic_heavyrain_big, R.drawable.ic_thundeshower_big, 16 | R.drawable.ic_shower_big, R.drawable.ic_heavyrain_big, 17 | R.drawable.ic_moderraterain_big, R.drawable.ic_lightrain_big, 18 | R.drawable.ic_sleet_big, R.drawable.ic_snow_big, 19 | R.drawable.ic_snow_big, R.drawable.ic_heavysnow_big, 20 | R.drawable.ic_snow_big, R.drawable.ic_snow_big, 21 | R.drawable.ic_sandstorm_big, R.drawable.ic_sandstorm_big, 22 | R.drawable.ic_sandstorm_big, R.drawable.ic_sandstorm_big, 23 | R.drawable.freezing_rain_day_night, R.drawable.ic_dust_big, 24 | R.drawable.ic_haze_big 25 | }; 26 | 27 | // 天气描述集合 28 | private static String[] mWeatherNames; 29 | 30 | /** 31 | * 初始化天气描述 32 | * @param names 天气描述集合 33 | */ 34 | public static void initWeatherNames(String[] names) 35 | { 36 | mWeatherNames = names; 37 | } 38 | 39 | /** 40 | * 返回所有的天气描述 41 | * @return 所有的天气描述 42 | */ 43 | public static String[] getWeatherNames(){ 44 | return mWeatherNames; 45 | } 46 | 47 | /** 48 | * 根据天气代码获取天气图标 49 | * @param type 天气情况代码 50 | * @return 天气图标 51 | */ 52 | public static int getWeatherIcon(int type) { 53 | if (type >= WeatherConstants.START_CODE && type <= WeatherConstants.END_CODE){ 54 | return mWeatherIcons[type]; 55 | } 56 | return R.drawable.ic_default_big; 57 | } 58 | 59 | /** 60 | * 根据天气代码获取天气描述 61 | * @param type 天气代码 62 | * @return 天气描述 63 | */ 64 | public static String getWeatherName(int type) 65 | { 66 | if (type >= WeatherConstants.START_CODE && type <= WeatherConstants.END_CODE){ 67 | return mWeatherNames[type]; 68 | } 69 | 70 | // 最后一个存放无效天气描述 71 | return mWeatherNames[mWeatherNames.length - 1]; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/Model/GlobalSetting.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.Model; 2 | 3 | /** 4 | * Created by Wgj on 2016/9/21. 5 | * 软件全局设置项 6 | */ 7 | public class GlobalSetting { 8 | // 如果要显示轮班记录则此值大于0 9 | private long mShiftsWorkIndex; 10 | // 主题颜色 11 | private int mPrimaryColor; 12 | // 铃声路径 13 | private String mRingPath; 14 | // 响铃时间长度,单位秒,默认60秒 15 | private int mRingSeconds; 16 | // 闹钟是否显示到状态栏中 17 | private boolean mNotification; 18 | // 是否将调试信息写入到文件中 19 | private boolean mRecordLog; 20 | 21 | public GlobalSetting(){ 22 | this.mRingSeconds = 60; 23 | this.mShiftsWorkIndex = 0; 24 | this.mNotification = true; 25 | this.mRecordLog = false; 26 | } 27 | 28 | public long getShiftsWorkIndex(){ 29 | return mShiftsWorkIndex; 30 | } 31 | 32 | public void setShiftsWorkIndex(long index){ 33 | this.mShiftsWorkIndex = index; 34 | } 35 | 36 | public int getPrimaryColor(){ 37 | return mPrimaryColor; 38 | } 39 | 40 | public void setPrimaryColor(int color){ 41 | this.mPrimaryColor = color; 42 | } 43 | 44 | public String getRingPath(){ 45 | return mRingPath; 46 | } 47 | 48 | public void setRingPath(String path){ 49 | this.mRingPath = path; 50 | } 51 | 52 | public int getRingSeconds(){ 53 | return mRingSeconds; 54 | } 55 | 56 | public void setRingSeconds(int seconds){ 57 | this.mRingSeconds = seconds; 58 | } 59 | 60 | public boolean getIsNotification(){ 61 | return mNotification; 62 | } 63 | 64 | public void setIsNotification(boolean isNotification){ 65 | this.mNotification = isNotification; 66 | } 67 | 68 | public boolean getIsRecordLog(){ 69 | return mRecordLog; 70 | } 71 | 72 | public void setIsRecordLog(boolean isRecord){ 73 | this.mRecordLog = isRecord; 74 | } 75 | 76 | /** 77 | * 复制本地对象 78 | * @return 复制的对象 79 | */ 80 | public GlobalSetting depthClone(){ 81 | GlobalSetting copyObj = new GlobalSetting(); 82 | 83 | copyObj.setPrimaryColor(this.mPrimaryColor); 84 | copyObj.setRingSeconds(this.mRingSeconds); 85 | copyObj.setRingPath(this.mRingPath); 86 | copyObj.setShiftsWorkIndex(this.mShiftsWorkIndex); 87 | copyObj.setIsNotification(this.mNotification); 88 | copyObj.setIsRecordLog(this.mRecordLog); 89 | 90 | return copyObj; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 20 | 21 | 29 | 38 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/toolbar/ToolBarHelper.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.toolbar; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.support.v7.widget.Toolbar; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.FrameLayout; 10 | 11 | import com.jjforever.wgj.maincalendar.R; 12 | 13 | /** 14 | * Created by Wgj on 2016/8/20. 15 | * 工具栏帮助类 16 | */ 17 | class ToolBarHelper { 18 | 19 | /*上下文,创建view的时候需要用到*/ 20 | private Context mContext; 21 | 22 | /*base view*/ 23 | private FrameLayout mContentView; 24 | 25 | /*mToolbar*/ 26 | private Toolbar mToolBar; 27 | 28 | /*视图构造器*/ 29 | private LayoutInflater mInflater; 30 | 31 | /* 32 | * 两个属性 33 | * 1、toolbar是否悬浮在窗口之上 34 | * 2、toolbar的高度获取 35 | * */ 36 | private static int[] ATTRS = { 37 | R.attr.windowActionBarOverlay, 38 | R.attr.actionBarSize 39 | }; 40 | 41 | ToolBarHelper(Context context, int layoutId) { 42 | this.mContext = context; 43 | mInflater = LayoutInflater.from(mContext); 44 | /*初始化整个内容*/ 45 | initContentView(); 46 | /*初始化用户定义的布局*/ 47 | initUserView(layoutId); 48 | /*初始化toolbar*/ 49 | initToolBar(); 50 | } 51 | 52 | private void initContentView() { 53 | /*直接创建一个帧布局,作为视图容器的父容器*/ 54 | mContentView = new FrameLayout(mContext); 55 | ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 56 | ViewGroup.LayoutParams.MATCH_PARENT); 57 | mContentView.setLayoutParams(params); 58 | } 59 | 60 | private void initToolBar() { 61 | /*通过inflater获取toolbar的布局文件*/ 62 | View toolbar = mInflater.inflate(R.layout.toolbar, mContentView); 63 | mToolBar = (Toolbar) toolbar.findViewById(R.id.id_tool_bar); 64 | } 65 | 66 | private void initUserView(int id) { 67 | View userView = mInflater.inflate(id, null); 68 | FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); 69 | TypedArray typedArray = mContext.getTheme().obtainStyledAttributes(ATTRS); 70 | /*获取主题中定义的悬浮标志*/ 71 | boolean overly = typedArray.getBoolean(0, false); 72 | /*获取主题中定义的toolbar的高度*/ 73 | @SuppressWarnings("ResourceType") 74 | int toolBarSize = (int) typedArray.getDimension(1, (int) mContext.getResources().getDimension(R.dimen.abc_action_bar_default_height_material)); 75 | typedArray.recycle(); 76 | /*如果是悬浮状态,则不需要设置间距*/ 77 | params.topMargin = overly ? 0 : toolBarSize; 78 | mContentView.addView(userView, params); 79 | } 80 | 81 | FrameLayout getContentView() { 82 | return mContentView; 83 | } 84 | 85 | Toolbar getToolBar() { 86 | return mToolBar; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/AboutActivity.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | import android.os.Bundle; 7 | import android.provider.Browser; 8 | import android.text.SpannableString; 9 | import android.text.Spanned; 10 | import android.text.method.LinkMovementMethod; 11 | import android.text.style.ClickableSpan; 12 | import android.text.style.ForegroundColorSpan; 13 | import android.view.View; 14 | import android.widget.TextView; 15 | 16 | import com.jjforever.wgj.maincalendar.monthui.ThemeStyle; 17 | import com.jjforever.wgj.maincalendar.toolbar.ToolBarActivity; 18 | import com.jjforever.wgj.maincalendar.util.DateUtil; 19 | import com.jjforever.wgj.maincalendar.util.Helper; 20 | 21 | public class AboutActivity extends ToolBarActivity { 22 | 23 | /** 24 | * 作者易信号 25 | */ 26 | private static final String mAuthorName = "main_h"; 27 | /** 28 | * 作者易信推广链接 29 | */ 30 | private static final String mExtLink = "http://yxs.im/8a62w2"; 31 | 32 | @Override 33 | protected void onCreate(Bundle savedInstanceState) { 34 | super.onCreate(savedInstanceState); 35 | setContentView(R.layout.activity_about); 36 | showOkBtn(false); 37 | setTitle(getResources().getString(R.string.action_about)); 38 | 39 | TextView rightView = (TextView) findViewById(R.id.about_right); 40 | if (rightView != null) { 41 | String tmpStr = String.format(getString(R.string.about_right), 42 | DateUtil.getYear(), Helper.getAppVersionName(this)); 43 | rightView.setText(getClickableSpan(tmpStr)); 44 | rightView.setMovementMethod(LinkMovementMethod.getInstance()); 45 | } 46 | } 47 | 48 | /** 49 | * 获取超链接字段 50 | * @return 超链接字符串 51 | */ 52 | private SpannableString getClickableSpan(String aStr) { 53 | int startIndex = aStr.indexOf(mAuthorName); 54 | int endIndex = startIndex + mAuthorName.length(); 55 | SpannableString spannableString = new SpannableString(aStr); 56 | //设置下划线文字 57 | // spannableString.setSpan(new UnderlineSpan(), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); 58 | //设置文字的单击事件 59 | spannableString.setSpan(new ClickableSpan() { 60 | @Override 61 | public void onClick(View widget) { 62 | Uri uri = Uri.parse(mExtLink); 63 | Context context = widget.getContext(); 64 | Intent intent = new Intent(Intent.ACTION_VIEW, uri); 65 | intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); 66 | context.startActivity(intent); 67 | } 68 | }, startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); 69 | //设置文字的前景色 70 | spannableString.setSpan(new ForegroundColorSpan(ThemeStyle.Accent), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); 71 | 72 | return spannableString; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/AlarmTipAdapter.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.TextView; 9 | 10 | import com.jjforever.wgj.maincalendar.Model.AlarmRecord; 11 | import com.jjforever.wgj.maincalendar.monthui.ThemeStyle; 12 | import com.jjforever.wgj.maincalendar.util.Helper; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * Created by Wgj on 2016/10/7. 18 | * 闹钟提醒适配器 19 | */ 20 | class AlarmTipAdapter extends BaseAdapter { 21 | private Context context; 22 | private List list; 23 | 24 | AlarmTipAdapter(Context context, List list) { 25 | this.context = context; 26 | this.list = list; 27 | } 28 | 29 | @Override 30 | public int getCount() { 31 | if (list == null) { 32 | return 0; 33 | } 34 | return list.size(); 35 | } 36 | 37 | @Override 38 | public Object getItem(int position) { 39 | if (list == null) { 40 | return null; 41 | } 42 | return list.get(position); 43 | } 44 | 45 | @Override 46 | public long getItemId(int position) { 47 | return position; 48 | } 49 | 50 | @Override 51 | public View getView(int position, View convertView, ViewGroup parent) { 52 | AlarmViewHolder holder; 53 | if (convertView == null) { 54 | holder = new AlarmViewHolder(); 55 | convertView = LayoutInflater.from(context).inflate( 56 | R.layout.item_alarm_notice, parent, false); 57 | holder.date = (TextView) convertView 58 | .findViewById(R.id.alarm_date); 59 | holder.date.setTextColor(ThemeStyle.Primary); 60 | holder.content = (TextView) convertView 61 | .findViewById(R.id.alarm_content); 62 | holder.title = (TextView) convertView 63 | .findViewById(R.id.alarm_title); 64 | holder.title.setTextColor(ThemeStyle.Primary); 65 | convertView.setTag(holder); 66 | } else { 67 | holder = (AlarmViewHolder) convertView.getTag(); 68 | } 69 | 70 | AlarmRecord tmpRecord = list.get(position); 71 | holder.date.setText(tmpRecord.toString()); 72 | holder.title.setText(tmpRecord.getOnlyTitle()); 73 | if (Helper.isNullOrEmpty(tmpRecord.getContent())){ 74 | holder.content.setVisibility(View.GONE); 75 | } 76 | else { 77 | holder.content.setText(tmpRecord.getContent()); 78 | holder.content.setVisibility(View.VISIBLE); 79 | } 80 | 81 | return convertView; 82 | } 83 | 84 | @Override 85 | public boolean hasStableIds() { 86 | return true; 87 | } 88 | 89 | private static class AlarmViewHolder { 90 | TextView title; 91 | TextView date; 92 | TextView content; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/wheelpicker/picker/WheelPicker.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.wheelpicker.picker; 2 | 3 | import android.app.Activity; 4 | import android.support.annotation.ColorInt; 5 | import android.support.annotation.IntRange; 6 | import android.view.View; 7 | 8 | import com.jjforever.wgj.maincalendar.common.popup.ConfirmPopup; 9 | import com.jjforever.wgj.maincalendar.wheelpicker.widget.WheelView; 10 | 11 | /** 12 | * 滑轮选择器 13 | * 14 | * @author 李玉江[QQ :1032694760] 15 | * @version 2015 /12/22 16 | */ 17 | public abstract class WheelPicker extends ConfirmPopup { 18 | /** 19 | * The Text size. 20 | */ 21 | protected int textSize = WheelView.TEXT_SIZE; 22 | /** 23 | * The Text color normal. 24 | */ 25 | protected int textColorNormal = WheelView.TEXT_COLOR_NORMAL; 26 | /** 27 | * The Text color focus. 28 | */ 29 | protected int textColorFocus = WheelView.TEXT_COLOR_FOCUS; 30 | /** 31 | * The Line color. 32 | */ 33 | protected int lineColor = WheelView.LINE_COLOR; 34 | /** 35 | * The Line visible. 36 | */ 37 | protected boolean lineVisible = true; 38 | /** 39 | * The Offset. 40 | */ 41 | protected int offset = WheelView.OFF_SET; 42 | 43 | /** 44 | * Instantiates a new Wheel picker. 45 | * 46 | * @param activity the activity 47 | */ 48 | public WheelPicker(Activity activity) { 49 | super(activity); 50 | } 51 | 52 | /** 53 | * Sets text size. 54 | * 55 | * @param textSize the text size 56 | */ 57 | public void setTextSize(int textSize) { 58 | this.textSize = textSize; 59 | } 60 | 61 | /** 62 | * Sets text color. 63 | * 64 | * @param textColorFocus the text color focus 65 | * @param textColorNormal the text color normal 66 | */ 67 | public void setTextColor(@ColorInt int textColorFocus, @ColorInt int textColorNormal) { 68 | this.textColorFocus = textColorFocus; 69 | this.textColorNormal = textColorNormal; 70 | } 71 | 72 | /** 73 | * Sets text color. 74 | * 75 | * @param textColor the text color 76 | */ 77 | public void setTextColor(@ColorInt int textColor) { 78 | this.textColorFocus = textColor; 79 | } 80 | 81 | /** 82 | * Sets line visible. 83 | * 84 | * @param lineVisible the line visible 85 | */ 86 | public void setLineVisible(boolean lineVisible) { 87 | this.lineVisible = lineVisible; 88 | } 89 | 90 | /** 91 | * Sets line color. 92 | * 93 | * @param lineColor the line color 94 | */ 95 | public void setLineColor(@ColorInt int lineColor) { 96 | this.lineColor = lineColor; 97 | } 98 | 99 | /** 100 | * Sets offset. 101 | * 102 | * @param offset the offset 103 | */ 104 | public void setOffset(@IntRange(from = 1, to = 4) int offset) { 105 | this.offset = offset; 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/BLL/GlobalSettingMng.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.BLL; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.SharedPreferences; 6 | import android.support.v4.content.ContextCompat; 7 | 8 | import com.jjforever.wgj.maincalendar.AppConstants; 9 | import com.jjforever.wgj.maincalendar.Model.GlobalSetting; 10 | import com.jjforever.wgj.maincalendar.R; 11 | 12 | /** 13 | * Created by Wgj on 2016/9/22. 14 | * 软件设置管理类 15 | */ 16 | public final class GlobalSettingMng { 17 | // 显示的轮班索引 18 | private static final String ShiftsWorkIndex = "ShiftsWorkIndex"; 19 | // 主题颜色 20 | private static final String PrimaryColor = "PrimaryColor"; 21 | // 闹钟铃声路径 22 | private static final String RingPath = "RingPath"; 23 | // 闹钟响铃时长(s) 24 | private static final String RingSeconds = "RingSeconds"; 25 | // 闹钟提醒是否在状态栏显示 26 | private static final String IsNotification = "IsNotification"; 27 | // 是否记录调试信息 28 | private static final String IsRecordLog = "IsRecordLog"; 29 | // 系统设置 30 | private static GlobalSetting mSetting = new GlobalSetting(); 31 | 32 | /** 33 | * 获取软件设置 34 | * @return 全局设置 35 | */ 36 | public static GlobalSetting getSetting(){ 37 | return mSetting; 38 | } 39 | 40 | public static void setSetting(GlobalSetting setting){ 41 | mSetting = setting; 42 | } 43 | 44 | /** 45 | * 读取配置 46 | */ 47 | public static void ReadSetting(Context context){ 48 | SharedPreferences preferences = context.getSharedPreferences(AppConstants.SETTING_PREFERENCE, Context.MODE_PRIVATE); 49 | mSetting.setShiftsWorkIndex(preferences.getLong(ShiftsWorkIndex, 0)); 50 | mSetting.setPrimaryColor(preferences.getInt(PrimaryColor, ContextCompat.getColor(context, R.color.colorPrimary))); 51 | mSetting.setRingPath(preferences.getString(RingPath, "")); 52 | mSetting.setRingSeconds(preferences.getInt(RingSeconds, 60)); 53 | mSetting.setIsNotification(preferences.getBoolean(IsNotification, true)); 54 | mSetting.setIsRecordLog(preferences.getBoolean(IsRecordLog, false)); 55 | } 56 | 57 | /** 58 | * 存储配置 59 | */ 60 | public static boolean SaveSetting(Activity activity){ 61 | try { 62 | SharedPreferences preferences = activity.getSharedPreferences(AppConstants.SETTING_PREFERENCE, Context.MODE_PRIVATE); 63 | SharedPreferences.Editor tmpEditor = preferences.edit(); 64 | tmpEditor.putLong(ShiftsWorkIndex, mSetting.getShiftsWorkIndex()); 65 | tmpEditor.putInt(PrimaryColor, mSetting.getPrimaryColor()); 66 | tmpEditor.putString(RingPath, mSetting.getRingPath()); 67 | tmpEditor.putInt(RingSeconds, mSetting.getRingSeconds()); 68 | tmpEditor.putBoolean(IsNotification, mSetting.getIsNotification()); 69 | tmpEditor.putBoolean(IsRecordLog, mSetting.getIsRecordLog()); 70 | tmpEditor.apply(); 71 | return true; 72 | } 73 | catch (Exception ex){ 74 | AppConstants.WLog(ex.toString()); 75 | return false; 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/dialogpicker/picker/DialogPicker.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.dialogpicker.picker; 2 | 3 | import android.app.Activity; 4 | import android.support.annotation.NonNull; 5 | import android.view.Gravity; 6 | import android.widget.LinearLayout; 7 | import android.widget.TextView; 8 | 9 | import com.jjforever.wgj.maincalendar.R; 10 | import com.jjforever.wgj.maincalendar.common.popup.ConfirmPopup; 11 | 12 | /** 13 | * Created by Wgj on 2016/8/25. 14 | * 自定义对话框 15 | */ 16 | public class DialogPicker extends ConfirmPopup { 17 | private TextView mTextView; 18 | // 标题 19 | private String mTitle; 20 | // 内容 21 | private String mContent; 22 | 23 | // 监听事件 24 | private OnDialogPickListener onDialogPickListener; 25 | 26 | /** 27 | * 创建一个对话框 28 | * @param activity 活动 29 | * @param title 标题 30 | * @param content 内容 31 | */ 32 | public DialogPicker(Activity activity, String title, String content) 33 | { 34 | super(activity); 35 | mTitle = title; 36 | mContent = content; 37 | } 38 | 39 | /** 40 | * 创建一个对话框,标题为提醒字样 41 | * @param activity 活动 42 | * @param content 内容 43 | */ 44 | public DialogPicker(Activity activity, String content) 45 | { 46 | this(activity, activity.getResources().getString(R.string.dialog_title), content); 47 | } 48 | 49 | /** 50 | * 设置监听事件 51 | * @param onDialogPickListener 回调方法 52 | */ 53 | public void setOnDialogPickListener(OnDialogPickListener onDialogPickListener) { 54 | this.onDialogPickListener = onDialogPickListener; 55 | } 56 | 57 | @Override 58 | protected void onSubmit() { 59 | if (onDialogPickListener != null) { 60 | onDialogPickListener.onDialogPicked(true); 61 | } 62 | } 63 | 64 | @Override 65 | protected void onCancel() 66 | { 67 | if (onDialogPickListener != null) { 68 | onDialogPickListener.onDialogPicked(false); 69 | } 70 | } 71 | 72 | @Override 73 | @NonNull 74 | protected LinearLayout makeCenterView() { 75 | LinearLayout rootLayout = new LinearLayout(activity); 76 | rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); 77 | rootLayout.setOrientation(LinearLayout.VERTICAL); 78 | 79 | mTextView = new TextView(activity); 80 | mTextView.setHeight(screenHeightPixels/4); 81 | mTextView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); 82 | mTextView.setGravity(Gravity.CENTER); 83 | mTextView.setTextSize(16); 84 | mTextView.setPadding(10, 10, 10, 10); 85 | mTextView.setText(mContent); 86 | rootLayout.addView(mTextView); 87 | 88 | setTitleText(mTitle); 89 | return rootLayout; 90 | } 91 | 92 | /** 93 | * 对话框确认取消接口 94 | */ 95 | public interface OnDialogPickListener { 96 | /** 97 | * 对话框确认事件 98 | * @param confirm 是否确认 99 | */ 100 | void onDialogPicked(boolean confirm); 101 | 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/AppConstants.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar; 2 | 3 | import android.content.Context; 4 | import android.util.Log; 5 | 6 | import com.jjforever.wgj.maincalendar.BLL.DatabaseHelper; 7 | import com.jjforever.wgj.maincalendar.BLL.GlobalSettingMng; 8 | import com.jjforever.wgj.maincalendar.Model.AlarmRecord; 9 | import com.jjforever.wgj.maincalendar.monthui.ThemeStyle; 10 | import com.jjforever.wgj.maincalendar.util.Helper; 11 | 12 | /** 13 | * Created by Wgj on 2016/8/27. 14 | * 应用中用到的一些常量定义 15 | */ 16 | public final class AppConstants { 17 | 18 | // 调试标识 19 | public static final String LOG_TAG = "MainCalendar"; 20 | // 是否为调试模式 21 | public static final boolean DEBUG = BuildConfig.DEBUG; 22 | // 主界面选中的日期 23 | static final String MAIN_ACTIVITY_CLICK_DATE = "main_click_date"; 24 | // 服务线程调用页面 25 | public static final String SERVICE_CALL_ACTIVITY = "service_call_activity"; 26 | // 服务传递动作 27 | public static final String MAIN_CALENDAR_SERVICE = "MAIN_CALENDAR_SERVICE"; 28 | // 本程序用于SharedPreferences设置项标识 29 | public final static String SETTING_PREFERENCE = "MainCalendar"; 30 | 31 | // 删除记录代码 32 | static int RESULT_DELETE = 7; 33 | // 预载日历页面数量 34 | final static int LOAD_CALENDAR_VIEW_COUNT = 3; 35 | 36 | // 闹钟类型对应下拉列表的索引 37 | static final int[] AlarmTypeIndexs = new int[]{ 38 | AlarmRecord.ONCE, AlarmRecord.BY_LUNAR_ONCE, 39 | AlarmRecord.BY_DAY, AlarmRecord.BY_WEEK, 40 | AlarmRecord.BY_MONTH, AlarmRecord.BY_YEAR, 41 | AlarmRecord.BY_LUNAR_MONTH, AlarmRecord.BY_LUNAR_YEAR}; 42 | 43 | // 闹钟类型名称集合 44 | public static String[] AlarmTypeNames; 45 | 46 | /** 47 | * 根据闹钟类型获取索引 48 | * @param type 闹钟类型 49 | * @return 在数组中的索引 50 | */ 51 | public static int getActionTypeIndex(int type){ 52 | for (int i = 0; i < AlarmTypeIndexs.length; i++){ 53 | if (AlarmTypeIndexs[i] == type){ 54 | return i; 55 | } 56 | } 57 | 58 | return -1; 59 | } 60 | 61 | /** 62 | * 载入全局性服务,Activity跟Service都需要用到的设置 63 | * @param context 上下文内容提供器 64 | */ 65 | public static void loadGlobalService(Context context){ 66 | // 初始化数据库 67 | DatabaseHelper.initDatabase(context); 68 | 69 | // 读取全局设置 70 | GlobalSettingMng.ReadSetting(context); 71 | 72 | // 载入默认主题 73 | ThemeStyle.LoadThemeResource(context); 74 | ThemeStyle.LoadGlobalTheme(); 75 | } 76 | 77 | /** 78 | * 输出调试信息 79 | * @param str 调试信息 80 | * @return 输出结果 81 | */ 82 | public static int DLog(String str){ 83 | Helper.RecordLog('D', str); 84 | return Log.d(LOG_TAG, str); 85 | } 86 | 87 | // public static int ILog(String str){ 88 | // return Log.i(LOG_TAG, str); 89 | // } 90 | 91 | public static int WLog(String str){ 92 | Helper.RecordLog('W', str); 93 | return Log.w(LOG_TAG, str); 94 | } 95 | 96 | public static int ELog(String str){ 97 | Helper.RecordLog('E', str); 98 | return Log.e(LOG_TAG, str); 99 | } 100 | 101 | public static int XLog(String str){ 102 | return Log.e(LOG_TAG, str); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/common/util/ScreenUtils.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.common.util; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.util.DisplayMetrics; 6 | import android.view.Window; 7 | import android.view.WindowManager; 8 | 9 | /** 10 | * 获取屏幕宽高等信息、全屏切换、保持屏幕常亮、截屏等 11 | * 12 | * @author liyujiang[QQ:1032694760] 13 | * @since 2015/11/26 14 | */ 15 | public final class ScreenUtils { 16 | private static boolean isFullScreen = false; 17 | 18 | /** 19 | * Display metrics display metrics. 20 | * 21 | * @param context the context 22 | * @return the display metrics 23 | */ 24 | public static DisplayMetrics displayMetrics(Context context) { 25 | DisplayMetrics dm = new DisplayMetrics(); 26 | WindowManager windowManager = (WindowManager) context 27 | .getSystemService(Context.WINDOW_SERVICE); 28 | windowManager.getDefaultDisplay().getMetrics(dm); 29 | LogUtils.debug("screen width=" + dm.widthPixels + "px, screen height=" + dm.heightPixels 30 | + "px, densityDpi=" + dm.densityDpi + ", density=" + dm.density); 31 | return dm; 32 | } 33 | 34 | /** 35 | * Width pixels int. 36 | * 37 | * @param context the context 38 | * @return the int 39 | */ 40 | public static int widthPixels(Context context) { 41 | return displayMetrics(context).widthPixels; 42 | } 43 | 44 | /** 45 | * Height pixels int. 46 | * 47 | * @param context the context 48 | * @return the int 49 | */ 50 | public static int heightPixels(Context context) { 51 | return displayMetrics(context).heightPixels; 52 | } 53 | 54 | /** 55 | * Density float. 56 | * 57 | * @param context the context 58 | * @return the float 59 | */ 60 | public static float density(Context context) { 61 | return displayMetrics(context).density; 62 | } 63 | 64 | /** 65 | * Density dpi int. 66 | * 67 | * @param context the context 68 | * @return the int 69 | */ 70 | public static int densityDpi(Context context) { 71 | return displayMetrics(context).densityDpi; 72 | } 73 | 74 | /** 75 | * Is full screen boolean. 76 | * 77 | * @return the boolean 78 | */ 79 | public static boolean isFullScreen() { 80 | return isFullScreen; 81 | } 82 | 83 | /** 84 | * Toggle full displayMetrics. 85 | * 86 | * @param activity the activity 87 | */ 88 | public static void toggleFullScreen(Activity activity) { 89 | Window window = activity.getWindow(); 90 | int flagFullscreen = WindowManager.LayoutParams.FLAG_FULLSCREEN; 91 | if (isFullScreen) { 92 | window.clearFlags(flagFullscreen); 93 | isFullScreen = false; 94 | } else { 95 | window.setFlags(flagFullscreen, flagFullscreen); 96 | isFullScreen = true; 97 | } 98 | } 99 | 100 | /** 101 | * 保持屏幕常亮 102 | * 103 | * @param activity the activity 104 | */ 105 | public static void keepBright(Activity activity) { 106 | //需在setContentView前调用 107 | int keepScreenOn = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; 108 | activity.getWindow().setFlags(keepScreenOn, keepScreenOn); 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/common/util/CompatUtils.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.common.util; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.graphics.drawable.Drawable; 6 | import android.os.Build; 7 | import android.support.annotation.ColorInt; 8 | import android.support.annotation.ColorRes; 9 | import android.support.annotation.DrawableRes; 10 | import android.support.annotation.StringRes; 11 | import android.support.annotation.StyleRes; 12 | import android.view.View; 13 | import android.widget.TextView; 14 | 15 | /** 16 | * 兼容旧版&新版 17 | * 18 | * @author 李玉江[QQ :1032694760] 19 | * @since 2015 /10/19 Created By Android Studio 20 | */ 21 | public class CompatUtils { 22 | 23 | /** 24 | * Sets background. 25 | * 26 | * @param view the view 27 | * @param drawable the drawable 28 | */ 29 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN) 30 | public static void setBackground(View view, Drawable drawable) { 31 | if (Build.VERSION.SDK_INT < 16) { 32 | //noinspection deprecation 33 | view.setBackgroundDrawable(drawable); 34 | } else { 35 | view.setBackground(drawable); 36 | } 37 | } 38 | 39 | /** 40 | * Sets text appearance. 41 | * 42 | * @param view the view 43 | * @param appearanceRes the appearance res 44 | */ 45 | @TargetApi(Build.VERSION_CODES.M) 46 | public static void setTextAppearance(TextView view, @StyleRes int appearanceRes) { 47 | if (Build.VERSION.SDK_INT < 23) { 48 | //noinspection deprecation 49 | view.setTextAppearance(view.getContext(), appearanceRes); 50 | } else { 51 | view.setTextAppearance(appearanceRes); 52 | } 53 | } 54 | 55 | /** 56 | * Gets drawable. 57 | * 58 | * @param context the context 59 | * @param drawableRes the drawable res 60 | * @return the drawable 61 | */ 62 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 63 | public static Drawable getDrawable(Context context, @DrawableRes int drawableRes) { 64 | if (Build.VERSION.SDK_INT < 21) { 65 | //noinspection deprecation 66 | return context.getResources().getDrawable(drawableRes); 67 | } else { 68 | return context.getDrawable(drawableRes); 69 | } 70 | } 71 | 72 | /** 73 | * Gets string. 74 | * 75 | * @param context the context 76 | * @param stringRes the string res 77 | * @return the string 78 | */ 79 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 80 | public static String getString(Context context, @StringRes int stringRes) { 81 | if (Build.VERSION.SDK_INT < 21) { 82 | //noinspection deprecation 83 | return context.getResources().getString(stringRes); 84 | } else { 85 | return context.getString(stringRes); 86 | } 87 | } 88 | 89 | /** 90 | * Gets color. 91 | * 92 | * @param context the context 93 | * @param colorRes the color res 94 | * @return the color 95 | */ 96 | @ColorInt 97 | public static int getColor(Context context, @ColorRes int colorRes) { 98 | if (Build.VERSION.SDK_INT < 21) { 99 | //noinspection deprecation 100 | return context.getResources().getColor(colorRes); 101 | } else { 102 | return context.getResources().getColor(colorRes, null); 103 | } 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/monthui/CalendarViewPagerListener.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.monthui; 2 | 3 | import android.support.v4.view.ViewPager; 4 | 5 | import com.jjforever.wgj.maincalendar.util.LunarCalendar; 6 | 7 | /** 8 | * Created by Wgj on 2016/8/10. 9 | * 日历页面滑动监听类 10 | */ 11 | public class CalendarViewPagerListener implements ViewPager.OnPageChangeListener { 12 | // 默认页面索引 13 | public static final int DEFAULT_INDEX = 498; 14 | 15 | // 滑动方向定义 16 | private static final int SLIDE_NO = 0; 17 | private static final int SLIDE_LEFT = 1; 18 | private static final int SLIDE_RIGHT = 2; 19 | 20 | // 滑动方向 21 | private int mDirection = SLIDE_NO; 22 | // 当前页面索引 23 | private int mCurrIndex = DEFAULT_INDEX; 24 | // 显示的日历页面 25 | private CalendarView[] mShowViews; 26 | 27 | public CalendarViewPagerListener(CalendarViewPagerAdapter viewAdapter) { 28 | super(); 29 | this.mShowViews = viewAdapter.getAllItems(); 30 | } 31 | 32 | @Override 33 | public void onPageSelected(int position) { 34 | measureDirection(position); 35 | updateCalendarView(position); 36 | } 37 | 38 | /** 39 | * 转到今日 40 | */ 41 | public void backToday(){ 42 | getCurrentView().backToday(); 43 | onPageSelected(mCurrIndex); 44 | } 45 | 46 | /** 47 | * 更细当前页面在添加或删除记录后 48 | */ 49 | public void updateView(){ 50 | getCurrentView().update(true); 51 | onPageSelected(mCurrIndex); 52 | } 53 | 54 | /** 55 | * 转到指定日期 56 | * @param date 指定日期 57 | */ 58 | public void locateToDay(LunarCalendar date){ 59 | getCurrentView().locateToDay(date); 60 | onPageSelected(mCurrIndex); 61 | } 62 | 63 | /** 64 | * 根据索引更新页面视图 65 | * @param index 页面索引 66 | */ 67 | private void updateCalendarView(int index) { 68 | LunarCalendar curDate = getCurrentView().getClickCell().CellDate; 69 | if(mDirection == SLIDE_RIGHT || mDirection == SLIDE_NO){ 70 | mShowViews[(index + 1)% mShowViews.length].rightSlide(new LunarCalendar(curDate)); 71 | } 72 | if(mDirection == SLIDE_LEFT || mDirection == SLIDE_NO){ 73 | int tmpIndex = (index - 1)% mShowViews.length; 74 | if (tmpIndex < 0){ 75 | tmpIndex += mShowViews.length; 76 | } 77 | mShowViews[tmpIndex].leftSlide(new LunarCalendar(curDate)); 78 | } 79 | mDirection = SLIDE_NO; 80 | getCurrentView().callBackDate(); 81 | } 82 | 83 | /** 84 | * 判断滑动方向 85 | * @param index 要载入的页面索引 86 | */ 87 | private void measureDirection(int index) { 88 | if (index > mCurrIndex) { 89 | mDirection = SLIDE_RIGHT; 90 | } else if (index < mCurrIndex) { 91 | mDirection = SLIDE_LEFT; 92 | } 93 | mCurrIndex = index; 94 | } 95 | 96 | /** 97 | * 获取当前显示的页面 98 | * @return 当前显示的日历页面 99 | */ 100 | public CalendarView getCurrentView() 101 | { 102 | return mShowViews[mCurrIndex % mShowViews.length]; 103 | } 104 | 105 | @Override 106 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { 107 | } 108 | 109 | @Override 110 | public void onPageScrollStateChanged(int state) { 111 | } 112 | 113 | /** 114 | * 获取所有页面 115 | * @return 所有页面 116 | */ 117 | // public CalendarView[] getAllItems() { 118 | // return mShowViews; 119 | // } 120 | } 121 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/listviewpicker/picker/WeekAdapter.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.listviewpicker.picker; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.CheckBox; 9 | import android.widget.TextView; 10 | 11 | import com.jjforever.wgj.maincalendar.R; 12 | 13 | import java.text.DateFormatSymbols; 14 | import java.util.ArrayList; 15 | import java.util.Calendar; 16 | import java.util.HashMap; 17 | 18 | /** 19 | * Created by Wgj on 2016/9/17. 20 | * 星期适配器 21 | */ 22 | public class WeekAdapter extends BaseAdapter { 23 | private Context context; 24 | private ArrayList list; 25 | // 用来控制CheckBox的选中状况 26 | private HashMap isSelected = new HashMap<>(); 27 | 28 | public WeekAdapter(Context context){ 29 | this.context = context; 30 | 31 | this.list = new ArrayList<>(); 32 | String[] weekdays = new DateFormatSymbols().getWeekdays(); 33 | this.list.add(weekdays[Calendar.SUNDAY]); 34 | this.list.add(weekdays[Calendar.MONDAY]); 35 | this.list.add(weekdays[Calendar.TUESDAY]); 36 | this.list.add(weekdays[Calendar.WEDNESDAY]); 37 | this.list.add(weekdays[Calendar.THURSDAY]); 38 | this.list.add(weekdays[Calendar.FRIDAY]); 39 | this.list.add(weekdays[Calendar.SATURDAY]); 40 | 41 | for(int i = 0; i < list.size(); i++) { 42 | setIsSelected(i, false); 43 | } 44 | } 45 | 46 | @Override 47 | public int getCount() { 48 | if (list == null) { 49 | return 0; 50 | } 51 | return list.size(); 52 | } 53 | 54 | @Override 55 | public Object getItem(int position) { 56 | if (list == null) { 57 | return null; 58 | } 59 | return list.get(position); 60 | } 61 | 62 | @Override 63 | public long getItemId(int position) { 64 | return position; 65 | } 66 | 67 | @Override 68 | public View getView(int position, View convertView, ViewGroup parent) { 69 | ViewHolder holder; 70 | if (convertView == null) { 71 | // 获得ViewHolder对象 72 | holder = new ViewHolder(); 73 | // 导入布局并赋值给convertView 74 | convertView = LayoutInflater.from(context).inflate( 75 | R.layout.listview_item_check, parent, false); 76 | holder.tv = (TextView) convertView.findViewById(R.id.item_tv); 77 | holder.cb = (CheckBox) convertView.findViewById(R.id.item_cb); 78 | // 为view设置标签 79 | convertView.setTag(holder); 80 | } else { 81 | // 取出holder 82 | holder = (ViewHolder) convertView.getTag(); 83 | } 84 | 85 | // 设置list中TextView的显示 86 | holder.tv.setText(list.get(position)); 87 | // 根据isSelected来设置checkbox的选中状况 88 | holder.cb.setChecked(getIsSelected(position)); 89 | return convertView; 90 | } 91 | 92 | public boolean getIsSelected(Integer position){ 93 | return isSelected.get(position); 94 | } 95 | 96 | public void setIsSelected(Integer position, boolean checked) { 97 | this.isSelected.put(position, checked); 98 | } 99 | 100 | @Override 101 | public boolean hasStableIds() { 102 | return true; 103 | } 104 | 105 | public static class ViewHolder { 106 | TextView tv; 107 | CheckBox cb; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 37 | 40 | 43 | 46 | 49 | 52 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/ShiftsWorkAdapter.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.RelativeLayout; 9 | import android.widget.TextView; 10 | 11 | import com.jjforever.wgj.maincalendar.Model.ShiftsWorkRecord; 12 | 13 | import java.util.List; 14 | import java.util.Locale; 15 | 16 | /** 17 | * Created by Wgj on 2016/9/28. 18 | * 倒班记录列表适配器 19 | */ 20 | public class ShiftsWorkAdapter extends BaseAdapter { 21 | private Context context; 22 | private List list; 23 | 24 | public ShiftsWorkAdapter(Context context, List list) { 25 | this.context = context; 26 | this.list = list; 27 | } 28 | 29 | @Override 30 | public int getCount() { 31 | if (list == null) { 32 | return 0; 33 | } 34 | return list.size(); 35 | } 36 | 37 | @Override 38 | public Object getItem(int position) { 39 | if (list == null) { 40 | return null; 41 | } 42 | return list.get(position); 43 | } 44 | 45 | /** 46 | * 删除指定位置的条目 47 | * @param position 指定的位置 48 | * @return 删除成功与否 49 | */ 50 | public boolean removeItem(int position){ 51 | if (list == null){ 52 | return false; 53 | } 54 | if (position < 0 || position >= list.size()){ 55 | return false; 56 | } 57 | 58 | return list.remove(position) != null; 59 | } 60 | 61 | /** 62 | * 在指定位置更新记录信息 63 | * @param position 指定位置 64 | * @param record 记录信息 65 | * @return 是否成功 66 | */ 67 | public boolean setItem(int position, ShiftsWorkRecord record){ 68 | if (list == null){ 69 | return false; 70 | } 71 | 72 | return list.set(position, record) != null; 73 | } 74 | 75 | @Override 76 | public long getItemId(int position) { 77 | return position; 78 | } 79 | 80 | @Override 81 | public View getView(int position, View convertView, ViewGroup parent) { 82 | WorkViewHolder holder; 83 | if (convertView == null) { 84 | holder = new WorkViewHolder(); 85 | convertView = LayoutInflater.from(context).inflate( 86 | R.layout.item_time_line, parent, false); 87 | holder.title = (TextView) convertView 88 | .findViewById(R.id.record_date_time); 89 | holder.content = (TextView) convertView 90 | .findViewById(R.id.txt_date_content); 91 | holder.line = convertView.findViewById(R.id.record_line); 92 | holder.layout = (RelativeLayout) convertView 93 | .findViewById(R.id.record_title); 94 | convertView.setTag(holder); 95 | } else { 96 | holder = (WorkViewHolder) convertView.getTag(); 97 | } 98 | //时间轴竖线的layout 99 | RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) holder.line.getLayoutParams(); 100 | //第一条数据,肯定显示时间标题 101 | ShiftsWorkRecord tmpRecord = list.get(position); 102 | holder.layout.setVisibility(View.VISIBLE); 103 | holder.title.setText(tmpRecord.getStartDate().toShortString()); 104 | params.addRule(RelativeLayout.ALIGN_TOP, R.id.record_title); 105 | params.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.txt_date_content); 106 | holder.line.setLayoutParams(params); 107 | holder.content.setText(String.format(Locale.getDefault(), "%s [周期%d天]", 108 | tmpRecord.getTitle(), tmpRecord.getPeriod())); 109 | return convertView; 110 | } 111 | 112 | @Override 113 | public boolean hasStableIds() { 114 | return true; 115 | } 116 | 117 | public static class WorkViewHolder { 118 | RelativeLayout layout; 119 | View line; 120 | TextView title; 121 | TextView content; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/listviewpicker/picker/WeekPicker.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.listviewpicker.picker; 2 | 3 | import android.app.Activity; 4 | import android.support.annotation.NonNull; 5 | import android.view.View; 6 | import android.widget.AdapterView; 7 | import android.widget.LinearLayout; 8 | import android.widget.ListView; 9 | 10 | import com.jjforever.wgj.maincalendar.R; 11 | import com.jjforever.wgj.maincalendar.common.popup.ConfirmPopup; 12 | 13 | import java.util.ArrayList; 14 | 15 | /** 16 | * Created by Wgj on 2016/9/17. 17 | * 星期选择器 18 | */ 19 | public class WeekPicker extends ConfirmPopup { 20 | // 星期列表 21 | private ListView mListView; 22 | // 标题 23 | private String mTitle; 24 | // 星期内容提供器 25 | private WeekAdapter mWeekAdapter; 26 | 27 | // 监听事件 28 | private OnWeekPickListener onWeekPickListener; 29 | 30 | /** 31 | * 创建一个对话框 32 | * @param activity 活动 33 | * @param title 标题 34 | */ 35 | public WeekPicker(Activity activity, String title) 36 | { 37 | super(activity); 38 | mWeekAdapter = new WeekAdapter(activity); 39 | mTitle = title; 40 | } 41 | 42 | /** 43 | * 创建一个对话框,标题为提醒字样 44 | * @param activity 活动 45 | */ 46 | public WeekPicker(Activity activity) 47 | { 48 | this(activity, activity.getResources().getString(R.string.please_chose_week)); 49 | } 50 | 51 | /** 52 | * 设置选中的星期 53 | * @param items 选中的星期 54 | */ 55 | public void setCheckedItems(int items){ 56 | for (int i = 0; i < mWeekAdapter.getCount(); i++){ 57 | if ((items & (1 << i)) != 0){ 58 | mWeekAdapter.setIsSelected(i, true); 59 | } 60 | else{ 61 | mWeekAdapter.setIsSelected(i, false); 62 | } 63 | } 64 | } 65 | 66 | /** 67 | * 设置监听事件 68 | * @param onWeekPickListener 回调方法 69 | */ 70 | public void setOnWeekPickListener(OnWeekPickListener onWeekPickListener) { 71 | this.onWeekPickListener = onWeekPickListener; 72 | } 73 | 74 | @Override 75 | protected void onSubmit() { 76 | if (onWeekPickListener != null) { 77 | int tmpDay = 0; 78 | for (int i = 0; i < mWeekAdapter.getCount(); i++){ 79 | if (mWeekAdapter.getIsSelected(i)){ 80 | tmpDay |= (1 << i); 81 | } 82 | } 83 | onWeekPickListener.onWeekPicked(tmpDay); 84 | } 85 | } 86 | 87 | @Override 88 | @NonNull 89 | protected LinearLayout makeCenterView() { 90 | LinearLayout rootLayout = new LinearLayout(activity); 91 | rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); 92 | rootLayout.setOrientation(LinearLayout.VERTICAL); 93 | 94 | mListView = new ListView(activity); 95 | mListView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); 96 | mListView.getLayoutParams().height = screenHeightPixels/4; 97 | mListView.setPadding(30, 10, 30, 10); 98 | // 去掉分割线 99 | mListView.setDividerHeight(0); 100 | mListView.setAdapter(mWeekAdapter); 101 | rootLayout.addView(mListView); 102 | 103 | mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 104 | @Override 105 | public void onItemClick(AdapterView arg0, View arg1, 106 | int arg2, long arg3) { 107 | // 取得ViewHolder对象,这样就省去了通过层层的findViewById去实例化我们需要的cb实例的步骤 108 | WeekAdapter.ViewHolder holder = (WeekAdapter.ViewHolder) arg1.getTag(); 109 | // 改变CheckBox的状态 110 | holder.cb.toggle(); 111 | // 将CheckBox的选中状况记录下来 112 | mWeekAdapter.setIsSelected(arg2, holder.cb.isChecked()); 113 | } 114 | }); 115 | setTitleText(mTitle); 116 | return rootLayout; 117 | } 118 | 119 | /** 120 | * 星期选择框确认取消接口 121 | */ 122 | public interface OnWeekPickListener { 123 | /** 124 | * 星期选择框确认事件 125 | * @param selected 选中的星期 126 | */ 127 | void onWeekPicked(int selected); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/Model/ShiftsWorkRecord.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.Model; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import com.jjforever.wgj.maincalendar.util.LunarCalendar; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Calendar; 10 | 11 | /** 12 | * Created by Wgj on 2016/9/19. 13 | * 倒班/轮班记录实体类 14 | */ 15 | public class ShiftsWorkRecord implements Parcelable { 16 | // 记录索引 17 | private long mIndex; 18 | // 该轮班的标题 19 | private String mTitle = ""; 20 | // 计算轮班的起始日期 21 | private LunarCalendar mStartDate; 22 | // 一个倒班循环周期天数 最多8天,最少2天 23 | private int mPeriod; 24 | // 每天记录集合 25 | private ArrayList mItems; 26 | // 记录创建时间 27 | private Calendar mCreateTime; 28 | // 是否为新记录 29 | private boolean mIsNew; 30 | 31 | public ShiftsWorkRecord(){ 32 | mIsNew = true; 33 | } 34 | 35 | public ShiftsWorkRecord(boolean isNew){ 36 | this.mIsNew = isNew; 37 | } 38 | 39 | public long getIndex(){ 40 | return mIndex; 41 | } 42 | 43 | public void setIndex(long index){ 44 | mIndex = index; 45 | } 46 | 47 | public String getTitle(){ 48 | return mTitle; 49 | } 50 | 51 | public void setTitle(String title){ 52 | this.mTitle = title; 53 | } 54 | 55 | public LunarCalendar getStartDate(){ 56 | return this.mStartDate; 57 | } 58 | 59 | public void setStartDate(LunarCalendar date){ 60 | this.mStartDate = date; 61 | } 62 | 63 | public int getPeriod(){ 64 | return mPeriod; 65 | } 66 | 67 | public void setPeriod(int period){ 68 | this.mPeriod = period; 69 | } 70 | 71 | public ArrayList getItems(){ 72 | return mItems; 73 | } 74 | 75 | public void setItems(ArrayList items){ 76 | this.mItems = items; 77 | } 78 | 79 | public Calendar getCreateTime(){ 80 | return mCreateTime; 81 | } 82 | 83 | public void setCreateTime(Calendar calendar){ 84 | mCreateTime = calendar; 85 | } 86 | 87 | public boolean getIsNew(){ 88 | return mIsNew; 89 | } 90 | 91 | public void setIsNew(boolean isNew){ 92 | mIsNew = isNew; 93 | } 94 | 95 | /** 96 | * 计算指定日期是轮班的第几天 97 | * @param year 年 98 | * @param month 月 99 | * @param day 日 100 | * @return 第几天 第一天为0 小于0表示无效 101 | */ 102 | public int getDayNo(int year, int month, int day){ 103 | LunarCalendar tmpDate = new LunarCalendar(year, month, day); 104 | long curMill = tmpDate.getTimeInMillis(); 105 | long startMill = this.mStartDate.getTimeInMillis(); 106 | long diff = Math.abs(curMill - startMill); 107 | int dayCount = (int)(diff / (24 * 3600000)); 108 | if (curMill >= startMill){ 109 | return dayCount % this.mPeriod; 110 | } 111 | 112 | int dayNo = this.mPeriod - (dayCount % this.mPeriod); 113 | return dayNo == this.mPeriod ? 0 : dayNo; 114 | } 115 | 116 | @Override 117 | public int describeContents() { 118 | return 0; 119 | } 120 | 121 | @Override 122 | public void writeToParcel(Parcel dest, int flags) { 123 | dest.writeLong(this.mIndex); 124 | dest.writeString(this.mTitle); 125 | dest.writeSerializable(this.mStartDate); 126 | dest.writeInt(this.mPeriod); 127 | dest.writeTypedList(this.mItems); 128 | dest.writeSerializable(this.mCreateTime); 129 | dest.writeByte(this.mIsNew ? (byte) 1 : (byte) 0); 130 | } 131 | 132 | protected ShiftsWorkRecord(Parcel in) { 133 | this.mIndex = in.readLong(); 134 | this.mTitle = in.readString(); 135 | this.mStartDate = (LunarCalendar) in.readSerializable(); 136 | this.mPeriod = in.readInt(); 137 | this.mItems = in.createTypedArrayList(ShiftsWorkItem.CREATOR); 138 | this.mCreateTime = (Calendar) in.readSerializable(); 139 | this.mIsNew = in.readByte() != 0; 140 | } 141 | 142 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { 143 | @Override 144 | public ShiftsWorkRecord createFromParcel(Parcel source) { 145 | return new ShiftsWorkRecord(source); 146 | } 147 | 148 | @Override 149 | public ShiftsWorkRecord[] newArray(int size) { 150 | return new ShiftsWorkRecord[size]; 151 | } 152 | }; 153 | } 154 | 155 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/Model/ShiftsWorkItem.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.Model; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | import android.support.annotation.IntDef; 6 | 7 | import java.lang.annotation.Retention; 8 | import java.lang.annotation.RetentionPolicy; 9 | 10 | /** 11 | * Created by Wgj on 2016/9/20. 12 | * 倒班每天记录实体类 13 | */ 14 | public class ShiftsWorkItem implements Parcelable { 15 | // 什么都不做标识 16 | final static int DO_NOTHING = 0; 17 | // 该条需要更新标识 18 | public final static int UPDATE = 1; 19 | // 该条需要添加标识 20 | public final static int INSERT = 2; 21 | // 该条需要删除标识 22 | public final static int DELETE = 3; 23 | 24 | @IntDef({DO_NOTHING, UPDATE, INSERT, DELETE}) 25 | @Retention(RetentionPolicy.SOURCE) 26 | @interface ActionFlag { 27 | } 28 | 29 | // 记录索引 30 | private long mIndex; 31 | // 所属倒班记录索引 32 | private long mWorkIndex; 33 | // 第几天 34 | private int mDayNo; 35 | // 当天上班或休息标题 36 | private String mTitle = ""; 37 | // 开始时间 38 | private AlarmTime mStartTime; 39 | // 结束时间 40 | private AlarmTime mEndTime; 41 | // 需要更新或者删除标识 0表示什么都不做 42 | @ActionFlag 43 | private int mFlag; 44 | 45 | public ShiftsWorkItem(){ 46 | this.mStartTime = new AlarmTime(0, 0); 47 | this.mEndTime = new AlarmTime(23, 59); 48 | this.mFlag = DO_NOTHING; 49 | } 50 | 51 | public long getIndex(){ 52 | return mIndex; 53 | } 54 | 55 | public void setIndex(long index){ 56 | this.mIndex = index; 57 | } 58 | 59 | public long getWorkIndex(){ 60 | return mWorkIndex; 61 | } 62 | 63 | public void setWorkIndex(long index){ 64 | this.mWorkIndex = index; 65 | } 66 | 67 | public int getDayNo(){ 68 | return mDayNo; 69 | } 70 | 71 | public void setDayNo(int day){ 72 | this.mDayNo = day; 73 | } 74 | 75 | public String getTitle(){ 76 | return mTitle; 77 | } 78 | 79 | public void setTitle(String title){ 80 | this.mTitle = title; 81 | } 82 | 83 | public AlarmTime getStartTime(){ 84 | return mStartTime; 85 | } 86 | 87 | public void setStartTime(int hour, int minute){ 88 | this.mStartTime.Hour = hour; 89 | this.mStartTime.Minute = minute; 90 | } 91 | 92 | public void setStartTime(int time){ 93 | this.mStartTime.setTime(time); 94 | } 95 | 96 | public AlarmTime getEndTime(){ 97 | return mEndTime; 98 | } 99 | 100 | public void setEndTime(int hour, int minute){ 101 | this.mEndTime.Hour = hour; 102 | this.mEndTime.Minute = minute; 103 | } 104 | 105 | /** 106 | * 从数据库读取的数据进行时间设置 107 | * @param time 数据库时间值 分钟数 108 | */ 109 | public void setEndTime(int time){ 110 | this.mEndTime.setTime(time); 111 | } 112 | 113 | @ActionFlag 114 | public int getFlag(){ 115 | return mFlag; 116 | } 117 | 118 | public void setFlag(@ActionFlag int flag){ 119 | this.mFlag = flag; 120 | } 121 | 122 | @Override 123 | public int describeContents() { 124 | return 0; 125 | } 126 | 127 | @Override 128 | public void writeToParcel(Parcel dest, int flags) { 129 | dest.writeLong(this.mIndex); 130 | dest.writeLong(this.mWorkIndex); 131 | dest.writeInt(this.mDayNo); 132 | dest.writeString(this.mTitle); 133 | dest.writeParcelable(this.mStartTime, flags); 134 | dest.writeParcelable(this.mEndTime, flags); 135 | dest.writeInt(this.mFlag); 136 | } 137 | 138 | @SuppressWarnings("ResourceType") 139 | protected ShiftsWorkItem(Parcel in) { 140 | this.mIndex = in.readLong(); 141 | this.mWorkIndex = in.readLong(); 142 | this.mDayNo = in.readInt(); 143 | this.mTitle = in.readString(); 144 | this.mStartTime = in.readParcelable(AlarmTime.class.getClassLoader()); 145 | this.mEndTime = in.readParcelable(AlarmTime.class.getClassLoader()); 146 | this.mFlag = in.readInt(); 147 | } 148 | 149 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { 150 | @Override 151 | public ShiftsWorkItem createFromParcel(Parcel source) { 152 | return new ShiftsWorkItem(source); 153 | } 154 | 155 | @Override 156 | public ShiftsWorkItem[] newArray(int size) { 157 | return new ShiftsWorkItem[size]; 158 | } 159 | }; 160 | } 161 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/wheelpicker/picker/LunarMonthPicker.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.wheelpicker.picker; 2 | 3 | import android.app.Activity; 4 | import android.support.annotation.NonNull; 5 | import android.view.Gravity; 6 | import android.view.View; 7 | import android.widget.LinearLayout; 8 | import android.widget.TextView; 9 | 10 | import com.jjforever.wgj.maincalendar.util.LunarCalendar; 11 | import com.jjforever.wgj.maincalendar.wheelpicker.widget.WheelView; 12 | 13 | import java.util.ArrayList; 14 | import java.util.Calendar; 15 | 16 | /** 17 | * Created by Wgj on 2016/9/11. 18 | * 农历月日选择器 19 | */ 20 | public class LunarMonthPicker extends WheelPicker { 21 | 22 | private int selectedMonth = 0; 23 | private int selectedDay = 0; 24 | private OnLunarMonthPickListener onLunarMonthPickListener; 25 | 26 | public LunarMonthPicker(Activity activity) { 27 | super(activity); 28 | Calendar tmpCalendar = Calendar.getInstance(); 29 | LunarCalendar tmpLunar = new LunarCalendar(tmpCalendar); 30 | selectedMonth = tmpLunar.get(LunarCalendar.LUNAR_MONTH) - 1; 31 | selectedDay = tmpLunar.get(LunarCalendar.LUNAR_DATE) - 1; 32 | } 33 | 34 | public void setSelectedItem(int month, int day) { 35 | selectedMonth = month - 1; 36 | selectedDay = day - 1; 37 | } 38 | 39 | public void setOnLunarMonthPickListener(OnLunarMonthPickListener listener) { 40 | this.onLunarMonthPickListener = listener; 41 | } 42 | 43 | @Override 44 | @NonNull 45 | protected View makeCenterView() { 46 | LinearLayout layout = new LinearLayout(activity); 47 | layout.setOrientation(LinearLayout.HORIZONTAL); 48 | layout.setGravity(Gravity.CENTER); 49 | WheelView monthView = new WheelView(activity); 50 | monthView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); 51 | monthView.setTextSize(textSize); 52 | monthView.setTextColor(textColorNormal, textColorFocus); 53 | monthView.setLineVisible(lineVisible); 54 | monthView.setLineColor(lineColor); 55 | layout.addView(monthView); 56 | TextView monthTextView = new TextView(activity); 57 | monthTextView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); 58 | monthTextView.setTextSize(textSize); 59 | monthTextView.setTextColor(textColorFocus); 60 | monthTextView.setText("月"); 61 | layout.addView(monthTextView); 62 | 63 | WheelView dayView = new WheelView(activity); 64 | dayView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); 65 | dayView.setTextSize(textSize); 66 | dayView.setTextColor(textColorNormal, textColorFocus); 67 | dayView.setLineVisible(lineVisible); 68 | dayView.setLineColor(lineColor); 69 | dayView.setOffset(offset); 70 | layout.addView(dayView); 71 | 72 | ArrayList months = new ArrayList<>(); 73 | for (int i = 1; i < LunarCalendar.lunarMonthNames.length; i++){ 74 | months.add(LunarCalendar.lunarMonthNames[i]); 75 | } 76 | monthView.setItems(months, selectedMonth); 77 | ArrayList days = new ArrayList<>(); 78 | for (int i = 1; i < LunarCalendar.lunarDateNames.length; i++) { 79 | days.add(LunarCalendar.lunarDateNames[i]); 80 | } 81 | dayView.setItems(days, selectedDay); 82 | monthView.setOnWheelViewListener(new WheelView.OnWheelViewListener() { 83 | @Override 84 | public void onSelected(boolean isUserScroll, int selectedIndex, String item) { 85 | selectedMonth = selectedIndex; 86 | } 87 | }); 88 | dayView.setOnWheelViewListener(new WheelView.OnWheelViewListener() { 89 | @Override 90 | public void onSelected(boolean isUserScroll, int selectedIndex, String item) { 91 | selectedDay = selectedIndex; 92 | } 93 | }); 94 | return layout; 95 | } 96 | 97 | @Override 98 | public void onSubmit() { 99 | if (onLunarMonthPickListener != null) { 100 | onLunarMonthPickListener.onLunarMonthPicked(selectedMonth + 1, selectedDay + 1); 101 | } 102 | } 103 | 104 | public interface OnLunarMonthPickListener { 105 | /** 106 | * 选中农历月日触发事件 107 | * @param month 农历月 108 | * @param day 农历日 109 | */ 110 | void onLunarMonthPicked(int month, int day); 111 | 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/wheelpicker/picker/WeatherPicker.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.wheelpicker.picker; 2 | 3 | import android.app.Activity; 4 | import android.graphics.drawable.Drawable; 5 | import android.support.annotation.NonNull; 6 | import android.text.Html; 7 | import android.view.Gravity; 8 | import android.view.View; 9 | import android.widget.LinearLayout; 10 | import android.widget.TextView; 11 | 12 | import com.jjforever.wgj.maincalendar.weather.util.WeatherConstants; 13 | import com.jjforever.wgj.maincalendar.weather.util.WeatherIconUtil; 14 | import com.jjforever.wgj.maincalendar.wheelpicker.widget.WheelView; 15 | 16 | import java.util.ArrayList; 17 | 18 | /** 19 | * Created by Wgj on 2016/8/24. 20 | * 天气情况选择控件 21 | */ 22 | public class WeatherPicker extends WheelPicker { 23 | 24 | // 选择的天气索引 25 | private int mSelectedWeatherIndex = 0; 26 | private ArrayList weathers = new ArrayList<>(); 27 | // 天气选中触发事件 28 | private OnWeatherPickListener onWeatherPickListener; 29 | // 图片显示 30 | private TextView mImageView; 31 | 32 | /** 33 | * 控件初始化 34 | * @param activity 所在活动 35 | */ 36 | public WeatherPicker(Activity activity){ 37 | super(activity); 38 | 39 | for (int i = WeatherConstants.START_CODE; i <= WeatherConstants.END_CODE; i++){ 40 | weathers.add(WeatherIconUtil.getWeatherName(i)); 41 | } 42 | } 43 | 44 | /** 45 | * 设置触发事件 46 | * @param listener 监听事件 47 | */ 48 | public void setOnWeatherPickListener(OnWeatherPickListener listener) { 49 | this.onWeatherPickListener = listener; 50 | } 51 | 52 | /** 53 | * 获取选中的天气代码 54 | * @return 天气代码 55 | */ 56 | public int getSelectedWeather() 57 | { 58 | return mSelectedWeatherIndex; 59 | } 60 | 61 | /** 62 | * 设置默认显示天气 63 | * @param code 天气代码 64 | */ 65 | public void setSelectedItem(int code) 66 | { 67 | mSelectedWeatherIndex = code; 68 | } 69 | 70 | // 获取图片 71 | Html.ImageGetter imageGetter = new Html.ImageGetter() { 72 | @Override 73 | public Drawable getDrawable(String source) { 74 | int id = Integer.parseInt(source); 75 | Drawable drawable = activity.getResources().getDrawable(id); 76 | if (drawable != null) { 77 | drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), 78 | drawable.getIntrinsicHeight()); 79 | } 80 | return drawable; 81 | } 82 | }; 83 | 84 | @Override 85 | @NonNull 86 | protected View makeCenterView() { 87 | LinearLayout layout = new LinearLayout(activity); 88 | layout.setOrientation(LinearLayout.HORIZONTAL); 89 | layout.setGravity(Gravity.CENTER); 90 | 91 | WheelView weatherView = new WheelView(activity); 92 | weatherView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); 93 | weatherView.setTextSize(textSize); 94 | weatherView.setTextColor(textColorNormal, textColorFocus); 95 | weatherView.setLineVisible(lineVisible); 96 | weatherView.setLineColor(lineColor); 97 | layout.addView(weatherView); 98 | 99 | mImageView = new TextView(activity); 100 | mImageView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); 101 | mImageView.setText(Html.fromHtml("", imageGetter, null)); 102 | layout.addView(mImageView); 103 | 104 | weatherView.setItems(weathers, mSelectedWeatherIndex); 105 | weatherView.setOnWheelViewListener(new WheelView.OnWheelViewListener() { 106 | @Override 107 | public void onSelected(boolean isUserScroll, int selectedIndex, String item) { 108 | mSelectedWeatherIndex = selectedIndex; 109 | mImageView.setText(Html.fromHtml("", imageGetter, null)); 110 | } 111 | }); 112 | 113 | return layout; 114 | } 115 | 116 | @Override 117 | public void onSubmit() { 118 | if (onWeatherPickListener != null) { 119 | onWeatherPickListener.onWeatherPicked(getSelectedWeather()); 120 | } 121 | } 122 | 123 | public interface OnWeatherPickListener { 124 | /** 125 | * 天气选中触发事件 126 | * @param code 天气代码 127 | */ 128 | void onWeatherPicked(int code); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/Model/DailyRecord.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.Model; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import com.jjforever.wgj.maincalendar.util.LunarCalendar; 7 | import java.util.Calendar; 8 | 9 | /** 10 | * Created by Wgj on 2016/8/26. 11 | * 日程记录实体类 实现Serializable接口方便传递 12 | */ 13 | public class DailyRecord implements ICalendarRecord, Parcelable { 14 | 15 | // 记录索引 16 | private long mIndex = 0; 17 | // 记录的日期 18 | private LunarCalendar mRecordTime; 19 | // 天气情况代码 20 | private int mWeather; 21 | // 记录标题 22 | private String mTitle = ""; 23 | // 记录内容 24 | private String mContent = ""; 25 | // 是否在日历中显示 26 | private boolean mDisplay = true; 27 | // 记录创建时间 28 | private Calendar mCreateTime; 29 | // 是否为新记录 30 | private boolean mIsNew; 31 | 32 | /** 33 | * 创建一条新的记录 34 | */ 35 | public DailyRecord() { 36 | mIsNew = true; 37 | } 38 | 39 | /** 40 | * 创建一条记录 41 | * @param isNew 是否为新记录 42 | */ 43 | public DailyRecord(boolean isNew){ 44 | mIsNew = isNew; 45 | } 46 | 47 | /** 48 | * 获取日常记录类型 49 | * @return 日常记录类型 RecordType.DAILY_RECORD 50 | */ 51 | public int getType(){ 52 | return RecordType.DAILY_RECORD; 53 | } 54 | 55 | /** 56 | * 显示方式 57 | * @return RecordShowType类型 58 | */ 59 | public int showType(){ 60 | return mDisplay ? RecordShowType.TEXT_DOT : RecordShowType.HIDE; 61 | } 62 | 63 | public long getIndex(){ 64 | return mIndex; 65 | } 66 | 67 | public void setIndex(long index){ 68 | mIndex = index; 69 | } 70 | 71 | /** 72 | * 获取记录的日期 73 | * @return 记录的日期 74 | */ 75 | public LunarCalendar getRecordTime(){ 76 | return mRecordTime; 77 | } 78 | 79 | public void setRecordTime(LunarCalendar calendar){ 80 | mRecordTime = calendar; 81 | } 82 | 83 | public int getWeather(){ 84 | return mWeather; 85 | } 86 | 87 | public void setWeather(int weather){ 88 | mWeather = weather; 89 | } 90 | 91 | public String getTitle(){ 92 | return mTitle; 93 | } 94 | 95 | public void setTitle(String title){ 96 | mTitle = title; 97 | } 98 | 99 | public String getContent(){ 100 | return mContent; 101 | } 102 | 103 | public void setContent(String content){ 104 | mContent = content; 105 | } 106 | 107 | public boolean getDisplay(){ 108 | return mDisplay; 109 | } 110 | 111 | public void setDisplay(boolean display){ 112 | mDisplay = display; 113 | } 114 | 115 | public Calendar getCreateTime(){ 116 | return mCreateTime; 117 | } 118 | 119 | public void setCreateTime(Calendar calendar){ 120 | mCreateTime = calendar; 121 | } 122 | 123 | public boolean getIsNew(){ 124 | return mIsNew; 125 | } 126 | 127 | public void setIsNew(boolean isNew){ 128 | mIsNew = isNew; 129 | } 130 | 131 | @Override 132 | public int describeContents() { 133 | return 0; 134 | } 135 | 136 | @Override 137 | public void writeToParcel(Parcel dest, int flags) { 138 | dest.writeLong(this.mIndex); 139 | dest.writeSerializable(this.mRecordTime); 140 | dest.writeInt(this.mWeather); 141 | dest.writeString(this.mTitle); 142 | dest.writeString(this.mContent); 143 | dest.writeByte(this.mDisplay ? (byte) 1 : (byte) 0); 144 | dest.writeSerializable(this.mCreateTime); 145 | dest.writeByte(this.mIsNew ? (byte) 1 : (byte) 0); 146 | } 147 | 148 | protected DailyRecord(Parcel in) { 149 | this.mIndex = in.readLong(); 150 | this.mRecordTime = (LunarCalendar) in.readSerializable(); 151 | this.mWeather = in.readInt(); 152 | this.mTitle = in.readString(); 153 | this.mContent = in.readString(); 154 | this.mDisplay = in.readByte() != 0; 155 | this.mCreateTime = (Calendar) in.readSerializable(); 156 | this.mIsNew = in.readByte() != 0; 157 | } 158 | 159 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { 160 | @Override 161 | public DailyRecord createFromParcel(Parcel source) { 162 | return new DailyRecord(source); 163 | } 164 | 165 | @Override 166 | public DailyRecord[] newArray(int size) { 167 | return new DailyRecord[size]; 168 | } 169 | }; 170 | } 171 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/RecordAdapter.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.RelativeLayout; 9 | import android.widget.TextView; 10 | 11 | import com.jjforever.wgj.maincalendar.Model.ICalendarRecord; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * Created by Wgj on 2016/8/29. 17 | * 记录适配器 18 | */ 19 | class RecordAdapter extends BaseAdapter { 20 | private Context context; 21 | private List list; 22 | // 是否显示日期,否则只显示时间 23 | private boolean mShowDate; 24 | 25 | RecordAdapter(Context context, boolean showDate, List list) { 26 | this.context = context; 27 | this.list = list; 28 | mShowDate = showDate; 29 | } 30 | 31 | @Override 32 | public int getCount() { 33 | if (list == null) { 34 | return 0; 35 | } 36 | return list.size(); 37 | } 38 | 39 | @Override 40 | public Object getItem(int position) { 41 | if (list == null) { 42 | return null; 43 | } 44 | return list.get(position); 45 | } 46 | 47 | /** 48 | * 删除指定位置的条目 49 | * @param position 指定的位置 50 | * @return 删除成功与否 51 | */ 52 | boolean removeItem(int position){ 53 | if (list == null){ 54 | return false; 55 | } 56 | if (position < 0 || position >= list.size()){ 57 | return false; 58 | } 59 | 60 | return list.remove(position) != null; 61 | } 62 | 63 | /** 64 | * 在指定位置更新记录信息 65 | * @param position 指定位置 66 | * @param record 记录信息 67 | * @return 是否成功 68 | */ 69 | boolean setItem(int position, ICalendarRecord record){ 70 | if (list == null){ 71 | return false; 72 | } 73 | 74 | return list.set(position, record) != null; 75 | } 76 | 77 | @Override 78 | public long getItemId(int position) { 79 | return position; 80 | } 81 | 82 | @Override 83 | public View getView(int position, View convertView, ViewGroup parent) { 84 | ViewHolder holder; 85 | if (convertView == null) { 86 | holder = new ViewHolder(); 87 | convertView = LayoutInflater.from(context).inflate( 88 | R.layout.item_time_line, parent, false); 89 | holder.date = (TextView) convertView 90 | .findViewById(R.id.record_date_time); 91 | holder.content = (TextView) convertView 92 | .findViewById(R.id.txt_date_content); 93 | holder.line = convertView.findViewById(R.id.record_line); 94 | holder.title = (RelativeLayout) convertView 95 | .findViewById(R.id.record_title); 96 | convertView.setTag(holder); 97 | } else { 98 | holder = (ViewHolder) convertView.getTag(); 99 | } 100 | //时间轴竖线的layout 101 | RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) holder.line.getLayoutParams(); 102 | //第一条数据,肯定显示时间标题 103 | if (position == 0) { 104 | holder.title.setVisibility(View.VISIBLE); 105 | holder.date.setText( 106 | list.get(position).getRecordTime().getTimeLineString(mShowDate)); 107 | params.addRule(RelativeLayout.ALIGN_TOP, R.id.record_title); 108 | params.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.txt_date_content); 109 | } else { // 不是第一条数据 110 | // 本条数据和上一条数据的时间戳相同,时间标题不显示 111 | if (list.get(position).getRecordTime() 112 | .equals(list.get(position - 1).getRecordTime())) { 113 | holder.title.setVisibility(View.GONE); 114 | params.addRule(RelativeLayout.ALIGN_TOP, R.id.txt_date_content); 115 | params.addRule(RelativeLayout.ALIGN_BOTTOM, 116 | R.id.txt_date_content); 117 | } else { 118 | //本条数据和上一条的数据的时间戳不同的时候,显示数据 119 | holder.title.setVisibility(View.VISIBLE); 120 | holder.date.setText( 121 | list.get(position).getRecordTime().getTimeLineString(mShowDate)); 122 | params.addRule(RelativeLayout.ALIGN_TOP, R.id.record_title); 123 | params.addRule(RelativeLayout.ALIGN_BOTTOM, 124 | R.id.txt_date_content); 125 | } 126 | } 127 | holder.line.setLayoutParams(params); 128 | holder.content.setText(list.get(position).getTitle()); 129 | return convertView; 130 | } 131 | 132 | @Override 133 | public boolean hasStableIds() { 134 | return true; 135 | } 136 | 137 | private static class ViewHolder { 138 | RelativeLayout title; 139 | View line; 140 | TextView date; 141 | TextView content; 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/util/Holiday.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.util; 2 | 3 | import com.jjforever.wgj.maincalendar.Model.ICalendarRecord; 4 | import com.jjforever.wgj.maincalendar.Model.LunarHoliday; 5 | import com.jjforever.wgj.maincalendar.Model.SolarHoliday; 6 | 7 | import java.util.ArrayList; 8 | import java.util.Calendar; 9 | 10 | /** 11 | * Created by Wgj on 2016/8/16. 12 | * 本类定义了一些常用的公历及农历节日 13 | * 不常用的就不做定义了。。。 14 | */ 15 | public final class Holiday { 16 | 17 | // 公历节日定义 18 | private static final String[] solarHolidays = { 19 | "元旦", "情人节", "妇女节", "植树节", "消费者权益日", "愚人节", 20 | "劳动节", "青年节", "儿童节", "建党节", "建军节", "教师节", 21 | "国庆节", "平安夜", "圣诞节", 22 | }; 23 | // 农历节日定义 24 | private static final String[] lunarHolidays = { 25 | "春节", "元宵节", "龙头节", "端午节", "七夕", "中元节", 26 | "中秋节", "重阳节", "腊八节", "北方小年", "南方小年", "除夕", 27 | }; 28 | private static final String[] weekHolidays = { 29 | "母亲节", "父亲节", "感恩节", 30 | }; 31 | 32 | // 阳历节日日期定义,第一个字节为月份 + 1,第二个字节为日期 33 | private static final byte[][] solarDate = { 34 | {1, 1}, {2, 14}, {3, 8}, {3, 12}, {3, 15}, {4, 1}, 35 | {5, 1}, {5, 4}, {6, 1}, {7, 1}, {8, 1}, {9, 10}, 36 | {10, 1}, {12, 24}, {12, 25} 37 | }; 38 | // 农历节日日期定义,第一个字节为农历月份,第二个为农历日期 除夕另外计算 39 | private static final byte[][] lunarDate = { 40 | {1, 1}, {1, 15}, {2, 2}, {5, 5}, {7, 7}, {7, 15}, 41 | {8, 15}, {9, 9}, {12, 8}, {12, 23}, {12, 24} 42 | }; 43 | // 根据星期定义的节日日期,第一个字节为月份+1,第二个为第几周, 44 | // 第三个为周几,Calendar中获取的数据 45 | private static final byte[][] weekDate = { 46 | // 周日为1 母亲节 5月的第二个星期日 47 | {5, 2, 1}, {6, 3, 1}, {11, 4, 5} 48 | }; 49 | 50 | /** 51 | * 根据日期获取阳历假日信息 52 | * @param date 日历信息 53 | * @return 如果有阳历假日信息返回对应字符串,没有返回null 54 | */ 55 | public static SolarHoliday getSolarHoliday(LunarCalendar date) 56 | { 57 | int month = date.get(Calendar.MONTH) + 1; 58 | int day = date.get(Calendar.DAY_OF_MONTH); 59 | 60 | for (int i = 0; i < solarDate.length; i++){ 61 | if (solarDate[i][0] == month && solarDate[i][1] == day){ 62 | return new SolarHoliday(solarHolidays[i]); 63 | } 64 | } 65 | 66 | return null; 67 | } 68 | 69 | /** 70 | * 根据日期获取农历假日信息 71 | * @param date 日历信息 72 | * @return 如果有农历假日信息则返回对应字符串,没有返回null 73 | */ 74 | public static LunarHoliday getLunarHoliday(LunarCalendar date) 75 | { 76 | int month = date.get(LunarCalendar.LUNAR_MONTH); 77 | int day = date.get(LunarCalendar.LUNAR_DATE); 78 | if (month < 0){ 79 | // 小于0为闰月,无节日 80 | return null; 81 | } 82 | 83 | for (int i = 0; i < lunarDate.length; i++){ 84 | if (lunarDate[i][0] == month && lunarDate[i][1] == day){ 85 | return new LunarHoliday(lunarHolidays[i]); 86 | } 87 | } 88 | 89 | // 计算除夕 90 | if (month == 12){ 91 | if (day == LunarCalendar.daysInLunarMonth(date.get(LunarCalendar.LUNAR_YEAR), month)){ 92 | // 12月的最后一天为除夕 93 | return new LunarHoliday(lunarHolidays[lunarHolidays.length - 1]); 94 | } 95 | } 96 | 97 | return null; 98 | } 99 | 100 | /** 101 | * 根据日期返回按星期计算的阳历节日 102 | * @param date 日历信息 103 | * @return 节日字符串 104 | */ 105 | public static SolarHoliday getWeekHoliday(LunarCalendar date) 106 | { 107 | int month = date.get(Calendar.MONTH) + 1; 108 | int week = date.get(Calendar.DAY_OF_WEEK); 109 | // 不能用WEEK_IN_MONTH获取 110 | int weekCount = date.get(Calendar.DAY_OF_WEEK_IN_MONTH); 111 | 112 | for (int i = 0; i < weekDate.length; i++){ 113 | if (month == weekDate[i][0] && weekCount == weekDate[i][1] 114 | && week == weekDate[i][2]){ 115 | return new SolarHoliday(weekHolidays[i]); 116 | } 117 | } 118 | 119 | return null; 120 | } 121 | 122 | /** 123 | * 根据日历信息获取节假日信息 124 | * @param date 日历信息 125 | * @return 节假日信息,多个使用/分割 126 | */ 127 | public static ArrayList getHolidays(LunarCalendar date) 128 | { 129 | ArrayList tmpLst = new ArrayList<>(); 130 | 131 | // 农历节日 132 | ICalendarRecord tmpRecord = getLunarHoliday(date); 133 | if (tmpRecord != null){ 134 | tmpLst.add(tmpRecord); 135 | } 136 | // 阳历节日 137 | tmpRecord = getSolarHoliday(date); 138 | if (tmpRecord != null){ 139 | tmpLst.add(tmpRecord); 140 | } 141 | // 星期节日 142 | tmpRecord = getWeekHoliday(date); 143 | if (tmpRecord != null){ 144 | tmpLst.add(tmpRecord); 145 | } 146 | 147 | // 没有则返回空 148 | return tmpLst.isEmpty() ? null : tmpLst; 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/common/popup/Popup.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.common.popup; 2 | 3 | import android.content.Context; 4 | import android.content.DialogInterface; 5 | import android.graphics.Color; 6 | import android.graphics.drawable.ColorDrawable; 7 | import android.support.annotation.CallSuper; 8 | import android.support.annotation.StyleRes; 9 | import android.view.Gravity; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.view.Window; 13 | import android.widget.FrameLayout; 14 | 15 | import com.jjforever.wgj.maincalendar.R; 16 | import com.jjforever.wgj.maincalendar.common.util.LogUtils; 17 | 18 | /** 19 | * 弹窗 20 | * 21 | * @author 李玉江[QQ :1023694760] 22 | * @version 2015 -10-19 23 | * @see android.widget.PopupWindow 24 | */ 25 | public class Popup { 26 | private android.app.Dialog dialog; 27 | private FrameLayout contentLayout; 28 | 29 | /** 30 | * Instantiates a new Popup. 31 | * 32 | * @param context the context 33 | */ 34 | public Popup(Context context) { 35 | init(context); 36 | } 37 | 38 | private void init(Context context) { 39 | contentLayout = new FrameLayout(context); 40 | contentLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); 41 | contentLayout.setFocusable(true); 42 | contentLayout.setFocusableInTouchMode(true); 43 | dialog = new android.app.Dialog(context); 44 | dialog.setCanceledOnTouchOutside(true);//触摸屏幕取消窗体 45 | dialog.setCancelable(true);//按返回键取消窗体 46 | Window window = dialog.getWindow(); 47 | window.setGravity(Gravity.BOTTOM);//位于屏幕底部 48 | window.setWindowAnimations(R.style.Animation_Popup); 49 | window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); 50 | //android.util.AndroidRuntimeException: requestFeature() must be called before adding content 51 | window.requestFeature(Window.FEATURE_NO_TITLE); 52 | window.setContentView(contentLayout); 53 | } 54 | 55 | /** 56 | * Gets context. 57 | * 58 | * @return the context 59 | */ 60 | public Context getContext() { 61 | return contentLayout.getContext(); 62 | } 63 | 64 | /** 65 | * Sets animation. 66 | * 67 | * @param animRes the anim res 68 | */ 69 | public void setAnimationStyle(@StyleRes int animRes) { 70 | Window window = dialog.getWindow(); 71 | window.setWindowAnimations(animRes); 72 | } 73 | 74 | /** 75 | * Is showing boolean. 76 | * 77 | * @return the boolean 78 | */ 79 | public boolean isShowing() { 80 | return dialog.isShowing(); 81 | } 82 | 83 | /** 84 | * Show. 85 | */ 86 | @CallSuper 87 | public void show() { 88 | dialog.show(); 89 | } 90 | 91 | /** 92 | * Dismiss. 93 | */ 94 | @CallSuper 95 | public void dismiss() { 96 | dialog.dismiss(); 97 | } 98 | 99 | /** 100 | * Sets content view. 101 | * 102 | * @param view the view 103 | */ 104 | public void setContentView(View view) { 105 | contentLayout.removeAllViews(); 106 | contentLayout.addView(view); 107 | } 108 | 109 | /** 110 | * Gets content view. 111 | * 112 | * @return the content view 113 | */ 114 | public View getContentView() { 115 | return contentLayout.getChildAt(0); 116 | } 117 | 118 | /** 119 | * Sets size. 120 | * 121 | * @param width the width 122 | * @param height the height 123 | */ 124 | public void setSize(int width, int height) { 125 | LogUtils.debug(String.format("will set popup width/height to: %s/%s", width, height)); 126 | ViewGroup.LayoutParams params = contentLayout.getLayoutParams(); 127 | if (params == null) { 128 | params = new ViewGroup.LayoutParams(width, height); 129 | } else { 130 | params.width = width; 131 | params.height = height; 132 | } 133 | contentLayout.setLayoutParams(params); 134 | } 135 | 136 | /** 137 | * Sets on dismiss listener. 138 | * 139 | * @param onDismissListener the on dismiss listener 140 | */ 141 | public void setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) { 142 | dialog.setOnDismissListener(onDismissListener); 143 | } 144 | 145 | /** 146 | * Sets on key listener. 147 | * 148 | * @param onKeyListener the on key listener 149 | */ 150 | public void setOnKeyListener(DialogInterface.OnKeyListener onKeyListener) { 151 | dialog.setOnKeyListener(onKeyListener); 152 | } 153 | 154 | /** 155 | * Gets window. 156 | * 157 | * @return the window 158 | */ 159 | public Window getWindow() { 160 | return dialog.getWindow(); 161 | } 162 | 163 | /** 164 | * Gets root view. 165 | * 166 | * @return the root view 167 | */ 168 | public ViewGroup getRootView() { 169 | return contentLayout; 170 | } 171 | 172 | } 173 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/AlarmAdapter.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.BaseAdapter; 9 | import android.widget.CompoundButton; 10 | import android.widget.LinearLayout; 11 | import android.widget.RelativeLayout; 12 | import android.widget.TextView; 13 | import android.widget.Toast; 14 | import android.widget.ToggleButton; 15 | 16 | import com.jjforever.wgj.maincalendar.BLL.AlarmRecordMng; 17 | import com.jjforever.wgj.maincalendar.Model.AlarmRecord; 18 | import com.jjforever.wgj.maincalendar.monthui.SwitchButton; 19 | import com.jjforever.wgj.maincalendar.services.CalendarService; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * Created by Wgj on 2016/9/19. 25 | * 闹钟记录适配器 26 | */ 27 | public class AlarmAdapter extends BaseAdapter { 28 | private Context context; 29 | private List list; 30 | 31 | public AlarmAdapter(Context context, List list) { 32 | this.context = context; 33 | this.list = list; 34 | } 35 | 36 | @Override 37 | public int getCount() { 38 | if (list == null) { 39 | return 0; 40 | } 41 | return list.size(); 42 | } 43 | 44 | @Override 45 | public Object getItem(int position) { 46 | if (list == null) { 47 | return null; 48 | } 49 | return list.get(position); 50 | } 51 | 52 | /** 53 | * 删除指定位置的条目 54 | * @param position 指定的位置 55 | * @return 删除成功与否 56 | */ 57 | // public boolean removeItem(int position){ 58 | // if (list == null){ 59 | // return false; 60 | // } 61 | // if (position < 0 || position >= list.size()){ 62 | // return false; 63 | // } 64 | // 65 | // return list.remove(position) != null; 66 | // } 67 | 68 | /** 69 | * 在指定位置更新记录信息 70 | * @param position 指定位置 71 | * @param record 记录信息 72 | * @return 是否成功 73 | */ 74 | // public boolean setItem(int position, AlarmRecord record){ 75 | // if (list == null){ 76 | // return false; 77 | // } 78 | // 79 | // return list.set(position, record) != null; 80 | // } 81 | 82 | /** 83 | * 获取Item的索引 84 | * @param position 位置 85 | * @return 索引 86 | */ 87 | @Override 88 | public long getItemId(int position) { 89 | return position; 90 | } 91 | 92 | @Override 93 | public View getView(int position, View convertView, ViewGroup parent) { 94 | AlarmViewHolder holder; 95 | if (convertView == null) { 96 | holder = new AlarmViewHolder(); 97 | convertView = LayoutInflater.from(context).inflate( 98 | R.layout.alarm_record_item, parent, false); 99 | holder.title = (TextView) convertView 100 | .findViewById(R.id.record_date_time); 101 | holder.content = (TextView) convertView 102 | .findViewById(R.id.txt_date_content); 103 | holder.button = (ToggleButton) convertView.findViewById(R.id.pause_button); 104 | holder.layout = (LinearLayout) convertView 105 | .findViewById(R.id.record_title); 106 | convertView.setTag(holder); 107 | } else { 108 | holder = (AlarmViewHolder) convertView.getTag(); 109 | } 110 | 111 | // 根据位置获取闹钟记录 112 | final AlarmRecord tmpRecord = list.get(position); 113 | holder.title.setText(String.format("%s %s", tmpRecord.getDateString(), tmpRecord.getAlarmTime().toString())); 114 | holder.content.setText(list.get(position).getOnlyTitle()); 115 | holder.button.setChecked(!tmpRecord.getPause()); 116 | 117 | holder.button.setOnClickListener(new View.OnClickListener() { 118 | @Override 119 | public void onClick(View v) { 120 | boolean isChecked = ((ToggleButton)v).isChecked(); 121 | if (isChecked != tmpRecord.getPause()){ 122 | return; 123 | } 124 | tmpRecord.setPause(!isChecked); 125 | if (AlarmRecordMng.update(tmpRecord)){ 126 | context.startService(new Intent(context, CalendarService.class)); 127 | Toast.makeText(context, 128 | tmpRecord.getOnlyTitle() + context.getResources().getString(isChecked ? R.string.no_pause : R.string.is_pause), 129 | Toast.LENGTH_SHORT).show(); 130 | } 131 | else{ 132 | tmpRecord.setPause(isChecked); 133 | } 134 | } 135 | }); 136 | 137 | return convertView; 138 | } 139 | 140 | @Override 141 | public boolean hasStableIds() { 142 | return true; 143 | } 144 | 145 | private static class AlarmViewHolder { 146 | LinearLayout layout; 147 | ToggleButton button; 148 | TextView title; 149 | TextView content; 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_add_shifts_work.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 17 | 18 | 35 | 36 | 45 | 55 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 87 | 97 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_add_daily.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 19 | 20 | 24 | 25 | 35 | 36 | 47 | 48 | 49 | 54 | 55 | 64 | 65 | 73 | 74 | 75 | 91 | 92 | 109 | 110 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/wheelpicker/picker/OptionPicker.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.wheelpicker.picker; 2 | 3 | import android.app.Activity; 4 | import android.support.annotation.NonNull; 5 | import android.text.TextUtils; 6 | import android.view.Gravity; 7 | import android.view.View; 8 | import android.widget.LinearLayout; 9 | import android.widget.TextView; 10 | 11 | import java.util.ArrayList; 12 | import java.util.Arrays; 13 | 14 | import com.jjforever.wgj.maincalendar.wheelpicker.widget.WheelView; 15 | 16 | /** 17 | * 单项选择器 18 | * 19 | * @author 李玉江[QQ :1032694760] 20 | * @version 2015 /9/29 21 | */ 22 | public class OptionPicker extends WheelPicker { 23 | /** 24 | * The Options. 25 | */ 26 | protected ArrayList options = new ArrayList(); 27 | private OnOptionPickListener onOptionPickListener; 28 | private OnOptionIndexPickListener onOptionIndexPickListener; 29 | private String selectedOption = ""; 30 | private int mSelectedIndex = 0; 31 | private String label = ""; 32 | 33 | /** 34 | * Instantiates a new Option picker. 35 | * 36 | * @param activity the activity 37 | * @param options the options 38 | */ 39 | public OptionPicker(Activity activity, String[] options) { 40 | super(activity); 41 | this.options.addAll(Arrays.asList(options)); 42 | } 43 | 44 | /** 45 | * Sets label. 46 | * 47 | * @param label the label 48 | */ 49 | public void setLabel(String label) { 50 | this.label = label; 51 | } 52 | 53 | /** 54 | * Sets selected index. 55 | * 56 | * @param index the index 57 | */ 58 | public void setSelectedIndex(int index) { 59 | for (int i = 0; i < options.size(); i++) { 60 | if (index == i) { 61 | selectedOption = options.get(index); 62 | mSelectedIndex = i; 63 | break; 64 | } 65 | } 66 | } 67 | 68 | /** 69 | * Sets selected item. 70 | * 71 | * @param option the option 72 | */ 73 | public void setSelectedItem(String option) { 74 | selectedOption = option; 75 | } 76 | 77 | /** 78 | * Sets on option pick listener. 79 | * 80 | * @param listener the listener 81 | */ 82 | public void setOnOptionPickListener(OnOptionPickListener listener) { 83 | this.onOptionPickListener = listener; 84 | } 85 | 86 | public void setOnOptionIndexPickListener(OnOptionIndexPickListener listener){ 87 | this.onOptionIndexPickListener = listener; 88 | } 89 | 90 | @Override 91 | @NonNull 92 | protected View makeCenterView() { 93 | if (options.size() == 0) { 94 | throw new IllegalArgumentException("please initial options at first, can't be empty"); 95 | } 96 | LinearLayout layout = new LinearLayout(activity); 97 | layout.setOrientation(LinearLayout.HORIZONTAL); 98 | layout.setGravity(Gravity.CENTER); 99 | WheelView optionView = new WheelView(activity); 100 | optionView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); 101 | optionView.setTextSize(textSize); 102 | optionView.setTextColor(textColorNormal, textColorFocus); 103 | optionView.setLineVisible(lineVisible); 104 | optionView.setLineColor(lineColor); 105 | optionView.setOffset(offset); 106 | layout.addView(optionView); 107 | TextView labelView = new TextView(activity); 108 | labelView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); 109 | labelView.setTextColor(textColorFocus); 110 | labelView.setTextSize(textSize); 111 | layout.addView(labelView); 112 | if (!TextUtils.isEmpty(label)) { 113 | labelView.setText(label); 114 | } 115 | if (TextUtils.isEmpty(selectedOption)) { 116 | optionView.setItems(options); 117 | } else { 118 | optionView.setItems(options, selectedOption); 119 | } 120 | optionView.setOnWheelViewListener(new WheelView.OnWheelViewListener() { 121 | @Override 122 | public void onSelected(boolean isUserScroll, int selectedIndex, String item) { 123 | selectedOption = item; 124 | mSelectedIndex = selectedIndex; 125 | } 126 | }); 127 | return layout; 128 | } 129 | 130 | @Override 131 | public void onSubmit() { 132 | if (onOptionPickListener != null) { 133 | onOptionPickListener.onOptionPicked(selectedOption); 134 | } 135 | if (onOptionIndexPickListener != null){ 136 | onOptionIndexPickListener.onOptionPicked(mSelectedIndex); 137 | } 138 | } 139 | 140 | /** 141 | * Gets selected option. 142 | * 143 | * @return the selected option 144 | */ 145 | public String getSelectedOption() { 146 | return selectedOption; 147 | } 148 | 149 | /** 150 | * The interface On option pick listener. 151 | */ 152 | public interface OnOptionPickListener { 153 | 154 | /** 155 | * On option picked. 156 | * 157 | * @param option the option 158 | */ 159 | void onOptionPicked(String option); 160 | 161 | } 162 | 163 | public interface OnOptionIndexPickListener{ 164 | 165 | void onOptionPicked(int index); 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /app/src/main/java/com/jjforever/wgj/maincalendar/toolbar/ToolBarActivity.java: -------------------------------------------------------------------------------- 1 | package com.jjforever.wgj.maincalendar.toolbar; 2 | 3 | import android.os.Build; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.Toolbar; 7 | import android.view.MenuItem; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.view.Window; 11 | import android.widget.ImageView; 12 | import android.widget.TextView; 13 | 14 | import com.jjforever.wgj.maincalendar.R; 15 | import com.jjforever.wgj.maincalendar.monthui.ThemeStyle; 16 | import com.jjforever.wgj.maincalendar.util.Helper; 17 | 18 | /** 19 | * Created by Wgj on 2016/8/20. 20 | * 带工具栏的活动 21 | */ 22 | public abstract class ToolBarActivity extends AppCompatActivity implements View.OnClickListener { 23 | // 工具栏 24 | public Toolbar mToolbar; 25 | // 标题控件 26 | private TextView mTitleView; 27 | // 确定按钮控件 28 | private ImageView mOkView; 29 | // 删除按钮 30 | private ImageView mDeleteView; 31 | // 标题字符串 32 | //private CharSequence mTitle; 33 | 34 | @Override 35 | protected void onCreate(Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | supportRequestWindowFeature(Window.FEATURE_NO_TITLE); 38 | 39 | ViewGroup contentFrameLayout = (ViewGroup) findViewById(Window.ID_ANDROID_CONTENT); 40 | if (contentFrameLayout != null) { 41 | View parentView = contentFrameLayout.getChildAt(0); 42 | if (parentView != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { 43 | parentView.setFitsSystemWindows(true); 44 | } 45 | } 46 | } 47 | 48 | @Override 49 | public void setContentView(int layoutResID) { 50 | int statusHeight = Helper.getStatusHeight(this); 51 | ToolBarHelper mToolBarHelper = new ToolBarHelper(this,layoutResID); 52 | mToolbar = mToolBarHelper.getToolBar(); 53 | mToolbar.getLayoutParams().height += statusHeight; 54 | mToolbar.setPadding(mToolbar.getPaddingLeft(), statusHeight, mToolbar.getPaddingRight(), mToolbar.getPaddingBottom()); 55 | setToolbarBack(ThemeStyle.Primary); 56 | setContentView(mToolBarHelper.getContentView()); 57 | /*把 mToolbar 设置到Activity 中*/ 58 | setSupportActionBar(mToolbar); 59 | /*自定义的一些操作*/ 60 | onCreateCustomToolBar(mToolbar); 61 | mTitleView = (TextView) this.findViewById(R.id.toolbar_title); 62 | mOkView = (ImageView) this.findViewById(R.id.toolbar_ok_btn); 63 | if (mOkView != null){ 64 | mOkView.getLayoutParams().height = mOkView.getLayoutParams().width / 3; 65 | mOkView.setOnClickListener(this); 66 | } 67 | mDeleteView = (ImageView) this.findViewById(R.id.toolbar_delete_btn); 68 | if (mDeleteView != null){ 69 | mDeleteView.getLayoutParams().height = mDeleteView.getLayoutParams().width / 3; 70 | mDeleteView.setOnClickListener(this); 71 | } 72 | } 73 | 74 | public void onCreateCustomToolBar(Toolbar toolbar){ 75 | toolbar.setContentInsetsRelative(0,0); 76 | getLayoutInflater().inflate(R.layout.toolbar_button, toolbar); 77 | } 78 | 79 | /** 80 | * 设置标题 81 | * @param title 标题字符串 82 | */ 83 | public void setTitle(CharSequence title) 84 | { 85 | //this.mTitle = title; 86 | if (mTitleView != null) { 87 | mTitleView.setText(title); 88 | } 89 | } 90 | 91 | /** 92 | * 设置工具栏背景色 93 | * @param color 背景色 94 | */ 95 | public void setToolbarBack(int color){ 96 | mToolbar.setBackgroundColor(color); 97 | } 98 | 99 | @Override 100 | public boolean onOptionsItemSelected(MenuItem item) { 101 | if (item.getItemId() == android.R.id.home){ 102 | finish(); 103 | return true; 104 | } 105 | return super.onOptionsItemSelected(item); 106 | } 107 | 108 | /** 109 | * 显示或者隐藏确定按钮 110 | * @param show 是否显示 111 | */ 112 | protected void showOkBtn(boolean show){ 113 | if (mOkView != null){ 114 | mOkView.setVisibility(show ? View.VISIBLE : View.GONE); 115 | } 116 | } 117 | 118 | /** 119 | * 显示或隐藏删除按钮 120 | * @param show 是否显示 121 | */ 122 | protected void showDeleteBtn(boolean show){ 123 | if (mDeleteView != null){ 124 | mDeleteView.setVisibility(show ? View.VISIBLE : View.GONE); 125 | } 126 | } 127 | 128 | /** 129 | * 设置OK按钮图标 130 | * @param resId 要设置的按钮图标资源 131 | */ 132 | protected void setOkBtnImage(int resId){ 133 | if (mOkView != null){ 134 | mOkView.setImageResource(resId); 135 | } 136 | } 137 | 138 | @Override 139 | public void onClick(View v) { 140 | switch (v.getId()) { 141 | case R.id.toolbar_ok_btn: 142 | // 确定按钮 143 | onOKButtonClick(); 144 | break; 145 | 146 | case R.id.toolbar_delete_btn: 147 | // 删除按钮 148 | onDeleteButtonClick(); 149 | break; 150 | 151 | default: 152 | break; 153 | } 154 | } 155 | 156 | /** 157 | * 按下确定按钮触发事件,需在子类中重写 158 | */ 159 | public void onOKButtonClick(){ 160 | 161 | } 162 | 163 | /** 164 | * 按下删除按钮触发事件,需在子类中重写 165 | */ 166 | public void onDeleteButtonClick(){ 167 | 168 | } 169 | 170 | @Override 171 | public void finish() 172 | { 173 | super.finish(); 174 | overridePendingTransition(R.anim.slide_in_left,R.anim.slide_out_right); 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /app/src/main/res/layout-land/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 25 | 29 | 30 | 35 | 36 | 38 | 42 | 46 | 50 | 54 | 58 | 62 | 66 | 67 | 68 | 72 | 73 | 79 | 80 | 81 | 89 | 95 | 99 | 100 | 109 | 113 | 114 | 115 | 123 | 124 | 125 | 126 | 127 | --------------------------------------------------------------------------------