Skip to content

Instantly share code, notes, and snippets.

View saurabharora90's full-sized avatar

Saurabh saurabharora90

View GitHub Profile
class CustomerCareInitializer @Inject constructor(
private val session: UserSession,
private val apiService: ApiService
) : ModuleInitializer {
override fun initialize(context: Context): Completable {
....
}
override fun dependencies(): List<Class<out ModuleInitializer>> {
interface ModuleInitializer {
fun initialize(context: Context): Completable
fun dependencies(): List<Class<out ModuleInitializer>> {
return emptyList()
}
}
class CustomerCareInitializer @Inject constructor(
private val session: UserSession,
private val apiService: ApiService
) : ModuleInitializer {
override fun initialize(context: Context): Completable {
return apiService.execute( ... )
.flatMap {
Zendesk.init(...)
}
interface ModuleInitializer {
/** Initializes a module given the application Context
*
* @return A Completable if the module needs the app to wait for its setup to complete before proceeding.
* If the module setup doesn't need an asynchronous setup, then it can simply return Completable.complete()
*/
fun initialize(context: Context): Completable
}
@saurabharora90
saurabharora90 / FullScreenPendingIntent.kt
Created July 9, 2019 16:53
Beginning with Android Q, Background Activity Starts should be done by notification triggered activities.
val fullScreenIntent = Intent(this, CallActivity::class.java)
val fullScreenPendingIntent = PendingIntent.getActivity(this, 0,
fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT)
val notificationBuilder = NotificationCompat.Builder(this, CHANNEL_ID)
....
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setCategory(NotificationCompat.CATEGORY_CALL)
.setFullScreenIntent(fullScreenPendingIntent, true)
@saurabharora90
saurabharora90 / checkstyle-as.xml
Created February 25, 2020 17:02
CodeStyle Configuration to match Android Studio Defaults
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="severity" value="warning" />
<property name="charset" value="UTF-8" />
<module name="FileTabCharacter">
class DarkThemeLintRegistry : IssueRegistry() {
override val issues: List<Issue>
get() = listOf(
DirectColorUseIssue.ISSUE,
MissingNightColorIssue.ISSUE
)
}
private const val COLOR = "color"
class MissingNightColorDetector : ResourceXmlDetector() {
private val nightModeColors = mutableListOf<String>()
private val regularColors = mutableMapOf<String, Location>()
override fun appliesTo(folderType: ResourceFolderType): Boolean {
return folderType == ResourceFolderType.VALUES
}
@saurabharora90
saurabharora90 / colors.xml
Last active August 3, 2019 09:06
Missing Night Color
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
</resources>
object MissingNightColorIssue {
private const val ID = "MissingNightColor"
private const val DESCRIPTION = "Night Color missing"
const val EXPLANATION =
'''Night color value for this color resource seems to be missing.
If your app supports dark theme, then you should add an equivalent color resource for it in the night values folder.'''
private val CATEGORY = Category.CORRECTNESS
private const val PRIORITY = 6
private val SEVERITY = Severity.WARNING