Skip to content

Instantly share code, notes, and snippets.

View dp-singh's full-sized avatar
🎯
Focusing

Dharmendra Pratap Singh dp-singh

🎯
Focusing
View GitHub Profile
@dp-singh
dp-singh / Setting up retrolamda java problem.groovy
Last active May 10, 2016 05:24
It is used to setup retrolambda in android
String java8 = getJavaVersion(8)
String java7 = getJavaVersion(7)
retrolambda {
jdk java8
oldJdk java7
javaVersion JavaVersion.VERSION_1_7
// jvmArgs '-arg1', '-arg2' < if I don't comment this line gradle fails
defaultMethods false
incremental true
@dp-singh
dp-singh / HeaderFooterRecyclerViewAdapter.java
Created December 2, 2015 00:26 — forked from mheras/HeaderFooterRecyclerViewAdapter.java
Header & footer support for RecyclerView.Adapter
public abstract class HeaderFooterRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final int VIEW_TYPE_MAX_COUNT = 1000;
private static final int HEADER_VIEW_TYPE_OFFSET = 0;
private static final int FOOTER_VIEW_TYPE_OFFSET = HEADER_VIEW_TYPE_OFFSET + VIEW_TYPE_MAX_COUNT;
private static final int CONTENT_VIEW_TYPE_OFFSET = FOOTER_VIEW_TYPE_OFFSET + VIEW_TYPE_MAX_COUNT;
private int headerItemCount;
private int contentItemCount;
private int footerItemCount;
@dp-singh
dp-singh / activity_main.xml
Created November 17, 2015 15:57 — forked from tsmsogn/activity_main.xml
[android]Google Play Services SDK
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
@dp-singh
dp-singh / BatteryActivity.java
Created November 13, 2015 00:28 — forked from gabrielemariotti/BatteryActivity.java
Android Wear: small gist to get data from Battery
public class BatteryActivity extends Activity {
//UI Elements
private TextView mTextViewLevel;
private TextView mTextViewTemperature;
private TextView mTextViewVoltage;
private TextView mTextViewHealth;
//Battery details
private int level;
@dp-singh
dp-singh / Restarting Service If it is killed by the user
Created August 6, 2015 09:01
Managing service if it killed by the user
//Sticky Service
public class StickyService extends Service
{
private static final String TAG = "StickyService";
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
@dp-singh
dp-singh / Sharing Android Gist
Created August 1, 2015 07:07
Sharing image and text though whatsapp
try{
shareIntent.setAction(Intent.ACTION_SEND);
//Target whatsapp:
shareIntent.setPackage("com.whatsapp");
//Add text and then Image URI
shareIntent.putExtra(Intent.EXTRA_TEXT, picture_text);
shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
shareIntent.setType("image/jpeg");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(shareIntent);
/**
* A collection of authentication and account connection utilities. With strong inspiration from the Google IO session
* app.
* @author Dandré Allison
*/
public class AccountUtils {
/**
* Interface for interacting with the result of {@link AccountUtils#getUserProfile}.
*/
public class AnimatedActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//opening transition animations
overridePendingTransition(R.anim.activity_open_translate,R.anim.activity_close_scale);
}
// Slide up animation
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="100%"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="0" />
@dp-singh
dp-singh / gist:8bf39f7dfd65f5820340
Created April 8, 2015 17:41
Image rendering with blur effect
Transformation blurTransformation = new Transformation() {
@Override
public Bitmap transform(Bitmap source) {
Bitmap blurred = Blur.fastblur(LiveImageView.this.context, source, 10);
source.recycle();
return blurred;
}
@Override
public String key() {