CollectionTimeline not working

android

#1

Hi, im currently trying to display a collection on my android app but it simply does not show up anything at all.
I’m using almost the same code as the one in the docs, the only difference is that im displaying it on a listview.
Here is the code and xml:

ListView tweetview = (ListView) findViewById(R.id.tweetView);
        final CollectionTimeline timeline = new CollectionTimeline.Builder()
                .id(766080906511708163L)
                .build();
        final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter.Builder(this)
                .setTimeline(timeline)
                .setViewStyle(R.style.tw__TweetLightWithActionsStyle)
                .build();
        tweetview.setAdapter(adapter);

<ListView android:id="@+id/tweetView"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:divider="#e1e8ed"
                android:dividerHeight="1dp"
                android:drawSelectorOnTop="false"/>

#2

Hey @WezzleCorp,

Can you share the output you see in Logcat when you try to load this?

Thanks,
Mike


#3

Here:

08-18 19:41:13.893 23420-23438/com.wezzlecorp.wezzle I/dalvikvm: Could not find method android.app.Notification$Builder.setLocalOnly, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza
08-18 19:41:14.073 23420-23438/com.wezzlecorp.wezzle W/dalvikvm: VFY: unable to resolve virtual method 251: Landroid/app/Notification$Builder;.setLocalOnly (Z)Landroid/app/Notification$Builder;
08-18 19:41:14.073 23420-23438/com.wezzlecorp.wezzle I/dalvikvm: DexOpt: access denied from Lcom/google/android/gms/common/GooglePlayServicesUtil; to field Landroid/app/Notification;.extras
08-18 19:41:14.073 23420-23438/com.wezzlecorp.wezzle W/dalvikvm: VFY: unable to resolve instance field 18
08-18 19:41:14.253 23420-23438/com.wezzlecorp.wezzle I/dalvikvm: Could not find method android.os.UserManager.getApplicationRestrictions, referenced from method com.google.android.gms.common.zze.zzbw
08-18 19:41:14.253 23420-23438/com.wezzlecorp.wezzle W/dalvikvm: VFY: unable to resolve virtual method 1638: Landroid/os/UserManager;.getApplicationRestrictions (Ljava/lang/String;)Landroid/os/Bundle;
08-18 19:41:14.253 23420-23438/com.wezzlecorp.wezzle I/dalvikvm: Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.zze.zzl
08-18 19:41:14.253 23420-23438/com.wezzlecorp.wezzle W/dalvikvm: VFY: unable to resolve virtual method 546: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
08-18 19:41:14.253 23420-23438/com.wezzlecorp.wezzle E/dalvikvm: Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.internal.zzro.zzg
08-18 19:41:14.253 23420-23438/com.wezzlecorp.wezzle W/dalvikvm: VFY: unable to resolve check-cast 30 (Landroid/app/AppOpsManager;) in Lcom/google/android/gms/internal/zzro;
08-18 19:41:15.344 23420-23420/com.wezzlecorp.wezzle W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
08-18 19:41:15.344 23420-23420/com.wezzlecorp.wezzle I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.internal.view.WindowCallbackWrapper.onSearchRequested
08-18 19:41:15.344 23420-23420/com.wezzlecorp.wezzle W/dalvikvm: VFY: unable to resolve interface method 18420: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
08-18 19:41:15.344 23420-23420/com.wezzlecorp.wezzle I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.internal.view.WindowCallbackWrapper.onWindowStartingActionMode
08-18 19:41:15.344 23420-23420/com.wezzlecorp.wezzle W/dalvikvm: VFY: unable to resolve interface method 18424: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
08-18 19:41:15.424 23420-23420/com.wezzlecorp.wezzle I/dalvikvm-heap: Grow heap (frag case) to 7.866MB for 4194320-byte allocation
08-18 19:41:15.935 23420-23420/com.wezzlecorp.wezzle I/dalvikvm-heap: Grow heap (frag case) to 16.866MB for 9437200-byte allocation
08-18 19:41:19.138 23420-23420/com.wezzlecorp.wezzle W/ResourceType: Attempt to retrieve bag 0x7f0a0032 which is invalid or in a cycle.
08-18 19:41:19.158 23420-23420/com.wezzlecorp.wezzle I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawable
08-18 19:41:19.158 23420-23420/com.wezzlecorp.wezzle W/dalvikvm: VFY: unable to resolve virtual method 597: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
08-18 19:41:19.158 23420-23420/com.wezzlecorp.wezzle I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawableForDensity
08-18 19:41:19.158 23420-23420/com.wezzlecorp.wezzle W/dalvikvm: VFY: unable to resolve virtual method 599: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
08-18 19:41:19.338 23420-23420/com.wezzlecorp.wezzle I/GAv4: Google Analytics 9.4.52 is starting up. To enable debug logging on a device run:
                                                               adb shell setprop log.tag.GAv4 DEBUG
                                                               adb logcat -s GAv4
08-18 19:41:19.408 23420-23674/com.wezzlecorp.wezzle W/dalvikvm: VFY: unable to find class referenced in signature (Ljava/nio/file/Path;)
08-18 19:41:19.408 23420-23674/com.wezzlecorp.wezzle W/dalvikvm: VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;)
08-18 19:41:19.408 23420-23674/com.wezzlecorp.wezzle I/dalvikvm: Could not find method java.nio.file.Files.newOutputStream, referenced from method okio.Okio.sink
08-18 19:41:19.408 23420-23674/com.wezzlecorp.wezzle W/dalvikvm: VFY: unable to resolve static method 44383: Ljava/nio/file/Files;.newOutputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/OutputStream;
08-18 19:41:19.408 23420-23674/com.wezzlecorp.wezzle W/dalvikvm: VFY: unable to find class referenced in signature (Ljava/nio/file/Path;)
08-18 19:41:19.408 23420-23674/com.wezzlecorp.wezzle W/dalvikvm: VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;)
08-18 19:41:19.408 23420-23674/com.wezzlecorp.wezzle I/dalvikvm: Could not find method java.nio.file.Files.newInputStream, referenced from method okio.Okio.source
08-18 19:41:19.408 23420-23674/com.wezzlecorp.wezzle W/dalvikvm: VFY: unable to resolve static method 44382: Ljava/nio/file/Files;.newInputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/InputStream;
08-18 19:41:21.150 23420-23438/com.wezzlecorp.wezzle W/Settings: Setting airplane_mode_on has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.

#4

Looks like something could be wrong with your layout. Could you share your whole layout?


#5
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/scrollviewMenu"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    tools:context="com.wezzlecorp.wezzle.MenuActivity">

    <LinearLayout
        android:id="@+id/holder"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/bg"
        android:orientation="vertical"
        android:padding="5dp">

        <!-- ##SEARCH BAR -->
        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp">
            <LinearLayout
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:layout_width="0px"
                android:layout_height="0px" />

            <EditText
                android:id="@+id/searchTerm"
                android:layout_width="fill_parent"
                android:layout_height="52dp"
                android:background="@drawable/fb_grey_normal"
                android:textSize="24dp"
                android:gravity="center_vertical"
                android:layout_toLeftOf="@+id/btnSearch"
                android:layout_toStartOf="@+id/btnSearch"
                android:hint="Search..."
                android:singleLine="true"
                android:textCursorDrawable="@drawable/cursor"
                style="@style/BaseStyle"
                android:paddingTop="8dp"
                android:paddingBottom="8dp"
                android:paddingRight="12dp"
                android:paddingLeft="12dp" />

            <Button
                android:id="@+id/btnSearch"
                android:layout_width="52dp"
                android:layout_height="52dp"
                android:drawableLeft="@drawable/btn_search"
                android:background="@drawable/btn_bg_white"
                android:layout_alignParentEnd="false"
                android:layout_alignParentRight="true"
                android:paddingLeft="8dp" />
        </RelativeLayout>

        <!-- ##LATEST WIDGET -->
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:background="@drawable/fb_grey_normal"
            android:layout_alignParentTop="true"
            android:layout_marginTop="5dp"
            android:paddingBottom="5dp">

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="TWEETS"
                style="@style/FrameHeader"
                android:layout_marginBottom="5dp"
                android:layout_marginTop="5dp" />

            <ListView android:id="@+id/tweetView"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:divider="#e1e8ed"
                android:dividerHeight="1dp"
                android:drawSelectorOnTop="false"/>

        </LinearLayout>
    </LinearLayout>
</ScrollView>

#6

May the problem be the fact of having a ListView inside a ScrollView? If thats the case, there is any way I can use the adapter on a RecyclerView instead of the ListView? ListView honestly is not my main pick it has too many layout limitations.

EDIT–

Oddly I tested it again, removed the scrollview.
I tested using two different timelines, UserTimeline and CollectionTimeline. UserTimeline works perfectly, but the CollectionTimeline does not, no matter what I do or change, I dont believe it Layout related because it worked perfectly using UserTimeline.

This is the code I used:

tweetview = (ListView) findViewById(R.id.tweetView);
final CollectionTimeline timeline = new CollectionTimeline.Builder()
        .id(766080906511708163L)
        .build();
final UserTimeline userTimeline = new UserTimeline.Builder()
        .screenName("wezzlecorp")
        .build();
final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter.Builder(this)
        .setTimeline(userTimeline)
        .build();
tweetview.setAdapter(adapter);

#7

Now I just tried to use the UserTimeline, and it shows the tweets but I can’t limit the amount of tweets to show, it shows always my whole list of tweets instead of the given quantity(3)

final UserTimeline userTimeline = new UserTimeline.Builder()
        .screenName("wezzlecorp")
        .maxItemsPerRequest(3)
        .build();
final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter.Builder(this)
        .setTimeline(userTimeline)
        .build();
tweetview.setAdapter(adapter);