Skip to content

Instantly share code, notes, and snippets.

Avatar
🤡

Bernat Borrás Paronella alorma

🤡
View GitHub Profile
@alorma
alorma / MyActivity.java
Created Jul 24, 2014
Base layout to use material button in middle two views
View MyActivity.java
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;
View dimens.xml
<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>
View LineTextView.java
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 Aug 16, 2014
Enable and disable component
View Interceptor.java
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);
View close_keyboard.java
InputMethodManager imm = (InputMethodManager)getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(searchEdit.getWindowToken(), 0);
@alorma
alorma / FABCenterLayout.java
Created Aug 26, 2014
Auto creates fab button at bottom of top view
View FABCenterLayout.java
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;
View CircleDrawableState.java
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 Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View 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
View BaseLoader.java
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();
}