Skip to content

Commit

Permalink
new CustomSwipeRefreshLayout with a workaround to catch onTouchEvent …
Browse files Browse the repository at this point in the history
…IllegalArgumentException
  • Loading branch information
maxme committed Feb 27, 2015
1 parent 3f8bedb commit f34c956
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.wordpress.android.util.ptr;

import android.content.Context;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.AttributeSet;
import android.view.MotionEvent;

import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;

public class CustomSwipeRefreshLayout extends SwipeRefreshLayout {
public CustomSwipeRefreshLayout(Context context) {
super(context);
}

public CustomSwipeRefreshLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
try{
return super.onTouchEvent(event);
} catch(IllegalArgumentException e) {
AppLog.e(T.UTILS, e);
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@
import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;
import android.util.TypedValue;

import org.wordpress.android.util.R;

public class SwipeToRefreshHelper implements OnRefreshListener {
private SwipeRefreshLayout mSwipeRefreshLayout;
private CustomSwipeRefreshLayout mSwipeRefreshLayout;
private RefreshListener mRefreshListener;
private boolean mRefreshing;

public interface RefreshListener {
public void onRefreshStarted();
}

public SwipeToRefreshHelper(Activity activity, SwipeRefreshLayout swipeRefreshLayout, RefreshListener listener) {
public SwipeToRefreshHelper(Activity activity, CustomSwipeRefreshLayout swipeRefreshLayout, RefreshListener listener) {
init(activity, swipeRefreshLayout, listener);
}

public void init(Activity activity, SwipeRefreshLayout swipeRefreshLayout, RefreshListener listener) {
public void init(Activity activity, CustomSwipeRefreshLayout swipeRefreshLayout, RefreshListener listener) {
mRefreshListener = listener;
mSwipeRefreshLayout = swipeRefreshLayout;
mSwipeRefreshLayout.setOnRefreshListener(this);
Expand Down

0 comments on commit f34c956

Please sign in to comment.