Yalantis / Phoenix

Phoenix Pull-to-Refresh
https://yalantis.com/
Apache License 2.0
4.01k stars 916 forks source link

Phoenix doesnt work on Samsung Galaxy S2 #19

Closed figengungor closed 9 years ago

figengungor commented 9 years ago

I added Phoenix to my project and it works fine with Sony Xperia. However, I can't scroll to refresh when testing my app on Samsung Galaxy S2. Do you have similar issue on that device? What might be the problem?

shliama commented 9 years ago

That's really weird, can you check it with the sample? I'll try to find SG S2 to test it myself, but not about the ETA

figengungor commented 9 years ago

I tested sample and it works fine on S2. However, I am using a custom ScrollView as following with Phoenix and Phoenix doesnt work on S2 in that case but works fine with Sony Xperia. Do you have any idea what might be the problem?

import android.content.Context; import android.util.AttributeSet; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; import android.widget.ScrollView;

public class VerticalScrollView extends ScrollView { private GestureDetector mGestureDetector; View.OnTouchListener mGestureListener;

public VerticalScrollView(Context context)
{
    super(context);
    init(context);
}

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

public VerticalScrollView(Context context, AttributeSet attrs, int defStyle) 
{
   super(context, attrs, defStyle);
   init(context);
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev)
{
   return super.onInterceptTouchEvent(ev) && mGestureDetector.onTouchEvent(ev);
}

class YScrollDetector extends GestureDetector.SimpleOnGestureListener
{
   @Override
    public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) 
   {             
      return Math.abs(distanceY) > Math.abs(distanceX);
    }
}

private void init(Context context)
{
   mGestureDetector = new GestureDetector(context, new YScrollDetector());
    setFadingEdgeLength(0);

} }

And my layout goes like this:

<com.test.project.ui.VerticalScrollView android:id="@+id/scrollView" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true">

           < <com.yalantis.phoenix.PullToRefreshView
                android:id="@+id/pull_to_refresh"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">  ....
shliama commented 9 years ago

Well, maybe that's because LinearLayout under the PullToRefreshView layout. It needs subclass of AbsListView or anything that can scroll.

figengungor commented 9 years ago

I put scrollview into pulltorefresh and now it works on S2. Thank you, @shliama.

shliama commented 9 years ago

great :+1: guess, the issue is closed now)