Skip to content

Instantly share code, notes, and snippets.

Avatar
🦀
Rustacean

Folyd Folyd

🦀
Rustacean
View GitHub Profile
@Folyd
Folyd / NonSwipeableViewPager.java
Last active Sep 9, 2015
A Custom ViewPager which can been disable swipe.
View NonSwipeableViewPager.java
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import com.folyd.app.R;
public class NonSwipeableViewPager extends ViewPager {
@Folyd
Folyd / WrapGridView.java
Last active Sep 15, 2015
A custom GridView which can wrap content.
View WrapGridView.java
import android.content.Context;
import android.util.AttributeSet;
import android.widget.GridView;
/**
* A custom GridView which can wrap content.
*/
public class WrapGridView extends GridView {
public WrapGridView(Context context) {
@Folyd
Folyd / ToggleVisibilityHelper.java
Created Sep 15, 2015
Toggle visibility helper class
View ToggleVisibilityHelper.java
import android.os.Handler;
/**
* A helper class can toggle target object visibility automatically.
* It is very useful for MediaController (or ActionBar) when play video in Activity.
*/
public abstract class ToggleVisibilityHelper {
/**
* Record the time while user lasted click.
View CircleProgressBar.java
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.View;
@Folyd
Folyd / AbstractDownloadAsyncTask.java
Created Sep 15, 2015
Abstract Download AsyncTask
View AbstractDownloadAsyncTask.java
import android.os.AsyncTask;
import android.text.TextUtils;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@Folyd
Folyd / Utils.java
Last active Sep 15, 2015
Common Utility class
View Utils.java
public class Utils {
/**
* To record the user click time.
*/
private static long sLastClickTime = 0L;
/**
* Get device unique identify.
*
* @param context
@Folyd
Folyd / LoadMoreView.java
Last active Sep 16, 2015
Load more view for ListView to load more data by page or cursor
View LoadMoreView.java
public class LoadMoreView extends LinearLayout {
private TextView mTipText;
private ProgressBar mProgressBar;
private boolean mIsLoading;
private boolean mIsDone;
private int mLimit = 20;
private String mCursor = null;
private int mPage = 1;
@Folyd
Folyd / debug_via_wifi.sh
Created Sep 17, 2015
A shell script let you debug android device via WI-FI.
View debug_via_wifi.sh
#!/usr/bin/env bash
#Notice: if unable to connect to [ip]:5555,
#try adb kill-server then try again.
adb shell ip route > addrs.txt
#Case 1:Nexus 7
#192.168.88.0/23 dev wlan0 proto kernel scope link src 192.168.89.48
#Case 2: Smartsian T1,Huawei C8813
#default via 192.168.88.1 dev eth0 metric 30
@Folyd
Folyd / VideoPickerActivity.java
Last active Oct 8, 2015
A video picker activity
View VideoPickerActivity.java
public class VideoPickerActivity extends Activity{
private final int REQUEST_PICK_VIDEO = 1;
public void onVideoPickClick(View view) {
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, REQUEST_PICK_VIDEO);
}
@Override
View MultiSwipeRefreshLayout.java
/*
* Copyright 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
You can’t perform that action at this time.