Skip to content

Instantly share code, notes, and snippets.

View yesidlazaro's full-sized avatar
🏠
Working from home

Yesid yesidlazaro

🏠
Working from home
View GitHub Profile
<service android:name=".ListenerServiceFromWear">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>
public class MyFragment {
boolean loaded;
private void maybeLoad() {
if (!loaded && getUserVisibleHint()) {
loaded = true;
loadMyData();
}
}
@Override
public class ColoredSnackBar {
private static final int red = 0xfff44336;
private static final int green = 0xff4caf50;
private static final int blue = 0xff2195f3;
private static final int orange = 0xffffc107;
private static View getSnackBarLayout(Snackbar snackbar) {
if (snackbar != null) {
package com.twnel.android.ui.views;
/**
* Created by etiennelawlor on 8/20/15.
*/
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.support.annotation.NonNull;
import android.support.v7.graphics.Palette;
import android.widget.ImageView;
@yesidlazaro
yesidlazaro / im_edittext.xml
Created November 15, 2013 23:18
Setup for Edittext in a mobile messenger compose activity
<EditText android:id="@+id/edtInput"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
android:imeOptions="actionSend|flagNoEnterAction"
android:maxLines="4"
android:maxLength="2000"
android:hint="@string/compose_hint"/>
DEPRECATED
About 24 hours after publishing this library, I found out that a regular LinearLayout with measureWithLargestChild="true" can indeed be used to achieve the desired result. Here is an example of how this can be done:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:measureWithLargestChild="true"
private void shareItem(String title, String link) {
// Standard message to send
String msg = title + " " + link;
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(share, 0);
if (!resInfo.isEmpty()) {
List<Intent> targetedShareIntents = new ArrayList<Intent>();
@yesidlazaro
yesidlazaro / DividerItemDecoration.java
Created February 8, 2016 16:03 — forked from zokipirlo/DividerItemDecoration.java
DividerItemDecoration. RecyclerView.ItemDecoration simple implementation
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
public class SQLQueryBuilder {
private static final String STATEMENT_SELECT = "SELECT";
private static final String STATEMENT_DISTINCT_SELECT = "SELECT DISTINCT";
private static final String STATEMENT_UPDATE = "UPDATE";
private static final String STATEMENT_INSERT_INTO = "INSERT INTO";
private static final String STATEMENT_DELETE = "DELETE FROM";
private static final String WHERE = "WHERE";
private static final String FROM = "FROM";