This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2022. Qamar A. Safadi | |
*/ | |
package com.qamar.test.base | |
import android.os.Bundle | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import android.view.WindowManager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Created by Qamar A. Safadi on 6/13/22, 9:50 PM | |
* Copyright (c) 2022 . | |
*/ | |
package com.example.qamar.ui.base | |
import android.app.Dialog | |
import android.graphics.Color | |
import android.graphics.drawable.ColorDrawable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object LocalData { | |
/** | |
* Set any type of shared preferences value | |
* @param key of the shared preferences which the caller is desire to set | |
* @param value any type | |
*/ | |
operator fun<T> set(key: String?, value: T) { | |
/* below you can put whatever shared preferences api you use, I prefer Hawk | |
* it helps to store objects immediately without need to use GSON in shared preferences | |
* */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ----------------------------------------- Activity ------------------------------------------ */ | |
/* make sure you have at least 'androidx.activity:activity-ktx:1.6.0-rc01' at your dependencies | |
(just to let you know this dependency is not stable yet ) | |
*/ | |
implementation 'androidx.activity:activity-ktx:1.6.0-rc01' | |
fun AppCompatActivity.onBackPressed(isEnabled: Boolean, callback: () -> Unit) { | |
onBackPressedDispatcher.addCallback(this, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.LocaleManager | |
import android.content.Context | |
import android.os.Build | |
import android.os.LocaleList | |
import androidx.appcompat.app.AppCompatDelegate | |
import androidx.core.os.LocaleListCompat | |
import java.util.Locale | |
/// Change Langauage Extenstion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// update your activity version | |
implementation 'androidx.activity:activity-ktx:1.7.1' | |
val pickMedia = registerForActivityResult(ActivityResultContracts.PickVisualMedia()) { uri -> | |
// Callback is invoked after the user selects a media item or closes the | |
// photo picker. | |
if (uri != null) { | |
// do what you want with pic | |
} else { |
OlderNewer