Skip to content

Commit

Permalink
updated to new feedly client library
Browse files Browse the repository at this point in the history
  • Loading branch information
dafi committed Aug 23, 2019
1 parent f97d7b4 commit c24f431
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.ternaryop.photoshelf

import android.app.Application
import com.ternaryop.feedly.FeedlyClient
import com.ternaryop.feedly.FeedlyClientInfo
import com.ternaryop.photoshelf.api.ApiManager
import com.ternaryop.photoshelf.customsearch.GoogleCustomSearchClient
import com.ternaryop.tumblr.android.TumblrManager
Expand All @@ -29,7 +30,11 @@ class PhotoShelfApplication : Application() {
ApiManager
.setup(AppSupport(this)
.photoShelfApikey, BuildConfig.PHOTOSHELF_API_PREFIX, okHttpClient)
FeedlyClient.setup(okHttpClient)
FeedlyClient.setup(FeedlyClientInfo(
getString(R.string.FEEDLY_USER_ID),
getString(R.string.FEEDLY_REFRESH_TOKEN),
getString(R.string.FEEDLY_CLIENT_ID),
getString(R.string.FEEDLY_CLIENT_SECRET)), okHttpClient)
GoogleCustomSearchClient.setup(
getString(R.string.GOOGLE_CSE_APIKEY),
getString(R.string.GOOGLE_CSE_CX),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import io.reactivex.Single
import io.reactivex.SingleObserver
import io.reactivex.disposables.Disposable
import java.io.InputStreamReader
import java.util.Locale

class FeedlyListFragment : AbsPhotoShelfFragment(), OnFeedlyContentClick {
private lateinit var adapter: FeedlyContentAdapter
Expand Down Expand Up @@ -86,10 +87,7 @@ class FeedlyListFragment : AbsPhotoShelfFragment(), OnFeedlyContentClick {
adapter.sortSwitcher.setType(preferences.getSortType())
adapter.clickListener = this

feedlyClient = FeedlyClient(
preferences.accessToken ?: getString(R.string.FEEDLY_ACCESS_TOKEN),
getString(R.string.FEEDLY_USER_ID),
getString(R.string.FEEDLY_REFRESH_TOKEN))
feedlyClient = FeedlyClient(preferences.accessToken ?: "")

refresh(false)
}
Expand Down Expand Up @@ -240,9 +238,7 @@ class FeedlyListFragment : AbsPhotoShelfFragment(), OnFeedlyContentClick {
}

private fun refreshToken() {
feedlyClient.refreshAccessToken(
getString(R.string.FEEDLY_CLIENT_ID),
getString(R.string.FEEDLY_CLIENT_SECRET))
feedlyClient.refreshAccessToken()
.compose(photoShelfSwipe.applySwipe())
.subscribe(object : FeedlyObserver<AccessToken>() {
override fun onSuccess(accessToken: AccessToken) {
Expand Down Expand Up @@ -332,7 +328,7 @@ class FeedlyListFragment : AbsPhotoShelfFragment(), OnFeedlyContentClick {
val snackbar = Snackbar.make(recyclerView, R.string.token_expired, Snackbar.LENGTH_INDEFINITE)
snackbar
.setActionTextColor(ContextCompat.getColor(context!!, R.color.snack_error_color))
.setAction(resources.getString(R.string.refresh).toLowerCase()) { refreshToken() }
.setAction(resources.getString(R.string.refresh).toLowerCase(Locale.getDefault())) { refreshToken() }
return snackbar
}
return super.makeSnake(view, t)
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apply plugin: "com.github.ben-manes.versions"
apply plugin: "org.jetbrains.kotlin.jvm"

buildscript {
ext.kotlin_version = '1.3.41'
ext.kotlin_version = '1.3.50'
ext {
minSdkVersion = 26
targetSdkVersion = 29
Expand Down Expand Up @@ -38,7 +38,7 @@ buildscript {

ternaryOpUtilLibVersion = '1.4.4'
ternaryOpDomSelectorLibVersion = '1.0.4'
ternaryOpFeedlyLibVersion = '1.0.1'
ternaryOpFeedlyLibVersion = '1.0.2'
ternaryOpTumblrLibVersion = '1.0.1'

rxjavaLibVersion = '2.2.11'
Expand Down

0 comments on commit c24f431

Please sign in to comment.