Skip to content

Instantly share code, notes, and snippets.

public class NumberTextWatcher implements TextWatcher {
//usage
//editText.addTextChangedListener(new NumberTextWatcher(editText));
private DecimalFormat df;
private DecimalFormat dfnd;
private boolean hasFractionalPart;
//http://stackoverflow.com/questions/2423498/how-to-get-the-html-source-of-a-page-from-a-html-link-in-android
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
String html = "";
InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder str = new StringBuilder();
String line = null;
import android.content.Context;
import android.content.SharedPreferences;
//usage:
// SettingsManager sm=new SettingsManager(getApplicationContext());
// String firstName=sm.getFirstName();
public class SettingsManager {
SharedPreferences pref;
public class ImageHolder implements Parcelable {
public String name="";
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
public class SpinnerDataHolder {
public String spinnerText;
public String value;
public SpinnerDataHolder( String spinnerText, String value ) {
this.spinnerText = spinnerText;
this.value = value;
}
public String toString() {
return spinnerText;
public class FontHelper {
private static final Map<String, Typeface> TYPEFACES = new HashMap<>();
public static Typeface get(Context context,String fontFileName){
Typeface typeface = TYPEFACES.get(fontFileName);
if(typeface == null){
typeface = Typeface.createFromAsset(context.getResources().getAssets(), fontFileName);
TYPEFACES.put(fontFileName, typeface);
}
return typeface;
package ir.paaaa.android.utils;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
package org.wordpress.android.ui.main;
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Parcelable;
import android.support.v13.app.FragmentStatePagerAdapter;
import android.util.SparseArray;
import android.view.ViewGroup;
import org.wordpress.android.ui.notifications.NotificationsListFragment;
package com.example.abbas.testssd;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imgProfile"
android:layout_width="70dp"
android:padding="5dp"