diff --git a/example/android/app/src/main/java/ru/sokomishalov/skraper/example/activity/ListViewActivity.kt b/example/android/app/src/main/java/ru/sokomishalov/skraper/example/activity/ListViewActivity.kt index 4a1df0a4..8378996d 100644 --- a/example/android/app/src/main/java/ru/sokomishalov/skraper/example/activity/ListViewActivity.kt +++ b/example/android/app/src/main/java/ru/sokomishalov/skraper/example/activity/ListViewActivity.kt @@ -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 @@ -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() } } \ No newline at end of file diff --git a/example/android/app/src/main/java/ru/sokomishalov/skraper/example/adapter/PostsAdapter.kt b/example/android/app/src/main/java/ru/sokomishalov/skraper/example/adapter/PostsAdapter.kt index 4853b33c..54df8de9 100644 --- a/example/android/app/src/main/java/ru/sokomishalov/skraper/example/adapter/PostsAdapter.kt +++ b/example/android/app/src/main/java/ru/sokomishalov/skraper/example/adapter/PostsAdapter.kt @@ -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 @@ -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, @@ -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 diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 286439dd..5007d0a1 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/skrapers/src/main/kotlin/ru/sokomishalov/skraper/provider/flickr/FlickrSkraper.kt b/skrapers/src/main/kotlin/ru/sokomishalov/skraper/provider/flickr/FlickrSkraper.kt index 2b9c267b..dc5ee381 100644 --- a/skrapers/src/main/kotlin/ru/sokomishalov/skraper/provider/flickr/FlickrSkraper.kt +++ b/skrapers/src/main/kotlin/ru/sokomishalov/skraper/provider/flickr/FlickrSkraper.kt @@ -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()