Skip to content

Instantly share code, notes, and snippets.

View alorma's full-sized avatar
🤡

Bernat Borrás Paronella alorma

🤡
View GitHub Profile
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().getDecorView()
.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
getWindow().setStatusBarColor(Color.TRANSPARENT);
public class MaterialDialogUtils {
private MaterialDialog.Builder builder;
private COUNTDOWN_BUTTON countdownButton;
private long timeInMillis;
private boolean positive;
private int positiveText;
private int positiveTextCountdown;
/**
* returns true if mock location enabled, false if not enabled.
*/
public static boolean isMockSettingsON(Context context) {
return !Settings.Secure.getString(context.getContentResolver(),
Settings.Secure.ALLOW_MOCK_LOCATION).equals("0");
}
@alorma
alorma / Colors.java
Created June 30, 2015 08:07
getTheme colors
private int fetchPrimaryColor() {
int colorAccent = Color.parseColor("#FF0000");
int attr = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? android.R.attr.colorPrimary : R.attr.colorPrimary;
TypedArray a = getContext().getTheme().obtainStyledAttributes(new int[]{attr});
colorAccent = a.getColor(0, colorAccent);
a.recycle();
return colorAccent;
@alorma
alorma / RepeatTask.java
Last active August 29, 2015 14:23
Snippet that show a good way to run a Runnable in a fixed rate time
ScheduledExecutorService executorService = Executors.newScheduledThreadPool(5);
executorService.scheduleAtFixedRate(runnable, 0, 5, TimeUnit.SECONDS);
package com.worldline.evasdk.view.utils;
import android.support.v4.view.ViewCompat;
import android.view.MotionEvent;
import android.view.View;
/**
* Created by a557114 on 07/05/2015.
*/
public class ElevationUtils {
@alorma
alorma / map_row.xml
Last active August 29, 2015 14:19
Example cardview
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card="http://schemas.android.com/apk/res-auto"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="180dp"
android:background="@color/white"
card_view:cardCornerRadius="4dp"
android:clickable="true"
jdbcjbdg
public abstract class ArrayAdapterRecycler<T, VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> {
private List<T> items;
protected ArrayAdapterRecycler(List<T> items) {
this.items = items;
}
@Override
public int getItemCount() {
@alorma
alorma / FABCenterLayout.java
Last active August 29, 2015 14:16
FabLayout with center ,left or right position
package com.worldline.evasdk.view.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;