List of usage examples for android.content Intent setClass
public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls)
From source file:com.haomee.chat.activity.ChatActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.chat_activity_chat); activityInstance = this; this.screen_width = ViewUtil.getScreenWidth(activityInstance); if (EMChat.getInstance().isLoggedIn()) { activityInstance = ChatActivity.this; this.screen_width = ViewUtil.getScreenWidth(activityInstance); initView();// w ww . j av a 2s.c o m setUpView(); initData(); } else { LiuLianApplication.getInstance().logout(); Intent intent = new Intent(); intent.setClass(this, LoginPageActivity.class); startActivity(intent); this.finish(); } /** * say hi */ if (getIntent().getBooleanExtra("is_from_hi", false)) { sendText("hi"); } getBadWords2();// ?? initLocaBadWords2();// ? /** * */ findViewById(R.id.more_emotions).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(ChatActivity.this, MoreEmotionsActivity.class); startActivity(intent); } }); download_receiver = new MyDownloadReceiver(); IntentFilter filter = new IntentFilter("MyReceiver_Emotion_download"); registerReceiver(download_receiver, filter); init_emotions_view(); is_first_load_emotions();// }
From source file:com.android.gallery3d.app.PhotoPage.java
private void launchTinyPlanet() { // Deep link into tiny planet MediaItem current = mModel.getMediaItem(0); Intent intent = new Intent(FilterShowActivity.TINY_PLANET_ACTION); intent.setClass(mActivity, FilterShowActivity.class); intent.setDataAndType(current.getContentUri(), current.getMimeType()) .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.putExtra(FilterShowActivity.LAUNCH_FULLSCREEN, mActivity.isFullscreen()); mActivity.startActivityForResult(intent, REQUEST_EDIT); overrideTransitionToEditor();/*ww w. j a v a 2 s.c o m*/ }
From source file:com.nononsenseapps.notepad.ActivityMain.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Pass the event to ActionBarDrawerToggle, if it returns // true, then it has handled the app icon touch event if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }//from w w w. j a v a 2 s. c om // Handle your other action bar items... int itemId = item.getItemId(); if (itemId == android.R.id.home) { if (showingEditor) { // Only true in portrait mode final View focusView = ActivityMain.this.getCurrentFocus(); if (inputManager != null && focusView != null) { inputManager.hideSoftInputFromWindow(focusView.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } // Should load the same list again // Try getting the list from the original intent final long listId = getListId(getIntent()); final Intent intent = new Intent().setAction(Intent.ACTION_VIEW).setClass(ActivityMain.this, ActivityMain_.class); if (listId > 0) { intent.setData(TaskList.getUri(listId)); } // Set the intent before, so we set the correct // action bar setIntent(intent); while (getSupportFragmentManager().popBackStackImmediate()) { // Need to pop the entire stack and then load } reverseAnimation = true; Log.d("nononsenseapps fragment", "starting activity"); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } // else // Handled by drawer return true; } else if (itemId == R.id.drawer_menu_createlist) { // Show fragment DialogEditList_ dialog = DialogEditList_.getInstance(); dialog.setListener(new EditListDialogListener() { @Override public void onFinishEditDialog(long id) { openList(id); } }); dialog.show(getSupportFragmentManager(), "fragment_create_list"); return true; } else if (itemId == R.id.menu_preferences) { Intent intent = new Intent(); intent.setClass(this, PrefsActivity.class); startActivity(intent); return true; } else if (itemId == R.id.menu_donate) { try { mBillingHelper.launchPurchaseFlow(this, SKU_INAPP_PREMIUM, SKU_DONATE_REQUEST_CODE, new IabHelper.OnIabPurchaseFinishedListener() { public void onIabPurchaseFinished(IabResult result, Purchase purchase) { if (result.isFailure()) { Log.d("nononsenseapps billing", "Error purchasing: " + result); return; } else if (purchase.getSku().equals(SKU_INAPP_PREMIUM)) { mHasPremiumAccess = true; mDonatedInApp = true; // Save in prefs PreferenceManager.getDefaultSharedPreferences(ActivityMain.this).edit() .putBoolean(SKU_INAPP_PREMIUM, true).putBoolean(PREMIUMSTATUS, true) .commit(); // Update relevant parts of UI updateUiDonate(); // Notify user of success Toast.makeText(ActivityMain.this, R.string.premiums_unlocked_and_thanks, Toast.LENGTH_SHORT).show(); } } }); } catch (Exception e) { Log.d("nononsenseapps billing", "Shouldnt start two purchases! " + e.getLocalizedMessage()); } return true; } else if (itemId == R.id.menu_sync) { handleSyncRequest(); return true; } else if (itemId == R.id.menu_delete) { return false; } else { return false; } }
From source file:com.haomee.chat.activity.ChatActivity.java
/** * initView//from www . ja v a 2 s.c om */ protected void initView() { report = (TextView) findViewById(R.id.report); report.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(); intent.setClass(ChatActivity.this, ReportActivity1.class); intent.putExtra("uid", uId); intent.putExtra("nickname", nickname); ChatActivity.this.startActivity(intent); } }); attachment_linear = (LinearLayout) findViewById(R.id.attachment_linear); attachment_content = (TextView) findViewById(R.id.attachment_content); attachment_close = (ImageView) findViewById(R.id.attachment_close); attachment_close.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub attachment_linear.setVisibility(View.GONE); } }); recordingContainer = findViewById(R.id.recording_container); game_container = findViewById(R.id.game_container); micImage = (ImageView) findViewById(R.id.mic_image); recordingHint = (TextView) findViewById(R.id.recording_hint); listView = (ListView) findViewById(R.id.list); mEditTextContent = (PasteEditText) findViewById(R.id.et_sendmessage); // buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard); edittext_layout = (RelativeLayout) findViewById(R.id.edittext_layout); buttonSetModeVoice = (ImageView) findViewById(R.id.btn_set_mode_voice); buttonSend = findViewById(R.id.btn_send); buttonPressToSpeak = findViewById(R.id.btn_press_to_speak); expressionContainer = (LinearLayout) findViewById(R.id.ll_face_container); more_container = (LinearLayout) findViewById(R.id.more_container); // locationImgview = (ImageView) findViewById(R.id.btn_location); bt_emoticons = (ImageView) findViewById(R.id.bt_emoticons); loadmorePB = (ProgressBar) findViewById(R.id.pb_load_more); btnMore = (ImageView) findViewById(R.id.btn_more); all_container = findViewById(R.id.all_container); edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); bt_question = (ImageView) findViewById(R.id.bt_question); btn_game = (ImageView) findViewById(R.id.btn_game); questionContainer = findViewById(R.id.question_container); // ?, micImages = new Drawable[] { getResources().getDrawable(R.drawable.record_animate_01), getResources().getDrawable(R.drawable.record_animate_02), getResources().getDrawable(R.drawable.record_animate_03), getResources().getDrawable(R.drawable.record_animate_04), getResources().getDrawable(R.drawable.record_animate_05), getResources().getDrawable(R.drawable.record_animate_06), getResources().getDrawable(R.drawable.record_animate_07), getResources().getDrawable(R.drawable.record_animate_08), getResources().getDrawable(R.drawable.record_animate_09), getResources().getDrawable(R.drawable.record_animate_10), getResources().getDrawable(R.drawable.record_animate_11), getResources().getDrawable(R.drawable.record_animate_12), getResources().getDrawable(R.drawable.record_animate_13), getResources().getDrawable(R.drawable.record_animate_14) }; // expressionViewpager.setAdapter(new ExpressionPagerAdapter(views)); edittext_layout.requestFocus(); voiceRecorder = new VoiceRecorder(micImageHandler); buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen()); mEditTextContent.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); } else { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); } } }); // ? mEditTextContent.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!TextUtils.isEmpty(s)) { buttonSetModeVoice.setVisibility(View.GONE); buttonSend.setVisibility(View.VISIBLE); } else { buttonSetModeVoice.setVisibility(View.VISIBLE); buttonSend.setVisibility(View.GONE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); }
From source file:cn.kangeqiu.kq.activity.ChatActivity.java
/** * ?//from w w w . j a va 2 s. c o m * * @param view */ @Override public void onClick(View view) { String st1 = getResources().getString(R.string.not_connect_to_server); int id = view.getId(); if (id == R.id.btn_send) {// ??(?) String s = mEditTextContent.getText().toString(); sendText(s); } else if (id == R.id.btn_take_picture) { selectPicFromCamera();// } else if (id == R.id.btn_picture) { selectPicFromLocal(); // } else if (id == R.id.btn_location) { // ? startActivityForResult(new Intent(this, BaiduMapActivity.class), REQUEST_CODE_MAP); } else if (id == R.id.iv_emoticons_normal) { // more.setVisibility(View.VISIBLE); iv_emoticons_normal.setVisibility(View.INVISIBLE); iv_emoticons_checked.setVisibility(View.VISIBLE); btnContainer.setVisibility(View.GONE); emojiIconContainer.setVisibility(View.VISIBLE); hideKeyboard(); } else if (id == R.id.iv_emoticons_checked) { // ?? iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); btnContainer.setVisibility(View.VISIBLE); emojiIconContainer.setVisibility(View.GONE); more.setVisibility(View.GONE); } else if (id == R.id.btn_video) { // ? Intent intent = new Intent(ChatActivity.this, ImageGridActivity.class); startActivityForResult(intent, REQUEST_CODE_SELECT_VIDEO); } else if (id == R.id.btn_file) { // selectFileFromLocal(); } else if (id == R.id.btn_voice_call) { // ? if (!EMChatManager.getInstance().isConnected()) Toast.makeText(this, st1, 0).show(); else startActivity(new Intent(ChatActivity.this, VoiceCallActivity.class) .putExtra("username", toChatUsername).putExtra("isComingCall", false)); } else if (id == R.id.btn_video_call) { // ? if (!EMChatManager.getInstance().isConnected()) Toast.makeText(this, st1, 0).show(); else startActivity(new Intent(this, VideoCallActivity.class).putExtra("username", toChatUsername) .putExtra("isComingCall", false)); } else if (id == R.id.btn_dadu) { // sendDadu(toChatUsername + "?"); MobclickAgent.onEvent(this, "room_chuiniu"); TCAgent.onEvent(this, "room_chuiniu"); Intent intent = new Intent(); intent.setClass(this, CreatMyBragActivity.class); intent.putExtra("roomId", roomId); startActivityForResult(intent, REQUEST_CODE_CREATE_BRAG); } else if (id == R.id.btn_jingcai) { // sendDadu(toChatUsername + "?"); MobclickAgent.onEvent(this, "room_pankou"); TCAgent.onEvent(this, "room_pankou"); Intent intent = new Intent(); intent.setClass(this, CreatMyGuessActivity.class); intent.putExtra("roomId", roomId); startActivityForResult(intent, REQUEST_CODE_CREATE_GUESS); } }
From source file:com.android.gallery3d.app.PhotoPage.java
@Override protected boolean onItemSelected(MenuItem item) { if (mModel == null) return true; refreshHidingMessage();/*from ww w.ja va2s . c o m*/ MediaItem current = mModel.getMediaItem(0); // This is a shield for monkey when it clicks the action bar // menu when transitioning from filmstrip to camera if (current instanceof SnailItem) return true; // TODO: We should check the current photo against the MediaItem // that the menu was initially created for. We need to fix this // after PhotoPage being refactored. if (current == null) { // item is not ready, ignore return true; } int currentIndex = mModel.getCurrentIndex(); Path path = current.getPath(); DataManager manager = mActivity.getDataManager(); int action = item.getItemId(); /// M: [BUG.ADD] show toast before PhotoDataAdapter finishing loading to avoid JE @{ if (action != android.R.id.home && !mLoadingFinished && mSetPathString != null) { Toast.makeText(mActivity, mActivity.getString(R.string.please_wait), Toast.LENGTH_SHORT).show(); return true; } /// @} String confirmMsg = null; switch (action) { case android.R.id.home: { onUpPressed(); return true; } case R.id.action_slideshow: { Bundle data = new Bundle(); /// M: [BUG.MODIFY] fix bug: slideshow doesn't play again // when finish playing the last picture @{ String mediaSetPath = mMediaSet.getPath().toString(); if (mSnailSetPath != null) { mediaSetPath = mediaSetPath.replace(mSnailSetPath + ",", ""); Log.i(TAG, "<onItemSelected> action_slideshow | mediaSetPath: " + mediaSetPath); } /*data.putString(SlideshowPage.KEY_SET_PATH, mMediaSet.getPath().toString());*/ data.putString(SlideshowPage.KEY_SET_PATH, mediaSetPath); /// @} data.putString(SlideshowPage.KEY_ITEM_PATH, path.toString()); /// M: [BUG.ADD] currentIndex-- if it is in camera folder @{ if (mHasCameraScreennailOrPlaceholder) { currentIndex--; } /// @} data.putInt(SlideshowPage.KEY_PHOTO_INDEX, currentIndex); data.putBoolean(SlideshowPage.KEY_REPEAT, true); mActivity.getStateManager().startStateForResult(SlideshowPage.class, REQUEST_SLIDESHOW, data); return true; } case R.id.action_crop: { /// M: [BUG.ADD] disable cropping photo when file not exists or sdcard is full. @{ File srcFile = new File(current.getFilePath()); if (!srcFile.exists()) { Log.i(TAG, "<onItemSelected> abort cropping photo when not exists!"); return true; } if (!isSpaceEnough(srcFile)) { Log.i(TAG, "<onItemSelected> abort cropping photo when no enough space!"); Toast.makeText(mActivity, mActivity.getString(R.string.storage_not_enough), Toast.LENGTH_SHORT) .show(); return true; } /// @} Activity activity = mActivity; Intent intent = new Intent(CropActivity.CROP_ACTION); intent.setClass(activity, CropActivity.class); intent.setDataAndType(manager.getContentUri(path), current.getMimeType()) .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); activity.startActivityForResult(intent, PicasaSource.isPicasaImage(current) ? REQUEST_CROP_PICASA : REQUEST_CROP); return true; } case R.id.action_trim: { Intent intent = new Intent(mActivity, TrimVideo.class); intent.setData(manager.getContentUri(path)); // We need the file path to wrap this into a RandomAccessFile. intent.putExtra(KEY_MEDIA_ITEM_PATH, current.getFilePath()); /// M: [FEATURE.ADD] SlideVideo@{ if (FeatureConfig.SUPPORT_SLIDE_VIDEO_PLAY) { intent.putExtra(TrimVideo.KEY_COME_FROM_GALLERY, true); } /// @} mActivity.startActivityForResult(intent, REQUEST_TRIM); return true; } case R.id.action_mute: { /// M: [BUG.ADD] disable muting video when file not exists or sdcard is full. @{ File srcFile = new File(current.getFilePath()); if (!srcFile.exists()) { Log.i(TAG, "<onItemSelected> abort muting video when not exists!"); return true; } if (!isSpaceEnough(srcFile)) { Log.i(TAG, "<onItemSelected> abort muting video when no enough space!"); Toast.makeText(mActivity, mActivity.getString(R.string.storage_not_enough), Toast.LENGTH_SHORT) .show(); return true; } /// @} mMuteVideo = new MuteVideo(current.getFilePath(), manager.getContentUri(path), mActivity); mMuteVideo.muteInBackground(); /// M: [FEATURE.ADD] SlideVideo@{ mMuteVideo.setMuteDoneListener(new MuteDoneListener() { public void onMuteDone(Uri uri) { redirectCurrentMedia(uri, false); } }); /// @} return true; } case R.id.action_edit: { /// M: [BUG.ADD] disable editing photo when file not exists or sdcard is full. @{ File srcFile = new File(current.getFilePath()); if (!srcFile.exists()) { Log.i(TAG, "<onItemSelected> abort editing photo when not exists!"); return true; } if (!isSpaceEnough(srcFile)) { Log.i(TAG, "<onItemSelected> abort editing photo when no enough space!"); Toast.makeText(mActivity, mActivity.getString(R.string.storage_not_enough), Toast.LENGTH_SHORT) .show(); return true; } /// @} launchPhotoEditor(); return true; } /// M: [FEATURE.ADD] @{ case R.id.m_action_picture_quality: { Activity activity = (Activity) mActivity; Intent intent = new Intent(PictureQualityActivity.ACTION_PQ); intent.setClass(activity, PictureQualityActivity.class); intent.setData(manager.getContentUri(path)); Bundle pqBundle = new Bundle(); pqBundle.putString("PQUri", manager.getContentUri(path).toString()); pqBundle.putString("PQMineType", current.getMimeType()); pqBundle.putInt("PQViewWidth", mPhotoView.getWidth()); pqBundle.putInt("PQViewHeight", mPhotoView.getHeight()); intent.putExtras(pqBundle); Log.i(TAG, "<onItemSelected>startActivity PQ"); activity.startActivityForResult(intent, REQUEST_PQ); return true; } case R.id.m_action_image_dc: { ImageDC.resetStatus((Context) mActivity); ImageDC.setMenuItemTile(item); path.clearObject(); mActivity.getDataManager().forceRefreshAll(); Log.d(TAG, "< onStateResult > forceRefreshAll~~"); return true; } /// @} case R.id.action_simple_edit: { launchSimpleEditor(); return true; } case R.id.action_details: { if (mShowDetails) { hideDetails(); } else { showDetails(); } return true; } case R.id.print: { mActivity.printSelectedImage(manager.getContentUri(path)); return true; } case R.id.action_delete: confirmMsg = mActivity.getResources().getQuantityString(R.plurals.delete_selection, 1); case R.id.action_setas: case R.id.action_rotate_ccw: case R.id.action_rotate_cw: case R.id.action_show_on_map: mSelectionManager.deSelectAll(); mSelectionManager.toggle(path); mMenuExecutor.onMenuClicked(item, confirmMsg, mConfirmDialogListener); return true; /// M: [FEATURE.ADD] DRM & HotKnot @{ case R.id.m_action_protect_info: Log.d(TAG, "<onItemSelected> ProtectionInfo: do action_protection_info"); DrmHelper.showProtectionInfoDialog((Activity) mActivity, manager.getContentUri(path)); return true; case R.id.action_hotknot: Log.d(TAG, "<onItemSelected> HotKnot: do action_hotknot"); // for continuous shot, may share a group image, so getContentUris() Uri[] uris = null; ExtItem extItem = mCurrentPhoto.getExtItem(); if (extItem != null) { uris = extItem.getContentUris(); } if (uris != null) { mActivity.getHotKnot().sendZip(uris); } else { extHotKnot(); } return true; /// @} /// M: [FEATURE.ADD] entry to export as video @{ case R.id.action_export: mAnimatedContentSharer.exportCurrentPhoto(); return true; /// @} /// M: [FEATURE.ADD] Support BlueTooth print feature.@{ case R.id.action_print: mSelectionManager.deSelectAll(); mSelectionManager.toggle(path); mMenuExecutor.onMenuClicked(item, confirmMsg, mConfirmDialogListener); return true; /// @} default: /// M: [FEATURE.ADD] menu extension @{ // return false; return mPhotoView.onOptionsItemSelected(item); /// @} } }
From source file:com.mgfypy.esafeboximagelibrary.MainActivity.java
@Override public void onClick(View v) { Intent intent = new Intent(); int requestCode = REQ_IMAGE; boolean isShowCamera = cbShowCamera.isChecked(); switch (v.getId()) { case R.id.btn_single: /*AndroidImagePicker.getInstance().setSelectMode(AndroidImagePicker.Select_Mode.MODE_SINGLE); AndroidImagePicker.getInstance().setShouldShowCamera(false); break;*///from ww w . j a v a 2 s .c o m AndroidImagePicker.getInstance().pickSingle(MainActivity.this, isShowCamera, new AndroidImagePicker.OnImagePickCompleteListener() { @Override public void onImagePickComplete(List<ImageItem> items) { if (items != null && items.size() > 0) { Log.i(TAG, "=====" + items.get(0).path); mAdapter.clear(); mAdapter.addAll(items); } } }); return; case R.id.btn_multi: /*AndroidImagePicker.getInstance().setSelectMode(AndroidImagePicker.Select_Mode.MODE_MULTI); AndroidImagePicker.getInstance().setShouldShowCamera(false); break;*/ AndroidImagePicker.getInstance().pickMulti(MainActivity.this, isShowCamera, new AndroidImagePicker.OnImagePickCompleteListener() { @Override public void onImagePickComplete(List<ImageItem> items) { if (items != null && items.size() > 0) { Log.i(TAG, "=====" + items.get(0).path); mAdapter.clear(); mAdapter.addAll(items); } } }); return; case R.id.btn_crop: AndroidImagePicker.getInstance().pickAndCrop(MainActivity.this, true, 120, new AndroidImagePicker.OnImageCropCompleteListener() { @Override public void onImageCropComplete(Bitmap bmp, float ratio) { Log.i(TAG, "=====onImageCropComplete (get bitmap=" + bmp.toString()); ivCrop.setVisibility(View.VISIBLE); ivCrop.setImageBitmap(bmp); } }); return; /*AndroidImagePicker.getInstance().setSelectMode(AndroidImagePicker.Select_Mode.MODE_SINGLE); AndroidImagePicker.getInstance().setShouldShowCamera(true); intent.putExtra("isCrop", true); AndroidImagePicker.getInstance().cropMode = true; requestCode = REQ_IMAGE_CROP;*/ default: break; } intent.setClass(this, ImagesGridActivity.class); startActivityForResult(intent, requestCode); }
From source file:com.general.myapplication.ImagePickerActivity.java
@Override public void onClick(View v) { Intent intent = new Intent(); int requestCode = REQ_IMAGE; boolean isShowCamera = cbShowCamera.isChecked(); switch (v.getId()) { case R.id.btn_single: /*AndroidImagePicker.getInstance().setSelectMode(AndroidImagePicker.Select_Mode.MODE_SINGLE); AndroidImagePicker.getInstance().setShouldShowCamera(false); break;*///from w w w. j ava 2s. c om AndroidImagePicker.getInstance().pickSingle(ImagePickerActivity.this, isShowCamera, new AndroidImagePicker.OnImagePickCompleteListener() { @Override public void onImagePickComplete(List<ImageItem> items) { if (items != null && items.size() > 0) { Log.i(TAG, "=====" + items.get(0).path); mAdapter.clear(); mAdapter.addAll(items); } } }); return; case R.id.btn_multi: /*AndroidImagePicker.getInstance().setSelectMode(AndroidImagePicker.Select_Mode.MODE_MULTI); AndroidImagePicker.getInstance().setShouldShowCamera(false); break;*/ AndroidImagePicker.getInstance().pickMulti(ImagePickerActivity.this, isShowCamera, new AndroidImagePicker.OnImagePickCompleteListener() { @Override public void onImagePickComplete(List<ImageItem> items) { if (items != null && items.size() > 0) { Log.i(TAG, "=====" + items.get(0).path); mAdapter.clear(); mAdapter.addAll(items); } } }); return; case R.id.btn_crop: AndroidImagePicker.getInstance().pickAndCrop(ImagePickerActivity.this, true, 120, new AndroidImagePicker.OnImageCropCompleteListener() { @Override public void onImageCropComplete(Bitmap bmp, float ratio) { Log.i(TAG, "=====onImageCropComplete (get bitmap=" + bmp.toString()); ivCrop.setVisibility(View.VISIBLE); ivCrop.setImageBitmap(bmp); } }); return; /*AndroidImagePicker.getInstance().setSelectMode(AndroidImagePicker.Select_Mode.MODE_SINGLE); AndroidImagePicker.getInstance().setShouldShowCamera(true); intent.putExtra("isCrop", true); AndroidImagePicker.getInstance().cropMode = true; requestCode = REQ_IMAGE_CROP;*/ default: break; } intent.setClass(this, ImagesGridActivity.class); startActivityForResult(intent, requestCode); }
From source file:com.ichi2.anki2.DeckPicker.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); mDontSaveOnStop = false;// w w w . j a v a 2 s .c om if (resultCode == RESULT_MEDIA_EJECTED) { showDialog(DIALOG_SD_CARD_NOT_MOUNTED); return; } else if (resultCode == RESULT_DB_ERROR) { handleDbError(); return; } if (requestCode == SHOW_STUDYOPTIONS && resultCode == RESULT_OK) { loadCounts(); } else if (requestCode == ADD_NOTE && resultCode != RESULT_CANCELED) { loadCounts(); } else if (requestCode == BROWSE_CARDS && (resultCode == Activity.RESULT_OK || resultCode == Activity.RESULT_CANCELED)) { loadCounts(); } else if (requestCode == ADD_CRAM_DECK) { // TODO: check, if ok has been clicked loadCounts(); } else if (requestCode == REPORT_ERROR) { showStartupScreensAndDialogs(AnkiDroidApp.getSharedPrefs(getBaseContext()), 4); } else if (requestCode == SHOW_INFO_UPGRADE_DECKS) { if (intent != null && intent.hasExtra(Info.TYPE_UPGRADE_STAGE)) { int type = intent.getIntExtra(Info.TYPE_UPGRADE_STAGE, Info.UPGRADE_SCREEN_BASIC1); if (type == Info.UPGRADE_CONTINUE) { showStartupScreensAndDialogs(AnkiDroidApp.getSharedPrefs(getBaseContext()), 3); } else { showUpgradeScreen(true, type, !intent.hasExtra(Info.TYPE_ANIMATION_RIGHT)); } } else { if (resultCode == RESULT_OK) { if (mOpenCollectionDialog != null && mOpenCollectionDialog.isShowing()) { mOpenCollectionDialog.dismiss(); } if (AnkiDroidApp.colIsOpen()) { AnkiDroidApp.closeCollection(true); } AnkiDroidApp.openCollection(AnkiDroidApp.getCollectionPath()); loadCounts(); } else { finishWithAnimation(); } } } else if (requestCode == SHOW_INFO_WELCOME || requestCode == SHOW_INFO_NEW_VERSION) { if (resultCode == RESULT_OK) { showStartupScreensAndDialogs(AnkiDroidApp.getSharedPrefs(getBaseContext()), requestCode == SHOW_INFO_WELCOME ? 1 : 2); } else { finishWithAnimation(); } } else if (requestCode == PREFERENCES_UPDATE) { String oldPath = mPrefDeckPath; SharedPreferences pref = restorePreferences(); String newLanguage = pref.getString("language", ""); if (!AnkiDroidApp.getLanguage().equals(newLanguage)) { AnkiDroidApp.setLanguage(newLanguage); mInvalidateMenu = true; } if (mNotMountedDialog != null && mNotMountedDialog.isShowing() && pref.getBoolean("internalMemory", false)) { showStartupScreensAndDialogs(pref, 0); } else if (!mPrefDeckPath.equals(oldPath)) { loadCollection(); } // if (resultCode == StudyOptions.RESULT_RESTART) { // setResult(StudyOptions.RESULT_RESTART); // finishWithAnimation(); // } else { // SharedPreferences preferences = PrefSettings.getSharedPrefs(getBaseContext()); // BackupManager.initBackup(); // if (!mPrefDeckPath.equals(preferences.getString("deckPath", AnkiDroidApp.getStorageDirectory())) || // mPrefDeckOrder != Integer.parseInt(preferences.getString("deckOrder", "0"))) { // // populateDeckList(preferences.getString("deckPath", AnkiDroidApp.getStorageDirectory())); // } // } } else if (requestCode == REPORT_FEEDBACK && resultCode == RESULT_OK) { } else if (requestCode == LOG_IN_FOR_SYNC && resultCode == RESULT_OK) { sync(); } else if (requestCode == LOG_IN_FOR_SHARED_DECK && resultCode == RESULT_OK) { addSharedDeck(); } else if (requestCode == ADD_SHARED_DECKS) { if (intent != null) { mImportPath = intent.getStringExtra("importPath"); } if (AnkiDroidApp.colIsOpen() && mImportPath != null) { DeckTask.launchDeckTask(DeckTask.TASK_TYPE_IMPORT, mImportAddListener, new TaskData(AnkiDroidApp.getCol(), mImportPath, true)); mImportPath = null; } } else if (requestCode == REQUEST_REVIEW) { Log.i(AnkiDroidApp.TAG, "Result code = " + resultCode); switch (resultCode) { default: // do not reload counts, if activity is created anew because it has been before destroyed by android loadCounts(); break; case Reviewer.RESULT_NO_MORE_CARDS: mDontSaveOnStop = true; Intent i = new Intent(); i.setClass(this, StudyOptionsActivity.class); i.putExtra("onlyFnsMsg", true); startActivityForResult(i, SHOW_STUDYOPTIONS); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(this, ActivityTransitionAnimation.RIGHT); } break; } } // workaround for hidden dialog on return BroadcastMessages.showDialog(); }
From source file:com.nit.vicky.DeckPicker.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); mDontSaveOnStop = false;//from w w w . j a v a2 s . c om if (resultCode == RESULT_MEDIA_EJECTED) { showDialog(DIALOG_SD_CARD_NOT_MOUNTED); return; } else if (resultCode == RESULT_DB_ERROR) { handleDbError(); return; } if (requestCode == SHOW_STUDYOPTIONS && resultCode == RESULT_OK) { loadCounts(); } else if (requestCode == ADD_NOTE && resultCode != RESULT_CANCELED) { loadCounts(); addNote(); } else if (requestCode == BROWSE_CARDS && (resultCode == Activity.RESULT_OK || resultCode == Activity.RESULT_CANCELED)) { loadCounts(); } else if (requestCode == ADD_CRAM_DECK) { // TODO: check, if ok has been clicked loadCounts(); } else if (requestCode == REPORT_ERROR) { showStartupScreensAndDialogs(AnkiDroidApp.getSharedPrefs(getBaseContext()), 4); } else if (requestCode == SHOW_INFO_UPGRADE_DECKS) { if (intent != null && intent.hasExtra(Info.TYPE_UPGRADE_STAGE)) { int type = intent.getIntExtra(Info.TYPE_UPGRADE_STAGE, Info.UPGRADE_SCREEN_BASIC1); if (type == Info.UPGRADE_CONTINUE) { showStartupScreensAndDialogs(AnkiDroidApp.getSharedPrefs(getBaseContext()), 3); } else { showUpgradeScreen(true, type, !intent.hasExtra(Info.TYPE_ANIMATION_RIGHT)); } } else { if (resultCode == RESULT_OK) { if (mOpenCollectionDialog != null && mOpenCollectionDialog.isShowing()) { mOpenCollectionDialog.dismiss(); } if (AnkiDroidApp.colIsOpen()) { AnkiDroidApp.closeCollection(true); } AnkiDroidApp.openCollection(AnkiDroidApp.getCollectionPath()); loadCounts(); } else { finishWithAnimation(); } } } else if (requestCode == SHOW_INFO_WELCOME || requestCode == SHOW_INFO_NEW_VERSION) { if (resultCode == RESULT_OK) { showStartupScreensAndDialogs(AnkiDroidApp.getSharedPrefs(getBaseContext()), requestCode == SHOW_INFO_WELCOME ? 1 : 2); } else { finishWithAnimation(); } } else if (requestCode == PREFERENCES_UPDATE) { String oldPath = mPrefDeckPath; SharedPreferences pref = restorePreferences(); String newLanguage = pref.getString("language", ""); if (AnkiDroidApp.setLanguage(newLanguage)) { mInvalidateMenu = true; } if (mNotMountedDialog != null && mNotMountedDialog.isShowing() && pref.getBoolean("internalMemory", false)) { showStartupScreensAndDialogs(pref, 0); } else if (!mPrefDeckPath.equals(oldPath)) { loadCollection(); } // if (resultCode == StudyOptions.RESULT_RESTART) { // setResult(StudyOptions.RESULT_RESTART); // finishWithAnimation(); // } else { // SharedPreferences preferences = PrefSettings.getSharedPrefs(getBaseContext()); // BackupManager.initBackup(); // if (!mPrefDeckPath.equals(preferences.getString("deckPath", AnkiDroidApp.getStorageDirectory())) || // mPrefDeckOrder != Integer.parseInt(preferences.getString("deckOrder", "0"))) { // // populateDeckList(preferences.getString("deckPath", AnkiDroidApp.getStorageDirectory())); // } // } } else if (requestCode == REPORT_FEEDBACK && resultCode == RESULT_OK) { } else if (requestCode == LOG_IN_FOR_SYNC && resultCode == RESULT_OK) { sync(); } else if (requestCode == LOG_IN_FOR_SHARED_DECK && resultCode == RESULT_OK) { addSharedDeck(); } else if (requestCode == ADD_SHARED_DECKS) { if (intent != null) { mImportPath = intent.getStringExtra("importPath"); } if (AnkiDroidApp.colIsOpen() && mImportPath != null) { DeckTask.launchDeckTask(DeckTask.TASK_TYPE_IMPORT, mImportAddListener, new TaskData(AnkiDroidApp.getCol(), mImportPath, true)); mImportPath = null; } } else if (requestCode == REQUEST_REVIEW) { // Log.i(AnkiDroidApp.TAG, "Result code = " + resultCode); switch (resultCode) { default: // do not reload counts, if activity is created anew because it has been before destroyed by android loadCounts(); break; case Reviewer.RESULT_NO_MORE_CARDS: mDontSaveOnStop = true; Intent i = new Intent(); i.setClass(this, StudyOptionsActivity.class); i.putExtra("onlyFnsMsg", true); startActivityForResult(i, SHOW_STUDYOPTIONS); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(this, ActivityTransitionAnimation.RIGHT); } break; } } // workaround for hidden dialog on return BroadcastMessages.showDialog(); }