Skip to content

Instantly share code, notes, and snippets.

View kyze8439690's full-sized avatar
📱
Working

Yang Hui kyze8439690

📱
Working
View GitHub Profile
import android.support.v4.view.ViewPager;
import android.view.View;
public class StackPageTransformer implements ViewPager.PageTransformer {
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void transformPage(View page, float position) {
final float alpha;
final float translationX;
package android.support.v4.app;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
@kyze8439690
kyze8439690 / CursorAdapter2
Created October 19, 2014 06:07
CursorAdapter used for RecyclerView
package me.yugy.cnbeta.widget;
import android.content.Context;
import android.database.ContentObserver;
import android.database.Cursor;
import android.database.DataSetObservable;
import android.database.DataSetObserver;
import android.os.Handler;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
@kyze8439690
kyze8439690 / android.mk
Created August 14, 2014 01:59
Jni android.mk
#Start from here
LOCAL+PATH:= $(call my-dir)
#Module1 definition start
include $(CLEAR_VARS)
LOCAL_MODULE := modulename1
LOCAL_SRC_FILES := modulesource1.c
include $(BUILD_STATIC_LIBRARY)
@kyze8439690
kyze8439690 / gist:8eb2da153cd207cd330b
Created July 6, 2014 13:28
run asynctask concurrently on targetSdkVersion 13+
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR1) {
task.execute();
} else {
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
@kyze8439690
kyze8439690 / gist:5bafc99a65a0f4298db3
Created January 11, 2014 08:21
thing to do when release
1.debug false
2.sign true
3.test proguard
4.change version code
5.upload new apk to umeng and test update works
6.merge master to release branch
7.upload new apk to appstores
-optimizationpasses 5
# 混淆时不会产生形形色色的类名
-dontusemixedcaseclassnames
# 指定不去忽略非公共的类库
-dontskipnonpubliclibraryclasses
# 不预校验
-dontpreverify
@kyze8439690
kyze8439690 / ListViewOnScrollListener.java
Created December 26, 2013 07:34
OnScrollListener to detect scrollup and scrolldown in ListView.
public class ListViewOnScrollListener extends OnScrollListener{
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {}
private int lastVisibleItem = 0;
private int lastY = 0;
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
int top = 0;
@kyze8439690
kyze8439690 / SquareRelativeLayout.java
Created November 30, 2013 17:59
A custom RelativeLayout which will auto match its height to its width
public class SquareRelativeLayout extends RelativeLayout{
public SquareRelativeLayout(Context context) {
super(context);
}
public SquareRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
@kyze8439690
kyze8439690 / build.gradle
Last active January 19, 2017 08:52
Use build.gradle to compile all jars in libs folder and ndk support
//compile all jar in libs folder
dependencies {
compile fileTree(dir: 'libs' , include: '*.jar')
}
//pack all so file into a jar and compile it
task nativeLibsToJar(
type: Zip,
description: 'create a jar archive of the native libs') {
destinationDir file('./libs')
baseName 'native-libs'