Skip to content

Instantly share code, notes, and snippets.

View JoaquimLey's full-sized avatar
👨‍💻
Product oriented, software perfectionist and developer

Joaquim Ley JoaquimLey

👨‍💻
Product oriented, software perfectionist and developer
View GitHub Profile
@JoaquimLey
JoaquimLey / .gitignore
Last active August 14, 2016 13:58
Pretty standard/complete .gitignore with focus on Android
# Local files
/local.properties
/build
/captures
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
@JoaquimLey
JoaquimLey / .travis.yml
Last active August 14, 2016 14:01
Travis config for Android
language: android
jdk:
# Jdk version used by your project
- oraclejdk8
sudo: false
android:
components:
@JoaquimLey
JoaquimLey / CurrentTimeParserUtil.java
Last active August 14, 2016 14:02
Get current DAY_MONTH_YEAR_HOUR_MINUTES_SECONDS
Calendar now = Calendar.getInstance();
int year = now.get(Calendar.YEAR);
int month = now.get(Calendar.MONTH); // Note: Starts at 0
int day = now.get(Calendar.DAY_OF_MONTH);
int hour = now.get(Calendar.HOUR_OF_DAY);
int minute = now.get(Calendar.MINUTE);
int second = now.get(Calendar.SECOND);
int millis = now.get(Calendar.MILLISECOND);
// NOTE: Starts at 0, hence month + 1
System.out.printf("%d-%02d-%02d %02d:%02d:%02d.%03d", year, month + 1, day, hour, minute, second, millis);
@JoaquimLey
JoaquimLey / CircleImageTransforation.md
Created August 17, 2016 21:55
Transform an ImageView into circular shape, works with Picasso

Using Picasso with a circular ImageView

With this helper class you can transform your ordinary ImageView into ciruclar shape using Picasso library.

###Include this class into your project:

package com.<YOUR-PACKAGE-NAME>
	
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
public class BusRepository {
private static BusRepository sInstance;
private final RemoteRepository remoteRepository;
private final BusDao busDao;
public static BusRepository getInstance(RemoteRepository remoteRepository, BusDao busDao) {
if (sInstance == null) {
public class BusListActivity extends AppCompatActivity implements LifecycleRegistryOwner,
BusListAdapter.ClickListener {
private final LifecycleRegistry lifecycleRegistry = new LifecycleRegistry(this);
private BusListViewModel viewModel;
private BusListAdapter adapter;
private ContentLoadingProgressBar progressDialogView;
public abstract class BasePresenter<V> {
protected V mView;
public final void attachView(@NonNull V view) {
mView = view;
}
public final void detachView() {
mView = null;
@JoaquimLey
JoaquimLey / ssh-add.sh
Last active August 2, 2018 01:12
Add ssh identity
ssh-add ~/.ssh/id_rsa
@JoaquimLey
JoaquimLey / ManualChangeUser.md
Last active November 14, 2018 02:52
Change github user on terminal, manual way

First restart the ssh agent

  killall ssh-agent; eval `ssh-agent`

You should see something along the lines of: Agent pid 59566

Now just add your "new" user .ssh key

ssh-add ~/.ssh/id_rsa

import androidx.annotation.MainThread
import androidx.annotation.Nullable
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import java.util.concurrent.atomic.AtomicBoolean
/**