Beispiel #1
0
  @Override
  public void onPause() {
    super.onPause();

    // clear show orig coloring
    Session.setReplyTagId(null);
    Session.setOrigTagId(null);
    // adapter.notifyDataSetChanged();
  }
Beispiel #2
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;
      }
    }