Skip to content

Instantly share code, notes, and snippets.

View ityancs's full-sized avatar
🎯
Focusing

Gekson ityancs

🎯
Focusing
View GitHub Profile
@ityancs
ityancs / NetWorkUtils.java
Created June 3, 2016 06:53
NetWork utils for Android to get Android Network Info
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.text.TextUtils;
import android.util.Log;
import android.util.Patterns;
import java.net.InetAddress;
@ityancs
ityancs / WaterWaveView.java
Created March 16, 2016 03:37 — forked from AvatarQing/WaterWaveView.java
水波浪效果
package com.example.glowbuttontest;
import java.lang.ref.WeakReference;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
@ityancs
ityancs / EndlessRecyclerOnScrollListener.java
Created January 7, 2016 06:06 — forked from ssinss/EndlessRecyclerOnScrollListener.java
Endless RecyclerView OnScrollListener
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
@ityancs
ityancs / SoftKeyboard.java
Created December 21, 2015 13:26 — forked from felHR85/SoftKeyboard.java
A solution to catch show/hide soft keyboard events in Android http://felhr85.net/2014/05/04/catch-soft-keyboard-showhidden-events-in-android/
/*
* Author: Felipe Herranz ([email protected])
* Contributors:Francesco Verheye ([email protected])
* Israel Dominguez ([email protected])
*/
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import android.os.Handler;
public class measureSize{
public void getSize1(){
int w = View.MeasureSpec.makeMeasureSpec(0,
View.MeasureSpec.UNSPECIFIED);
int h = View.MeasureSpec.makeMeasureSpec(0,
View.MeasureSpec.UNSPECIFIED);
imageView.measure(w, h);
int height = imageView.getMeasuredHeight();
int width = imageView.getMeasuredWidth();
}
/**
* A {@link android.support.v7.widget.RecyclerView.LayoutManager} implementation
* that places children in a two-dimensional grid, sized to a fixed column count
* value. User scrolling is possible in both horizontal and vertical directions
* to view the data set.
*
* <p>The column count is controllable via {@link #setTotalColumnCount(int)}. The layout manager
* will generate the number of rows necessary to accommodate the data set based on
* the fixed column count.
*
/**
* ItemDecoration implementation that applies and inset margin
* around each child of the RecyclerView. It also draws item dividers
* that are expected from a vertical list implementation, such as
* ListView.
*/
public class GridDividerDecoration extends RecyclerView.ItemDecoration {
private static final int[] ATTRS = { android.R.attr.listDivider };
/**
* ItemDecoration implementation that applies and inset margin
* around each child of the RecyclerView. It also draws item dividers
* that are expected from a vertical list implementation, such as
* ListView.
*/
public class DividerDecoration extends RecyclerView.ItemDecoration {
private static final int[] ATTRS = { android.R.attr.listDivider };
/**
* Fragment used for managing interactions for and presentation of a navigation drawer.
* See the <a href="https://developer.android.com/design/patterns/navigation-drawer.html#Interaction">
* design guidelines</a> for a complete explanation of the behaviors implemented here.
*/
public class NavigationDrawerFragment extends Fragment {
/**
* Remember the position of the selected item.
*/
@ityancs
ityancs / TextViewVertical.java
Created September 25, 2015 07:14
A vertical TextView like Chinese old text style
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.FontMetrics;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;