Skip to content

Instantly share code, notes, and snippets.

View robUx4's full-sized avatar

Steve Lhomme robUx4

View GitHub Profile
@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 / 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"
/**
* 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 / 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
@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 / 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 / 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 / gist:95fc695540ac34e51807
Created March 10, 2015 13:18
VLC d3d11 compilation
libtool: link: i686-w64-mingw32-gcc -std=gnu99 -shared .libs/libdirect3d11_plugin.dll.def ../modules/.libs/module.rc.o video_output/msw/.libs/libdirect3d11_plugin_la-direct3d11.o video_output/msw/.libs/libdirect3d11_plugin_la-common.o video_output/msw/.libs/libdirect3d11_plugin_la-events.o video_output/msw/.libs/libdirect3d11_plugin_la-win32touch.o ../compat/.libs/libcompat.a -L/c/Users/robUx4/Documents/Program/Videolabs/work/contrib/i686-w64-mingw32/lib ../src/.libs/libvlccore.dll.a /c/Users/robUx4/Documents/Program/Videolabs/work/contrib/i686-w64-mingw32/lib/libgpg-error.a -lwinmm -lws2_32 -lgdi32 -lole32 -luuid -g -mms-bitfields --static -static-libgcc -Wl,--nxcompat -Wl,--no-seh -Wl,--dynamicbase -o .libs/libdirect3d11_plugin.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libdirect3d11_plugin.dll.a
@robUx4
robUx4 / gist:1bb8fc594a7f09e52956
Created March 10, 2015 15:05
mingw netoapi.h fail in VLC
In file included from ../../../work/extras/package/win32/../../../include/vlc_common.h:43:0,
from ../../../work/extras/package/win32/../../../modules/services_discovery/upnp.hpp:34,
from ../../../work/extras/package/win32/../../../modules/services_discovery/upnp.cpp:35:
C:/msys64/mingw32/i686-w64-mingw32/include/stdlib.h:346:36: error: conflicting declaration of C function 'int atoi(const char*)'
int __cdecl atoi(const char *_Str);
^
In file included from ../config.h:815:0,
from ../../../work/extras/package/win32/../../../modules/services_discovery/upnp.cpp:32:
../../../work/extras/package/win32/../../../include/vlc_fixups.h:304:34: note: previous declaration 'NET_IFINDEX atoi(PCSTR)'
# define if_nametoindex(name) atoi(name)
@robUx4
robUx4 / output.gralde
Created August 12, 2015 08:30
rename output with mapping
applicationVariants.all { variant ->
//def file = variant.outputFile
if (variant.buildType.name == "release") {
variant.outputs.each { output ->
//println ">> outputFile for " + variant.buildType.name + " = " + output.outputFile
output.outputFile = new File(projectDir.parent + "/../builds", archivesBaseName + "-" + versionName + ".apk")
}
} else if (variant.buildType.name == "kindle") {
variant.outputs.each { output ->
//println ">> outputFile for " + variant.buildType.name + " = " + output.outputFile