Advertisement
olcayertas

MySwipeRefreshLayout

May 20th, 2015
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.51 KB | None | 0 0
  1. package com.yceo.namazvakti.utility;
  2.  
  3. import android.content.Context;
  4. import android.util.AttributeSet;
  5.  
  6. /**
  7.  * Created by Olcay Ertaş on 13/05/15.
  8.  */
  9. public class MySwipeRefreshLayout extends android.support.v4.widget.SwipeRefreshLayout {
  10.  
  11.     private boolean mMeasured = false;
  12.     private boolean mPreMeasureRefreshing = false;
  13.  
  14.     @Override
  15.     public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  16.         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  17.         if (!mMeasured) {
  18.             mMeasured = true;
  19.             setRefreshing(mPreMeasureRefreshing);
  20.         }
  21.     }
  22.  
  23.     @Override
  24.     public void setRefreshing(boolean refreshing) {
  25.         if (mMeasured) {
  26.             super.setRefreshing(refreshing);
  27.         } else {
  28.             mPreMeasureRefreshing = refreshing;
  29.         }
  30.     }
  31.  
  32.     public MySwipeRefreshLayout(Context context) {
  33.         super(context);
  34.     }
  35.  
  36.     public MySwipeRefreshLayout(Context context, AttributeSet attrs) {
  37.         super(context, attrs);
  38.     }
  39.  
  40.     public MySwipeRefreshLayout(Context context, boolean mMeasured, boolean mPreMeasureRefreshing) {
  41.         super(context);
  42.         this.mMeasured = mMeasured;
  43.         this.mPreMeasureRefreshing = mPreMeasureRefreshing;
  44.     }
  45.  
  46.     public MySwipeRefreshLayout(Context context, AttributeSet attrs, boolean mMeasured, boolean mPreMeasureRefreshing) {
  47.         super(context, attrs);
  48.         this.mMeasured = mMeasured;
  49.         this.mPreMeasureRefreshing = mPreMeasureRefreshing;
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement