TweetViewFetchAdapter.setTweetIds 不适用于 android

TweetViewFetchAdapter.setTweetIds does not work in android

我想在我的应用程序中显示一些带有 twitter API 的推文。为此,我获取了一些推文 ID(可以轻松使用)并使用 Twitter API 提供的 TweetViewFetchAdapter 适配器来显示我的推文。 奇怪的是:这在某些时候奏效了!但突然它停止工作(公司应用程序,多人在处理代码,但我在工作和不工作之间的时间里没有看到 twitter 的任何变化)

代码非常直接,取自官方推特网站:

// fill the tweet adapter with the loaded tweet ids
            @Override
            protected void onPostExecute(List<Long> params){
                if (params != null && params.size() > 0) {
                    adapter.setTweetIds(params,
                            new LoadCallback<List<Tweet>>() {
                                @Override
                                public void success(List<Tweet> tweets) {
                                    Log.i("twitter", "Success!");
                                }
                                @Override
                                public void failure(TwitterException exception) {
                                    Log.e("twitter", "Exception: " + exception.getMessage());
                                }
                            });
                }
                Log.i("twitter", "params.size = " + params.size() + "adapter.tweetCount = " + adapter.getCount());
            }

(在 AsyncTask 中)。适配器似乎无法设置推文 ID,因为调试输出为 I/twitter﹕ params.size = 10 adapter.tweet Count = 0 我试图在 success/failure 回调中 debug/have 日志输出,但我从来没有得到任何东西,好像这些方法永远不会被调用(实际上很奇怪..)

关于 log cat 的输出,我还没有看到,但恐怕我可能把它搞砸了,因为我们最近刚搬到 Android Studio,我就是做不到我还没想好那里的一些东西。

问题是由错误的 okhttp / okhttp-urlconnection 版本引起的。

奇怪的是没有显示任何调试信息。此代码解决了调试消息问题并帮助解决了整个问题:

final Fabric fabric = new Fabric.Builder(this)
            .kits(new Twitter(authConfig))
            .logger(new DefaultLogger(Log.DEBUG))
            .debuggable(true)
            .build();
Fabric.with(fabric);

整体修复:更改 build.gradle:

dependencies {
// ...
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.3.0'
}

原始对话:https://twittercommunity.com/t/adapter-settweetid-seems-to-be-unable-to-load-the-tweets-but-doesnt-fire-a-success-failure-callback/36506/13