• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TweetUtils类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.twitter.sdk.android.tweetui.TweetUtils的典型用法代码示例。如果您正苦于以下问题:Java TweetUtils类的具体用法?Java TweetUtils怎么用?Java TweetUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

TweetUtils类属于com.twitter.sdk.android.tweetui包,在下文中一共展示了TweetUtils类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: loadTweet

点赞 3

import com.twitter.sdk.android.tweetui.TweetUtils; //导入依赖的package包/类
private void loadTweet() {
  LogUtils.d(TAG, "loadTweet, tweetId = " + tweetId);

  TweetUtils.loadTweet(tweetId, new Callback<Tweet>() {
    @Override
    public void success(Result<Tweet> result) {
      LogUtils.d(TAG, "loadTweet, success");
      Tweet selectedTweet = result.data;
      setTweet(selectedTweet);
      handleSuccess();
    }

    @Override
    public void failure(TwitterException exception) {
      LogUtils.d(TAG, "loadTweet, failure");
      // TODO send message
      handleError();
    }
  });
}
 

开发者ID:netceteragroup,
项目名称:react-native-twitterkit,
代码行数:21,
代码来源:TweetView.java

示例2: handleTweet

点赞 3

import com.twitter.sdk.android.tweetui.TweetUtils; //导入依赖的package包/类
/**
 * Handles adding a tweet to the view.
 *
 * @param holder the holder for hte tweet.
 * @param post   the post that contains the Id for the tweet.
 * @see CompactTweetView
 * @see TweetUtils#loadTweet(long, Callback)
 * @see Tweet
 */
private void handleTweet(ViewHolder holder, Post post) {
    final TwitterViewHolder twitterViewHolder = (TwitterViewHolder) holder;
    TwitterPost twitterPost = (TwitterPost) post;
    TweetUtils.loadTweet(twitterPost.tweetId, new Callback<Tweet>() {
        @Override
        public void success(Result<Tweet> result) {
            //Unlike the other posts, we have to add a delivered TweetView to the card view.
            twitterViewHolder.mCardView.addView(new CompactTweetView(mContext, result.data));
        }

        @Override
        public void failure(TwitterException exception) {
            Log.d(TAG, "Failed to handle tweet properly in adapter");
        }
    });
}
 

开发者ID:cache117,
项目名称:social-journal,
代码行数:26,
代码来源:SocialJournalAdapter.java

示例3: loadAllTweets

点赞 3

import com.twitter.sdk.android.tweetui.TweetUtils; //导入依赖的package包/类
private void loadAllTweets(){

        for(final Long tweetId: tweetIds){

            TweetUtils.loadTweet(tweetId, new Callback<Tweet>() {
                @Override
                public void success(Result<Tweet> result) {
                    //Tweet tweet = result.data;

                    TweetView tweetView = new TweetView(MyReTweetsActivity.this, result.data,
                            R.style.tw__TweetLightWithActionsStyle);

                    View breakLine = getLayoutInflater().inflate(R.layout.tweet_view_layout, null);
                    tweetView.setOnActionCallback(actionCallback);
                    myLayout.addView(tweetView);
                    myLayout.addView(breakLine);
                }

                @Override
                public void failure(TwitterException exception) {
                    // Toast.makeText(...).show();
                }
            });

        }
    }
 

开发者ID:manishpatelgt,
项目名称:MyTwitterRepo,
代码行数:27,
代码来源:MyReTweetsActivity.java

示例4: loadAllTweets

点赞 3

import com.twitter.sdk.android.tweetui.TweetUtils; //导入依赖的package包/类
private void loadAllTweets(){

        for(final Long tweetId: tweetIds){

            TweetUtils.loadTweet(tweetId, new Callback<Tweet>() {
                @Override
                public void success(Result<Tweet> result) {
                    //Tweet tweet = result.data;

                    TweetView tweetView = new TweetView(MyTweetsActivity.this, result.data,
                            R.style.tw__TweetLightWithActionsStyle);

                    View breakLine = getLayoutInflater().inflate(R.layout.tweet_view_layout, null);
                    tweetView.setOnActionCallback(actionCallback);
                    myLayout.addView(tweetView);
                    myLayout.addView(breakLine);
                }

                @Override
                public void failure(TwitterException exception) {
                    // Toast.makeText(...).show();
                }
            });

        }
    }
 

开发者ID:manishpatelgt,
项目名称:MyTwitterRepo,
代码行数:27,
代码来源:MyTweetsActivity.java

示例5: loadAllTweets

点赞 3

import com.twitter.sdk.android.tweetui.TweetUtils; //导入依赖的package包/类
private void loadAllTweets(){

        for(final Long tweetId: tweetIds){

            TweetUtils.loadTweet(tweetId, new Callback<Tweet>() {
                @Override
                public void success(Result<Tweet> result) {
                    //Tweet tweet = result.data;

                    TweetView tweetView = new TweetView(HomeActivity.this, result.data,
                            R.style.tw__TweetLightWithActionsStyle);

                    View breakLine = getLayoutInflater().inflate(R.layout.tweet_view_layout, null);
                    tweetView.setOnActionCallback(actionCallback);
                    myLayout.addView(tweetView);
                    myLayout.addView(breakLine);
                }

                @Override
                public void failure(TwitterException exception) {
                    // Toast.makeText(...).show();
                }
            });

        }
    }
 

开发者ID:manishpatelgt,
项目名称:MyTwitterRepo,
代码行数:27,
代码来源:HomeActivity.java

示例6: loadTweet

点赞 3

import com.twitter.sdk.android.tweetui.TweetUtils; //导入依赖的package包/类
/**
 * loadTweet wraps TweetUtils.loadTweet with a callback that ensures the view is given a
 * known id to simplify UI automation testing.
 */
private void loadTweet(long tweetId, final ViewGroup container, final int viewId) {
    final Callback<Tweet> singleTweetCallback = new Callback<Tweet>() {
        @Override
        public void success(Result<Tweet> result) {
            final Context context = getActivity();
            if (context == null) return;
            final Tweet tweet = result.data;
            final BaseTweetView tv = new TweetView(context, tweet,
                    R.style.tw__TweetLightWithActionsStyle);
            tv.setOnActionCallback(actionCallback);
            tv.setId(viewId);
            container.addView(tv);
        }

        @Override
        public void failure(TwitterException exception) {
            Log.e(TAG, "loadTweet failure", exception);
        }
    };
    TweetUtils.loadTweet(tweetId, singleTweetCallback);
}
 

开发者ID:twitter,
项目名称:twitter-kit-android,
代码行数:26,
代码来源:TweetActivity.java

示例7: loadTweets

点赞 3

import com.twitter.sdk.android.tweetui.TweetUtils; //导入依赖的package包/类
/**
 * loadTweets wraps TweetUtils.loadTweets to use a callback that ensures each view is given
 * a known id to simplify UI automation testing.
 */
private void loadTweets(final List<Long> tweetIds, final ViewGroup container,
                        final List<Integer> viewIds) {
    TweetUtils.loadTweets(tweetIds, new Callback<List<Tweet>>() {
        @Override
        public void success(Result<List<Tweet>> result) {
            final Context context = getActivity();
            if (context == null) return;
            for (int i = 0; i < result.data.size(); i++) {
                final BaseTweetView tv = new CompactTweetView(context, result.data.get(i),
                        R.style.tw__TweetDarkWithActionsStyle);
                tv.setOnActionCallback(actionCallback);
                tv.setId(viewIds.get(i));
                container.addView(tv);
            }
        }

        @Override
        public void failure(TwitterException exception) {
            Log.e(TAG, "loadTweets failure " + tweetIds, exception);
        }
    });
}
 

开发者ID:twitter,
项目名称:twitter-kit-android,
代码行数:27,
代码来源:TweetActivity.java

示例8: loadTweet

点赞 2

import com.twitter.sdk.android.tweetui.TweetUtils; //导入依赖的package包/类
/**
 * loadTweet wraps TweetUtils.loadTweet with a callback that ensures a compact and default
 * view with the correct style and spacing are inserted.
 */
private void loadTweet(long tweetId, final ViewGroup container, final int style) {

    final Callback<Tweet> singleTweetCallback = new Callback<Tweet>() {

        @Override
        public void success(Result<Tweet> result) {
            final Context context = getActivity();
            if (context == null) return;

            final Tweet tweet = result.data;
            final CompactTweetView cv = new CompactTweetView(context, tweet, style);
            container.addView(cv);

            final View spacer = new View(context);
            final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,
                    (int) context.getResources().getDimension(R.dimen.demo_tweet_space));
            spacer.setLayoutParams(params);
            container.addView(spacer);

            final TweetView tv = new TweetView(context, tweet, style);
            container.addView(tv);

        }

        @Override
        public void failure(TwitterException exception) {
            final Activity activity = getActivity();
            if (activity != null && !activity.isFinishing()) {
                Toast.makeText(activity, R.string.tweet_load_error,
                        Toast.LENGTH_SHORT).show();
            }
            Log.e(TAG, "loadTweet failure", exception);
        }
    };
    TweetUtils.loadTweet(tweetId, singleTweetCallback);
}
 

开发者ID:twitter,
项目名称:twitter-kit-android,
代码行数:41,
代码来源:TweetPreviewActivity.java

示例9: onCreate

点赞 2

import com.twitter.sdk.android.tweetui.TweetUtils; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    tweetIds.addAll(Arrays.asList(574000939800993792L, 503435417459249153L, 510908133917487104L,
            473514864153870337L, 477788140900347904L, 20L, 484816434313195520L,
            466041861774114819L, 448250020773380096L));

    TweetUtils.loadTweets(tweetIds, new Callback<List<Tweet>>() {
        @Override
        public void success(Result<List<Tweet>> result) {
            final FixedTweetTimeline fixedTimeline = new FixedTweetTimeline.Builder()
                    .setTweets(result.data).build();
            final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter(getActivity(),
                    fixedTimeline);
            setListAdapter(adapter);
        }

        @Override
        public void failure(TwitterException exception) {
            final Activity activity = getActivity();
            if (activity != null && !activity.isFinishing()) {
                Toast.makeText(activity, R.string.multi_tweet_view_error,
                        Toast.LENGTH_SHORT).show();
            }
        }
    });
}
 

开发者ID:twitter,
项目名称:twitter-kit-android,
代码行数:29,
代码来源:FixedTimelineActivity.java

示例10: onCreate

点赞 2

import com.twitter.sdk.android.tweetui.TweetUtils; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_embed_tweets);
    setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mToolbar.setTitle("Embed Tweets");

    final LinearLayout mLinearLayout = (LinearLayout) findViewById(R.id.linear_layout);

    //Dynamically add tweet
    final long tweetId = 623055543385591809L;
    TweetUtils.loadTweet(tweetId, new Callback<Tweet>() {
        @Override
        public void success(Result<Tweet> result) {
            mLinearLayout.addView(new TweetView(EmbedTweetsActivity.this, result.data));
        }

        @Override
        public void failure(TwitterException exception) {
            //Handle failure to load tweet
        }
    });
}
 

开发者ID:JSafaiyeh,
项目名称:Fabric-Example-App-Android,
代码行数:28,
代码来源:EmbedTweetsActivity.java

示例11: onCreate

点赞 2

import com.twitter.sdk.android.tweetui.TweetUtils; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_embedded_tweets);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final LinearLayout myLayout = (LinearLayout) findViewById(R.id.my_tweet_layout);

    TweetUtils.loadTweet(710543894992130048L, new Callback<Tweet>() {
        @Override
        public void success(Result<Tweet> result) {
            //Tweet tweet = result.data;
            TweetView tweetView = new TweetView(EmbeddedTweetsActivity.this, result.data,
                    R.style.tw__TweetLightWithActionsStyle);

            tweetView.setOnActionCallback(actionCallback);
            myLayout.addView(tweetView);
        }

        @Override
        public void failure(TwitterException exception) {
            // Toast.makeText(...).show();
        }
    });

    /*TwitterApiClient twitterApiClient = TwitterCore.getInstance().getApiClient();
   // Can also use Twitter directly: Twitter.getApiClient()
    StatusesService statusesService = twitterApiClient.getStatusesService();
    statusesService.show(710543894992130048L, null, null, null, new Callback<Tweet>() {
        @Override
        public void success(Result<Tweet> result) {
            //Do something with result, which provides a Tweet inside of result.data
                Tweet tweet = result.data;
                TweetView tweetView = new TweetView(EmbeddedTweetsActivity.this, result.data,
                    R.style.tw__TweetDarkWithActionsStyle);

               tweetView.setOnActionCallback(actionCallback);
               myLayout.addView(tweetView);

        }

        public void failure(TwitterException exception) {
            //Do something on failure
        }
    });*/

    /*final LinearLayout myLayout = (LinearLayout) findViewById(R.id.my_tweet_layout);

    final List<Long> tweetIds = Arrays.asList(510908133917487104L);
    TweetUtils.loadTweets(tweetIds, new Callback<Tweet>() {
        @Override
        public void success(Result<Tweet> result) {
            for (Tweet tweet : result.data) {
                myLayout.addView(new TweetView(EmbeddedTweetsActivity.this, tweet));
            }
        }

        @Override
        public void failure(TwitterException exception) {
            // Toast.makeText(...).show();
        }
    });*/

}
 

开发者ID:manishpatelgt,
项目名称:MyTwitterRepo,
代码行数:66,
代码来源:EmbeddedTweetsActivity.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)