Skip to content

Instantly share code, notes, and snippets.

public class RefreshProgressBar extends View {
private static final float PROGRESS_BAR_HEIGHT = 5f;
private final Handler handler;
private boolean mIsRefreshing = false;
private SwipeProgressBar mProgressBar;
private final int mProgressBarHeight;
public RefreshProgressBar(Context context) {
@xingstarx
xingstarx / RefreshProgressBar.java
Created June 6, 2017 06:51 — forked from cbeyls/RefreshProgressBar.java
A custom horizontal indeterminate progress bar which displays a smooth colored animation. (Google Now progress bar)
package android.support.v4.widget;
import android.content.Context;
import android.graphics.Canvas;
import android.os.Handler;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
@xingstarx
xingstarx / RainEmployeeProvider.java
Created June 5, 2017 13:39 — forked from dustin-graham/RainEmployeeProvider.java
An example Android ContentProvider
package com.rain.example.data.provider;
import com.rain.example.data.database.RainEmployeeDatabase;
import com.rain.example.data.database.table.*;
import android.provider.BaseColumns;
import android.text.TextUtils;
import android.content.ContentUris;
import android.database.sqlite.SQLiteQueryBuilder;
@xingstarx
xingstarx / HanziToPinyin.java
Created March 31, 2017 07:06 — forked from D-clock/HanziToPinyin.java
从Android4.2.2原生系统中提取出来的汉字转换成拼音的方案,同时兼容国产ROM(从2.x的原生系统提取出来的类转换有错误,不建议使用)
/*
* Copyright (C) 2009 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
@xingstarx
xingstarx / Android: get CountryCode from TelephonyManager
Last active October 5, 2020 03:34 — forked from rinav/Android: get CountryCode from TelephonyManager
Android: Get CountryCode and Locale from TelephonyManager
public static int getCurrentCountryCode(Context context) {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String countryIso = telephonyManager.getSimCountryIso().toUpperCase();
return PhoneNumberUtil.getInstance().getCountryCodeForRegion(countryIso);
}
PhoneNumberUtil 引用自
compile 'com.googlecode.libphonenumber:libphonenumber:8.3.1'
@xingstarx
xingstarx / EachDirectoryPath.md
Created February 6, 2017 02:36 — forked from granoeste/EachDirectoryPath.md
[Android] How to get the each directory path.

System directories

Method Result
Environment.getDataDirectory() /data
Environment.getDownloadCacheDirectory() /cache
Environment.getRootDirectory() /system

External storage directories

@xingstarx
xingstarx / DeleteModelInBatchOnSubscribe.java
Created January 18, 2017 11:15 — forked from trajakovic/DeleteModelInBatchOnSubscribe.java
Android DbFlow Update/Delete/Save models in batch with RxJava - ReactiveX with DbFlow
import android.database.Cursor;
import android.support.annotation.NonNull;
import com.raizlabs.android.dbflow.runtime.DBTransactionInfo;
import com.raizlabs.android.dbflow.runtime.TransactionManager;
import com.raizlabs.android.dbflow.runtime.transaction.BaseTransaction;
import com.raizlabs.android.dbflow.runtime.transaction.QueryTransaction;
import com.raizlabs.android.dbflow.runtime.transaction.TransactionListener;
import com.raizlabs.android.dbflow.sql.builder.ConditionQueryBuilder;
import com.raizlabs.android.dbflow.sql.language.Delete;
@xingstarx
xingstarx / RoundedImageView.java
Created January 4, 2017 05:34 — forked from Pretz/RoundedImageView.java
Andround Rounded Image View
package com.yelp.android.ui.widgets;
import com.yelp.android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
@xingstarx
xingstarx / gist:f7a1d3a758d5b0f6447b9068a3b2314e
Created December 28, 2016 09:35 — forked from ongakuer/gist:add32475478360251809
SquareFrameLayout (这个版本的测量考虑更全面)
/*
* 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
@xingstarx
xingstarx / README.md
Last active December 13, 2016 05:58 — forked from polbins/README.md
Simple RecyclerView Divider

Simple RecyclerView Divider

Simple Horizontal Divider Item Decoration for RecyclerView

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

NOTE: Add item decoration prior to setting the adapter