Skip to content

Instantly share code, notes, and snippets.

View ityancs's full-sized avatar
🎯
Focusing

Gekson ityancs

🎯
Focusing
View GitHub Profile
@ityancs
ityancs / README.md
Last active August 29, 2015 14:17 — forked from polbins/README.md

Simple RecyclerView Divider

Simple Horizontal Divider Item Decoration for RecyclerView

    mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(
            getApplicationContext()
    	));

NOTE: Add item decoration prior to setting the adapter

/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ityancs
ityancs / 0_reuse_code.js
Last active August 29, 2015 14:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@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;
/**
* 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.
*/
/**
* 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 };
/**
* 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 };
/**
* 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.
*
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();
}
@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;