List of usage examples for android.content Intent getSerializableExtra
public Serializable getSerializableExtra(String name)
From source file:com.aegiswallet.actions.MainActivity.java
private void setupBlockchainBroadcastReceiver(final TextView blockchainStatus) { receiver = new BroadcastReceiver() { @Override/*w ww. j a va 2 s . co m*/ public void onReceive(Context context, Intent intent) { int download = intent.getIntExtra(PeerBlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD, PeerBlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_OK); Date bestChainDate = (Date) intent .getSerializableExtra(PeerBlockchainService.ACTION_BLOCKCHAIN_STATE_BEST_CHAIN_DATE); long blockchainLag = System.currentTimeMillis() - bestChainDate.getTime(); boolean blockchainUptodate = blockchainLag < Constants.BLOCKCHAIN_UPTODATE_THRESHOLD_MS; boolean downloadOk = download == PeerBlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_OK; String downloading = downloadOk ? getString(R.string.synchronizing_network) : getString(R.string.sync_stalled); Date currentDate = new Date(); long daysOutOfDate = TimeUnit.MILLISECONDS.toDays(currentDate.getTime() - bestChainDate.getTime()) + 1; if (!blockchainUptodate) { blockchainStatus.setText( downloading + " " + daysOutOfDate + " " + getString(R.string.sync_days_behind)); blockchainStatus.setTextColor(getResources().getColor(R.color.custom_red)); } else { blockchainStatus.setText(getString(R.string.sync_completed)); blockchainStatus.setTextColor(getResources().getColor(R.color.custom_green)); } updateMainViews(); } }; }
From source file:com.androidquery.simplefeed.activity.PostActivity.java
private void failed() { Intent intent = new Intent(this, PostActivity.class); intent.putExtra("photo", photo); intent.putExtra("message", getMessage()); intent.putExtra("entity", entity); intent.putExtra("item", item); AQUtility.debug("failed input", photo + ":" + getMessage()); AQUtility.debug("failed input2", intent.getSerializableExtra("photo") + ":" + intent.getStringExtra("message")); String failed = getString(R.string.upload_failed); notify(failed, getString(R.string.photo_upload), failed, intent); }
From source file:io.barracks.ota.client.helper.PackageDownloadHelper.java
/** * {@inheritDoc}/*from w ww . j av a2 s . c om*/ */ @Override public void onReceive(Context context, Intent intent) { switch (intent.getAction()) { case PackageDownloadService.ACTION_DOWNLOAD_PACKAGE: if (callback.hashCode() == intent.getIntExtra(UpdateCheckService.EXTRA_CALLBACK, 0)) { if (intent.hasCategory(PackageDownloadService.DOWNLOAD_PROGRESS)) { callback.onDownloadProgress( intent.<UpdateDetails>getParcelableExtra(PackageDownloadService.EXTRA_UPDATE_DETAILS), intent.getIntExtra(PackageDownloadService.EXTRA_PROGRESS, 0)); } else if (intent.hasCategory(PackageDownloadService.DOWNLOAD_SUCCESS)) { callback.onDownloadSuccess( intent.<UpdateDetails>getParcelableExtra(PackageDownloadService.EXTRA_UPDATE_DETAILS), intent.getStringExtra(PackageDownloadService.EXTRA_FINAL_DEST)); } else if (intent.hasCategory(PackageDownloadService.DOWNLOAD_ERROR)) { callback.onDownloadFailure( intent.<UpdateDetails>getParcelableExtra(PackageDownloadService.EXTRA_UPDATE_DETAILS), (Throwable) intent.getSerializableExtra(PackageDownloadService.EXTRA_EXCEPTION)); } } break; } }
From source file:com.chatwing.whitelabel.LegacyLoginActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE_SIGN_IN_GOOGLE_PLUS || requestCode == REQUEST_CODE_GET_GOOGLE_PLAY_SERVICES) { // Google+ resolve error if (resultCode == Activity.RESULT_OK && !mGoogleApiClient.isConnected() && !mGoogleApiClient.isConnecting()) { mConnectionResult = null;// w w w .j av a 2s. c o m connectPlusClient(); } else { mProgressViewsManager.showProgress(false); } } else if (requestCode == REQUEST_CODE_USER_RECOVERABLE_AUTH) { if (resultCode == RESULT_OK) { connectPlusClient(); } else { mProgressViewsManager.showProgress(false); } } else if (requestCode == REQUEST_CODE_AUTHENTICATE && resultCode == RESULT_OK) { checkUser((User) data.getSerializableExtra(AuthenticateActivity.INTENT_USER)); } }
From source file:com.sft.fragment.SchoolsFragment.java
@Override public void onActivityResult(int requestCode, final int resultCode, final Intent data) { if (data != null) { if (resultCode == R.id.base_left_btn) { SchoolVO school = (SchoolVO) data.getSerializableExtra("school"); if (app.userVO != null && app.userVO.getApplystate().equals(EnrollResult.SUBJECT_NONE.getValue()) && school != null) { int position = adapter.getData().indexOf(school); adapter.setSelected(position); adapter.notifyDataSetChanged(); }/*w w w.j a v a 2 s. c o m*/ return; } LogUtil.print("schoolsss-->"); if (isFromMenu) { data.setClass(getActivity(), ApplyActivity.class); data.putExtra("isFromMenu", isFromMenu); startActivity(data); } new MyHandler(200) { @Override public void run() { getActivity().setResult(resultCode, data); getActivity().finish(); } }; } }
From source file:com.housekeeper.ar.healthhousekeeper.RegisterActivity.java
@SuppressWarnings("unchecked") @Override//from w w w . j a v a 2 s . c om public void onActivityResult(int requestCode, int resultCode, Intent data) { // super.onActivityResult(requestCode, resultCode, data); if (resultCode == -1) { selectedPicture = (ArrayList<String>) data .getSerializableExtra(SelectPictureActivity.INTENT_SELECTED_PICTURE); Log.i(TAG, "SelectedPicture:" + selectedPicture.toString()); if (selectedPicture.size() > 0) { //?? for (int i = 0; i < 1; i++) { Bitmap bitmap = PhotoUtils.getimage(selectedPicture.get(i)); File file = null; JSONObject joRev = new JSONObject(); httpUrl = http + upload_pic_url; Log.i(TAG, "post reg image url:" + httpUrl); if (PhotoUtils.saveBitmap2file(bitmap)) { file = new File(Environment.getExternalStorageDirectory(), IMAGE_FILE_NAME); joRev = HttpUtil.postImage(file, httpUrl); Log.i(TAG, "post image:" + joRev.toString()); try { if (joRev.getLong("result") == 200) { String returnAddr = joRev.getString("value"); switch (picKind) { case 0: //? Bitmap head_bitmap = bitmap; photo.setImageBitmap(head_bitmap); photoAddr = returnAddr; break; case 1: break; // case 2: // zyysAddr = returnAddr; // break; // case 3: // yszcAddr = returnAddr; // break; // case 4: // zcpsAddr = returnAddr; // break; } } } catch (JSONException e) { e.printStackTrace(); } } } } } }
From source file:com.undatech.opaque.RemoteCanvasActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // TODO: Implement left-icon //requestWindowFeature(Window.FEATURE_LEFT_ICON); //setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.icon); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); handler = new Handler(); setContentView(R.layout.canvas);/*from ww w.j a va2s. c o m*/ canvas = (RemoteCanvas) findViewById(R.id.canvas); Intent i = getIntent(); String vvFileName = startSessionFromVvFile(i); if (vvFileName == null) { android.util.Log.d(TAG, "Initializing session from connection settings."); connection = (ConnectionSettings) i.getSerializableExtra("com.undatech.opaque.ConnectionSettings"); canvas.initialize(connection); } else { canvas.initialize(vvFileName, connection); } canvas.setOnKeyListener(this); canvas.setFocusableInTouchMode(true); canvas.setDrawingCacheEnabled(false); // If rotation is disabled, fix the orientation to the current one. if (!connection.isRotationEnabled()) { int orientation = getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } // This code detects when the soft keyboard is up and sets an appropriate visibleHeight in the canvas. // When the keyboard is gone, it resets visibleHeight and pans zero distance to prevent us from being // below the desktop image (if we scrolled all the way down when the keyboard was up). // TODO: Move this into a separate thread, and post the visibility changes to the handler. // to avoid occupying the UI thread with this. final View rootView = ((ViewGroup) findViewById(android.R.id.content)).getChildAt(0); rootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { Rect r = new Rect(); rootView.getWindowVisibleDisplayFrame(r); // To avoid setting the visible height to a wrong value after an screen unlock event // (when r.bottom holds the width of the screen rather than the height due to a rotation) // we make sure r.top is zero (i.e. there is no notification bar and we are in full-screen mode) // It's a bit of a hack. if (r.top == 0) { if (canvas.myDrawable != null) { canvas.setVisibleDesktopHeight(r.bottom); canvas.relativePan(0, 0); } } // Enable/show the zoomer if the keyboard is gone, and disable/hide otherwise. // We detect the keyboard if more than 19% of the screen is covered. int offset = 0; int rootViewHeight = rootView.getHeight(); if (r.bottom > rootViewHeight * 0.81) { offset = rootViewHeight - r.bottom; // Soft Kbd gone, shift the meta keys and arrows down. if (layoutKeys != null) { layoutKeys.offsetTopAndBottom(offset); keyStow.offsetTopAndBottom(offset); if (prevBottomOffset != offset) { setExtraKeysVisibility(View.GONE, false); canvas.invalidate(); kbdIcon.enable(); } } } else { offset = r.bottom - rootViewHeight; // Soft Kbd up, shift the meta keys and arrows up. if (layoutKeys != null) { layoutKeys.offsetTopAndBottom(offset); keyStow.offsetTopAndBottom(offset); if (prevBottomOffset != offset) { setExtraKeysVisibility(View.VISIBLE, true); canvas.invalidate(); kbdIcon.hide(); kbdIcon.disable(); } } } setKeyStowDrawableAndVisibility(); prevBottomOffset = offset; } }); kbdIcon = (ZoomControls) findViewById(R.id.zoomer); kbdIcon.hide(); kbdIcon.setOnZoomKeyboardClickListener(new View.OnClickListener() { @Override public void onClick(View v) { InputMethodManager inputMgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); inputMgr.toggleSoftInput(0, 0); } }); // Initialize and define actions for on-screen keys. initializeOnScreenKeys(); myVibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); // Initialize map from XML IDs to input handlers. inputHandlerIdMap = new HashMap<Integer, InputHandler>(); inputHandlerIdMap.put(R.id.inputMethodDirectSwipePan, new InputHandlerDirectSwipePan(this, canvas, myVibrator)); inputHandlerIdMap.put(R.id.inputMethodDirectDragPan, new InputHandlerDirectDragPan(this, canvas, myVibrator)); inputHandlerIdMap.put(R.id.inputMethodTouchpad, new InputHandlerTouchpad(this, canvas, myVibrator)); inputHandlerIdMap.put(R.id.inputMethodSingleHanded, new InputHandlerSingleHanded(this, canvas, myVibrator)); android.util.Log.e(TAG, "connection.getInputMethod(): " + connection.getInputMethod()); inputHandler = idToInputHandler(connection.getInputMethod()); }
From source file:com.insthub.O2OMobile.Activity.C1_PublishOrderActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.c1_publish_order); mFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); File file = new File(newFileName()); if (file.exists()) { file.delete();//w ww .j a v a 2 s . c om } Intent intent = getIntent(); mServiceType = (SERVICE_TYPE) intent.getSerializableExtra(O2OMobileAppConst.SERVICE_TYPE); mDefaultReceiverId = intent.getIntExtra(DEFAULT_RECEIVER_ID, 0); service_list = intent.getStringExtra("service_list"); mBack = (ImageView) findViewById(R.id.top_view_back); mTitle = (TextView) findViewById(R.id.top_view_title); mBack.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub finish(); } }); mArrowImage = (ImageView) findViewById(R.id.top_view_arrow_image); mClose = (ImageView) findViewById(R.id.top_view_right_close); mTitleView = (LinearLayout) findViewById(R.id.top_view_title_view); mServiceTypeView = (FrameLayout) findViewById(R.id.c1_publish_order_service_type_view); mServiceTypeListview = (ListView) findViewById(R.id.c1_publish_order_service_type_list); mPrice = (EditText) findViewById(R.id.c1_publish_order_price); mTime = (TextView) findViewById(R.id.c1_publish_order_time); mLocation = (EditText) findViewById(R.id.c1_publish_order_location); mText = (EditText) findViewById(R.id.c1_publish_order_text); mVoice = (Button) findViewById(R.id.c1_publish_order_voice); mVoicePlay = (Button) findViewById(R.id.c1_publish_order_voicePlay); mVoiceReset = (ImageView) findViewById(R.id.c1_publish_order_voiceReset); mPublish = (Button) findViewById(R.id.c1_publish_order_publish); mVoiceView = (FrameLayout) findViewById(R.id.c1_publish_order_voice_view); mVoiceAnim = (ImageView) findViewById(R.id.c1_publish_order_voice_anim); mVoiceAnim.setImageResource(R.anim.voice_animation); mAnimationDrawable = (AnimationDrawable) mVoiceAnim.getDrawable(); mAnimationDrawable.setOneShot(false); mTitleView.setEnabled(false); mServiceTypeView.setOnClickListener(null); mServiceTypeListview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub if (mDefaultReceiverId == 0) { mTitle.setText(mHomeModel.publicServiceTypeList.get(position).title); mServiceTypeId = mHomeModel.publicServiceTypeList.get(position).id; mC1PublishOrderAdapter = new C1_PublishOrderAdapter(C1_PublishOrderActivity.this, mHomeModel.publicServiceTypeList, position); mServiceTypeListview.setAdapter(mC1PublishOrderAdapter); mClose.setVisibility(View.GONE); mArrowImage.setImageResource(R.drawable.b3_arrow_down); AnimationUtil.backAnimationFromBottom(mServiceTypeListview); Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); mServiceTypeView.setVisibility(View.GONE); } }; mHandler.sendEmptyMessageDelayed(0, 200); } else { mTitle.setText(mServiceTypeList.get(position).title); mServiceTypeId = mServiceTypeList.get(position).id; mC1PublishOrderAdapter = new C1_PublishOrderAdapter(C1_PublishOrderActivity.this, mServiceTypeList, position); mServiceTypeListview.setAdapter(mC1PublishOrderAdapter); mClose.setVisibility(View.GONE); mArrowImage.setImageResource(R.drawable.b3_arrow_down); AnimationUtil.backAnimationFromBottom(mServiceTypeListview); Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); mServiceTypeView.setVisibility(View.GONE); } }; mHandler.sendEmptyMessageDelayed(0, 200); } } }); mTitleView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (mServiceTypeView.getVisibility() == View.GONE) { mServiceTypeView.setVisibility(View.VISIBLE); mClose.setVisibility(View.VISIBLE); mArrowImage.setImageResource(R.drawable.b4_arrow_up); AnimationUtil.showAnimationFromTop(mServiceTypeListview); closeKeyBoard(); } else { mClose.setVisibility(View.GONE); mArrowImage.setImageResource(R.drawable.b3_arrow_down); AnimationUtil.backAnimationFromBottom(mServiceTypeListview); Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); mServiceTypeView.setVisibility(View.GONE); } }; mHandler.sendEmptyMessageDelayed(0, 200); } } }); mClose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub mClose.setVisibility(View.GONE); mArrowImage.setImageResource(R.drawable.b3_arrow_down); AnimationUtil.backAnimationFromBottom(mServiceTypeListview); Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); mServiceTypeView.setVisibility(View.GONE); } }; mHandler.sendEmptyMessageDelayed(0, 200); } }); mPrice.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub if (s.toString().length() > 0) { if (s.toString().substring(0, 1).equals(".")) { s = s.toString().substring(1, s.length()); mPrice.setText(s); } } if (s.toString().length() > 1) { if (s.toString().substring(0, 1).equals("0")) { if (!s.toString().substring(1, 2).equals(".")) { s = s.toString().substring(1, s.length()); mPrice.setText(s); CharSequence charSequencePirce = mPrice.getText(); if (charSequencePirce instanceof Spannable) { Spannable spanText = (Spannable) charSequencePirce; Selection.setSelection(spanText, charSequencePirce.length()); } } } } boolean flag = false; for (int i = 0; i < s.toString().length() - 1; i++) { String getstr = s.toString().substring(i, i + 1); if (getstr.equals(".")) { flag = true; break; } } if (flag) { int i = s.toString().indexOf("."); if (s.toString().length() - 3 > i) { String getstr = s.toString().substring(0, i + 3); mPrice.setText(getstr); CharSequence charSequencePirce = mPrice.getText(); if (charSequencePirce instanceof Spannable) { Spannable spanText = (Spannable) charSequencePirce; Selection.setSelection(spanText, charSequencePirce.length()); } } } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); initData(); mHomeModel = new HomeModel(this); mHomeModel.addResponseListener(this); if (mDefaultReceiverId == 0) { mShared = getSharedPreferences(O2OMobileAppConst.USERINFO, 0); mHomeData = mShared.getString("home_data", ""); if ("".equals(mHomeData)) { mHomeModel.getServiceTypeList(); } else { try { servicetypelistResponse response = new servicetypelistResponse(); response.fromJson(new JSONObject(mHomeData)); mHomeModel.publicServiceTypeList = response.services; setServiceTypeAdater(); } catch (JSONException e) { e.printStackTrace(); } } } else { if (service_list != null && !"".equals(service_list)) { try { JSONObject userJson = new JSONObject(service_list); myservicelistResponse response = new myservicelistResponse(); response.fromJson(userJson); for (int i = 0; i < response.services.size(); i++) { SERVICE_TYPE service = new SERVICE_TYPE(); service = response.services.get(i).service_type; mServiceTypeList.add(service); } if (mServiceTypeList.size() > 0) { mTitleView.setEnabled(true); mArrowImage.setVisibility(View.VISIBLE); if (mServiceType != null) { for (int i = 0; i < mServiceTypeList.size(); i++) { if (mServiceType.id == mServiceTypeList.get(i).id) { mC1PublishOrderAdapter = new C1_PublishOrderAdapter(this, mServiceTypeList, i); mServiceTypeListview.setAdapter(mC1PublishOrderAdapter); mTitle.setText(mServiceTypeList.get(i).title); mServiceTypeId = mServiceTypeList.get(i).id; break; } } } else { mC1PublishOrderAdapter = new C1_PublishOrderAdapter(this, mServiceTypeList); mServiceTypeListview.setAdapter(mC1PublishOrderAdapter); mTitle.setText(getString(R.string.select_service)); } } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { mShared = getSharedPreferences(O2OMobileAppConst.USERINFO, 0); mHomeData = mShared.getString("home_data", ""); if ("".equals(mHomeData)) { mHomeModel.getServiceTypeList(); } else { try { servicetypelistResponse response = new servicetypelistResponse(); response.fromJson(new JSONObject(mHomeData)); mHomeModel.publicServiceTypeList = response.services; setServiceTypeAdater(); } catch (JSONException e) { e.printStackTrace(); } } } } mLocationInfoModel = new LocationInfoModel(this); mLocationInfoModel.addResponseListener(this); mLocationInfoModel.get(); mOrderPublishModel = new OrderPublishModel(this); mOrderPublishModel.addResponseListener(this); //?? CharSequence charSequencePirce = mPrice.getText(); if (charSequencePirce instanceof Spannable) { Spannable spanText = (Spannable) charSequencePirce; Selection.setSelection(spanText, charSequencePirce.length()); } CharSequence charSequenceLocation = mLocation.getText(); if (charSequenceLocation instanceof Spannable) { Spannable spanText = (Spannable) charSequenceLocation; Selection.setSelection(spanText, charSequenceLocation.length()); } mVoice.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (event.getAction() == MotionEvent.ACTION_DOWN) { closeKeyBoard(); mVoice.setKeepScreenOn(true); mMaxTime = MAX_TIME; mVoiceView.setVisibility(View.VISIBLE); mAnimationDrawable.start(); startRecording(); } else if (event.getAction() == MotionEvent.ACTION_UP) { mVoice.setKeepScreenOn(false); mVoiceView.setVisibility(View.GONE); mAnimationDrawable.stop(); if (mMaxTime > 28) { mVoice.setEnabled(false); Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); stopRecording(); mVoice.setEnabled(true); } }; mHandler.sendEmptyMessageDelayed(0, 500); } else { stopRecording(); } } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { mVoice.setKeepScreenOn(false); mVoiceView.setVisibility(View.GONE); mAnimationDrawable.stop(); if (mMaxTime > 28) { mVoice.setEnabled(false); Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); stopRecording(); mVoice.setEnabled(true); } }; mHandler.sendEmptyMessageDelayed(0, 500); } else { stopRecording(); } } else if (event.getAction() == MotionEvent.ACTION_MOVE) { mVoice.getParent().requestDisallowInterceptTouchEvent(true); } return false; } }); mVoicePlay.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (mPlayer == null) { File file = new File(mFileName); if (file.exists()) { mPlayer = new MediaPlayer(); mVoicePlay.setBackgroundResource(R.anim.record_animation); mAnimationDrawable2 = (AnimationDrawable) mVoicePlay.getBackground(); mAnimationDrawable2.setOneShot(false); mAnimationDrawable2.start(); try { mPlayer.setDataSource(mFileName); mPlayer.prepare(); mPlayer.start(); mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { mp.reset(); mPlayer = null; mVoicePlay.setBackgroundResource(R.drawable.b5_play_btn); mAnimationDrawable2.stop(); } }); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { Toast.makeText(C1_PublishOrderActivity.this, getString(R.string.file_does_not_exist), Toast.LENGTH_SHORT).show(); } } else { mPlayer.release(); mPlayer = null; mVoicePlay.setBackgroundResource(R.drawable.b5_play_btn); mAnimationDrawable2.stop(); } } }); mVoiceReset.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (mPlayer != null) { mPlayer.release(); mPlayer = null; mVoicePlay.setBackgroundResource(R.drawable.b5_play_btn); mAnimationDrawable2.stop(); } File file = new File(mFileName); if (file.exists()) { file.delete(); } mVoice.setVisibility(View.VISIBLE); mVoicePlay.setVisibility(View.GONE); mVoiceReset.setVisibility(View.GONE); } }); mPublish.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub File file = new File(newFileName()); int duration = 0; if (file.exists()) { MediaPlayer mp = MediaPlayer.create(C1_PublishOrderActivity.this, Uri.parse(mFileName)); if (null != mp) { duration = mp.getDuration();//? ms mp.release(); } if (duration % 1000 > 500) { duration = duration / 1000 + 1; } else { duration = duration / 1000; } } else { file = null; } int num = 0; try { // ?? Date date = new Date(); Date date1 = mFormat.parse(mFormat.format(date)); Date date2 = mFormat.parse(mTime.getText().toString()); num = date2.compareTo(date1); if (num < 0) { long diff = date1.getTime() - date2.getTime(); long mins = diff / (1000 * 60); if (mins < 3) { num = 1; } } } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (mServiceTypeId == 0) { ToastView toast = new ToastView(C1_PublishOrderActivity.this, getString(R.string.select_service)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } else if (mPrice.getText().toString().equals("")) { ToastView toast = new ToastView(C1_PublishOrderActivity.this, getString(R.string.price_range)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } else if (mPrice.getText().toString().equals("0.")) { ToastView toast = new ToastView(C1_PublishOrderActivity.this, getString(R.string.right_price)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } else if (mTime.getText().toString().equals("")) { ToastView toast = new ToastView(C1_PublishOrderActivity.this, getString(R.string.appoint_time)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } else if (num < 0) { ToastView toast = new ToastView(C1_PublishOrderActivity.this, getString(R.string.wrong_appoint_time_hint)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } else if (mLocation.getText().toString().equals("")) { ToastView toast = new ToastView(C1_PublishOrderActivity.this, getString(R.string.appoint_location_hint)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } else { mOrderPublishModel.publish(mPrice.getText().toString(), mTime.getText().toString(), mLocation.getText().toString(), mText.getText().toString(), file, mServiceTypeId, mDefaultReceiverId, duration); } } }); }
From source file:com.inter.trade.ui.fragment.buylicensekey.BuyLicenseKeyPayConfirmFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); if (resultCode == 78) {// bank = (DefaultBankCardData) data.getSerializableExtra("bankcard"); // TODO ? bankno = bank.getBkcardno();/*w w w. j ava2s. c o m*/ switch (viewHandler.getCheckpay()) {// 1 2 ? 3? case 2: viewHandler.setCredit(bankno); isChooseBank = true; break; case 3: viewHandler.setDeposit(bankno); break; default: break; } } else {// ? // payResult(data); // if (data == null) { // return; // } // String bankid = data.getStringExtra(BankListActivity.BANK_ID); // String bankname = data.getStringExtra(BankListActivity.BANK_NAME); // if(null != bankname &&!"".equals(bankname)){ // isSelectedBank=true; // DaikuanActivity.mDaikuanData.sunMap.put(DaikuanData.fucardbank, bankname); // } // bank_name.setText(bankname); // // //? } }
From source file:com.cmput301w17t07.moody.CreateMoodActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_create_mood); UserController userController = new UserController(); userName = userController.readUsername(CreateMoodActivity.this).toString(); setUpMenuBar(this); location = null;// w w w.ja v a2 s . c o m date = new Date(); Intent intent = getIntent(); locationText = (TextView) findViewById(R.id.locationText); Description = (EditText) findViewById(R.id.Description); mImageView = (ImageView) findViewById(R.id.editImageView); //try to get picklocation, if it is equal to 1 that means, user just back from map not //other activities try { pickLocation = (int) intent.getExtras().getInt("pickLocation"); } catch (Exception e) { e.printStackTrace(); } if (pickLocation == 1) { tempMood = (Mood) intent.getSerializableExtra("editMood"); bitmap = (Bitmap) intent.getParcelableExtra("bitmapback"); latitude = tempMood.getLatitude(); longitude = tempMood.getLongitude(); address = tempMood.getDisplayLocation(); locationText.setText(address); Description.setText(tempMood.getMoodMessage()); mImageView.setImageBitmap(bitmap); date = tempMood.getDate(); displayAttributes(); } /** * Spinner dropdown logic taken from http://stackoverflow.com/questions/13377361/how-to-create-a-drop-down-list <br> * Author: Nicolas Tyler, 2013/07/15 8:47 <br> * taken by Xin Huang 2017/03/10 <br> */ //Spinner for emotion and socialsituatuion if (pickLocation == 0) { Spinner dropdown = (Spinner) findViewById(R.id.Emotion); String[] items = new String[] { "anger", "confusion", "disgust", "fear", "happiness", "sadness", "shame", "surprise" }; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, items); dropdown.setAdapter(adapter); dropdown.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { EmotionText = parent.getItemAtPosition(position).toString(); } @Override public void onNothingSelected(AdapterView<?> parent) { Toast.makeText(CreateMoodActivity.this, "Please pick a feeling!", Toast.LENGTH_SHORT).show(); } }); Spinner dropdown_SocialSituation = (Spinner) findViewById(R.id.SocialSituation); String[] item_SocialSituation = new String[] { "", "alone", "with one other person", "with two people", "with several people", "with a crowd" }; ArrayAdapter<String> adapter_SocialSituation = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, item_SocialSituation); dropdown_SocialSituation.setAdapter(adapter_SocialSituation); dropdown_SocialSituation.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { SocialSituation = parent.getItemAtPosition(position).toString(); TextView sizeView = (TextView) findViewById(R.id.SocialText); sizeView.setText(" " + SocialSituation); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); } ImageButton chooseButton = (ImageButton) findViewById(R.id.Camera); ImageButton locationButton = (ImageButton) findViewById(R.id.location); ImageButton PickerButton = (ImageButton) findViewById(R.id.Picker); //click on PickerButton, call the datetimePicker PickerButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { innit(); TimeDialog.show(); } }); chooseButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(intent, 1); } catch (Exception e) { Intent intent = new Intent(getApplicationContext(), CreateMoodActivity.class); startActivity(intent); } } }); chooseButton.setOnLongClickListener(new View.OnLongClickListener() { public boolean onLongClick(View view) { try { Intent intent = new Intent("android.intent.action.PICK"); intent.setType("image/*"); startActivityForResult(intent, 0); } catch (Exception e) { Intent intent = new Intent(getApplicationContext(), CreateMoodActivity.class); startActivity(intent); } return true; } }); locationButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); //check available tools List<String> locationList = locationManager.getProviders(true); if (locationList.contains(LocationManager.GPS_PROVIDER)) { provider = LocationManager.GPS_PROVIDER; } else if (locationList.contains(LocationManager.NETWORK_PROVIDER)) { provider = LocationManager.NETWORK_PROVIDER; } else { Toast.makeText(getApplicationContext(), "Please check application permissions", Toast.LENGTH_LONG).show(); } //check the permission if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling Toast.makeText(getApplicationContext(), "Get location failed, Please check the Permission", Toast.LENGTH_SHORT).show(); return; } location = locationManager.getLastKnownLocation(provider); if (location == null) { latitude = 0; longitude = 0; } else { latitude = location.getLatitude(); longitude = location.getLongitude(); } Geocoder gcd = new Geocoder(CreateMoodActivity.this, Locale.getDefault()); try { List<Address> addresses = gcd.getFromLocation(latitude, longitude, 1); if (addresses.size() > 0) address = " " + addresses.get(0).getFeatureName() + " " + addresses.get(0).getThoroughfare() + ", " + addresses.get(0).getLocality() + ", " + addresses.get(0).getAdminArea() + ", " + addresses.get(0).getCountryCode(); locationText.setText(address); } catch (Exception e) { e.printStackTrace(); } } }); //pass users' changes to map, will be passed back locationButton.setOnLongClickListener(new View.OnLongClickListener() { public boolean onLongClick(View view) { int fromCreate = 123; moodMessage_text = Description.getText().toString(); tempMood = new Mood(EmotionText, userName, moodMessage_text, latitude, longitude, null, SocialSituation, date, address); Intent editLocation = new Intent(CreateMoodActivity.this, EditLocation.class); editLocation.putExtra("EditMood", tempMood); editLocation.putExtra("fromCreate", fromCreate); editLocation.putExtra("bitmap", compress(bitmap)); startActivity(editLocation); return true; } }); Button submitButton = (Button) findViewById(R.id.button5); submitButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { moodMessage_text = Description.getText().toString(); MoodController moodController = new MoodController(); // --------------------------- achievements ------------------------------------- AchievementManager.initManager(CreateMoodActivity.this); AchievementController achievementController = new AchievementController(); achievements = achievementController.getAchievements(); achievements.moodCount += 1; achievementController.incrementMoodCounter(EmotionText); achievementController.saveAchievements(); // ------------------------------------------------------------------------------ if (location != null || pickLocation == 1) { //todo can remove these if/else statements that toast message too long. They could // be handled in the controller if (!MoodController.createMood(EmotionText, userName, moodMessage_text, latitude, longitude, bitmap, SocialSituation, date, address, CreateMoodActivity.this)) { Toast.makeText(CreateMoodActivity.this, "Mood message length is too long. Please try again.", Toast.LENGTH_SHORT).show(); } else { Intent intent = new Intent(CreateMoodActivity.this, TimelineActivity.class); startActivity(intent); finish(); } } else { if (!MoodController.createMood(EmotionText, userName, moodMessage_text, 0, 0, bitmap, SocialSituation, date, address, CreateMoodActivity.this)) { Toast.makeText(CreateMoodActivity.this, "Mood message length is too long. Please try again.", Toast.LENGTH_SHORT).show(); } else { Intent intent = new Intent(CreateMoodActivity.this, TimelineActivity.class); startActivity(intent); finish(); } } } }); }