Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:wordpress-mobile/WordPress-Andro…
Browse files Browse the repository at this point in the history
…id into feature/modularize-editor
  • Loading branch information
maxme committed Mar 3, 2015
2 parents c9a7b99 + c0c684a commit 1398d41
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
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;
import org.wordpress.android.util.widgets.CustomSwipeRefreshLayout;

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.wordpress.android.util.widgets;

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) {
// Fix for https://github.com/wordpress-mobile/WordPress-Android/issues/2373
// Catch IllegalArgumentException which can be fired by the underlying SwipeRefreshLayout.onTouchEvent()
// method.
// When android support-v4 fixes it, we'll have to remove that custom layout completely.
AppLog.e(T.UTILS, e);
return true;
}
}
}

0 comments on commit 1398d41

Please sign in to comment.