TweetView is cut off inside LinearLayout

android
embeddedtweet

#1

I’m trying to render a TweetView inside a LinearLayout. It gets cut-off like this:

And I am not sure why. I create the View with a null Tweet initially, and then setTweet later, I wonder if that’s the issue. But if I try to create the tweetView and add it in the callback it just never shows up.

This is all inside a React Native app, so maybe there is some weirdness with sizing?

Here is my view code for reference:

package com.starjar.twitter;

import android.content.Context;
import android.util.Log;
import android.widget.LinearLayout;

import com.facebook.react.uimanager.ThemedReactContext;
import com.twitter.sdk.android.core.Callback;
import com.twitter.sdk.android.core.Result;
import com.twitter.sdk.android.core.TwitterApiClient;
import com.twitter.sdk.android.core.TwitterCore;
import com.twitter.sdk.android.core.TwitterException;
import com.twitter.sdk.android.core.models.Tweet;
import com.twitter.sdk.android.core.services.StatusesService;
import com.twitter.sdk.android.tweetui.CompactTweetView;
import retrofit2.Call;


public class TweetView extends LinearLayout {

    private CompactTweetView tweetView;

    public TweetView(ThemedReactContext context){
        super(context);
        setOrientation(LinearLayout.VERTICAL);
        setGravity(17);

        tweetView = new CompactTweetView(context, (Tweet)null);
        addView(tweetView);
    }

    public void setTweetID(String tweetID){
        TwitterApiClient twitterApiClient = TwitterCore.getInstance().getApiClient();

        StatusesService statusesService = twitterApiClient.getStatusesService();

        Call<Tweet> call = statusesService.show(Long.parseLong(tweetID), false, false, true);

        call.enqueue(new Callback<Tweet>(){
            @Override
            public void success(Result<Tweet> result){
                tweetView.setTweet(result.data);
            }

            @Override
            public void failure(TwitterException exception) {
                Log.d("TwitterKit", "Load Tweet failure", exception);
            }
        });
    }
}

Thanks in advance!


#2

Hey there,

Typically your view code would consist of multiple parts- an XML file defining the layout and its various sub-elements, and then an Activity (controller) class that manages the presentation of the elements on this page. I don’t see your controller code here- can you include it, or is this the usual structure of a React Native project? It’s worth noting that we don’t actually support React Native with our SDK, and that may be part of the problem.