Skip to content

Instantly share code, notes, and snippets.

View guffyWave's full-sized avatar

Gufran Khurshid guffyWave

View GitHub Profile
@guffyWave
guffyWave / countries.json
Created February 26, 2021 04:52 — forked from keeguon/countries.json
A list of countries in JSON
[
{name: 'Afghanistan', code: 'AF'},
{name: 'Åland Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'AndorrA', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},
Taken from
https://www.programcreek.com/java-api-examples/?code=lujianzhao/AndroidBase/AndroidBase-master/AndroidBase/src/main/java/com/ljz/base/common/diskcache/DiskLruCacheHelper.java#
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Environment;
import android.util.Log;
import com.jakewharton.disklrucache.DiskLruCache;
@guffyWave
guffyWave / Connectivity.java
Created May 15, 2018 09:41 — forked from emil2k/Connectivity.java
Android utility class for checking device's network connectivity and speed.
/*
* Copyright (c) 2017 Emil Davtyan
*
* 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 furnished to do so, subject to
* the following conditions:
@guffyWave
guffyWave / gist:f1095faeaa284daa0731ee9992fbb552
Created December 28, 2017 13:08
onRetainNonConfigurationInstance
public Object onRetainNonConfigurationInstance() {
return this;
}
Then in YourActivity's onCreate()
public void onCreate(Bundle savedState)
{
YourActivity prevActivity = (YourActivity)getLastNonConfigurationInstance();
if(prevActivity!= null) {
@guffyWave
guffyWave / ImageCompression
Created August 11, 2017 13:51 — forked from vipulasri/ImageCompression
Whatsapp Like Image Compression
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.media.ExifInterface;
import android.os.AsyncTask;
import android.os.Environment;
@guffyWave
guffyWave / Car.java
Created June 24, 2017 22:18 — forked from alejandrogr/Car.java
Deal with list of Refs in objectify
package com.alejandrogr.gists.ofylistref;
import com.googlecode.objectify.Ref;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Ignore;
import com.googlecode.objectify.annotation.Load;
import com.googlecode.objectify.annotation.OnLoad;
import java.util.ArrayList;
import java.util.List;
compile 'org.jsoup:jsoup:1.10.2'
Document doc;
try {
doc = Jsoup.connect("https://jsoup.org/").followRedirects(true).get();
// doc=Jsoup.parse(new File("/home/gufran/Desktop/JSoupStudy/StumbleUpon - StumbleUpon.html"),null);
// get title of the page
String title = doc.title();
For Class
/**
* <h1>Hello, World!</h1>
* The HelloWorld program implements an application that
* simply displays "Hello World!" to the standard output.
* <p>
* Giving proper comments in your program makes it more
* user friendly and it is assumed as a high quality code.
*
public class ShowHideToggleButton extends LinearLayout {
Context context;
public ShowHideToggleButton(final Context context) {
this(context, null);
}
public ShowHideToggleButton(Context context, AttributeSet attrs) {
this(context, attrs, 0);