Exemplo n.º 1
0
  @Override
  public void onPause() {
    super.onPause();

    // clear show orig coloring
    Session.setReplyTagId(null);
    Session.setOrigTagId(null);
    // adapter.notifyDataSetChanged();
  }
Exemplo n.º 2
0
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;

    int actualPos = info.position - tagListView.getHeaderViewsCount();
    if (actualPos < 0) return;
    Tag tagClicked = tags.getTags().get(actualPos);

    // Log.i("occm", tagClicked.getParent_id() + " " +
    // tagClicked.getComment().toString());

    String userId = tagInfo.getString("user_id", "error");

    boolean isOwnTag = (tagClicked.getUser_id().equals(userId));

    menu.setHeaderTitle(R.string.context_menu_header);
    menu.add(0, v.getId(), 6, R.string.context_menu_reply);
    if (!tagClicked.getParent_id().equals("0")) {
      menu.add(0, v.getId(), 5, R.string.context_menu_show_orig);
    }
    if (isOwnTag) return;

    if (!tagClicked.getIs_thumbedup()) menu.add(0, v.getId(), 1, R.string.context_menu_thumbup);

    if (Session.getFollowerSet().contains(tagClicked.getUser_id()))
      menu.add(0, v.getId(), 3, R.string.context_menu_unfollow);
    else menu.add(0, v.getId(), 4, R.string.context_menu_follow);
  }
Exemplo n.º 3
0
    private void showOrig(String idToAdd, String replyId) {
      Session.setReplyTagId(replyId);
      Session.setOrigTagId(idToAdd);
      String access_token = checkAccessToken();
      String user_id = checkUserId();
      boolean wasFound = false;
      try {
        if (UpdateTagService.tagUpdateLock.tryLock(500, TimeUnit.MILLISECONDS)) {
          Tag tagToShow = tags.pullTagFromList(idToAdd);
          if (tagToShow != null) {
            wasFound = tags.addTagAbove(replyId, tagToShow);
            adapter.notifyDataSetChanged();
          }
        }
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

      if (wasFound) { // if this is true, both the orig and reply are in
        // the current tag list
        return;
      }
      final String replyIdLocal = replyId;
      final String idToAddLocal = idToAdd;
      JSONObject jsonSend = new JSONObject();
      try {
        jsonSend.put("access_token", access_token);
        jsonSend.put("user_id", user_id);
        jsonSend.put("ttag_id", idToAdd);
        jsonSend.put("search_on", "ttag");
        WebserviceClient.post(
            getActivity(),
            "/ttag/get",
            jsonSend,
            new ResponseHandler() {
              @Override
              public void onSuccess(JSONObject response) {
                if (!isError(response)) {
                  JSONObject jsonData;
                  try {
                    jsonData = response.getJSONObject("data");
                    JSONObject jsonTag = jsonData.getJSONObject("ttag");
                    long time = response.getLong("time");
                    Tag tag = new Tag(jsonTag, tags.getSpam(), tags.getThumbed(), time);
                    tags.addTagAbove(replyIdLocal, tag);
                    adapter.notifyDataSetChanged();

                  } catch (JSONException e) {
                    e.printStackTrace();
                  }
                }
              }

              @Override
              public void onFailure(Throwable error, String content) {
                Log.e("Post failure", content);
                Toast.makeText(
                        Ttagit.getAppContext(), "Request to Get Tag Failed", Toast.LENGTH_LONG)
                    .show();
              }
            });
      } catch (JSONException e) {
        e.printStackTrace();
        return;
      }
    }
Exemplo n.º 4
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   Util.writeFollowingSet(Session.getFollowerSet());
 }