Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db initialization in module and BASEURL as comp obj #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions .idea/.gitignore

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

1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.primelab.skeleton">

<application
android:name=".AppController"
android:allowBackup="true"
Expand Down
11 changes: 0 additions & 11 deletions app/src/main/java/com/primelab/skeleton/database/AppDataBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,4 @@ import com.primelab.skeleton.networks.models.User
)
abstract class AppDataBase : AppRoomDataBase() {
abstract fun getUserDao(): UserDao

companion object {
@Volatile
private var instance: AppDataBase? = null
fun getInstance(context: Context): AppDataBase =
instance ?: synchronized(this) {
instance ?: getRoomDatabase(context, "skeleton", AppDataBase::class.java).also {
instance = it
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.primelab.skeleton.modules

import android.content.Context
import androidx.room.Room
import com.primelab.common.database.dao.UserTokenDao
import com.primelab.skeleton.database.AppDataBase
import com.primelab.skeleton.database.daos.UserDao
Expand All @@ -21,7 +22,10 @@ import javax.inject.Singleton
class DataBaseModule {
@Singleton
@Provides
fun provideDataBase(@ApplicationContext context: Context) = AppDataBase.getInstance(context)
fun provideDataBase(@ApplicationContext context: Context) : AppDataBase{
return Room.databaseBuilder(context,AppDataBase::class.java,"mydb").build()
}


@Provides
@Singleton
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/java/com/primelab/skeleton/modules/NetworkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import javax.inject.Singleton
@InstallIn(SingletonComponent::class)
class NetworkModule : BaseNetworkModuleImpl() {

override fun getBaseUrl(): String {
return "https://lmn.opq.rs"
}

@BaseUrl
@Singleton
@Provides
fun provideBaseUrl() = getBaseUrl()
// override fun getBaseUrl(): String { //alag fil m
// return "https://lmn.opq.rs"
// }
//
// @BaseUrl
// @Singleton
// @Provides
// fun provideBaseUrl() = getBaseUrl()

@Provides
@Singleton
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
apply from: "$rootDir/dependencies.gradle"
apply from: "$rootDir/config.gradle"
dependencies {
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.38.1'
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.39'
}
}
plugins {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.primelab.common.database
import android.content.Context
import androidx.room.Room
import androidx.room.RoomDatabase

import com.primelab.common.database.dao.UserTokenDao

/**
Expand All @@ -12,6 +13,7 @@ import com.primelab.common.database.dao.UserTokenDao
*/
abstract class AppRoomDataBase : RoomDatabase() {
abstract fun getUserTokenDao(): UserTokenDao

companion object {
fun <T : RoomDatabase> getRoomDatabase(
context: Context,
Expand All @@ -21,7 +23,7 @@ abstract class AppRoomDataBase : RoomDatabase() {
Room.databaseBuilder(context, clazz, prefix + getName())
.fallbackToDestructiveMigration()
.build()

private fun getName(): String = "_room_data_base"
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ fun AppCompatTextView.makeLinks(vararg links: Pair<String, View.OnClickListener>
*/
fun View.setDebouncedClickListener(
listener: (view: View) -> Unit,
//The amount of time, in seconds,
// that elapses before the downlink interfaces are brought up after a state change of the uplink interfaces.
debounceIntervalMs: Int = 700
) {
var lastTapTimestamp: Long = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class FragmentViewBindingDelegate<T : ViewBinding>(
) : ReadOnlyProperty<Fragment, T> {
private var binding: T? = null





init {
fragment.lifecycle.addObserver(object : DefaultLifecycleObserver {
override fun onCreate(owner: LifecycleOwner) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import retrofit2.Retrofit
* PrimeLab.io on 09/02/2022.
*/
interface BaseNetworkModule {
fun getBaseUrl(): String
// fun getBaseUrl(): String
fun getRetrofit(httpClient: OkHttpClient, suffix: String = ""): Retrofit
fun getOkHttpClient(autInterceptor: Interceptor?): OkHttpClient
fun <T> getAPi(retrofit: Retrofit, clazz: Class<T>): T
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.primelab.common.network

import com.primelab.common.di.BaseUrl
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
Expand All @@ -12,9 +13,12 @@ import retrofit2.converter.gson.GsonConverterFactory
* PrimeLab.io on 09/02/2022.
*/
abstract class BaseNetworkModuleImpl : BaseNetworkModule {
companion object{
const val BASE_URL="https://lmn.opq.rs"
}
override fun getRetrofit(httpClient: OkHttpClient, suffix: String): Retrofit =
Retrofit.Builder()
.baseUrl(getBaseUrl())
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.client(httpClient)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sealed class Resource<T> {
data class Success<T>(val data: T?) : Resource<T>()

data class Error<T>(val error: AppError) : Resource<T>()

object load:Resource<Nothing>()
data class Loading<T>(val data: T? = null) : Resource<T>()

data class None<T>(val data: T?=null) : Resource<T>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.primelab.common.sharedpreferences

import android.content.Context
import android.content.SharedPreferences
import android.util.Property
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
import kotlin.reflect.KProperty

/**
Expand All @@ -24,4 +27,18 @@ class SharedPrefs(private val sharePrefs: SharedPreferences) {
sharePrefs.delete()
}

}



class token @Inject constructor(@ApplicationContext context: Context){
var pref=context.getSharedPreferences("xyz",Context.MODE_PRIVATE)
fun savetoken(token: String){
val edi=pref.edit()
edi.putString("usertoken",token)
edi.apply()
}
fun gettoken():String?{
return pref.getString("usertoken",null)
}
}
20 changes: 10 additions & 10 deletions common/src/main/java/com/primelab/common/widgets/OtpView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class OtpView : LinearLayoutCompat {
private var defaultCount: Int = 5
private var focusColor: Int = Color.GREEN
private var unFocusColor: Int = Color.GRAY
private lateinit var stateColor: ColorStateList
private val editTexts: MutableList<AppCompatEditText> = mutableListOf()
private lateinit var stateColor: ColorStateList
private val editTexts: MutableList<AppCompatEditText> = mutableListOf()
private lateinit var errorMessage: String

private lateinit var errorView: TextView
Expand Down Expand Up @@ -71,7 +71,7 @@ class OtpView : LinearLayoutCompat {
recycle()
}
}
stateColor = ColorStateList(
stateColor = ColorStateList(
arrayOf(
intArrayOf(-android.R.attr.state_focused), // Disabled
intArrayOf(android.R.attr.state_focused) // Enabled
Expand All @@ -87,8 +87,8 @@ class OtpView : LinearLayoutCompat {
LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT).apply {
gravity = Gravity.CENTER
}
for (i in 0 until defaultCount) {
val edt = AppCompatEditText(context)
for (i in 0 until defaultCount) {
val edt = AppCompatEditText(context)
edt.layoutParams =
LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT).apply {
weight = 1F
Expand All @@ -98,17 +98,17 @@ class OtpView : LinearLayoutCompat {
}
edt.inputType = InputType.TYPE_CLASS_NUMBER
edt.hint = "0"
edt.imeOptions =
if (i < defaultCount - 1) EditorInfo.IME_ACTION_NEXT else EditorInfo.IME_ACTION_DONE
edt.imeOptions
if (i < defaultCount - 1) EditorInfo.IME_ACTION_NEXT else EditorInfo.IME_ACTION_DONE
edt.tag = i
edt.filters = arrayOf(InputFilter.LengthFilter(1))
edt.gravity = Gravity.CENTER
edt.background = ContextCompat.getDrawable(context, R.drawable.selector_otp)
itemViewContainer.addView(edt)
editTexts.add(edt)
}
addView(itemViewContainer)
setUpErrorView()
addView(itemViewContainer)
setUpErrorView()
setListener()
}

Expand Down Expand Up @@ -150,7 +150,7 @@ class OtpView : LinearLayoutCompat {
}

fun isValid(): Boolean {
for (i in 0 until editTexts.size) {
for (i in 0 until editTexts.size) {
val edt = editTexts[i]
if (edt.text?.length == 0) {
errorView.visibility = VISIBLE
Expand Down