diff --git a/android/app/src/main/java/com/emergetools/hackernews/HackerNewsApplication.kt b/android/app/src/main/java/com/emergetools/hackernews/HackerNewsApplication.kt index b07e5cdc..5a6f09f5 100644 --- a/android/app/src/main/java/com/emergetools/hackernews/HackerNewsApplication.kt +++ b/android/app/src/main/java/com/emergetools/hackernews/HackerNewsApplication.kt @@ -2,6 +2,7 @@ package com.emergetools.hackernews import android.app.Application import android.content.Context +import android.util.Log import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.preferencesDataStore @@ -10,9 +11,14 @@ import com.emergetools.hackernews.data.local.BookmarkDao import com.emergetools.hackernews.data.local.HackerNewsDatabase import com.emergetools.hackernews.data.local.LocalCookieJar import com.emergetools.hackernews.data.local.UserStorage +import com.emergetools.hackernews.data.remote.FeedIdResponse import com.emergetools.hackernews.data.remote.HackerNewsBaseClient import com.emergetools.hackernews.data.remote.HackerNewsSearchClient import com.emergetools.hackernews.data.remote.HackerNewsWebClient +import com.emergetools.hackernews.data.remote.ItemResponse +import com.emergetools.hackernews.data.remote.PostPage +import com.emergetools.hackernews.features.stories.FeedType +import kotlinx.coroutines.runBlocking import kotlinx.serialization.json.Json import okhttp3.OkHttpClient import java.time.Duration @@ -47,7 +53,29 @@ class HackerNewsApplication : Application() { webClient = HackerNewsWebClient(httpClient) baseClient = HackerNewsBaseClient(json, httpClient) + + // Find if a Android item is in the feed! + runBlocking { + when (val response = baseClient.getFeedIds(FeedType.Top)) { + is FeedIdResponse.Success -> { + for (item in response.page) { + when (val item = baseClient.getItem(item)) { + is ItemResponse.Item -> { + if (item.title?.contains("Android") == true) { + Log.d("HN", "Android item! ${item.title}") + } + } + ItemResponse.NullResponse -> { + } + } + } + } + is FeedIdResponse.Error -> { + } + } + } } + } val Context.dataStore: DataStore by preferencesDataStore(name = "user")