Skip to content

Commit

Permalink
Fix unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzsout committed May 3, 2023
1 parent bbb1860 commit eec1a2b
Show file tree
Hide file tree
Showing 63 changed files with 215 additions and 242 deletions.
4 changes: 2 additions & 2 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
id("com.android.application")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class BaseBottomSheetDialogFragment<VB : ViewBinding>(private val bindi
}

fun navigate(@IdRes id: Int, extras: Bundle?) {
findNavController().navigateSafe(id,extras)
findNavController().navigateSafe(id, extras)
}

fun navigateBack(@IdRes destination: Int? = null) {
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/com/oguzdogdu/wallies/core/BaseFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import androidx.viewbinding.ViewBinding
import com.oguzdogdu.wallies.util.navigateSafe

abstract class BaseFragment<VB : ViewBinding>(
private val bindingInflater: (inflater: LayoutInflater) -> VB
private val bindingInflater: (inflater: LayoutInflater) -> VB,
) : Fragment(), Presenters {

private var _binding: VB? = null
val binding: VB
get() = _binding as VB

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
): View? {
_binding = bindingInflater.invoke(inflater)
if (_binding == null) throw IllegalArgumentException("Binding cannot be null")
Expand All @@ -32,6 +32,7 @@ abstract class BaseFragment<VB : ViewBinding>(
initViews()
initListeners()
}

override fun observeData() {
}

Expand All @@ -42,7 +43,7 @@ abstract class BaseFragment<VB : ViewBinding>(
}

fun navigate(@IdRes id: Int, extras: Bundle?) {
findNavController().navigateSafe(id,extras)
findNavController().navigateSafe(id, extras)
}

fun navigateBack(@IdRes destination: Int? = null) {
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/com/oguzdogdu/wallies/core/WalliesApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ import dagger.hilt.android.HiltAndroidApp


@HiltAndroidApp
class WalliesApp : Application() {

}
class WalliesApp : Application()
4 changes: 2 additions & 2 deletions app/src/main/java/com/oguzdogdu/wallies/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import dagger.hilt.components.SingletonComponent
object AppModule {
@Provides
fun provideCheckConnection(
@ApplicationContext context: Context
) : CheckConnection {
@ApplicationContext context: Context,
): CheckConnection {
return CheckConnection(context)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object NetworkModule {
@Provides
@Singleton
fun provideOkHttpClient(
loggingInterceptor: HttpLoggingInterceptor
loggingInterceptor: HttpLoggingInterceptor,
): OkHttpClient {
val builder = OkHttpClient.Builder().apply {
addInterceptor(loggingInterceptor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import javax.inject.Singleton
object RepositoryModule {
@Provides
@Singleton
fun provideRepository(service: WallpaperService,dao: FavoriteDao): WallpaperRepository {
return WallpaperRepositoryImpl(service,dao)
fun provideRepository(service: WallpaperService, dao: FavoriteDao): WallpaperRepository {
return WallpaperRepositoryImpl(service, dao)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CollectionListAdapter :
fun bind(wallpaper: WallpaperCollections) {
binding.apply {
textViewAuthorName.text = wallpaper.title
imageViewPost.load(wallpaper.photo)
imageViewPost.load(wallpaper.photo)
binding.root.setOnClickListener {
onItemClickListener?.let {
it(wallpaper)
Expand Down Expand Up @@ -54,7 +54,7 @@ class CollectionListAdapter :
object : DiffUtil.ItemCallback<WallpaperCollections>() {
override fun areItemsTheSame(
oldItem: WallpaperCollections,
newItem: WallpaperCollections
newItem: WallpaperCollections,
) =
oldItem.id == newItem.id

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.oguzdogdu.wallies.presentation.collections

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import androidx.paging.cachedIn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CollectionsFragment :
BaseFragment<FragmentCollectionsBinding>(FragmentCollectionsBinding::inflate) {

@Inject
lateinit var connection : CheckConnection
lateinit var connection: CheckConnection

private val viewModel: CollectionViewModel by viewModels()

Expand All @@ -37,7 +37,8 @@ class CollectionsFragment :
adapter = collectionListAdapter,
true,
onScroll = {
recyclerViewCollections.addOnScrollListener(object : RecyclerView.OnScrollListener() {
recyclerViewCollections.addOnScrollListener(object :
RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
if (dy > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class CollectionsListsViewModel @Inject constructor(private val useCase: GetCollectionsListByIdUseCase) :
ViewModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SingleCollectionFragment :
super.initViews()
binding.apply {
val layoutManager =
StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL)
StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)
layoutManager.gapStrategy = StaggeredGridLayoutManager.GAP_HANDLING_NONE
recyclerViewCollectionsList.layoutManager = layoutManager
recyclerViewCollectionsList.adapter = collectionsListsAdapter
Expand Down Expand Up @@ -76,18 +76,19 @@ class SingleCollectionFragment :
}
}

private fun getListByCategory(){
private fun getListByCategory() {
args.id?.let { viewModel.getCollectionsLists(it) }
observe(viewModel.photo, viewLifecycleOwner) {
when {
it.isLoading -> {}
it.error.isNotEmpty() -> {}
it.collectionsLists.isEmpty() -> {
binding.linearLayoutNoPicture.show()
}
else -> {
binding.linearLayoutNoPicture.hide()
collectionsListsAdapter.submitList(it.collectionsLists)
when {
it.isLoading -> {}
it.error.isNotEmpty() -> {}
it.collectionsLists.isEmpty() -> {
binding.linearLayoutNoPicture.show()
}

else -> {
binding.linearLayoutNoPicture.hide()
collectionsListsAdapter.submitList(it.collectionsLists)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.navigation.fragment.navArgs
import coil.load
import coil.request.CachePolicy
import coil.transform.CircleCropTransformation
import com.oguzdogdu.data.model.maindto.Urls
import com.oguzdogdu.domain.model.favorites.FavoriteImages
import com.oguzdogdu.domain.model.singlephoto.Photo
import com.oguzdogdu.wallies.R
Expand All @@ -32,7 +31,7 @@ import javax.inject.Inject
class DetailFragment : BaseFragment<FragmentDetailBinding>(FragmentDetailBinding::inflate) {

@Inject
lateinit var connection : CheckConnection
lateinit var connection: CheckConnection

private val viewModel: DetailViewModel by viewModels()

Expand Down Expand Up @@ -134,7 +133,13 @@ class DetailFragment : BaseFragment<FragmentDetailBinding>(FragmentDetailBinding
}
}

private fun navigateToDownloadWallpaper(raw:String?,high:String?,medium:String?,low:String?,imageTitle:String?){
private fun navigateToDownloadWallpaper(
raw: String?,
high: String?,
medium: String?,
low: String?,
imageTitle: String?,
) {
binding.buttonDownload.setOnClickListener {
val arguments = Bundle().apply {
putString("raw", raw)
Expand Down Expand Up @@ -197,7 +202,4 @@ class DetailFragment : BaseFragment<FragmentDetailBinding>(FragmentDetailBinding
}
}
}
}



}
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
package com.oguzdogdu.wallies.presentation.downloadphoto

import android.app.DownloadManager
import android.content.Context
import android.net.Uri
import android.os.Bundle
import android.os.Environment
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.navigation.fragment.navArgs
import com.oguzdogdu.wallies.R
import com.oguzdogdu.wallies.core.BaseBottomSheetDialogFragment
import com.oguzdogdu.wallies.databinding.FragmentDownloadPhotoBinding
import com.oguzdogdu.wallies.presentation.setwallpaper.SetWallpaperFragmentArgs
import com.oguzdogdu.wallies.util.downloadImage
import com.oguzdogdu.wallies.util.showToast
import java.io.File

class DownloadPhotoFragment : BaseBottomSheetDialogFragment<FragmentDownloadPhotoBinding>(FragmentDownloadPhotoBinding::inflate) {
class DownloadPhotoFragment :
BaseBottomSheetDialogFragment<FragmentDownloadPhotoBinding>(FragmentDownloadPhotoBinding::inflate) {

private val args: DownloadPhotoFragmentArgs by navArgs()

Expand All @@ -43,7 +31,7 @@ class DownloadPhotoFragment : BaseBottomSheetDialogFragment<FragmentDownloadPhot


private fun downloadImageFromWeb(url: String?) {
val directory : String = requireContext().getString(R.string.app_name)
val directory: String = requireContext().getString(R.string.app_name)
val fileName = "${args.imageTitle}.jpg"
if (url != null) {
requireContext().downloadImage(url, directory, fileName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class FavoritesFragment :
it.favorites.isEmpty() -> {
binding.linearLayoutNoPicture.show()
}

else -> {
binding.linearLayoutNoPicture.hide()
favoritesListAdapter.submitList(it.favorites)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.paging.PagingDataAdapter
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import coil.load
import coil.request.CachePolicy
Expand All @@ -26,7 +25,7 @@ class LatestWallpaperAdapter :
RecyclerView.ViewHolder(binding.root) {
fun bind(wallpaper: LatestImage?) {
binding.apply {
imageViewItemWallpaper.load(wallpaper?.url){
imageViewItemWallpaper.load(wallpaper?.url) {
diskCachePolicy(CachePolicy.DISABLED)
}
binding.root.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class MainActivity : AppCompatActivity() {
R.id.favoritesFragment,
R.id.settingsFragment,
-> true

else -> false
}
if (viewModel.showBottomNavigation.value == true) {
Expand Down Expand Up @@ -109,11 +110,11 @@ class MainActivity : AppCompatActivity() {
.build()
}

fun slideUp() {
fun slideUp() {
binding.bottomNavigationView.show()
}

fun slideDown() {
fun slideDown() {
binding.bottomNavigationView.hide()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import dagger.hilt.android.AndroidEntryPoint
class MainFragment : BaseFragment<FragmentMainBinding>(FragmentMainBinding::inflate) {

private val fragments =
listOf(PopularFragment(),LatestFragment())
listOf(PopularFragment(), LatestFragment())

private val tabTitles = listOf("POPULAR","LATEST")
private val tabTitles = listOf("POPULAR", "LATEST")
override fun initViews() {
super.initViews()
initViewPager()
Expand All @@ -24,7 +24,7 @@ class MainFragment : BaseFragment<FragmentMainBinding>(FragmentMainBinding::infl
override fun initListeners() {
super.initListeners()
binding.imageViewSearchWalpapers.setOnClickListener {
navigate(R.id.toSearch,null)
navigate(R.id.toSearch, null)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class MainViewModel @Inject constructor() : ViewModel(){
class MainViewModel @Inject constructor() : ViewModel() {
val showBottomNavigation = MutableLiveData(true)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@ class ViewPagerAdapter(container: FragmentActivity, private val fragmentList: Li
FragmentStateAdapter(container) {
override fun getItemCount() = fragmentList.size

override fun createFragment(position: Int) : Fragment {
return when(position){
0 -> {PopularFragment()}
1 -> {LatestFragment()}
else -> {throw Resources.NotFoundException("Position Not Found")}
override fun createFragment(position: Int): Fragment {
return when (position) {
0 -> {
PopularFragment()
}

1 -> {
LatestFragment()
}

else -> {
throw Resources.NotFoundException("Position Not Found")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.paging.PagingDataAdapter
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import coil.load
import coil.request.CachePolicy
Expand All @@ -26,7 +25,7 @@ class PopularWallpaperAdapter :
RecyclerView.ViewHolder(binding.root) {
fun bind(wallpaper: PopularImage?) {
binding.apply {
imageViewItemWallpaper.load(wallpaper?.url){
imageViewItemWallpaper.load(wallpaper?.url) {
diskCachePolicy(CachePolicy.DISABLED)
}
binding.root.setOnClickListener {
Expand Down
Loading

0 comments on commit eec1a2b

Please sign in to comment.