Skip to content

Instantly share code, notes, and snippets.

View robUx4's full-sized avatar

Steve Lhomme robUx4

View GitHub Profile
@robUx4
robUx4 / drawer_main.xml
Last active August 29, 2015 14:16
Navigation Drawer layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- The main content view -->
<include layout="@layout/main" />
@robUx4
robUx4 / map_db.json
Created February 20, 2015 08:20
Example CPG with hashmap cache
{
"fields": [
{
"name": "ACCOUNT",
"type": "String",
"isKey": true,
},
{
"name": "DOMAIN",
"type": "String",
@robUx4
robUx4 / Lang.java
Created February 12, 2015 10:01
Force Android user language
public static void setUILanguage(Context context, String uiLang) {
if (!TextUtils.isEmpty(uiLang) && context!=null) {
int sep = uiLang.indexOf("-r");
final Locale setLocale;
if (sep==-1)
setLocale = new Locale(uiLang);
else
setLocale = new Locale(uiLang.substring(0,sep), uiLang.substring(sep+2));
final Resources res = context.getResources();
@robUx4
robUx4 / C:\temp\with space\work
Created February 5, 2015 12:33
AAPT windows space issue
C:\temp\with space\work>gradlew aR
Using local InMemoryDB library in :
Building RELEASE
:preBuild UP-TO-DATE
:preReleaseBuild UP-TO-DATE
:checkReleaseManifest
:preDebugBuild UP-TO-DATE
:InMemoryDb:compileLint
:InMemoryDb:copyReleaseLint UP-TO-DATE
:InMemoryDb:preBuild UP-TO-DATE
/**
* This method is used to enable streaming of a HTTP request body
* without internal buffering, when the content length is known in
* advance.
*
* <P> An exception will be thrown if the application attempts to write
* more data than the indicated content-length, or if the application
* closes the OutputStream before writing the indicated amount.
*
@robUx4
robUx4 / Cursor
Created December 30, 2014 09:59
Sqlite de gitans
mColumns = {java.lang.String[4]@831729442344}
[0] = {java.lang.String@831729442376}"HOST"
[1] = {java.lang.String@831729442408}"COUNT(date)"
[2] = {java.lang.String@831729442480}"PORT"
[3] = {java.lang.String@831729442512}"_id"
@robUx4
robUx4 / FragmentCursor.java
Last active January 6, 2016 17:05
Basic SwipeRefreshLayout support in ListFragment, you get support for an empty view in ListFragment. You need to set an OnRefreshListener and call setRefreshing()
import org.gawst.proxy.ui.SwipeListFragment;
import android.content.Context;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.Loader;
import android.support.v4.widget.CursorAdapter;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.View;
@robUx4
robUx4 / PictureCache.java
Created December 18, 2014 11:50
Picture Cache abstraction interface
import java.io.IOException;
import android.widget.ImageView;
public interface PictureCache<L, R extends RunningLoad, AUTH_COOKIE, AUTH_LOADER, VIEW_TYPE extends ImageView> {
R load(VIEW_TYPE view, String imageUrl, PictureLoader loader, SizeConstraint sizeConstraint, AUTH_LOADER networkLoader, AUTH_COOKIE cookie, long freshness);
void loadFromAnyThread(String imageUrl, PictureLoader loader, SizeConstraint sizeConstraint, AUTH_LOADER withAuth, AUTH_COOKIE cookie);
@robUx4
robUx4 / gist:c94f2835b292453e8035
Created December 17, 2014 08:48
Adding picasso in my project
Error:java.lang.NullPointerException
at com.android.dx.cf.code.ConcreteMethod.<init>(ConcreteMethod.java:87)
at com.android.dx.cf.code.ConcreteMethod.<init>(ConcreteMethod.java:75)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:271)
... 24 more
...while processing <init> (Lcom/levelup/touiteur/pictures/AvatarCache;Landroid/content/Context;Ljava/lang/String;D)V
...while processing com/levelup/touiteur/pictures/AvatarCache$1.class
@robUx4
robUx4 / gradle log
Created December 8, 2014 14:21
Setting multiDexEnabled true
Error:Execution failed for task ':Plume:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\android-sdk\build-tools\21.1.1\dx.bat --dex --no-optimize --multi-dex --main-dex-list C:\Users\Dell990MT\Documents\Program\LevelUp\Plume\work\Plume\build\intermediates\multi-dex\debug\maindexlist.txt --output C:\Users\Dell990MT\Documents\Program\LevelUp\Plume\work\Plume\build\intermediates\dex\debug --input-list=C:\Users\Dell990MT\Documents\Program\LevelUp\Plume\work\Plume\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
3
Output:
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:1048)
at com.android.dx.cf.code.Ropper.doit(Ropper.java:742)