Skip to content

Instantly share code, notes, and snippets.

View rhexgomez's full-sized avatar

Rhex Gomez rhexgomez

  • Philippines
View GitHub Profile
@rhexgomez
rhexgomez / EnumTest.java
Created December 2, 2016 07:22
Java Enum#values() nature.
public class EnumTest {
public static void main(String[] args) {
TestEnum[] values = TestEnum.values();
TestEnum[] values2 = TestEnum.values();
// Compare the array itself.
if (values == values2) {
System.out.println("Same");
} else {
sourceSets {
main {
res.srcDirs =
[
"src/main/res",
"src/main/second-res/splash",
"src/main/second-res/home",
"src/main/second-res/logon"
];
}
@rhexgomez
rhexgomez / MainActivity.java
Last active September 15, 2016 06:01
The `onLoaderReset()` is only called when the user presses the back button and not when calling `restartLoader()`. A related issue is discussed here https://code.google.com/p/android/issues/detail?id=68896
public class MainActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks<Cursor> {
public static final String LOG_TAG = MainActivity.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
@rhexgomez
rhexgomez / ContextHelper.java
Last active October 22, 2016 06:23
The proper way of getting the Activity or Fragment Manager from the Context.
/*
* Copyright 2016 Elmar Rhex Gomez.
*
* 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
@rhexgomez
rhexgomez / ReusableFuture.java
Created August 3, 2016 08:26
The reusable implementation of Future<T> Blocking callback in Android Volley
/*
* Copyright 2016 Elmar Rhex Gomez.
*
* 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
@rhexgomez
rhexgomez / UploadRequest.java
Last active August 1, 2016 01:56
Upload image using Android Volley and does not need any other 3rd party library.
/*
* Copyright (C) 2016 Elmar Rhex Gomez
*
* 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
@rhexgomez
rhexgomez / Foo.java
Created April 7, 2016 14:45
Builder Design Pattern using Java Generics.
/*
* Copyright 2016 Elmar Rhex Gomez.
*
* 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
@rhexgomez
rhexgomez / InvitationInformation.java
Created February 23, 2016 07:28
Wedding Planner Basic App
/*
* Copyright 2016 Elmar Rhex Gomez.
*
* 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
@rhexgomez
rhexgomez / AS External Module.md
Last active December 22, 2015 06:44
Setting up external Module as library in Android Studio.

In settings.gradle

include ':app',':mymodule'
project(":mymodule").projectDir = new File("/<prject full path>/mymodule");
@rhexgomez
rhexgomez / Apache 2.0.java
Created December 2, 2015 05:16
An Apache Opensource License Header
/*
* Copyright ${YEAR} <Full name>
*
* 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