├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── libs │ └── Toolkit-1.1.aar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── allever │ │ └── daymatter │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── litepal.xml │ ├── java │ │ └── com │ │ │ └── allever │ │ │ └── daymatter │ │ │ ├── MainActivity.java │ │ │ ├── MyApp.kt │ │ │ ├── ad │ │ │ ├── AdConstants.kt │ │ │ └── AdFactory.kt │ │ │ ├── bean │ │ │ ├── ItemDayMatter.java │ │ │ └── ItemSlidMenuSort.java │ │ │ ├── data │ │ │ ├── Config.java │ │ │ ├── DataListener.java │ │ │ ├── DataSource.java │ │ │ ├── Event.java │ │ │ └── Repository.java │ │ │ ├── event │ │ │ ├── Event.kt │ │ │ ├── EventDayMatter.java │ │ │ └── SortEvent.kt │ │ │ ├── mvp │ │ │ ├── BaseActivity.java │ │ │ ├── BaseFragment.java │ │ │ ├── BasePresenter.java │ │ │ ├── presenter │ │ │ │ ├── AboutPresenter.kt │ │ │ │ ├── DateCalcPresenter.java │ │ │ │ ├── DayMatterDetailFgPresenter.java │ │ │ │ ├── DayMatterDetailPresenter.java │ │ │ │ ├── DayMatterListPresenter.java │ │ │ │ ├── EditDayMatterPresenter.java │ │ │ │ ├── MainActivityPresenter.java │ │ │ │ ├── ModifyDayMatterPresenter.java │ │ │ │ ├── SelectSortPresenter.java │ │ │ │ ├── SettingPresenter.java │ │ │ │ └── SortListPresenter.kt │ │ │ └── view │ │ │ │ ├── IAboutView.kt │ │ │ │ ├── IAddDayMatterView.java │ │ │ │ ├── IDateCalcView.java │ │ │ │ ├── IDayMatterDetailFgView.java │ │ │ │ ├── IDayMatterDetailView.java │ │ │ │ ├── IDayMatterListView.java │ │ │ │ ├── IMainActivityView.java │ │ │ │ ├── IModifyDayMatterView.java │ │ │ │ ├── ISelectSortView.java │ │ │ │ ├── ISettingView.java │ │ │ │ └── ISortListView.kt │ │ │ ├── receiver │ │ │ ├── BeforeAlarmReceiver.java │ │ │ └── CurrentAlarmReceiver.java │ │ │ ├── ui │ │ │ ├── AboutActivity.kt │ │ │ ├── DateCalcFragment.java │ │ │ ├── DayMatterDetailActivity.java │ │ │ ├── DayMatterDetailFragment.java │ │ │ ├── DayMatterListFragment.java │ │ │ ├── EditDayMatterActivity.java │ │ │ ├── ModifyDayMatterActivity.java │ │ │ ├── SelectSortActivity.java │ │ │ ├── SettingFragment.java │ │ │ ├── SortFragment.kt │ │ │ ├── SortListActivity.kt │ │ │ ├── TabModel.kt │ │ │ ├── adapter │ │ │ │ ├── DayMatterListAdapter.java │ │ │ │ ├── DialogSortAdapter.kt │ │ │ │ ├── SlidMenuSortAdapter.java │ │ │ │ ├── SortAdapter.kt │ │ │ │ └── ViewPagerAdapter.java │ │ │ ├── dialog │ │ │ │ ├── DialogHelper.kt │ │ │ │ ├── RepeatTypeDialog.java │ │ │ │ └── SortDialog.java │ │ │ └── widget │ │ │ │ └── tab │ │ │ │ ├── AnimationUtils.java │ │ │ │ ├── TabItem.java │ │ │ │ ├── TabLayout.java │ │ │ │ ├── ThemeUtils.java │ │ │ │ ├── ValueAnimatorCompat.java │ │ │ │ ├── ValueAnimatorCompatImplEclairMr1.java │ │ │ │ ├── ValueAnimatorCompatImplHoneycombMr1.java │ │ │ │ ├── ViewUtils.java │ │ │ │ └── ViewUtilsLollipop.java │ │ │ └── utils │ │ │ ├── ActivityController.kt │ │ │ ├── CommonHalper.kt │ │ │ ├── Constants.java │ │ │ ├── DateUtils.java │ │ │ ├── DisplayUtil.kt │ │ │ ├── LogUtil.kt │ │ │ ├── RemindUtils.java │ │ │ ├── SPUtils.java │ │ │ ├── SpUtil.kt │ │ │ ├── SystemUtils.kt │ │ │ ├── TimeUtils.kt │ │ │ └── ToastUtil.kt │ └── res │ │ ├── drawable-xxhdpi │ │ ├── ic_about.png │ │ ├── ic_add_white_24dp.png │ │ ├── ic_arrow_back_white_24dp.png │ │ ├── ic_arrow_down.png │ │ ├── ic_calc.png │ │ ├── ic_drawer_calculate.png │ │ ├── ic_drawer_date.png │ │ ├── ic_drawer_menu.png │ │ ├── ic_drawer_more.png │ │ ├── ic_edit_title.png │ │ ├── ic_edit_white_24dp.png │ │ ├── ic_feedback.png │ │ ├── ic_google_play_privacy.png │ │ ├── ic_list_settings_line.png │ │ ├── ic_list_style.png │ │ ├── ic_logo.png │ │ ├── ic_matter.png │ │ ├── ic_setting.png │ │ ├── ic_share_white.png │ │ ├── ic_sort.png │ │ └── icon_back.png │ │ ├── drawable │ │ ├── days_bg_round.xml │ │ ├── days_bg_round_gray.xml │ │ ├── ic_launcher_background.xml │ │ └── slid_sort_tv_count_bg.xml │ │ ├── layout │ │ ├── activity_about.xml │ │ ├── activity_add_day_matter.xml │ │ ├── activity_day_matter_detail.xml │ │ ├── activity_main.xml │ │ ├── activity_modify_day_matter.xml │ │ ├── activity_select_sort.xml │ │ ├── activity_sort_list.xml │ │ ├── dialog_repeat_type.xml │ │ ├── dialog_select_sort.xml │ │ ├── dialog_sort.xml │ │ ├── fragment_date_calc.xml │ │ ├── fragment_day_matter_detail.xml │ │ ├── fragment_day_matter_list.xml │ │ ├── fragment_remind.xml │ │ ├── header_main_slide.xml │ │ ├── include_toolbar.xml │ │ ├── include_top_bar.xml │ │ ├── input_day_matter.xml │ │ ├── item_dialog_sort.xml │ │ ├── item_list_day_matter.xml │ │ ├── item_slid_menu_sort.xml │ │ ├── item_sort.xml │ │ ├── layout_alert_dialog.xml │ │ ├── layout_bottom_tab.xml │ │ └── layout_divider.xml │ │ ├── menu │ │ ├── menu_day_matter_detail.xml │ │ └── menu_main.xml │ │ ├── mipmap │ │ └── ic_launcher.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── allever │ └── daymatter │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | /.idea 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | /app/release 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 倒计时 2 | 3 | 这是一款记录重要日子的倒计时工具,重要内容包括:增加事件,分类,倒计时天数,日历计算器,提醒 4 | 5 | 6 | - 事件管理 7 | - 新增事件 8 | - 修改事件 9 | - 删除事件 10 | - 分类管理 11 | - 创建分类 12 | - 删除分类 13 | - 修改分类 14 | - 日历计算器 15 | - 提醒 16 | - 当前提醒 17 | - 前天提醒 -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android-extensions' 3 | apply plugin: 'kotlin-android' 4 | 5 | android { 6 | compileSdkVersion 28 7 | defaultConfig { 8 | applicationId "org.xm.app.daymatter" 9 | minSdkVersion 16 10 | targetSdkVersion 28 11 | versionCode 1 12 | versionName "1.0" 13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 14 | multiDexEnabled true 15 | 16 | //默认渠道为官网 17 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "offical"] 18 | 19 | //在Manifest.xml中使用的值 20 | manifestPlaceholders += [ 21 | ADMOB_APP_ID: rootProject.ext.admobAppId 22 | ] 23 | 24 | } 25 | 26 | //友盟多渠道 27 | flavorDimensions "mark" 28 | productFlavors { 29 | ad {} 30 | // google {} 31 | // xiaomi {} 32 | // baidu {} 33 | } 34 | 35 | productFlavors.all { 36 | flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name] 37 | } 38 | 39 | //解决butterknife编译异常 40 | //Failed to transform artifact 'butterknife-runtime.aar (com.jakewharton:butterknife-runtime:10.1.0)' to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=19} 41 | compileOptions { 42 | sourceCompatibility JavaVersion.VERSION_1_8 43 | targetCompatibility JavaVersion.VERSION_1_8 44 | } 45 | 46 | signingConfigs { 47 | release { 48 | storeFile file("${rootProject.ext.signingStoreFile}") 49 | storePassword "${rootProject.ext.signingStorePassword}" 50 | keyAlias "${rootProject.ext.signingKeyAlias}" 51 | keyPassword "${rootProject.ext.signingKeyPassword}" 52 | } 53 | } 54 | 55 | buildTypes { 56 | release { 57 | minifyEnabled true 58 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 59 | signingConfig signingConfigs.release 60 | } 61 | } 62 | 63 | 64 | 65 | applicationVariants.all { 66 | variant -> 67 | if (variant.buildType.name.equals('release')) { 68 | variant.outputs.each { output -> 69 | def outputFile = output.outputFile 70 | if (outputFile != null && outputFile.name.endsWith('.apk')) { 71 | def fileName = "${defaultConfig.applicationId}_(Release)_V${defaultConfig.versionName}_C${defaultConfig.versionCode}_(Build${releaseTime()}).apk" 72 | output.outputFileName = new File(fileName) 73 | //com.tcqmt.xiaoxue_(Release)_V1.0_C1_(Build201905070905).apk 74 | } 75 | } 76 | } 77 | } 78 | } 79 | 80 | 81 | def releaseTime() { 82 | return new Date().format("yyyyMMddHHmm", TimeZone.getTimeZone("Asia/Chongqing")) 83 | } 84 | 85 | //引入aar包需加 86 | repositories { 87 | flatDir { 88 | dirs 'libs' 89 | } 90 | } 91 | 92 | dependencies { 93 | implementation fileTree(dir: 'libs', include: ['*.jar']) 94 | implementation 'androidx.appcompat:appcompat:1.0.2' 95 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 96 | testImplementation 'junit:junit:4.12' 97 | androidTestImplementation 'androidx.test:runner:1.2.0' 98 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 99 | 100 | implementation 'androidx.recyclerview:recyclerview:1.0.0' 101 | implementation 'com.google.android.material:material:1.0.0' 102 | implementation 'androidx.cardview:cardview:1.0.0' 103 | //Butterknife 104 | implementation 'com.jakewharton:butterknife:10.1.0' 105 | annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0' 106 | //消息事件 107 | implementation 'org.greenrobot:eventbus:3.1.1' 108 | //数据库 109 | implementation 'org.litepal.android:core:1.6.1' 110 | //EventBus 111 | implementation 'org.greenrobot:eventbus:3.1.1' 112 | //Rx 113 | implementation 'io.reactivex.rxjava2:rxandroid:2.0.2' 114 | implementation 'io.reactivex.rxjava2:rxjava:2.2.6' 115 | //Quick Recycler Adapter 116 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.40' 117 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 118 | 119 | //功能性RecyclerView 120 | implementation ('com.yanzhenjie.recyclerview:support:1.3.2') { 121 | exclude group: 'com.android.support', module: 'recyclerview-v7' 122 | } 123 | 124 | 125 | //local 126 | implementation project(':permission') 127 | implementation project(':common') 128 | implementation project(':umeng') 129 | implementation project(':admob') 130 | implementation(name: "Toolkit-1.1", ext: 'aar') 131 | 132 | } 133 | repositories { 134 | mavenCentral() 135 | } 136 | -------------------------------------------------------------------------------- /app/libs/Toolkit-1.1.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/libs/Toolkit-1.1.aar -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | 23 | #友盟----------------------------------------------------------------------------------------------- 24 | #SDK需要引用导入工程的资源文件,通过了反射机制得到资源引用文件R.java, 25 | #但是在开发者通过proguard等混淆/优化工具处理apk时,proguard可能会将R.java删除, 26 | #如果遇到这个问题,请添加如下配置: 27 | -keep public class [com.allever.daymatter].R$*{ 28 | public static final int *; 29 | } 30 | 31 | #LitePal------------------------------------------------------------------------------------------- 32 | -keep class org.litepal.** { 33 | *; 34 | } 35 | 36 | -keep class * extends org.litepal.crud.DataSupport { 37 | *; 38 | } 39 | 40 | -keep class * extends org.litepal.crud.LitePalSupport { 41 | *; 42 | } 43 | # litepal要加这两句 44 | -keep class org.**{ *; } 45 | -keep class com.allever.daymatter.data.** {*;} 46 | 47 | #BaseRecyclerViewAdapterHelper--------------------------------------------------------------------- 48 | -keep class com.chad.library.adapter.** { 49 | *; 50 | } 51 | -keep public class * extends com.chad.library.adapter.base.BaseQuickAdapter 52 | -keep public class * extends com.chad.library.adapter.base.BaseViewHolder 53 | -keepclassmembers class **$** extends com.chad.library.adapter.base.BaseViewHolder { 54 | (...); 55 | } 56 | 57 | #EventBus---------------------------------------------------------------------------------------- 58 | -keepattributes *Annotation* 59 | -keepclassmembers class * { 60 | @org.greenrobot.eventbus.Subscribe ; 61 | } 62 | -keep enum org.greenrobot.eventbus.ThreadMode { *; } 63 | 64 | # Only required if you use AsyncExecutor 65 | -keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent { 66 | (java.lang.Throwable); 67 | } 68 | 69 | 70 | # ADMOB----------------------------------------------------------------------- 71 | # For Google Play Services 72 | -keep public class com.google.android.gms.ads.**{ 73 | public *; 74 | } 75 | 76 | # For old ads classes 77 | -keep public class com.google.ads.**{ 78 | public *; 79 | } 80 | 81 | # For mediation 82 | -keepattributes *Annotation* 83 | 84 | # Other required classes for Google Play Services 85 | # Read more at http://developer.android.com/google/play-services/setup.html 86 | -keep class * extends java.util.ListResourceBundle { 87 | protected Object[][] getContents(); 88 | } 89 | 90 | -keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { 91 | public static final *** NULL; 92 | } 93 | 94 | -keepnames @com.google.android.gms.common.annotation.KeepName class * 95 | -keepclassmembernames class * { 96 | @com.google.android.gms.common.annotation.KeepName *; 97 | } 98 | 99 | -keepnames class * implements android.os.Parcelable { 100 | public static final ** CREATOR; 101 | } 102 | 103 | # ADMOB----------------------------------------------------------------------- 104 | 105 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/allever/daymatter/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter; 2 | 3 | import android.content.Context; 4 | import androidx.test.InstrumentationRegistry; 5 | import androidx.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.zf.daymatter", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 26 | 28 | 30 | 32 | 34 | 35 | 38 | 41 | 42 | 43 | 46 | 49 | 50 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /app/src/main/assets/litepal.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/MyApp.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter 2 | 3 | import com.allever.daymatter.ad.AdConstants 4 | import com.allever.daymatter.ad.AdFactory 5 | import com.allever.lib.ad.chain.AdChainHelper 6 | import com.allever.lib.common.app.App 7 | import com.allever.lib.umeng.UMeng 8 | 9 | import org.litepal.LitePal 10 | 11 | /** 12 | * Created by Allever on 18/5/21. 13 | */ 14 | 15 | class MyApp : App(){ 16 | override fun onCreate() { 17 | super.onCreate() 18 | context = this 19 | LitePal.initialize(this) 20 | UMeng.init(this) 21 | AdChainHelper.init(this, AdConstants.adData, AdFactory()) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ad/AdConstants.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.ad 2 | 3 | import com.allever.lib.ad.ADType 4 | import com.allever.lib.ad.AdBusiness 5 | 6 | object AdConstants { 7 | 8 | val AD_NAME_INSERT = "AD_NAME_INSERT" 9 | 10 | 11 | val AD_NAME_BANNER = "AD_NAME_BANNER" 12 | 13 | 14 | val AD_NAME_VIDEO = "AD_NAME_VIDEO" 15 | 16 | val adData = "{\n" + 17 | " \"business\": [\n" + 18 | " {\n" + 19 | " \"name\": \"${AdBusiness.A}\",\n" + 20 | " \"appId\": \"\",\n" + 21 | " \"appKey\": \"\",\n" + 22 | " \"token\": \"\"\n" + 23 | " }\n" + 24 | " ],\n" + 25 | " \"adConfig\": [\n" + 26 | " {\n" + 27 | " \"name\": \"$AD_NAME_INSERT\",\n" + 28 | " \"type\": \"${ADType.INSERT}\",\n" + 29 | " \"chain\": [\n" + 30 | " {\n" + 31 | " \"business\": \"${AdBusiness.A}\",\n" + 32 | " \"adPosition\": \"ca-app-pub-8815582923430605/4136486096\"\n" + 33 | " }\n" + 34 | " ]\n" + 35 | " },\n" + 36 | " {\n" + 37 | " \"name\": \"$AD_NAME_BANNER\",\n" + 38 | " \"type\": \"${ADType.BANNER}\",\n" + 39 | " \"chain\": [\n" + 40 | " {\n" + 41 | " \"business\": \"${AdBusiness.A}\",\n" + 42 | " \"adPosition\": \"ca-app-pub-8815582923430605/5449567767\"\n" + 43 | " }\n" + 44 | " ]\n" + 45 | " },\n" + 46 | " {\n" + 47 | " \"name\": \"$AD_NAME_VIDEO\",\n" + 48 | " \"type\": \"${ADType.VIDEO}\",\n" + 49 | " \"chain\": [\n" + 50 | " {\n" + 51 | " \"business\": \"${AdBusiness.A}\",\n" + 52 | " \"adPosition\": \"ca-app-pub-8815582923430605/1510322757\"\n" + 53 | " }\n" + 54 | " ]\n" + 55 | " }\n" + 56 | " ]\n" + 57 | "}\n" 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ad/AdFactory.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.ad 2 | 3 | import com.allever.lib.ad.AdBusiness 4 | import com.allever.lib.ad.admob.AdMobBusiness 5 | import com.allever.lib.ad.chain.IAdBusiness 6 | import com.allever.lib.ad.chain.IAdBusinessFactory 7 | 8 | class AdFactory: IAdBusinessFactory { 9 | override fun getAdBusiness(businessName: String): IAdBusiness? { 10 | return when(businessName) { 11 | AdBusiness.A -> { 12 | AdMobBusiness 13 | } 14 | else -> { 15 | null 16 | } 17 | } 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/bean/ItemDayMatter.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.bean; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | /** 7 | * Created by Allever on 18/5/21. 8 | */ 9 | 10 | public class ItemDayMatter implements Parcelable { 11 | private int id; 12 | private String title; 13 | private int leftDay; 14 | private int year; 15 | private int month; 16 | private int day; 17 | private int weekDay; 18 | private long lastUpdateTime; 19 | 20 | 21 | public int getId() { 22 | return id; 23 | } 24 | 25 | public void setId(int id) { 26 | this.id = id; 27 | } 28 | 29 | public String getTitle() { 30 | return title; 31 | } 32 | 33 | public void setTitle(String title) { 34 | this.title = title; 35 | } 36 | 37 | public int getLeftDay() { 38 | return leftDay; 39 | } 40 | 41 | public void setLeftDay(int leftDay) { 42 | this.leftDay = leftDay; 43 | } 44 | 45 | public int getYear() { 46 | return year; 47 | } 48 | 49 | public void setYear(int year) { 50 | this.year = year; 51 | } 52 | 53 | public int getMonth() { 54 | return month; 55 | } 56 | 57 | public void setMonth(int month) { 58 | this.month = month; 59 | } 60 | 61 | public int getDay() { 62 | return day; 63 | } 64 | 65 | public void setDay(int day) { 66 | this.day = day; 67 | } 68 | 69 | public int getWeekDay() { 70 | return weekDay; 71 | } 72 | 73 | public void setWeekDay(int weekDay) { 74 | this.weekDay = weekDay; 75 | } 76 | 77 | public long getLastUpdateTime() { 78 | return lastUpdateTime; 79 | } 80 | 81 | public void setLastUpdateTime(long lastUpdateTime) { 82 | this.lastUpdateTime = lastUpdateTime; 83 | } 84 | 85 | @Override 86 | public int describeContents() { 87 | return 0; 88 | } 89 | 90 | @Override 91 | public void writeToParcel(Parcel dest, int flags) { 92 | dest.writeInt(this.id); 93 | dest.writeString(this.title); 94 | dest.writeInt(this.leftDay); 95 | dest.writeInt(this.year); 96 | dest.writeInt(this.month); 97 | dest.writeInt(this.day); 98 | dest.writeInt(this.weekDay); 99 | dest.writeLong(this.lastUpdateTime); 100 | } 101 | 102 | public ItemDayMatter() { 103 | } 104 | 105 | protected ItemDayMatter(Parcel in) { 106 | this.id = in.readInt(); 107 | this.title = in.readString(); 108 | this.leftDay = in.readInt(); 109 | this.year = in.readInt(); 110 | this.month = in.readInt(); 111 | this.day = in.readInt(); 112 | this.weekDay = in.readInt(); 113 | this.lastUpdateTime = in.readLong(); 114 | } 115 | 116 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { 117 | @Override 118 | public ItemDayMatter createFromParcel(Parcel source) { 119 | return new ItemDayMatter(source); 120 | } 121 | 122 | @Override 123 | public ItemDayMatter[] newArray(int size) { 124 | return new ItemDayMatter[size]; 125 | } 126 | }; 127 | } 128 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/bean/ItemSlidMenuSort.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.bean; 2 | 3 | /** 4 | * Created by Allever on 18/5/26. 5 | */ 6 | 7 | public class ItemSlidMenuSort { 8 | private int id; 9 | private String name; 10 | private int count; 11 | 12 | 13 | public int getId() { 14 | return id; 15 | } 16 | 17 | public void setId(int id) { 18 | this.id = id; 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | 29 | public int getCount() { 30 | return count; 31 | } 32 | 33 | public void setCount(int count) { 34 | this.count = count; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/data/Config.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.data; 2 | 3 | import org.litepal.crud.DataSupport; 4 | 5 | /** 6 | * Created by Allever on 18/6/1. 7 | */ 8 | 9 | public class Config extends DataSupport { 10 | private int id; 11 | 12 | private int currentDayRemind; 13 | private int currentRemindHour; 14 | private int currentRemindMin; 15 | 16 | private int beforeDayRemind; 17 | private int beforeRemindHour; 18 | private int beforeRemindMin; 19 | 20 | public int getId() { 21 | return id; 22 | } 23 | 24 | public void setId(int id) { 25 | this.id = id; 26 | } 27 | 28 | 29 | 30 | public int getCurrentRemindHour() { 31 | return currentRemindHour; 32 | } 33 | 34 | public void setCurrentRemindHour(int currentRemindHour) { 35 | this.currentRemindHour = currentRemindHour; 36 | } 37 | 38 | public int getCurrentRemindMin() { 39 | return currentRemindMin; 40 | } 41 | 42 | public void setCurrentRemindMin(int currentRemindMin) { 43 | this.currentRemindMin = currentRemindMin; 44 | } 45 | 46 | 47 | 48 | public int getBeforeRemindHour() { 49 | return beforeRemindHour; 50 | } 51 | 52 | public void setBeforeRemindHour(int beforeRemindHour) { 53 | this.beforeRemindHour = beforeRemindHour; 54 | } 55 | 56 | public int getBeforeRemindMin() { 57 | return beforeRemindMin; 58 | } 59 | 60 | public void setBeforeRemindMin(int beforeRemindMin) { 61 | this.beforeRemindMin = beforeRemindMin; 62 | } 63 | 64 | public int getCurrentDayRemind() { 65 | return currentDayRemind; 66 | } 67 | 68 | public void setCurrentDayRemind(int currentDayRemind) { 69 | this.currentDayRemind = currentDayRemind; 70 | } 71 | 72 | public int getBeforeDayRemind() { 73 | return beforeDayRemind; 74 | } 75 | 76 | public void setBeforeDayRemind(int beforeDayRemind) { 77 | this.beforeDayRemind = beforeDayRemind; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/data/DataListener.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.data; 2 | 3 | /** 4 | * Created by Allever on 18/6/4. 5 | */ 6 | 7 | public interface DataListener{ 8 | void onSuccess(T data); 9 | void onFail(String msg); 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/data/DataSource.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.data; 2 | 3 | import android.content.Context; 4 | 5 | import com.allever.daymatter.bean.ItemSlidMenuSort; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by Allever on 18/5/26. 11 | */ 12 | 13 | public interface DataSource { 14 | String getEventTitle(int id); 15 | 16 | /** 17 | * 获取侧滑菜单中列表数据 18 | * @param context 19 | * @return 20 | */ 21 | @Deprecated 22 | List getSlidMenuSortData(Context context); 23 | void getSlidMenuSortData(Context context, DataListener> dataListener); 24 | 25 | void getSortData(Context context, DataListener> dataListener); 26 | 27 | /** 28 | * 第一次启动时初始化数据库,添加默认数据 29 | * @param context 30 | */ 31 | void addDefaultSortData(Context context); 32 | 33 | /** 34 | * 第一次启动时,初始化配置信息 35 | */ 36 | void addDefaultConfig(); 37 | 38 | /** 39 | * 保存倒计时事件 40 | * @param 41 | */ 42 | @Deprecated 43 | boolean saveEvent(String eventTitle, int year, int month, int day, int weekday, int sortId, boolean isTop, int repeatType, boolean isEnd, int endYear, int endMonth, int endDay, int endWeekday); 44 | void saveEvent(Event event); 45 | 46 | /** 47 | * 获取 某分类的倒计时事件 48 | * @param sortId 49 | * @return 50 | */ 51 | @Deprecated 52 | List getSortEventList(int sortId); 53 | void getSortEventList(int sortId, DataListener> dataListener); 54 | 55 | /** 56 | * 获取所有倒计时事件 57 | * @return 58 | */ 59 | @Deprecated 60 | List getAllEventList(); 61 | void getAllEventList(final DataListener> dataListener); 62 | 63 | /** 64 | * 获取分类名称 65 | * @param sortId 66 | * @return 67 | */ 68 | String getSortName(int sortId); 69 | 70 | @Deprecated 71 | boolean updateEvent(int eventId, String eventTitle, int year, int month, int day, int weekday, int sortId, boolean isTop, int repeatType, boolean isEnd, int endYear, int endMonth, int endDay, int endWeekday); 72 | /** 73 | * 修改倒计时事件 74 | * @param event 75 | */ 76 | void updateEvent(Event event); 77 | 78 | /** 79 | * 获取倒计时事件详细信息 80 | * @param eventId 81 | * @return 82 | */ 83 | Event getEvent(int eventId); 84 | 85 | /** 86 | * 删除倒计时事件 87 | * @param eventId 88 | * @return 89 | */ 90 | boolean deleteEvent(int eventId); 91 | 92 | /** 93 | * 获取提醒配置信息 94 | * @return 95 | */ 96 | Config getRemindConfigData(); 97 | 98 | /** 99 | * 修改提醒配置 100 | * @param value 101 | */ 102 | void updateCurrentRemindSwitch(boolean value); 103 | void updateBeforeRemindSwitch(boolean value); 104 | void updateCurrentRemindTime(int hour, int min); 105 | void updateBeforeRemindTiem(int hour, int min); 106 | 107 | /*** 108 | * 获取指定日期的倒计时事件 109 | * @param year 110 | * @param month 111 | * @param day 112 | * @return 113 | */ 114 | @Deprecated 115 | List getEventListByDate(int year, int month, int day); 116 | void getEventListByDate(int year, int month, int day, DataListener> dataListener); 117 | 118 | Event.Sort saveSort(String name); 119 | void modifySort(int id, String name); 120 | void deleteSort(int id); 121 | } 122 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/data/Event.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.data; 2 | 3 | import org.litepal.crud.DataSupport; 4 | 5 | /** 6 | * Created by Allever on 18/5/21. 7 | */ 8 | 9 | public class Event extends DataSupport { 10 | private int id; 11 | 12 | //事件标题 13 | private String title; 14 | 15 | private int year; 16 | private int month; 17 | private int day; 18 | private int weekDay; 19 | 20 | //分类 21 | private int sortId; 22 | 23 | //是否置顶 24 | private boolean top; 25 | 26 | /** 27 | * 重复类型 28 | * 0:不重复 29 | * 1:每周重复 30 | * 2:每月 31 | * 3:每年*/ 32 | private int repeatType; 33 | 34 | //是否结束 35 | private boolean endSwitch; 36 | 37 | private int endYear; 38 | private int endMonth; 39 | private int endDay; 40 | private int endWeekday; 41 | 42 | private long lastUpdateTime; 43 | 44 | public int getId() { 45 | return id; 46 | } 47 | 48 | public void setId(int id) { 49 | this.id = id; 50 | } 51 | 52 | public String getTitle() { 53 | return title; 54 | } 55 | 56 | public void setTitle(String title) { 57 | this.title = title; 58 | } 59 | 60 | public int getYear() { 61 | return year; 62 | } 63 | 64 | public void setYear(int year) { 65 | this.year = year; 66 | } 67 | 68 | public int getMonth() { 69 | return month; 70 | } 71 | 72 | public void setMonth(int month) { 73 | this.month = month; 74 | } 75 | 76 | public int getDay() { 77 | return day; 78 | } 79 | 80 | public void setDay(int day) { 81 | this.day = day; 82 | } 83 | 84 | public int getWeekDay() { 85 | return weekDay; 86 | } 87 | 88 | public void setWeekDay(int weekDay) { 89 | this.weekDay = weekDay; 90 | } 91 | 92 | 93 | public int getSortId() { 94 | return sortId; 95 | } 96 | 97 | public void setSortId(int sortId) { 98 | this.sortId = sortId; 99 | } 100 | 101 | public boolean isTop() { 102 | return top; 103 | } 104 | 105 | public void setTop(boolean top) { 106 | this.top = top; 107 | } 108 | 109 | public int getRepeatType() { 110 | return repeatType; 111 | } 112 | 113 | public void setRepeatType(int repeatType) { 114 | this.repeatType = repeatType; 115 | } 116 | 117 | public boolean isEndSwitch() { 118 | return endSwitch; 119 | } 120 | 121 | public void setEndSwitch(boolean endSwitch) { 122 | this.endSwitch = endSwitch; 123 | } 124 | 125 | public int getEndWeekday() { 126 | return endWeekday; 127 | } 128 | 129 | public void setEndWeekday(int endWeekday) { 130 | this.endWeekday = endWeekday; 131 | } 132 | 133 | public int getEndYear() { 134 | return endYear; 135 | } 136 | 137 | public void setEndYear(int endYear) { 138 | this.endYear = endYear; 139 | } 140 | 141 | public int getEndMonth() { 142 | return endMonth; 143 | } 144 | 145 | public void setEndMonth(int endMonth) { 146 | this.endMonth = endMonth; 147 | } 148 | 149 | public int getEndDay() { 150 | return endDay; 151 | } 152 | 153 | public void setEndDay(int endDay) { 154 | this.endDay = endDay; 155 | } 156 | 157 | public long getLastUpdateTime() { 158 | return lastUpdateTime; 159 | } 160 | 161 | public void setLastUpdateTime(long lastUpdateTime) { 162 | this.lastUpdateTime = lastUpdateTime; 163 | } 164 | 165 | public static class Sort extends DataSupport{ 166 | 167 | private int id; 168 | 169 | //分类名称 170 | private String name; 171 | 172 | //是否默认分类 173 | private boolean defaultSort; 174 | 175 | public int getId() { 176 | return id; 177 | } 178 | 179 | public void setId(int id) { 180 | this.id = id; 181 | } 182 | 183 | public String getName() { 184 | return name; 185 | } 186 | 187 | public void setName(String name) { 188 | this.name = name; 189 | } 190 | 191 | public boolean isDefaultSort() { 192 | return defaultSort; 193 | } 194 | 195 | public void setDefaultSort(boolean defaultSort) { 196 | this.defaultSort = defaultSort; 197 | } 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/event/Event.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.event 2 | 3 | interface Event { 4 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/event/EventDayMatter.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.event; 2 | 3 | /** 4 | * Created by Allever on 18/5/28. 5 | */ 6 | 7 | public class EventDayMatter { 8 | private String event; 9 | private int sortId; 10 | private int eventId; 11 | private String name; 12 | 13 | public String getEvent() { 14 | return event; 15 | } 16 | 17 | public void setEvent(String event) { 18 | this.event = event; 19 | } 20 | 21 | public int getSortId() { 22 | return sortId; 23 | } 24 | 25 | public void setSortId(int sortId) { 26 | this.sortId = sortId; 27 | } 28 | 29 | public int getEventId() { 30 | return eventId; 31 | } 32 | 33 | public void setEventId(int eventId) { 34 | this.eventId = eventId; 35 | } 36 | 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | public void setName(String name) { 42 | this.name = name; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/event/SortEvent.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.event 2 | 3 | class SortEvent: Event{ 4 | 5 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp; 2 | 3 | import android.os.Bundle; 4 | import android.os.Handler; 5 | import androidx.annotation.Nullable; 6 | import androidx.appcompat.app.AppCompatActivity; 7 | import androidx.appcompat.widget.Toolbar; 8 | import android.view.View; 9 | import android.widget.Toast; 10 | 11 | import com.allever.daymatter.R; 12 | 13 | /** 14 | * Created by allever on 18-2-28. 15 | */ 16 | 17 | public abstract class BaseActivity> extends AppCompatActivity { 18 | 19 | protected T mPresenter; 20 | protected Handler mHandler = new Handler(); 21 | 22 | @Override 23 | protected void onCreate(@Nullable Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | mPresenter = createPresenter(); 26 | //view 与 Presenter 关联 27 | mPresenter.attachView((V) this); 28 | } 29 | 30 | @Override 31 | protected void onDestroy() { 32 | mPresenter.detachView(); 33 | super.onDestroy(); 34 | } 35 | 36 | protected abstract T createPresenter(); 37 | 38 | protected void showToast(String msg){ 39 | Toast.makeText(this, msg,Toast.LENGTH_SHORT).show(); 40 | } 41 | 42 | protected void initToolbar(Toolbar toolbar, String title){ 43 | toolbar.setTitle(title); 44 | initToolbar(toolbar); 45 | } 46 | 47 | protected void initToolbar(Toolbar toolbar, int strId){ 48 | toolbar.setTitle(strId); 49 | initToolbar(toolbar); 50 | } 51 | 52 | protected void initToolbar(Toolbar toolbar){ 53 | setSupportActionBar(toolbar); 54 | toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); 55 | toolbar.setNavigationOnClickListener(new View.OnClickListener() { 56 | @Override 57 | public void onClick(View v) { 58 | onBackPressed(); 59 | } 60 | }); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp; 2 | 3 | 4 | import android.app.Activity; 5 | import android.os.Bundle; 6 | import androidx.annotation.Nullable; 7 | import androidx.fragment.app.Fragment; 8 | import androidx.appcompat.widget.Toolbar; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.Toast; 13 | 14 | 15 | /** 16 | * Created by Mac on 18/3/1. 17 | */ 18 | 19 | public abstract class BaseFragment> extends Fragment { 20 | 21 | protected T mPresenter; 22 | 23 | protected Activity mActivity; 24 | 25 | @Override 26 | public void onCreate(@Nullable Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | } 29 | 30 | @Nullable 31 | @Override 32 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 33 | mPresenter = createPresenter(); 34 | mPresenter.attachView((V) this); 35 | 36 | mActivity = getActivity(); 37 | 38 | return super.onCreateView(inflater, container, savedInstanceState); 39 | } 40 | 41 | @Override 42 | public void onDestroyView() { 43 | mPresenter.detachView(); 44 | super.onDestroyView(); 45 | } 46 | 47 | protected void initToolbar(Toolbar toolbar, String title){ 48 | toolbar.setTitle(title); 49 | initToolbar(toolbar); 50 | } 51 | 52 | protected void initToolbar(Toolbar toolbar, int strId){ 53 | toolbar.setTitle(strId); 54 | initToolbar(toolbar); 55 | } 56 | 57 | protected void initToolbar(Toolbar toolbar){ 58 | // toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); 59 | // toolbar.setNavigationOnClickListener(new View.OnClickListener() { 60 | // @Override 61 | // public void onClick(View v) { 62 | // _mActivity.onBackPressed(); 63 | // } 64 | // }); 65 | } 66 | 67 | protected void showToast(String msg){ 68 | Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT).show(); 69 | } 70 | protected void showToast(int msg){ 71 | Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT).show(); 72 | } 73 | 74 | protected abstract T createPresenter(); 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/BasePresenter.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp; 2 | 3 | import com.allever.daymatter.data.DataSource; 4 | import com.allever.daymatter.data.Repository; 5 | 6 | import java.lang.ref.Reference; 7 | import java.lang.ref.WeakReference; 8 | 9 | /** 10 | * Created by allever on 18-2-28. 11 | */ 12 | 13 | public abstract class BasePresenter { 14 | //View类(Activity Fragment)接口弱引用 15 | protected Reference mViewRef; 16 | 17 | protected DataSource mDataSource = Repository.getIns(); 18 | 19 | public void attachView(V view){ 20 | mViewRef = new WeakReference(view); 21 | } 22 | 23 | protected V getView(){ 24 | return mViewRef.get(); 25 | } 26 | 27 | public boolean isAttachedView(){ 28 | return mViewRef != null && mViewRef.get() != null; 29 | } 30 | 31 | public void detachView(){ 32 | if (mViewRef != null){ 33 | mViewRef.clear(); 34 | mViewRef = null; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/presenter/AboutPresenter.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.presenter 2 | 3 | import com.allever.daymatter.mvp.BasePresenter 4 | import com.allever.daymatter.mvp.view.IAboutView 5 | import com.allever.daymatter.utils.SystemUtils 6 | import com.allever.lib.common.app.App 7 | 8 | class AboutPresenter: BasePresenter() { 9 | 10 | private val PRIVACY_URL = "https://plus.google.com/116794250597377070773/posts/SYoEZWDm77x" 11 | 12 | fun goToPrivacy() { 13 | SystemUtils.startWebView(App.context, PRIVACY_URL) 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/presenter/DateCalcPresenter.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.presenter; 2 | 3 | import com.allever.daymatter.mvp.BasePresenter; 4 | import com.allever.daymatter.mvp.view.IDateCalcView; 5 | 6 | /** 7 | * Created by Allever on 18/5/21. 8 | */ 9 | 10 | public class DateCalcPresenter extends BasePresenter { 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/presenter/DayMatterDetailFgPresenter.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.presenter; 2 | 3 | import android.content.Context; 4 | 5 | import com.allever.daymatter.data.Event; 6 | import com.allever.daymatter.utils.DateUtils; 7 | import com.allever.daymatter.R; 8 | import com.allever.daymatter.mvp.BasePresenter; 9 | import com.allever.daymatter.mvp.view.IDayMatterDetailFgView; 10 | 11 | /** 12 | * Created by Allever on 18/5/22. 13 | */ 14 | 15 | public class DayMatterDetailFgPresenter extends BasePresenter { 16 | 17 | public void getDayMatterData(Context context, int id) { 18 | 19 | Event event = mDataSource.getEvent(id); 20 | 21 | if (event == null){ 22 | return; 23 | } 24 | 25 | IDayMatterDetailFgView iView = mViewRef.get(); 26 | String title; 27 | int leftDay = DateUtils.calDistanceDayCount(event.getYear(), event.getMonth()-1, event.getDay()); 28 | 29 | //如果剩余天数大于等于0, 表示还没到 30 | if (leftDay >= 0){ 31 | title = context.getString(R.string.distance) + event.getTitle() + context.getString(R.string.has); 32 | iView.setTvTitle(title); 33 | iView.setTvLeftDay(leftDay + ""); 34 | iView.setTitleBackgroundColor(context.getResources().getColor(R.color.colorDefault)); 35 | }else { 36 | //如果剩余天数小于0, 表示已经过了 37 | title = event.getTitle() +context.getString(R.string.already); 38 | iView.setTvTitle(title); 39 | iView.setTvLeftDay((-1 * leftDay) + ""); 40 | iView.setTitleBackgroundColor(context.getResources().getColor(R.color.orange_500)); 41 | } 42 | String date = DateUtils.formatDate_Y_M_D_WEEK_New(context, 43 | event.getYear(), 44 | event.getMonth()-1, 45 | event.getDay(), 46 | event.getWeekDay()); 47 | iView.setTvDate(context.getString(R.string.target_date) + date); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/presenter/DayMatterDetailPresenter.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.presenter; 2 | 3 | import com.allever.daymatter.mvp.BasePresenter; 4 | import com.allever.daymatter.mvp.view.IDayMatterDetailView; 5 | 6 | /** 7 | * Created by Allever on 18/5/22. 8 | */ 9 | 10 | public class DayMatterDetailPresenter extends BasePresenter { 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/presenter/DayMatterListPresenter.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.presenter; 2 | 3 | import android.content.Context; 4 | 5 | import com.allever.daymatter.bean.ItemDayMatter; 6 | import com.allever.daymatter.data.DataListener; 7 | import com.allever.daymatter.data.Event; 8 | import com.allever.daymatter.utils.DateUtils; 9 | import com.allever.daymatter.R; 10 | import com.allever.daymatter.mvp.BasePresenter; 11 | import com.allever.daymatter.mvp.view.IDayMatterListView; 12 | import com.allever.lib.common.util.log.LogUtils; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | /** 18 | * 19 | * @author Allever 20 | * @date 18/5/21 21 | */ 22 | 23 | public class DayMatterListPresenter extends BasePresenter{ 24 | /** 25 | * 获取指定分类事件列表 26 | * */ 27 | public void getDayMatterData(final Context context, int sortId) { 28 | LogUtils.INSTANCE.d("getDayMatterData: with sortId"); 29 | mDataSource.getSortEventList(sortId, new DataListener>() { 30 | @Override 31 | public void onSuccess(List data) { 32 | setDayMatterList(context, data); 33 | } 34 | 35 | @Override 36 | public void onFail(String msg) {} 37 | }); 38 | 39 | } 40 | 41 | /** 42 | * 获取所有事件 43 | * */ 44 | public void getDayMatterData(final Context context) { 45 | LogUtils.INSTANCE.d( "getDayMatterData: "); 46 | mDataSource.getAllEventList(new DataListener>() { 47 | @Override 48 | public void onSuccess(List data) { 49 | setDayMatterList(context, data); 50 | } 51 | 52 | @Override 53 | public void onFail(String msg) {} 54 | }); 55 | 56 | } 57 | 58 | private void setDayMatterList(Context context, List eventList){ 59 | List dayMatterList = new ArrayList<>(); 60 | ItemDayMatter topDayMatterItem = null; 61 | for (Event event: eventList){ 62 | ItemDayMatter itemDayMatter = new ItemDayMatter(); 63 | itemDayMatter.setId(event.getId()); 64 | 65 | //计算倒计时天数 66 | int leftDay = DateUtils.calDistanceDayCount(event.getYear(), 67 | event.getMonth()-1, 68 | event.getDay()); 69 | itemDayMatter.setLeftDay(leftDay); 70 | 71 | itemDayMatter.setTitle(event.getTitle()); 72 | itemDayMatter.setYear(event.getYear()); 73 | itemDayMatter.setMonth(event.getMonth()); 74 | itemDayMatter.setDay(event.getDay()); 75 | itemDayMatter.setWeekDay(event.getWeekDay()); 76 | itemDayMatter.setLastUpdateTime(event.getLastUpdateTime()); 77 | dayMatterList.add(itemDayMatter); 78 | 79 | // 80 | if (event.isTop()){ 81 | //如果顶部数据为空,则赋值,只执行一次 82 | if (topDayMatterItem == null){ 83 | topDayMatterItem = itemDayMatter; 84 | }else { 85 | //如果顶部数据不为空 86 | //如果当前事件更新时间比上一个事件数据的更新时间大,则置换顶部数据对象 87 | if (itemDayMatter.getLastUpdateTime() > topDayMatterItem.getLastUpdateTime()){ 88 | topDayMatterItem = itemDayMatter; 89 | } 90 | } 91 | } 92 | } 93 | 94 | //如果都不存在置顶数据,则取第一个为置顶数据 95 | if (topDayMatterItem == null && dayMatterList.size() > 0){ 96 | topDayMatterItem = dayMatterList.get(0); 97 | } 98 | 99 | //如果没有数据,则设置空视图 100 | if (dayMatterList.size() == 0){ 101 | mViewRef.get().setEmptyData(); 102 | }else { 103 | mViewRef.get().setDayMatterList(dayMatterList); 104 | 105 | //以下是设置置顶数据 106 | //如果倒计时天数大于等于0, 表示还没到 107 | if (topDayMatterItem.getLeftDay() >= 0){ 108 | //事件标题 ,距离xxx还有 109 | mViewRef.get().setTvTitle(context.getResources().getString(R.string.distance) 110 | + topDayMatterItem.getTitle() 111 | + context.getResources().getString(R.string.left)); 112 | 113 | //剩余天数 114 | mViewRef.get().setTvLeftDay(topDayMatterItem.getLeftDay() + ""); 115 | }else { 116 | //如果倒计时天数小于0, 表示已经过了 xxx已经 117 | mViewRef.get().setTvTitle(topDayMatterItem.getTitle() + context.getString(R.string.already)); 118 | mViewRef.get().setTvLeftDay((-1 * topDayMatterItem.getLeftDay()) + ""); 119 | } 120 | 121 | 122 | //目标日 123 | StringBuilder builder = new StringBuilder(); 124 | builder.append(context.getString(R.string.target_date)); 125 | builder.append(DateUtils.formatDate_Y_M_D_WEEK_New(context, 126 | topDayMatterItem.getYear(), 127 | //月份下标值 0-11 128 | topDayMatterItem.getMonth()-1, 129 | topDayMatterItem.getDay(), 130 | topDayMatterItem.getWeekDay())); 131 | mViewRef.get().setTvTargetDate(builder.toString()); 132 | } 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/presenter/MainActivityPresenter.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.presenter; 2 | 3 | import android.content.Context; 4 | 5 | import com.allever.daymatter.R; 6 | import com.allever.daymatter.utils.SPUtils; 7 | import com.allever.daymatter.mvp.BasePresenter; 8 | import com.allever.daymatter.mvp.view.IMainActivityView; 9 | import com.allever.lib.common.app.App; 10 | 11 | /** 12 | * Created by Allever on 18/5/21. 13 | */ 14 | 15 | public class MainActivityPresenter extends BasePresenter { 16 | 17 | private String mAppName = App.context.getString(R.string.matter); 18 | private String mCurrentSortName = App.context.getString(R.string.all); 19 | 20 | public void initDefaultSortData(Context context) { 21 | //如果是第一次启动,则向数据库添加初始化数据 22 | if (SPUtils.getIsFirstLaunch(context)){ 23 | SPUtils.setFirstLaunch(context,false); 24 | mDataSource.addDefaultSortData(context); 25 | mDataSource.addDefaultConfig(); 26 | } 27 | } 28 | 29 | public void updateTitle() { 30 | mViewRef.get().updateTitle(mAppName + "." + mCurrentSortName); 31 | } 32 | 33 | public void updateTitle(int id) { 34 | if (id == 0) { 35 | mCurrentSortName = App.context.getString(R.string.all); 36 | } else { 37 | mCurrentSortName = mDataSource.getSortName(id); 38 | } 39 | updateTitle(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/presenter/SelectSortPresenter.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.presenter; 2 | 3 | import com.allever.daymatter.mvp.BasePresenter; 4 | import com.allever.daymatter.mvp.view.ISelectSortView; 5 | 6 | /** 7 | * Created by Allever on 18/5/22. 8 | */ 9 | 10 | public class SelectSortPresenter extends BasePresenter { 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/presenter/SettingPresenter.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.presenter; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.util.Log; 6 | 7 | import com.allever.daymatter.data.Config; 8 | import com.allever.daymatter.receiver.BeforeAlarmReceiver; 9 | import com.allever.daymatter.receiver.CurrentAlarmReceiver; 10 | import com.allever.daymatter.utils.CommonHalper; 11 | import com.allever.daymatter.utils.RemindUtils; 12 | import com.allever.daymatter.mvp.BasePresenter; 13 | import com.allever.daymatter.mvp.view.ISettingView; 14 | import com.allever.daymatter.utils.TimeUtils; 15 | 16 | import java.util.Calendar; 17 | 18 | /** 19 | * Created by Allever on 18/6/1. 20 | */ 21 | 22 | public class SettingPresenter extends BasePresenter { 23 | 24 | private static final String TAG = "SettingPresenter"; 25 | 26 | private Calendar mCalendar = Calendar.getInstance(); 27 | 28 | public void getRemindConfig() { 29 | Config config = mDataSource.getRemindConfigData(); 30 | if (config == null){ 31 | return; 32 | } 33 | 34 | boolean currentSwitch; 35 | Log.d(TAG, "getRemindConfig: currentRemind = " + config.getCurrentDayRemind()); 36 | 37 | //如果当天提醒配置为0, 则当天开关为false 38 | if (config.getCurrentDayRemind() == 0){ 39 | currentSwitch = false; 40 | }else { 41 | currentSwitch = true; 42 | } 43 | Log.d(TAG, "getRemindConfig: currentSwitch = " + currentSwitch ); 44 | mViewRef.get().setCurrentRemindSwitch(currentSwitch); 45 | 46 | //如果前天提醒配置为0,则前天开关为false 47 | boolean beforeSwitch; 48 | if (config.getBeforeDayRemind() == 0){ 49 | beforeSwitch = false; 50 | }else { 51 | beforeSwitch = true; 52 | } 53 | mViewRef.get().setBeforeRemindSwitch(beforeSwitch); 54 | 55 | mViewRef.get().setCurrentRemindTime(TimeUtils.INSTANCE.formatTime(config.getCurrentRemindHour(), config.getCurrentRemindMin())); 56 | 57 | mViewRef.get().setBeforeRemindTime(TimeUtils.INSTANCE.formatTime(config.getBeforeRemindHour(), config.getBeforeRemindMin())); 58 | 59 | mViewRef.get().returnRemindConfig(config); 60 | 61 | } 62 | 63 | public void updateCurrentRemindTime(int hourOfDay, int minute) { 64 | mDataSource.updateCurrentRemindTime(hourOfDay, minute); 65 | } 66 | 67 | public void updateBeforeRemindTime(int hourOfDay, int minute) { 68 | mDataSource.updateBeforeRemindTiem(hourOfDay, minute); 69 | } 70 | 71 | public void updateCurrentDaySwitch(boolean isChecked) { 72 | Log.d(TAG, "updateCurrentDaySwitch: " + isChecked); 73 | mDataSource.updateCurrentRemindSwitch(isChecked); 74 | } 75 | 76 | public void updateBeforeDaySwitch(boolean isChecked) { 77 | Log.d(TAG, "updateBeforeDaySwitch: " + isChecked); 78 | mDataSource.updateBeforeRemindSwitch(isChecked); 79 | } 80 | 81 | public void setCurrentDayRemind(Context context) { 82 | Config config = mDataSource.getRemindConfigData(); 83 | if (config == null){ 84 | return; 85 | } 86 | 87 | //检查配置如果是 1, 则设置提醒,先取消原有提醒 88 | if (config.getCurrentDayRemind() == 1) { 89 | //取消原有提醒 90 | RemindUtils.stopRemind(context, RemindUtils.REQUEST_CODE_CURRENT_REMIND, CurrentAlarmReceiver.class); 91 | //设置提醒 92 | RemindUtils.setRemind(context, 93 | config.getCurrentRemindHour(), 94 | config.getCurrentRemindMin(), 95 | RemindUtils.REQUEST_CODE_CURRENT_REMIND, 96 | CurrentAlarmReceiver.class); 97 | }else { 98 | RemindUtils.stopRemind(context, RemindUtils.REQUEST_CODE_CURRENT_REMIND, CurrentAlarmReceiver.class); 99 | } 100 | 101 | } 102 | 103 | public void setBeforeDayRemind(Context context) { 104 | Config config = mDataSource.getRemindConfigData(); 105 | if (config == null){ 106 | return; 107 | } 108 | 109 | //检查配置如果是 1, 则设置提醒,先取消原有提醒 110 | if (config.getCurrentDayRemind() == 1) { 111 | //取消原有提醒 112 | RemindUtils.stopRemind(context, RemindUtils.REQUEST_CODE_BEFORE_REMIND, BeforeAlarmReceiver.class); 113 | //设置提醒 114 | RemindUtils.setRemind(context, 115 | config.getBeforeRemindHour(), 116 | config.getBeforeRemindMin(), 117 | RemindUtils.REQUEST_CODE_BEFORE_REMIND, 118 | BeforeAlarmReceiver.class); 119 | }else { 120 | RemindUtils.stopRemind(context, RemindUtils.REQUEST_CODE_BEFORE_REMIND, BeforeAlarmReceiver.class); 121 | } 122 | 123 | } 124 | 125 | public void feedback(Activity activity) { 126 | CommonHalper.INSTANCE.feedback(activity); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/presenter/SortListPresenter.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.presenter 2 | 3 | import android.app.Activity 4 | import android.content.Context 5 | import androidx.appcompat.app.AlertDialog 6 | import com.allever.daymatter.data.DataListener 7 | import com.allever.daymatter.data.Event 8 | import com.allever.daymatter.ui.dialog.DialogHelper 9 | import com.allever.daymatter.event.SortEvent 10 | import com.allever.daymatter.mvp.BasePresenter 11 | import com.allever.daymatter.mvp.view.ISortListView 12 | import com.allever.daymatter.utils.ToastUtil 13 | import com.allever.daymatter.R 14 | import com.allever.lib.common.app.App 15 | import org.greenrobot.eventbus.EventBus 16 | 17 | class SortListPresenter : BasePresenter() { 18 | 19 | fun getSlideMenuSortData(context: Context) { 20 | //List list = mDataSource.getSlidMenuSortData(context); 21 | mDataSource.getSortData(context, object : DataListener> { 22 | override fun onSuccess(data: MutableList) { 23 | val first = Event.Sort() 24 | first.id = 0 25 | first.name = App.context.getString(R.string.all) 26 | data.add(0, first) 27 | mViewRef.get()?.setSortData(data) 28 | val sortEvent = SortEvent() 29 | EventBus.getDefault().post(sortEvent) 30 | } 31 | 32 | override fun onFail(msg: String) { 33 | 34 | } 35 | }) 36 | } 37 | 38 | fun addSort(activity: Context) { 39 | val dialogBuilder = DialogHelper.Builder() 40 | dialogBuilder.title = App.context.resources.getString(R.string.add_sort) 41 | dialogBuilder.isShowMessage(false) 42 | dialogBuilder.isShowEditText(true) 43 | val dialog = DialogHelper.createEditTextDialog(activity, dialogBuilder, object : DialogHelper.EditDialogCallback { 44 | override fun onCancelClick(dialog: AlertDialog) { 45 | dialog.dismiss() 46 | } 47 | 48 | override fun onOkClick(dialog: AlertDialog, etContent: String) { 49 | if (etContent.isEmpty()) { 50 | ToastUtil.show("请输入内容") 51 | return 52 | } else { 53 | mDataSource.saveSort(etContent) 54 | getSlideMenuSortData(App.context) 55 | dialog.dismiss() 56 | } 57 | } 58 | }) 59 | 60 | dialog.show() 61 | } 62 | 63 | fun modifySort(activity: Activity, sort: Event.Sort) { 64 | val dialogBuilder = DialogHelper.Builder() 65 | dialogBuilder.title = App.context.resources.getString(R.string.modify_sort) 66 | dialogBuilder.etContent = sort.name 67 | dialogBuilder.isShowMessage(false) 68 | dialogBuilder.isShowEditText(true) 69 | val dialog = DialogHelper.createEditTextDialog(activity, dialogBuilder, object : DialogHelper.EditDialogCallback { 70 | override fun onCancelClick(dialog: AlertDialog) { 71 | dialog.dismiss() 72 | } 73 | 74 | override fun onOkClick(dialog: AlertDialog, etContent: String) { 75 | if (etContent.isEmpty()) { 76 | ToastUtil.show("请输入内容") 77 | return 78 | } else { 79 | mDataSource.modifySort(sort.id, etContent) 80 | getSlideMenuSortData(App.context) 81 | dialog.dismiss() 82 | } 83 | } 84 | }) 85 | 86 | dialog.show() 87 | } 88 | 89 | fun deleteSort(activity: Activity, sort: Event.Sort) { 90 | val builder = DialogHelper.Builder() 91 | builder.title = App.context.resources.getString(R.string.delete_sort) 92 | builder.message = App.context.resources.getString(R.string.make_sure_delete_sort) 93 | val dialog = DialogHelper.createMessageDialog(activity, builder, object : DialogHelper.TextDialogCallback { 94 | override fun onOkClick(dialog: AlertDialog) { 95 | mDataSource.deleteSort(sort.id) 96 | getSlideMenuSortData(activity) 97 | dialog.dismiss() 98 | } 99 | 100 | override fun onCancelClick(dialog: AlertDialog) { 101 | dialog.dismiss() 102 | } 103 | }) 104 | 105 | dialog.show() 106 | } 107 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/view/IAboutView.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.view 2 | 3 | interface IAboutView { 4 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/view/IAddDayMatterView.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.view; 2 | 3 | import android.app.DatePickerDialog; 4 | import android.app.DialogFragment; 5 | 6 | /** 7 | * Created by Allever on 18/5/21. 8 | */ 9 | 10 | public interface IAddDayMatterView { 11 | void showProgressDialog(); 12 | void hideProgressDialog(); 13 | 14 | void finishSelf(); 15 | 16 | void setTvDate(String date); 17 | void setSort(String sort); 18 | void setTopSwitch(boolean value); 19 | void setTvRepeatType(String repeatType); 20 | void setEndDateSwitch(boolean value); 21 | void setTvEndDate(String endDate); 22 | 23 | void showDatePickDialog(DatePickerDialog datePickerDialog); 24 | void showEndDatePickDialog(DatePickerDialog datePickerDialog); 25 | 26 | void showRepeatTypeDialog(); 27 | 28 | void setEndDateItemVisible(); 29 | void setEndDateItemGone(); 30 | void setEndDateSwitchVisible(); 31 | void setEndDateSwitchGone(); 32 | void setEtTetle(String title); 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/view/IDateCalcView.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.view; 2 | 3 | /** 4 | * Created by Allever on 18/5/21. 5 | */ 6 | 7 | public interface IDateCalcView { 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/view/IDayMatterDetailFgView.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.view; 2 | 3 | /** 4 | * Created by Allever on 18/5/22. 5 | */ 6 | 7 | public interface IDayMatterDetailFgView { 8 | void setTvTitle(String title); 9 | void setTvLeftDay(String leftDay); 10 | void setTvDate(String date); 11 | void setTitleBackgroundColor(int color); 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/view/IDayMatterDetailView.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.view; 2 | 3 | /** 4 | * Created by Allever on 18/5/22. 5 | */ 6 | 7 | public interface IDayMatterDetailView { 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/view/IDayMatterListView.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.view; 2 | 3 | import com.allever.daymatter.bean.ItemDayMatter; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by Allever on 18/5/21. 9 | */ 10 | 11 | public interface IDayMatterListView { 12 | void setDayMatterList(List dayMatterList); 13 | 14 | void setEmptyData(); 15 | 16 | void setTvTitle(String title); 17 | void setTvLeftDay(String leftDay); 18 | void setTvTargetDate(String tvTargetDate); 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/view/IMainActivityView.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.view; 2 | 3 | import com.allever.daymatter.bean.ItemSlidMenuSort; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by Allever on 18/5/21. 9 | */ 10 | 11 | public interface IMainActivityView { 12 | void updateTitle(String title); 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/view/IModifyDayMatterView.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.view; 2 | 3 | import android.app.DatePickerDialog; 4 | 5 | /** 6 | * Created by Allever on 18/5/22. 7 | */ 8 | 9 | public interface IModifyDayMatterView { 10 | void showProgressDialog(); 11 | void hideProgressDialog(); 12 | 13 | void finishSelf(); 14 | 15 | void setTvDate(String date); 16 | void setSort(String sort); 17 | void setTopSwitch(boolean value); 18 | void setTvRepeatType(String repeatType); 19 | void setEndDateSwitch(boolean value); 20 | void setTvEndDate(String endDate); 21 | 22 | void showDatePickDialog(DatePickerDialog datePickerDialog); 23 | void showEndDatePickDialog(DatePickerDialog datePickerDialog); 24 | 25 | void showRepeatTypeDialog(); 26 | 27 | void setEndDateItemVisible(); 28 | void setEndDateItemGone(); 29 | void setEndDateSwitchVisible(); 30 | void setEndDateSwitchGone(); 31 | void setEtTetle(String title); 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/view/ISelectSortView.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.view; 2 | 3 | /** 4 | * Created by Allever on 18/5/22. 5 | */ 6 | 7 | public interface ISelectSortView { 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/view/ISettingView.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.view; 2 | 3 | import com.allever.daymatter.data.Config; 4 | 5 | /** 6 | * Created by Allever on 18/6/1. 7 | */ 8 | 9 | public interface ISettingView { 10 | void setCurrentRemindSwitch(boolean value); 11 | void setCurrentRemindTime(String time); 12 | 13 | void setBeforeRemindSwitch(boolean value); 14 | void setBeforeRemindTime(String time); 15 | 16 | void returnRemindConfig(Config config); 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/mvp/view/ISortListView.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.mvp.view 2 | 3 | import com.allever.daymatter.data.Event 4 | 5 | public interface ISortListView { 6 | fun setSortData(itemSlidMenuSortList: List) 7 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/receiver/BeforeAlarmReceiver.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.receiver; 2 | 3 | import android.app.NotificationManager; 4 | import android.app.PendingIntent; 5 | import android.content.BroadcastReceiver; 6 | import android.content.Context; 7 | import android.content.Intent; 8 | import android.graphics.BitmapFactory; 9 | import androidx.core.app.NotificationCompat; 10 | import android.util.Log; 11 | 12 | import com.allever.daymatter.R; 13 | import com.allever.daymatter.data.DataListener; 14 | import com.allever.daymatter.data.Event; 15 | import com.allever.daymatter.data.Repository; 16 | import com.allever.daymatter.utils.DateUtils; 17 | 18 | import java.util.Calendar; 19 | import java.util.List; 20 | 21 | import static android.content.Context.NOTIFICATION_SERVICE; 22 | 23 | /** 24 | * Created by Mac on 2018/3/7. 25 | */ 26 | 27 | public class BeforeAlarmReceiver extends BroadcastReceiver { 28 | 29 | private static final String TAG = "BeforeAlarmReceiver"; 30 | 31 | @Override 32 | public void onReceive(final Context context, Intent intent) { 33 | Log.d(TAG, "onReceive: "); 34 | 35 | Calendar c = Calendar.getInstance(); 36 | 37 | //当前日历加1天 38 | c.add(Calendar.DAY_OF_MONTH, 1); 39 | 40 | int year = c.get(Calendar.YEAR); 41 | int month = c.get(Calendar.MONTH); 42 | int day = c.get(Calendar.DAY_OF_MONTH); 43 | 44 | Log.d(TAG, "onReceive: year = " + year); 45 | Log.d(TAG, "onReceive: month = " + month); 46 | Log.d(TAG, "onReceive: day = " + day); 47 | 48 | Repository.getIns().getEventListByDate(year, month + 1, day, new DataListener>() { 49 | @Override 50 | public void onSuccess(List data) { 51 | sendNotification(context, data); 52 | } 53 | 54 | @Override 55 | public void onFail(String msg) {} 56 | }); 57 | 58 | } 59 | 60 | private void sendNotification(Context context, List eventList){ 61 | NotificationManager notificationManager = 62 | (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE); 63 | 64 | Intent actionIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); 65 | PendingIntent contentIntent = PendingIntent.getActivity(context, 0,actionIntent , 0); 66 | 67 | for (Event event: eventList){ 68 | Log.d(TAG, "onReceive: title = " + event.getTitle()); 69 | 70 | String date = DateUtils.formatDate_Y_M_D_WEEK_New(context, 71 | event.getYear(), 72 | event.getMonth()-1, 73 | event.getDay(), 74 | event.getWeekDay()); 75 | 76 | //通知 77 | NotificationCompat.Builder builder = new NotificationCompat.Builder(context,"") 78 | .setSmallIcon(R.drawable.ic_logo) 79 | .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_logo)) 80 | .setContentTitle(context.getResources().getString(R.string.app_name)) 81 | .setContentText(event.getTitle() + ": " + date) 82 | .setContentIntent(contentIntent) 83 | .setDefaults(NotificationCompat.DEFAULT_ALL); 84 | 85 | notificationManager.notify(event.getId(), builder.build()); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/receiver/CurrentAlarmReceiver.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.receiver; 2 | 3 | import android.app.NotificationManager; 4 | import android.app.PendingIntent; 5 | import android.content.BroadcastReceiver; 6 | import android.content.Context; 7 | import android.content.Intent; 8 | import android.graphics.BitmapFactory; 9 | import androidx.core.app.NotificationCompat; 10 | import android.util.Log; 11 | 12 | 13 | import com.allever.daymatter.R; 14 | import com.allever.daymatter.data.DataListener; 15 | import com.allever.daymatter.data.Event; 16 | import com.allever.daymatter.data.Repository; 17 | import com.allever.daymatter.utils.DateUtils; 18 | 19 | import java.util.Calendar; 20 | import java.util.List; 21 | 22 | import static android.content.Context.NOTIFICATION_SERVICE; 23 | 24 | /** 25 | * Created by Mac on 2018/3/7. 26 | */ 27 | 28 | public class CurrentAlarmReceiver extends BroadcastReceiver { 29 | 30 | private static final String TAG = "CurrentAlarmReceiver"; 31 | 32 | 33 | @Override 34 | public void onReceive(final Context context, Intent intent) { 35 | Log.d(TAG, "onReceive: "); 36 | //遍历 今天的所有倒计时事件 37 | Calendar c = Calendar.getInstance(); 38 | 39 | int year = c.get(Calendar.YEAR); 40 | int month = c.get(Calendar.MONTH); 41 | int day = c.get(Calendar.DAY_OF_MONTH); 42 | 43 | Log.d(TAG, "onReceive: year = " + year); 44 | Log.d(TAG, "onReceive: month = " + month); 45 | Log.d(TAG, "onReceive: day = " + day); 46 | 47 | Repository.getIns().getEventListByDate(year, month + 1, day, new DataListener>() { 48 | @Override 49 | public void onSuccess(List data) { 50 | sendNotification(context, data); 51 | } 52 | 53 | @Override 54 | public void onFail(String msg) {} 55 | }); 56 | } 57 | 58 | private void sendNotification(Context context, List eventList){ 59 | NotificationManager notificationManager = 60 | (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE); 61 | 62 | Intent actionIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); 63 | PendingIntent contentIntent = PendingIntent.getActivity(context, 0,actionIntent , 0); 64 | 65 | for (Event event: eventList){ 66 | Log.d(TAG, "onReceive: title = " + event.getTitle()); 67 | 68 | String date = DateUtils.formatDate_Y_M_D_WEEK_New(context, 69 | event.getYear(), 70 | event.getMonth()-1, 71 | event.getDay(), 72 | event.getWeekDay()); 73 | 74 | //通知 75 | NotificationCompat.Builder builder = new NotificationCompat.Builder(context,"") 76 | .setSmallIcon(R.mipmap.ic_launcher) 77 | .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher)) 78 | .setContentTitle(context.getResources().getString(R.string.app_name)) 79 | .setContentText(event.getTitle() + ": " + date) 80 | .setContentIntent(contentIntent) 81 | .setDefaults(NotificationCompat.DEFAULT_ALL); 82 | 83 | notificationManager.notify(event.getId(), builder.build()); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/AboutActivity.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.ui 2 | 3 | import android.content.Context 4 | import android.content.Intent 5 | import android.os.Bundle 6 | import androidx.appcompat.widget.Toolbar 7 | import android.view.View 8 | import android.widget.TextView 9 | import com.allever.daymatter.mvp.BaseActivity 10 | import com.allever.daymatter.mvp.presenter.AboutPresenter 11 | import com.allever.daymatter.mvp.view.IAboutView 12 | import com.allever.daymatter.R 13 | 14 | class AboutActivity : BaseActivity(), View.OnClickListener { 15 | 16 | 17 | private lateinit var mToolbar: Toolbar 18 | private lateinit var mTvPrivacy: TextView 19 | 20 | override fun onCreate(savedInstanceState: Bundle?) { 21 | super.onCreate(savedInstanceState) 22 | setContentView(R.layout.activity_about) 23 | 24 | initView() 25 | 26 | initToolbar(mToolbar, R.string.about) 27 | } 28 | 29 | private fun initView() { 30 | mToolbar = findViewById(R.id.id_toolbar) 31 | mTvPrivacy = findViewById(R.id.about_privacy) 32 | mTvPrivacy.setOnClickListener(this) 33 | } 34 | 35 | override fun onDestroy() { 36 | super.onDestroy() 37 | } 38 | 39 | override fun createPresenter(): AboutPresenter = AboutPresenter() 40 | 41 | override fun onClick(v: View?) { 42 | when (v?.id) { 43 | R.id.about_privacy -> { 44 | mPresenter.goToPrivacy() 45 | } 46 | } 47 | } 48 | 49 | companion object { 50 | fun actionStart(context: Context) { 51 | val intent = Intent(context, AboutActivity::class.java) 52 | context.startActivity(intent) 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/DayMatterDetailFragment.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.ui; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.os.Bundle; 5 | import androidx.annotation.Nullable; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.FrameLayout; 10 | import android.widget.TextView; 11 | 12 | import com.allever.daymatter.R; 13 | import com.allever.daymatter.bean.ItemDayMatter; 14 | import com.allever.daymatter.event.EventDayMatter; 15 | import com.allever.daymatter.mvp.BaseFragment; 16 | import com.allever.daymatter.mvp.presenter.DayMatterDetailFgPresenter; 17 | import com.allever.daymatter.mvp.view.IDayMatterDetailFgView; 18 | import com.allever.daymatter.utils.Constants; 19 | import com.allever.daymatter.utils.DateUtils; 20 | 21 | import org.greenrobot.eventbus.EventBus; 22 | import org.greenrobot.eventbus.Subscribe; 23 | import org.greenrobot.eventbus.ThreadMode; 24 | 25 | import butterknife.BindView; 26 | import butterknife.ButterKnife; 27 | import butterknife.Unbinder; 28 | 29 | /** 30 | * Created by Allever on 18/5/22. 31 | */ 32 | 33 | public class DayMatterDetailFragment extends BaseFragment implements IDayMatterDetailFgView { 34 | @BindView(R.id.id_fg_day_matter_detail_tv_title) 35 | TextView mTvTitle; 36 | @BindView(R.id.id_fg_day_matter_detail_fl_title_container) 37 | FrameLayout mFlTitleContainer; 38 | @BindView(R.id.id_fg_day_matter_detail_tv_left_day) 39 | TextView mTvLeftDay; 40 | @BindView(R.id.id_fg_day_matter_detail_tv_date) 41 | TextView mTvDate; 42 | 43 | Unbinder unbinder; 44 | 45 | private ItemDayMatter mItemDayMatter; 46 | 47 | public DayMatterDetailFragment() {} 48 | 49 | @SuppressLint("ValidFragment") 50 | public DayMatterDetailFragment(ItemDayMatter itemDayMatter) { 51 | mItemDayMatter = itemDayMatter; 52 | } 53 | 54 | @Nullable 55 | @Override 56 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 57 | super.onCreateView(inflater, container, savedInstanceState); 58 | View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_day_matter_detail, container, false); 59 | 60 | EventBus.getDefault().register(this); 61 | 62 | unbinder = ButterKnife.bind(this, view); 63 | 64 | initView(); 65 | 66 | return view; 67 | } 68 | 69 | private void initView(){ 70 | int leftDay = mItemDayMatter.getLeftDay(); 71 | if (leftDay >= 0){ 72 | mTvTitle.setText(getActivity().getString(R.string.distance) + mItemDayMatter.getTitle() + getActivity().getString(R.string.has)); 73 | mTvLeftDay.setText(leftDay + ""); 74 | mFlTitleContainer.setBackgroundColor(getActivity().getResources().getColor(R.color.colorDefault)); 75 | }else { 76 | mTvTitle.setText(mItemDayMatter.getTitle() + getActivity().getString(R.string.already)); 77 | mTvLeftDay.setText((-1 * leftDay) + ""); 78 | mFlTitleContainer.setBackgroundColor(getActivity().getResources().getColor(R.color.orange_500)); 79 | } 80 | String date = DateUtils.formatDate_Y_M_D_WEEK_New(getActivity(), 81 | mItemDayMatter.getYear(), 82 | mItemDayMatter.getMonth()-1, 83 | mItemDayMatter.getDay(), 84 | mItemDayMatter.getWeekDay()); 85 | mTvDate.setText(getActivity().getString(R.string.target_date) + date); 86 | } 87 | 88 | @Override 89 | protected DayMatterDetailFgPresenter createPresenter() { 90 | return new DayMatterDetailFgPresenter(); 91 | } 92 | 93 | @Override 94 | public void onDestroyView() { 95 | super.onDestroyView(); 96 | unbinder.unbind(); 97 | EventBus.getDefault().unregister(this); 98 | } 99 | 100 | @Subscribe(threadMode = ThreadMode.MAIN) 101 | public void onDayMatterReceive(EventDayMatter event){ 102 | String eventType = event.getEvent(); 103 | switch (eventType){ 104 | case Constants.EVENT_MODIFY_DAY_MATTER: 105 | //刷新界面 106 | if (mItemDayMatter.getId() == event.getEventId()){ 107 | //mPresenter.g 108 | mPresenter.getDayMatterData(getActivity(), mItemDayMatter.getId()); 109 | } 110 | break; 111 | default: 112 | break; 113 | } 114 | } 115 | 116 | @Override 117 | public void setTvTitle(String title) { 118 | mTvTitle.setText(title); 119 | } 120 | 121 | @Override 122 | public void setTvLeftDay(String leftDay) { 123 | mTvLeftDay.setText(leftDay); 124 | } 125 | 126 | @Override 127 | public void setTvDate(String date) { 128 | mTvDate.setText(date); 129 | } 130 | 131 | @Override 132 | public void setTitleBackgroundColor(int color) { 133 | mFlTitleContainer.setBackgroundColor(color); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/SelectSortActivity.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.ui; 2 | 3 | import android.os.Bundle; 4 | import androidx.annotation.Nullable; 5 | 6 | import com.allever.daymatter.R; 7 | import com.allever.daymatter.mvp.BaseActivity; 8 | import com.allever.daymatter.mvp.presenter.SelectSortPresenter; 9 | import com.allever.daymatter.mvp.view.ISelectSortView; 10 | 11 | /** 12 | * Created by Allever on 18/5/22. 13 | */ 14 | 15 | public class SelectSortActivity extends BaseActivity implements ISelectSortView { 16 | @Override 17 | protected void onCreate(@Nullable Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_select_sort); 20 | } 21 | 22 | @Override 23 | protected SelectSortPresenter createPresenter() { 24 | return new SelectSortPresenter(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/SortFragment.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.ui 2 | 3 | import android.os.Bundle 4 | import android.os.Handler 5 | import android.view.LayoutInflater 6 | import android.view.View 7 | import android.view.ViewGroup 8 | import com.allever.daymatter.R 9 | import com.allever.daymatter.data.Event 10 | import com.allever.daymatter.event.EventDayMatter 11 | import com.allever.daymatter.mvp.BaseFragment 12 | import com.allever.daymatter.mvp.presenter.SortListPresenter 13 | import com.allever.daymatter.mvp.view.ISortListView 14 | import com.allever.daymatter.ui.adapter.SortAdapter 15 | import com.allever.daymatter.utils.Constants 16 | import com.allever.daymatter.utils.DisplayUtil 17 | import com.allever.lib.common.util.ToastUtils 18 | import com.chad.library.adapter.base.BaseQuickAdapter 19 | import com.google.android.material.floatingactionbutton.FloatingActionButton 20 | import com.yanzhenjie.recyclerview.OnItemMenuClickListener 21 | import com.yanzhenjie.recyclerview.SwipeMenuBridge 22 | import com.yanzhenjie.recyclerview.SwipeMenuCreator 23 | import com.yanzhenjie.recyclerview.SwipeMenuItem 24 | import com.yanzhenjie.recyclerview.SwipeRecyclerView 25 | import org.greenrobot.eventbus.EventBus 26 | 27 | class SortFragment: BaseFragment(), 29 | ISortListView, 30 | OnItemMenuClickListener, 31 | BaseQuickAdapter.OnItemChildClickListener, View.OnClickListener, BaseQuickAdapter.OnItemClickListener { 32 | 33 | private lateinit var mRvSort: SwipeRecyclerView 34 | private lateinit var mAdapter: SortAdapter 35 | private var mSortData = mutableListOf() 36 | private lateinit var mBtnAddSort: FloatingActionButton 37 | private lateinit var mView: View 38 | private val mHandler = Handler() 39 | 40 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { 41 | super.onCreateView(inflater, container, savedInstanceState) 42 | mView = LayoutInflater.from(activity).inflate(R.layout.activity_sort_list, container, false) 43 | initData() 44 | initView() 45 | mPresenter.getSlideMenuSortData(context!!) 46 | return mView 47 | } 48 | 49 | private fun initView() { 50 | mRvSort = mView.findViewById(R.id.rv_sort_list) 51 | mRvSort.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(activity) 52 | mRvSort.setOnItemMenuClickListener(this) 53 | 54 | val menuCreator = SwipeMenuCreator { leftMenu, rightMenu, position -> 55 | val modifyItem = SwipeMenuItem(activity) 56 | modifyItem.text = getString(R.string.sort_list_menu_modify) 57 | modifyItem.setTextColor(resources.getColor(R.color.white)) 58 | modifyItem.setBackgroundColor(resources.getColor(R.color.sort_list_menu_modify_color)) 59 | modifyItem.height = ViewGroup.LayoutParams.MATCH_PARENT 60 | modifyItem.width = DisplayUtil.dip2px(60) 61 | rightMenu.addMenuItem(modifyItem) 62 | 63 | val deleteItem = SwipeMenuItem(activity) 64 | deleteItem.text = getString(R.string.sort_list_menu_delete) 65 | deleteItem.setTextColor(resources.getColor(R.color.white)) 66 | deleteItem.setBackgroundColor(resources.getColor(R.color.sort_list_menu_delete_color)) 67 | deleteItem.height = ViewGroup.LayoutParams.MATCH_PARENT 68 | deleteItem.width = DisplayUtil.dip2px(60) 69 | rightMenu.addMenuItem(deleteItem) 70 | } 71 | 72 | mRvSort.setSwipeMenuCreator(menuCreator) 73 | mRvSort.adapter = mAdapter 74 | 75 | mBtnAddSort = mView.findViewById(R.id.id_btn_add_sort) 76 | mBtnAddSort.setOnClickListener(this) 77 | 78 | } 79 | 80 | private fun initData() { 81 | mAdapter = SortAdapter(mSortData) 82 | mAdapter.onItemChildClickListener = this 83 | mAdapter.onItemClickListener = this 84 | } 85 | 86 | override fun createPresenter(): SortListPresenter = SortListPresenter() 87 | 88 | override fun setSortData(data: List) { 89 | mSortData.clear() 90 | mSortData.addAll(data) 91 | mAdapter.notifyDataSetChanged() 92 | } 93 | 94 | override fun onItemClick(adapter: BaseQuickAdapter<*, *>?, view: View?, position: Int) { 95 | val event = EventDayMatter() 96 | event.event = Constants.EVENT_SELECT_DISPLAY_SORT_LIST 97 | event.sortId = mSortData[position].id 98 | event.name = mSortData[position].name 99 | EventBus.getDefault().post(event) 100 | } 101 | 102 | override fun onItemClick(menuBridge: SwipeMenuBridge?, adapterPosition: Int) { 103 | menuBridge?.closeMenu() 104 | val menuIndex = menuBridge?.position 105 | if (adapterPosition in 0..3) { 106 | showToast(getString(R.string.can_not_modify_default_sort)) 107 | return 108 | } 109 | 110 | if (menuBridge?.position == 0) { 111 | mHandler.postDelayed({ 112 | mPresenter.modifySort(activity!!, mSortData[adapterPosition]) 113 | }, 200) 114 | } else if (menuBridge?.position == 1) { 115 | mHandler.postDelayed({ 116 | mPresenter.deleteSort(activity!!, mSortData[adapterPosition]) 117 | }, 200) 118 | } 119 | } 120 | 121 | override fun onItemChildClick(adapter: BaseQuickAdapter<*, *>?, view: View?, position: Int) { 122 | when (view?.id) { 123 | R.id.id_item_slid_sort_iv_type -> { 124 | mRvSort.smoothOpenRightMenu(position) 125 | } 126 | } 127 | } 128 | 129 | override fun onClick(v: View?) { 130 | when (v?.id) { 131 | R.id.id_btn_add_sort -> { 132 | mPresenter.addSort(context!!) 133 | } 134 | } 135 | } 136 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/SortListActivity.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.ui 2 | 3 | import android.content.Context 4 | import android.content.Intent 5 | import android.os.Bundle 6 | import com.google.android.material.floatingactionbutton.FloatingActionButton 7 | import androidx.appcompat.widget.Toolbar 8 | import android.view.View 9 | import android.view.ViewGroup 10 | import com.allever.daymatter.ui.adapter.SortAdapter 11 | import com.allever.daymatter.data.Event 12 | import com.allever.daymatter.mvp.BaseActivity 13 | import com.allever.daymatter.mvp.presenter.SortListPresenter 14 | import com.allever.daymatter.mvp.view.ISortListView 15 | import com.allever.daymatter.utils.DisplayUtil 16 | import com.chad.library.adapter.base.BaseQuickAdapter 17 | import com.yanzhenjie.recyclerview.* 18 | import com.allever.daymatter.R 19 | 20 | class SortListActivity : BaseActivity(), 22 | ISortListView, 23 | OnItemMenuClickListener, 24 | BaseQuickAdapter.OnItemChildClickListener, View.OnClickListener { 25 | 26 | private lateinit var mRvSort: SwipeRecyclerView 27 | private lateinit var mAdapter: SortAdapter 28 | private var mSortData = mutableListOf() 29 | private lateinit var mToolbar: Toolbar 30 | private lateinit var mBtnAddSort: FloatingActionButton 31 | 32 | override fun onCreate(savedInstanceState: Bundle?) { 33 | super.onCreate(savedInstanceState) 34 | setContentView(R.layout.activity_sort_list) 35 | 36 | initData() 37 | 38 | initView() 39 | 40 | initToolbar(mToolbar, R.string.sort_manage) 41 | 42 | mPresenter.getSlideMenuSortData(this) 43 | 44 | } 45 | 46 | private fun initView() { 47 | mToolbar = findViewById(R.id.id_toolbar) 48 | mRvSort = findViewById(R.id.rv_sort_list) 49 | mRvSort.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(this) 50 | mRvSort.setOnItemMenuClickListener(this) 51 | 52 | val menuCreator = SwipeMenuCreator { leftMenu, rightMenu, position -> 53 | val modifyItem = SwipeMenuItem(this) 54 | modifyItem.text = getString(R.string.sort_list_menu_modify) 55 | modifyItem.setTextColor(resources.getColor(R.color.white)) 56 | modifyItem.setBackgroundColor(resources.getColor(R.color.sort_list_menu_modify_color)) 57 | modifyItem.height = ViewGroup.LayoutParams.MATCH_PARENT 58 | modifyItem.width = DisplayUtil.dip2px(60) 59 | rightMenu.addMenuItem(modifyItem) 60 | 61 | val deleteItem = SwipeMenuItem(this) 62 | deleteItem.text = getString(R.string.sort_list_menu_delete) 63 | deleteItem.setTextColor(resources.getColor(R.color.white)) 64 | deleteItem.setBackgroundColor(resources.getColor(R.color.sort_list_menu_delete_color)) 65 | deleteItem.height = ViewGroup.LayoutParams.MATCH_PARENT 66 | deleteItem.width = DisplayUtil.dip2px(60) 67 | rightMenu.addMenuItem(deleteItem) 68 | } 69 | 70 | mRvSort.setSwipeMenuCreator(menuCreator) 71 | mRvSort.adapter = mAdapter 72 | 73 | mBtnAddSort = findViewById(R.id.id_btn_add_sort) 74 | mBtnAddSort.setOnClickListener(this) 75 | 76 | } 77 | 78 | private fun initData() { 79 | mAdapter = SortAdapter(mSortData) 80 | mAdapter.onItemChildClickListener = this 81 | } 82 | 83 | override fun createPresenter(): SortListPresenter = SortListPresenter() 84 | 85 | 86 | /*** 87 | * MenuItem回调 88 | */ 89 | override fun onItemClick(menuBridge: SwipeMenuBridge?, adapterPosition: Int) { 90 | menuBridge?.closeMenu() 91 | val menuIndex = menuBridge?.position 92 | if (adapterPosition in 0..2) { 93 | showToast(getString(R.string.can_not_modify_default_sort)) 94 | return 95 | } 96 | 97 | if (menuBridge?.position == 0) { 98 | mHandler.postDelayed({ 99 | mPresenter.modifySort(this, mSortData[adapterPosition]) 100 | }, 200) 101 | } else if (menuBridge?.position == 1) { 102 | mHandler.postDelayed({ 103 | mPresenter.deleteSort(this, mSortData[adapterPosition]) 104 | }, 200) 105 | } 106 | 107 | } 108 | 109 | /*** 110 | * Rv Adapter item child回调 111 | */ 112 | override fun onItemChildClick(adapter: BaseQuickAdapter<*, *>?, view: View?, position: Int) { 113 | when (view?.id) { 114 | R.id.id_item_slid_sort_iv_type -> { 115 | mRvSort.smoothOpenRightMenu(position) 116 | } 117 | } 118 | } 119 | 120 | /*** 121 | * 点击事件回调 122 | */ 123 | override fun onClick(v: View?) { 124 | when (v?.id) { 125 | R.id.id_btn_add_sort -> { 126 | mPresenter.addSort(this) 127 | } 128 | } 129 | } 130 | 131 | 132 | override fun setSortData(data: List) { 133 | mSortData.clear() 134 | mSortData.addAll(data) 135 | mAdapter.notifyDataSetChanged() 136 | } 137 | 138 | 139 | companion object { 140 | fun start(context: Context?) { 141 | val intent = Intent(context, SortListActivity::class.java) 142 | context?.startActivity(intent) 143 | } 144 | 145 | } 146 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/adapter/DayMatterListAdapter.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.ui.adapter; 2 | 3 | import android.content.Context; 4 | 5 | import com.chad.library.adapter.base.BaseQuickAdapter; 6 | import com.chad.library.adapter.base.BaseViewHolder; 7 | import com.allever.daymatter.R; 8 | import com.allever.daymatter.bean.ItemDayMatter; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Allever on 18/5/21. 14 | */ 15 | 16 | public class DayMatterListAdapter extends BaseQuickAdapter { 17 | private Context mContext; 18 | public DayMatterListAdapter(Context context, List data) { 19 | super(R.layout.item_list_day_matter, data); 20 | mContext = context; 21 | } 22 | 23 | @Override 24 | protected void convert(BaseViewHolder holder, ItemDayMatter item) { 25 | //如果剩余天数大于等于0 ,表示还没到 26 | if (item.getLeftDay() >= 0){ 27 | holder.setText(R.id.id_item_list_tv_title, mContext.getResources().getString(R.string.distance) 28 | + item.getTitle() 29 | + mContext.getResources().getString(R.string.has)); 30 | holder.setText(R.id.id_item_list_tv_left_day, item.getLeftDay() + ""); 31 | //设置背景默认 32 | holder.setBackgroundColor(R.id.id_item_list_ll_left_day_container, mContext.getResources().getColor(R.color.colorDefault)); 33 | }else { 34 | //如果剩余天数小于0,表示已经过了 35 | holder.setText(R.id.id_item_list_tv_title, item.getTitle() + mContext.getString(R.string.already)); 36 | int leftDay = -1 * item.getLeftDay(); 37 | holder.setText(R.id.id_item_list_tv_left_day, leftDay+""); 38 | 39 | //设置背景黄色 40 | holder.setBackgroundColor(R.id.id_item_list_ll_left_day_container, mContext.getResources().getColor(R.color.orange_500)); 41 | } 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/adapter/DialogSortAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.ui.adapter 2 | 3 | import com.allever.daymatter.data.Event 4 | import com.chad.library.adapter.base.BaseQuickAdapter 5 | import com.chad.library.adapter.base.BaseViewHolder 6 | import com.allever.daymatter.R 7 | 8 | class DialogSortAdapter(data: List) 9 | : BaseQuickAdapter(R.layout.item_dialog_sort, data) { 10 | 11 | override fun convert(holder: BaseViewHolder?, item: Event.Sort?) { 12 | holder?.setText(R.id.item_dialog_sort_title, item?.name) 13 | } 14 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/adapter/SlidMenuSortAdapter.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.ui.adapter; 2 | 3 | import com.chad.library.adapter.base.BaseQuickAdapter; 4 | import com.chad.library.adapter.base.BaseViewHolder; 5 | import com.allever.daymatter.R; 6 | import com.allever.daymatter.bean.ItemSlidMenuSort; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 12 | * @author Allever 13 | * @date 18/5/26 14 | */ 15 | 16 | public class SlidMenuSortAdapter extends BaseQuickAdapter { 17 | public SlidMenuSortAdapter(List data) { 18 | super(R.layout.item_slid_menu_sort, data); 19 | } 20 | 21 | @Override 22 | protected void convert(BaseViewHolder holder, ItemSlidMenuSort item) { 23 | holder.setText(R.id.id_item_slid_sort_tv_name, item.getName()); 24 | holder.setText(R.id.id_item_slid_sort_tv_count, item.getCount() + ""); 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/adapter/SortAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.ui.adapter 2 | 3 | import com.allever.daymatter.data.Event 4 | import com.chad.library.adapter.base.BaseQuickAdapter 5 | import com.chad.library.adapter.base.BaseViewHolder 6 | import com.allever.daymatter.R 7 | 8 | class SortAdapter(data: List) 9 | : BaseQuickAdapter(R.layout.item_sort, data) { 10 | 11 | override fun convert(holder: BaseViewHolder?, item: Event.Sort?) { 12 | holder?.setText(R.id.id_item_slid_sort_tv_name, item?.name) 13 | holder?.addOnClickListener(R.id.id_item_slid_sort_iv_type) 14 | holder?.setVisible(R.id.id_item_slid_sort_tv_count, false) 15 | } 16 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/adapter/ViewPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.ui.adapter; 2 | 3 | import android.content.Context; 4 | import androidx.fragment.app.Fragment; 5 | import androidx.fragment.app.FragmentManager; 6 | import androidx.fragment.app.FragmentPagerAdapter; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by Allever on 18/5/21. 12 | */ 13 | 14 | public class ViewPagerAdapter extends FragmentPagerAdapter { 15 | private List mFragmentList; 16 | private Context mContext; 17 | public ViewPagerAdapter(FragmentManager fragmentManager, Context context, List fragmentList){ 18 | super(fragmentManager); 19 | mFragmentList = fragmentList; 20 | mContext = context; 21 | } 22 | @Override 23 | public Fragment getItem(int position) { 24 | return mFragmentList.get(position); 25 | } 26 | 27 | @Override 28 | public int getCount() { 29 | return mFragmentList.size(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/dialog/RepeatTypeDialog.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.ui.dialog; 2 | 3 | import android.os.Bundle; 4 | import androidx.annotation.Nullable; 5 | import androidx.fragment.app.DialogFragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.RadioButton; 10 | import android.widget.TextView; 11 | 12 | import com.allever.daymatter.R; 13 | import com.allever.daymatter.utils.Constants; 14 | 15 | import butterknife.BindView; 16 | import butterknife.ButterKnife; 17 | import butterknife.OnClick; 18 | import butterknife.Unbinder; 19 | 20 | /** 21 | * Created by Allever on 18/5/28. 22 | */ 23 | 24 | public class RepeatTypeDialog extends DialogFragment { 25 | 26 | private static OptionListener mOptionListener; 27 | 28 | @BindView(R.id.id_dialog_repeat_type_rb_no_repeat) 29 | RadioButton mRbNoRepeat; 30 | @BindView(R.id.id_dialog_repeat_type_rb_per_week) 31 | RadioButton mRbPerWeek; 32 | @BindView(R.id.id_dialog_repeat_type_rb_per_month) 33 | RadioButton mRbPerMonth; 34 | @BindView(R.id.id_dialog_repeat_type_rb_per_year) 35 | RadioButton mRbPerYear; 36 | @BindView(R.id.id_dialog_repeat_type_tv_cancel) 37 | TextView mTvCancel; 38 | 39 | Unbinder unbinder; 40 | 41 | public static RepeatTypeDialog newInsance(OptionListener optionListener) { 42 | RepeatTypeDialog repeatTypeDialog = new RepeatTypeDialog(); 43 | repeatTypeDialog.setCancelable(true); 44 | mOptionListener = optionListener; 45 | return repeatTypeDialog; 46 | } 47 | 48 | @Nullable 49 | @Override 50 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 51 | View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_repeat_type, container, false); 52 | 53 | unbinder = ButterKnife.bind(this, view); 54 | 55 | return view; 56 | } 57 | 58 | @Override 59 | public void onDestroyView() { 60 | super.onDestroyView(); 61 | unbinder.unbind(); 62 | } 63 | 64 | @OnClick({R.id.id_dialog_repeat_type_rb_no_repeat, 65 | R.id.id_dialog_repeat_type_rb_per_week, 66 | R.id.id_dialog_repeat_type_rb_per_month, 67 | R.id.id_dialog_repeat_type_rb_per_year, 68 | R.id.id_dialog_repeat_type_tv_cancel}) 69 | public void onViewClicked(View view) { 70 | switch (view.getId()) { 71 | case R.id.id_dialog_repeat_type_rb_no_repeat: 72 | if (mOptionListener != null) { 73 | mOptionListener.onItemClick(this, Constants.REPEAT_TYPE_NO_REPEAT); 74 | } 75 | break; 76 | case R.id.id_dialog_repeat_type_rb_per_week: 77 | if (mOptionListener != null) { 78 | mOptionListener.onItemClick(this, Constants.REPEAT_TYPE_PER_WEEK); 79 | } 80 | break; 81 | case R.id.id_dialog_repeat_type_rb_per_month: 82 | if (mOptionListener != null) { 83 | mOptionListener.onItemClick(this, Constants.REPEAT_TYPE_PER_MONTH); 84 | } 85 | break; 86 | case R.id.id_dialog_repeat_type_rb_per_year: 87 | if (mOptionListener != null) { 88 | mOptionListener.onItemClick(this, Constants.REPEAT_TYPE_PER_YEAR); 89 | } 90 | break; 91 | case R.id.id_dialog_repeat_type_tv_cancel: 92 | if (mOptionListener != null){ 93 | mOptionListener.onCancel(this); 94 | } 95 | break; 96 | default: 97 | break; 98 | } 99 | } 100 | 101 | public interface OptionListener { 102 | void onItemClick(DialogFragment dialog, int repeatType); 103 | 104 | void onCancel(DialogFragment dialog); 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/dialog/SortDialog.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.ui.dialog; 2 | 3 | import android.os.Bundle; 4 | import androidx.annotation.Nullable; 5 | import androidx.fragment.app.DialogFragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.allever.daymatter.R; 11 | 12 | import butterknife.ButterKnife; 13 | import butterknife.OnClick; 14 | import butterknife.Unbinder; 15 | 16 | /** 17 | * Created by Allever on 18/5/28. 18 | */ 19 | 20 | public class SortDialog extends DialogFragment { 21 | 22 | private static OptionListener mOptionListener; 23 | 24 | Unbinder unbinder; 25 | 26 | public static SortDialog newInsance(OptionListener optionListener) { 27 | SortDialog sortDialog = new SortDialog(); 28 | sortDialog.setCancelable(true); 29 | mOptionListener = optionListener; 30 | return sortDialog; 31 | } 32 | 33 | @Nullable 34 | @Override 35 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 36 | View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_sort, container, false); 37 | 38 | unbinder = ButterKnife.bind(this, view); 39 | 40 | return view; 41 | } 42 | 43 | @Override 44 | public void onDestroyView() { 45 | super.onDestroyView(); 46 | unbinder.unbind(); 47 | } 48 | 49 | @OnClick({R.id.id_dialog_sort_rb_life, 50 | R.id.id_dialog_sort_rb_work, 51 | R.id.id_dialog_sort_rb_memory_day, 52 | R.id.id_dialog_sort_tv_cancel}) 53 | public void onViewClicked(View view) { 54 | switch (view.getId()) { 55 | case R.id.id_dialog_sort_rb_life: 56 | if (mOptionListener != null) { 57 | mOptionListener.onItemClick(this, getString(R.string.sort_life), 1); 58 | } 59 | break; 60 | case R.id.id_dialog_sort_rb_work: 61 | if (mOptionListener != null) { 62 | mOptionListener.onItemClick(this, getString(R.string.sort_work), 2); 63 | } 64 | break; 65 | case R.id.id_dialog_sort_rb_memory_day: 66 | if (mOptionListener != null) { 67 | mOptionListener.onItemClick(this, getString(R.string.sort_memory_day), 3); 68 | } 69 | break; 70 | case R.id.id_dialog_sort_tv_cancel: 71 | if (mOptionListener != null){ 72 | mOptionListener.onCancel(this); 73 | } 74 | break; 75 | default: 76 | break; 77 | } 78 | } 79 | 80 | public interface OptionListener { 81 | void onItemClick(DialogFragment dialog, String sortName, int sortId); 82 | 83 | void onCancel(DialogFragment dialog); 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/widget/tab/AnimationUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.allever.daymatter.ui.widget.tab; 18 | 19 | import androidx.interpolator.view.animation.FastOutLinearInInterpolator; 20 | import androidx.interpolator.view.animation.FastOutSlowInInterpolator; 21 | import androidx.interpolator.view.animation.LinearOutSlowInInterpolator; 22 | import android.view.animation.Animation; 23 | import android.view.animation.DecelerateInterpolator; 24 | import android.view.animation.Interpolator; 25 | import android.view.animation.LinearInterpolator; 26 | 27 | class AnimationUtils { 28 | 29 | static final Interpolator LINEAR_INTERPOLATOR = new LinearInterpolator(); 30 | static final Interpolator FAST_OUT_SLOW_IN_INTERPOLATOR = new FastOutSlowInInterpolator(); 31 | static final Interpolator FAST_OUT_LINEAR_IN_INTERPOLATOR = new FastOutLinearInInterpolator(); 32 | static final Interpolator LINEAR_OUT_SLOW_IN_INTERPOLATOR = new LinearOutSlowInInterpolator(); 33 | static final Interpolator DECELERATE_INTERPOLATOR = new DecelerateInterpolator(); 34 | 35 | /** 36 | * Linear interpolation between {@code startValue} and {@code endValue} by {@code fraction}. 37 | */ 38 | static float lerp(float startValue, float endValue, float fraction) { 39 | return startValue + (fraction * (endValue - startValue)); 40 | } 41 | 42 | static int lerp(int startValue, int endValue, float fraction) { 43 | return startValue + Math.round(fraction * (endValue - startValue)); 44 | } 45 | 46 | static class AnimationListenerAdapter implements Animation.AnimationListener { 47 | @Override 48 | public void onAnimationStart(Animation animation) { 49 | } 50 | 51 | @Override 52 | public void onAnimationEnd(Animation animation) { 53 | } 54 | 55 | @Override 56 | public void onAnimationRepeat(Animation animation) { 57 | } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/widget/tab/TabItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.allever.daymatter.ui.widget.tab; 18 | 19 | import android.content.Context; 20 | import android.graphics.drawable.Drawable; 21 | import androidx.appcompat.widget.TintTypedArray; 22 | import android.util.AttributeSet; 23 | import android.view.View; 24 | 25 | /** 26 | * TabItem is a special 'view' which allows you to declare tab items for a {@link TabLayout} 27 | * within a layout. This view is not actually added to TabLayout, it is just a dummy which allows 28 | * setting of a tab items's text, icon and custom layout. See TabLayout for more information on how 29 | * to use it. 30 | * 31 | * @attr ref com.google.android.material.R.styleable#TabItem_android_icon 32 | * @attr ref com.google.android.material.R.styleable#TabItem_android_text 33 | * @attr ref com.google.android.material.R.styleable#TabItem_android_layout 34 | * 35 | * @see TabLayout 36 | */ 37 | public final class TabItem extends View { 38 | final CharSequence mText; 39 | final Drawable mIcon; 40 | final int mCustomLayout; 41 | 42 | public TabItem(Context context) { 43 | this(context, null); 44 | } 45 | 46 | public TabItem(Context context, AttributeSet attrs) { 47 | super(context, attrs); 48 | 49 | final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, 50 | com.google.android.material.R.styleable.TabItem); 51 | mText = a.getText(com.google.android.material.R.styleable.TabItem_android_text); 52 | mIcon = a.getDrawable(com.google.android.material.R.styleable.TabItem_android_icon); 53 | mCustomLayout = a.getResourceId(com.google.android.material.R.styleable.TabItem_android_layout, 0); 54 | a.recycle(); 55 | } 56 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/widget/tab/ThemeUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.allever.daymatter.ui.widget.tab; 18 | 19 | import android.content.Context; 20 | import android.content.res.TypedArray; 21 | 22 | class ThemeUtils { 23 | 24 | private static final int[] APPCOMPAT_CHECK_ATTRS = { com.google.android.material.R.attr.colorPrimary }; 25 | 26 | static void checkAppCompatTheme(Context context) { 27 | TypedArray a = context.obtainStyledAttributes(APPCOMPAT_CHECK_ATTRS); 28 | final boolean failed = !a.hasValue(0); 29 | if (a != null) { 30 | a.recycle(); 31 | } 32 | if (failed) { 33 | throw new IllegalArgumentException("You need to use a Theme.AppCompat theme " 34 | + "(or descendant) with the design library."); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/widget/tab/ValueAnimatorCompatImplHoneycombMr1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.allever.daymatter.ui.widget.tab; 18 | 19 | import android.animation.Animator; 20 | import android.animation.AnimatorListenerAdapter; 21 | import android.animation.ValueAnimator; 22 | import android.view.animation.Interpolator; 23 | 24 | class ValueAnimatorCompatImplHoneycombMr1 extends ValueAnimatorCompat.Impl { 25 | 26 | final ValueAnimator mValueAnimator; 27 | 28 | ValueAnimatorCompatImplHoneycombMr1() { 29 | mValueAnimator = new ValueAnimator(); 30 | } 31 | 32 | @Override 33 | public void start() { 34 | mValueAnimator.start(); 35 | } 36 | 37 | @Override 38 | public boolean isRunning() { 39 | return mValueAnimator.isRunning(); 40 | } 41 | 42 | @Override 43 | public void setInterpolator(Interpolator interpolator) { 44 | mValueAnimator.setInterpolator(interpolator); 45 | } 46 | 47 | @Override 48 | public void setUpdateListener(final AnimatorUpdateListenerProxy updateListener) { 49 | mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 50 | @Override 51 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 52 | updateListener.onAnimationUpdate(); 53 | } 54 | }); 55 | } 56 | 57 | @Override 58 | public void setListener(final AnimatorListenerProxy listener) { 59 | mValueAnimator.addListener(new AnimatorListenerAdapter() { 60 | @Override 61 | public void onAnimationStart(Animator animator) { 62 | listener.onAnimationStart(); 63 | } 64 | 65 | @Override 66 | public void onAnimationEnd(Animator animator) { 67 | listener.onAnimationEnd(); 68 | } 69 | 70 | @Override 71 | public void onAnimationCancel(Animator animator) { 72 | listener.onAnimationCancel(); 73 | } 74 | }); 75 | } 76 | 77 | @Override 78 | public void setIntValues(int from, int to) { 79 | mValueAnimator.setIntValues(from, to); 80 | } 81 | 82 | @Override 83 | public int getAnimatedIntValue() { 84 | return (int) mValueAnimator.getAnimatedValue(); 85 | } 86 | 87 | @Override 88 | public void setFloatValues(float from, float to) { 89 | mValueAnimator.setFloatValues(from, to); 90 | } 91 | 92 | @Override 93 | public float getAnimatedFloatValue() { 94 | return (float) mValueAnimator.getAnimatedValue(); 95 | } 96 | 97 | @Override 98 | public void setDuration(int duration) { 99 | mValueAnimator.setDuration(duration); 100 | } 101 | 102 | @Override 103 | public void cancel() { 104 | mValueAnimator.cancel(); 105 | } 106 | 107 | @Override 108 | public float getAnimatedFraction() { 109 | return mValueAnimator.getAnimatedFraction(); 110 | } 111 | 112 | @Override 113 | public void end() { 114 | mValueAnimator.end(); 115 | } 116 | 117 | @Override 118 | public long getDuration() { 119 | return mValueAnimator.getDuration(); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/widget/tab/ViewUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.allever.daymatter.ui.widget.tab; 18 | 19 | import android.os.Build; 20 | import android.view.View; 21 | 22 | class ViewUtils { 23 | 24 | static final ValueAnimatorCompat.Creator DEFAULT_ANIMATOR_CREATOR 25 | = new ValueAnimatorCompat.Creator() { 26 | @Override 27 | public ValueAnimatorCompat createAnimator() { 28 | return new ValueAnimatorCompat(Build.VERSION.SDK_INT >= 12 29 | ? new ValueAnimatorCompatImplHoneycombMr1() 30 | : new ValueAnimatorCompatImplEclairMr1()); 31 | } 32 | }; 33 | 34 | private interface ViewUtilsImpl { 35 | void setBoundsViewOutlineProvider(View view); 36 | } 37 | 38 | private static class ViewUtilsImplBase implements ViewUtilsImpl { 39 | @Override 40 | public void setBoundsViewOutlineProvider(View view) { 41 | // no-op 42 | } 43 | } 44 | 45 | private static class ViewUtilsImplLollipop implements ViewUtilsImpl { 46 | @Override 47 | public void setBoundsViewOutlineProvider(View view) { 48 | ViewUtilsLollipop.setBoundsViewOutlineProvider(view); 49 | } 50 | } 51 | 52 | private static final ViewUtilsImpl IMPL; 53 | 54 | static { 55 | final int version = Build.VERSION.SDK_INT; 56 | if (version >= 21) { 57 | IMPL = new ViewUtilsImplLollipop(); 58 | } else { 59 | IMPL = new ViewUtilsImplBase(); 60 | } 61 | } 62 | 63 | static void setBoundsViewOutlineProvider(View view) { 64 | IMPL.setBoundsViewOutlineProvider(view); 65 | } 66 | 67 | static ValueAnimatorCompat createAnimator() { 68 | return DEFAULT_ANIMATOR_CREATOR.createAnimator(); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/ui/widget/tab/ViewUtilsLollipop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.allever.daymatter.ui.widget.tab; 18 | 19 | import android.os.Build; 20 | import androidx.annotation.RequiresApi; 21 | import android.view.View; 22 | import android.view.ViewOutlineProvider; 23 | 24 | class ViewUtilsLollipop { 25 | 26 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) 27 | static void setBoundsViewOutlineProvider(View view) { 28 | view.setOutlineProvider(ViewOutlineProvider.BOUNDS); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/utils/ActivityController.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.utils 2 | 3 | import android.app.Activity 4 | import java.lang.ref.WeakReference 5 | import java.util.ArrayList 6 | 7 | object ActivityController { 8 | 9 | private val TAG = ActivityController::class.java.simpleName 10 | 11 | private val mActivityList = ArrayList?>() 12 | 13 | fun size(): Int { 14 | return mActivityList.size 15 | } 16 | 17 | fun add(weakRefActivity: WeakReference?) { 18 | mActivityList.add(weakRefActivity) 19 | } 20 | 21 | fun remove(weakRefActivity: WeakReference?) { 22 | val result = mActivityList.remove(weakRefActivity) 23 | } 24 | 25 | fun finishAll() { 26 | if (mActivityList.isNotEmpty()) { 27 | for (activityWeakReference in mActivityList) { 28 | val activity = activityWeakReference?.get() 29 | if (activity != null && !activity.isFinishing) { 30 | activity.finish() 31 | } 32 | } 33 | mActivityList.clear() 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/utils/CommonHalper.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.utils 2 | 3 | import android.content.Context 4 | import android.content.Intent 5 | import android.net.Uri 6 | import com.allever.daymatter.R 7 | import com.allever.lib.common.app.App 8 | 9 | object CommonHalper { 10 | 11 | private val FEEDBACK_TO = "devallever@163.com" 12 | private val SUBJECT = "" 13 | 14 | fun feedback(context: Context?) { 15 | // 必须明确使用mailto前缀来修饰邮件地址,如果使用 16 | // intent.putExtra(Intent.EXTRA_EMAIL, email),结果将匹配不到任何应用 17 | val uri = Uri.parse("mailto:" + FEEDBACK_TO) 18 | val email = arrayOf(FEEDBACK_TO) 19 | val intent = Intent(Intent.ACTION_SENDTO, uri) 20 | intent.putExtra(Intent.EXTRA_CC, email) 21 | intent.putExtra(Intent.EXTRA_SUBJECT, App.context.getString(R.string.feed_back_subject)) 22 | intent.putExtra(Intent.EXTRA_TEXT, App.context.getString(R.string.feed_back_content)) 23 | context?.startActivity(Intent.createChooser(intent, App.context.getString(R.string.select_mail_app))) 24 | } 25 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/utils/Constants.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.utils; 2 | 3 | /** 4 | * Created by Allever on 18/5/28. 5 | */ 6 | 7 | public class Constants { 8 | 9 | //私有构造 10 | private Constants(){} 11 | 12 | //倒计时事件重复类型 13 | public static final int REPEAT_TYPE_NO_REPEAT = 0; 14 | public static final int REPEAT_TYPE_PER_WEEK = 1; 15 | public static final int REPEAT_TYPE_PER_MONTH = 2; 16 | public static final int REPEAT_TYPE_PER_YEAR = 3; 17 | 18 | //EventBus 事件类型 19 | public static final String EVENT_SELECT_DISPLAY_SORT_LIST = "EVENT_SELECT_DISPLAY_SORT_LIST"; 20 | public static final String EVENT_ADD_DAY_MATTER = "EVENT_ADD_DAY_MATTER"; 21 | public static final String EVENT_MODIFY_DAY_MATTER = "EVENT_MODIFY_DAY_MATTER"; 22 | public static final String EVENT_DELETE_DAY_MATTER = "EVENT_DELETE_DAY_MATTER"; 23 | 24 | 25 | 26 | public static final int SORT_LIFE = 1; 27 | public static final int SORT_WORK = 2; 28 | public static final int SORT_MEMORY_DAY = 3; 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/utils/DisplayUtil.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.utils 2 | 3 | import com.allever.lib.common.app.App 4 | 5 | /** 6 | * Created by allever on 17-8-5. 7 | * 单位转换工具类 8 | */ 9 | 10 | object DisplayUtil { 11 | 12 | private val TAG = "DisplayUtil" 13 | 14 | /** 15 | * 将px转换成dip或dp 16 | * @param context 17 | * @param px 像素值 18 | * @density 转换比例 例如1dp = 3px, density值就是3 19 | * 20 | * 320x480 mdpi 1dp = 1px density = 1 21 | * 480x800 hdpi 1dp = 1.5px density = 1.5 22 | * 720x1280 xhdpi 1dp = 2px density = 2 23 | * 1080x1920 xxhdpi 1dp = 3px density = 3 24 | * 1440x2560 xxxhdpi 1dp = 4px density = 4 25 | * 26 | * @result 返回dip或dp值 27 | */ 28 | fun px2dip(px: Int): Int { 29 | val density = App.context.resources.displayMetrics.density 30 | val result = (px / density + 0.5f).toInt() 31 | return result 32 | } 33 | 34 | fun dip2px(dip: Int): Int { 35 | val density = App.context.resources.displayMetrics.density 36 | val result = (dip * density + 0.5f).toInt() 37 | return result 38 | } 39 | 40 | fun px2sp(px: Int): Int { 41 | val scaledDensity = App.context.resources.displayMetrics.scaledDensity 42 | return (px / scaledDensity + 0.5f).toInt() 43 | } 44 | 45 | fun sp2px(sp: Int): Int { 46 | val scaledDensity = App.context.resources.displayMetrics.scaledDensity 47 | return (sp * scaledDensity + 0.5f).toInt() 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/utils/LogUtil.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.utils 2 | 3 | 4 | import android.util.Log 5 | 6 | object LogUtil { 7 | 8 | 9 | private val TAG = LogUtil::class.java.simpleName 10 | 11 | private var mShow: Boolean = true 12 | 13 | fun init(show: Boolean = true) { 14 | mShow = show 15 | } 16 | 17 | 18 | fun d(tag: String, msg: String) { 19 | if (mShow) { 20 | Log.d(tag, msg) 21 | } 22 | } 23 | 24 | fun d(msg: String) { 25 | if (mShow) { 26 | d(TAG, msg) 27 | } 28 | } 29 | 30 | fun e(msg: String) { 31 | if (mShow) { 32 | e(TAG, msg) 33 | } 34 | } 35 | 36 | fun e(tag: String, msg: String) { 37 | if (mShow) { 38 | Log.e(tag, msg) 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/utils/RemindUtils.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.utils; 2 | 3 | import android.app.AlarmManager; 4 | import android.app.PendingIntent; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.util.Log; 8 | 9 | import java.util.Calendar; 10 | import java.util.TimeZone; 11 | 12 | import static android.content.Context.ALARM_SERVICE; 13 | 14 | /** 15 | * Created by Allever on 18/6/1. 16 | */ 17 | 18 | public class RemindUtils { 19 | 20 | private static final String TAG = "RemindUtils"; 21 | 22 | public static final int REQUEST_CODE_CURRENT_REMIND = 1; 23 | public static final int REQUEST_CODE_BEFORE_REMIND = 2; 24 | 25 | private RemindUtils(){} 26 | 27 | public static void setRemind(Context context, int hour, int min, int uniqueRequestCode, Class clz){ 28 | Log.d(TAG, "setRemind: "); 29 | 30 | if (context == null){ 31 | return; 32 | } 33 | 34 | //得到日历实例,主要是为了下面的获取时间 35 | Calendar mCalendar = Calendar.getInstance(); 36 | mCalendar.setTimeInMillis(System.currentTimeMillis()); 37 | 38 | //是设置日历的时间,主要是让日历的年月日和当前同步 39 | mCalendar.setTimeInMillis(System.currentTimeMillis()); 40 | // 这里时区需要设置一下 41 | mCalendar.setTimeZone(TimeZone.getTimeZone("GMT+8")); 42 | //设置在几点提醒 43 | mCalendar.set(Calendar.HOUR_OF_DAY, hour); 44 | //设置在几分提醒 45 | mCalendar.set(Calendar.MINUTE, min); 46 | //下面这两个看字面意思也知道 47 | mCalendar.set(Calendar.SECOND, 0); 48 | mCalendar.set(Calendar.MILLISECOND, 0); 49 | 50 | //CurrentAlarmReceiver.class为广播接受者 51 | Intent intent = new Intent(context ,clz); 52 | PendingIntent pi = PendingIntent.getBroadcast(context, uniqueRequestCode, intent, 0); 53 | //得到AlarmManager实例 54 | AlarmManager am = (AlarmManager)context.getSystemService(ALARM_SERVICE); 55 | 56 | Log.d(TAG, "startRemind: time = " + mCalendar.getTimeInMillis()); 57 | am.setRepeating(AlarmManager.RTC_WAKEUP, mCalendar.getTimeInMillis(), (1000 * 60 * 60 * 24), pi); 58 | } 59 | 60 | public static void stopRemind(Context context, int uniqueRequestCode, Class clz){ 61 | Log.d(TAG, "stopRemind: "); 62 | if (context == null){ 63 | return; 64 | } 65 | 66 | Intent intent = new Intent(context, clz); 67 | PendingIntent pi = PendingIntent.getBroadcast(context, uniqueRequestCode, intent, 0); 68 | AlarmManager am = (AlarmManager)context.getSystemService(ALARM_SERVICE); 69 | //取消提醒 70 | am.cancel(pi); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/utils/SPUtils.java: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.utils; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | 6 | /** 7 | * Created by Allever on 18/5/26. 8 | */ 9 | 10 | public class SPUtils { 11 | 12 | private static final String SP_CONFIG = "config"; 13 | private static final String KEY_FIRST_LAUNCH = "first_launch"; 14 | private static final String KEY_CURRENT_DAY_REMIND = "current_day_remind"; 15 | private static final String KEY_BEFORE_DAY_REMIND = "before_day_remind"; 16 | 17 | private SPUtils(){} 18 | 19 | public static void setFirstLaunch(Context context, boolean isFirstLaunch){ 20 | SharedPreferences.Editor editor = context.getSharedPreferences(SP_CONFIG, Context.MODE_PRIVATE).edit(); 21 | editor.putBoolean(KEY_FIRST_LAUNCH, isFirstLaunch); 22 | editor.apply(); 23 | } 24 | 25 | public static boolean getIsFirstLaunch(Context context){ 26 | SharedPreferences sharedPreferences = context.getSharedPreferences(SP_CONFIG, Context.MODE_PRIVATE); 27 | boolean isFirstLaunch = sharedPreferences.getBoolean(KEY_FIRST_LAUNCH, true); 28 | return isFirstLaunch; 29 | } 30 | 31 | public static void setCurrentDayRemind(Context context, boolean isCurrentDayRemind){ 32 | SharedPreferences.Editor editor = context.getSharedPreferences(SP_CONFIG, Context.MODE_PRIVATE).edit(); 33 | editor.putBoolean(KEY_CURRENT_DAY_REMIND, isCurrentDayRemind); 34 | editor.apply(); 35 | } 36 | 37 | public static boolean getIsCurrentDayRemind(Context context){ 38 | SharedPreferences sharedPreferences = context.getSharedPreferences(SP_CONFIG, Context.MODE_PRIVATE); 39 | boolean currentDayRemind = sharedPreferences.getBoolean(KEY_CURRENT_DAY_REMIND, true); 40 | return currentDayRemind; 41 | } 42 | 43 | public static void setBeforeDayRemind(Context context, boolean isBeforeDayRemind){ 44 | SharedPreferences.Editor editor = context.getSharedPreferences(SP_CONFIG, Context.MODE_PRIVATE).edit(); 45 | editor.putBoolean(KEY_BEFORE_DAY_REMIND, isBeforeDayRemind); 46 | editor.apply(); 47 | } 48 | 49 | public static boolean getIsBeforeDayRemind(Context context){ 50 | SharedPreferences sharedPreferences = context.getSharedPreferences(SP_CONFIG, Context.MODE_PRIVATE); 51 | boolean beforeDayRemind = sharedPreferences.getBoolean(KEY_BEFORE_DAY_REMIND, true); 52 | return beforeDayRemind; 53 | } 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/utils/SpUtil.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.utils 2 | 3 | import android.content.Context 4 | import com.allever.lib.common.app.App 5 | 6 | /** 7 | * SharedPreferences 工具类 8 | */ 9 | object SpUtil { 10 | 11 | /** SharedPreferences 文件名 */ 12 | private const val SP_FILE_NAME = "ALSKF_ALSKDJFO" 13 | /** SharedPreferences 对象 */ 14 | private val mSharePreference = 15 | App.context.getSharedPreferences(SP_FILE_NAME, Context.MODE_PRIVATE) 16 | 17 | /** 18 | * 保存字符串 19 | * 20 | * @param key 键名 21 | * @param value 值 22 | */ 23 | fun putString(key: String, value: String) { 24 | mSharePreference.edit().putString(key, value).apply() 25 | } 26 | 27 | /** 28 | * 获取字符串 29 | * 30 | * @param key 键名 31 | * @param defValue 默认值 32 | * 33 | * @return 字符串 34 | */ 35 | fun getString(key: String, defValue: String) = mSharePreference.getString(key, defValue)!! 36 | 37 | /** 38 | * 保存整形 39 | * 40 | * @param key 键名 41 | * @param value 值 42 | */ 43 | fun putInteger(key: String, value: Int) { 44 | mSharePreference.edit().putInt(key, value).apply() 45 | } 46 | 47 | /** 48 | * 获取整形 49 | * 50 | * @param key 键名 51 | * @param defValue 默认值 52 | * 53 | * @return 整形 54 | */ 55 | fun getInteger(key: String, defValue: Int) = mSharePreference.getInt(key, defValue) 56 | 57 | /** 58 | * 保存布尔类型 59 | * 60 | * @param key 键名 61 | * @param value 值 62 | */ 63 | fun putBoolean(key: String, value: Boolean) { 64 | mSharePreference.edit().putBoolean(key, value).apply() 65 | } 66 | 67 | /** 68 | * 获取布尔值 69 | * 70 | * @param key 键名 71 | * @param defValue 默认值 72 | * 73 | * @return 布尔值 74 | */ 75 | fun getBoolean(key: String, defValue: Boolean) = mSharePreference.getBoolean(key, defValue) 76 | 77 | /** 78 | * 保存Int 79 | * 80 | * @param key 键名 81 | * @param defValue 默认值 82 | * 83 | * @return Long 84 | */ 85 | fun putInt(key: String, value: Int) { 86 | mSharePreference.edit().putInt(key, value).apply() 87 | } 88 | 89 | /** 90 | * 获取Int 91 | * 92 | * @param key 键名 93 | * @param defValue 默认值 94 | * 95 | * @return Long 96 | */ 97 | fun getInt(key: String, value: Int) = mSharePreference.getInt(key, value) 98 | 99 | /** 100 | * 保存Long 101 | * 102 | * @param key 键名 103 | * @param defValue 默认值 104 | * 105 | * @return Long 106 | */ 107 | fun putLong(key: String, value: Long) { 108 | mSharePreference.edit().putLong(key, value).apply() 109 | } 110 | 111 | /** 112 | * 获取Long 113 | * 114 | * @param key 键名 115 | * @param defValue 默认值 116 | * 117 | * @return Long 118 | */ 119 | fun getLong(key: String, value: Long) = mSharePreference.getLong(key, value) 120 | 121 | /** 122 | * 根据 key,从 SharedPref 中移除数据 123 | * 124 | * @param key 键名 125 | */ 126 | fun remove(key: String) { 127 | mSharePreference.edit().remove(key).apply() 128 | } 129 | 130 | /** 131 | * 获取 SharedPref 中所有数据集合 132 | * 133 | * @return 保存的所有数据集合 134 | */ 135 | fun getAll(): Map = mSharePreference.all 136 | 137 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/utils/TimeUtils.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.utils 2 | 3 | object TimeUtils { 4 | 5 | private var startTime = 0L 6 | private var prevTime = 0L 7 | fun start() { 8 | startTime = System.currentTimeMillis() 9 | prevTime = startTime 10 | } 11 | 12 | fun getInterval(): Long { 13 | val currentTimeMillis = System.currentTimeMillis() 14 | val interval = currentTimeMillis - prevTime 15 | prevTime = currentTimeMillis 16 | return interval 17 | } 18 | 19 | 20 | fun formatTime(time: Long): String { 21 | var min = (time / (1000 * 60)).toString() + "" 22 | var sec = (time % (1000 * 60)).toString() + "" 23 | min = if (min.length < 2) { 24 | "0" + time / (1000 * 60) + "" 25 | } else { 26 | (time / (1000 * 60)).toString() + "" 27 | } 28 | when { 29 | sec.length == 4 -> sec = "0" + time % (1000 * 60) + "" 30 | sec.length == 3 -> sec = "00" + time % (1000 * 60) + "" 31 | sec.length == 2 -> sec = "000" + time % (1000 * 60) + "" 32 | sec.length == 1 -> sec = "0000" + time % (1000 * 60) + "" 33 | } 34 | return min + ":" + sec.trim { it <= ' ' }.substring(0, 2) 35 | } 36 | 37 | fun formatTime(hour: Int, min: Int): String { 38 | val hourStr = 39 | if (hour < 10) { 40 | "0$hour" 41 | } else { 42 | hour.toString() 43 | } 44 | val minStr = 45 | if (min < 10) { 46 | "0$min" 47 | } else { 48 | min.toString() 49 | } 50 | 51 | return "$hourStr:$minStr" 52 | } 53 | } -------------------------------------------------------------------------------- /app/src/main/java/com/allever/daymatter/utils/ToastUtil.kt: -------------------------------------------------------------------------------- 1 | package com.allever.daymatter.utils 2 | 3 | import android.widget.Toast 4 | import com.allever.lib.common.app.App 5 | 6 | object ToastUtil { 7 | fun show(msg: String) { 8 | Toast.makeText(App.context, msg, Toast.LENGTH_SHORT).show() 9 | } 10 | 11 | fun showLong(msg: String) { 12 | Toast.makeText(App.context, msg, Toast.LENGTH_LONG).show() 13 | } 14 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_about.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_arrow_back_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_arrow_back_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_arrow_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_arrow_down.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_calc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_calc.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_drawer_calculate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_drawer_calculate.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_drawer_date.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_drawer_date.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_drawer_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_drawer_menu.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_drawer_more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_drawer_more.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_edit_title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_edit_title.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_edit_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_edit_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_feedback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_feedback.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_google_play_privacy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_google_play_privacy.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_list_settings_line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_list_settings_line.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_list_style.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_list_style.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_logo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_matter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_matter.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_setting.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_share_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_share_white.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/ic_sort.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/icon_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devallever/DayMatter/f6b71280931a2e4c69b65687f9ca7909a7c1ef5a/app/src/main/res/drawable-xxhdpi/icon_back.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/days_bg_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/days_bg_round_gray.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/slid_sort_tv_count_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 13 | 14 | 15 | 16 | 24 | 25 | 36 | 37 | 47 | 48 | 57 | 58 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_add_day_matter.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |