Skip to content

Instantly share code, notes, and snippets.

View lalbuquerque's full-sized avatar

Lucas Albuquerque lalbuquerque

View GitHub Profile
@haroldolivieri
haroldolivieri / ResizableTextView.java
Last active May 3, 2016 23:45
A resizable textview with animation that depends on screen width and decreases in relation to stepTextSize attribute
public class ResizableTextView extends TextView {
private final float mMaximumTextSize;
private final float mMinimumTextSize;
private final float mStepTextSize;
private final Paint mTempPaint = new TextPaint();
private final Rect mTempRect = new Rect();
private int mWidthConstraint = -1;
@dpolishuk
dpolishuk / gist:ecd944f9cf84c62dfd5d
Created November 17, 2015 07:31
Broken kapt in latest Kotlin beta [1.0.0-beta-2422, 1.0.0-beta-2417]
Note: Generating a MembersInjector or Factory for io.dp.weather.app.activity.debug.DebugActivity. Prefer to run the dagger processor over that class instead.
warning: The following options were not recognized by any processor: '[kapt.kotlin.generated]'
/Users/deepol/work/weather-android-kotlin/app/build/generated/source/kapt/release/io/dp/weather/app/adapter/PlacesAdapter_MembersInjector.java:14: error: cannot access NonExistentClass
private final MembersInjector<OrmliteCursorRecyclerViewAdapter<Place, Holder>> supertypeInjector;
^
class file for error.NonExistentClass not found
Note: /Users/deepol/work/weather-android-kotlin/app/build/generated/source/kapt/release/io/dp/weather/app/activity/DaggerActivityComponent.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
:app:compileReleaseJavaWithJavac FAILED
@rodrigohenriques
rodrigohenriques / ClickToSelectEditText.java
Last active July 28, 2024 11:13
Used to make your EditText a better option than Spinners
public class ClickToSelectEditText<T extends Listable> extends AppCompactEditText {
List<T> mItems;
String[] mListableItems;
CharSequence mHint;
OnItemSelectedListener<T> onItemSelectedListener;
public ClickToSelectEditText(Context context) {
super(context);
package utils;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
public class RootUtil {
public static boolean isDeviceRooted() {
return checkRootMethod1() || checkRootMethod2() || checkRootMethod3() || checkRootMethod4();
}
@qk7b
qk7b / drawer_open.java
Last active August 29, 2015 14:21
Robotium 5.3.1 (App compat API 21+) / Open navigation drawer
/**
* As we use app compat it seems Solo#setNavigationDrawer is not doing well (drawer does not open, but the button is clicked)
* Same result for clickOnView(getView(android.R.id.home))
*
* This code opens the navigation drawer on the main thread
* Be aware : you need to provide your DrawerLayout id (you can do it in params)
*/
public void openCompatNavigationDrawer() {
getInstrumentation().runOnMainSync(new Runnable() {
@Override
@gabrielemariotti
gabrielemariotti / Readme.md
Last active January 1, 2025 22:35
A SimpleSectionedRecyclerViewAdapter: use this class to realize a simple sectioned `RecyclerView.Adapter`.

You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.

The RecyclerView should use a LinearLayoutManager. You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)

This is a porting of the class SimpleSectionedListAdapter provided by Google

Screen

Example:

@saadfarooq
saadfarooq / android_replace_in_manifest.gradle
Last active March 1, 2024 15:47
Gradle function to replace a placeholder string in AndroidManifest.xml with productFlavor package name
replaceInManifest = {variant, fromString, toString ->
def flavor = variant.productFlavors.get(0)
def buildtype = variant.buildType
def manifestFile = "$buildDir/manifests/${flavor.name}/${buildtype.name}/AndroidManifest.xml"
def updatedContent = new File(manifestFile).getText('UTF-8').replaceAll(fromString, toString)
new File(manifestFile).write(updatedContent, 'UTF-8')
}
@dodyg
dodyg / gist:5823184
Last active October 20, 2024 12:25
Kotlin Programming Language Cheat Sheet Part 1

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.