Skip to content

Instantly share code, notes, and snippets.

View Kashif-E's full-sized avatar

Kashif Mehmood Kashif-E

View GitHub Profile
@Kashif-E
Kashif-E / HtmlToAnotatedString.kt
Created January 17, 2024 17:18
An example of how html can be converted to annotated string in compose
val html = """
<h5>Requesting a refund on markaz</h5>
<p>Ap Delivery partner ke issue ke baray main hamin mukhtalif tareeqo se bta skta hain?</p>
<ul>
<li> Pehla order laganay k baad verification call ka intezar karain aur call receive kar kay apna order confirm karwayen. Orders ke tadaad ziada honay ki surat mei verification ko 2 days bhi lag sakte hain </li>
<li>Agar apke order ka status shipping booked likha ajai tou iska matlab apki verification ho chuki hai</li>
<li>Agar aap pehli dafa order kar rahay hain tou aap bara order nahi laga sakte. Ap ka pehla order deliver hone ke baad ap 2-3 multiple order laga sakte hain</li>
</ul>
<ol>
@Kashif-E
Kashif-E / ToUIColor.kt
Created September 3, 2023 15:14
Material Color to UIColor
val uiColor = MaterialTheme.colors.surface.toUIColor()
@OptIn(ExperimentalForeignApi::class)
fun Color.toUIColor(): UIColor {
val colorSpace = CGColorSpaceCreateDeviceRGB()
val components = nativeHeap.allocArray<DoubleVar>(4)
components[0] = red.toDouble()
components[1] = green.toDouble()
components[2] = blue.toDouble()
components[3] = alpha.toDouble()
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import androidx.viewbinding.ViewBinding
abstract class MyBaseAdapter():
RecyclerView.Adapter<MyBaseAdapter.MyBaseViewHolder>() {
inner class MyBaseViewHolder(private val itemViewBinding: ViewBinding) :
RecyclerView.ViewHolder(itemViewBinding.root) {
@Kashif-E
Kashif-E / ParallelAPICallsHOF.kt
Last active March 5, 2022 15:35
Parallel API calls With HOF part 3
class repository{
fun getItems( result : (humans: List<Humans>, birds: List<Birds> ,
reptiles: List<Reptiles> )-> Unit) {
try {
CoroutineScope(Dispatchers.IO).launch {
val humanResponse = async {
apiService.getHumans()
}
val reptileResponse = async {
@Kashif-E
Kashif-E / ParallelAPICallsHOF.kt
Last active March 5, 2022 15:35
Parallel API calls With HOF part 2
class repository{
fun getItems( ) {
try {
CoroutineScope(Dispatchers.IO).launch {
val humanResponse = async {
apiService.getHumans()
}
val reptileResponse = async {
apiServices.getReptiles()
@Kashif-E
Kashif-E / ParallelAPICallsHOF.kt
Last active March 5, 2022 15:34
Parallel API calls With HOF part 1
class repository{
fun getItems( ) {
try {
} catch (e: Exception) {
@Kashif-E
Kashif-E / proguard_rules.pro
Last active October 14, 2024 00:46
This gist contains almost all the pro guard rules that you will ever need for R8
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
@Kashif-E
Kashif-E / ParallelApiCallsWithCotoutines.kt
Created December 22, 2021 09:25
this is how you make parallel api calls using Kotlin coroutines
override suspend fun doNetworkCallsInParallel() {
try {
CoroutineScope(Dispatchers.IO).launch {
val usNewsResponse = async {
apiServices.getHeadLines(country = "us")
}
val healthNewsResponse = async {
apiServices.getHeadLines(category = "health") }
val x = usNewsResponse.await()
//Dependencies
// implementation 'com.sun.mail:android-mail:1.6.0'
// implementation'com.sun.mail:android-activation:1.6.0'
fun sendEmail(){
val prop = Properties().apply {
put("mail.smtp.auth", "true")
put("mail.smtp.starttls.enable","true")
put("mail.smtp.host","smtp.gmail.com")
/**
* Used as a wrapper for data that is exposed via a LiveData that represents an event.
*/
open class Event<out T>(private val content: T) {
@Suppress("MemberVisibilityCanBePrivate")
var hasBeenHandled = false
private set // Allow external read but not write