Exemplo n.º 1
0
    @Override
    public void onClick(View v) {

      String tweetContent = twTx.getText().toString();

      if (tweetContent.length() == 0) {
        Toast toast2 =
            Toast.makeText(
                getSherlockActivity().getApplicationContext(), "文を入力して下さい。", Toast.LENGTH_LONG);
        toast2.show();
        return;
      } else {
        /*
        if (tweetCheckBox.isChecked()) { //「ツイートする」にチェックが入っていたら
        	//ログインチェックとログイン画面への自動遷移
        	checkLoginTwitter();

        	//ツイート機能
        	if (tweetContent.length() > 140) {
        		Toast toast = Toast.makeText(getSherlockActivity().getApplicationContext(), "長過ぎます。",
        				Toast.LENGTH_LONG);
        		toast.show();
        	} else {

        		Bundle args = new Bundle(1); //onCreateLoaderに渡したい値はここへ
        		args.putString("tweetContent", tweetContent);
        		//getSherlockActivity().getSupportLoaderManager().initLoader(0, args, CommentFragment.this);  //こっちは自分にローダーを実装する場合

        		TweetAsyncLoaderClass tweet_async_loader_class = new TweetAsyncLoaderClass(CommentFragment.this, token, token_secret, getSherlockActivity().getApplicationContext());
        		getLoaderManager().restartLoader(0, args, tweet_async_loader_class);
        	}
        }
        */
      }

      // IPPへコメント投稿
      CommentItem commentItem = new CommentItem();

      // スター
      commentItem.setStar(0);

      // コメント内容
      commentItem.setCommentText(tweetContent);

      // 現在の日時
      Timestamp timestamp = new Timestamp(System.currentTimeMillis());
      commentItem.setCommentCreated(timestamp.toString());
      commentItem.setTimestamp(timestamp.getTime());

      // ユーザ名(IPP上の)
      commentItem.setCommentUserName(ipp_id_string);

      // スクリーンネーム
      commentItem.setCommentScreenName(ipp_screen_name);

      // 緯度経度精度
      /*
      if(mNowLocation != null){
      	commentItem.setLongitude(mNowLocation.getLongitude());
      	commentItem.setLatitude(mNowLocation.getLatitude());
      	commentItem.setAccuracy(mNowLocation.getAccuracy());
      	commentItem.setProvider(mNowLocation.getProvider());
      }
      */

      // チームid
      commentItem.setTeam_resource_id(team_resource_id);
      commentItem.setPair_common_id(CommentFragment.this.pair_common_id);

      // 返信
      if (comment_parent_id_new != null) {
        commentItem.setCommentParentResourceId(comment_parent_id_new);
      }

      // 位置情報用リソース
      IPPGeoLocation geo_location = new IPPGeoLocation();
      if (mNowLocation != null) {
        geo_location.setLongitude(mNowLocation.getLongitude());
        geo_location.setLatitude(mNowLocation.getLatitude());
        geo_location.setAccuracy(mNowLocation.getAccuracy());
        geo_location.setTimestamp(mNowLocation.getTime());

        geo_location.setProvider(mNowLocation.getProvider());
      }

      // testdata
      // geo_location.setLongitude(141.157322);
      // geo_location.setLatitude(43.143333);

      List<IPPGeoLocation> geoLocations = new ArrayList();
      geoLocations.add(geo_location);

      CommentGeoResource resource = new CommentGeoResource();
      resource.setResource(commentItem);
      resource.setGeolocations(geoLocations);

      IPPGeoResourceClient client =
          new IPPGeoResourceClient(getSherlockActivity().getApplicationContext());
      client.setAuthKey(ipp_auth_key);
      client.setDebugMessage(true);
      client.create(CommentGeoResource.class, resource, new SendCommentCallback(twTx));
    }