Skip to content

Instantly share code, notes, and snippets.

View pratamawijaya's full-sized avatar

Pratama Nur Wijaya pratamawijaya

View GitHub Profile
@pratamawijaya
pratamawijaya / EndlessListActivity.java
Created July 25, 2017 04:24 — forked from polbins/EndlessListActivity.java
Android Endless Scroll using RecyclerView
public class EndlessListActivity<D> extends Activity {
private EndlessRecyclerOnScrollListener mEndlessScrollListener;
private EndlessListAdapter mAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RecyclerView listView = (RecyclerView) findViewById(R.id.list);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
@pratamawijaya
pratamawijaya / update.sh
Last active July 23, 2018 07:17
Update android sdk via bash
#!/usr/bin/env bash
#
# Install JUST the required dependencies for the project.
# May be used for ci or other team members.
#
for I in android-25 \
build-tools-25.0.2 \
tool \
extra-android-m2repository \
@pratamawijaya
pratamawijaya / ResultHolder.java
Created June 15, 2017 05:00 — forked from 1zaman/ResultHolder.java
Loader for Retrofit 2.0 API. This uses the framework implementation, but it can be adapted to use the support library implementation without much modification.
package com.example.retrofit.loader;
import retrofit.Response;
/**
* A wrapper around the Retrofit {@link Response} that will
* throw any loading errors upon retrieval.
*
* @param <T> The data type that was loaded.
*/
@pratamawijaya
pratamawijaya / APP
Created April 17, 2017 04:39 — forked from pishguy/APP
Implementing JobManager on Dagger2
public class Alachiq extends MultiDexApplication {
...
private static Context context;
public static SlidrConfig config;
private GithubService githubService;
private Picasso picasso;
private static GithubApplicationComponent component;
private JobManager jobManager;
private static Alachiq instance;
@pratamawijaya
pratamawijaya / MySQL.md
Created March 15, 2017 04:55 — forked from nrollr/MySQL.md
Install MySQL on El Capitan using Homebrew

Install MySQL on OS X El Capitan

Normally the installation of MySQL can be achieved with a single command, which executes a script provided by MacMiniVault : bash <(curl -Ls http://git.io/eUx7rg)

However, at the time of writing the script is not compatible with OS X El Capitan (10.11)

Install MySQL using Homebrew

An alternative to the aforementioned installation script is installing MySQL using Homebrew. This gist assumes you already have Homebrew installed, if not first read the article "Homebrew and El Capitan"

Make sure Homebrew has the latest formulae, so run brew update first

@pratamawijaya
pratamawijaya / intellij_username
Created February 26, 2017 07:21 — forked from dedickinson/intellij_username
Override the username in IntelliJ templates
(For OS X)
See: https://www.jetbrains.com/idea/help/tuning-intellij-idea.html
> mkdir ~/Library/Preferences/IntelliJ\ IDEA\ 14\ CE/
> cp /Applications/IntelliJ\ IDEA\ 14\ CE.app/Contents/bin/idea.vmoptions ~/Library/Preferences/IntelliJ\ IDEA\ 14\ CE/
> vi ~/Library/Preferences/IntelliJ\ IDEA\ 14\ CE/idea.vmoptions
Add the line below:
-Duser.name=Duncan Dickinson
@pratamawijaya
pratamawijaya / tmux-cheatsheet.markdown
Created January 13, 2017 06:44 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@pratamawijaya
pratamawijaya / ApiModule.java
Created December 17, 2016 10:28 — forked from koesie10/ApiModule.java
Retrofit 1 error handling behaviour in Retrofit 2
// Dagger 1 example
@Module(
complete = false,
library = true
)
public final class ApiModule {
@Provides
@Singleton
Retrofit provideRetrofit(Gson gson, Application app) {
return new Retrofit.Builder()
@pratamawijaya
pratamawijaya / file_transparent.txt
Created November 28, 2016 05:18
Android Transparent Background HEX
100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
@pratamawijaya
pratamawijaya / TextHighlight.java
Created November 27, 2016 10:53
TextHighlight.java
// digunakan untuk Highlight text yang sedang dicari
private void setColor(TextView view, String fulltext, String subtext, int color) {
view.setText(fulltext, TextView.BufferType.SPANNABLE);
Spannable str = (Spannable) view.getText();
int i = fulltext.indexOf(subtext);
str.setSpan(new ForegroundColorSpan(color), i, i + subtext.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}