Skip to content

Instantly share code, notes, and snippets.

Avatar

Piyush Malaviya piyush-malaviya

  • Ahmedabad, Gujarat, India
View GitHub Profile
View FragmentStack.java
import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import java.util.HashMap;
View LocationSharingService.java
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.location.Location;
import android.os.Build;
import android.os.IBinder;
View LocationHelper.java
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
View DelayTextWatcher.java
import android.os.Handler;
import android.text.Editable;
import android.text.TextWatcher;
public abstract class DelayTextWatcher implements TextWatcher {
private final long DELAY = 300; // milliseconds
private Handler handler = new Handler();
private Runnable runnable = new Runnable() {
@Override
@piyush-malaviya
piyush-malaviya / Status bar transparent
Created Apr 19, 2019
Make Status bar transparent
View Status bar transparent
protected fun setStatusBarTranslucent(makeTranslucent: Boolean) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (makeTranslucent) {
window.setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
)
window.setFlags(
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
@piyush-malaviya
piyush-malaviya / EditTextDateValidation.java
Created Apr 19, 2019 — forked from devrath/EditTextDateValidation.java
Validation date in EditText for android while user is clicking
View EditTextDateValidation.java
//SOURCE: http://stackoverflow.com/questions/16889502/how-to-mask-an-edittext-to-show-the-dd-mm-yyyy-date-format
EditText date;
date = (EditText)findViewById(R.id.whichdate);
date.addTextChangedListener(tw);
TextWatcher tw = new TextWatcher() {
private String current = "";
@piyush-malaviya
piyush-malaviya / PDFUtil.java
Created Mar 19, 2019 — forked from tejpratap46/PDFUtil.java
Android Generate PDF from view
View PDFUtil.java
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.pdf.PdfDocument;
import android.graphics.pdf.PdfRenderer;
import android.os.AsyncTask;
import android.os.Build;
import android.os.ParcelFileDescriptor;
import android.util.Log;
View PixelUtil.java
/**
* Util class for converting between dp, px and other magical pixel units
*/
public class PixelUtil {
private PixelUtil() {
}
public static int dpToPx(Context context, int dp) {
int px = Math.round(dp * getPixelScaleFactor(context));
View RadarView.java
import android.animation.ObjectAnimator;
import android.animation.TypeEvaluator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.animation.LinearInterpolator;
@piyush-malaviya
piyush-malaviya / HomeActivity.java
Last active Apr 19, 2018
Get directories and files list using native methods
View HomeActivity.java
public class HomeActivity extends BaseAppCompatActivity {
// Used to load the 'native-lib' library on application startup.
static {
System.loadLibrary("native-lib");
}
public native Object[] getMediaFiles(String root);
@Override