-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
myung jun Hyun
committed
Nov 20, 2019
1 parent
636bf2d
commit 59f1901
Showing
12 changed files
with
165 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
package com.mashup.repository | ||
|
||
import com.mashup.model.Notice | ||
import com.mashup.model.VoteStatus | ||
import io.reactivex.Completable | ||
import io.reactivex.Flowable | ||
|
||
interface NoticesRepository { | ||
|
||
fun getNoticeList(): Flowable<List<Notice>> | ||
|
||
fun updateNoticeAttendance(userId: Int, voteStatus: VoteStatus): Completable | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.mashup.util | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import retrofit2.Converter | ||
import retrofit2.Retrofit | ||
import java.lang.reflect.Type | ||
|
||
class EnumConverterFactory : Converter.Factory() { | ||
|
||
override fun stringConverter( | ||
type: Type, | ||
annotations: Array<Annotation>, | ||
retrofit: Retrofit | ||
): Converter<Enum<*>, String>? = | ||
if (type is Class<*> && type.isEnum) { | ||
Converter { enum -> | ||
try { | ||
enum.javaClass.getField(enum.name) | ||
.getAnnotation(SerializedName::class.java)?.value | ||
} catch (exception: Exception) { | ||
null | ||
} ?: enum.toString() | ||
} | ||
} else { | ||
null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.mashup.util | ||
|
||
import androidx.lifecycle.Observer | ||
|
||
/** | ||
* Used as a wrapper for data that is exposed via a LiveData that represents an event. | ||
*/ | ||
open class Event<out T>(private val content: T) { | ||
|
||
@Suppress("MemberVisibilityCanBePrivate") | ||
var hasBeenHandled = false | ||
private set // Allow external read but not write | ||
|
||
/** | ||
* Returns the content and prevents its use again. | ||
*/ | ||
fun getContentIfNotHandled(): T? { | ||
return if (hasBeenHandled) { | ||
null | ||
} else { | ||
hasBeenHandled = true | ||
content | ||
} | ||
} | ||
|
||
/** | ||
* Returns the content, even if it's already been handled. | ||
*/ | ||
fun peekContent(): T = content | ||
} | ||
|
||
/** | ||
* An [Observer] for [Event]s, simplifying the pattern of checking if the [Event]'s content has | ||
* already been handled. | ||
* | ||
* [onEventUnhandledContent] is *only* called if the [Event]'s contents has not been handled. | ||
*/ | ||
class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Observer<Event<T>> { | ||
override fun onChanged(event: Event<T>?) { | ||
event?.getContentIfNotHandled()?.let { | ||
onEventUnhandledContent(it) | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
app/src/main/res/drawable/notice_attendance_button_background.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="@color/author" /> | ||
</shape> |
5 changes: 5 additions & 0 deletions
5
app/src/main/res/drawable/notice_attendance_button_ripple.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ripple xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:color="@color/author"> | ||
<item android:drawable="@android:color/white" /> | ||
</ripple> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters