├── .gitignore ├── .idea ├── .gitignore ├── compiler.xml ├── gradle.xml ├── misc.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── mahmudul │ │ └── imagesearch │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── mahmudul │ │ │ └── imagesearch │ │ │ ├── HiltApplication.kt │ │ │ ├── common │ │ │ ├── Constants.kt │ │ │ ├── Extensions.kt │ │ │ └── Resource.kt │ │ │ ├── data │ │ │ ├── model │ │ │ │ ├── Hit.kt │ │ │ │ └── PixabayResponse.kt │ │ │ ├── repository │ │ │ │ └── ImageSearchRepositoryImpl.kt │ │ │ └── source │ │ │ │ ├── ImageSearchService.kt │ │ │ │ └── RemoteDateSourceImpl.kt │ │ │ ├── di │ │ │ ├── DataSourceModule.kt │ │ │ ├── RepositoryModule.kt │ │ │ └── RetrofitModule.kt │ │ │ ├── domain │ │ │ ├── adapter │ │ │ │ └── SearchImagePagingDataAdapter.kt │ │ │ ├── repository │ │ │ │ └── ImageSearchRepository.kt │ │ │ ├── source │ │ │ │ └── RemoteDataSource.kt │ │ │ └── use_case │ │ │ │ └── ImageSearchUseCase.kt │ │ │ └── presentation │ │ │ ├── MainActivity.kt │ │ │ └── search_image │ │ │ ├── ImageSearchViewModel.kt │ │ │ └── SearchImageFragment.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── ic_default_image.xml │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── fragment_search_image.xml │ │ └── search_image_item.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── navigation │ │ └── nav_graph.xml │ │ ├── values-night │ │ └── themes.xml │ │ ├── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ │ └── xml │ │ ├── backup_rules.xml │ │ └── data_extraction_rules.xml │ └── test │ └── java │ └── com │ └── mahmudul │ └── imagesearch │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ImageSearch 2 | 3 | ## 🛠 Built With 4 | - [MVVM (Model - View - ViewModel)](https://developer.android.com/topic/architecture) 5 | - [Dependency Injection (Dagger Hilt)](https://developer.android.com/training/dependency-injection/hilt-android) 6 | - [Flow](https://kotlinlang.org/docs/flow.html) 7 | - [Clean Arhitecture](https://developer.android.com/topic/architecture) 8 | - [Use Case](https://developer.android.com/topic/architecture) 9 | - [Live Data](https://developer.android.com/topic/libraries/architecture/livedata) 10 | - [Glide](https://github.com/skydoves/landscapist) 11 | - [Shimmer Effect](https://github.com/valentinilk/compose-shimmer) 12 | - [Retrofit2](https://square.github.io/retrofit) 13 | - [Coroutines](https://developer.android.com/kotlin/coroutines) 14 | - [Navigation Component](https://developer.android.com/guide/navigation/navigation-getting-started) 15 | - [JSON Parsing Gson](https://github.com/google/gson) 16 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'org.jetbrains.kotlin.android' 4 | id 'kotlin-kapt' 5 | id 'kotlin-android' 6 | id 'androidx.navigation.safeargs.kotlin' 7 | id 'kotlin-parcelize' 8 | id 'dagger.hilt.android.plugin' 9 | } 10 | 11 | android { 12 | namespace 'com.mahmudul.imagesearch' 13 | compileSdk 33 14 | 15 | defaultConfig { 16 | applicationId "com.mahmudul.imagesearch" 17 | minSdk 23 18 | targetSdk 33 19 | versionCode 1 20 | versionName "1.0" 21 | 22 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 23 | } 24 | 25 | buildFeatures { 26 | viewBinding true 27 | } 28 | 29 | buildTypes { 30 | release { 31 | minifyEnabled false 32 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 33 | } 34 | } 35 | compileOptions { 36 | sourceCompatibility JavaVersion.VERSION_1_8 37 | targetCompatibility JavaVersion.VERSION_11 38 | } 39 | kotlinOptions { 40 | jvmTarget = '1.8' 41 | } 42 | } 43 | 44 | dependencies { 45 | 46 | implementation 'androidx.core:core-ktx:1.9.0' 47 | implementation 'androidx.appcompat:appcompat:1.5.1' 48 | implementation 'com.google.android.material:material:1.7.0' 49 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' 50 | implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' 51 | testImplementation 'junit:junit:4.13.2' 52 | androidTestImplementation 'androidx.test.ext:junit:1.1.4' 53 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0' 54 | 55 | 56 | // Retrofit 57 | implementation 'com.squareup.retrofit2:retrofit:2.9.0' 58 | 59 | // JSON Parsing 60 | implementation 'com.google.code.gson:gson:2.10' 61 | implementation 'com.squareup.retrofit2:converter-gson:2.9.0' 62 | 63 | // Coroutines 64 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4' 65 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4' 66 | 67 | // ViewModel 68 | implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1" 69 | implementation "androidx.activity:activity-ktx:1.6.1" 70 | 71 | // LiveData 72 | implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1" 73 | 74 | // Navigation 75 | implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3' 76 | implementation 'androidx.navigation:navigation-ui-ktx:2.5.3' 77 | 78 | // Shimmer Effect 79 | implementation 'com.facebook.shimmer:shimmer:0.5.0' 80 | 81 | // Motion Toast 82 | implementation 'com.github.Spikeysanju:MotionToast:1.4' 83 | 84 | // Loading Button 85 | implementation group: 'com.apachat', name: 'loadingbutton-android', version: '1.0.11' 86 | 87 | // Rounded Progress Bar 88 | implementation 'com.github.MackHartley:RoundedProgressBar:3.0.0' 89 | 90 | // ViewBinding Delegate 91 | implementation 'com.github.Zhuinden:fragmentviewbindingdelegate-kt:1.0.0' 92 | 93 | //Glide 94 | implementation 'com.github.bumptech.glide:glide:4.14.2' 95 | annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2' 96 | implementation 'jp.wasabeef:glide-transformations:4.3.0' 97 | 98 | //Click Shrink Effect 99 | implementation 'com.github.muratozturk5:ClickShrinkEffectLibrary:1.2.0' 100 | 101 | //Hilt 102 | implementation 'com.google.dagger:hilt-android:2.44' 103 | kapt 'com.google.dagger:hilt-compiler:2.44' 104 | kapt 'com.google.dagger:hilt-android-compiler:2.44' 105 | kapt "androidx.hilt:hilt-compiler:1.0.0" 106 | annotationProcessor 'com.google.dagger:dagger-android-processor:2.44' 107 | 108 | //Paging 109 | implementation "androidx.paging:paging-runtime-ktx:3.1.1" 110 | 111 | //Coil 112 | implementation("io.coil-kt:coil:2.2.2") 113 | implementation("com.github.Commit451.coil-transformations:transformations:1.0.0") 114 | 115 | 116 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/com/mahmudul/imagesearch/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.mahmudul.imagesearch", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | 13 | 24 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/HiltApplication.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch 2 | 3 | import android.app.Application 4 | import dagger.hilt.android.HiltAndroidApp 5 | 6 | @HiltAndroidApp 7 | class HiltApplication : Application() -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/common/Constants.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.common 2 | 3 | object Constants { 4 | const val BASE_URL = "https://pixabay.com/" 5 | const val TOKEN = "30783432-3a3db2d47a19ee90995ae42a4" 6 | const val MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1 7 | const val QUERY_IMAGE_PATH = "api/" 8 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/common/Extensions.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.common 2 | 3 | import android.content.Context 4 | import android.graphics.drawable.Drawable 5 | import android.view.View 6 | import android.widget.ImageView 7 | import androidx.swiperefreshlayout.widget.CircularProgressDrawable 8 | import com.bumptech.glide.Glide 9 | import com.bumptech.glide.load.engine.DiskCacheStrategy 10 | import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions 11 | import com.bumptech.glide.request.RequestOptions.bitmapTransform 12 | import com.mahmudul.imagesearch.R 13 | 14 | 15 | import jp.wasabeef.glide.transformations.BlurTransformation 16 | 17 | 18 | fun View.visible() { 19 | this.visibility = View.VISIBLE 20 | } 21 | 22 | fun View.gone() { 23 | this.visibility = View.GONE 24 | } 25 | 26 | fun Context.circularProgressDrawable(): Drawable { 27 | return CircularProgressDrawable(this).apply { 28 | strokeWidth = 10f 29 | centerRadius = 80f 30 | start() 31 | } 32 | } 33 | 34 | fun ImageView.glideImage(url: String, isBlur: Boolean? = false) { 35 | 36 | if (isBlur == true) { 37 | Glide.with(this.context) 38 | .load(url) 39 | .override(500, 500) 40 | .transition(DrawableTransitionOptions.withCrossFade()) 41 | .apply(bitmapTransform(BlurTransformation(10, 1))) 42 | .diskCacheStrategy(DiskCacheStrategy.DATA) 43 | .placeholder(this.context.circularProgressDrawable()) 44 | .error(R.drawable.ic_launcher_background) 45 | .into(this) 46 | } else { 47 | Glide.with(this.context) 48 | .load(url) 49 | .override(500, 500) 50 | .diskCacheStrategy(DiskCacheStrategy.DATA) 51 | .placeholder(this.context.circularProgressDrawable()) 52 | .error(R.drawable.ic_launcher_background) 53 | .into(this) 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/common/Resource.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.common 2 | 3 | sealed class Resource { 4 | object Loading : Resource() 5 | data class Success(val data: T) : Resource() 6 | data class Error(val throwable: Throwable) : Resource() 7 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/data/model/Hit.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.data.model 2 | 3 | data class Hit( 4 | val collections: Int, 5 | val comments: Int, 6 | val downloads: Int, 7 | val id: Int, 8 | val imageHeight: Int, 9 | val imageSize: Int, 10 | val imageWidth: Int, 11 | val largeImageURL: String, 12 | val likes: Int, 13 | val pageURL: String, 14 | val previewHeight: Int, 15 | val previewURL: String, 16 | val previewWidth: Int, 17 | val tags: String, 18 | val type: String, 19 | val user: String, 20 | val userImageURL: String, 21 | val user_id: Int, 22 | val views: Int, 23 | val webformatHeight: Int, 24 | val webformatURL: String, 25 | val webformatWidth: Int 26 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/data/model/PixabayResponse.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.data.model 2 | 3 | data class PixabayResponse( 4 | val hits: List, 5 | val total: Int, 6 | val totalHits: Int 7 | ) 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/data/repository/ImageSearchRepositoryImpl.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.data.repository 2 | 3 | import com.mahmudul.imagesearch.common.Resource 4 | import com.mahmudul.imagesearch.domain.repository.ImageSearchRepository 5 | import com.mahmudul.imagesearch.domain.source.RemoteDataSource 6 | import kotlinx.coroutines.flow.flow 7 | 8 | class ImageSearchRepositoryImpl( 9 | private val remoteDataSource: RemoteDataSource 10 | ) : ImageSearchRepository { 11 | 12 | override fun queryImage( 13 | query: String, 14 | apiKey: String, 15 | imageType: String 16 | ) = flow { 17 | emit(Resource.Loading) 18 | try { 19 | val response = remoteDataSource.queryImage(query, apiKey, imageType) 20 | emit(Resource.Success(response)) 21 | } catch (t: Throwable) { 22 | emit(Resource.Error(t)) 23 | } 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/data/source/ImageSearchService.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.data.source 2 | 3 | import com.mahmudul.imagesearch.common.Constants.QUERY_IMAGE_PATH 4 | import com.mahmudul.imagesearch.data.model.PixabayResponse 5 | import retrofit2.http.GET 6 | import retrofit2.http.Query 7 | 8 | interface ImageSearchService{ 9 | 10 | @GET(QUERY_IMAGE_PATH) 11 | suspend fun getQueryImages( 12 | @Query("q") query:String, 13 | @Query("key") apiKey:String, 14 | @Query("image_type") imageType:String 15 | ): PixabayResponse 16 | 17 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/data/source/RemoteDateSourceImpl.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.data.source 2 | 3 | import com.mahmudul.imagesearch.data.model.PixabayResponse 4 | import com.mahmudul.imagesearch.domain.source.RemoteDataSource 5 | 6 | 7 | class RemoteDateSourceImpl(private val remoteService: ImageSearchService) : RemoteDataSource { 8 | 9 | override suspend fun queryImage( 10 | query: String, 11 | apiKey: String, 12 | imageType: String 13 | ): PixabayResponse { 14 | return remoteService.getQueryImages(query, apiKey, imageType) 15 | } 16 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/di/DataSourceModule.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.di 2 | 3 | import com.mahmudul.imagesearch.data.source.ImageSearchService 4 | import com.mahmudul.imagesearch.data.source.RemoteDateSourceImpl 5 | import com.mahmudul.imagesearch.domain.source.RemoteDataSource 6 | import dagger.Module 7 | import dagger.Provides 8 | import dagger.hilt.InstallIn 9 | import dagger.hilt.components.SingletonComponent 10 | import javax.inject.Singleton 11 | 12 | @Module 13 | @InstallIn(SingletonComponent::class) 14 | object DataSourceModule { 15 | 16 | @Provides 17 | @Singleton 18 | fun provideRemoteDateSource(remoteService: ImageSearchService): RemoteDataSource = 19 | RemoteDateSourceImpl(remoteService) 20 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/di/RepositoryModule.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.di 2 | 3 | import com.mahmudul.imagesearch.data.repository.ImageSearchRepositoryImpl 4 | import com.mahmudul.imagesearch.domain.repository.ImageSearchRepository 5 | import com.mahmudul.imagesearch.domain.source.RemoteDataSource 6 | import dagger.Module 7 | import dagger.Provides 8 | import dagger.hilt.InstallIn 9 | import dagger.hilt.components.SingletonComponent 10 | import javax.inject.Singleton 11 | 12 | @Module 13 | @InstallIn(SingletonComponent::class) 14 | object RepositoryModule { 15 | @Provides 16 | @Singleton 17 | fun provideDallERepository( 18 | remoteDataSource: RemoteDataSource 19 | ): ImageSearchRepository = 20 | ImageSearchRepositoryImpl(remoteDataSource) 21 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/di/RetrofitModule.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.di 2 | 3 | import com.mahmudul.imagesearch.common.Constants.BASE_URL 4 | import com.mahmudul.imagesearch.data.source.ImageSearchService 5 | import dagger.Module 6 | import dagger.Provides 7 | import dagger.hilt.InstallIn 8 | import dagger.hilt.components.SingletonComponent 9 | import okhttp3.OkHttpClient 10 | import okhttp3.Request 11 | import retrofit2.Retrofit 12 | import retrofit2.converter.gson.GsonConverterFactory 13 | import javax.inject.Singleton 14 | 15 | 16 | @Module 17 | @InstallIn(SingletonComponent::class) 18 | object RetrofitModule { 19 | 20 | private var client: OkHttpClient = OkHttpClient.Builder().addInterceptor { chain -> 21 | val newRequest: Request = 22 | chain.request().newBuilder() 23 | .addHeader("Content-Type", "application/json").build() 24 | //.addHeader("Authorization", "Bearer $TOKEN").build() 25 | chain.proceed(newRequest) 26 | }.build() 27 | 28 | @Provides 29 | @Singleton 30 | fun provideImageSearchService(): ImageSearchService = Retrofit.Builder().client(client).baseUrl(BASE_URL) 31 | .addConverterFactory(GsonConverterFactory.create()).build().create(ImageSearchService::class.java) 32 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/domain/adapter/SearchImagePagingDataAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.domain.adapter 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.Context 5 | import android.util.Log 6 | import android.view.LayoutInflater 7 | import android.view.ViewGroup 8 | import androidx.paging.PagingDataAdapter 9 | import androidx.recyclerview.widget.DiffUtil 10 | import androidx.recyclerview.widget.RecyclerView 11 | import coil.load 12 | import coil.request.ErrorResult 13 | import coil.request.ImageRequest 14 | import com.mahmudul.imagesearch.R 15 | import com.mahmudul.imagesearch.data.model.Hit 16 | import com.mahmudul.imagesearch.databinding.SearchImageItemBinding 17 | 18 | class SearchImagePagingDataAdapter() : 19 | PagingDataAdapter(Diff) { 20 | 21 | 22 | companion object { 23 | val Diff = object : DiffUtil.ItemCallback() { 24 | override fun areItemsTheSame( 25 | oldItem: Hit, 26 | newItem: Hit 27 | ): Boolean { 28 | return oldItem.user_id == newItem.user_id 29 | } 30 | 31 | @SuppressLint("DiffUtilEquals") 32 | override fun areContentsTheSame( 33 | oldItem: Hit, 34 | newItem: Hit 35 | ): Boolean { 36 | return oldItem == newItem 37 | } 38 | } 39 | } 40 | 41 | override fun onCreateViewHolder( 42 | parent: ViewGroup, 43 | viewType: Int 44 | ): SearchImageViewHolder { 45 | val layoutInflater = LayoutInflater.from(parent.context) 46 | 47 | return SearchImageViewHolder( 48 | SearchImageItemBinding.inflate(layoutInflater, parent, false) 49 | ) 50 | } 51 | 52 | class SearchImageViewHolder(val binding: SearchImageItemBinding) : 53 | RecyclerView.ViewHolder(binding.root) 54 | 55 | @SuppressLint("CheckResult", "SetTextI18n") 56 | override fun onBindViewHolder(holder: SearchImageViewHolder, position: Int) { 57 | 58 | try { 59 | val hit = getItem(position) 60 | if (hit != null) { 61 | with(holder.binding) { 62 | title.text = hit.tags 63 | title.isSelected = true 64 | 65 | if (hit.previewURL.isNotBlank()) { 66 | imageView.load(hit.previewURL) { 67 | placeholder(R.drawable.ic_default_image) 68 | 69 | listener( 70 | onSuccess = { _, _ -> 71 | Log.d( 72 | "imageIssue", 73 | "Success image Url = " + hit.previewURL 74 | ) 75 | }, 76 | onError = { request: ImageRequest, error: ErrorResult -> 77 | request.error 78 | imageView.load(R.drawable.ic_default_image) 79 | Log.d( 80 | "imageIssue", 81 | "Exception image Url = " + hit.previewURL + " Error $error" 82 | ) 83 | } 84 | ) 85 | } 86 | } else { 87 | imageView.load(R.drawable.ic_default_image) 88 | } 89 | } 90 | } 91 | } catch (ex: Exception) { 92 | ex.message 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/domain/repository/ImageSearchRepository.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.domain.repository 2 | 3 | import com.mahmudul.imagesearch.common.Resource 4 | import com.mahmudul.imagesearch.data.model.PixabayResponse 5 | import kotlinx.coroutines.flow.Flow 6 | 7 | interface ImageSearchRepository { 8 | fun queryImage(query: String, apiKey: String, imageType: String): Flow> 9 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/domain/source/RemoteDataSource.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.domain.source 2 | 3 | import com.mahmudul.imagesearch.data.model.PixabayResponse 4 | 5 | interface RemoteDataSource { 6 | suspend fun queryImage( 7 | query: String, 8 | apiKey: String, 9 | imageType: String 10 | ): PixabayResponse 11 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/domain/use_case/ImageSearchUseCase.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.domain.use_case 2 | 3 | import com.mahmudul.imagesearch.domain.repository.ImageSearchRepository 4 | import javax.inject.Inject 5 | 6 | class ImageSearchUseCase @Inject constructor(private val repository: ImageSearchRepository) { 7 | operator fun invoke(query: String, apiKey: String, imageType: String) = repository.queryImage(query, apiKey, imageType) 8 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/presentation/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.presentation 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | import com.mahmudul.imagesearch.R 6 | import dagger.hilt.android.AndroidEntryPoint 7 | 8 | @AndroidEntryPoint 9 | class MainActivity : AppCompatActivity() { 10 | override fun onCreate(savedInstanceState: Bundle?) { 11 | super.onCreate(savedInstanceState) 12 | setContentView(R.layout.activity_main) 13 | } 14 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/presentation/search_image/ImageSearchViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.presentation.search_image 2 | 3 | import androidx.lifecycle.ViewModel 4 | import androidx.lifecycle.viewModelScope 5 | import com.mahmudul.imagesearch.common.Resource 6 | import com.mahmudul.imagesearch.data.model.PixabayResponse 7 | import com.mahmudul.imagesearch.domain.use_case.ImageSearchUseCase 8 | import dagger.hilt.android.lifecycle.HiltViewModel 9 | import kotlinx.coroutines.flow.MutableStateFlow 10 | import kotlinx.coroutines.flow.asStateFlow 11 | import kotlinx.coroutines.launch 12 | import javax.inject.Inject 13 | 14 | @HiltViewModel 15 | class ImageSearchViewModel @Inject constructor(private val imageSearchUseCase: ImageSearchUseCase) : 16 | ViewModel() { 17 | 18 | private val _state = MutableStateFlow?>(null) 19 | val state = _state.asStateFlow() 20 | 21 | fun queryImage(query: String, apiKey: String, imageType: String) = viewModelScope.launch { 22 | 23 | imageSearchUseCase(query, apiKey, imageType).collect { 24 | _state.emit(it) 25 | } 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mahmudul/imagesearch/presentation/search_image/SearchImageFragment.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch.presentation.search_image 2 | 3 | import android.os.Bundle 4 | import android.util.Log 5 | import androidx.fragment.app.Fragment 6 | import android.view.View 7 | import androidx.fragment.app.viewModels 8 | import androidx.lifecycle.lifecycleScope 9 | import androidx.paging.PagingData 10 | import androidx.recyclerview.widget.GridLayoutManager 11 | import com.mahmudul.imagesearch.R 12 | import com.mahmudul.imagesearch.common.Constants 13 | import com.mahmudul.imagesearch.common.Resource 14 | import com.mahmudul.imagesearch.databinding.FragmentSearchImageBinding 15 | import com.mahmudul.imagesearch.domain.adapter.SearchImagePagingDataAdapter 16 | import com.zhuinden.fragmentviewbindingdelegatekt.viewBinding 17 | import dagger.hilt.android.AndroidEntryPoint 18 | import www.sanju.motiontoast.MotionToast 19 | import www.sanju.motiontoast.MotionToastStyle 20 | 21 | @AndroidEntryPoint 22 | class SearchImageFragment : Fragment(R.layout.fragment_search_image) { 23 | 24 | private val viewModel: ImageSearchViewModel by viewModels() 25 | private val binding by viewBinding(FragmentSearchImageBinding::bind) 26 | lateinit var searchImagePagingDataAdapter: SearchImagePagingDataAdapter 27 | 28 | 29 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 30 | super.onViewCreated(view, savedInstanceState) 31 | 32 | initViewCollect() 33 | } 34 | 35 | private fun initViewCollect() { 36 | with(viewModel) { 37 | with(binding) { 38 | searchImagePagingDataAdapter = SearchImagePagingDataAdapter() 39 | recyclerView.layoutManager = GridLayoutManager(requireContext(), 2) 40 | recyclerView.apply { 41 | layoutManager 42 | adapter = searchImagePagingDataAdapter 43 | } 44 | recyclerView.layoutManager 45 | 46 | queryImage("tiger", Constants.TOKEN, "photo") 47 | viewLifecycleOwner.lifecycleScope.launchWhenStarted { 48 | state.collect { response -> 49 | when (response) { 50 | is Resource.Loading -> { 51 | Log.e("Response", "Loading") 52 | } 53 | is Resource.Success -> { 54 | Log.e("Response", response.data.hits.size.toString()) 55 | // binding.result.text = response.data.toString() 56 | searchImagePagingDataAdapter.submitData( 57 | lifecycle, PagingData.from(response.data.hits) 58 | ) 59 | 60 | } 61 | is Resource.Error -> { 62 | MotionToast.createColorToast( 63 | requireActivity(), 64 | getString(R.string.error), 65 | response.throwable.localizedMessage ?: "Error", 66 | MotionToastStyle.ERROR, 67 | MotionToast.GRAVITY_TOP or MotionToast.GRAVITY_CENTER, 68 | MotionToast.LONG_DURATION, 69 | null 70 | ) 71 | Log.e("Response", response.throwable.localizedMessage ?: "Error") 72 | } 73 | else -> { 74 | Log.e("Response", "Unknown Error") 75 | } 76 | } 77 | } 78 | } 79 | 80 | } 81 | } 82 | } 83 | } 84 | 85 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_default_image.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 19 | 20 | 29 | 30 | 31 | 32 | 43 | 44 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_search_image.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/layout/search_image_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 21 | 22 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhasancse15/ImageSearch/043597a60b31e812efc99bf013b03f7290f3fe5a/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhasancse15/ImageSearch/043597a60b31e812efc99bf013b03f7290f3fe5a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhasancse15/ImageSearch/043597a60b31e812efc99bf013b03f7290f3fe5a/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhasancse15/ImageSearch/043597a60b31e812efc99bf013b03f7290f3fe5a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhasancse15/ImageSearch/043597a60b31e812efc99bf013b03f7290f3fe5a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhasancse15/ImageSearch/043597a60b31e812efc99bf013b03f7290f3fe5a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhasancse15/ImageSearch/043597a60b31e812efc99bf013b03f7290f3fe5a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhasancse15/ImageSearch/043597a60b31e812efc99bf013b03f7290f3fe5a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhasancse15/ImageSearch/043597a60b31e812efc99bf013b03f7290f3fe5a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhasancse15/ImageSearch/043597a60b31e812efc99bf013b03f7290f3fe5a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/navigation/nav_graph.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 15 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | #002B42 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ImageSearch 3 | 4 | Hello blank fragment 5 | Error! 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/xml/backup_rules.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/xml/data_extraction_rules.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 12 | 13 | 19 | -------------------------------------------------------------------------------- /app/src/test/java/com/mahmudul/imagesearch/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.mahmudul.imagesearch 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | dependencies { 3 | classpath 'com.google.dagger:hilt-android-gradle-plugin:2.42' 4 | } 5 | } 6 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 7 | plugins { 8 | id 'com.android.application' version '7.3.1' apply false 9 | id 'com.android.library' version '7.3.1' apply false 10 | id 'org.jetbrains.kotlin.android' version '1.7.20' apply false 11 | id 'androidx.navigation.safeargs.kotlin' version '2.5.3' apply false 12 | 13 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Kotlin code style for this project: "official" or "obsolete": 19 | kotlin.code.style=official 20 | # Enables namespacing of each library's R class so that its R class includes only the 21 | # resources declared in the library itself and none from the library's dependencies, 22 | # thereby reducing the size of the R class for that library 23 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhasancse15/ImageSearch/043597a60b31e812efc99bf013b03f7290f3fe5a/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Jan 01 16:10:01 BDT 2023 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | maven { url "https://jitpack.io" } 14 | } 15 | } 16 | rootProject.name = "ImageSearch" 17 | include ':app' 18 | --------------------------------------------------------------------------------