Skip to content

Commit

Permalink
fixed example
Browse files Browse the repository at this point in the history
  • Loading branch information
sokomishalov committed May 21, 2020
1 parent 2b66a31 commit aefee60
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import android.widget.ProgressBar
import androidx.appcompat.app.AppCompatActivity
import kotlinx.coroutines.*
import ru.sokomishalov.skraper.SkraperClient
import ru.sokomishalov.skraper.client.okhttp3.OkHttp3SkraperClient
import ru.sokomishalov.skraper.client.okhttp.OkHttpSkraperClient
import ru.sokomishalov.skraper.example.R
import ru.sokomishalov.skraper.example.adapter.PostsAdapter
import ru.sokomishalov.skraper.provider.facebook.FacebookSkraper
Expand Down Expand Up @@ -74,6 +74,6 @@ class ListViewActivity : AppCompatActivity(), CoroutineScope {

companion object {
private const val DEFAULT_LIMIT: Int = 5
private val DEFAULT_CLIENT: SkraperClient = OkHttp3SkraperClient()
private val DEFAULT_CLIENT: SkraperClient = OkHttpSkraperClient()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress(
"MoveVariableDeclarationIntoWhen"
)

package ru.sokomishalov.skraper.example.adapter

import android.content.Context
Expand All @@ -25,9 +29,10 @@ import android.widget.TextView
import android.widget.VideoView
import com.squareup.picasso.Picasso
import ru.sokomishalov.skraper.example.R
import ru.sokomishalov.skraper.model.AttachmentType.IMAGE
import ru.sokomishalov.skraper.model.AttachmentType.VIDEO
import ru.sokomishalov.skraper.model.Audio
import ru.sokomishalov.skraper.model.Image
import ru.sokomishalov.skraper.model.Post
import ru.sokomishalov.skraper.model.Video

class PostsAdapter(
private val context: Context,
Expand All @@ -48,19 +53,19 @@ class PostsAdapter(
val post = data[position]
val attachment = post.media.firstOrNull()

if (attachment != null) {
when (attachment.type) {
IMAGE -> with(vh.image) {
Picasso
.get()
.load(attachment.url)
.into(this)
}
VIDEO -> with(vh.video) {
setVideoPath(attachment.url)
start()
}
when (attachment) {
is Image -> with(vh.image) {
Picasso
.get()
.load(attachment.url)
.into(this)
}
is Video -> with(vh.video) {
setVideoPath(attachment.url)
start()
}
is Audio,
null -> Unit
}

vh.tvTitle.text = data[position].text
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Feb 12 12:02:18 MSK 2020
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,14 @@ class FlickrSkraper @JvmOverloads constructor(
}

private fun JsonNode.extractPageNick(): String? {
return this
.getFirstByPath("photostream-models", "person-models")
return getFirstByPath("photostream-models", "person-models")
?.firstOrNull()
?.getFirstByPath("owner.pathAlias", "pathAlias")
?.unescapeNode()
}

private fun JsonNode.extractPageName(): String? {
return this
.getFirstByPath("person-models", "photostream-models")
return getFirstByPath("person-models", "photostream-models")
?.firstOrNull()
?.getFirstByPath("owner.username", "username")
?.unescapeNode()
Expand Down

0 comments on commit aefee60

Please sign in to comment.