Skip to content

Instantly share code, notes, and snippets.

View alorma's full-sized avatar
🤡

Bernat Borrás Paronella alorma

🤡
View GitHub Profile
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.RelativeSizeSpan;
import android.text.style.SuperscriptSpan;
/**
* Created by a557114 on 02/02/2015.
*/
public class MoneyUtils {
@alorma
alorma / designer.html
Last active August 29, 2015 14:15
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">
SupportMapFragment mapFragment;
if (savedInstanceState == null) {
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria cri = new Criteria();
String bbb = locationManager.getBestProvider(cri, true);
Location myLocation = locationManager.getLastKnownLocation(bbb);
if (myLocation != null) {
LatLng ll = new LatLng(myLocation.getLatitude(), myLocation.getLongitude());
public static Drawable getDefaultButtonBackground(Context context) {
int[] attrsButtonStyle = {android.R.attr.buttonStyle};
TypedArray taButtonStyle = context.getTheme().obtainStyledAttributes(attrsButtonStyle);
int buttonStyle = taButtonStyle.getResourceId(0, 0);
taButtonStyle.recycle();
int[] attrs = {android.R.attr.background};
TypedArray ta = context.getTheme().obtainStyledAttributes(buttonStyle, attrs);
Drawable background = ta.getDrawable(0);
ta.recycle();
@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;
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() {
jdbcjbdg
@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"
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 / 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);