Ejemplo n.º 1
0
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  // IPPからコメント読み込むメソッド
  public void showCommentList(int target_year, int target_month, long until, int near) {

    // オンラインなら外部DBから他人のデータ読み出し//
    try {
      waitBar.setVisibility(View.VISIBLE);
      listView.setVisibility(View.GONE);
    } catch (NullPointerException e) {
      Log.d(TAG, e.toString());
    }

    if (NetworkManager.isConnected(getActivity().getApplicationContext())) {
      adapter.clear();

      // 読みだすデータの日時の範囲を指定
      int year = 0;
      int month = 0;
      long mUntil = 0;
      this.until = until;

      if (target_month == 0 && target_year == 0) {
        // 今月1日のUNIXタイムスタンプ(ミリ秒)を取得
        year = calendar.get(Calendar.YEAR);
        month = calendar.get(Calendar.MONTH);
        calendar.set(year, month, 1, 0, 0, 0);

        since = calendar.getTimeInMillis(); // 今月頭から

        if (until == 0) {
          mUntil = System.currentTimeMillis(); // 現在まで

        } else {
          mUntil = until;
        }

      } else { // 月と日を指定されたら

        year = target_year;
        calendar.set(year, target_month, 1, 0, 0, 0); // 指定月の1日から
        since = calendar.getTimeInMillis();

        if (until == 0) {
          calendar.add(Calendar.MONTH, 1);
          mUntil = calendar.getTimeInMillis(); // 次の月の1日まで
          calendar.add(Calendar.MONTH, -1); // 戻しとく

        } else {
          mUntil = until;
        }
      }

      IPPGeoResourceClient client =
          new IPPGeoResourceClient(getSherlockActivity().getApplicationContext());
      client.setAuthKey(ipp_auth_key);

      jp.innovationplus.ipp.client.IPPGeoResourceClient.QueryCondition condition =
          new jp.innovationplus.ipp.client.IPPGeoResourceClient.QueryCondition();

      condition.setSince(since);
      condition.setUntil(mUntil);
      condition.setCount(10);
      condition.eq("pair_common_id", pair_common_id);

      if (near == 1) {
        condition.setBoundByRadiusSquare(
            mNowLocation.getLatitude(), mNowLocation.getLongitude(), radiusSquare);
      }

      condition.build();
      client.query(CommentGeoResource.class, condition, new CommentGeoGetCallback());

    } else {
      Toast.makeText(
              getSherlockActivity(),
              res.getString(R.string.message_network_disabled),
              Toast.LENGTH_SHORT)
          .show();
    }
  }
Ejemplo n.º 2
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));
    }