Skip to content

Instantly share code, notes, and snippets.

View DevPicon's full-sized avatar
🎯
Looking for new ways to improve my job

Armando Picón DevPicon

🎯
Looking for new ways to improve my job
View GitHub Profile
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
public class Utils {
/**
* Get formatted representation of distance in kilometers
*
* @param distanceInMeters Distance in meters
* @return String representation of distance in kilometers
*/
public static String distanceFromYouFormatted(@NonNull Context context, float distanceInMeters) {
@DevPicon
DevPicon / UploadToS3Test.java
Created April 19, 2018 20:28
Uploading files to S3 with OKHttp
package com.cornershopapp.shopper.android.utils;
import java.io.File;
import java.io.IOException;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
@DevPicon
DevPicon / Application.java
Created February 5, 2018 21:21
Fresco Caching configuration, caching images and load images
Supplier<File> diskSupplier = new Supplier<File>() {
public File get() {
return getApplicationContext().getCacheDir();
}
};
DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(this)
.setBaseDirectoryName("images")
.setBaseDirectoryPathSupplier(diskSupplier)
/**
* Configure fresco using ONLY disk cache
*/
public void configFresco() {
Supplier<File> diskSupplier = new Supplier<File>() {
public File get() {
return getApplicationContext().getCacheDir();
}
};
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
public class ParseMockJson {
public static String readFromfile(String filename) {
StringBuilder returnString = new StringBuilder();
@DevPicon
DevPicon / androidSreenUtils.java
Created January 26, 2018 19:16
Some util methods to work with screen density and screenlayout
private boolean hasSmallDensity() {
int densityDpi = getResources().getDisplayMetrics().densityDpi;
if (densityDpi < DisplayMetrics.DENSITY_MEDIUM) {
return true;
}
return false;
}
@DevPicon
DevPicon / build.gradle
Created July 16, 2017 17:28
Just another build.gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "pe.devpicon.android.myoxxorequestapp"
minSdkVersion 21
@DevPicon
DevPicon / apply.kt
Created May 20, 2017 16:21
Algunos ejemplos de como usar Kotlin de una mejor manera
fun getDataSource(): MysqlDataSource {
val fileInputStream = FileInputStream("myfile.properties")
val properties = Properties()
properties.load(fileInputStream)
val mySqlDataSource = MysqlDataSource()?.apply {
setURL(properties.getProperty("MYSQL_DB_URL"))
user = properties.getProperty("MYSQL_DB_USERNAME")
setPassword(properties.getProperty("MYSQL_DB_PASSWORD"))
@DevPicon
DevPicon / README-Template.md
Created March 28, 2017 04:04 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites