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 / 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() {
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;
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;

System directories

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

External storage directories

public static class ScaleToFitWidhtHeigthTransform implements Transformation {
private int mSize;
private boolean isHeightScale;
public ScaleToFitWidhtHeigthTransform(int size, boolean isHeightScale){
mSize =size;
this.isHeightScale = isHeightScale;
}
#!/bin/bash -e
# Ensure we're running in location of script.
cd "`dirname $0`"
for f in *; do
if [[ $f == *.png ]];
then
echo "...$f"
convert $f -resize 37.5% ../res/drawable-ldpi/$f
AlertDialog.Builder builder = new AlertDialog.Builder(Activity.this);
builder.setTitle("Delete")
.setIcon(android.R.drawable.ic_dialog_alert)
.setMessage("Do you want to delete?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
DAO dao = new DAO(Activity.this);
dao.deleteValues(valueSelected);
dao.close();
SelectionQueryBuilder q = new SelectionQueryBuilder()
.expr("is_awesome", EQ, true)
.expr("money", GT, 50.0f)
.expr("speed", LT, 21.1f)
.or()
.expr("door_number", EQ, 123)
.or().expr(
new SelectionQueryBuilder()
.expr("a", GT, 0)
.expr("a", LT, 100)
@dp-singh
dp-singh / Location
Created November 21, 2014 05:11
Location based Class android
/*
* This file is part of the AusStage Utilities Package
*
* The AusStage Utilities Package is free software: you can redistribute
* it and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* The AusStage Utilities Package is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
@dp-singh
dp-singh / writeToSystem
Created October 13, 2014 09:56
Snippet to store string data in andrdoi
public Boolean write(String fname, String fcontent) {
try {
String fpath = "/sdcard/" + fname + ".txt";
File file = new File(fpath);
// If file does not exists, then create it
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);