├── .gitignore
├── .idea
├── .gitignore
├── .name
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── compiler.xml
├── deploymentTargetDropDown.xml
├── dictionaries
│ └── theapache64.xml
├── gradle.xml
├── jarRepositories.xml
├── markdown-navigator-enh.xml
├── markdown-navigator.xml
├── misc.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── theapache64
│ │ └── notes
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── theapache64
│ │ │ └── notes
│ │ │ ├── NotesApp.kt
│ │ │ ├── data
│ │ │ ├── NotesRepo.kt
│ │ │ └── remote
│ │ │ │ ├── ApiInterface.kt
│ │ │ │ ├── addnote
│ │ │ │ └── AddNoteRequest.kt
│ │ │ │ └── getnotes
│ │ │ │ └── Note.kt
│ │ │ ├── di
│ │ │ └── modules
│ │ │ │ └── NetworkModule.kt
│ │ │ ├── features
│ │ │ ├── addnote
│ │ │ │ ├── AddNoteActivity.kt
│ │ │ │ └── AddNoteViewModel.kt
│ │ │ └── notes
│ │ │ │ ├── NotesActivity.kt
│ │ │ │ ├── NotesAdapter.kt
│ │ │ │ └── NotesViewModel.kt
│ │ │ └── utils
│ │ │ ├── Const.kt
│ │ │ ├── calladapter
│ │ │ └── flow
│ │ │ │ ├── FlowResourceCallAdapter.kt
│ │ │ │ ├── FlowResourceCallAdapterFactory.kt
│ │ │ │ └── Resource.kt
│ │ │ └── livedata
│ │ │ └── SingleLiveEvent.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ ├── activity_add_note.xml
│ │ ├── activity_main.xml
│ │ └── item_note.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── theapache64
│ └── notes
│ └── ExampleUnitTest.kt
├── build.gradle
├── demo.png
├── gpm.json
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── montage.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | Notes
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | xmlns:android
37 |
38 | ^$
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | xmlns:.*
48 |
49 | ^$
50 |
51 |
52 | BY_NAME
53 |
54 |
55 |
56 |
57 |
58 |
59 | .*:id
60 |
61 | http://schemas.android.com/apk/res/android
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | .*:name
71 |
72 | http://schemas.android.com/apk/res/android
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | name
82 |
83 | ^$
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 | style
93 |
94 | ^$
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 | .*
104 |
105 | ^$
106 |
107 |
108 | BY_NAME
109 |
110 |
111 |
112 |
113 |
114 |
115 | .*
116 |
117 | http://schemas.android.com/apk/res/android
118 |
119 |
120 | ANDROID_ATTRIBUTE_ORDER
121 |
122 |
123 |
124 |
125 |
126 |
127 | .*
128 |
129 | .*
130 |
131 |
132 | BY_NAME
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetDropDown.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/.idea/dictionaries/theapache64.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | retrosheet
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator-enh.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # notes 🗒️
2 |
3 | 
4 |
5 | > A sample note taking app, to demonstrate the [Retrosheet](https://github.com/theapache64/retrosheet) library.
6 |
7 | ## Run 💻
8 |
9 | ### Data Source
10 |
11 | - [View Google Sheet](https://docs.google.com/spreadsheets/d/1YTWKe7_mzuwl7AO1Es1aCtj5S9buh3vKauKCMjx1j_M/)
12 | - [View Google Form](https://docs.google.com/forms/d/e/1FAIpQLSdmavg6P4eZTmIu-0M7xF_z-qDCHdpGebX8MGL43HSGAXcd3w/viewform?usp=sf_link)
13 |
14 | 
15 |
16 | ### Output
17 |
18 | 
19 |
20 |
21 | ## Author ✍️
22 |
23 | - theapache64
24 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'kotlin-android'
4 | id 'kotlin-kapt'
5 | id 'dagger.hilt.android.plugin'
6 | }
7 |
8 | android {
9 | compileSdkVersion 31
10 |
11 | defaultConfig {
12 | applicationId "com.theapache64.notes"
13 | minSdkVersion 16
14 | targetSdkVersion 31
15 | versionCode 1
16 | versionName "1.0"
17 |
18 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
19 | }
20 |
21 | buildTypes {
22 | release {
23 | minifyEnabled false
24 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
25 | }
26 | }
27 | compileOptions {
28 | sourceCompatibility JavaVersion.VERSION_1_8
29 | targetCompatibility JavaVersion.VERSION_1_8
30 | }
31 | kotlinOptions {
32 | jvmTarget = '1.8'
33 | }
34 |
35 | buildFeatures{
36 | dataBinding true
37 | }
38 | }
39 |
40 | dependencies {
41 |
42 | implementation 'androidx.core:core-ktx:1.6.0'
43 | implementation 'androidx.appcompat:appcompat:1.3.1'
44 | implementation 'com.google.android.material:material:1.4.0'
45 | implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
46 |
47 | // Hilt
48 | implementation "com.google.dagger:hilt-android:$hilt_version"
49 | kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
50 | implementation "androidx.hilt:hilt-lifecycle-viewmodel:$androidx_hilt_version"
51 | kapt "androidx.hilt:hilt-lifecycle-viewmodel:$androidx_hilt_version"
52 | kapt "androidx.hilt:hilt-compiler:$androidx_hilt_version"
53 |
54 | // Timber : No-nonsense injectable logging.
55 | implementation 'com.jakewharton.timber:timber:4.7.1'
56 |
57 | // Activity Kotlin Extensions : Kotlin extensions for 'activity' artifact
58 | implementation 'androidx.activity:activity-ktx:1.4.0-beta01'
59 |
60 | // Moshi : Moshi
61 | implementation 'com.squareup.moshi:moshi:1.12.0'
62 |
63 | // Retrofit : A type-safe HTTP client for Android and Java.
64 | implementation 'com.squareup.retrofit2:retrofit:2.9.0'
65 |
66 | // Retrosheet
67 | implementation 'com.github.theapache64:retrosheet:2.0.0-beta02'
68 |
69 | // Kotlinx Coroutines Core : Coroutines support libraries for Kotlin
70 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
71 |
72 | // LiveData Kotlin Extensions : Kotlin extensions for 'livedata' artifact
73 | implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0-rc01'
74 |
75 | // Moshi Kotlin Codegen : Moshi Kotlin Codegen
76 | kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.12.0'
77 |
78 | // Converter: Moshi : A Retrofit Converter which uses Moshi for serialization.
79 | implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
80 | }
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/theapache64/notes/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.theapache64.names", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
15 |
19 |
20 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/theapache64/notes/NotesApp.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes
2 |
3 | import android.app.Application
4 | import androidx.appcompat.app.AppCompatDelegate
5 | import dagger.hilt.android.HiltAndroidApp
6 | import timber.log.Timber
7 |
8 | /**
9 | * Created by theapache64 : Aug 29 Sat,2020 @ 10:04
10 | */
11 | @HiltAndroidApp
12 | class NotesApp : Application() {
13 | override fun onCreate() {
14 | super.onCreate()
15 |
16 | Timber.plant(Timber.DebugTree())
17 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
18 | }
19 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/theapache64/notes/data/NotesRepo.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes.data
2 |
3 | import com.theapache64.notes.data.remote.ApiInterface
4 | import com.theapache64.notes.data.remote.addnote.AddNoteRequest
5 | import javax.inject.Inject
6 |
7 | /**
8 | * Created by theapache64 : Aug 29 Sat,2020 @ 09:59
9 | */
10 | class NotesRepo @Inject constructor(
11 | private val apiInterface: ApiInterface
12 | ) {
13 | fun getNotes() = apiInterface.getNotes()
14 | fun addNote(addNoteRequest: AddNoteRequest) = apiInterface.addNote(addNoteRequest)
15 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/theapache64/notes/data/remote/ApiInterface.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes.data.remote
2 |
3 | import com.github.theapache64.retrosheet.annotations.Read
4 | import com.github.theapache64.retrosheet.annotations.Write
5 | import com.theapache64.notes.data.remote.addnote.AddNoteRequest
6 | import com.theapache64.notes.data.remote.getnotes.Note
7 | import com.theapache64.notes.utils.Const
8 | import com.theapache64.notes.utils.calladapter.flow.Resource
9 | import kotlinx.coroutines.flow.Flow
10 | import retrofit2.http.Body
11 | import retrofit2.http.GET
12 | import retrofit2.http.POST
13 |
14 | /**
15 | * Created by theapache64 : Aug 29 Sat,2020 @ 10:14
16 | */
17 | interface ApiInterface {
18 |
19 |
20 | @Read("SELECT * ORDER BY created_at DESC")
21 | @GET("notes")
22 | fun getNotes(): Flow>> // you can also use suspend and return List
23 |
24 | @Write
25 | @POST(Const.ADD_NOTE_ENDPOINT)
26 | fun addNote(@Body note: AddNoteRequest): Flow> // you can also use suspend and return AddNoteRequest
27 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/theapache64/notes/data/remote/addnote/AddNoteRequest.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes.data.remote.addnote
2 |
3 | import com.squareup.moshi.Json
4 | import com.squareup.moshi.JsonClass
5 |
6 | /**
7 | * Created by theapache64 : Aug 29 Sat,2020 @ 10:13
8 | */
9 | @JsonClass(generateAdapter = true)
10 | data class AddNoteRequest(
11 | @Json(name = "Title")
12 | val title: String,
13 | @Json(name = "Description")
14 | val description: String
15 | )
--------------------------------------------------------------------------------
/app/src/main/java/com/theapache64/notes/data/remote/getnotes/Note.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes.data.remote.getnotes
2 |
3 | import com.squareup.moshi.Json
4 | import com.squareup.moshi.JsonClass
5 |
6 | /**
7 | * Created by theapache64 : Aug 29 Sat,2020 @ 10:13
8 | */
9 | @JsonClass(generateAdapter = true)
10 | data class Note(
11 | @Json(name = "created_at")
12 | val createdAt: String?,
13 | @Json(name = "title")
14 | val title: String,
15 | @Json(name = "description")
16 | val description: String
17 | )
--------------------------------------------------------------------------------
/app/src/main/java/com/theapache64/notes/di/modules/NetworkModule.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes.di.modules
2 |
3 | import com.github.theapache64.retrosheet.RetrosheetInterceptor
4 | import com.theapache64.notes.data.remote.ApiInterface
5 | import com.theapache64.notes.utils.Const
6 | import com.theapache64.notes.utils.calladapter.flow.FlowResourceCallAdapterFactory
7 | import dagger.Module
8 | import dagger.Provides
9 | import dagger.hilt.InstallIn
10 | import dagger.hilt.components.SingletonComponent
11 | import okhttp3.OkHttpClient
12 | import retrofit2.Retrofit
13 | import retrofit2.converter.moshi.MoshiConverterFactory
14 |
15 | /**
16 | * Created by theapache64 : Aug 29 Sat,2020 @ 10:14
17 | */
18 | @Module
19 | @InstallIn(SingletonComponent::class)
20 | class NetworkModule {
21 |
22 | @Provides
23 | fun provideRetrosheetInterceptor(): RetrosheetInterceptor {
24 | return RetrosheetInterceptor.Builder()
25 | // To Read
26 | .addSheet("notes", "created_at", "title", "description")
27 | // To Write
28 | .addForm(
29 | Const.ADD_NOTE_ENDPOINT,
30 | "https://docs.google.com/forms/d/e/1FAIpQLSdmavg6P4eZTmIu-0M7xF_z-qDCHdpGebX8MGL43HSGAXcd3w/viewform?usp=sf_link"
31 | )
32 | .build()
33 | }
34 |
35 | @Provides
36 | fun provideOkHttpClient(retrosheetInterceptor: RetrosheetInterceptor): OkHttpClient {
37 | return OkHttpClient.Builder()
38 | .addInterceptor(retrosheetInterceptor)
39 | .build()
40 | }
41 |
42 | @Provides
43 | fun provideRetrofit(
44 | okHttpClient: OkHttpClient
45 | ): Retrofit {
46 | return Retrofit.Builder()
47 | .baseUrl("https://docs.google.com/spreadsheets/d/1YTWKe7_mzuwl7AO1Es1aCtj5S9buh3vKauKCMjx1j_M/")
48 | .client(okHttpClient)
49 | .addCallAdapterFactory(FlowResourceCallAdapterFactory())
50 | .addConverterFactory(MoshiConverterFactory.create())
51 | .build()
52 | }
53 |
54 | @Provides
55 | fun provideApi(retrofit: Retrofit): ApiInterface {
56 | return retrofit
57 | .create(ApiInterface::class.java)
58 | }
59 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/theapache64/notes/features/addnote/AddNoteActivity.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes.features.addnote
2 |
3 | import android.app.Activity
4 | import android.content.Context
5 | import android.content.Intent
6 | import android.os.Bundle
7 | import android.view.MenuItem
8 | import android.widget.Toast
9 | import androidx.activity.viewModels
10 | import androidx.appcompat.app.AppCompatActivity
11 | import androidx.databinding.DataBindingUtil
12 | import androidx.lifecycle.Observer
13 | import com.theapache64.notes.R
14 | import com.theapache64.notes.databinding.ActivityAddNoteBinding
15 | import com.theapache64.notes.utils.calladapter.flow.Resource
16 | import dagger.hilt.android.AndroidEntryPoint
17 |
18 | @AndroidEntryPoint
19 | class AddNoteActivity : AppCompatActivity() {
20 | companion object {
21 | const val RQ_CODE = 2332
22 | fun getStartIntent(context: Context): Intent {
23 | return Intent(context, AddNoteActivity::class.java).apply {
24 | // data goes here
25 | }
26 | }
27 | }
28 |
29 | private val viewModel: AddNoteViewModel by viewModels()
30 |
31 | override fun onCreate(savedInstanceState: Bundle?) {
32 | super.onCreate(savedInstanceState)
33 | val binding =
34 | DataBindingUtil.setContentView(this, R.layout.activity_add_note)
35 |
36 | binding.viewModel = viewModel
37 |
38 | supportActionBar?.setDisplayHomeAsUpEnabled(true)
39 |
40 | viewModel.addNoteResponse.observe(this, Observer {
41 | when (it) {
42 | is Resource.Loading -> {
43 | binding.bAddNote.isEnabled = false
44 | }
45 | is Resource.Success -> {
46 | Toast.makeText(this, "Note added", Toast.LENGTH_SHORT).show();
47 | binding.bAddNote.isEnabled = true
48 | setResult(Activity.RESULT_OK)
49 | finish()
50 | }
51 | is Resource.Error -> {
52 | binding.bAddNote.isEnabled = true
53 | Toast.makeText(this, it.errorData, Toast.LENGTH_SHORT).show();
54 | }
55 | }
56 | })
57 | }
58 |
59 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
60 | return if (item.itemId == android.R.id.home) {
61 | onBackPressed()
62 | true
63 | } else {
64 | super.onOptionsItemSelected(item)
65 | }
66 | }
67 |
68 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/theapache64/notes/features/addnote/AddNoteViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes.features.addnote
2 |
3 | import androidx.lifecycle.MutableLiveData
4 | import androidx.lifecycle.ViewModel
5 | import androidx.lifecycle.asLiveData
6 | import androidx.lifecycle.switchMap
7 | import com.theapache64.notes.data.NotesRepo
8 | import com.theapache64.notes.data.remote.addnote.AddNoteRequest
9 | import com.theapache64.notes.utils.calladapter.flow.Resource
10 | import dagger.hilt.android.lifecycle.HiltViewModel
11 | import kotlinx.coroutines.flow.onEach
12 | import javax.inject.Inject
13 |
14 | /**
15 | * Created by theapache64 : Aug 30 Sun,2020 @ 10:46
16 | */
17 | @HiltViewModel
18 | class AddNoteViewModel @Inject constructor(
19 | private val notesRepo: NotesRepo
20 | ) : ViewModel() {
21 |
22 | var title = ""
23 | var description = ""
24 |
25 | private val _addNoteRequest = MutableLiveData()
26 | val addNoteResponse = _addNoteRequest.switchMap { it ->
27 | notesRepo.addNote(it)
28 | .onEach { resp ->
29 | if (resp is Resource.Success) {
30 | title = ""
31 | description = ""
32 | }
33 | }
34 | .asLiveData()
35 | }
36 |
37 | fun onAddNoteClicked() {
38 | _addNoteRequest.value = AddNoteRequest(
39 | title,
40 | description
41 | )
42 | }
43 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/theapache64/notes/features/notes/NotesActivity.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes.features.notes
2 |
3 | import android.app.Activity
4 | import android.content.Intent
5 | import android.os.Bundle
6 | import android.view.View
7 | import android.widget.Toast
8 | import androidx.activity.viewModels
9 | import androidx.appcompat.app.AppCompatActivity
10 | import androidx.databinding.DataBindingUtil
11 | import androidx.lifecycle.Observer
12 | import com.theapache64.notes.R
13 | import com.theapache64.notes.databinding.ActivityMainBinding
14 | import com.theapache64.notes.features.addnote.AddNoteActivity
15 | import com.theapache64.notes.utils.calladapter.flow.Resource
16 | import dagger.hilt.android.AndroidEntryPoint
17 |
18 | @AndroidEntryPoint
19 | class NotesActivity : AppCompatActivity() {
20 |
21 | private val viewModel: NotesViewModel by viewModels()
22 |
23 | override fun onCreate(savedInstanceState: Bundle?) {
24 | super.onCreate(savedInstanceState)
25 | val binding =
26 | DataBindingUtil.setContentView(
27 | this,
28 | R.layout.activity_main
29 | )
30 |
31 | binding.viewModel = viewModel
32 |
33 | viewModel.notes.observe(this, {
34 | when (it) {
35 |
36 | is Resource.Loading -> {
37 | Toast.makeText(this, "Loading...", Toast.LENGTH_SHORT).show();
38 | binding.rvNames.visibility = View.INVISIBLE
39 | }
40 |
41 | is Resource.Success -> {
42 | val adapter = NotesAdapter(this, it.data) { position ->
43 | Toast.makeText(this, "Clicked on '$position'", Toast.LENGTH_SHORT).show();
44 | }
45 |
46 | binding.rvNames.adapter = adapter
47 | binding.rvNames.visibility = View.VISIBLE
48 | }
49 |
50 | is Resource.Error -> {
51 | Toast.makeText(this, it.errorData, Toast.LENGTH_SHORT).show();
52 | }
53 | }
54 | })
55 |
56 | viewModel.shouldLaunchAddNote.observe(this, {
57 | if (it) {
58 | // TODO:
59 | startActivityForResult(
60 | AddNoteActivity.getStartIntent(this),
61 | AddNoteActivity.RQ_CODE
62 | )
63 | }
64 | })
65 | }
66 |
67 | override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
68 | if (requestCode == AddNoteActivity.RQ_CODE && resultCode == Activity.RESULT_OK) {
69 | // new note added so refresh
70 | viewModel.onNewNoteAdded()
71 | } else {
72 | super.onActivityResult(requestCode, resultCode, data)
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/theapache64/notes/features/notes/NotesAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes.features.notes
2 |
3 |
4 | import android.content.Context
5 | import android.view.LayoutInflater
6 | import android.view.ViewGroup
7 | import androidx.recyclerview.widget.RecyclerView
8 | import com.theapache64.notes.data.remote.getnotes.Note
9 | import com.theapache64.notes.databinding.ItemNoteBinding
10 |
11 | /**
12 | * Created by theapache64 : Aug 29 Sat,2020 @ 16:37
13 | */
14 | class NotesAdapter(
15 | context: Context,
16 | private val notes: List,
17 | private val callback: (position: Int) -> Unit
18 | ) : RecyclerView.Adapter() {
19 |
20 | private val inflater = LayoutInflater.from(context)
21 |
22 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
23 | val binding = ItemNoteBinding.inflate(inflater, parent, false)
24 | return ViewHolder(binding)
25 | }
26 |
27 | override fun getItemCount(): Int = notes.size
28 |
29 | override fun onBindViewHolder(holder: ViewHolder, position: Int) {
30 | val note = notes[position]
31 | holder.binding.note = note
32 | }
33 |
34 | inner class ViewHolder(val binding: ItemNoteBinding) : RecyclerView.ViewHolder(binding.root) {
35 | init {
36 | binding.root.setOnClickListener {
37 | callback(layoutPosition)
38 | }
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/theapache64/notes/features/notes/NotesViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes.features.notes
2 |
3 | import androidx.hilt.lifecycle.ViewModelInject
4 | import androidx.lifecycle.*
5 | import com.theapache64.notes.data.NotesRepo
6 | import com.theapache64.notes.data.remote.getnotes.Note
7 | import com.theapache64.notes.utils.calladapter.flow.Resource
8 | import com.theapache64.notes.utils.livedata.SingleLiveEvent
9 | import dagger.hilt.android.lifecycle.HiltViewModel
10 | import timber.log.Timber
11 | import javax.inject.Inject
12 |
13 | /**
14 | * Created by theapache64 : Aug 29 Sat,2020 @ 09:59
15 | */
16 | @HiltViewModel
17 | class NotesViewModel @Inject constructor(
18 | private val notesRepo: NotesRepo
19 | ) : ViewModel() {
20 |
21 | private val _shouldLoadNotes = MutableLiveData()
22 | val notes: LiveData>> = _shouldLoadNotes.switchMap {
23 | notesRepo.getNotes().asLiveData()
24 | }
25 |
26 | private val _shouldLaunchAddNote = SingleLiveEvent()
27 | val shouldLaunchAddNote: LiveData = _shouldLaunchAddNote
28 |
29 | init {
30 | _shouldLoadNotes.value = true
31 | }
32 |
33 | fun onAddNameClicked() {
34 | Timber.d("onAddNameClicked: Add name clicked ")
35 | _shouldLaunchAddNote.value = true
36 | }
37 |
38 | fun onRefreshClicked() {
39 | Timber.d("onRefreshClicked: On refresh clicked")
40 | _shouldLoadNotes.value = true
41 | }
42 |
43 | fun onNewNoteAdded() {
44 | _shouldLoadNotes.value = true
45 | }
46 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/theapache64/notes/utils/Const.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes.utils
2 |
3 | /**
4 | * Created by theapache64 : Aug 30 Sun,2020 @ 11:56
5 | */
6 | object Const {
7 | const val ADD_NOTE_ENDPOINT = "add_note"
8 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/theapache64/notes/utils/calladapter/flow/FlowResourceCallAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes.utils.calladapter.flow
2 |
3 | import com.theapache64.notes.utils.calladapter.flow.Resource.Error
4 | import com.theapache64.notes.utils.calladapter.flow.Resource.Success
5 | import kotlinx.coroutines.ExperimentalCoroutinesApi
6 | import kotlinx.coroutines.flow.Flow
7 | import kotlinx.coroutines.flow.catch
8 | import kotlinx.coroutines.flow.flow
9 | import retrofit2.Call
10 | import retrofit2.CallAdapter
11 | import retrofit2.awaitResponse
12 | import java.lang.reflect.Type
13 |
14 | /**
15 | * To convert retrofit response to Flow>.
16 | * Inspired from FlowCallAdapterFactory
17 | */
18 | class FlowResourceCallAdapter(
19 | private val responseType: Type,
20 | private val isSelfExceptionHandling: Boolean
21 | ) : CallAdapter>> {
22 |
23 | override fun responseType() = responseType
24 |
25 | @ExperimentalCoroutinesApi
26 | override fun adapt(call: Call) = flow> {
27 |
28 | // Firing loading resource
29 | emit(Resource.Loading())
30 |
31 | val resp = call.awaitResponse()
32 |
33 | if (resp.isSuccessful) {
34 | resp.body()?.let { data ->
35 | // Success
36 | emit(Success(null, data))
37 | } ?: kotlin.run {
38 | // Error
39 | emit(Error("Response can't be null"))
40 | }
41 | } else {
42 | // Error
43 | val errorBody = resp.message()
44 | emit(Error(errorBody))
45 | }
46 |
47 | }.catch { error: Throwable ->
48 | if (isSelfExceptionHandling) {
49 | emit(Error(error.message ?: "Something went wrong"))
50 | } else {
51 | throw error
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/theapache64/notes/utils/calladapter/flow/FlowResourceCallAdapterFactory.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes.utils.calladapter.flow
2 |
3 |
4 | import kotlinx.coroutines.flow.Flow
5 | import retrofit2.CallAdapter
6 | import retrofit2.CallAdapter.Factory
7 | import retrofit2.Retrofit
8 | import java.lang.reflect.ParameterizedType
9 | import java.lang.reflect.Type
10 |
11 | class FlowResourceCallAdapterFactory(
12 | private val isSelfExceptionHandling: Boolean = true
13 | ) : Factory() {
14 | override fun get(
15 | returnType: Type,
16 | annotations: Array,
17 | retrofit: Retrofit
18 | ): CallAdapter<*, *>? {
19 | if (getRawType(returnType) != Flow::class.java) {
20 | return null
21 | }
22 | val observableType = getParameterUpperBound(0, returnType as ParameterizedType)
23 | val rawObservableType = getRawType(observableType)
24 | require(rawObservableType == Resource::class.java) { "type must be a resource" }
25 | require(observableType is ParameterizedType) { "resource must be parameterized" }
26 | val bodyType = getParameterUpperBound(0, observableType)
27 | return FlowResourceCallAdapter(
28 | bodyType,
29 | isSelfExceptionHandling
30 | )
31 | }
32 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/theapache64/notes/utils/calladapter/flow/Resource.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes.utils.calladapter.flow
2 |
3 | /**
4 | * Created by theapache64 : Jul 26 Sun,2020 @ 13:22
5 | */
6 | sealed class Resource {
7 |
8 | class Loading : Resource()
9 |
10 | data class Success(
11 | val message: String?,
12 | val data: T
13 | ) : Resource()
14 |
15 | data class Error(
16 | val errorData: String
17 | ) : Resource()
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/theapache64/notes/utils/livedata/SingleLiveEvent.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes.utils.livedata
2 |
3 | import android.util.Log
4 | import androidx.annotation.MainThread
5 | import androidx.lifecycle.LifecycleOwner
6 | import androidx.lifecycle.MutableLiveData
7 | import androidx.lifecycle.Observer
8 | import java.util.concurrent.atomic.AtomicBoolean
9 |
10 | /**
11 | * Normally LiveData can be fired at many times, but this special live data wrapper only fires once.
12 | */
13 | open class SingleLiveEvent : MutableLiveData() {
14 |
15 | private val pending = AtomicBoolean(false)
16 |
17 | @MainThread
18 | override fun observe(owner: LifecycleOwner, observer: Observer) {
19 | if (hasActiveObservers()) {
20 | Log.w(TAG, "Multiple observers registered but only one will be notified of changes.")
21 | }
22 |
23 | // Observe the internal MutableLiveData
24 | super.observe(owner, Observer { t ->
25 | if (pending.compareAndSet(true, false)) {
26 | observer.onChanged(t)
27 | }
28 | })
29 | }
30 |
31 |
32 | @MainThread
33 | override fun setValue(t: T?) {
34 | pending.set(true)
35 | super.setValue(t)
36 | }
37 |
38 |
39 | override fun postValue(value: T) {
40 | pending.set(true)
41 | super.postValue(value)
42 | }
43 |
44 | /**
45 | * Used for cases where T is Void, to make calls cleaner.
46 | */
47 | @MainThread
48 | fun call() {
49 | value = null
50 | }
51 |
52 | companion object {
53 | private const val TAG = "SingleLiveEvent"
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_add_note.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
11 |
12 |
13 |
17 |
18 |
19 |
28 |
29 |
34 |
35 |
36 |
37 |
46 |
47 |
52 |
53 |
54 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
16 |
17 |
18 |
28 |
29 |
30 |
41 |
42 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_note.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
11 |
12 |
13 |
18 |
19 |
24 |
25 |
26 |
33 |
34 |
35 |
42 |
43 |
44 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/theapache64/notes/b807e9c9d71518b09c9144400e1d2a0ba03de37e/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/theapache64/notes/b807e9c9d71518b09c9144400e1d2a0ba03de37e/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/theapache64/notes/b807e9c9d71518b09c9144400e1d2a0ba03de37e/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/theapache64/notes/b807e9c9d71518b09c9144400e1d2a0ba03de37e/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/theapache64/notes/b807e9c9d71518b09c9144400e1d2a0ba03de37e/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/theapache64/notes/b807e9c9d71518b09c9144400e1d2a0ba03de37e/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/theapache64/notes/b807e9c9d71518b09c9144400e1d2a0ba03de37e/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/theapache64/notes/b807e9c9d71518b09c9144400e1d2a0ba03de37e/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/theapache64/notes/b807e9c9d71518b09c9144400e1d2a0ba03de37e/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/theapache64/notes/b807e9c9d71518b09c9144400e1d2a0ba03de37e/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Notes
3 | ADD NOTE
4 | REFRESH
5 | Title
6 | Description
7 | Add Note
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/test/java/com/theapache64/notes/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.theapache64.notes
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | ext {
4 | kotlin_version = "1.5.31"
5 | hilt_version = '2.39.1'
6 | androidx_hilt_version = '1.0.0-alpha03'
7 | }
8 |
9 |
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | dependencies {
15 | classpath 'com.android.tools.build:gradle:7.0.3'
16 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
17 | classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
18 |
19 |
20 | // NOTE: Do not place your application dependencies here; they belong
21 | // in the individual module build.gradle files
22 | }
23 | }
24 |
25 | allprojects {
26 | repositories {
27 | google()
28 | mavenCentral()
29 | maven { url "https://jitpack.io" }
30 | }
31 | }
32 |
33 | task clean(type: Delete) {
34 | delete rootProject.buildDir
35 | }
--------------------------------------------------------------------------------
/demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/theapache64/notes/b807e9c9d71518b09c9144400e1d2a0ba03de37e/demo.png
--------------------------------------------------------------------------------
/gpm.json:
--------------------------------------------------------------------------------
1 | {
2 | "added": [
3 | {
4 | "id": 1,
5 | "type": "implementation",
6 | "installed_name": "timber",
7 | "gpm_dep": {
8 | "artifact_id": "timber",
9 | "default_type": "implementation",
10 | "docs": "https://mvnrepository.com/artifact/com.jakewharton.timber/timber",
11 | "get_from": "Central",
12 | "group_id": "com.jakewharton.timber",
13 | "name": "Timber",
14 | "description": "No-nonsense injectable logging."
15 | }
16 | },
17 | {
18 | "id": 2,
19 | "type": "implementation",
20 | "installed_name": "activity-ktx",
21 | "gpm_dep": {
22 | "artifact_id": "activity-ktx",
23 | "default_type": "implementation",
24 | "docs": "https://mvnrepository.com/artifact/androidx.activity/activity-ktx",
25 | "get_from": "Google",
26 | "group_id": "androidx.activity",
27 | "name": "Activity Kotlin Extensions",
28 | "description": "Kotlin extensions for 'activity' artifact"
29 | }
30 | },
31 | {
32 | "id": 3,
33 | "type": "implementation",
34 | "installed_name": "moshi",
35 | "gpm_dep": {
36 | "artifact_id": "moshi",
37 | "default_type": "implementation",
38 | "docs": "https://mvnrepository.com/artifact/com.squareup.moshi/moshi",
39 | "get_from": "Central",
40 | "group_id": "com.squareup.moshi",
41 | "name": "Moshi",
42 | "description": "Moshi"
43 | }
44 | },
45 | {
46 | "id": 4,
47 | "type": "implementation",
48 | "installed_name": "retrofit",
49 | "gpm_dep": {
50 | "artifact_id": "retrofit",
51 | "default_type": "implementation",
52 | "docs": "https://mvnrepository.com/artifact/com.squareup.retrofit2/retrofit",
53 | "get_from": "Central",
54 | "group_id": "com.squareup.retrofit2",
55 | "name": "Retrofit",
56 | "description": "A type-safe HTTP client for Android and Java."
57 | }
58 | },
59 | {
60 | "id": 5,
61 | "type": "implementation",
62 | "installed_name": "coroutines",
63 | "gpm_dep": {
64 | "artifact_id": "kotlinx-coroutines-core",
65 | "default_type": "implementation",
66 | "docs": "https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core",
67 | "get_from": "Central",
68 | "group_id": "org.jetbrains.kotlinx",
69 | "name": "Kotlinx Coroutines Core",
70 | "description": "Coroutines support libraries for Kotlin"
71 | }
72 | },
73 | {
74 | "id": 6,
75 | "type": "implementation",
76 | "installed_name": "livedata-ktx",
77 | "gpm_dep": {
78 | "artifact_id": "lifecycle-livedata-ktx",
79 | "default_type": "implementation",
80 | "docs": "https://mvnrepository.com/artifact/androidx.lifecycle/lifecycle-livedata-ktx",
81 | "get_from": "Google",
82 | "group_id": "androidx.lifecycle",
83 | "name": "LiveData Kotlin Extensions",
84 | "description": "Kotlin extensions for 'livedata' artifact"
85 | }
86 | },
87 | {
88 | "id": 7,
89 | "type": "implementation",
90 | "installed_name": "moshi",
91 | "gpm_dep": {
92 | "artifact_id": "converter-moshi",
93 | "default_type": "implementation",
94 | "docs": "https://mvnrepository.com/artifact/com.squareup.retrofit2/converter-moshi",
95 | "get_from": "Central",
96 | "group_id": "com.squareup.retrofit2",
97 | "name": "Converter: Moshi",
98 | "description": "A Retrofit Converter which uses Moshi for serialization."
99 | }
100 | },
101 | {
102 | "id": 8,
103 | "type": "kapt",
104 | "installed_name": "moshi-codegen",
105 | "gpm_dep": {
106 | "artifact_id": "moshi-kotlin-codegen",
107 | "default_type": "implementation",
108 | "docs": "https://mvnrepository.com/artifact/com.squareup.moshi/moshi-kotlin-codegen",
109 | "get_from": "Central",
110 | "group_id": "com.squareup.moshi",
111 | "name": "Moshi Kotlin Codegen",
112 | "description": "Moshi Kotlin Codegen"
113 | }
114 | },
115 | {
116 | "id": 9,
117 | "type": "implementation",
118 | "installed_name": "moshi-converter",
119 | "gpm_dep": {
120 | "artifact_id": "converter-moshi",
121 | "default_type": "implementation",
122 | "docs": "https://mvnrepository.com/artifact/com.squareup.retrofit2/converter-moshi",
123 | "get_from": "Central",
124 | "group_id": "com.squareup.retrofit2",
125 | "name": "Converter: Moshi",
126 | "description": "A Retrofit Converter which uses Moshi for serialization."
127 | }
128 | }
129 | ]
130 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/theapache64/notes/b807e9c9d71518b09c9144400e1d2a0ba03de37e/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Aug 29 10:04:05 IST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/montage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/theapache64/notes/b807e9c9d71518b09c9144400e1d2a0ba03de37e/montage.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name = "Notes"
--------------------------------------------------------------------------------