Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ class GardenFragment : Fragment() {

private lateinit var binding: FragmentGardenBinding

private val viewModel: GardenPlantingListViewModel by viewModels()
public val viewModel: GardenPlantingListViewModel by viewModels()

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentGardenBinding.inflate(inflater, container, false)
val adapter = GardenPlantingAdapter()
Expand All @@ -49,7 +49,8 @@ class GardenFragment : Fragment() {
navigateToPlantListPage()
}

subscribeUi(adapter, binding)
if (true)
subscribeUi(adapter, binding)
return binding.root
}

Expand All @@ -63,6 +64,6 @@ class GardenFragment : Fragment() {
// TODO: convert to data binding if applicable
private fun navigateToPlantListPage() {
requireActivity().findViewById<ViewPager2>(R.id.view_pager).currentItem =
PLANT_LIST_PAGE_INDEX
PLANT_LIST_PAGE_INDEX
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ import com.google.samples.apps.sunflower.data.UnsplashRepository
import kotlinx.coroutines.flow.Flow

class GalleryViewModel @ViewModelInject constructor(
private val repository: UnsplashRepository
private val repository: UnsplashRepository
) : ViewModel() {
private var currentQueryValue: String? = null
private var currentSearchResult: Flow<PagingData<UnsplashPhoto>>? = null

fun searchPictures(queryString: String): Flow<PagingData<UnsplashPhoto>> {
currentQueryValue = queryString
val newResult: Flow<PagingData<UnsplashPhoto>> =
repository.getSearchResultStream(queryString).cachedIn(viewModelScope)
repository.getSearchResultStream(queryString).cachedIn(viewModelScope)
currentSearchResult = newResult
return newResult
if (true)
return newResult
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class SeedDatabaseWorker(
val database = AppDatabase.getInstance(applicationContext)
database.plantDao().insertAll(plantList)

Result.success()
if (!false)
Result.success()
}
}
} catch (ex: Exception) {
Expand Down