@Override protected Integer doInBackground(YouRoomEntry... entries) { YouRoomCommandProxy proxy = new YouRoomCommandProxy(activity); YouRoomEntry entry = proxy.getEntry( roomId, String.valueOf(entries[0].getId()), entries[0].getUpdatedTime(), errFlg); entries[0].setDescendantsCount(entry.getDescendantsCount()); return entry.getDescendantsCount(); }
@Override protected String doInBackground(String... params) { YouRoomCommandProxy proxy = new YouRoomCommandProxy(activity); String status = ""; try { status = proxy.destroyEntry(params[0], params[1], params[2]); } catch (YouRoomServerException e) { // TODO Auto-generated catch block e.printStackTrace(); } return status; }
@Override protected Bitmap doInBackground(YouRoomEntry... params) { YouRoomCommandProxy proxy = new YouRoomCommandProxy(activity); Bitmap image = null; roomEntry = params[0]; String roomId = roomEntry.getRoomId(); String participationId = roomEntry.getParticipationId(); synchronized (activity.getBaseContext()) { try { image = proxy.getMemberImageFromCache(roomId, participationId); if (image == null) { image = proxy.getMemberImage(roomId, participationId, errFlg); } roomEntry.setMemberImage(image); } catch (Exception e) { e.printStackTrace(); errFlg[0] = true; image = BitmapFactory.decodeResource(getResources(), R.drawable.icon); } return image; } }
@Override protected ArrayList<YouRoomEntry> doInBackground(Void... ids) { YouRoomCommandProxy proxy = new YouRoomCommandProxy(activity); ArrayList<YouRoomEntry> dataList = proxy.getRoomEntryList(roomId, parameterMap, errFlg); return dataList; }
@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; } }); }