List of usage examples for android.os Handler sendEmptyMessageDelayed
public final boolean sendEmptyMessageDelayed(int what, long delayMillis)
From source file:com.insthub.O2OMobile.Activity.D1_OrderActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.d1_order_listview); mBack = (ImageView) findViewById(R.id.top_view_back); mTitle = (TextView) findViewById(R.id.top_view_title); mRightText = (TextView) findViewById(R.id.top_view_right_text); mBack.setOnClickListener(new OnClickListener() { @Override/* www.jav a2 s. c om*/ public void onClick(View v) { // TODO Auto-generated method stub finish(); } }); mTitle.setText(getString(R.string.order_detail)); mRightText.setVisibility(View.VISIBLE); DisplayMetrics dm = getResources().getDisplayMetrics(); mWidthPixels = dm.widthPixels; Intent intent = getIntent(); mOrderId = intent.getIntExtra(ORDER_ID, 0); mHeaderView = LayoutInflater.from(this).inflate(R.layout.d1_order, null); mXListView = (XListView) findViewById(R.id.order_listview); mXListView.addHeaderView(mHeaderView); mXListView.setPullLoadEnable(false); mXListView.loadMoreHide(); mXListView.setRefreshTime(); mXListView.setXListViewListener(this, 1); mXListView.setAdapter(null); mOrderBtnCancel = (Button) findViewById(R.id.order_button_cancel); mOrderBtnOk = (Button) findViewById(R.id.order_button_ok); mOrderEmptyView = (ImageView) findViewById(R.id.order_empty_view); mOrderPlay = findViewById(R.id.order_play); mOrderPlayOrderView = (LinearLayout) findViewById(R.id.order_play_order_view); mOrderPlayOrderSn = (TextView) findViewById(R.id.order_play_order_sn); mOrderPlayOrderServiceType = (TextView) findViewById(R.id.order_play_order_service_type); mOrderPlayOrderLocation = (TextView) findViewById(R.id.order_play_order_location); mOrderPlayOrderPrice = (TextView) findViewById(R.id.order_play_order_price); mOrderPlayButtonView = (LinearLayout) findViewById(R.id.order_play_button_view); mOrderPlayOnline = (Button) findViewById(R.id.order_play_online); mOrderPlayOffline = (Button) findViewById(R.id.order_play_offline); mOrderPlayCancel = (Button) findViewById(R.id.order_play_cancel); mOrderEmployerAvatar = (RoundedWebImageView) mHeaderView.findViewById(R.id.order_employer_avatar); mOrderEmployerName = (TextView) mHeaderView.findViewById(R.id.order_employer_name); mOrderEmployerPhone = (ImageView) mHeaderView.findViewById(R.id.order_employer_phone); mOrderTime = (TextView) mHeaderView.findViewById(R.id.order_time); mOrderSn = (TextView) mHeaderView.findViewById(R.id.order_sn); mOrderServiceType = (TextView) mHeaderView.findViewById(R.id.order_service_type); mOrderAppointmentTime = (TextView) mHeaderView.findViewById(R.id.order_appointment_time); mOrderLocation = (TextView) mHeaderView.findViewById(R.id.order_location); mOrderPrice = (TextView) mHeaderView.findViewById(R.id.order_price); mOrderTransactionPriceView = (LinearLayout) mHeaderView.findViewById(R.id.order_transaction_price_view); mOrderTransactionPrice = (TextView) mHeaderView.findViewById(R.id.order_transaction_price); mOrderContentText = (TextView) mHeaderView.findViewById(R.id.order_content_text); mOrderContentVoiceView = (LinearLayout) mHeaderView.findViewById(R.id.order_content_voice_view); mOrderContentVoiceIcon = (ImageView) mHeaderView.findViewById(R.id.order_content_voice_icon); mOrderContentVoiceTime = (TextView) mHeaderView.findViewById(R.id.order_content_voice_time); mOrderStatusView = (LinearLayout) mHeaderView.findViewById(R.id.order_status_view); mOrderStatus = (TextView) mHeaderView.findViewById(R.id.order_status); mOrderStatusArrow = (ImageView) mHeaderView.findViewById(R.id.order_status_arrow); mOrderVisibleButtonView = mHeaderView.findViewById(R.id.order_visible_button_view); mOrderWaitView = (LinearLayout) mHeaderView.findViewById(R.id.order_wait_view); mOrderEmployeeCount = (TextView) mHeaderView.findViewById(R.id.order_employee_count); mOrderEmployeeView = (LinearLayout) mHeaderView.findViewById(R.id.order_employee_view); mOrderEmployeeAvatar = (RoundedWebImageView) mHeaderView.findViewById(R.id.order_employee_avatar); mOrderEmployeeName = (TextView) mHeaderView.findViewById(R.id.order_employee_name); mOrderEmployeePhone = (ImageView) mHeaderView.findViewById(R.id.order_employee_phone); mOrderCommentView = (LinearLayout) mHeaderView.findViewById(R.id.order_comment_view); mAcceptOrderTime = (TextView) mHeaderView.findViewById(R.id.accept_order_time); mRightText.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(D1_OrderActivity.this, G0_ReportActivity.class); intent.putExtra("orderId", mOrderId); startActivity(intent); } }); mOrderEmptyView.setOnClickListener(null); mOrderPlayOrderView.setOnClickListener(null); mOrderPlay.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub AnimationUtil.backAnimationFromBottom(mOrderPlayOrderView); mOrderPlayOrderView.setVisibility(View.GONE); AnimationUtil.backAnimation(mOrderPlayButtonView); mOrderPlayButtonView.setVisibility(View.GONE); Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); mOrderPlay.setVisibility(View.GONE); mOrderBtnCancel.setVisibility(View.VISIBLE); } }; mHandler.sendEmptyMessageDelayed(0, 200); } }); mOrderPlayOnline.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { payCode = ENUM_PAY_CODE.PAY_ONLINE; mOrderInfoModel.pay(mOrderId, ENUM_PAY_CODE.PAY_ONLINE.value()); } }); mOrderPlayOffline.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { payCode = ENUM_PAY_CODE.PAY_OFFLINE; mOrderInfoModel.pay(mOrderId, ENUM_PAY_CODE.PAY_OFFLINE.value()); } }); mOrderPlayCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub AnimationUtil.backAnimationFromBottom(mOrderPlayOrderView); mOrderPlayOrderView.setVisibility(View.GONE); AnimationUtil.backAnimation(mOrderPlayButtonView); mOrderPlayButtonView.setVisibility(View.GONE); Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); mOrderPlay.setVisibility(View.GONE); mOrderBtnCancel.setVisibility(View.VISIBLE); } }; mHandler.sendEmptyMessageDelayed(0, 200); } }); mOrderStatusView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(D1_OrderActivity.this, D2_OrderHistoryActivity.class); intent.putExtra("order_id", mOrderId); startActivity(intent); } }); mOrderInfoModel = new OrderInfoModel(this); mOrderInfoModel.addResponseListener(this); mOrderInfoModel.get(mOrderId); }
From source file:com.jtschohl.androidfirewall.MainActivity.java
/** * Clear logs// www. j a v a 2 s. co m */ private void clearLog() { final Resources res = getResources(); final ProgressDialog progress = ProgressDialog.show(this, res.getString(R.string.working), res.getString(R.string.please_wait), true); final Handler handler = new Handler() { public void handleMessage(Message msg) { try { progress.dismiss(); } catch (Exception ex) { } if (!Api.hasRootAccess(MainActivity.this, true)) return; if (Api.clearLog(MainActivity.this)) { Toast.makeText(MainActivity.this, R.string.log_cleared, Toast.LENGTH_SHORT).show(); } } }; handler.sendEmptyMessageDelayed(0, 100); }
From source file:com.jtschohl.androidfirewall.MainActivity.java
/** * Purge iptable rules, showing a visual indication *//*from w ww . java 2s . c o m*/ private void purgeRules() { final Resources res = getResources(); final ProgressDialog progress = ProgressDialog.show(this, res.getString(R.string.working), res.getString(R.string.deleting_rules), true); final Handler handler = new Handler() { public void handleMessage(Message msg) { try { progress.dismiss(); } catch (Exception ex) { } if (!Api.hasRootAccess(MainActivity.this, true)) return; if (Api.purgeIptables(MainActivity.this, true)) { Toast.makeText(MainActivity.this, R.string.rules_deleted, Toast.LENGTH_SHORT).show(); if (abs_menu != null) { final MenuItem item_onoff = abs_menu.findItem(R.id.enableipv4); final MenuItem item_apply = abs_menu.findItem(R.id.applyrules); item_apply.setTitle(R.string.saverules); item_onoff.setChecked(false); } } } }; handler.sendEmptyMessageDelayed(0, 100); }
From source file:com.jtschohl.androidfirewall.MainActivity.java
/** * Apply or save iptable rules, showing a visual indication *//*from w w w . j av a 2s .c om*/ private void applyOrSaveRules() { final Resources res = getResources(); final boolean enabled = Api.isEnabled(this); final ProgressDialog progress = ProgressDialog.show(this, res.getString(R.string.working), res.getString(enabled ? R.string.applying_rules : R.string.saving_rules), true); final Handler handler = new Handler() { public void handleMessage(Message msg) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); int i; try { progress.dismiss(); } catch (Exception ex) { } if (enabled) { Log.d(TAG, "Applying rules."); if (Api.hasRootAccess(MainActivity.this, true) && Api.applyIptablesRules(MainActivity.this, true)) { Toast.makeText(MainActivity.this, R.string.rules_applied, Toast.LENGTH_SHORT).show(); if (abs_menu != null) { final MenuItem item_onoff = abs_menu.findItem(R.id.enableipv4); final MenuItem item_apply = abs_menu.findItem(R.id.applyrules); item_apply.setTitle(R.string.applyrules); item_onoff.setChecked(true); } i = prefs.getInt("itemPosition", 0); if (i == 0) { saveDefaultProfile(); } if (i == 1) { saveProfile1(); } if (i == 2) { saveProfile2(); } if (i == 3) { saveProfile3(); } if (i == 4) { saveProfile4(); } if (i == 5) { saveProfile5(); } } else { Log.d(TAG, "Failed - Disabling firewall."); Api.setEnabled(MainActivity.this, false); if (abs_menu != null) { final MenuItem item_onoff = abs_menu.findItem(R.id.enableipv4); final MenuItem item_apply = abs_menu.findItem(R.id.applyrules); item_apply.setTitle(R.string.saverules); item_onoff.setChecked(false); } } } else { Log.d(TAG, "Saving rules."); Api.saveRules(MainActivity.this); Toast.makeText(MainActivity.this, R.string.rules_saved, Toast.LENGTH_SHORT).show(); i = prefs.getInt("itemPosition", 0); if (i == 0) { saveDefaultProfile(); } if (i == 1) { saveProfile1(); } if (i == 2) { saveProfile2(); } if (i == 3) { saveProfile3(); } if (i == 4) { saveProfile4(); } if (i == 5) { saveProfile5(); } } MainActivity.this.dirty = false; } }; handler.sendEmptyMessageDelayed(0, 100); }