Skip to content

Instantly share code, notes, and snippets.

View praveenb's full-sized avatar

praveen praveenb

  • PC Control Systems India Pvt Ltd
  • Hyderabad, India
View GitHub Profile
@praveenb
praveenb / README.md
Created January 20, 2022 17:05 — forked from kasperpeulen/README.md
How to pretty-print JSON using Dart.
@praveenb
praveenb / Converter.java
Created December 2, 2020 12:41 — forked from SatyaSnehith/Converter.java
Convert Bytes to KB, MB, GB, TB - java
class Converter{
public static void main(String[] args) {
System.out.println(getSize(1048576));
}
public static String getSize(long size) {
long n = 1024;
String s = "";
double kb = size / n;
double mb = kb / n;
double gb = mb / n;
@praveenb
praveenb / Custom font in WebView
Last active September 26, 2020 20:13 — forked from andrea-ale-sbarra/Custom font in WebView
How to add custom font in Android WebView.
//View container..
View rootView = inflater.inflate(R.layout.fragment1, container, false);
//Global WebView
mWebView = (WebView) rootView.findViewById(R.id.enter_text);
//Font must be placed in assets/fonts folder
String text = "<html><style type='text/css'>@font-face { font-family: spqr; src: url('fonts/spqr.ttf'); } body p {font-family: spqr;}</style>"
+ "<body >" + "<p align=\"justify\" style=\"font-size: 22px; font-family: spqr;\">" + getString(R.string.enter_text) + "</p> "+ "</body></html>";
@praveenb
praveenb / gist:4b9593992a9deaa582336bdabe910477
Created September 24, 2019 14:48 — forked from dseerapu/gist:b768728b3b4ccf282c7806a3745d0347
Android app inactivity timeout | Android Logout timer
public class LogOutTimerUtil {
public interface LogOutListener {
void doLogout();
}
static Timer longTimer;
static final int LOGOUT_TIME = 600000; // delay in milliseconds i.e. 5 min = 300000 ms or use timeout argument
public static synchronized void startLogoutTimer(final Context context, final LogOutListener logOutListener) {
@praveenb
praveenb / download.dart
Created June 14, 2019 16:09 — forked from slightfoot/download.dart
Download file in Dart/Flutter
static var httpClient = new HttpClient();
Future<File> _downloadFile(String url, String filename) async {
var request = await httpClient.getUrl(Uri.parse(url));
var response = await request.close();
var bytes = await consolidateHttpClientResponseBytes(response);
String dir = (await getApplicationDocumentsDirectory()).path;
File file = new File('$dir/$filename');
await file.writeAsBytes(bytes);
return file;
}
@praveenb
praveenb / layout#activity_main.xml
Created January 23, 2019 19:14 — forked from artzmb/layout#activity_main.xml
Android - Selector in vector drawables
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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"
tools:context="ru.artzmb.solar.MainActivity">
<ImageView
@praveenb
praveenb / README.md
Created June 14, 2018 06:26 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

All hex value from 100% to 0% alpha:

@praveenb
praveenb / README.md
Created January 9, 2018 14:12 — forked from polbins/README.md
Simple RecyclerView Divider

Simple RecyclerView Divider

Simple Horizontal Divider Item Decoration for RecyclerView

    mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(
            getApplicationContext()
    	));

NOTE: Add item decoration prior to setting the adapter

@praveenb
praveenb / InteractiveScrollView.java
Created August 9, 2016 10:52 — forked from marteinn/InteractiveScrollView.java
ScrollView with a OnBottomReachedListener for Android
package se.marteinn.ui;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ScrollView;
/**
* Triggers a event when scrolling reaches bottom.
package info.piwai.android;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.util.AttributeSet;
import android.util.Log;