Skip to content

Instantly share code, notes, and snippets.

@tobrun
tobrun / gist:7299827
Created November 4, 2013 08:46
Adding platform tools to path (OSX)
// create .bash_profile
touch .bash_profile
// open file with TextEdit
open -e .bash_profile
// insert line into TextEdit
export PATH=$PATH:/Users/tvn/Software/adt-bundle-mac-x86_64-20130911/sdk/platform-tools/
// save TextEdit and reload file
@tobrun
tobrun / gist:7719277
Created November 30, 2013 13:44
Immersive sticky mode android
@SuppressLint("NewApi")
@Override
public void onWindowFocusChanged(final boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
mDecorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
@tobrun
tobrun / Handle Deprecated API Android
Created September 24, 2014 08:14
Handle Deprecated API Android
int sdk = android.os.Build.VERSION.SDK_INT;
if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
setBackgroundDrawable();
} else {
setBackground();
}
@tobrun
tobrun / gist:5ab43beee185ab792462
Last active August 29, 2015 14:06
Generic findViewById
public class ViewFinder {
@SuppressWarnings("unchecked")
public static <T extends View> T find(Activity activity, int id) {
return (T) activity.findViewById(id);
}
@SuppressWarnings("unchecked")
public static <T extends View> T find(Fragment fragment, int id) {
return (T) fragment.getView().findViewById(id);
@tobrun
tobrun / gist:3043b8dc9e5cb01af37d
Created October 2, 2014 09:06
Disable screenshot
// DISABLE SCREENSHOT
getWindow().setFlags(LayoutParams.FLAG_SECURE,LayoutParams.FLAG_SECURE);
@tobrun
tobrun / gist:40b833e7879478190c0b
Created October 3, 2014 14:18
Tracking memory from command line
adb shell dumpsys meminfo <process name>
/*
* Copyright (C) 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@tobrun
tobrun / SymbolGenerator.java
Last active February 7, 2021 14:46
SymbolGenerator allows to convert a Android SDK View to a Bitmap. Use SymbolGenerator in combination with SymbolLayer. Add the result from SymbolGenerator#generate(View) with MapboxMap#addImage(String, Bitmap) and link the id of the image with PropertyFactory#iconImage(String) when setting properties to a SymbolLayer with SymbolLayer#setProperti…
/**
* Utility class to generate Bitmaps for Symbol.
* <p>
* Bitmaps can be added to the map with {@link com.mapbox.mapboxsdk.maps.MapboxMap#addImage(String, Bitmap)}
* </p>
*/
public final class SymbolGenerator {
/**
* Generate a Bitmap from an Android SDK View.
@tobrun
tobrun / adb_pull.sh
Last active September 25, 2017 19:04
A common issue that Android developers face with copying files between device and development machine is that the structure of the external storage folders can differ. A robust way of getting files through adb is using the EXTERNAL_STORAGE environment variable of the device as a base.
# below matches files saved to Environment.getExternalStorageDirectory() + "/from/path"
adb pull "`adb shell 'printenv EXTERNAL_STORAGE' | tr -d '\r'`/from/path