@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setTitle(getString(R.string.inbox)); this.setContentView(R.layout.outbox); SettingManager.getInstance().init(this); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancelAll(); mListView = (ListView) findViewById(R.id.list); mData = DatabaseOperator.getInstance().queryInbox(); if (DEBUG) { if (mData == null) { return; } for (MessageInfo info : mData) { Log.d(TAG, "[[onCreate]] info = " + info.toString()); } } mAdapter = new InfoAdapter(this, R.layout.list_item, mData); mListView.setAdapter(mAdapter); mListView.setOnItemLongClickListener( new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick( AdapterView<?> parent, View view, final int position, long id) { AlertDialog dialog = new AlertDialog.Builder(InboxActivity.this) .setPositiveButton( R.string.btn_delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mData != null && mData.size() > 0 && position < mData.size()) { MessageInfo info = mData.get(position); DatabaseOperator.getInstance().deleteInboxInfo(info); mData = DatabaseOperator.getInstance().queryInbox(); mAdapter = new InfoAdapter(InboxActivity.this, R.layout.list_item, mData); mListView.setAdapter(mAdapter); } } }) .setNegativeButton( R.string.btn_reply, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent reply = new Intent(); reply.setClass(getApplicationContext(), SendMessageActivity.class); reply.putExtra(SendMessageActivity.RELAY_SMS, true); startActivity(reply); } }) .create(); dialog.show(); return true; } }); }
public DiaryManager(Context context) { this.mContext = context; mDiaryDB = DiaryDB.getInstance(mContext, GlobalVariables.gSchoolKey); SettingManager setInstance = SettingManager.getSettingManager(context); mUsername = setInstance.getCurrentUserInfo().strUsrName; }