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
public static class ScaleToFitWidhtHeigthTransform implements Transformation {
private int mSize;
private boolean isHeightScale;
public ScaleToFitWidhtHeigthTransform(int size, boolean isHeightScale){
mSize =size;
this.isHeightScale = isHeightScale;
}

System directories

Method Result
Environment.getDataDirectory() /data
Environment.getDownloadCacheDirectory() /cache
Environment.getRootDirectory() /system

External storage directories

package com.example;
import android.content.Context;
import com.squareup.okhttp.HttpResponseCache;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.picasso.OkHttpDownloader;
import com.squareup.picasso.Picasso;
import javax.net.ssl.SSLContext;
import java.io.File;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.SearchView;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@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() {
// 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" />
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);
}
/**
* 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}.
*/
@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);
@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;