GithubHelp home page GithubHelp logo

pulltorefresharp's People

Contributors

ansuria avatar bduncavage avatar leonluc-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pulltorefresharp's Issues

Empty view not supported

It is not possible to add a view for the empty state of the list through a XML-layout. If you place a TextView with the id = "@android:id/empty" at the same level under the ListView inside the ViewWrapper, the app crashes.

Placing it outside the ViewWrapper prevents it from being visible if the ListView is empty.

Event touch not handled with added views

Hi!

Thank you for this beautiful component!!!

I have some problem. When i add programmaticly LinearLayouts inside your ScrollView the touch event not handled on them. For example LinearLayouts which were in axml file support touch event, but new Layouts which i add programmaticly are not... I don't understand where and how do you add event to child controls inside ScrollView. Can you help me with this?

Sorry for my English =)

How to apply translation for different language?

Hi,

I want to apply string manual or by code....

String in the sense....

Pull down to refresh... in that place i want add my own strings...
Release to refresh... same here...

Can you please let me know, how to apply this function...

Linker Problem

hello,thank you for your component ,but there is a problem when reference the component with the option --> android build --->linker --->link all assembies ,even your sample cast a crash with it, when go with don't link ,it goes well. thank you for your repeat

Header Background Color

Hi, first of all I'm sorry for my English - it's not my native language...
I found a problem in your ViewWrapper class, while tried to set header color.
It's impossible to set color, but only resource, as this case is not handled in the ViewWrapper class, but in your attrs.xml declared that you can set both - the resource or the color as attribute to this field.

Objects on scrollview intercept touch events, pull to refresh doesn't work in that case

I'm testing this out on a scenario where the scrollview has variable sized content and thus may not always scroll on its own. In that scenario if you have say an TextView with a click handler it is intercepting the touch event and the pull to refresh feature doesn't work.

Try this:

<pulltorefresharp.android.views.ViewWrapper xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:pullToRefresharpWrapper="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<pulltorefresharp.android.widget.ScrollView
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:background="@color/content_background">



</pulltorefresharp.android.widget.ScrollView>
</pulltorefresharp.android.views.ViewWrapper>

And then in code, bind to the textview like so:
var tv = view.FindViewById(Resource.Id.textview);
tv.Click += (object sender, EventArgs e) => {
Console.WriteLine("clicked on ...");
};

The PTR scrollview widget's OnTouchEvent never gets called. I'm going to do some more testing to see how to fix this but wanted to post it in case you've already tested this scenario.

Thanks.

Long touches not registering when Listview is at top scrollposition

I'm using a ListView and ExpandableListView with pull to refresh enabled (using a ViewWrapper and all).

When the ListViews are at their top scroll position (Y for the scroll component is 0) the ListView no longer registers long touches (like the ones registered by IOnLongItemClickListener). At any other scroll position the long touches work fine.

I figured out that the issue is caused by the OnTouchEvent and OnInterceptTouchEvent in the ViewWrapper class. More specifically in the line 233-241 and line 281-288 blocks in the ViewWrapper.cs file. But I can't figure out how the bug occurs.

I tried to fix it by changing the return ContentView.IsAtTop; on line 288 to return false; While this does allow the long touches to fire their relevant events, it will also allow long touches to fire events when scrolling to "pull down" the refresh header. So in the end it doesn't work out.

ItemClick event not firing in ListView with custom adapter

I've created a custom adapter, ExistingGameAdapter, that holds a collection of IListViewItems. IListViewItems is implemented by either HeaderListViewItem or SelectableListViewItems. When a SelectableListViewItem is selected, I need to hook into the ItemClick event for that custom adapter. It appears as if the OnInterceptTouchEvent is suppressing that event. I mucked around with that method but couldn't seem to figure it out...

Below is my layout:
<pulltorefresharp.android.views.ViewWrapper
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_below="@id/prestart_tv_Question"
android:layout_weight="2.5"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginBottom="15dp"
android:background="@layout/listviewbackground">
<pulltorefresharp.android.widget.ListView
android:id="@+id/gameselect_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:listSelector="@drawable/listview_itembackground"
android:padding="2dp"
android:cacheColorHint="#003334"
android:background="@layout/listviewbackground"
android:minHeight="?android:attr/listPreferredItemHeight" />
</pulltorefresharp.android.views.ViewWrapper>

Below is my custom adapter:
///

    /// A basic adapter for the existing games list view.
    /// </summary>


    public class ExistingGameAdapter : ArrayAdapter<IListViewItem>{
    private readonly List<IListViewItem> _listViewItems;
    private readonly LayoutInflater _inflater;
    public ExistingGameAdapter(Context context, List<IListViewItem> items) : base(context, 0, items)
    {
        _inflater = LayoutInflater.From(context);
        _listViewItems = items;
    }

    /// <summary>
    /// Gets the number of different view types that are possible.
    /// </summary>
    public override int ViewTypeCount
    {
        get { return Enum.GetNames(typeof(ListViewType)).Length; }
    }

    /// <summary>
    /// Gets the value that corresponds to which view to present.
    /// </summary>
    /// <param name="position"></param>
    /// <returns></returns>
    public override int GetItemViewType(int position)
    {
        return (int) GetItem(position).GetViewType();
    }

    /// <summary>
    /// Removes an item at the given position.
    /// </summary>
    /// <param name="position">The position.</param>
    public void Remove(int position)
    {
        if (_listViewItems != null && _listViewItems.ElementAt(position) != null)
        {
            Remove(_listViewItems[position]);
        }
    }

    public void Remove(GameDO game)
    {
        var toRemove = _listViewItems.First(x => x.Game == game);
        Remove(toRemove);
    }

    /// <summary>
    /// Gets the game associated with the given position.
    /// </summary>
    /// <param name="position">The position.</param>
    /// <returns>The game that for this position</returns>
    /// <remarks>If the item is a <see cref="HeaderListViewItem"/>, then no game will be returned.</remarks>
    public GameDO GetGame(int position)
    {
        if (_listViewItems != null 
            && _listViewItems.ElementAt(position) != null 
            && !(_listViewItems[position] is HeaderListViewItem))
        {
            return _listViewItems[position].Game;
        }

        return null;
    }

    /// <summary>
    /// Gets whether or not the item at the given position is selectable.
    /// </summary>
    /// <param name="position">The position to test against.</param>
    /// <returns>Whether or not the item at the position is selectable.</returns>
    public override bool IsEnabled(int position)
    {
        return !(_listViewItems[position] is HeaderListViewItem);
    }

    public int GetNumberHeaders(int searchEnd)
    {
        var collection = _listViewItems.Where(lvi => _listViewItems.IndexOf(lvi) <= searchEnd ).Where (lvi => lvi is HeaderListViewItem);
        return collection == null ? 0 : collection.Count ();
    }

    /// <summary>
    /// Gets the associated view for the list view item.
    /// </summary>
    /// <param name="position">The position.</param>
    /// <param name="convertView">The view to convert, or keep the same.</param>
    /// <param name="parent">The container for the current convertView.</param>
    /// <returns>The final, potentionally converted.</returns>
    public override View GetView(int position, View convertView, ViewGroup parent)
    {
        return GetItem(position).GetView(_inflater, convertView);
    }
}

Below is my usage of the adapter:

_currentGames = (PullToRefresharp.Android.Widget.ListView)FindViewById (Resource.Id.gameselect_listview);
_currentGames.RefreshActivated += HandleRefreshActivated;

//listViewItems is populated...

_existingGamesAdapter = new ExistingGameAdapter (this, listViewItems);
_currentGames.Adapter = _existingGamesAdapter;
_currentGames.ChoiceMode = ChoiceMode.Single;

_currentGames.ItemClick += OnItemClick;
_currentGames.ItemLongClick += OnItemLongClick;

Clarify licensing terms

Your project is currently released out of any licensing scheme. This leaves a lot of gray areas in the usage of your code, especially wrt closed source projects and liability waiver (i.e. "use this code at your own risk").

You are stating in the README that your code is open source, but that's not enough. You should really provide a license, just choose the best fit among the "standard" ones, e.g. MIT, BSD, Apache 2.0 or GPLv2/3.

Problem using pulltorefresharp

I tried to integrate pulltorefresharp in my xamarin project but was getting this error:

03-25 07:50:20.828: I/MonoDroid(10630): Caused by: java.lang.ClassNotFoundException: pulltorefresharp.android.views.ViewWrapper
03-25 07:50:20.828: I/MonoDroid(10630): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-25 07:50:20.828: I/MonoDroid(10630): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-25 07:50:20.828: I/MonoDroid(10630): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-25 07:50:20.828: I/MonoDroid(10630): at android.view.LayoutInflater.createView(LayoutInflater.java:558)
03-25 07:50:20.828: I/MonoDroid(10630): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693)
03-25 07:50:20.828: I/MonoDroid(10630): ... 26 more
03-25 07:50:20.835: W/dalvikvm(10630): JNI WARNING: JNI method called with exception pending
03-25 07:50:20.835: W/dalvikvm(10630): in Leroaddriverapp/android/fragments/MessagingMainScreenFragment;.n_onCreateView:(Landroid/view/LayoutInflater;Landroid/view/ViewGroup;Landroid/os/Bundle;)Landroid/view/View; (NewString)
03-25 07:50:20.835: W/dalvikvm(10630): Pending exception is:
03-25 07:50:20.835: I/dalvikvm(10630): android.view.InflateException: Binary XML file line #1: Error inflating class pulltorefresharp.android.views.ViewWrapper
03-25 07:50:20.835: I/dalvikvm(10630): (raw stack trace not found)
03-25 07:50:20.843: I/dalvikvm(10630): Caused by:
03-25 07:50:20.843: I/dalvikvm(10630): java.lang.ClassNotFoundException: pulltorefresharp.android.views.ViewWrapper
03-25 07:50:20.843: I/dalvikvm(10630): (raw stack trace not found)
03-25 07:50:20.843: I/dalvikvm(10630): "main" prio=5 tid=1 NATIVE

I can run the samples fine and the sample seems to run ok but as soon as I copy the project into my solution and make the change i.e. change the layout xml. I get the following error on deploy

Mono.Android.Support.V4 reference vs Xamarin.Android.Support.V4?

I've been using the component for a long time (thanks!). But recently decided to switch to using the Google Play Services ICS component in my app. This component has a reference to Xamarin.Android.Support.V4.

If I include both components in my app then I get linker errors due to types defined in multiple places. If you could update the component / github repo to use the Xamarin.Android.Support.V4 library it would fix this.

As is stands now I need to look at either forking your library and change the reference or switch to the Swipe to refresh API added in API 19.x.

Getting started with the component.

I am writing my first Android Application and I was trying to use this component downloaded from the Xamarin Store.

I tried to follow the Getting Started instructions in order to use the component inside my application, but I was facing these next issues:

  • Mono.Android.Support.v4 not found;
  • There is no implicit reference conversion from PullToRefresharp.Android.Views.IPullToRefresharpView to Android.Views.View (CS0311);
  • Binary XML file line #1: Error inflating class pulltorefresharp.views.ViewWrapper.

After researching for while, I could make it work by:

  • Downloading, installing and referencing the Mono.Android.Support.v4 into my project;
  • Updating the next line:

from:
FindViewById<IPullToRefresharpView>(Resource.Id.myListView);
to
FindViewById<PullToRefresharp.Android.Widget.ListView> (Resource.Id.myListView);

  • Updating my layout:

from:
<pulltorefresharp.views.ViewWrapper and <pulltorefresharp.widget.ListView
to
<pulltorefresharp.android.views.ViewWrapper and <pulltorefresharp.android.widget.ListView

Were these fixed issues just related to my current project or are there some mistakes into the Getting Started page instructions?

Just asking because it may help others.

Btw, thank you @bduncavage by the good job you have been doing here.

Binary XML file line #1: Error inflating class pulltorefresharp.android.views.ViewWrapper

I'm trying to implement Pull to Refresh. I've copy/pasted code from the sample verbatim, but I keep seeing this error:

ex.Message = "Binary XML file line #1: Error inflating class pulltorefresharp.android.views.ViewWrapper"

Here's my Layout.axml:

<?xml version="1.0" encoding="utf-8"?>
<pulltorefresharp.android.views.ViewWrapper xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:pullToRefresharpWrapper="http://schemas.android.com/apk/res-auto"
android:id="@+id/ptrAssignedCardsWrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
pullToRefresharpWrapper:pullDownTension="0.5"
pullToRefresharpWrapper:snapbackDuration="300">
<pulltorefresharp.android.widget.ListView
    android:id="@+id/assignedCardsListView"
    android:divider="#ccc"
    android:dividerHeight="1dp"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:layout_marginRight="10dp"
    android:layout_marginLeft="10dp" />

</pulltorefresharp.android.views.ViewWrapper>

A snippet from my Fragment:

public class MyClass : SherlockListFragment, AbsListView.IOnScrollListener
{
...
public override View OnCreateView(LayoutInflater inflater, ViewGroup container,     Bundle savedInstanceState)
    {
        try
        {
            return inflater.Inflate(LayoutId, null, false);
        }
        catch (Exception ex)
        {
            //  ERROR INTO HERE
            var a = ex.Message;
            throw;
        }

    }
...
}

I have a references to:

Mono.Android Mono.Android.Support.v4 PullToRefresharp System.System.Core System.Xml etc.

Am I missing something? The sample project list example works perfectly.

Custom ListView

hi sir, i want to add listview with custom row. but i can make it work, can u give me an idea how, thanks

Crash - with list is in startup view and touching screen upon startup

Android (Galaxy S4)

Crashed on:

        public override bool OnInterceptTouchEvent(MotionEvent ev)
        {
           ...
            if (ev.ActionMasked == MotionEventActions.Down && ContentView.IsAtTop

-and-

        public override bool OnTouchEvent(MotionEvent e)
        {
                    ...
                    last_touch_y = ContentView.IsAtTop ? (int)e.RawY : -1;

There's a race condition where the content view is not set before the touch events arrive, i.e. the "OnGlobalLayout" gets called after the touch events arrive if you are touching the list view while the screen is still loading/rendering.

        public void OnGlobalLayout()
        {
                ...
                if (content_view_res_id > 0) {
                    ContentView = (IPullToRefresharpWrappedView)FindViewById<View>(content_view_res_id);
                } else {
                    ContentView = (IPullToRefresharpWrappedView)GetChildAt(1);
                }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.