Skip to content

Instantly share code, notes, and snippets.

View imranhsn's full-sized avatar
🏠
Working from home

Imran imranhsn

🏠
Working from home
  • Sporty Group
  • Dhaka, Bangladesh
  • 17:45 (UTC +06:00)
View GitHub Profile
@imranhsn
imranhsn / PieChartColors
Created August 21, 2019 06:26
Dynamically generate pie chart color based on base color and number of slices.
private fun getPieChartColors(
numPieSlices: Int, adjacentColors: Boolean
): IntArray {
val colors = IntArray(numPieSlices)
val baseColor = Color.parseColor("#8A56E2")
colors[0] = baseColor
val hsv = FloatArray(3)
Color.RGBToHSV(
Color.red(baseColor), Color.green(baseColor), Color.blue(baseColor),
hsv
package test;
import android.arch.lifecycle.LiveData;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
@imranhsn
imranhsn / LinearGradientDrawable.java
Created October 29, 2017 08:43 — forked from n1lesh/LinearGradientDrawable.java
Android Gradient Toolbar and Statusbar
RelativeLayout layout = (RelativeLayout) findViewById(R.id.rel);
GradientDrawable drawable = new GradientDrawable();
drawable.setColors(new int[] {
Color.parseColor("#FFF6B7"),
Color.parseColor("#F6416C")
});
drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
drawable.setOrientation(GradientDrawable.Orientation.LEFT_RIGHT);