List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TASK
int FLAG_ACTIVITY_CLEAR_TASK
To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_TASK.
Click Source Link
From source file:com.oakesville.mythling.MediaActivity.java
public void goMainActivity() { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);/* w w w . j a v a 2 s. c o m*/ }
From source file:com.tct.mail.compose.ComposeActivity.java
private static void launch(Context context, Account account, Message message, int action, String toAddress, String body, String quotedText, String subject, final ContentValues extraValues) { //TS: xujian 2015-06-23 EMAIL BUGFIX_1015657 MOD_S if (message != null && message.bodyHtml != null && message.bodyHtml.length() > 1024 * 5) { message.bodyHtml = ""; LogUtils.d("Email", "test---launch---bodyHtml set to empty"); }// w ww . j a v a2 s . c o m if (message != null && message.bodyText != null && message.bodyText.length() > 1024 * 5) { message.bodyText = ""; LogUtils.d("Email", "test---launch---bodyText set to empty"); } //TS: xujian 2015-06-23 EMAIL BUGFIX_1015657 MOD_E //Note: intent can not take too much extra data, so not take these two string in extra data. if (message != null) { message.bodyHtmlLinkify = ""; message.bodyTextLinkify = ""; } Intent intent = new Intent(ACTION_LAUNCH_COMPOSE); intent.setPackage(context.getPackageName()); intent.putExtra(EXTRA_FROM_EMAIL_TASK, true); intent.putExtra(EXTRA_ACTION, action); intent.putExtra(Utils.EXTRA_ACCOUNT, account); if (action == EDIT_DRAFT) { intent.putExtra(ORIGINAL_DRAFT_MESSAGE, message); } else { intent.putExtra(EXTRA_IN_REFERENCE_TO_MESSAGE, message); } if (message != null) { LogUtils.d("Email", String.format("test---launch---action=%d messageId=%d conversationUri=%s uri=%s subject=%s", action, message.id, message.conversationUri, message.uri, message.subject)); } //TS: wenggangjin 2015-01-06 EMAIL BUGFIX_882161 MOD_S // if(message != null && message.bodyHtml != null && message.bodyHtml.length() > 1024*10){ // message.bodyHtml = ""; // Log.d("Email","test---launch---bodyHtml set to empty"); // } //TS: wenggangjin 2015-01-06 EMAIL BUGFIX_882161 MOD_E if (toAddress != null) { intent.putExtra(EXTRA_TO, toAddress); } if (body != null) { intent.putExtra(EXTRA_BODY, body); } if (quotedText != null) { intent.putExtra(EXTRA_QUOTED_TEXT, quotedText); } if (subject != null) { intent.putExtra(EXTRA_SUBJECT, subject); } if (extraValues != null) { LogUtils.d(LOG_TAG, "Launching with extraValues: %s", extraValues.toString()); intent.putExtra(EXTRA_VALUES, extraValues); } if (action == COMPOSE) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); } else if (message != null) { //TS: jin.dong 2015-10-19 EMAIL BUGFIX_1100033 ADD_S if (message.uri == null) { LogUtils.e(LOG_TAG, "what ? message's uri is null? want launch ComposeActivity ? do nothing is the right thing!!!"); return; } //TS: jin.dong 2015-10-19 EMAIL BUGFIX_1100033 ADD_E //TS: yanhua.chen 2016-03-31 EMAIL BUGFIX_1877378 ADD_S intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); //TS: yanhua.chen 2016-03-31 EMAIL BUGFIX_1877378 ADD_E intent.setData(Utils.normalizeUri(message.uri)); } // TS: xiaolin.li 2015-01-29 EMAIL BUGFIX-917401 ADD_S //context.startActivity(intent); try { context.startActivity(intent); } catch (Exception e) { LogUtils.e(LOG_TAG, "Launch compose activity err."); } // TS: xiaolin.li 2015-01-29 EMAIL BUGFIX-917401 ADD_E }
From source file:org.anurag.file.quest.FileQuestHD.java
/** * this function checks for update for File Quest * and makes a notification to download link * in playstore.... /*from www . j a v a 2 s . c o m*/ */ private void update_checker() { // TODO Auto-generated method stub Toast.makeText(FileQuestHD.this, R.string.checking_update, Toast.LENGTH_SHORT).show(); final Handler hand = new Handler() { @Override public void handleMessage(Message msg) { // TODO Auto-generated method stub switch (msg.what) { case 1://update available.... { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(FileQuestHD.this); mBuilder.setSmallIcon(R.drawable.file_quest_icon); mBuilder.setContentTitle(getString(R.string.app_name)); mBuilder.setContentText(getString(R.string.update_avail)); mBuilder.setTicker(getString(R.string.update_avail)); Toast.makeText(FileQuestHD.this, R.string.update_avail, Toast.LENGTH_SHORT).show(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=org.anurag.file.quest")); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); PendingIntent pendint = PendingIntent.getActivity(FileQuestHD.this, 900, intent, 0); mBuilder.setContentIntent(pendint); mBuilder.setAutoCancel(true); NotificationManager notimgr = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notimgr.notify(1, mBuilder.build()); } break; case 2://no connectivity.... Toast.makeText(FileQuestHD.this, R.string.nointernet, Toast.LENGTH_SHORT).show(); break; case 3: //failed to check for update.... Toast.makeText(FileQuestHD.this, R.string.failed_to_check_for_update, Toast.LENGTH_SHORT) .show(); } } }; Thread th = new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub try { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); if (!info.isConnected()) { hand.sendEmptyMessage(2); return; } Scanner scan = new Scanner( new URL("https://www.dropbox.com/s/x1gp7a6ozdvg81g/FQ_UPDATE.txt?dl=1").openStream()); String update = scan.next(); if (!update.equalsIgnoreCase(getString(R.string.version))) hand.sendEmptyMessage(1); scan.close(); } catch (Exception e) { hand.sendEmptyMessage(3); } } }); th.start(); }
From source file:com.android.gallery3d.app.PhotoPage.java
@Override /// M: [BUG.MODIFY] @{ /* public void onSingleTapUp(int x, int y) {*/ public void onSingleTapConfirmed(int x, int y) { Log.i(TAG, "<onSingleTapConfirmed>"); /// @}//from w w w .j ava2s . com if (mAppBridge != null) { if (mAppBridge.onSingleTapUp(x, y)) return; } MediaItem item = mModel.getMediaItem(0); if (item == null || item == mScreenNailItem) { // item is not ready or it is camera preview, ignore return; } int supported = item.getSupportedOperations(); /// M: [BUG.MARK] play video in onSingleTapUp @{ /* boolean playVideo = ((supported & MediaItem.SUPPORT_PLAY) != 0); */ /// @} boolean unlock = ((supported & MediaItem.SUPPORT_UNLOCK) != 0); boolean goBack = ((supported & MediaItem.SUPPORT_BACK) != 0); boolean launchCamera = ((supported & MediaItem.SUPPORT_CAMERA_SHORTCUT) != 0); /// M: [BEHAVIOR.ADD] [Camera independent from Gallery] @{ // Play video from secure camera, go into key guard. if (mPlaySecureVideo) { unlock = true; } /// @} /// M: [BUG.MARK] play video in onSingleTapUp @{ /* if (playVideo) { // determine if the point is at center (1/6) of the photo view. // (The position of the "play" icon is at center (1/6) of the photo) int w = mPhotoView.getWidth(); int h = mPhotoView.getHeight(); playVideo = (Math.abs(x - w / 2) * 12 <= w) && (Math.abs(y - h / 2) * 12 <= h); } if (playVideo) { if (mSecureAlbum == null) { playVideo(mActivity, item.getPlayUri(), item.getName()); } else { mActivity.getStateManager().finishState(this); } } else */ /// @} if (goBack) { /// M: [BUG.ADD] [Camera independent from Gallery] @{ // Don't need show bars when back to camera preview onActionBarAllowed(false); /// @} onBackPressed(); } else if (unlock) { /// M: [BEHAVIOR.ADD] [Camera independent from Gallery] @{ mPlaySecureVideo = false; /// @} Intent intent = new Intent(mActivity, GalleryActivity.class); /// M: [BUG.ADD] secure camera come here, use new task @{ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); /// @} /// M: [BUG.MARK] @{ // In secure camera, user can not skip key guard /*intent.putExtra(GalleryActivity.KEY_DISMISS_KEYGUARD, true);*/ /// @} mActivity.startActivity(intent); } else if (launchCamera) { launchCamera(); } else { /// M: [BUG.MODIFY] @{ /*toggleBars();*/ // if we are starting video player, give up toggleBars() to avoid view junk if (!mIsStartingVideoPlayer) { toggleBars(); } /// @} } }
From source file:knayi.delevadriver.AvaliableJobDetailActivity.java
@Override public void onClick(View v) { Calendar calendar = Calendar.getInstance(); final long timestamp = System.currentTimeMillis(); final String token = sPref.getString(Config.TOKEN, null); switch (v.getId()) { /*case R.id.job_reject: /*w w w.j av a 2s . c o m*/ if(job_reject.getText().toString().equals("Reject")){ MaterialDialog dialog = new MaterialDialog.Builder(this) .title("Rejecting") .titleColor(R.color.white) .customView(R.layout.reject_layout, true) .positiveText("REJECT") .positiveColor(R.color.white) .positiveColorRes(R.color.white) .negativeText("CANCEL") .negativeColorRes(R.color.white) .backgroundColorRes(R.color.primary) .typeface("ciclefina", "ciclegordita") .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(final MaterialDialog dialog) { super.onPositive(dialog); EditText et_message = (EditText) dialog.findViewById(R.id.reject_message); if(!et_message.getText().toString().equals("")){ AvaliableJobsAPI.getInstance().getService().rejectJob(jobitem.get_id(), token, et_message.getText().toString(), "true", new Callback<String>() { @Override public void success(String s, Response response) { Toast.makeText(AvaliableJobDetailActivity.this, "Job is successfully rejected", Toast.LENGTH_SHORT).show(); dialog.dismiss(); //remove job id that is saved to use in locatin update sPref.edit().putString(Config.TOKEN_JOBID, null).commit(); sPref.edit().putString(Config.TOKEN_DELAY, null).commit(); //check report service is alive //if alive stop service if(sPref.getBoolean(Config.TOKEN_SERVICE_ALIVE, false)){ Intent intentservice = new Intent(AvaliableJobDetailActivity.this, BackgroundLocationService.class); stopService(intentservice); } Intent intent = new Intent(AvaliableJobDetailActivity.this, DrawerMainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); finish(); } @Override public void failure(RetrofitError error) { if (error.getBody() == null) { Toast.makeText(AvaliableJobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT).show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err").getString("message"); Toast.makeText(AvaliableJobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } dialog.dismiss(); } }); }else{ Toast.makeText(AvaliableJobDetailActivity.this, "Please enter your message", Toast.LENGTH_SHORT).show(); } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); dialog.dismiss(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } ) .build(); dialog.show(); EditText et_message = (EditText) dialog.findViewById(R.id.reject_message); et_message.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); } *//*else{ final Dialog msgDialog = new Dialog(AvaliableJobDetailActivity.this); msgDialog.setTitle("Why do u reject?"); msgDialog.setCancelable(true); msgDialog.setContentView(R.layout.custom_dialog_reason); final EditText message = (EditText) msgDialog.findViewById(R.id.messagebox); Button submit = (Button) msgDialog.findViewById(R.id.submitbutton); msgDialog.show(); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); if(message.getText().toString().equals("") && message.getText().toString().equals(null)){ Toast.makeText(getApplicationContext(), "Please input message to submit", Toast.LENGTH_SHORT).show(); }else{ msgDialog.dismiss(); progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); if(token == null){ new SweetAlertDialog(AvaliableJobDetailActivity.this, SweetAlertDialog.WARNING_TYPE) .setTitleText("") .setContentText("Please Login again!") .show(); finish(); startActivity(new Intent(AvaliableJobDetailActivity.this, LoginActivity.class)); } else{ AvaliableJobsAPI.getInstance().getService().rejectJob(jobitem.get_id(), token, location, String.valueOf(timestamp), message.getText().toString(), new Callback<String>() { @Override public void success(String s, Response response) { progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); startActivity(new Intent(AvaliableJobDetailActivity.this, TabMainActivity.class)); finish(); } @Override public void failure(RetrofitError error) { progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); Toast.makeText(getApplicationContext(), "Something Went Wrong!", Toast.LENGTH_SHORT).show(); } }); } } } }); }*//* break;*/ case R.id.job_bid: progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); if (token == null) { MaterialDialog dialog = new MaterialDialog.Builder(this).positiveText("OK") .customView(R.layout.custom_message_dialog, false).positiveColor(R.color.white) .positiveColorRes(R.color.white).backgroundColorRes(R.color.primary) .typeface("ciclefina.ttf", "ciclegordita.ttf").build(); dialog.show(); TextView txt_title = (TextView) dialog.findViewById(R.id.dialog_title); TextView txt_message = (TextView) dialog.findViewById(R.id.dialog_message); txt_title.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); txt_message.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); txt_title.setText("Please Login again!"); txt_message.setText("Server doesn't know this account!"); Intent intent = new Intent(AvaliableJobDetailActivity.this, LoginActivity.class); startActivity(intent); finish(); } if (job_bid.getText().toString().equals("Bid")) { final long ts1 = System.currentTimeMillis(); Location mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); if (mLastLocation != null) { location = mLastLocation.getLongitude() + "," + mLastLocation.getLatitude(); } acceptJob(token, String.valueOf(ts1), ""); /*MaterialDialog dialog = new MaterialDialog.Builder(this) .title("Estimate time of arrival to pick up point") .customView(R.layout.estimatetime_layout, true) .positiveText("BID") .positiveColor(R.color.primary) .positiveColorRes(R.color.primary) .negativeText("CANCEL") .negativeColorRes(R.color.primary) .cancelable(false) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); EditText et_estimatetime = (EditText) dialog.findViewById(R.id.estimatetime_et); if(!et_estimatetime.getText().toString().equals("")) { acceptJob(token, String.valueOf(ts1), et_estimatetime.getText().toString()); }else{ Toast.makeText(AvaliableJobDetailActivity.this, "Please Input Fields!", Toast.LENGTH_SHORT).show(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); dialog.dismiss(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } ) .build(); dialog.show(); final EditText et_estimatetime = (EditText) dialog.findViewById(R.id.estimatetime_et); et_estimatetime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Calendar mcurrentTime = Calendar.getInstance(); int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY); int minute = mcurrentTime.get(Calendar.MINUTE); TimePickerDialog mTimePicker; mTimePicker = new TimePickerDialog(AvaliableJobDetailActivity.this, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) { et_estimatetime.setText( selectedHour + ":" + selectedMinute); } }, hour, minute, true);//Yes 24 hour time mTimePicker.setTitle("Select Time"); mTimePicker.show(); } });*/ } else if (job_bid.getText().toString().equals("Agree")) { AvaliableJobsAPI.getInstance().getService().agreeJob(jobitem.get_id(), token, "true", new Callback<String>() { @Override public void success(String s, Response response) { Toast.makeText(AvaliableJobDetailActivity.this, "Success", Toast.LENGTH_SHORT) .show(); getDataFromServer(job_id); } @Override public void failure(RetrofitError error) { if (error.getBody() == null) { Toast.makeText(AvaliableJobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT).show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err").getString("message"); Toast.makeText(AvaliableJobDetailActivity.this, errcode, Toast.LENGTH_SHORT) .show(); } catch (JSONException e) { e.printStackTrace(); } } } }); } /*else if(job_bid.getText().toString().equals("Finished")){ MaterialDialog dialog = new MaterialDialog.Builder(this) .title("Secret Code") .customView(R.layout.custom_request_message_dialog, true) .positiveText("SEND") .positiveColor(R.color.primary) .positiveColorRes(R.color.primary) .negativeText("CANCEL") .negativeColorRes(R.color.primary) .typeface("ciclefina", "ciclegordita") .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); EditText request_secret_code = (EditText) dialog.findViewById(R.id.request_secret_code); EditText request_msg = (EditText) dialog.findViewById(R.id.request_msg); if (request_secret_code != null) { if (request_secret_code.getText().toString() != null && request_secret_code.getText().toString() != "") { Location mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); Long tsLong = System.currentTimeMillis(); String ts = tsLong.toString(); String location = "96,16"; if (mLastLocation != null) { location = mLastLocation.getLongitude() + "," + mLastLocation.getLatitude(); } final long timestamp = System.currentTimeMillis(); JSONObject obj = new JSONObject(); try { obj.put("location", location); obj.put("timestamp", String.valueOf(timestamp)); obj.put("secret_code", request_secret_code.getText().toString()); obj.put("message", request_msg.getText().toString()); } catch (JSONException e) { e.printStackTrace(); } String json = obj.toString(); try { TypedInput in = new TypedByteArray("application/json", json.getBytes("UTF-8")); progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); AvaliableJobsAPI.getInstance().getService().jobDone(jobitem.get_id(), token, in, new Callback<String>() { @Override public void success(String s, Response response) { Toast.makeText(AvaliableJobDetailActivity.this, "Message is sent successfully", Toast.LENGTH_SHORT).show(); sPref.edit().putString(Config.TOKEN_DELAY, null).commit(); if(sPref.getBoolean(Config.TOKEN_SERVICE_ALIVE, false)){ Intent intentservice = new Intent(AvaliableJobDetailActivity.this, BackgroundLocationService.class); stopService(intentservice); } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); bitLayout.setVisibility(View.GONE); } @Override public void failure(RetrofitError error) { //Toast.makeText(AvaliableJobDetailActivity.this, "Failed, Please Try Again!", Toast.LENGTH_SHORT).show(); if (error.getBody() == null) { Toast.makeText(AvaliableJobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT).show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err").getString("message"); Toast.makeText(AvaliableJobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } }); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); dialog.dismiss(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } ) .build(); dialog.show(); EditText request_secret_code = (EditText) dialog.findViewById(R.id.request_secret_code); EditText request_msg = (EditText) dialog.findViewById(R.id.request_msg); request_secret_code.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); request_msg.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); } break;*/ /*case R.id.job_report: isFirstDialog = true; totalprice = Double.parseDouble(jobitem.get_price()); final MaterialDialog dialog = new MaterialDialog.Builder(this) .title("Reporting") .customView(R.layout.report_layout, true) .positiveText("REPORT") .positiveColor(R.color.primary) .positiveColorRes(R.color.primary) .negativeText("CANCEL") .negativeColorRes(R.color.primary) .typeface("ciclefina", "ciclegordita") .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(final MaterialDialog dialog) { super.onPositive(dialog); CheckBox cb_weight = (CheckBox) dialog.findViewById(R.id.report_cb_overweight); CheckBox cb_express = (CheckBox) dialog.findViewById(R.id.report_cb_express); CheckBox cb_refrig = (CheckBox) dialog.findViewById(R.id.report_cb_refrigerated); //CheckBox cb_type = (CheckBox) dialog.findViewById(R.id.report_cb_type); final Spinner sp_weight = (Spinner) dialog.findViewById(R.id.report_spinner_overweight); //final Spinner sp_type = (Spinner) dialog.findViewById(R.id.report_spinner_type); EditText et_message = (EditText) dialog.findViewById(R.id.report_et_message); //Refrage if(!et_message.getText().toString().equals("") && et_message.getText().toString() != null) { if (cb_weight.isChecked() || cb_express.isChecked() || cb_refrig.isChecked()) { String message = "";//et_message.getText().toString(); if(cb_express.isChecked()){ message += "true,"; }else{ message += "false,"; } if(cb_refrig.isChecked()){ message += "true,"; }else{ message += "false,"; } if (cb_weight.isChecked()) { message += weightlist.get(sp_weight.getSelectedItemPosition()) + ","; }else{ message += ","; } AvaliableJobsAPI.getInstance().getService().reportJob(jobitem.get_id(), token, message, "0", new Callback<String>() { @Override public void success(String s, Response response) { Toast.makeText(AvaliableJobDetailActivity.this, "Your report has successfully sent", Toast.LENGTH_SHORT).show(); dialog.dismiss(); } @Override public void failure(RetrofitError error) { //Toast.makeText(AvaliableJobDetailActivity.this, "Report is Failed", Toast.LENGTH_SHORT).show(); if (error.getBody() == null) { Toast.makeText(AvaliableJobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT).show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err").getString("message"); Toast.makeText(AvaliableJobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } dialog.dismiss(); } }); } else { Toast.makeText(AvaliableJobDetailActivity.this, "Please select report reason", Toast.LENGTH_SHORT).show(); } }else{ Toast.makeText(AvaliableJobDetailActivity.this, "Please enter your message", Toast.LENGTH_SHORT).show(); } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); dialog.dismiss(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } ) .build(); dialog.show(); */ /* TextView tv_pricecategory = (TextView) dialog.findViewById(R.id.to_pricecategory); tv_pricecategory.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(dialog.getContext(), PriceCategoryActivity.class)); } });*//* final CheckBox cb_weight = (CheckBox) dialog.findViewById(R.id.report_cb_overweight); //final CheckBox cb_type = (CheckBox) dialog.findViewById(R.id.report_cb_type); CheckBox cb_express = (CheckBox) dialog.findViewById(R.id.report_cb_express); CheckBox cb_refrig = (CheckBox) dialog.findViewById(R.id.report_cb_refrigerated); EditText et_message = (EditText) dialog.findViewById(R.id.report_et_message); cb_weight.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); cb_express.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); cb_refrig.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); et_message.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); if(typepos == 1){ cb_express.setChecked(true); } if(typepos == 2){ cb_refrig.setChecked(true); } //final TextView tv_price = (TextView) dialog.findViewById(R.id.report_price_tag); final Spinner sp_weight = (Spinner) dialog.findViewById(R.id.report_spinner_overweight); //final Spinner sp_type = (Spinner) dialog.findViewById(R.id.report_spinner_type); sp_weight.setEnabled(false); //sp_type.setEnabled(false); //tv_price.setText("price " + jobitem.get_price()); sp_weight.setAdapter(new ArrayAdapter<String>(AvaliableJobDetailActivity.this, android.R.layout.simple_spinner_dropdown_item, weightshowlist)); //sp_type.setAdapter(new ArrayAdapter<String>(AvaliableJobDetailActivity.this, android.R.layout.simple_spinner_dropdown_item, new String[]{"Other", "Express", "Refrigerated"})); sp_weight.setSelection(weightpos); //sp_type.setSelection(typepos); sp_weight.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (!isFirstDialog){ totalprice += weightPricelist.get(sp_weight.getSelectedItemPosition()); }else{ isFirstDialog = false; } *//*if(cb_type.isChecked()){ totalprice += typepricelist.get(position); }*//* // tv_price.setText("price " + String.valueOf(totalprice)); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); *//*sp_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { totalprice = Double.parseDouble(jobitem.get_price()); if (!isFirstDialog) { totalprice += typepricelist.get(position); } else { isFirstDialog = false; } if (cb_weight.isChecked()) { totalprice += weightPricelist.get(sp_weight.getSelectedItemPosition()); } tv_price.setText("price " + String.valueOf(totalprice)); } @Override public void onNothingSelected(AdapterView<?> parent) { } });*//* cb_weight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked){ sp_weight.setEnabled(true); totalprice += weightPricelist.get(sp_weight.getSelectedItemPosition()); }else{ sp_weight.setEnabled(false); totalprice -= weightPricelist.get(sp_weight.getSelectedItemPosition()); } //tv_price.setText("price " + String.valueOf(totalprice)); } }); *//*cb_type.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked){ sp_type.setEnabled(true); totalprice += typepricelist.get(sp_type.getSelectedItemPosition()); }else{ sp_type.setEnabled(false); totalprice -= typepricelist.get(sp_type.getSelectedItemPosition()); } tv_price.setText("price " + String.valueOf(totalprice)); } });*//* break;*/ default: Intent intent = new Intent(AvaliableJobDetailActivity.this, DrawerMainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); finish(); break; } }
From source file:knayi.delevadriver.JobDetailActivity.java
public void acceptJob(String token, String ts1, String time) { AvaliableJobsAPI.getInstance().getService().acceptJob(jobitem.get_id(), token, location, ts1, time, new Callback<String>() { @Override/* w ww. jav a 2s .co m*/ public void success(String s, Response response) { progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); currentlyTracking(); //startAlarmManager(); Toast.makeText(getApplicationContext(), "Your job is successfully bid.", Toast.LENGTH_SHORT) .show(); sPref.edit().putString(Config.TOKEN_JOBID, jobitem.get_id()).commit(); Intent intentservice = new Intent(JobDetailActivity.this, BackgroundLocationService.class); startService(intentservice); Intent intent = new Intent(JobDetailActivity.this, DrawerMainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); finish(); } @Override public void failure(RetrofitError error) { progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); if (error.getBody() == null) { Toast.makeText(JobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT) .show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err").getString("message"); Toast.makeText(JobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } } }); }
From source file:knayi.delevadriver.AvaliableJobDetailActivity.java
public void acceptJob(String token, String ts1, String time) { AvaliableJobsAPI.getInstance().getService().acceptJob(jobitem.get_id(), token, location, ts1, time, new Callback<String>() { @Override/*from w ww. jav a2 s . c o m*/ public void success(String s, Response response) { progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); currentlyTracking(); //startAlarmManager(); Toast.makeText(getApplicationContext(), "Your job is successfully bid.", Toast.LENGTH_SHORT) .show(); sPref.edit().putString(Config.TOKEN_JOBID, jobitem.get_id()).commit(); Intent intentservice = new Intent(AvaliableJobDetailActivity.this, BackgroundLocationService.class); startService(intentservice); Intent intent = new Intent(AvaliableJobDetailActivity.this, DrawerMainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); finish(); } @Override public void failure(RetrofitError error) { progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); if (error.getBody() == null) { Toast.makeText(AvaliableJobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT).show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err").getString("message"); Toast.makeText(AvaliableJobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } } }); }
From source file:com.android.mail.compose.ComposeActivity.java
/** * Carries out the "up" action in the action bar. *//*from w w w .ja v a 2s .c o m*/ private void onAppUpPressed() { if (mLaunchedFromEmail) { // If this was started from Gmail, simply treat app up as the system back button, so // that the last view is restored. onBackPressed(); return; } // Fire the main activity to ensure it launches the "top" screen of mail. // Since the main Activity is singleTask, it should revive that task if it was already // started. final Intent mailIntent = Utils.createViewInboxIntent(mAccount); mailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME); startActivity(mailIntent); finish(); }