-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added the ability to get a redditor's moderated subs
- Loading branch information
1 parent
b787525
commit db567f6
Showing
13 changed files
with
245 additions
and
2 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
71 changes: 71 additions & 0 deletions
71
lib/src/main/java/com/kirkbushman/araw/models/ModeratedList.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,71 @@ | ||
package com.kirkbushman.araw.models | ||
|
||
import android.os.Parcelable | ||
import com.kirkbushman.araw.http.base.EnvelopeKind | ||
import com.kirkbushman.araw.models.mixins.Created | ||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
import kotlinx.android.parcel.Parcelize | ||
|
||
@JsonClass(generateAdapter = true) | ||
@Parcelize | ||
data class ModeratedList( | ||
|
||
@Json(name = "kind") | ||
val kind: EnvelopeKind?, | ||
|
||
@Json(name = "data") | ||
val data: List<ModeratedSub>? | ||
|
||
) : Parcelable | ||
|
||
@JsonClass(generateAdapter = true) | ||
@Parcelize | ||
data class ModeratedSub( | ||
|
||
@Json(name = "name") | ||
val fullname: String, | ||
|
||
@Json(name = "banner_img") | ||
val bannerImg: String, | ||
|
||
@Json(name = "banner_size") | ||
val bannerImgSize: List<Int>?, | ||
|
||
@Json(name = "created") | ||
override val created: Long, | ||
|
||
@Json(name = "created_utc") | ||
override val createdUtc: Long, | ||
|
||
@Json(name = "icon_img") | ||
val iconImg: String, | ||
|
||
@Json(name = "icon_size") | ||
val iconImgSize: List<Int>?, | ||
|
||
@Json(name = "user_is_subscriber") | ||
val isSubscriber: Boolean, | ||
|
||
@Json(name = "sr") | ||
val displayName: String, | ||
|
||
@Json(name = "sr_display_name_prefixed") | ||
val displayNamePrefixed: String, | ||
|
||
@Json(name = "over_18") | ||
val over18: Boolean, | ||
|
||
@Json(name = "subreddit_type") | ||
val subredditType: String, | ||
|
||
@Json(name = "subscribers") | ||
val subscribers: Int, | ||
|
||
@Json(name = "title") | ||
val title: String, | ||
|
||
@Json(name = "url") | ||
val url: String | ||
|
||
) : Parcelable, Created |
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
53 changes: 53 additions & 0 deletions
53
sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/RedditorModeratedSubs.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,53 @@ | ||
package com.kirkbushman.sampleapp.activities | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.widget.Button | ||
import android.widget.EditText | ||
import androidx.appcompat.widget.Toolbar | ||
import com.airbnb.epoxy.EpoxyRecyclerView | ||
import com.kirkbushman.araw.RedditClient | ||
import com.kirkbushman.araw.models.ModeratedSub | ||
import com.kirkbushman.sampleapp.R | ||
import com.kirkbushman.sampleapp.activities.base.BaseSearchControllerActivity | ||
import com.kirkbushman.sampleapp.controllers.BaseController | ||
import com.kirkbushman.sampleapp.controllers.ModeratedSubsController | ||
import com.kirkbushman.sampleapp.controllers.SubredditController | ||
import kotlinx.android.synthetic.main.activity_wiki_pages.* | ||
|
||
class RedditorModeratedSubs : BaseSearchControllerActivity<ModeratedSub, SubredditController.SubredditCallback>(R.layout.activity_moderated_subs) { | ||
|
||
companion object { | ||
|
||
fun start(context: Context) { | ||
|
||
val intent = Intent(context, RedditorModeratedSubs::class.java) | ||
context.startActivity(intent) | ||
} | ||
} | ||
|
||
override val actionBar: Toolbar | ||
get() = toolbar | ||
|
||
override val bttnSearch: Button | ||
get() = search_bttn | ||
|
||
override val editSearch: EditText | ||
get() = search | ||
|
||
override val recyclerView: EpoxyRecyclerView | ||
get() = list | ||
|
||
override val callback: SubredditController.SubredditCallback? | ||
get() = object : SubredditController.SubredditCallback { | ||
|
||
override fun subscribeClick(index: Int) {} | ||
} | ||
|
||
override val controller: BaseController<ModeratedSub, SubredditController.SubredditCallback> = ModeratedSubsController(callback!!) | ||
|
||
override fun fetchItem(client: RedditClient?, query: String): Collection<ModeratedSub>? { | ||
|
||
return client?.redditorsClient?.moderatedSubreddits(query) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/ModeratedSubsController.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,18 @@ | ||
package com.kirkbushman.sampleapp.controllers | ||
|
||
import android.view.View | ||
import com.kirkbushman.araw.models.ModeratedSub | ||
import com.kirkbushman.sampleapp.models.subreddit | ||
|
||
class ModeratedSubsController(callback: SubredditController.SubredditCallback) : BaseController<ModeratedSub, SubredditController.SubredditCallback>(callback) { | ||
|
||
override fun itemModel(index: Int, it: ModeratedSub, callback: SubredditController.SubredditCallback?) { | ||
|
||
subreddit { | ||
id(it.fullname) | ||
subreddit(it.displayNamePrefixed) | ||
subscribed(it.isSubscriber) | ||
subscribeClick(View.OnClickListener { callback?.subscribeClick(index) }) | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.coordinatorlayout.widget.CoordinatorLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<com.google.android.material.appbar.AppBarLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<androidx.appcompat.widget.Toolbar | ||
android:id="@+id/toolbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:layout_scrollFlags="scroll|enterAlways"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal"> | ||
|
||
<EditText | ||
android:id="@+id/search" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="2" | ||
android:hint="@string/edit_insert_query" | ||
android:inputType="text" | ||
android:importantForAutofill="no" | ||
/> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
android:id="@+id/search_bttn" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="5" | ||
android:text="@string/bttn_ok" | ||
/> | ||
|
||
</LinearLayout> | ||
|
||
</androidx.appcompat.widget.Toolbar> | ||
|
||
</com.google.android.material.appbar.AppBarLayout> | ||
|
||
<com.airbnb.epoxy.EpoxyRecyclerView | ||
android:id="@+id/list" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:clipToPadding="true" | ||
android:scrollbars="vertical" | ||
android:fadeScrollbars="true" | ||
app:itemSpacing="16dp" | ||
app:layoutManager="@string/linear_layout" | ||
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> | ||
|
||
</androidx.coordinatorlayout.widget.CoordinatorLayout> |
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