void buttonVisible(int state) { try { activity.findViewById(R.id.Button01).setVisibility(state); activity.findViewById(R.id.Button02).setVisibility(state); } catch (Exception e) { } }
public void repaint() { try { TextView tv = (TextView) activity.findViewById(R.id.TextView01); tv.setText("" + lname); } catch (Exception e) { } ListView listView = (ListView) activity.findViewById(R.id.ListView01); ((AdapterView<ListAdapter>) listView).setAdapter(null); mHandler.post( new Runnable() { @Override public void run() { try { repaintMain(); } catch (Exception e) { errorHandling(e); } } }); }
@Override public void loadMain() { ResponseList<Status> result = null; List<ListItem> list = new ArrayList<ListItem>(); // ListItem AD = getMessageItem(getAD()); list.add(AD); try { result = getTwitter().getUserListStatuses(lid, new Paging(1)); } catch (Exception e) { errorHandling(e); } if (result == null || result.isEmpty()) { String comment = "NO DATA"; if (!myAdapter.getItem(myAdapter.getCount() - 1).comment.equals(comment)) { myAdapter.add(getMessageItem(comment)); } } else { for (Status tweet : result) { ListItem item1 = toListItem(tweet); list.add(item1); downloadIdList.add("" + item1.id); } // itemMessLoading = getMessageItem("Loading..."); list.add(itemMessLoading); itemEmpty = getMessageItem(""); list.add(itemEmpty); adapter = new ListItemAdapter(activity, 0, list, R.layout.list_item10, true); listView = (ListView) activity.findViewById(R.id.ListView01); ((AdapterView<ListAdapter>) listView).setAdapter(adapter); listView.setScrollingCacheEnabled(false); listView.setSelection(0); if (!BaseActivity.fast) { listView.setOnItemLongClickListener( new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick( AdapterView<?> parent, View view, int position, long id) { final ListItem item = (ListItem) listView.getItemAtPosition(position); ArrayList<String> entries = getEntries(activity, item); if (entries.size() > 0) { final String[] ITEM = toArray(entries); new AlertDialog.Builder(activity) .setTitle("") .setItems( ITEM, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { controlTag(activity, ITEM, which, item); } }) .create() .show(); } return true; } }); } listView.setOnScrollListener( new OnScrollListener() { private boolean doing; @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { try { if (firstVisibleItem + visibleItemCount == totalItemCount) { Log.d(TAG, "LASTTTTTTTTTTTTT"); // if (doing) return; doing = true; // myAdapter = (ListItemAdapter) view.getAdapter(); if (!myAdapter .getItem(myAdapter.getCount() - 1) .comment .equals("NO DATA")) { // NO DATA mHandler.post( new Runnable() { @Override public void run() { paging.setPage(paging.getPage() + 1); myAdapter.remove(itemMessLoading); myAdapter.remove(itemEmpty); ResponseList<Status> result = null; try { result = getTwitter().getUserListStatuses(lid, paging); } catch (Exception e) { errorHandling(e); } if (result == null || result.isEmpty()) { String comment = "NO DATA"; if (!myAdapter .getItem(myAdapter.getCount() - 1) .comment .equals(comment)) { myAdapter.add(getMessageItem(comment)); } } else { for (Status tweet : result) { ListItem item1 = toListItem(tweet); if (!downloadIdList.contains("" + item1.id)) { // myAdapter.add(item1); downloadIdList.add("" + item1.id); } } myAdapter.add(itemMessLoading); myAdapter.add(itemEmpty); } // doing = false; } }); } } } catch (Throwable t) { } } @Override public void onScrollStateChanged(AbsListView view, int scrollState) {} }); } }