Skip to content

Instantly share code, notes, and snippets.

@JetXing
JetXing / includeToolbar.java
Last active August 29, 2015 14:09
instead actionbar below 3.0
private Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutResource());
toolbar = (Toolbar) findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
@JetXing
JetXing / Sample.java
Created November 24, 2014 10:21
Generate the specified string
package com.example;
import java.util.ArrayList;
import java.util.List;
public class MyClass {
public static void main(String[] args){
UserBuild mUserBuild = new UserBuild("INTEGER");
@JetXing
JetXing / CheckEmail.java
Created February 2, 2015 09:08
we much have to sure that entered email address is valid of not and there for to check it followed method can be use
public boolean eMailValidations(String emailstring){
Pattern emailPattern = Pattern.compile(".+@.+\\.[a-z]+");
Matcher emailMatcher = emailPattern.matcher(emailstring);
return emailMatcher.matches();
}
//call method
eMailValidations("jet@jet.com");
@JetXing
JetXing / StringReverse.java
Created February 10, 2015 05:07
reverse String
public String reverseString(String data){
return new StringBuffer(data).reverse().toString();
}
@JetXing
JetXing / ActivityToView.java
Last active September 10, 2015 05:53
Activity convertion to View
/**
* <p>Helper class for managing multiple running embedded activities in the same
* process. This class is not normally used directly, but rather created for
* you as part of the {@link android.app.ActivityGroup} implementation.
*
* @see ActivityGroup
*
* @deprecated Use the new {@link Fragment} and {@link FragmentManager} APIs
* instead; these are also
* available on older platforms through the Android compatibility package.
@JetXing
JetXing / FixRefresh
Created March 23, 2015 04:14
解决SwipeRefreshLayout嵌套ListView时,滑动ListView触发SwipeRefreshLayout的refresh method
/**
* 解决listview向上滑动刷新的bug
*/
mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
@JetXing
JetXing / ProgressBarWebView
Created April 14, 2015 03:48
add ProgressBar for WebView
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.main );
final Activity MyActivity = this;
// Makes Progress bar Visible
getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
webview = (WebView) findViewById(R.id.webview);
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
@JetXing
JetXing / ActionBarHeight
Created April 15, 2015 06:28
get the height of actionBar
private int getActionBarHeight() {
int actionBarHeight = getSupportActionBar().getHeight();
if (actionBarHeight != 0) {
return actionBarHeight;
}
final TypedValue typedValue = new TypedValue();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
if (getTheme().resolveAttribute(android.R.attr.actionBarSize, typedValue, true)) {
actionBarHeight = TypedValue.complexToDimensionPixelSize(
@JetXing
JetXing / ImmersiveMode
Created April 16, 2015 07:49
Immersive Mode(沉浸式) ,设置view的padding
protected final void initStatusBar(int resId) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
tintManager.setTintResource(R.color.your_color);
SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
findViewById(resId).setPadding(0, config.getPixelInsetTop(true), 0, config.getPixelInsetBottom());
}
}
@JetXing
JetXing / IDCard.java
Last active December 3, 2020 14:28
java, 身份证号的正则表达式, regular expression for ID card
package com.gitcafe.android.base.fragment;
import android.util.Log;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Hashtable;
import java.util.regex.Matcher;