Skip to content

Instantly share code, notes, and snippets.

View milaptank's full-sized avatar
💭
a lazy android developer

milap tank milaptank

💭
a lazy android developer
View GitHub Profile
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import android.content.Context;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
public class UDID {
public static boolean isInternetAvailable() {
Runtime runtime = Runtime.getRuntime();
try {
Process ipProcess = runtime.exec("/system/bin/ping -c 1 8.8.8.8");
int exitValue = ipProcess.waitFor();
Debug.i(exitValue + "");
return (exitValue == 0);
} catch (IOException | InterruptedException e) {
@milaptank
milaptank / EmptyRecyclerView.java
Created February 26, 2016 13:59 — forked from AnirudhaAgashe/EmptyRecyclerView.java
RecyclerView with provosion to add empty view like list view. Displayed when the data set is empty
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
public class EmptyRecyclerView extends RecyclerView {
public static String saveBitmapToFile(String path) {
try {
File file = new File(path);
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
o.inSampleSize = 6;
FileInputStream inputStream = new FileInputStream(file);
@milaptank
milaptank / 0_reuse_code.js
Created April 27, 2016 10:03
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@milaptank
milaptank / CursorRecyclerAdapter.java
Created June 10, 2016 09:03 — forked from quanturium/CursorRecyclerAdapter.java
A simple implementation of CursorAdapter for the new RecyclerView. It is designed to work with CursorLoaders and do not register any content observer (which can cause leaks if not handled properly)
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 ARNAUD FRUGIER
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
package api;
import android.os.Handler;
import android.os.Looper;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
@milaptank
milaptank / AbstractRecyclerAdapter.java
Created August 11, 2016 16:43 — forked from iChintanSoni/BaseRecyclerAdapter.java
This implementation of generic recycler adapter is truely inspired from Firebase Database UI Adapter.
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
class Test
{
static int x = 100; // line 3
int y = 200; // line 4
public static void main(String []args)
{
final int z; // line 7
z = x + y; // line 8
System.out.println(z);
package com.mpt.android.multitextwatcher;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
public class MultiTextWatcher implements TextWatcher {
private OnTextWatcher onTextWatcher;
private EditText editText;