コード例 #1
0
  public void onReceiveResult(int resultCode, Bundle resultData) {
    switch (resultCode) {
      case STATUS_RUNNING:
        {
          mState.mSyncing = true;
          ToolKit.updateRefreshStatus(mState.mSyncing);
          break;
        }
      case STATUS_FINISHED:
        {
          ShortSite[] s = (ShortSite[]) resultData.getParcelableArray(GET_SITES);
          m_adapter.notifyDataSetChanged();
          mState.listSites.clear();
          mState.listSites.addAll(Arrays.asList(s));
          m_adapter.notifyDataSetChanged();
          //			runOnUiThread(returnRes);

          mState.mSyncing = false;
          ToolKit.updateRefreshStatus(mState.mSyncing);
          break;
        }
      case STATUS_ERROR:
        {
          // Error happened down in SyncService, show as toast.
          mState.mSyncing = false;
          ToolKit.updateRefreshStatus(mState.mSyncing);
          Toast.makeText(
                  ExploreRecentsActivity.this,
                  resultData.getString(Intent.EXTRA_TEXT),
                  Toast.LENGTH_LONG)
              .show();
          break;
        }
    }
  }
コード例 #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.list_view);
    actionBar = MenuHelper.actionBar;
    context = this;

    mState = (State) getLastNonConfigurationInstance();
    onRefreshClick = new RefreshClick();
    MenuHelper.actionBar.setHomeAction(onRefreshClick);

    final boolean previousState = mState != null;
    if (previousState) {
      // Start listening for SyncService updates again
      mState.mReceiver.setReceiver(this);
      ToolKit.updateRefreshStatus(mState.mSyncing);
    } else {
      mState = new State();
      mState.mReceiver.setReceiver(this);
      //			onRefreshClick.performAction(null);
    }

    getListView().setItemsCanFocus(true);
    m_adapter = new SiteAdapter(this, R.layout.explore_site, mState.listSites);
    setListAdapter(this.m_adapter);
  }
コード例 #3
0
 public void performAction(View view) {
   ToolKit.updateRefreshStatus(mState.mSyncing);
   mState.listSites.clear();
   if (ToolKit.i.recentsQueue.size() > 0) {
     Bundle b = new Bundle();
     ArrayList<Integer> list = new ArrayList<Integer>();
     Integer array[] = (Integer[]) ToolKit.i.recentsQueue.toArray(new Integer[0]);
     Collections.addAll(list, array);
     b.putIntegerArrayList(SITE_VAULE, list);
     ServiceHelper.startAction(POST_SITES, b, mState.mReceiver, getApplicationContext());
   }
   //			for (integer site_id: toolkit.i.recentsqueue){
   //				servicehelper.startaction(get_site, string.valueof(site_id), type,
   // mstate.mreceiver,context);
   //			}
 }