@Override protected void onListItemClick(ListView l, View v, int position, long id) { // TODO Auto-generated method stub super.onListItemClick(l, v, position, id); Toast.makeText(getApplicationContext(), "class" + v.getClass().toString(), Toast.LENGTH_SHORT) .show(); TextView tv = (TextView) ((LinearLayout) v).findViewById(R.id.customListId); mSelectedAgentId = tv.getText().toString(); mQuickAction.show(v); mQuickAction.setAnimStyle(QuickAction.ANIM_GROW_FROM_CENTER); }
@Override protected void populateQuickActions(List<QuickAction> quickActions) { mQuickActions = quickActions; final LayoutInflater inflater = LayoutInflater.from(getContext()); for (QuickAction action : quickActions) { TextView view = (TextView) inflater.inflate(R.layout.gd_quick_action_bar_item, mQuickActionItems, false); view.setText(action.mTitle); view.setCompoundDrawablesWithIntrinsicBounds(null, action.mDrawable, null, null); view.setOnClickListener(mClickHandlerInternal); mQuickActionItems.addView(view); action.mView = new WeakReference<View>(view); } }
public void onClick(View v) { SQLiteEventStore store = new SQLiteEventStore(context); if (event.isFavorite()) { store.setFavorite(event.getUid(), event.getStartDate(), false); event.setFavorite(false); } else { store.setFavorite(event.getUid(), event.getStartDate(), true); event.setFavorite(true); } adapter.notifyDataSetChanged(); quickAction.dismiss(); }
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.agentslist); // get the database inContactData = openOrCreateDatabase("inContactData", MODE_PRIVATE, null); // // set up the quick action popup // ActionItem chatAgent = new ActionItem( ID_SMSAGENT, "Text", getResources().getDrawable(R.drawable.ic_action_example)); ActionItem callAgent = new ActionItem( ID_CALLAGENT, "Call", getResources().getDrawable(R.drawable.ic_action_phone)); ActionItem icMessageAgent = new ActionItem( ID_ICMESSAGEAGENT, "iCMessage", getResources().getDrawable(R.drawable.ic_action_example)); mQuickAction = new QuickAction(this); mQuickAction.addActionItem(chatAgent); mQuickAction.addActionItem(callAgent); mQuickAction.addActionItem(icMessageAgent); mQuickAction.setOnActionItemClickListener( new QuickAction.OnActionItemClickListener() { public void onItemClick(QuickAction source, int pos, int actionId) { ActionItem actionItem = source.getActionItem(pos); switch (actionId) { case ID_CALLAGENT: { Toast.makeText(getApplicationContext(), "call agent", Toast.LENGTH_SHORT).show(); break; } case ID_SMSAGENT: { Toast.makeText(getApplicationContext(), "text agent", Toast.LENGTH_SHORT).show(); break; } case ID_ICMESSAGEAGENT: { if (mInSideWSService != null) { DateTime dt = new DateTime(); dt = dt.plusDays(5); DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); String validUntilDate = fmt.print(dt); mInSideWSService.sendAgentMessage( InContactAgentMessageScopes.Agent, new int[] {Integer.parseInt(mSelectedAgentId)}, "Hey you", "Useless Things", validUntilDate, 5); } break; } } } }); mQuickAction.setOnDismissListener( new QuickAction.OnDismissListener() { public void onDismiss() { Toast.makeText(getApplicationContext(), "Ups..dismissed", Toast.LENGTH_SHORT).show(); } }); Log.i("sortedagent.oncreate", "creating service object"); // // creating service connection // mInSideWSConnection = new ServiceConnection() { // // service connected handler // public void onServiceConnected(ComponentName comp, IBinder binder) { InSideWSServiceBinder b = (InSideWSServiceBinder) binder; mInSideWSService = b.getService(); mInSideWSService.registerListener(SortedAgentList.this); Log.i("sortedagent.connected", "connected!"); setAdapter(); } // // service disconnected handler // public void onServiceDisconnected(ComponentName comp) { // TODO Auto-generated method stub mBound = false; } }; refreshAgentsButton = (Button) findViewById(R.id.refreshAgentsButton); refreshAgentsButton.setOnClickListener( new OnClickListener() { public void onClick(View v) { SortedAgentList.this.mInSideWSService.requestActiveAgentsRefresh(); } }); testButton = (Button) findViewById(R.id.button1); testButton.setOnClickListener( new OnClickListener() { public void onClick(View v) { startActivity(new Intent(getApplicationContext(), AgentViewActivity.class)); } }); // // create the handler... this is used to do work on the // UI thread from the handleEvent() method, which will // be called from another thread (usually). // mHandler = new Handler() { @Override public void handleMessage(Message msg) { Log.d("Handler", "a handle request occured on a non-UI thread... marshalling."); InContactEvent evt = (InContactEvent) msg.obj; if (evt.eventType == InContactEventType.ACTIVE_AGENTS_UPDATED) { setAdapter(); } } }; }