-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20172 from wordpress-mobile/issue/20040-notificat…
…ions-share-an-own-published-post--preliminary-refactor Notification inline actions - preliminary refactor
- Loading branch information
Showing
7 changed files
with
130 additions
and
45 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
32 changes: 32 additions & 0 deletions
32
WordPress/src/main/java/org/wordpress/android/models/NoteExtensions.kt
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,32 @@ | ||
package org.wordpress.android.models | ||
|
||
val Note.type | ||
get() = NoteType.from(rawType) | ||
|
||
sealed class Notification { | ||
data class Like(val url: String, val title: String): Notification() | ||
data object Unknown: Notification() | ||
|
||
companion object { | ||
fun from(rawNote: Note) = when(rawNote.type) { | ||
NoteType.Like -> Like(url= rawNote.url, title = rawNote.title) | ||
else -> Unknown | ||
} | ||
} | ||
} | ||
enum class NoteType(val rawType: String) { | ||
Follow(Note.NOTE_FOLLOW_TYPE), | ||
Like(Note.NOTE_LIKE_TYPE), | ||
Comment(Note.NOTE_COMMENT_TYPE), | ||
Matcher(Note.NOTE_MATCHER_TYPE), | ||
CommentLike(Note.NOTE_COMMENT_LIKE_TYPE), | ||
Reblog(Note.NOTE_REBLOG_TYPE), | ||
NewPost(Note.NOTE_NEW_POST_TYPE), | ||
ViewMilestone(Note.NOTE_VIEW_MILESTONE), | ||
Unknown(Note.NOTE_UNKNOWN_TYPE); | ||
|
||
companion object { | ||
private val map = entries.associateBy(NoteType::rawType) | ||
fun from(rawType: String) = map[rawType] ?: Unknown | ||
} | ||
} |
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