Skip to content

Instantly share code, notes, and snippets.

View wajahatkarim3's full-sized avatar
:octocat:
Subscribe to my newsletter: remotekaro.substack.com

Wajahat Karim wajahatkarim3

:octocat:
Subscribe to my newsletter: remotekaro.substack.com
View GitHub Profile
<com.google.android.material.card.MaterialCardView
android:id="@+id/cardView"
android:layout_width="match_parent"
app:cardBackgroundColor="@color/card_background_color"
app:cardUseCompatPadding="true"
app:cardElevation="3dp"
android:layout_height="wrap_content">
</com.google.android.material.card.MaterialCardView>
<!-- res/colors/colors.xml -->
<item name=”card_background_color”>#FFF</item>
<!-- res/colors-night/colors.xml-->
<item name=”card_background_color”>#000</item>
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
<!-- Customize your theme here. -->
...
</style>
<!-- Default Theme -->
<style name="Theme.Imagine.Base" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="android:forceDarkAllowed" tools:targetApi="q">true</item>
<item name="colorPrimary">@color/color_primary</item>
<item name="colorPrimaryVariant">@color/color_primary_dark</item>
<item name="colorOnPrimary">@color/color_on_primary</item>
</style>
@wajahatkarim3
wajahatkarim3 / example_layout.xml
Created May 31, 2022 19:15
Constraint Layout Basics example
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/lblLogin"
@wajahatkarim3
wajahatkarim3 / article.md
Created March 21, 2022 13:15
Example artilce

ActivityResultContracts by Examples

Since Android came into existence in 2007, Activity has been one of its core components. One of the most common tasks in apps is transferring data between two Activities. Until now, Intents and onActivityResult were the only choice.

Through the combination of these two parts, developers are able to transfer data from one Activity to another and get data back easily.

Let’s elaborate through an example: your app wants to capture an image and display it to the user. You either write your own custom Camera or delegate the task of fetching an image to Android through Intents. In this second scenario, Android system will open the user-preferred Camera app, capture the image and deliver the requested data to your activity by calling onActivityResult() method.

@wajahatkarim3
wajahatkarim3 / SomeComposable.kt
Created February 14, 2022 16:00
Timer in Composables
@Composable
fun SomeComposableViewHere() {
val scope = rememberCoroutineScope()
scope.launch {
try {
startTimer(flipDurationMs.toLong()) {
// Timer Ended. Do something here
}
} catch(ex: Exception) {
class WebViewActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_web_view)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
val urlToLoad = intent.getStringExtra("url_webview_key")
webView!!.settings.javaScriptEnabled = true
git clone -b start-here https://github.com/wajahatkarim3/ZocDoc-Clone
@wajahatkarim3
wajahatkarim3 / Zocdoc.kt
Created February 4, 2021 08:44
Customizing Color of CometChat UI Kit
fun initCometChat() {
val appID = getString(R.string.app_id) // Replace with your App ID
val region = getString(R.string.region) // Replace with your App Region ("eu" or "us")
val appSettings: AppSettings = AppSettings.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(
region
).build()
CometChat.init(this, appID, appSettings, object : CometChat.CallbackListener<String?>() {
override fun onSuccess(successMessage: String?) {