private void getInitData() { try { CaOperatorIds OperatorIds = caDeskImpl.CaGetOperatorIds(); if (OperatorIds == null) { return; } contents.clear(); Log.d( "KonkaCaSystem", "OperatorIds.sOperatorIdState is " + OperatorIds.sOperatorIdState + "length is " + OperatorIds.OperatorId.length); if (OperatorIds.sOperatorIdState == RETURN_CODE.ST_CA_RC_OK.getRetCode()) { if (OperatorIds.OperatorId.length > 0) { for (int i = 0; i < OperatorIds.OperatorId.length; i++) { if (OperatorIds.OperatorId[i] == 0) // CA Spec:if // OperatorId=0,need // continue { continue; } Map<String, Object> map = new HashMap<String, Object>(); map.put("operator", OperatorIds.OperatorId[i]); CaOperatorChildStatus caOperatorChildStatus = caDeskImpl.CaGetOperatorChildStatus(OperatorIds.OperatorId[i]); if (caOperatorChildStatus.sIsChild == 0) { map.put("isparentcard", getResources().getString(R.string.str_ca_mg_parent_card)); map.put("delaytime", ""); map.put("lastfeedtime", ""); } else if (caOperatorChildStatus.sIsChild == 1) { map.put("isparentcard", getResources().getString(R.string.str_ca_mg_child_card)); map.put("delaytime", caOperatorChildStatus.sDelayTime); map.put("lastfeedtime", dateConvert(caOperatorChildStatus.wLastFeedTime)); } contents.add(map); } } } else if (OperatorIds.sOperatorIdState == RETURN_CODE.ST_CA_RC_CARD_INVALID.getRetCode()) { Tools.toastShow(R.string.st_ca_rc_card_invalid, this); } else if (OperatorIds.sOperatorIdState == RETURN_CODE.ST_CA_RC_POINTER_INVALID.getRetCode()) { Tools.toastShow(R.string.st_ca_rc_pointer_invalid, this); } } catch (CaCommonException e) { e.printStackTrace(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.ca_card_feed); ca_card_feed_listview = (ListView) findViewById(R.id.ca_card_feed_listview); caDeskImpl = CaDeskManager.getCaMgrInstance(); getInitData(); SimpleAdapter adapter = new SimpleAdapter( this, (List<Map<String, Object>>) contents, R.layout.ca_card_feed_listview_item, new String[] {"operator", "isparentcard", "delaytime", "lastfeedtime"}, new int[] { R.id.ca_card_feed_listviewitem_operator_id, R.id.ca_card_feed_listviewitem_child_or_parent, R.id.ca_card_feed_listviewitem_delaytime, R.id.ca_card_feed_listviewitem_lastfeedtime }); ca_card_feed_listview.setAdapter(adapter); ca_card_feed_listview.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final short wTVSID = (Short) contents.get(position).get("operator"); if (!getResources() .getString(R.string.str_ca_mg_parent_card) .equals(contents.get(position).get("isparentcard"))) { new AlertDialog.Builder(CaCardFeedActivity.this) .setTitle(R.string.please_insert_parent_card) .setNegativeButton(android.R.string.cancel, null) .setPositiveButton( android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { try { CaFeedDataInfo caFeedDataInfo = caDeskImpl.CaReadFeedDataFromParent(wTVSID); if (caFeedDataInfo.sFeedDataState == CDCAS_OK) { showInsertChildDialog(wTVSID, caFeedDataInfo); } else { showpRomptDialog(R.string.read_feeddata_from_parent_failed, null); } } catch (CaCommonException e) { e.printStackTrace(); } } }) .create() .show(); } } }); }