Skip to content

Instantly share code, notes, and snippets.

View mgarnerdev's full-sized avatar

Michael Garner mgarnerdev

  • Walmart
  • Northwest Arkansas
View GitHub Profile
// All requesting permissions needs to happen inside of an Activity.
// When you request a permission it is like calling startActivityForResult()
// So you need to be able to have the call back that will handle whether the
// permission was granted or not. Checking permissions can be done from any context
// Also keep in mind for this implementation of runtime permissions you need to
// have included the support library in your build.gradle file.
// this is for your use only so this just needs to be distinct for your purposes.
private static final int REQUEST_LOCATION_PERMISSION = 101;
// Check for the permission you need
String permission = Manifest.permission.ACCESS_FINE_LOCATION;
@mgarnerdev
mgarnerdev / RelativeKeyboardListenerLayout
Created March 11, 2016 01:49
Relative Layout that lets you listen for keyboard opens and closes.
import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.RelativeLayout;
/**
* Created by mgarner on 3/8/2016.
package com.example.mgarner.blankslate;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.app.Presentation;
import android.content.Context;
import android.location.Location;
import android.provider.CalendarContract;
import android.widget.Toast;
import java.util.ArrayList;
/**
* Created by mgarner on 12/11/2015.
import android.app.Presentation;
import android.content.Context;
import android.location.Location;
import android.provider.CalendarContract;
import android.widget.Toast;
import java.util.ArrayList;
/**
* Created by mgarner on 12/11/2015.
@mgarnerdev
mgarnerdev / PagingRecyclerView
Created December 8, 2015 23:23
Horizontal Snapping RecyclerView with Page Indication
import android.content.Context;
import android.graphics.PointF;
import android.support.v7.widget.LinearSmoothScroller;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.MotionEvent;
/**