Skip to content

Instantly share code, notes, and snippets.

View alorma's full-sized avatar
🤡

Bernat Borrás Paronella alorma

🤡
View GitHub Profile
@alorma
alorma / MyActivity.java
Created July 24, 2014 05:50
Base layout to use material button in middle two views
package com.example.a557114.materialbutton;
import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<!-- http://developer.android.com/design/style/metrics-grids.html -->
<dimen name="gapSmall">4dp</dimen>
<dimen name="gapMedium">8dp</dimen>
<dimen name="gapLarge">16dp</dimen>
<dimen name="gapXLarge">32dp</dimen>
package com.tempos21.bluekiwi.ui.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.TextView;
@alorma
alorma / Interceptor.java
Created August 16, 2014 11:44
Enable and disable component
int enabled = PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
int disabled = PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
ComponentName component = new ComponentName(context,
Interceptor.class);
context.getPackageManager().setComponentEnabledSetting(component, disabled,
PackageManager.DONT_KILL_APP);
context.startActivity(intent);
InputMethodManager imm = (InputMethodManager)getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(searchEdit.getWindowToken(), 0);
@alorma
alorma / FABCenterLayout.java
Created August 26, 2014 18:03
Auto creates fab button at bottom of top view
package android.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import com.alorma.github.R;
public class CircleDrawable extends StateListDrawable {
public CircleDrawable() {
int stateFocused = android.R.attr.state_focused;
int statePressed = android.R.attr.state_pressed;
int stateSelected = android.R.attr.state_selected;
int stateDisabled = -android.R.attr.state_enabled;
int selectedColor = ColorHelper.getHexColorTransparent(getActivity(), "a4");
addState(new int[]{stateSelected}, new CircleShape(selectedColor));
@alorma
alorma / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@alorma
alorma / branch.sh
Last active August 29, 2015 14:06 — forked from kchodorow/branch.sh
#!/bin/bash
# Shows branches with descriptions
branches=$(git for-each-ref --format='%(refname)' refs/heads/ | sed 's|refs/heads/||')
for branch in $branches; do
last_used=$(git show --pretty=format:"%Cgreen%cr%Creset" $branch | head -1)
desc=$(git config branch.$branch.description)
if [ $branch == $(git rev-parse --abbrev-ref HEAD) ]; then
branch="*\t$last_used\t\033[0;32m$branch\033[0m"
else
public abstract class AbstractNetService<K> extends AsyncTaskLoader<K> {
private Bundle bundle;
private K mData;
public AbstractNetService(Context context, Bundle bundle) {
super(context);
this.bundle = bundle;
onContentChanged();
}