Back to project page AndroidWifiServer.
The source code is released under:
Apache License
If you think the Android project AndroidWifiServer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package jp.maju.wifiserver.twitter; //from w w w .ja v a 2 s .c o m import jp.maju.wifiserver.AsyncExecutionTask; import jp.maju.wifiserver.util.Logger; import twitter4j.StatusUpdate; import twitter4j.Twitter; import twitter4j.TwitterException; /* * Copyright {2014} {Matsuda Jumpei} * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ public class TweetTask extends AsyncExecutionTask<StatusUpdate, Void, twitter4j.Status> { private static final String TAG = TweetTask.class.getSimpleName(); public interface OnTweetResultListener { void onPostedAll(boolean isLogin); void onPosted(twitter4j.Status status, boolean isLogin); } private OnTweetResultListener mOnTweetResultListener; public void setOnTweetResultListener(OnTweetResultListener mOnTweetResultListener) { this.mOnTweetResultListener = mOnTweetResultListener; } private final Twitter mTwitter; private final boolean isLogin; public TweetTask(Twitter twitter, boolean isLogin) { mTwitter = twitter; this.isLogin = isLogin; } @Override protected twitter4j.Status doInBackground(StatusUpdate... params) { if (params == null || params[0] == null) { return null; } try { for (StatusUpdate param : params) { twitter4j.Status status = mTwitter.updateStatus(param); if (mOnTweetResultListener != null) { mOnTweetResultListener.onPosted(status, isLogin); } try { Thread.sleep(2000); } catch (InterruptedException e) { Logger.e(TAG, e); } } } catch (TwitterException e) { Logger.e(TAG, e); } return null; } @Override protected void onPostExecute(twitter4j.Status result) { if (mOnTweetResultListener != null) { mOnTweetResultListener.onPostedAll(isLogin); } } }