示例#1
0
  public boolean onOptionsItemSelected(MenuItem item) {
    boolean ret = true;

    switch (item.getItemId()) {
      case REACQUIRE_ROOM:
        page = 1;
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap.put("page", String.valueOf(page));
        ProgressBar progress = (ProgressBar) footerView.findViewById(R.id.progbar);
        progress.setVisibility(View.VISIBLE);
        TextView footerText = (TextView) footerView.findViewById(R.id.footer_text_view);
        footerText.setText(getBaseContext().getString(R.string.now_loading));
        // footerView.setMinimumHeight(FOOTER_MIN_HEIGHT);
        // footerView.setVisibility(View.GONE);
        ((AppHolder) getApplication()).setDirty(roomId, true);
        GetRoomEntryTask task = new GetRoomEntryTask(roomId, parameterMap, this);
        task.execute();
        page++;
        ret = true;
        break;
      default:
        ret = super.onOptionsItemSelected(item);
        break;
    }
    return ret;
  }
示例#2
0
  private void reloadList() {
    ((AppHolder) getApplication()).setDirty(roomId, true);
    page = 1;
    Map<String, String> parameterMap = new HashMap<String, String>();
    parameterMap.put("page", String.valueOf(page));

    ((AppHolder) getApplication()).setDirty(roomId, true);
    GetRoomEntryTask task = new GetRoomEntryTask(roomId, parameterMap, this);
    task.execute();
    page++;
  }
示例#3
0
  @Override
  public void onStart() {
    super.onStart();
    final Activity activity = this;
    Intent intent = getIntent();
    roomId = intent.getStringExtra("roomId");

    Map<String, String> parameterMap = new HashMap<String, String>();
    parameterMap.put("page", String.valueOf(page));
    YouRoomCommandProxy proxy = new YouRoomCommandProxy(this);
    ArrayList<YouRoomEntry> dataList = proxy.getRoomEntryListFromCache(roomId, parameterMap);

    adapter = new YouRoomEntryAdapter(this, R.layout.room_list_item, dataList);
    listView.setAdapter(adapter);

    if (dataList.size() < MAX_ROOM_COUNT) {
      listView.removeFooterView(footerView);
      listView.removeFooterView(emptyView);
    }

    GetRoomEntryTask task = new GetRoomEntryTask(roomId, parameterMap, activity);
    task.execute();
    page++;

    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (view == footerView) {
              if (reloadButton.isClickable()) {
                Map<String, String> parameterMap = new HashMap<String, String>();
                parameterMap.put("page", String.valueOf(page));
                ProgressBar progress = (ProgressBar) footerView.findViewById(R.id.progbar);
                progress.setVisibility(View.VISIBLE);
                TextView footerText = (TextView) footerView.findViewById(R.id.footer_text_view);
                footerText.setText(getBaseContext().getString(R.string.now_loading));
                GetRoomEntryTask task = new GetRoomEntryTask(roomId, parameterMap, activity);
                task.execute();
                page++;
              }
            } else {
              ListView listView = (ListView) parent;
              YouRoomEntry item = (YouRoomEntry) listView.getItemAtPosition(position);
              if (item.getDescendantsCount() == -1) {
                Toast.makeText(getApplication(), "読み込み中です。もう少しおまちください。", Toast.LENGTH_SHORT).show();

              } else if (item.getDescendantsCount() == 0) {
                Intent intent = new Intent(getApplication(), CreateEntryActivity.class);
                intent.putExtra("action", "create");
                intent.putExtra("roomId", String.valueOf(roomId));
                intent.putExtra("youRoomEntry", item);

                startActivity(intent);
              } else {

                /*
                 * UserSession session = UserSession.getInstance();
                 * String lastAccessTime =
                 * youRoomUtil.getRoomAccessTime(roomId);
                 * session.setRoomAccessTime(roomId, lastAccessTime);
                 * String time = YouRoomUtil.getRFC3339FormattedTime();
                 * youRoomUtil.storeRoomAccessTime(roomId, time);
                 */
                UserSession session = UserSession.getInstance();
                String roomAccessTime = session.getRoomAccessTime(roomId);
                Intent intent = new Intent(getApplication(), EntryActivity.class);
                if (roomAccessTime != null) {
                  int compareResult =
                      YouRoomUtil.calendarCompareTo(roomAccessTime, item.getUpdatedTime());
                  if (compareResult < 0) {
                    intent.putExtra("update_flag", true);
                  }
                }
                intent.putExtra("roomId", String.valueOf(roomId));
                intent.putExtra("youRoomEntry", item);
                startActivity(intent);
              }
            }
          }
        });

    listView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {

          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            ListView listView = (ListView) parent;
            YouRoomEntry item = (YouRoomEntry) listView.getItemAtPosition(position);
            if (item == null) return false;
            // String entryId = String.valueOf(item.getId());
            // SQLiteDatabase cacheDb = ((AppHolder)
            // getApplication()).getCacheDb();
            // cacheDb.execSQL("delete from entries where entryId = ? and roomId = ? ;",
            // new String[] { entryId, roomId });
            contentsDialogUtil.showContentsDialog(item, roomId);
            return true;
          }
        });
  }