Skip to content

Instantly share code, notes, and snippets.

View arriolac's full-sized avatar
🌍

Chris Arriola arriolac

🌍
View GitHub Profile
@arriolac
arriolac / TopCropImageView.java
Last active March 21, 2023 08:01
Custom Android ImageView for top-crop scaling of the contained drawable.
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* Created by chris on 7/27/16.
@arriolac
arriolac / Android Studio Tricks.md
Last active January 28, 2022 02:40
Some Android Studio Tricks.

Android Studio Notes

Android Studio keyboard shortcuts I use often.

Keyboard Shortcuts for Mac

  • SHIFT + F6 to refactor methods, classes, and variable names
  • CTRL + O to override methods
  • COMMAND + N
    • Generate getter, setter, and constructor method for a class (when in editor pane)
@arriolac
arriolac / .bashrc
Last active December 30, 2015 07:18
Useful Bash Aliases and Functions
### aliases for vim ###
# Given two files, performs a diff
alias mvimdiff='mvim -d'
# Given two files, does a vertical split
alias mvimvsplit='mvim -O'
### git ###
@arriolac
arriolac / AutoNextTextWatcher.java
Last active August 29, 2015 13:57
TextWatcher that will proceed to the next focusable view once the specified length has been reached
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
/**
* Created by chris on 3/13/14.
*/
public class AutoNextTextWatcher implements TextWatcher {
@arriolac
arriolac / AlphaImageButton.java
Created March 26, 2014 18:36
AlphaImageButton - auto shows disabled state on an ImageButton.
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageButton;
public class AlphaImageButton extends ImageButton {
private static final float ENABLED_ALPHA = 1.0f;
private static final float DISABLED_ALPHA = 0.5f;
public AlphaImageButton(Context context) {
@arriolac
arriolac / BundleUtil.java
Last active August 29, 2015 14:04
Utility class for writing Parcelables into a Bundle (ExampleActivity.java uses the Parceler library: https://github.com/johncarl81/parceler).
import android.os.Bundle;
import android.os.Parcelable;
/**
* Utility class for {@link android.os.Bundle}.
* Created by chris on 8/6/14.
*/
public class BundleUtil {
private static final String EXTRA_PARCELABLE_COUNT = "parcelable_count";
@arriolac
arriolac / ReminderIntentService.java
Last active July 27, 2016 16:48
IntentService for displaying a reminder
package chrisarriola.me.remind;
import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import chrisarriola.me.DataPath;
import chrisarriola.me.remind.util.LogUtil;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
public class AutomaticDripCoffeeMaker extends BaseCoffeeMaker {
public AutomaticDropCoffeeMaker() {
super();
}
public void scheduleBrew() {
// schedules a call to #brew()
}
@arriolac
arriolac / DrawingViewArchitecture.md
Created September 7, 2015 16:57
DrawingView Architecture

This is the proposed architecture for implementing drawing on text, photos and videos on Leo.

DrawingView

  • This is the custom view that will display the drawing created by the user.
  • Will be the View on "top" (relative to z-axis) of all the other views in AddTextActivity except the top bar Views.
  • Notes:
    • overrides onTouchEvent(...)
    • has a method called setEnabled(boolean enabled)
      • enabled value will be returned by onTouchEvent(...). this means that it will intercept all touch events when enabled.
  • Note: this will be toggled by the compose views (enabled when in drawing mode, disabled when not in drawing mode).
@arriolac
arriolac / CustomView.java
Last active January 18, 2024 19:53
Saving state on configuration changes for a custom view.
package com.operator.android;
import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
import android.view.View;
/**
* A custom {@link View} that demonstrates how to save/restore instance state.
*/