Skip to content

Instantly share code, notes, and snippets.

@Viyu
Viyu / Bitmap.scaleShortAndLimitLong
Created July 31, 2015 02:58
Scale the short side of the bitmap to goal value and limit the long side to the limit value.
/**
* 把小边放大至要求值,同时限制大边不超过要求值
*
* @param bitmap
* @param shortSideGoal
* 短边需要放大到的目标值
* @param longSideLimit
* 长边需要被限制的值得
* @return
*/
@Viyu
Viyu / OnMultiTouchListener.java
Created July 22, 2015 01:33
Multi Touch Listener
/**
* Multi touch event listener
*
* @author viyu
*
*/
public abstract class OnMultiTouchListener implements OnTouchListener {
/**
* last touch time
@Viyu
Viyu / KeyValueTable
Created April 2, 2015 06:02
Key-Value Table
/**
* 专门用来存储key-value的表格,shared preferences的db版
* From db version 1
* @author viyu
*/
public final class KeyValueTable {
/**
* @param key
@Viyu
Viyu / IMessage.java
Created January 19, 2015 03:30
An Implementation of Android Message Framework
public interface IMessage {
}
@Viyu
Viyu / GridItemView.java
Created January 19, 2015 02:09
Grid item view holder for GirdView which show the border lines properly.
public class GridItemView {
private View mView = null;
private FrameLayout mContentLayout = null;
private View mTopLine = null;
private View mBottomLine = null;
private View mLeftLine = null;
private View mRightLine = null;
public GridItemView(LayoutInflater inflater, int contentLayoutResId) {
@Viyu
Viyu / 可复用View的PagerAdapter
Last active August 29, 2015 14:07
Adapter for ViewPager which reuse the item views
package com.msyd.client.ui.viewadapter;
import java.util.ArrayList;
import java.util.List;
import android.support.v4.view.PagerAdapter;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
@Viyu
Viyu / gist:9521561
Last active August 29, 2015 13:57
A encapsulated popup window which show given content view(mostly menus).
/**
*
* @author viyu
*
*/
public class MenuPopWindow extends PopupWindow implements OnClickListener {
private Activity mActivity = null;
private CustomView mContentView = null;
private TextView mItemQuit = null;
public boolean isGPSIsOn() {
LocationManager locationManager = (LocationManager) mContext
.getSystemService(Context.LOCATION_SERVICE);
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
}
public void openGPSSettingPage() {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@Viyu
Viyu / AndroidLedDemoActivity.java
Created December 23, 2013 08:18
Android Led Demo
package com.demo.led;
import java.util.HashMap;
import java.util.Map;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.graphics.Color;
import android.os.Bundle;
@Viyu
Viyu / DragAndDropActivity.java
Last active May 7, 2019 18:18
Android Drag And Drop Demo
package com.viyu.draganddropdemo;
import com.viyu.dradanddropdemo.R;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipDescription;
import android.os.Bundle;
import android.util.Log;
import android.view.DragEvent;