Skip to content

Instantly share code, notes, and snippets.

View Zulqurnain's full-sized avatar
🤓
I'm Human Seriously

Zulqurnain Haider Zulqurnain

🤓
I'm Human Seriously
View GitHub Profile
@Zulqurnain
Zulqurnain / GridSpacingItemDecoration.kt
Created November 10, 2022 00:31
GridLayoutManager used in RecyclerView , then use this Item Decoration for spacing
class GridSpacingItemDecoration(
private val spanCount: Int,
private val spacing: Int,
private val includeEdges: Boolean
) : RecyclerView.ItemDecoration() {
override fun getItemOffsets(
outRect: Rect,
view: View,
parent: RecyclerView,
package com.jutt.medsreminders.helper
import android.content.Context
import com.google.gson.Gson
import com.jutt.medsreminders.data.bo.PushNotificationData
import com.jutt.medsreminders.data.enums.PushNotificationAction
import com.jutt.medsreminders.data.models.Alert
import com.jutt.medsreminders.injection.Injector
import com.jutt.medsreminders.utils.NotificationChannelCreator
import com.jutt.medsreminders.utils.NotificationHandler
@Zulqurnain
Zulqurnain / Failure.kt
Created March 29, 2022 17:21 — forked from rommansabbir/Failure.kt
Sealed Class that return HTTP Failure (4xx, 5xx)
sealed class Failure {
/*Network Error*/
class NetworkConnection(var additionalData: Any? = null) : Failure()
/*Exception*/
class Exception(var additionalData: Any? = null) : Failure()
/**
* Although the HTTP standard specifies "unauthorized",
* semantically this response means "unauthenticated".
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.os.Build
import android.view.Menu
import android.view.View
import android.view.WindowManager
import androidx.annotation.*
@Zulqurnain
Zulqurnain / MockCallInterceptor.kt
Last active December 27, 2021 23:39
MockCallInterceptor working in kotlin using Gson
class MockCallInterceptor<T> constructor(val value: T) : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val uri = chain.request().url().uri().toString()
val responseString: String = Gson().toJson(T::class.java)
val response = Response.Builder()
.code(200)
.message(responseString)
.request(chain.request())
.protocol(Protocol.HTTP_1_0)
@Zulqurnain
Zulqurnain / shadow.xml
Created September 7, 2021 08:23 — forked from lecho/shadow.xml
Android shadow drawable xml.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Drop Shadow Stack -->
<item>
<shape>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
@Zulqurnain
Zulqurnain / ViewDrawableUtils.kt
Created September 7, 2021 07:14
Get One Sides Shadow In View
/**
* Get Shadow Drawable with most elevation on provided shadowGravity Attribute
*/
fun getBoxShadowBackground(
view: View,
@ColorRes backgroundColor: Int = android.R.color.white,
radiusInDP: Float = view.convertDpTpPx(5F),
@ColorRes shadowColor: Int = android.R.color.black,
elevation: Int = 0,
shadowGravity: Int = Gravity.BOTTOM
@Zulqurnain
Zulqurnain / StreamMusicPlayerService.kt
Last active September 7, 2021 08:30
Simple music service using native music player and play any kind of online stream url
import android.app.Service
import android.content.Intent
import android.media.AudioManager
import android.media.MediaPlayer
import android.media.MediaPlayer.OnPreparedListener
import android.os.IBinder
import androidx.annotation.Nullable
import java.io.IOException
/**
@Zulqurnain
Zulqurnain / image_text_item.xml
Created March 27, 2018 04:49
Simple Image and Text list item , because you know very common code is uncommon on github ;)
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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">
<android.support.v7.widget.AppCompatImageView
@Zulqurnain
Zulqurnain / Truss.java
Created March 19, 2018 00:56 — forked from JakeWharton/Truss.java
Extremely simple wrapper around SpannableStringBuilder to make the API more logical and less awful. Apache 2 licensed.
import android.text.SpannableStringBuilder;
import java.util.ArrayDeque;
import java.util.Deque;
import static android.text.Spanned.SPAN_INCLUSIVE_EXCLUSIVE;
/** A {@link SpannableStringBuilder} wrapper whose API doesn't make me want to stab my eyes out. */
public class Truss {
private final SpannableStringBuilder builder;
private final Deque<Span> stack;