Skip to content

Instantly share code, notes, and snippets.

View webserveis's full-sized avatar

Webserveis webserveis

View GitHub Profile
@webserveis
webserveis / doubleBackPressed_drawableMenu.java
Created September 21, 2016 13:38
Sistema pulsación doble para salir App con DrawableMenu de Android
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
if (firstClickTime + Constants.TIME_INTERVAL > System.currentTimeMillis()) {
super.onBackPressed();
return;
@webserveis
webserveis / Ejemplo1.gradle
Last active September 28, 2016 16:38
Para aumentar la velocidad de compilación usando Gradle en Android Studio 2.2
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
dexOptions {
maxProcessCount 2
javaMaxHeapSize "2g"
}
defaultConfig {
@webserveis
webserveis / draw_item_single_line_avatar_with_text.xml
Created September 23, 2016 17:38
Layout para crear lista simple compatible recyclerview en Android
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="?android:attr/selectableItemBackground"
android:paddingEnd="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingStart="16dp"
/**
* Drawables which should be tinted with the value of {@code R.attr.colorControlNormal},
* using the default mode.
*/
private static final int[] TINT_COLOR_CONTROL_NORMAL = {
R.drawable.abc_ic_ab_back_mtrl_am_alpha,
R.drawable.abc_ic_go_search_api_mtrl_alpha,
R.drawable.abc_ic_search_api_mtrl_alpha,
R.drawable.abc_ic_commit_search_api_mtrl_alpha,
R.drawable.abc_ic_clear_mtrl_alpha,
package app.descubrirosona.lite.adapters;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import io.realm.RealmObject;
import io.realm.RealmResults;
public abstract class RealmRecyclerViewAdapter<T extends RealmObject, VH extends RecyclerView.ViewHolder>
private void setupActionBar() {
getLayoutInflater().inflate(R.layout.toolbar_settings, (ViewGroup)findViewById(android.R.id.content));
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
// Show the Up button in the action bar.
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(getString(R.string.settings_activity_title)); //Fix title after change locale
@webserveis
webserveis / fetchAccentColor.java
Created October 9, 2016 14:21
Get atributes android programallity
private int fetchAccentColor(Activity context) {
TypedValue typedValue = new TypedValue();
TypedArray a = context.obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorAccent});
int color = a.getColor(0, 0);
a.recycle();
return color;
}
package com.webserveis.app.testpatternnavigation;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@webserveis
webserveis / material text sizes.md
Last active September 20, 2023 10:10 — forked from passsy/material text sizes.md
Material font sizes

Material text sizes XML for Android

Simple helper file for standard text sizes in material design. The sizes are provided by the material design documentation https://www.google.com/design/spec/style/typography.html#typography-roboto

material typography

Standard Styles

Too many type sizes and styles at once can wreck any layout. A typographic scale is a limited set of type sizes that work well together, along with the layout grid. The basic set of styles are based on a typographic scale of 12, 14, 16, 20, and 34.

@webserveis
webserveis / MainActivity.java
Last active November 26, 2016 14:06
Add Dismiss Action in Android Wear
package com.webserveis.app.testandroidwear;
import android.nfc.Tag;
import android.os.Bundle;
import android.support.wearable.activity.WearableActivity;
import android.support.wearable.view.BoxInsetLayout;
import android.support.wearable.view.DismissOverlayView;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;