private void addShortcut(){
Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
// Shortcut name
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
shortcut.putExtra("duplicate", false); // Just create once
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Display display = getWindowManager().getDefaultDisplay(); | |
String displayName = display.getName(); // minSdkVersion=17+ | |
Log.i(TAG, "Pantalla = " + displayName); | |
// Tamaño en píxeles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.database.DataSetObserver; | |
import android.graphics.Rect; | |
import android.util.AttributeSet; | |
import android.view.GestureDetector; | |
import android.view.GestureDetector.OnGestureListener; | |
import android.view.MotionEvent; | |
import android.view.View; | |
import android.widget.AdapterView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ToolbarActivity extends AppCompatActivity { | |
// Set the flags that fit your needs | |
private static final int ENABLED_SCROLL_BEHAVIOR = AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS | AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL; | |
private static final int DISABLED_SCROLL_BEHAVIOR = 0; | |
private static final int SCROLL_DOWN = 1; | |
//Injected via ButterKnife (http://jakewharton.github.io/butterknife) | |
@InjectView(R.id.toolbar) | |
Toolbar toolbar; | |
@InjectView(R.id.recyclerview) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class Result<S, F> { | |
private final Optional<S> success; | |
private final Optional<F> failure; | |
public Result(Optional<S> success, Optional<F> failure) { | |
this.success = success; | |
this.failure = failure; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _GETCH_H_ | |
#define _GETCH_H_ | |
#include <termios.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
/* reads from keypress, doesn't echo */ | |
int getch(void) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.milanuncios.milanunciosandroid.common.remoteconfig; | |
import com.alexsimo.toolbelt.optional.Optional; | |
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; | |
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings; | |
import com.milanuncios.milanunciosandroid.BuildConfig; | |
import java.util.Map; | |
import rx.AsyncEmitter; | |
import rx.Observable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int color = palette.getVibrantColor(defaultColor); | |
int r = (color >> 16) & 0xFF; | |
int g = (color >> 8) & 0xFF; | |
int b = (color >> 0) & 0xFF; | |
row.setBackgroundColor(color); | |
//@see http://stackoverflow.com/questions/12043187/how-to-check-if-hex-color-is-too-black | |
double luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; |
OlderNewer