diff --git a/.editorconfig b/.editorconfig index 735ef93e..db42d4dc 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,3 +1,3 @@ [*.{kt,kts}] # allow wild cards input -disabled_rules=no-wildcard-imports,import-ordering \ No newline at end of file +ktlint_disabled_rules=no-wildcard-imports,import-ordering,spacing-between-declarations-with-annotations,no-empty-first-line-in-method-block \ No newline at end of file diff --git a/build.gradle b/build.gradle index 875e6adc..9745cbfe 100644 --- a/build.gradle +++ b/build.gradle @@ -2,52 +2,52 @@ buildscript { ext { - android_gradle_ver = '7.1.1' + android_gradle_ver = '7.2.2' - compile_sdk_ver = 31 - build_tools_ver = '31.0.0' + compile_sdk_ver = 33 + build_tools_ver = '33.0.0' min_sdk_ver = 21 - compile_sdk_ver = 31 + compile_sdk_ver = 33 - version_code = 7 - version_name = "1.1.0-beta02" + version_code = 8 + version_name = "1.1.0-beta03" java_target = JavaVersion.VERSION_11 jvm_target = '11' - kotlin_ver = '1.6.10' - coroutines_ver = '1.6.0' + kotlin_ver = '1.7.10' + coroutines_ver = '1.6.4' - ksp_ver = '1.6.10-1.0.2' + ksp_ver = "$kotlin_ver-1.0.6" - hilt_ver = "2.40.5" + hilt_ver = "2.43.2" ax_hilt_ver = "1.0.0" - ax_core_ver = '1.7.0' - ax_appcompat_ver = '1.4.1' - ax_activity_ver = '1.4.0' - ax_annot_ver = '1.3.0' + ax_core_ver = '1.8.0' + ax_appcompat_ver = '1.5.0' + ax_activity_ver = '1.5.1' + ax_annot_ver = '1.4.0' ax_browser_ver = '1.4.0' - constr_ver = '2.1.3' + constr_ver = '2.1.4' retrofit_ver = '2.9.0' moshi_ver = '1.13.0' - okhttp_ver = '4.9.3' - mdc_ver = '1.5.0' + okhttp_ver = '4.10.0' + mdc_ver = '1.6.1' epoxy_ver = '4.6.4' oauth2_ver = 'a364454d6f' // '1.2.2' - ktlint_ver = '0.42.1' + ktlint_ver = '0.47.0' detekt_ver = '1.19.0' test_ver = '1.4.0' espresso_ver = '3.4.0' junit_ver = '1.1.3' - leakcanary_ver = '2.8.1' - mockito_ver = '4.3.1' + leakcanary_ver = '2.9.1' + mockito_ver = '4.7.0' arch_core_ver = '2.1.0' orchestrator_ver = '1.3.0' diff --git a/gradle.properties b/gradle.properties index 1e4598f4..44b76823 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,6 @@ org.gradle.vfs.watch=true android.useAndroidX=true -kapt.use.worker.api=true kapt.incremental.apt=true kotlin.code.style=official \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c4113d8c..f28fb94a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip diff --git a/lib/src/main/java/com/kirkbushman/araw/RedditClient.kt b/lib/src/main/java/com/kirkbushman/araw/RedditClient.kt index da86955f..65917607 100644 --- a/lib/src/main/java/com/kirkbushman/araw/RedditClient.kt +++ b/lib/src/main/java/com/kirkbushman/araw/RedditClient.kt @@ -25,13 +25,13 @@ class RedditClient @JvmOverloads constructor( @Volatile private var retrofit: Retrofit? = null + @Volatile private var api: RedditApi? = null @Synchronized fun getRetrofit(logging: Boolean = false): Retrofit { return synchronized(this) { - if (retrofit == null) { retrofit = buildRetrofit(logging) } @@ -43,7 +43,6 @@ class RedditClient @JvmOverloads constructor( @Synchronized fun getApi(logging: Boolean = false): RedditApi { return synchronized(this) { - if (api == null) { api = getRetrofit(logging).create(RedditApi::class.java) } diff --git a/lib/src/main/java/com/kirkbushman/araw/adapters/PolyJsonAdapterFactory.kt b/lib/src/main/java/com/kirkbushman/araw/adapters/PolyJsonAdapterFactory.kt index 6be3561b..3f8bce48 100644 --- a/lib/src/main/java/com/kirkbushman/araw/adapters/PolyJsonAdapterFactory.kt +++ b/lib/src/main/java/com/kirkbushman/araw/adapters/PolyJsonAdapterFactory.kt @@ -16,7 +16,6 @@ class PolyJsonAdapterFactory( ) : JsonAdapter.Factory { override fun create(type: Type, annotations: Set, moshi: Moshi): JsonAdapter? { - if (Types.getRawType(type) != baseType || annotations.isNotEmpty()) { return null } diff --git a/lib/src/main/java/com/kirkbushman/araw/clients/AccountsClient.kt b/lib/src/main/java/com/kirkbushman/araw/clients/AccountsClient.kt index ee8c7a08..d70cd657 100644 --- a/lib/src/main/java/com/kirkbushman/araw/clients/AccountsClient.kt +++ b/lib/src/main/java/com/kirkbushman/araw/clients/AccountsClient.kt @@ -25,7 +25,6 @@ class AccountsClient( private var currentUser: Me? = null fun getCurrentUser(): Me? { - if (currentUser == null) { currentUser = me() } @@ -35,7 +34,6 @@ class AccountsClient( @WorkerThread fun me(): Me? { - val authMap = getHeaderMap() val req = api.me( rawJson = (if (disableLegacyEncoding) 1 else null), @@ -55,7 +53,6 @@ class AccountsClient( // todo check why it is not working @WorkerThread fun myBlocked(): Any? { - val authMap = getHeaderMap() val req = api.myBlocked( rawJson = (if (disableLegacyEncoding) 1 else null), @@ -72,7 +69,6 @@ class AccountsClient( @WorkerThread fun myFriends(): List? { - val authMap = getHeaderMap() val req = api.myFriends( rawJson = (if (disableLegacyEncoding) 1 else null), @@ -89,7 +85,6 @@ class AccountsClient( @WorkerThread fun myKarma(): List? { - val authMap = getHeaderMap() val req = api.myKarma( rawJson = (if (disableLegacyEncoding) 1 else null), @@ -106,7 +101,6 @@ class AccountsClient( @WorkerThread fun myPrefs(): Prefs? { - val authMap = getHeaderMap() val req = api.myPrefs( rawJson = (if (disableLegacyEncoding) 1 else null), @@ -123,7 +117,6 @@ class AccountsClient( @WorkerThread fun myTrophies(): List? { - val authMap = getHeaderMap() val req = api.myTrophies( rawJson = (if (disableLegacyEncoding) 1 else null), @@ -147,7 +140,6 @@ class AccountsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): ContributionsFetcher { - return createContributionsFetcher( where = ContributionsFetcher.USER_CONTRIB_OVERVIEW, limit = limit, @@ -165,7 +157,6 @@ class AccountsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): ContributionsFetcher { - return createContributionsFetcher( where = ContributionsFetcher.USER_CONTRIB_SUBMITTED, limit = limit, @@ -183,7 +174,6 @@ class AccountsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): ContributionsFetcher { - return createContributionsFetcher( where = ContributionsFetcher.USER_CONTRIB_COMMENTS, limit = limit, @@ -201,7 +191,6 @@ class AccountsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): ContributionsFetcher { - return createContributionsFetcher( where = ContributionsFetcher.USER_CONTRIB_SAVED, limit = limit, @@ -219,7 +208,6 @@ class AccountsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): ContributionsFetcher { - return createContributionsFetcher( where = ContributionsFetcher.USER_CONTRIB_HIDDEN, limit = limit, @@ -237,7 +225,6 @@ class AccountsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): ContributionsFetcher { - return createContributionsFetcher( where = ContributionsFetcher.USER_CONTRIB_UPVOTED, limit = limit, @@ -255,7 +242,6 @@ class AccountsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): ContributionsFetcher { - return createContributionsFetcher( where = ContributionsFetcher.USER_CONTRIB_DOWNVOTED, limit = limit, @@ -273,7 +259,6 @@ class AccountsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): ContributionsFetcher { - return createContributionsFetcher( where = ContributionsFetcher.USER_CONTRIB_GILDED, limit = limit, @@ -293,7 +278,6 @@ class AccountsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): ContributionsFetcher { - return ContributionsFetcher( api = api, getUsername = { getCurrentUser()!!.fullname }, @@ -312,7 +296,6 @@ class AccountsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): SubredditsFetcher { - return createSubredditsFetcher( where = SubredditsFetcher.SUBREDDITS_MINE_SUBSCRIBER, limit = limit @@ -325,7 +308,6 @@ class AccountsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): SubredditsFetcher { - return createSubredditsFetcher( where = SubredditsFetcher.SUBREDDITS_MINE_CONTRIBUTOR, limit = limit @@ -338,7 +320,6 @@ class AccountsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): SubredditsFetcher { - return createSubredditsFetcher( where = SubredditsFetcher.SUBREDDITS_MINE_MODERATOR, limit = limit @@ -351,7 +332,6 @@ class AccountsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): SubredditsFetcher { - return createSubredditsFetcher( where = SubredditsFetcher.SUBREDDITS_MINE_STREAMS, limit = limit @@ -366,7 +346,6 @@ class AccountsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): SubredditsFetcher { - return SubredditsFetcher( api = api, where = where, diff --git a/lib/src/main/java/com/kirkbushman/araw/clients/MessagesClient.kt b/lib/src/main/java/com/kirkbushman/araw/clients/MessagesClient.kt index 933fff4c..3fec8b4b 100644 --- a/lib/src/main/java/com/kirkbushman/araw/clients/MessagesClient.kt +++ b/lib/src/main/java/com/kirkbushman/araw/clients/MessagesClient.kt @@ -35,7 +35,6 @@ class MessagesClient( limit: Long = Fetcher.DEFAULT_LIMIT ): InboxFetcher { - return createInboxFetcher( where = InboxFetcher.MESSAGES_UNREAD, limit = limit @@ -48,7 +47,6 @@ class MessagesClient( limit: Long = Fetcher.DEFAULT_LIMIT ): InboxFetcher { - return createInboxFetcher( where = InboxFetcher.MESSAGES_MESSAGES, limit = limit @@ -61,7 +59,6 @@ class MessagesClient( limit: Long = Fetcher.DEFAULT_LIMIT ): InboxFetcher { - return createInboxFetcher( where = InboxFetcher.MESSAGES_SENT, limit = limit @@ -74,7 +71,6 @@ class MessagesClient( limit: Long = Fetcher.DEFAULT_LIMIT ): InboxFetcher { - return createInboxFetcher( where = InboxFetcher.MESSAGES_COMMENTS, limit = limit @@ -87,7 +83,6 @@ class MessagesClient( limit: Long = Fetcher.DEFAULT_LIMIT ): InboxFetcher { - return createInboxFetcher( where = InboxFetcher.MESSAGES_SELF_REPLY, limit = limit @@ -100,7 +95,6 @@ class MessagesClient( limit: Long = Fetcher.DEFAULT_LIMIT ): InboxFetcher { - return createInboxFetcher( where = InboxFetcher.MESSAGES_MENTIONS, limit = limit @@ -115,7 +109,6 @@ class MessagesClient( limit: Long = Fetcher.DEFAULT_LIMIT ): InboxFetcher { - return InboxFetcher( api = api, where = where, @@ -132,7 +125,6 @@ class MessagesClient( @WorkerThread fun deleteMessage(fullname: String): Any? { - val authMap = getHeaderMap() val req = api.deleteMessage( id = fullname, @@ -155,7 +147,6 @@ class MessagesClient( @WorkerThread fun markAsRead(read: Boolean, fullname: String): Any? { - val authMap = getHeaderMap() val req = if (read) { api.readMessage( @@ -186,7 +177,6 @@ class MessagesClient( @WorkerThread fun vote(vote: Vote, fullname: String): Any? { - val authMap = getHeaderMap() val req = api.vote( id = fullname, @@ -205,19 +195,16 @@ class MessagesClient( @WorkerThread fun markAllAsRead(filters: Array?): Any? { - return markAllAsRead(filters?.joinToString(separator = ",") { it.fullname }) } @WorkerThread fun markAllAsRead(filters: List?): Any? { - return markAllAsRead(filters?.joinToString(separator = ",") { it.fullname }) } @WorkerThread fun markAllAsRead(filters: String?): Any? { - val authMap = getHeaderMap() val req = api.readAllMessages( filters = filters ?: "", diff --git a/lib/src/main/java/com/kirkbushman/araw/clients/MultisClient.kt b/lib/src/main/java/com/kirkbushman/araw/clients/MultisClient.kt index 6d11830a..df1ab193 100644 --- a/lib/src/main/java/com/kirkbushman/araw/clients/MultisClient.kt +++ b/lib/src/main/java/com/kirkbushman/araw/clients/MultisClient.kt @@ -30,7 +30,6 @@ class MultisClient( limit: Long = Fetcher.DEFAULT_LIMIT ): MultiSubmissionsFetcher { - return createMultiSubmissionsFetcher( username = multi.ownerName, multiname = multi.name, @@ -52,7 +51,6 @@ class MultisClient( limit: Long = Fetcher.DEFAULT_LIMIT ): MultiSubmissionsFetcher { - return MultiSubmissionsFetcher( api = api, username = username, @@ -91,7 +89,6 @@ class MultisClient( @WorkerThread fun myMultis(): List? { - val authMap = getHeaderMap() val req = api.myMultis( rawJson = (if (disableLegacyEncoding) 1 else null), @@ -108,7 +105,6 @@ class MultisClient( @WorkerThread fun redditorMultis(username: String): List? { - val authMap = getHeaderMap() val req = api.redditorMultis( username = username, @@ -130,7 +126,6 @@ class MultisClient( multi: Multi ): Boolean { - return deleteMulti( username = multi.ownerName, multiname = multi.name @@ -144,7 +139,6 @@ class MultisClient( multiname: String ): Boolean { - val authMap = getHeaderMap() val req = api.deleteMulti( username = username, @@ -163,7 +157,6 @@ class MultisClient( multi: Multi ): MultiDescription? { - return multiDescription( username = multi.ownerName, multiname = multi.name @@ -177,7 +170,6 @@ class MultisClient( multiname: String ): MultiDescription? { - val authMap = getHeaderMap() val req = api.multiDescription( username = username, @@ -201,7 +193,6 @@ class MultisClient( description: String ): Boolean { - return setMultiDescription( username = multi.ownerName, multiname = multi.name, @@ -217,7 +208,6 @@ class MultisClient( description: String ): Boolean { - val authMap = getHeaderMap() val req = api.setMultiDescription( username = username, @@ -238,7 +228,6 @@ class MultisClient( subname: String ): MultiSub? { - val authMap = getHeaderMap() val req = api.multiSubreddit( username = username, @@ -264,7 +253,6 @@ class MultisClient( subname: String ): MultiSub? { - val authMap = getHeaderMap() val req = api.addSubredditToMulti( username = username, @@ -291,7 +279,6 @@ class MultisClient( subname: String ): Boolean { - val authMap = getHeaderMap() val req = api.removeSubredditToMulti( username = username, diff --git a/lib/src/main/java/com/kirkbushman/araw/clients/SearchClient.kt b/lib/src/main/java/com/kirkbushman/araw/clients/SearchClient.kt index 37e0b835..6e804b08 100644 --- a/lib/src/main/java/com/kirkbushman/araw/clients/SearchClient.kt +++ b/lib/src/main/java/com/kirkbushman/araw/clients/SearchClient.kt @@ -26,7 +26,6 @@ class SearchClient( includeOver18: Boolean? = null, includeUnadvertisable: Boolean? = null ): SubredditSearchResult? { - val authMap = getHeaderMap() val req = api.searchSubreddits( query = query, @@ -61,7 +60,6 @@ class SearchClient( restrictToSubreddit: Boolean = false ): SubmissionsSearchFetcher { - return SubmissionsSearchFetcher( api = api, subreddit = subreddit, @@ -89,7 +87,6 @@ class SearchClient( showAll: Boolean = false ): SubredditsSearchFetcher { - return SubredditsSearchFetcher( api = api, query = query, @@ -115,7 +112,6 @@ class SearchClient( showAll: Boolean = false ): RedditorsSearchFetcher { - return RedditorsSearchFetcher( api = api, query = query, diff --git a/lib/src/main/java/com/kirkbushman/araw/clients/SubredditsClient.kt b/lib/src/main/java/com/kirkbushman/araw/clients/SubredditsClient.kt index 9c78505c..660e71e8 100644 --- a/lib/src/main/java/com/kirkbushman/araw/clients/SubredditsClient.kt +++ b/lib/src/main/java/com/kirkbushman/araw/clients/SubredditsClient.kt @@ -36,7 +36,6 @@ class SubredditsClient( @WorkerThread fun subreddit(subreddit: String): SubredditData? { - val authMap = getHeaderMap() val req = api.subreddit( subreddit = subreddit, @@ -54,7 +53,6 @@ class SubredditsClient( @WorkerThread fun subreddits(vararg ids: String): List? { - val authMap = getHeaderMap() val req = api.subreddits( subredditIds = ids.joinToString { "t5_$it" }, @@ -77,7 +75,6 @@ class SubredditsClient( @WorkerThread fun subredditBanned(subredditName: String): List? { - val authMap = getHeaderMap() val req = api.subredditInfo( subreddit = subredditName, @@ -101,7 +98,6 @@ class SubredditsClient( @WorkerThread fun subredditMuted(subredditName: String): List? { - val authMap = getHeaderMap() val req = api.subredditInfo( subreddit = subredditName, @@ -125,7 +121,6 @@ class SubredditsClient( @WorkerThread fun subredditWikiBanned(subredditName: String): List? { - val authMap = getHeaderMap() val req = api.subredditInfo( subreddit = subredditName, @@ -149,7 +144,6 @@ class SubredditsClient( @WorkerThread fun subredditContributors(subredditName: String): List? { - val authMap = getHeaderMap() val req = api.subredditInfo( subreddit = subredditName, @@ -173,7 +167,6 @@ class SubredditsClient( @WorkerThread fun subredditWikiContributors(subredditName: String): List? { - val authMap = getHeaderMap() val req = api.subredditInfo( subreddit = subredditName, @@ -197,7 +190,6 @@ class SubredditsClient( @WorkerThread fun subredditModerators(subredditName: String): List? { - val authMap = getHeaderMap() val req = api.subredditInfo( subreddit = subredditName, @@ -221,7 +213,6 @@ class SubredditsClient( @WorkerThread fun rules(subreddit: String): Array? { - val authMap = getHeaderMap() val req = api.rules( subreddit = subreddit, @@ -239,13 +230,11 @@ class SubredditsClient( @WorkerThread fun subredditFlairs(subreddit: SubredditData): List? { - return subredditFlairs(subreddit.displayName) } @WorkerThread fun subredditFlairs(subreddit: String): List? { - val authMap = getHeaderMap() val req = api.subredditFlairs( subreddit = subreddit, @@ -270,7 +259,6 @@ class SubredditsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): SubmissionsFetcher { - return createSubmissionsFetcher( subreddit = SubmissionsFetcher.SUBMISSIONS_FRONTPAGE, sorting = sorting, @@ -288,7 +276,6 @@ class SubredditsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): SubmissionsFetcher { - return createSubmissionsFetcher( subreddit = SubmissionsFetcher.SUBMISSIONS_ALL, sorting = sorting, @@ -306,7 +293,6 @@ class SubredditsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): SubmissionsFetcher { - return createSubmissionsFetcher( subreddit = SubmissionsFetcher.SUBMISSIONS_POPULAR, sorting = sorting, @@ -324,7 +310,6 @@ class SubredditsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): SubmissionsFetcher { - return createSubmissionsFetcher( subreddit = SubmissionsFetcher.SUBMISSIONS_FRIENDS, sorting = sorting, @@ -342,7 +327,6 @@ class SubredditsClient( limit: Long = Fetcher.DEFAULT_LIMIT ): SubmissionsFetcher { - return createSubmissionsFetcher( subreddit = SubmissionsFetcher.SUBMISSIONS_ORIGINAL, sorting = sorting, @@ -359,10 +343,9 @@ class SubredditsClient( timePeriod: TimePeriod = SubmissionsFetcher.DEFAULT_TIMEPERIOD, @IntRange(from = Fetcher.MIN_LIMIT, to = Fetcher.MAX_LIMIT) - limit: Long = Fetcher.DEFAULT_LIMIT, + limit: Long = Fetcher.DEFAULT_LIMIT ): SubmissionsFetcher { - return SubmissionsFetcher( api = api, subreddit = subreddit, @@ -398,7 +381,6 @@ class SubredditsClient( showErrorList: Boolean? = null ): SubmitResponse? { - return submit( subredditName = subreddit.displayName, @@ -446,7 +428,6 @@ class SubredditsClient( showErrorList: Boolean? = null ): SubmitResponse? { - val authMap = getHeaderMap() val req = api.submit( subreddit = subredditName, @@ -484,7 +465,6 @@ class SubredditsClient( @WorkerThread fun subscribe(subreddit: Subreddit, skipInitialDefaults: Boolean = true): Any? { - if (subreddit.isSubscriber == null) { throw IllegalStateException("isSubscriber is null! Is this a userless grant...?") } @@ -506,7 +486,6 @@ class SubredditsClient( skipInitialDefaults: Boolean = true ): Any? { - return subscribe( subredditNames = listOf(subredditName), @@ -527,7 +506,6 @@ class SubredditsClient( skipInitialDefaults: Boolean = true ): Any? { - val authMap = getHeaderMap() val req = api.subscribe( subredditIds = subredditIds?.joinToString(separator = ","), diff --git a/lib/src/main/java/com/kirkbushman/araw/clients/WikisClient.kt b/lib/src/main/java/com/kirkbushman/araw/clients/WikisClient.kt index 9dc9ed64..76d27541 100644 --- a/lib/src/main/java/com/kirkbushman/araw/clients/WikisClient.kt +++ b/lib/src/main/java/com/kirkbushman/araw/clients/WikisClient.kt @@ -24,7 +24,6 @@ class WikisClient( @WorkerThread @Throws(WikiDisabledException::class) fun wiki(subreddit: String): WikiPage? { - val authMap = getHeaderMap() val req = api.wiki( subreddit = subreddit, @@ -34,7 +33,6 @@ class WikisClient( val res = req.execute() if (!res.isSuccessful) { - val errorBody = res.errorBody() if (errorBody != null && errorBody.string().contains("WIKI_DISABLED")) { @@ -54,7 +52,6 @@ class WikisClient( @WorkerThread fun wikiPage(subreddit: String, page: String): WikiPage? { - val authMap = getHeaderMap() val req = api.wikiPage( subreddit = subreddit, @@ -78,7 +75,6 @@ class WikisClient( @WorkerThread fun wikiPages(subreddit: String): List? { - val authMap = getHeaderMap() val req = api.wikiPages( subreddit = subreddit, @@ -111,7 +107,6 @@ class WikisClient( page: String ): List? { - val authMap = getHeaderMap() val req = api.wikiRevision( subreddit = subreddit, @@ -135,7 +130,6 @@ class WikisClient( @WorkerThread fun wikiRevisions(subreddit: String): List? { - val authMap = getHeaderMap() val req = api.wikiRevisions( subreddit = subreddit, diff --git a/lib/src/main/java/com/kirkbushman/araw/fetcher/CommentsFetcher.kt b/lib/src/main/java/com/kirkbushman/araw/fetcher/CommentsFetcher.kt index 80860f70..e6d725e6 100644 --- a/lib/src/main/java/com/kirkbushman/araw/fetcher/CommentsFetcher.kt +++ b/lib/src/main/java/com/kirkbushman/araw/fetcher/CommentsFetcher.kt @@ -43,7 +43,6 @@ class CommentsFetcher( nextToken: String?, setTokens: (previous: String?, next: String?) -> Unit ): List? { - val req = api.fetchComments( submissionId = submissionId, focusedCommentId = focusedCommentId, diff --git a/lib/src/main/java/com/kirkbushman/araw/fetcher/InboxFetcher.kt b/lib/src/main/java/com/kirkbushman/araw/fetcher/InboxFetcher.kt index f63e53e6..fcb77066 100644 --- a/lib/src/main/java/com/kirkbushman/araw/fetcher/InboxFetcher.kt +++ b/lib/src/main/java/com/kirkbushman/araw/fetcher/InboxFetcher.kt @@ -36,7 +36,6 @@ class InboxFetcher( nextToken: String?, setTokens: (previous: String?, next: String?) -> Unit ): List? { - val req = api.fetchMessages( where = where, limit = getLimit(), diff --git a/lib/src/main/java/com/kirkbushman/araw/fetcher/SubmissionsFetcher.kt b/lib/src/main/java/com/kirkbushman/araw/fetcher/SubmissionsFetcher.kt index 32e15bfe..964bb6f5 100644 --- a/lib/src/main/java/com/kirkbushman/araw/fetcher/SubmissionsFetcher.kt +++ b/lib/src/main/java/com/kirkbushman/araw/fetcher/SubmissionsFetcher.kt @@ -42,7 +42,6 @@ class SubmissionsFetcher( nextToken: String?, setTokens: (previous: String?, next: String?) -> Unit ): List? { - val req = if (subreddit != "") { api.fetchSubmissions( subreddit = subreddit, diff --git a/lib/src/main/java/com/kirkbushman/araw/helpers/AuthAppHelper.kt b/lib/src/main/java/com/kirkbushman/araw/helpers/AuthAppHelper.kt index 797faa48..b562d3ed 100644 --- a/lib/src/main/java/com/kirkbushman/araw/helpers/AuthAppHelper.kt +++ b/lib/src/main/java/com/kirkbushman/araw/helpers/AuthAppHelper.kt @@ -41,13 +41,10 @@ class AuthAppHelper( private var returnUrl: String? = null fun startWebViewAuthentication(webView: WebView, onBearerFetched: (String) -> Unit) { - webView.webViewClient = object : WebViewClient() { override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) { - if (url != null && isRedirectedUrl(url)) { - onBearerFetched(url) } } @@ -66,14 +63,12 @@ class AuthAppHelper( } fun getRedditClient(url: String): RedditClient? { - returnUrl = url return getRedditClient() } override fun getRedditClient(): RedditClient? { - val savedClient = getSavedRedditClient() if (savedClient != null) { return savedClient @@ -85,7 +80,6 @@ class AuthAppHelper( val bearer = auth.authenticate(returnUrl) if (bearer != null) { - return RedditClient( bearer = bearer, disableLegacyEncoding = disableLegacyEncoding, diff --git a/lib/src/main/java/com/kirkbushman/araw/helpers/AuthHelper.kt b/lib/src/main/java/com/kirkbushman/araw/helpers/AuthHelper.kt index 4d651d87..14a494fc 100644 --- a/lib/src/main/java/com/kirkbushman/araw/helpers/AuthHelper.kt +++ b/lib/src/main/java/com/kirkbushman/araw/helpers/AuthHelper.kt @@ -22,7 +22,6 @@ abstract class AuthHelper( } fun getSavedBearer(): TokenBearer? { - if (auth.hasSavedBearer()) { return auth.retrieveSavedBearer() } @@ -31,12 +30,9 @@ abstract class AuthHelper( } fun getSavedRedditClient(): RedditClient? { - if (auth.hasSavedBearer()) { - val bearer = getSavedBearer() if (bearer != null) { - return RedditClient( bearer = bearer, disableLegacyEncoding = disableLegacyEncoding, @@ -51,7 +47,6 @@ abstract class AuthHelper( abstract fun getRedditClient(): RedditClient? fun forceRenew() { - if (hasSavedBearer()) { val bearer = getSavedBearer() bearer?.renewToken() @@ -59,7 +54,6 @@ abstract class AuthHelper( } fun forceRevoke() { - if (hasSavedBearer()) { val bearer = getSavedBearer() bearer?.revokeToken() diff --git a/lib/src/main/java/com/kirkbushman/araw/helpers/AuthScriptHelper.kt b/lib/src/main/java/com/kirkbushman/araw/helpers/AuthScriptHelper.kt index ae6d94c3..8076430b 100644 --- a/lib/src/main/java/com/kirkbushman/araw/helpers/AuthScriptHelper.kt +++ b/lib/src/main/java/com/kirkbushman/araw/helpers/AuthScriptHelper.kt @@ -38,7 +38,6 @@ class AuthScriptHelper( } override fun getRedditClient(): RedditClient? { - val savedClient = getSavedRedditClient() if (savedClient != null) { return savedClient @@ -46,7 +45,6 @@ class AuthScriptHelper( val bearer = auth.authenticate() if (bearer != null) { - return RedditClient( bearer = bearer, disableLegacyEncoding = disableLegacyEncoding, diff --git a/lib/src/main/java/com/kirkbushman/araw/helpers/AuthUserlessHelper.kt b/lib/src/main/java/com/kirkbushman/araw/helpers/AuthUserlessHelper.kt index f6e714c0..38c51985 100644 --- a/lib/src/main/java/com/kirkbushman/araw/helpers/AuthUserlessHelper.kt +++ b/lib/src/main/java/com/kirkbushman/araw/helpers/AuthUserlessHelper.kt @@ -34,7 +34,6 @@ class AuthUserlessHelper( } override fun getRedditClient(): RedditClient? { - val savedClient = getSavedRedditClient() if (savedClient != null) { return savedClient @@ -42,7 +41,6 @@ class AuthUserlessHelper( val bearer = auth.authenticate() if (bearer != null) { - return RedditClient( bearer = bearer, disableLegacyEncoding = disableLegacyEncoding, diff --git a/lib/src/main/java/com/kirkbushman/araw/http/base/EnvelopeKind.kt b/lib/src/main/java/com/kirkbushman/araw/http/base/EnvelopeKind.kt index fc3eaa63..2b50a9a7 100644 --- a/lib/src/main/java/com/kirkbushman/araw/http/base/EnvelopeKind.kt +++ b/lib/src/main/java/com/kirkbushman/araw/http/base/EnvelopeKind.kt @@ -4,21 +4,37 @@ import com.squareup.moshi.Json enum class EnvelopeKind(val value: String) { - @Json(name = "t1") Comment("t1"), - @Json(name = "t2") Account("t2"), - @Json(name = "t3") Link("t3"), - @Json(name = "t4") Message("t4"), - @Json(name = "t5") Subreddit("t5"), - @Json(name = "t6") Award("t6"), + @Json(name = "t1") + Comment("t1"), + @Json(name = "t2") + Account("t2"), + @Json(name = "t3") + Link("t3"), + @Json(name = "t4") + Message("t4"), + @Json(name = "t5") + Subreddit("t5"), + @Json(name = "t6") + Award("t6"), - @Json(name = "Listing") Listing("Listing"), - @Json(name = "wikipage") Wikipage("wikipage"), - @Json(name = "wikipagelisting") WikipageListing("wikipagelisting"), - @Json(name = "more") More("more"), - @Json(name = "TrophyList") TrophyList("TrophyList"), - @Json(name = "UserList") UserList("UserList"), - @Json(name = "KarmaList") KarmaList("KarmaList"), - @Json(name = "ModeratedList") ModeratedList("ModeratedList"), - @Json(name = "LabeledMulti") LabeledMulti("LabeledMulti"), - @Json(name = "LabeledMultiDescription") LabeledMultiDescription("LabeledMultiDescription") + @Json(name = "Listing") + Listing("Listing"), + @Json(name = "wikipage") + Wikipage("wikipage"), + @Json(name = "wikipagelisting") + WikipageListing("wikipagelisting"), + @Json(name = "more") + More("more"), + @Json(name = "TrophyList") + TrophyList("TrophyList"), + @Json(name = "UserList") + UserList("UserList"), + @Json(name = "KarmaList") + KarmaList("KarmaList"), + @Json(name = "ModeratedList") + ModeratedList("ModeratedList"), + @Json(name = "LabeledMulti") + LabeledMulti("LabeledMulti"), + @Json(name = "LabeledMultiDescription") + LabeledMultiDescription("LabeledMultiDescription") } diff --git a/lib/src/main/java/com/kirkbushman/araw/models/Multi.kt b/lib/src/main/java/com/kirkbushman/araw/models/Multi.kt index 49d70db8..471c5018 100644 --- a/lib/src/main/java/com/kirkbushman/araw/models/Multi.kt +++ b/lib/src/main/java/com/kirkbushman/araw/models/Multi.kt @@ -62,7 +62,7 @@ data class Multi( val subreddits: List, @Json(name = "visibility") - val visibility: String, + val visibility: String ) : Created, Parcelable diff --git a/lib/src/main/java/com/kirkbushman/araw/models/commons/Images.kt b/lib/src/main/java/com/kirkbushman/araw/models/commons/Images.kt index 014d2d1a..f888a9f7 100644 --- a/lib/src/main/java/com/kirkbushman/araw/models/commons/Images.kt +++ b/lib/src/main/java/com/kirkbushman/araw/models/commons/Images.kt @@ -28,7 +28,6 @@ data class Images( } override fun equals(other: Any?): Boolean { - if (other == null) { return false } diff --git a/lib/src/main/java/com/kirkbushman/araw/models/commons/SubmissionPreview.kt b/lib/src/main/java/com/kirkbushman/araw/models/commons/SubmissionPreview.kt index 373a57bf..eceedc12 100644 --- a/lib/src/main/java/com/kirkbushman/araw/models/commons/SubmissionPreview.kt +++ b/lib/src/main/java/com/kirkbushman/araw/models/commons/SubmissionPreview.kt @@ -21,7 +21,6 @@ data class SubmissionPreview( ) : Parcelable { fun id(): String? { - if (images.isEmpty()) { return null } @@ -30,7 +29,6 @@ data class SubmissionPreview( } fun source(): ImageDetail? { - if (images.isEmpty()) { return null } @@ -39,7 +37,6 @@ data class SubmissionPreview( } fun lowerRes(): ImageDetail? { - if (images.isEmpty()) { return null } @@ -48,7 +45,6 @@ data class SubmissionPreview( } fun higherRes(): ImageDetail? { - if (images.isEmpty()) { return null } @@ -57,7 +53,6 @@ data class SubmissionPreview( } fun variants(): ImageVariants? { - if (images.isEmpty()) { return null } diff --git a/lib/src/main/java/com/kirkbushman/araw/utils/CommentDataIterator.kt b/lib/src/main/java/com/kirkbushman/araw/utils/CommentDataIterator.kt index 2fd5b04c..4707cf01 100644 --- a/lib/src/main/java/com/kirkbushman/araw/utils/CommentDataIterator.kt +++ b/lib/src/main/java/com/kirkbushman/araw/utils/CommentDataIterator.kt @@ -20,14 +20,12 @@ class CommentDataIterator : Iterator { } override fun next(): CommentData { - if (!hasNext()) { throw NoSuchElementException() } val item = stack.pop() if (item.hasReplies) { - item.replies ?.asReversed() ?.forEach { stack.push(it) } diff --git a/lib/src/main/java/com/kirkbushman/araw/utils/Extensions.kt b/lib/src/main/java/com/kirkbushman/araw/utils/Extensions.kt index 9b452d15..0c73152a 100644 --- a/lib/src/main/java/com/kirkbushman/araw/utils/Extensions.kt +++ b/lib/src/main/java/com/kirkbushman/araw/utils/Extensions.kt @@ -109,12 +109,10 @@ val WikiRevision.timestampDate: Date } fun List.toLinearList(): List { - val list = ArrayList() treeIterator() .forEach { - if (it is Comment) { val item = it.copy() item.replies = null diff --git a/lib/src/main/java/com/kirkbushman/araw/utils/Utils.kt b/lib/src/main/java/com/kirkbushman/araw/utils/Utils.kt index a2b7fdf5..f366dd31 100644 --- a/lib/src/main/java/com/kirkbushman/araw/utils/Utils.kt +++ b/lib/src/main/java/com/kirkbushman/araw/utils/Utils.kt @@ -26,12 +26,10 @@ object Utils { const val BASE_URL = "https://oauth.reddit.com" fun buildRetrofit(logging: Boolean): Retrofit { - return buildRetrofit(BASE_URL, logging) } fun buildRetrofit(baseUrl: String, logging: Boolean): Retrofit { - val moshi = Moshi.Builder() .add( PolymorphicJsonAdapterFactory.of(EnvelopedData::class.java, "kind") @@ -83,7 +81,6 @@ object Utils { val nullRepliesInterceptor = NullRepliesInterceptor val httpClient = if (logging) { - val logger = HttpLoggingInterceptor() logger.level = HttpLoggingInterceptor.Level.BODY @@ -93,7 +90,6 @@ object Utils { .addInterceptor(logger) .build() } else { - OkHttpClient .Builder() .addInterceptor(nullRepliesInterceptor) diff --git a/sampleapp/src/androidTest/java/com/kirkbushman/sampleapp/instrumented/TestUtils.kt b/sampleapp/src/androidTest/java/com/kirkbushman/sampleapp/instrumented/TestUtils.kt index ed2f84ae..557f9b41 100644 --- a/sampleapp/src/androidTest/java/com/kirkbushman/sampleapp/instrumented/TestUtils.kt +++ b/sampleapp/src/androidTest/java/com/kirkbushman/sampleapp/instrumented/TestUtils.kt @@ -31,19 +31,21 @@ object TestUtils { fun getTokenBearer(auth: ScriptAuth): TokenBearer { return ( - if (auth.hasSavedBearer()) + if (auth.hasSavedBearer()) { auth.retrieveSavedBearer() - else + } else { auth.authenticate() + } ) ?: throw IllegalStateException("Bearer cannot be null!") } fun getTokenBearer(auth: UserlessAuth): TokenBearer { return ( - if (auth.hasSavedBearer()) + if (auth.hasSavedBearer()) { auth.retrieveSavedBearer() - else + } else { auth.authenticate() + } ) ?: throw IllegalStateException("Bearer cannot be null!") } diff --git a/sampleapp/src/androidTest/java/com/kirkbushman/sampleapp/instrumented/tests/CommentDataTest.kt b/sampleapp/src/androidTest/java/com/kirkbushman/sampleapp/instrumented/tests/CommentDataTest.kt index b0f4b487..e75614a7 100644 --- a/sampleapp/src/androidTest/java/com/kirkbushman/sampleapp/instrumented/tests/CommentDataTest.kt +++ b/sampleapp/src/androidTest/java/com/kirkbushman/sampleapp/instrumented/tests/CommentDataTest.kt @@ -47,7 +47,6 @@ class CommentDataTest { @Test fun linearCommentsTest() { - val selectedSubmission = submissions .filter { it.numComments > 0 } .maxByOrNull { it.numComments } @@ -85,7 +84,6 @@ class CommentDataTest { private fun areRepliesBlank(list: List): Boolean { list.forEach { - if (it.hasReplies) { return false } @@ -98,7 +96,6 @@ class CommentDataTest { var position = 0 comments?.treeIterator()?.forEach { - if (it.fullname != linearList[position].fullname) { return false } @@ -116,14 +113,12 @@ class CommentDataTest { // wrap the children comments?.treeIterator()?.forEach { - if (it.depth == 0) { val copyComm = deepCopy(it) newComm.add(copyComm) if (it.hasReplies) { it.replies?.forEach { r -> - childMap[r.fullname] = copyComm } } @@ -141,7 +136,6 @@ class CommentDataTest { if (it.hasReplies) { it.replies?.forEach { r -> - childMap[r.fullname] = copyComm } } @@ -152,9 +146,7 @@ class CommentDataTest { } private fun wrappedLinearCommentModels(comments: List): List { - return comments.toList().treeIterable().map { - if (it is Comment) { TestComment(it.copy()) } else { @@ -167,13 +159,11 @@ class CommentDataTest { * Once wrapped there should be the same amount of items, in the same place, with the same id */ private fun compareModelNumber(wrapped: List, comment: List): Boolean { - val wrappedNames = ArrayList() val commentNames = ArrayList() var wrappedNum = 0 wrapped.treeIterator().forEach { - if (it is TestComment) { wrappedNum++ } @@ -183,7 +173,6 @@ class CommentDataTest { var commentsNum = 0 comment.treeIterator().forEach { - if (it is Comment) { commentsNum++ } @@ -198,10 +187,8 @@ class CommentDataTest { * Walking the tree and running through the list one should have the same amounts of items */ private fun compareModelLinearNumber(wrapped: List, linearList: List): Boolean { - var wrappedNum = 0 wrapped.treeIterator().forEach { - if (it is TestComment) { wrappedNum++ } @@ -209,7 +196,6 @@ class CommentDataTest { var linearNum = 0 linearList.forEach { - if (it is Comment) { linearNum++ } @@ -226,7 +212,6 @@ class CommentDataTest { is Comment -> { val newItem = TestComment(item.copy()) newItem.replies = null - newItem } is MoreComments -> item.copy() @@ -240,7 +225,6 @@ class CommentDataTest { if (parent.replies != null) { val newRep = parent.replies!!.toMutableList() newRep.add(child) - parent.replies = newRep } else { parent.replies = listOf(child) @@ -250,7 +234,6 @@ class CommentDataTest { if (parent.replies != null) { val newRep = parent.replies!!.toMutableList() newRep.add(child) - parent.replies = newRep } else { parent.replies = listOf(child) diff --git a/sampleapp/src/androidTest/java/com/kirkbushman/sampleapp/instrumented/tests/UserlessFetchTest.kt b/sampleapp/src/androidTest/java/com/kirkbushman/sampleapp/instrumented/tests/UserlessFetchTest.kt index 9ea4464e..e333fa38 100644 --- a/sampleapp/src/androidTest/java/com/kirkbushman/sampleapp/instrumented/tests/UserlessFetchTest.kt +++ b/sampleapp/src/androidTest/java/com/kirkbushman/sampleapp/instrumented/tests/UserlessFetchTest.kt @@ -54,11 +54,9 @@ class UserlessFetchTest { @Test fun modelMeTest() { - var exception: Exception? = null try { - val me = client?.accountsClient?.me() assertNotEquals("Assert that Me Object is not null", null, me) } catch (ex: Exception) { @@ -71,11 +69,9 @@ class UserlessFetchTest { @Test fun modelsFrontpageSubmissionsTest() { - var exception: Exception? = null try { - val fetcher = client?.subredditsClient?.createFrontpageSubmissionsFetcher(limit = LIMIT) val submissions = fetcher?.fetchNext() assertNotEquals("Assert that submissions from /r/frontpage are not null", null, submissions) @@ -93,11 +89,9 @@ class UserlessFetchTest { @Test fun modelsAllSubmissionsTest() { - var exception: Exception? = null try { - val fetcher = client?.subredditsClient?.createAllSubmissionsFetcher(limit = LIMIT) val submissions = fetcher?.fetchNext() assertNotEquals("Assert that submissions from /r/all are not null", null, submissions) @@ -115,11 +109,9 @@ class UserlessFetchTest { @Test fun modelsSubmissionsTest() { - var exception: Exception? = null try { - subreddits.forEach { val fetcher = client?.contributionsClient?.createSubmissionsFetcher(it, limit = LIMIT) @@ -140,11 +132,9 @@ class UserlessFetchTest { @Test fun modelsSubredditTest() { - var exception: Exception? = null try { - subreddits.forEach { val subreddit = client?.subredditsClient?.subreddit(it) @@ -160,11 +150,9 @@ class UserlessFetchTest { @Test fun modelsInboxSentTest() { - var exception: Exception? = null try { - val fetcher = client?.messagesClient?.createSentInboxFetcher(limit = LIMIT) val messages = fetcher?.fetchNext() assertNotEquals("Assert that messages in inbox are not null", null, messages) @@ -179,11 +167,9 @@ class UserlessFetchTest { @Test fun modelsInboxTest() { - var exception: Exception? = null try { - val fetcher = client?.messagesClient?.createOverviewInboxFetcher(limit = LIMIT) val messages = fetcher?.fetchNext() assertNotEquals("Assert that messages in inbox are not null", null, messages) @@ -198,7 +184,6 @@ class UserlessFetchTest { @Test fun modelsCommentsTest() { - val fetcher = client?.subredditsClient?.createAllSubmissionsFetcher(limit = LIMIT) val submissions = fetcher?.fetchNext() @@ -219,7 +204,6 @@ class UserlessFetchTest { var exception: Exception? = null try { - val wikiSubs = listOf("soccer", "pics") val randomSub = wikiSubs.random() val pages = client?.wikisClient?.wikiPages(subreddit = randomSub) diff --git a/sampleapp/src/main/java/com/kirkbushman/sampleapp/LoginActivity.kt b/sampleapp/src/main/java/com/kirkbushman/sampleapp/LoginActivity.kt index 4edddbed..19203757 100644 --- a/sampleapp/src/main/java/com/kirkbushman/sampleapp/LoginActivity.kt +++ b/sampleapp/src/main/java/com/kirkbushman/sampleapp/LoginActivity.kt @@ -22,7 +22,6 @@ class LoginActivity : AppCompatActivity() { private const val PARAM_AUTO_LOGIN = "intent_param_auto_login" fun start(context: Context, stopAutoLogin: Boolean = false) { - val intent = Intent(context, LoginActivity::class.java) intent.putExtra(PARAM_AUTO_LOGIN, stopAutoLogin) @@ -54,23 +53,18 @@ class LoginActivity : AppCompatActivity() { checkAuthStatus() if (!stopAutoLogin) { - if (!appAuth.shouldLogin() || !userlessAuth.shouldLogin()) { - if (!appAuth.shouldLogin()) { - savedInstalledApp() } if (!userlessAuth.shouldLogin()) { - savedUserless() } } } binding.bttnAppLogin.setOnClickListener { - binding.browser.visibility = View.VISIBLE binding.textCurrentLogin.visibility = View.GONE binding.bttnAppLogin.visibility = View.GONE @@ -86,29 +80,23 @@ class LoginActivity : AppCompatActivity() { } binding.bttnUserlessLogin.setOnClickListener { - if (!userlessAuth.shouldLogin()) { - savedUserless() } else { - fetchUserless() } } } private fun savedInstalledApp() { - DoAsync( doWork = { - val client = appAuth.getSavedRedditClient() if (client != null) { Provider.setRedditClient(client) } }, onPost = { - val intent = Intent(this@LoginActivity, MainActivity::class.java) startActivity(intent) } @@ -116,17 +104,14 @@ class LoginActivity : AppCompatActivity() { } private fun savedUserless() { - DoAsync( doWork = { - val client = userlessAuth.getSavedRedditClient() if (client != null) { Provider.setRedditClient(client) } }, onPost = { - val intent = Intent(this@LoginActivity, MainActivity::class.java) startActivity(intent) } @@ -134,14 +119,11 @@ class LoginActivity : AppCompatActivity() { } private fun fetchInstalledApp() { - appAuth.startWebViewAuthentication(binding.browser) { - binding.browser.stopLoading() DoAsync( doWork = { - if (!userlessAuth.shouldLogin()) { userlessAuth.forceRevoke() } @@ -161,12 +143,10 @@ class LoginActivity : AppCompatActivity() { } private fun fetchUserless() { - var client: RedditClient? = null DoAsync( doWork = { - if (!appAuth.shouldLogin()) { appAuth.forceRevoke() } @@ -174,7 +154,6 @@ class LoginActivity : AppCompatActivity() { client = userlessAuth.getRedditClient() }, onPost = { - if (client != null) { Provider.setRedditClient(client!!) } @@ -188,7 +167,6 @@ class LoginActivity : AppCompatActivity() { } private fun checkAuthStatus() { - if (!appAuth.shouldLogin()) { binding.textCurrentLogin.text = getString(R.string.header_login_type, "INSTALLED_APP") diff --git a/sampleapp/src/main/java/com/kirkbushman/sampleapp/MainActivity.kt b/sampleapp/src/main/java/com/kirkbushman/sampleapp/MainActivity.kt index 3b7f6e35..7e418d8e 100644 --- a/sampleapp/src/main/java/com/kirkbushman/sampleapp/MainActivity.kt +++ b/sampleapp/src/main/java/com/kirkbushman/sampleapp/MainActivity.kt @@ -16,153 +16,118 @@ class MainActivity : AppCompatActivity() { setContentView(binding.root) binding.bttnBackToLogin.setOnClickListener { - LoginActivity.start(this, stopAutoLogin = true) } binding.bttnApis.setOnClickListener { - ApisActivity.start(this) } binding.bttnMe.setOnClickListener { - SelfAccountActivity.start(this) } binding.bttnSelfInfo.setOnClickListener { - SelfAccountInfoActivity.start(this) } binding.bttnInbox.setOnClickListener { - InboxActivity.start(this) } binding.bttnMySubreddits.setOnClickListener { - SubscribedSubredditsActivity.start(this) } binding.bttnMyTrophies.setOnClickListener { - SelfTrophiesActivity.start(this) } binding.bttnUser.setOnClickListener { - RedditorActivity.start(this) } binding.bttnUserInfo.setOnClickListener { - RedditorInfoActivity.start(this) } binding.bttnUserTrophies.setOnClickListener { - UserTrophiesActivity.start(this) } binding.bttnUserSearch.setOnClickListener { - UserSearchActivity.start(this) } binding.bttnUserModeratedSubs.setOnClickListener { - RedditorModeratedSubs.start(this) } binding.bttnSubreddit.setOnClickListener { - SubredditActivity.start(this) } binding.bttnSubmission.setOnClickListener { - SubmissionActivity.start(this) } binding.bttnSubmissions.setOnClickListener { - SubmissionsActivity.start(this) } binding.bttnSubmissionsSearch.setOnClickListener { - SubmissionsSearchActivity.start(this) } binding.bttnSubmissionsFilter.setOnClickListener { - SubmissionsFlairFilterActivity.start(this) } binding.bttnMultiSubmissions.setOnClickListener { - MultiSubmissionsActivity.start(this) } binding.bttnSubredditSearch.setOnClickListener { - SubredditsSearchActivity.start(this) } - /*bttn_multi_search.setOnClickListener { - - val intent = Intent(this, MultiSearchActivity::class.java) - startActivity(intent) - }*/ - binding.bttnSubmit.setOnClickListener { - SubmitActivity.start(this) } binding.bttnSubmitMedia.setOnClickListener { - SubmitMediaActivity.start(this) } binding.bttnSubmissionsCommons.setOnClickListener { - CommonSubmissionsActivity.start(this) } binding.bttnComment.setOnClickListener { - CommentActivity.start(this) } binding.bttnComments.setOnClickListener { - CommentsActivity.start(this) } binding.bttnWiki.setOnClickListener { - WikiPageActivity.start(this) } binding.bttnWikiPages.setOnClickListener { - WikiPagesActivity.start(this) } binding.bttnRules.setOnClickListener { - RulesActivity.start(this) } binding.bttnUploadImages.setOnClickListener { - UploadImagesActivity.start(this) } binding.bttnSettings.setOnClickListener { - SettingsActivity.start(this) } } diff --git a/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/ApiDetailActivity.kt b/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/ApiDetailActivity.kt index 6818111c..f775a85d 100644 --- a/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/ApiDetailActivity.kt +++ b/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/ApiDetailActivity.kt @@ -726,7 +726,6 @@ class ApiDetailActivity : BaseActivity() { } private fun getRandomSubredditNames(): Array { - return subreddits .shuffled() .take(TAKE_SUB_NUM) @@ -734,9 +733,7 @@ class ApiDetailActivity : BaseActivity() { } private fun getRandomSubredditIds(): List { - return listOf( - // centuryclub // testing private subreddit "2u3fa", diff --git a/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/ApisActivity.kt b/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/ApisActivity.kt index 0a86220a..e44d409a 100644 --- a/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/ApisActivity.kt +++ b/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/ApisActivity.kt @@ -11,7 +11,6 @@ class ApisActivity : BaseActivity() { companion object { fun start(context: Context) { - val intent = Intent(context, ApisActivity::class.java) context.startActivity(intent) } diff --git a/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/SubmissionsActivity.kt b/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/SubmissionsActivity.kt index 2f1333d3..664101db 100644 --- a/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/SubmissionsActivity.kt +++ b/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/SubmissionsActivity.kt @@ -22,7 +22,6 @@ class SubmissionsActivity : BaseSearchControllerActivity? { - fetcher = client.contributionsClient.createSubmissionsFetcher(query, limit = 100L) return fetcher?.fetchNext() } @@ -111,7 +103,6 @@ class SubmissionsActivity : BaseSearchControllerActivity { reloadSubmission(sorting = SubmissionsSorting.HOT); true } R.id.item_sorting_best -> { reloadSubmission(sorting = SubmissionsSorting.BEST); true } R.id.item_sorting_new -> { reloadSubmission(sorting = SubmissionsSorting.NEW); true } @@ -133,10 +124,8 @@ class SubmissionsActivity : BaseSearchControllerActivity { - val fetcher = client.accountsClient.createSubscribedSubredditsFetcher(limit = 100) return fetcher.fetchNext() ?: emptyList() } diff --git a/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/UploadImagesActivity.kt b/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/UploadImagesActivity.kt index b8389bdc..aba9d363 100644 --- a/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/UploadImagesActivity.kt +++ b/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/UploadImagesActivity.kt @@ -57,11 +57,9 @@ class UploadImagesActivity : AppCompatActivity() { DoAsync( doWork = { - mediaUrl = client.contributionsClient.uploadMedia(fileName!!, mimeType!!, fileContent!!) }, onPost = { - if (mediaUrl != null) { Toast.makeText(this, mediaUrl, Toast.LENGTH_SHORT).show() @@ -74,7 +72,6 @@ class UploadImagesActivity : AppCompatActivity() { } binding.bttnLoadImage.setOnClickListener { - StorageUtil.openMediaChooser(this) } @@ -94,7 +91,6 @@ class UploadImagesActivity : AppCompatActivity() { resultCode = resultCode, resultIntent = data ) { fileName, mimeType, fileContent, bitmap -> - this.fileName = fileName this.mimeType = mimeType this.fileContent = fileContent diff --git a/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/UserTrophiesActivity.kt b/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/UserTrophiesActivity.kt index 476837c1..ec6acc5f 100644 --- a/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/UserTrophiesActivity.kt +++ b/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/UserTrophiesActivity.kt @@ -13,9 +13,7 @@ import dagger.hilt.android.AndroidEntryPoint class UserTrophiesActivity : BaseSearchControllerActivity2() { companion object { - fun start(context: Context) { - val intent = Intent(context, UserTrophiesActivity::class.java) context.startActivity(intent) } @@ -28,7 +26,6 @@ class UserTrophiesActivity : BaseSearchControllerActivity2() { override val controller by lazy { TrophiesController() } override fun fetchItem(client: RedditClient, query: String): Collection? { - return client.redditorsClient.trophies(query) } } diff --git a/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/base/BaseSearchPrintActivity.kt b/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/base/BaseSearchPrintActivity.kt index 2c3ec3eb..2940bf85 100644 --- a/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/base/BaseSearchPrintActivity.kt +++ b/sampleapp/src/main/java/com/kirkbushman/sampleapp/activities/base/BaseSearchPrintActivity.kt @@ -33,7 +33,6 @@ abstract class BaseSearchPrintActivity : BaseActivity() { binding.editSearch.hint = getString(hintTextRes()) binding.bttnSearch.setOnClickListener { - val searchQuery = binding.editSearch.text.toString().trim() if (searchQuery.isNotEmpty()) { diff --git a/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/CommentController.kt b/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/CommentController.kt index bf815e60..937ed866 100644 --- a/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/CommentController.kt +++ b/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/CommentController.kt @@ -18,7 +18,6 @@ class CommentController( ) : EpoxyController() { interface CommentCallback { - fun onUpvoteClick(submission: Submission) fun onNoneClick(submission: Submission) fun onDownClick(submission: Submission) @@ -49,14 +48,12 @@ class CommentController( override fun buildModels() { if (comments.isEmpty()) { - empty { id("empty_model") } } submission?.let { - submission { id(it.id) subredditText(it.subreddit) @@ -77,9 +74,7 @@ class CommentController( comments .treeIterator() .forEach { - if (it is Comment) { - comment { id(it.id) authorText(it.author) @@ -91,7 +86,6 @@ class CommentController( } if (it is MoreComments) { - moreComment { id(it.fullname) moreText("${it.count} more children") diff --git a/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/ModeratedSubsController.kt b/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/ModeratedSubsController.kt index 85ef5186..4dbaeaae 100644 --- a/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/ModeratedSubsController.kt +++ b/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/ModeratedSubsController.kt @@ -16,7 +16,6 @@ class ModeratedSubsController( it: ModeratedSub, callback: SubredditController.SubredditCallback? ) { - subreddit { id(it.fullname) subreddit(it.displayNamePrefixed) diff --git a/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/SubmissionController.kt b/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/SubmissionController.kt index 87463017..8106b564 100644 --- a/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/SubmissionController.kt +++ b/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/SubmissionController.kt @@ -11,10 +11,10 @@ import com.kirkbushman.sampleapp.models.submission class SubmissionController( callback: SubmissionCallback + ) : BaseController(callback) { interface SubmissionCallback : BaseCallback { - fun onUpvoteClick(index: Int) fun onNoneClick(index: Int) fun onDownClick(index: Int) @@ -26,7 +26,6 @@ class SubmissionController( } override fun itemModel(index: Int, it: Submission, callback: SubmissionCallback?) { - submission { id(it.id) subredditText(it.subreddit) @@ -46,7 +45,6 @@ class SubmissionController( } fun getTaggedTitle(submission: Submission): String { - var out = "" if (submission.vote != Vote.NONE) { diff --git a/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/SubredditSearchController.kt b/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/SubredditSearchController.kt index 03394fda..35f52a20 100644 --- a/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/SubredditSearchController.kt +++ b/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/SubredditSearchController.kt @@ -17,7 +17,6 @@ class SubredditSearchController( ) : EpoxyController() { interface SubredditCallback : BaseCallback { - fun subscribeClick(index: Int) } @@ -36,7 +35,6 @@ class SubredditSearchController( } override fun buildModels() { - if (data.isEmpty() && searchResult == null) { empty { id("empty_model") @@ -44,7 +42,6 @@ class SubredditSearchController( } data.forEachIndexed { index, it -> - when (it) { is Subreddit -> @@ -75,7 +72,6 @@ class SubredditSearchController( if (searchResult != null) { searchResult!!.subreddits.forEach { - subreddit { id(it.name) subreddit(it.name) diff --git a/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/base/BaseController.kt b/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/base/BaseController.kt index 73a9231f..4192bb0a 100644 --- a/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/base/BaseController.kt +++ b/sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/base/BaseController.kt @@ -18,16 +18,13 @@ abstract class BaseController(private val callback: C?) : E } override fun buildModels() { - if (items.isEmpty()) { - empty { id("empty_items") } } items.forEachIndexed { index, it -> - itemModel(index, it, callback) } } diff --git a/sampleapp/src/main/java/com/kirkbushman/sampleapp/fragments/ContributionFragment.kt b/sampleapp/src/main/java/com/kirkbushman/sampleapp/fragments/ContributionFragment.kt index c5ec5a72..5836aadb 100644 --- a/sampleapp/src/main/java/com/kirkbushman/sampleapp/fragments/ContributionFragment.kt +++ b/sampleapp/src/main/java/com/kirkbushman/sampleapp/fragments/ContributionFragment.kt @@ -45,16 +45,15 @@ class ContributionFragment : BaseControllerFragment? { - fetcher = when (passedTag) { TAG_OVERVIEW -> client?.redditorsClient?.createOverviewContributionsFetcher(username) TAG_SUBMITTED -> client?.redditorsClient?.createSubmittedContributionsFetcher(username) @@ -127,12 +121,10 @@ class ContributionFragment : BaseControllerFragment? { - fetcher = when (passedTag) { TAG_FRONTPAGE -> client?.subredditsClient?.createFrontpageSubmissionsFetcher() TAG_ALL -> client?.subredditsClient?.createAllSubmissionsFetcher() @@ -127,10 +117,8 @@ class SubmissionFragment : BaseControllerFragment = ('a'..'z') + ('A'..'Z') + ('0'..'9') fun randomString(): String { - return (1..RANDOM_STR_LENGTH) .map { Random.nextInt(0, charPool.size) } .map(charPool::get) @@ -19,17 +18,14 @@ object RandomUtil { } fun randomInt(): Int { - return Random.nextInt(0, RANDOM_INT_LIMIT) } fun randomLong(): Long { - return Random.nextLong(0L, RANDOM_LNG_LIMIT) } fun randomBool(): Boolean { - return Random.nextBoolean() } } diff --git a/sampleapp/src/test/java/com/kirkbushman/sampleapp/local/unit/MessagesClientTests.kt b/sampleapp/src/test/java/com/kirkbushman/sampleapp/local/unit/MessagesClientTests.kt index cb0e7091..7497c670 100644 --- a/sampleapp/src/test/java/com/kirkbushman/sampleapp/local/unit/MessagesClientTests.kt +++ b/sampleapp/src/test/java/com/kirkbushman/sampleapp/local/unit/MessagesClientTests.kt @@ -19,7 +19,6 @@ class MessagesClientTests { @Before fun onPre() { - client = MessagesClient( api = mockApi, disableLegacyEncoding = false, @@ -29,7 +28,6 @@ class MessagesClientTests { @Test fun testCreateFetcher_genericWhere() { - val fetcher = client.createInboxFetcher("test_string") Assert.assertEquals("test_string", fetcher.getWhere()) @@ -37,7 +35,6 @@ class MessagesClientTests { @Test fun testCreateFetcher_overview() { - val fetcher = client.createOverviewInboxFetcher() Assert.assertEquals("inbox", fetcher.getWhere()) @@ -45,7 +42,6 @@ class MessagesClientTests { @Test fun testCreateFetcher_unread() { - val fetcher = client.createUnreadInboxFetcher() Assert.assertEquals("unread", fetcher.getWhere()) @@ -53,7 +49,6 @@ class MessagesClientTests { @Test fun testCreateFetcher_messages() { - val fetcher = client.createMessagesInboxFetcher() Assert.assertEquals("messages", fetcher.getWhere()) @@ -61,7 +56,6 @@ class MessagesClientTests { @Test fun testCreateFetcher_sent() { - val fetcher = client.createSentInboxFetcher() Assert.assertEquals("sent", fetcher.getWhere()) @@ -69,7 +63,6 @@ class MessagesClientTests { @Test fun testCreateFetcher_comments() { - val fetcher = client.createCommentsRepliesInboxFetcher() Assert.assertEquals("comments", fetcher.getWhere()) @@ -77,7 +70,6 @@ class MessagesClientTests { @Test fun testCreateFetcher_selfReply() { - val fetcher = client.createSelfRepliesInboxFetcher() Assert.assertEquals("selfreply", fetcher.getWhere()) @@ -85,7 +77,6 @@ class MessagesClientTests { @Test fun testCreateFetcher_mentions() { - val fetcher = client.createMentionsInboxFetcher() Assert.assertEquals("mentions", fetcher.getWhere()) diff --git a/sampleapp/src/test/java/com/kirkbushman/sampleapp/local/unit/MultisClientTests.kt b/sampleapp/src/test/java/com/kirkbushman/sampleapp/local/unit/MultisClientTests.kt index 612e5415..7ba01c08 100644 --- a/sampleapp/src/test/java/com/kirkbushman/sampleapp/local/unit/MultisClientTests.kt +++ b/sampleapp/src/test/java/com/kirkbushman/sampleapp/local/unit/MultisClientTests.kt @@ -19,7 +19,6 @@ class MultisClientTests { @Before fun onPre() { - client = MultisClient( api = mockApi, disableLegacyEncoding = false, @@ -29,7 +28,6 @@ class MultisClientTests { @Test fun testCreateFetcher_genericWhere() { - val fetcher = client.createMultiSubmissionsFetcher("test_username", "test_multiname") Assert.assertEquals("test_username", fetcher.getUsername()) diff --git a/sampleapp/src/test/java/com/kirkbushman/sampleapp/local/unit/SubredditsClientTests.kt b/sampleapp/src/test/java/com/kirkbushman/sampleapp/local/unit/SubredditsClientTests.kt index 60bec338..99258476 100644 --- a/sampleapp/src/test/java/com/kirkbushman/sampleapp/local/unit/SubredditsClientTests.kt +++ b/sampleapp/src/test/java/com/kirkbushman/sampleapp/local/unit/SubredditsClientTests.kt @@ -19,7 +19,6 @@ class SubredditsClientTests { @Before fun onPre() { - client = SubredditsClient( api = mockApi, disableLegacyEncoding = false, @@ -29,7 +28,6 @@ class SubredditsClientTests { @Test fun testCreateFetcher_genericWhere() { - val fetcher = client.createSubmissionsFetcher("test_string") Assert.assertEquals("test_string", fetcher.getSubreddit()) @@ -37,7 +35,6 @@ class SubredditsClientTests { @Test fun testCreateFetcher_frontpage() { - val fetcher = client.createFrontpageSubmissionsFetcher() Assert.assertEquals("", fetcher.getSubreddit()) @@ -45,7 +42,6 @@ class SubredditsClientTests { @Test fun testCreateFetcher_all() { - val fetcher = client.createAllSubmissionsFetcher() Assert.assertEquals("all", fetcher.getSubreddit()) @@ -53,7 +49,6 @@ class SubredditsClientTests { @Test fun testCreateFetcher_popular() { - val fetcher = client.createPopularSubmissionsFetcher() Assert.assertEquals("popular", fetcher.getSubreddit()) @@ -61,7 +56,6 @@ class SubredditsClientTests { @Test fun testCreateFetcher_friends() { - val fetcher = client.createFriendsSubmissionsFetcher() Assert.assertEquals("friends", fetcher.getSubreddit()) @@ -69,7 +63,6 @@ class SubredditsClientTests { @Test fun testCreateFetcher_original() { - val fetcher = client.createOriginalSubmissionsFetcher() Assert.assertEquals("original", fetcher.getSubreddit()) @@ -77,7 +70,6 @@ class SubredditsClientTests { @Test fun testDisableLegacyEncoding_coherence() { - client = SubredditsClient( api = mockApi, disableLegacyEncoding = false,