Skip to content

Instantly share code, notes, and snippets.

View enginebai's full-sized avatar
📈
Focusing, Learning, Improving, Evolving

Engine Bai enginebai

📈
Focusing, Learning, Improving, Evolving
View GitHub Profile
@enginebai
enginebai / MapActivity.java
Created March 26, 2014 05:39
MapActivity
import android.app.Activity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
@enginebai
enginebai / LocationActivity.java
Last active August 29, 2015 14:00
Android getLocation()
public Location getCurrentLocation()
{
this.locationManager = (LocationManager) this.getSystemService( Context.LOCATION_SERVICE );
Location location = null;
boolean isGPSEnabled = locationManager.isProviderEnabled( LocationManager.GPS_PROVIDER );
boolean isNetworkEnabled = this.locationManager.isProviderEnabled( LocationManager.NETWORK_PROVIDER );
if ( !( isGPSEnabled || isNetworkEnabled ) )
this.checkGPSSetting();
else
{
@enginebai
enginebai / NetworkStatus.java
Last active August 29, 2015 14:00
The code can detect the network status on Android mobile.
public void checkNetworkType()
{
ConnectivityManager connectivityManager = (ConnectivityManager) this.getSystemService( CONNECTIVITY_SERVICE );
NetworkInfo networkActive = connectivityManager.getActiveNetworkInfo();
NetworkInfo networkWifi = connectivityManager.getNetworkInfo( ConnectivityManager.TYPE_WIFI );
boolean connect = false;
if ( connectivityManager.getNetworkInfo( ConnectivityManager.TYPE_WIFI ).getState() == NetworkInfo.State.CONNECTED )
connect = true;

Developer Cheat Sheets

This are my cheat sheets that I have compiled over the years. Tired of searching Google for the same things, I started adding the information here. As time went on, this list has grown. I use this almost everyday and this Gist is the first bookmark on my list for quick and easy access.

I recommend that you compile your own list of cheat sheets as typing out the commands has been super helpful in allowing me to retain the information longer.

@enginebai
enginebai / CardView_Ripple.xml
Created May 26, 2015 01:15
CardView + Ripple
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
android:id="@+id/card_movie_list_item"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:custom="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':superRecyclerView')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.balysv:material-ripple:1.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.hdodenhof:circleimageview:1.2.2'
compile 'com.github.rey5137:material:1.0.0'
compile 'it.neokree:MaterialTabs:0.11'
compile 'com.loopj.android:android-async-http:1.4.6'
@enginebai
enginebai / activity_main.xml
Last active December 9, 2015 22:51
Movie lol Front Page Layouts
<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<include
@Override
public void onNavigationDrawerItemSelected(int position) {
// update the main content by replacing fragments
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
Fragment fragment;
String fragmentTag;
switch (position) {
case 0:
fragment = MoviePageFragment.newInstance();
public class MoviePageFragment extends Fragment implements MaterialTabListener, View.OnClickListener {
public static final int[] TABS = {R.string.tab_movie_thisweek,
R.string.tab_movie_intheater, R.string.tab_movie_comingsoon};
public enum SortBy {
LASTEST,
OLDEST,
BOMBER
}
public class MovieListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private List<MovieListItem> mMovieList = new ArrayList<>();
private Context mContext;
private boolean mShowBomberCount;
public MovieListAdapter(Context context, List<MovieListItem> mMovieList, boolean showBomberCount) {
this.mContext = context;
this.mMovieList = mMovieList;
this.mShowBomberCount = showBomberCount;