Skip to content

ListView not scrolling #40

Description

@pmessina

I am working with version 2 of your SectionCursorAdapter library, and I'm having trouble with my listView not scrolling. I ran your sample and it scrolls fine. I reverted back to version 1 of your library, but I have the same issues. The views inflate fine, and I'm retrieving the right amount of cursors. Here's my implementation:

package com.pirateman.recruitercallsinterviews;

import android.annotation.TargetApi;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.CalendarContract;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.pirateman.recruitercallsactivity.R;
import com.twotoasters.sectioncursoradapter.adapter.SectionCursorAdapter;
import com.twotoasters.sectioncursoradapter.adapter.viewholder.ViewHolder;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

@TargetApi(value=21)
public class InterviewsCursorAdapter extends SectionCursorAdapter<String, InterviewsCursorAdapter.InterviewDateViewHolder, InterviewsCursorAdapter.InterviewViewHolder>
{
private static Uri calendarUri = CalendarContract.Events.CONTENT_URI;
private static String calDisplayName = CalendarContract.Events.CALENDAR_DISPLAY_NAME;
private static String eventID = CalendarContract.Events._ID;
private static String eventStartCol = CalendarContract.Events.DTSTART;
private static String eventEndCol = CalendarContract.Events.DTEND;
private static String eventTitle = CalendarContract.Events.TITLE;
private static String eventDescription = CalendarContract.Events.DESCRIPTION;
private static String eventTimeZone = CalendarContract.Events.EVENT_TIMEZONE;
private static String eventAllDay = CalendarContract.Events.ALL_DAY;

public InterviewsCursorAdapter(Context context, Cursor cursor)
{
    super(context, cursor, 0, R.layout.interviews_date_tv_separator, R.layout.interviews_lv_row_layout);
}

@Override
protected String getSectionFromCursor(Cursor cursor)
{
    DateTimeFormatter dateFormatter = DateTimeFormat.longDate();
    String eventStart = cursor.getString(cursor.getColumnIndex(eventStartCol));

    return dateFormatter.print(Long.parseLong(eventStart));
}

@Override
protected InterviewDateViewHolder createSectionViewHolder(View sectionView, String section)
{
    return new InterviewDateViewHolder(sectionView);
}

@Override
protected void bindSectionViewHolder(int position, InterviewDateViewHolder sectionViewHolder, ViewGroup parent, String section)
{
    sectionViewHolder.interviewDate.setOnClickListener(null);
    sectionViewHolder.interviewDate.setText(section);
}

@Override
protected InterviewViewHolder createItemViewHolder(Cursor cursor, View itemView)
{
    return new InterviewViewHolder(itemView);
}


@Override
protected void bindItemViewHolder(InterviewViewHolder itemViewHolder, Cursor cursor, ViewGroup parent)
{
    if (itemViewHolder.interviewType != null && itemViewHolder.timeStart != null && itemViewHolder.timeEnd != null)
    {
        String eventStart = cursor.getString(cursor.getColumnIndex(eventStartCol));
        String eventEnd = cursor.getString(cursor.getColumnIndex(eventEndCol));
        String eventTitleName = cursor.getString(cursor.getColumnIndex(eventTitle));

        DateTimeFormatter timeFormatter = DateTimeFormat.shortTime();
        DateTime startTimeDT = new DateTime(Long.parseLong(eventStart));
        DateTime endTimeDT = new DateTime(Long.parseLong(eventEnd));
        String eventStartTF = timeFormatter.print(startTimeDT);
        String eventEndTF = timeFormatter.print(endTimeDT);

        itemViewHolder.timeStart.setText(eventStartTF);
        itemViewHolder.timeEnd.setText(eventEndTF);
        itemViewHolder.interviewType.setText(eventTitleName);
    }
}

@Deprecated
protected View newSectionView(Context context, Object o, ViewGroup parent)
{
    return LayoutInflater.from(context).inflate(R.layout.interviews_date_tv_separator, parent, false);
}

@Deprecated
protected void bindSectionView(View view, Context context, int i, Object o)
{
    TextView interviewDate = (TextView) view.findViewById(R.id.tvInterviewDate);
    interviewDate.setOnClickListener(null);
    interviewDate.setText(o.toString());
}

@Deprecated
protected View newItemView(Context context, Cursor cursor, ViewGroup parent)
{
    return LayoutInflater.from(context).inflate(R.layout.interviews_lv_row_layout, parent, false);
}

@Deprecated
protected void bindItemView(View view, Context context, Cursor cursor)
{
    TextView interviewType = (TextView)view.findViewById(R.id.tvInterviewType);
    TextView timeStart = (TextView)view.findViewById(R.id.tvStartTime);
    TextView timeEnd = (TextView)view.findViewById(R.id.tvEndTime);

    if (interviewType != null && timeStart != null && timeEnd != null)
    {
        String eventStart = cursor.getString(cursor.getColumnIndex(eventStartCol));
        String eventEnd = cursor.getString(cursor.getColumnIndex(eventEndCol));
        String eventTitleName = cursor.getString(cursor.getColumnIndex(eventTitle));

        DateTimeFormatter timeFormatter = DateTimeFormat.shortTime();
        DateTime startTimeDT = new DateTime(Long.parseLong(eventStart));
        DateTime endTimeDT = new DateTime(Long.parseLong(eventEnd));
        String eventStartTF = timeFormatter.print(startTimeDT);
        String eventEndTF = timeFormatter.print(endTimeDT);

        timeStart.setText(eventStartTF);
        timeEnd.setText(eventEndTF);
        interviewType.setText(eventTitleName);
    }
}

public class InterviewViewHolder extends ViewHolder
{
    public final TextView interviewType;
    public final TextView timeStart;
    public final TextView timeEnd;

    public InterviewViewHolder(View rootView)
    {
        super(rootView);
        interviewType = findWidgetById(R.id.tvInterviewType);
        timeStart= findWidgetById(R.id.tvStartTime);
        timeEnd = findWidgetById(R.id.tvEndTime);
    }
}

public class InterviewDateViewHolder extends ViewHolder
{
    public final TextView interviewDate;

    public InterviewDateViewHolder(View rootView)
    {
        super(rootView);
        interviewDate = findWidgetById(R.id.tvInterviewDate);
    }
}

}

Activity

  1. MinceMan commented on Nov 6, 2016

    @MinceMan
    Collaborator

    It sounds like there is something wrong with you View hierarchy. Do you
    have something blocking your ListView that is click able? In other words,
    is there something else intercepting the touch events? Is the ListView
    consuming or ignoring touchevents somewhere else? That's are going guess
    but my gut says that the adapter is not fault as it does not control
    scrolling.

    On Sat, Nov 5, 2016, 2:09 PM pmessina notifications@github.com wrote:

    I am working with version 2 of your SectionCursorAdapter library, and I'm
    having trouble with my listView not scrolling. I ran your sample and it
    scrolls fine. I reverted back to version 1 of your library, but I have the
    same issues. The views inflate fine, and I'm retrieving the right amount of
    cursors. Here's my implementation:

    package com.pirateman.recruitercallsinterviews;

    import android.annotation.TargetApi;
    import android.content.Context;
    import android.database.Cursor;
    import android.net.Uri;
    import android.provider.CalendarContract;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.TextView;

    import com.pirateman.recruitercallsactivity.R;
    import com.twotoasters.sectioncursoradapter.adapter.SectionCursorAdapter;
    import com.twotoasters.sectioncursoradapter.adapter.viewholder.ViewHolder;

    import org.joda.time.DateTime;
    import org.joda.time.format.DateTimeFormat;
    import org.joda.time.format.DateTimeFormatter;

    @TargetApi(value=21)
    public class InterviewsCursorAdapter extends SectionCursorAdapter<String,
    InterviewsCursorAdapter.InterviewDateViewHolder,
    InterviewsCursorAdapter.InterviewViewHolder>
    {
    private static Uri calendarUri = CalendarContract.Events.CONTENT_URI;
    private static String calDisplayName =
    CalendarContract.Events.CALENDAR_DISPLAY_NAME;
    private static String eventID = CalendarContract.Events._ID;
    private static String eventStartCol = CalendarContract.Events.DTSTART;
    private static String eventEndCol = CalendarContract.Events.DTEND;
    private static String eventTitle = CalendarContract.Events.TITLE;
    private static String eventDescription =
    CalendarContract.Events.DESCRIPTION;
    private static String eventTimeZone =
    CalendarContract.Events.EVENT_TIMEZONE;
    private static String eventAllDay = CalendarContract.Events.ALL_DAY;

    public InterviewsCursorAdapter(Context context, Cursor cursor)
    {
    super(context, cursor, 0, R.layout.interviews_date_tv_separator, R.layout.interviews_lv_row_layout);
    }

    @OverRide
    protected String getSectionFromCursor(Cursor cursor)
    {
    DateTimeFormatter dateFormatter = DateTimeFormat.longDate();
    String eventStart = cursor.getString(cursor.getColumnIndex(eventStartCol));

    return dateFormatter.print(Long.parseLong(eventStart));
    

    }

    @OverRide
    protected InterviewDateViewHolder createSectionViewHolder(View sectionView, String section)
    {
    return new InterviewDateViewHolder(sectionView);
    }

    @OverRide
    protected void bindSectionViewHolder(int position, InterviewDateViewHolder sectionViewHolder, ViewGroup parent, String section)
    {
    sectionViewHolder.interviewDate.setOnClickListener(null);
    sectionViewHolder.interviewDate.setText(section);
    }

    @OverRide
    protected InterviewViewHolder createItemViewHolder(Cursor cursor, View itemView)
    {
    return new InterviewViewHolder(itemView);
    }

    @OverRide
    protected void bindItemViewHolder(InterviewViewHolder itemViewHolder, Cursor cursor, ViewGroup parent)
    {
    if (itemViewHolder.interviewType != null && itemViewHolder.timeStart != null && itemViewHolder.timeEnd != null)
    {
    String eventStart = cursor.getString(cursor.getColumnIndex(eventStartCol));
    String eventEnd = cursor.getString(cursor.getColumnIndex(eventEndCol));
    String eventTitleName = cursor.getString(cursor.getColumnIndex(eventTitle));

        DateTimeFormatter timeFormatter = DateTimeFormat.shortTime();
        DateTime startTimeDT = new DateTime(Long.parseLong(eventStart));
        DateTime endTimeDT = new DateTime(Long.parseLong(eventEnd));
        String eventStartTF = timeFormatter.print(startTimeDT);
        String eventEndTF = timeFormatter.print(endTimeDT);
    
        itemViewHolder.timeStart.setText(eventStartTF);
        itemViewHolder.timeEnd.setText(eventEndTF);
        itemViewHolder.interviewType.setText(eventTitleName);
    }
    

    }

    @deprecated
    protected View newSectionView(Context context, Object o, ViewGroup parent)
    {
    return LayoutInflater.from(context).inflate(R.layout.interviews_date_tv_separator, parent, false);
    }

    @deprecated
    protected void bindSectionView(View view, Context context, int i, Object o)
    {
    TextView interviewDate = (TextView) view.findViewById(R.id.tvInterviewDate);
    interviewDate.setOnClickListener(null);
    interviewDate.setText(o.toString());
    }

    @deprecated
    protected View newItemView(Context context, Cursor cursor, ViewGroup parent)
    {
    return LayoutInflater.from(context).inflate(R.layout.interviews_lv_row_layout, parent, false);
    }

    @deprecated
    protected void bindItemView(View view, Context context, Cursor cursor)
    {
    TextView interviewType = (TextView)view.findViewById(R.id.tvInterviewType);
    TextView timeStart = (TextView)view.findViewById(R.id.tvStartTime);
    TextView timeEnd = (TextView)view.findViewById(R.id.tvEndTime);

    if (interviewType != null && timeStart != null && timeEnd != null)
    {
        String eventStart = cursor.getString(cursor.getColumnIndex(eventStartCol));
        String eventEnd = cursor.getString(cursor.getColumnIndex(eventEndCol));
        String eventTitleName = cursor.getString(cursor.getColumnIndex(eventTitle));
    
        DateTimeFormatter timeFormatter = DateTimeFormat.shortTime();
        DateTime startTimeDT = new DateTime(Long.parseLong(eventStart));
        DateTime endTimeDT = new DateTime(Long.parseLong(eventEnd));
        String eventStartTF = timeFormatter.print(startTimeDT);
        String eventEndTF = timeFormatter.print(endTimeDT);
    
        timeStart.setText(eventStartTF);
        timeEnd.setText(eventEndTF);
        interviewType.setText(eventTitleName);
    }
    

    }

    public class InterviewViewHolder extends ViewHolder
    {
    public final TextView interviewType;
    public final TextView timeStart;
    public final TextView timeEnd;

    public InterviewViewHolder(View rootView)
    {
        super(rootView);
        interviewType = findWidgetById(R.id.tvInterviewType);
        timeStart= findWidgetById(R.id.tvStartTime);
        timeEnd = findWidgetById(R.id.tvEndTime);
    }
    

    }

    public class InterviewDateViewHolder extends ViewHolder
    {
    public final TextView interviewDate;

    public InterviewDateViewHolder(View rootView)
    {
        super(rootView);
        interviewDate = findWidgetById(R.id.tvInterviewDate);
    }
    

    }

    }

    —
    You are receiving this because you are subscribed to this thread.
    Reply to this email directly, view it on GitHub
    #40, or mute
    the thread
    https://github.com/notifications/unsubscribe-auth/ADCADJ-rnFdkBEBX929jyxE3MadGxUh7ks5q7OJ_gaJpZM4KqXrA
    .

    Cheers,
    Chris

  2. pmessina commented on Nov 7, 2016

    @pmessina
    Author

    I discovered that the problem was with the ListView. It will not work with CoordinatorLayout, but works fine with LinearLayout. Are you guys still working on supporting RecyclerView? I hear that would work with CoordinatorLayout.

  3. MinceMan commented on Nov 7, 2016

    @MinceMan
    Collaborator

    Yes version 3 has full support but as I no longer work at this company I
    cannot release it myself. I would recommend using it. The Readme has been
    mostly updated as well. That said there are still a bugs with it.

    On Mon, Nov 7, 2016, 4:17 AM pmessina notifications@github.com wrote:

    I discovered that the problem was with the ListView. It will not work with
    CoordinatorLayout, but works fine with LinearLayout. Are you guys still
    working on supporting RecyclerView? I hear that would work with
    CoordinatorLayout.

    —
    You are receiving this because you commented.

    Reply to this email directly, view it on GitHub
    #40 (comment),
    or mute the thread
    https://github.com/notifications/unsubscribe-auth/ADCADA5yUY7G9s8KVvxWixsT1UFo1ke3ks5q7uyxgaJpZM4KqXrA
    .

    Cheers,
    Chris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions