Skip to content

Instantly share code, notes, and snippets.

@vahid-m
vahid-m / Parallax.kt
Created May 26, 2022 20:22 — forked from surajsau/ParallaxScreen.kt
Parallax effect with Jetpack Compose
val context = LocalContext.current
val scope = rememberCoroutineScope()
var data by remember { mutableStateOf<SensorData?>(null) }
DisposableEffect(Unit) {
val dataManager = SensorDataManager(context)
dataManager.init()
scope.launch {
@vahid-m
vahid-m / Badge.java
Created August 10, 2021 19:02
Utility class to create Drawable with custom text badge. Uses https://github.com/devunwired/textdrawable.
import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RectShape;
import android.graphics.drawable.shapes.Shape;
@vahid-m
vahid-m / HttpStatusCodeHelper.java
Created July 29, 2021 11:28 — forked from jemshit/HttpStatusCodeHelper.java
HTTP Status Codes, Helper Class in JAVA
public class HttpStatusCodeHelper {
/**
* Gets Http Status Code Information for given Code. No Reflection, No Enum
* @param code
* @return type + text
*/
public static String getHttpTypeAndTextByCode(final int code) {
//region 1xx
@vahid-m
vahid-m / Example.kt
Created May 30, 2021 09:06 — forked from radoyankov/Example.kt
Easy Spannable on Kotlin
val spanned = spannable{ bold("some") + italic(" formatted") + color(Color.RED, " text") }
val nested = spannable{ bold(italic("nested ")) + url("www.google.com", "text") }
val noWrapping = bold("no ") + sub("wrapping ) + sup("also ") + "works"
text_view.text = spanned + nested + noWrapping
@vahid-m
vahid-m / mutablelivedata.md
Created May 2, 2021 15:39 — forked from humblehacker/mutablelivedata.md
Don't expose MutableLiveData
@vahid-m
vahid-m / HeaderItemDecoration.kt
Created May 1, 2021 10:32 — forked from filipkowicz/HeaderItemDecoration.kt
Item Decorator for sticky headers in Kotlin
package com.filipkowicz.headeritemdecorator
/*
solution based on - based on Sevastyan answer on StackOverflow
changes:
- take to account views offsets
- transformed to Kotlin
- now works on viewHolders
@vahid-m
vahid-m / README.MD
Created November 27, 2020 17:03 — forked from gabrielemariotti/README.MD
How to use the ShapeableImageView.

The Material Components Library introduced with the 1.2.0-alpha03 the new ShapeableImageView.

In your layout you can use:

 <com.google.android.material.imageview.ShapeableImageView
      android:id="@+id/image_view"
      app:srcCompat="@drawable/..." />

Then in your code apply the ShapeAppearanceModel to define your custom corners:

@vahid-m
vahid-m / AnimateCounter.java
Created December 22, 2019 14:10 — forked from bmarrdev/AnimateCounter.java
AnimateCounter provides ability to animate the counting of numbers using the builtin Android Interpolator animation functionality.
/*
* Copyright (C) 2015 Hooked On Play
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.annotation.AttrRes
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.NestedScrollingChild3
import androidx.core.view.NestedScrollingChildHelper
import com.redmadrobot.plazius.R
@vahid-m
vahid-m / DeviceOrientation
Created October 4, 2019 18:44 — forked from Abdelhady/DeviceOrientation
A utility class to help get current device orientation, you will need it if you decided to fix the activity's orientation in the manifest :)
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.media.ExifInterface;
/**
* Created by abdelhady on 9/23/14.
*
* to use this class do the following 3 steps in your activity: