Skip to content

Commit

Permalink
search recyclerview completed
Browse files Browse the repository at this point in the history
  • Loading branch information
iamnaran committed Feb 22, 2021
1 parent 0aa6406 commit 398f053
Show file tree
Hide file tree
Showing 31 changed files with 495 additions and 913 deletions.
21 changes: 9 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ android {
targetSdkVersion 30
versionCode 1
versionName "1.0"
buildConfigField 'String', 'BASE_URL', "\"https://elibrary.smartgov.app/api/\""
// buildConfigField 'String', 'BASE_URL', "\"https://elibrary.smartgov.app/api/\""
buildConfigField 'String', 'BASE_URL', "\"https://picsum.photos/v2/\""
// buildConfigField 'String', 'API_SECRET', "\"61y2UU1XME1GfVFa\""
// buildConfigField 'String', 'API_KEY', "\"guWQWTof\""

//https://api.thecommunitycloud.com/a/

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down Expand Up @@ -53,29 +52,27 @@ dependencies {
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'androidx.activity:activity-ktx:1.1.0'
implementation 'androidx.activity:activity-ktx:1.2.0'

//Dagger

implementation 'com.google.dagger:hilt-android:2.28-alpha'
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-compiler:$hilt_version"
kapt 'com.google.dagger:hilt-android-compiler:2.28-alpha'

implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02'
kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02'

implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03'
// Networking

implementation 'com.google.code.gson:gson:2.8.6'
implementation "com.squareup.retrofit2:converter-gson:2.6.2"
implementation "com.squareup.retrofit2:converter-gson:2.8.1"


implementation "com.squareup.retrofit2:retrofit:2.8.1"
implementation "com.squareup.okhttp3:okhttp:4.7.2"
implementation "com.squareup.okhttp3:logging-interceptor:4.7.2"

//Coroutine
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.6"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.6"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7"

//CardView

Expand Down
11 changes: 5 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup">
<activity
android:name=".ui.main.view.HomeActivity"
android:launchMode="singleTask" />
<activity android:name=".ui.photos.view.PhotosActivity">

<activity
android:name=".ui.login.view.LoginActivity"
android:launchMode="singleTask" />
</activity>

<activity
android:name=".ui.splash.view.SplashActivity"
android:launchMode="singleTask"
android:theme="@style/SplashScreenTheme">

<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>
</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ object ApiEndPoints {
const val LOGIN = "login"
const val REGISTER = "register"
const val HOME = "home"
const val PHOTOS_URL = "list"


}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.template.androidtemplate.data.api

import com.template.androidtemplate.data.model.Home
import com.template.androidtemplate.data.model.Photos
import com.template.androidtemplate.data.model.User
import retrofit2.Response

interface ApiHelper {
suspend fun postLogin(email: String,password: String): Response<User>

suspend fun homeFeeds(): Response<Home>
suspend fun getPhotos(): Response<List<Photos>>
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.template.androidtemplate.data.api

import com.template.androidtemplate.data.model.Home
import com.template.androidtemplate.data.model.Photos
import com.template.androidtemplate.data.model.User
import retrofit2.Response
import javax.inject.Inject

class ApiHelperImpl @Inject constructor(private val apiService: ApiService) : ApiHelper {

override suspend fun postLogin(email: String, password: String): Response<User> = apiService.userLogin(email,password)
override suspend fun homeFeeds(): Response<Home> = apiService.homeFeeds()
override suspend fun getPhotos(): Response<List<Photos>> = apiService.getPhotosUrl()

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.template.androidtemplate.data.api

import com.template.androidtemplate.data.model.Home
import com.template.androidtemplate.data.model.Photos
import com.template.androidtemplate.data.model.User
import retrofit2.Response
import retrofit2.http.Field
Expand All @@ -21,4 +22,8 @@ interface ApiService {
suspend fun homeFeeds(): Response<Home>


@GET(ApiEndPoints.PHOTOS_URL)
suspend fun getPhotosUrl(): Response<List<Photos>>


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.template.androidtemplate.data.model
import com.google.gson.annotations.SerializedName



data class Photos(
@SerializedName("author")
var author: String, // Matthew Wiebe
@SerializedName("download_url")
var downloadUrl: String, // https://picsum.photos/id/1025/4951/3301
@SerializedName("height")
var height: Int, // 3301
@SerializedName("id")
var id: String, // 1025
@SerializedName("url")
var url: String, // https://unsplash.com/photos/U5rMrSI7Pn4
@SerializedName("width")
var width: Int // 4951
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ import javax.inject.Inject

class LoginRepository @Inject constructor(private val apiHelper: ApiHelper) {

suspend fun postLogin(email: String, password: String) = apiHelper.postLogin(email,password)

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package com.template.androidtemplate.data.repository
import com.template.androidtemplate.data.api.ApiHelper
import javax.inject.Inject

class HomeRepository @Inject constructor(
class PhotosRepository @Inject constructor(
private val apiHelper: ApiHelper
) {

suspend fun homeFeeds() = apiHelper.homeFeeds()

suspend fun photosFeed() = apiHelper.getPhotos()


}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import com.template.androidtemplate.utils.NetworkHelper
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
Expand All @@ -25,7 +25,7 @@ import javax.inject.Inject
import javax.inject.Singleton

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
class ApplicationModule() {

@Provides
Expand All @@ -38,7 +38,6 @@ class ApplicationModule() {
@Provides
fun providesBaseUrl() = BuildConfig.BASE_URL


// @Provides
// @Singleton
// fun provideSupportAuthenticator(): SupportAuthenticator {
Expand Down Expand Up @@ -78,6 +77,7 @@ class ApplicationModule() {
}
}


@Provides
@Singleton
fun provideRetrofit(
Expand All @@ -95,6 +95,7 @@ class ApplicationModule() {
fun provideApiService(retrofit: Retrofit): ApiService = retrofit.create(ApiService::class.java)



@Provides
@Singleton
fun provideApiHelper(apiHelper: ApiHelperImpl): ApiHelper = apiHelper
Expand Down

This file was deleted.

Loading

0 comments on commit 398f053

Please sign in to comment.