List of usage examples for android.os Bundle getParcelableArrayList
@Nullable public <T extends Parcelable> ArrayList<T> getParcelableArrayList(@Nullable String key)
From source file:com.android.mail.compose.ComposeActivity.java
private void finishCreate() { final Bundle savedState = mInnerSavedState; findViews();//from w w w . j av a2 s. c o m final Intent intent = getIntent(); final Message message; final ArrayList<AttachmentPreview> previews; mShowQuotedText = false; final CharSequence quotedText; int action; // Check for any of the possibly supplied accounts.; final Account account; if (hadSavedInstanceStateMessage(savedState)) { action = savedState.getInt(EXTRA_ACTION, COMPOSE); account = savedState.getParcelable(Utils.EXTRA_ACCOUNT); message = savedState.getParcelable(EXTRA_MESSAGE); previews = savedState.getParcelableArrayList(EXTRA_ATTACHMENT_PREVIEWS); mRefMessage = savedState.getParcelable(EXTRA_IN_REFERENCE_TO_MESSAGE); quotedText = savedState.getCharSequence(EXTRA_QUOTED_TEXT); mExtraValues = savedState.getParcelable(EXTRA_VALUES); // Get the draft id from the request id if there is one. if (savedState.containsKey(EXTRA_REQUEST_ID)) { final int requestId = savedState.getInt(EXTRA_REQUEST_ID); if (sRequestMessageIdMap.containsKey(requestId)) { synchronized (mDraftLock) { mDraftId = sRequestMessageIdMap.get(requestId); } } } } else { account = obtainAccount(intent); action = intent.getIntExtra(EXTRA_ACTION, COMPOSE); // Initialize the message from the message in the intent message = intent.getParcelableExtra(ORIGINAL_DRAFT_MESSAGE); previews = intent.getParcelableArrayListExtra(EXTRA_ATTACHMENT_PREVIEWS); mRefMessage = intent.getParcelableExtra(EXTRA_IN_REFERENCE_TO_MESSAGE); mRefMessageUri = intent.getParcelableExtra(EXTRA_IN_REFERENCE_TO_MESSAGE_URI); quotedText = null; if (Analytics.isLoggable()) { if (intent.getBooleanExtra(Utils.EXTRA_FROM_NOTIFICATION, false)) { Analytics.getInstance().sendEvent("notification_action", "compose", getActionString(action), 0); } } } mAttachmentsView.setAttachmentPreviews(previews); setAccount(account); if (mAccount == null) { return; } initRecipients(); // Clear the notification and mark the conversation as seen, if necessary final Folder notificationFolder = intent.getParcelableExtra(EXTRA_NOTIFICATION_FOLDER); if (notificationFolder != null) { final Uri conversationUri = intent.getParcelableExtra(EXTRA_NOTIFICATION_CONVERSATION); Intent actionIntent; if (conversationUri != null) { actionIntent = new Intent(MailIntentService.ACTION_RESEND_NOTIFICATIONS_WEAR); actionIntent.putExtra(Utils.EXTRA_CONVERSATION, conversationUri); } else { actionIntent = new Intent(MailIntentService.ACTION_CLEAR_NEW_MAIL_NOTIFICATIONS); actionIntent.setData(Utils.appendVersionQueryParameter(this, notificationFolder.folderUri.fullUri)); } actionIntent.setPackage(getPackageName()); actionIntent.putExtra(Utils.EXTRA_ACCOUNT, account); actionIntent.putExtra(Utils.EXTRA_FOLDER, notificationFolder); startService(actionIntent); } if (intent.getBooleanExtra(EXTRA_FROM_EMAIL_TASK, false)) { mLaunchedFromEmail = true; } else if (Intent.ACTION_SEND.equals(intent.getAction())) { final Uri dataUri = intent.getData(); if (dataUri != null) { final String dataScheme = intent.getData().getScheme(); final String accountScheme = mAccount.composeIntentUri.getScheme(); mLaunchedFromEmail = TextUtils.equals(dataScheme, accountScheme); } } if (mRefMessageUri != null) { mShowQuotedText = true; mComposeMode = action; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); String wearReply = null; if (remoteInput != null) { LogUtils.d(LOG_TAG, "Got remote input from new api"); CharSequence input = remoteInput.getCharSequence(NotificationActionUtils.WEAR_REPLY_INPUT); if (input != null) { wearReply = input.toString(); } } else { // TODO: remove after legacy code has been removed. LogUtils.d(LOG_TAG, "No remote input from new api, falling back to compatibility mode"); ClipData clipData = intent.getClipData(); if (clipData != null && LEGACY_WEAR_EXTRA.equals(clipData.getDescription().getLabel())) { Bundle extras = clipData.getItemAt(0).getIntent().getExtras(); if (extras != null) { wearReply = extras.getString(NotificationActionUtils.WEAR_REPLY_INPUT); } } } if (!TextUtils.isEmpty(wearReply)) { createWearReplyTask(this, mRefMessageUri, UIProvider.MESSAGE_PROJECTION, mComposeMode, wearReply).execute(); finish(); return; } else { LogUtils.w(LOG_TAG, "remote input string is null"); } } getLoaderManager().initLoader(INIT_DRAFT_USING_REFERENCE_MESSAGE, null, this); return; } else if (message != null && action != EDIT_DRAFT) { initFromDraftMessage(message); initQuotedTextFromRefMessage(mRefMessage, action); mShowQuotedText = message.appendRefMessageContent; // if we should be showing quoted text but mRefMessage is null // and we have some quotedText, display that if (mShowQuotedText && mRefMessage == null) { if (quotedText != null) { initQuotedText(quotedText, false /* shouldQuoteText */); } else if (mExtraValues != null) { initExtraValues(mExtraValues); return; } } } else if (action == EDIT_DRAFT) { if (message == null) { throw new IllegalStateException("Message must not be null to edit draft"); } initFromDraftMessage(message); // Update the action to the draft type of the previous draft switch (message.draftType) { case UIProvider.DraftType.REPLY: action = REPLY; break; case UIProvider.DraftType.REPLY_ALL: action = REPLY_ALL; break; case UIProvider.DraftType.FORWARD: action = FORWARD; break; case UIProvider.DraftType.COMPOSE: default: action = COMPOSE; break; } LogUtils.d(LOG_TAG, "Previous draft had action type: %d", action); mShowQuotedText = message.appendRefMessageContent; if (message.refMessageUri != null) { // If we're editing an existing draft that was in reference to an existing message, // still need to load that original message since we might need to refer to the // original sender and recipients if user switches "reply <-> reply-all". mRefMessageUri = message.refMessageUri; mComposeMode = action; getLoaderManager().initLoader(REFERENCE_MESSAGE_LOADER, null, this); return; } } else if ((action == REPLY || action == REPLY_ALL || action == FORWARD)) { if (mRefMessage != null) { initFromRefMessage(action); mShowQuotedText = true; } } else { if (initFromExtras(intent)) { return; } } mComposeMode = action; finishSetup(action, intent, savedState); }
From source file:com.android.mail.compose.ComposeActivity.java
private void initAttachmentsFromIntent(Intent intent) { Bundle extras = intent.getExtras(); if (extras == null) { extras = Bundle.EMPTY;// w w w . ja va 2 s. com } final String action = intent.getAction(); if (!mAttachmentsChanged) { long totalSize = 0; if (extras.containsKey(EXTRA_ATTACHMENTS)) { final String[] uris = (String[]) extras.getSerializable(EXTRA_ATTACHMENTS); final ArrayList<Uri> parsedUris = Lists.newArrayListWithCapacity(uris.length); for (String uri : uris) { parsedUris.add(Uri.parse(uri)); } totalSize += handleAttachmentUrisFromIntent(parsedUris); } if (extras.containsKey(Intent.EXTRA_STREAM)) { if (Intent.ACTION_SEND_MULTIPLE.equals(action)) { final ArrayList<Uri> uris = extras.getParcelableArrayList(Intent.EXTRA_STREAM); totalSize += handleAttachmentUrisFromIntent(uris); } else { final Uri uri = extras.getParcelable(Intent.EXTRA_STREAM); final ArrayList<Uri> uris = Lists.newArrayList(uri); totalSize += handleAttachmentUrisFromIntent(uris); } } if (totalSize > 0) { mAttachmentsChanged = true; updateSaveUi(); Analytics.getInstance().sendEvent("send_intent_with_attachments", Integer.toString(getAttachments().size()), null, totalSize); } } }
From source file:org.mariotaku.twidere.activity.support.ComposeActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mPreferences = SharedPreferencesWrapper.getInstance(this, SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE, SharedPreferenceConstants.class); final TwidereApplication app = TwidereApplication.getInstance(this); mTwitterWrapper = app.getTwitterWrapper(); mResolver = getContentResolver();//from ww w .j a v a2 s. co m mValidator = new TwidereValidator(this); mImageLoader = app.getMediaLoaderWrapper(); setContentView(R.layout.activity_compose); setFinishOnTouchOutside(false); final long[] defaultAccountIds = Utils.getAccountIds(this); if (defaultAccountIds.length <= 0) { final Intent intent = new Intent(INTENT_ACTION_TWITTER_LOGIN); intent.setClass(this, SignInActivity.class); startActivity(intent); finish(); return; } mMenuBar.setOnMenuItemClickListener(this); setupEditText(); mAccountSelectorContainer.setOnClickListener(this); mAccountSelectorButton.setOnClickListener(this); mLocationContainer.setOnClickListener(this); final LinearLayoutManager linearLayoutManager = new FixedLinearLayoutManager(this); linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); linearLayoutManager.setStackFromEnd(true); mAccountSelector.setLayoutManager(linearLayoutManager); mAccountSelector.addItemDecoration(new SpacingItemDecoration(this)); mAccountSelector.setItemAnimator(new RecyclerView.ItemAnimator() { @Override public void runPendingAnimations() { } @Override public boolean animateRemove(ViewHolder holder) { return false; } @Override public boolean animateAdd(ViewHolder holder) { return false; } @Override public boolean animateMove(ViewHolder holder, int fromX, int fromY, int toX, int toY) { Log.d(LOGTAG, String.format("animateMove")); return false; } @Override public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder, int fromLeft, int fromTop, int toLeft, int toTop) { Log.d(LOGTAG, String.format("animateChange")); return false; } @Override public void endAnimation(ViewHolder item) { Log.d(LOGTAG, String.format("endAnimation")); } @Override public void endAnimations() { } @Override public boolean isRunning() { return false; } }); mAccountsAdapter = new AccountIconsAdapter(this); mAccountSelector.setAdapter(mAccountsAdapter); mAccountsAdapter.setAccounts(ParcelableAccount.getAccounts(this, false, false)); mMediaPreviewAdapter = new MediaPreviewAdapter(this); mMediaPreviewGrid.setAdapter(mMediaPreviewAdapter); final Intent intent = getIntent(); if (savedInstanceState != null) { // Restore from previous saved state mAccountsAdapter.setSelectedAccountIds(savedInstanceState.getLongArray(EXTRA_ACCOUNT_IDS)); mIsPossiblySensitive = savedInstanceState.getBoolean(EXTRA_IS_POSSIBLY_SENSITIVE); final ArrayList<ParcelableMediaUpdate> mediaList = savedInstanceState .getParcelableArrayList(EXTRA_MEDIA); if (mediaList != null) { addMedia(mediaList); } mInReplyToStatus = savedInstanceState.getParcelable(EXTRA_STATUS); mInReplyToStatusId = savedInstanceState.getLong(EXTRA_STATUS_ID); mMentionUser = savedInstanceState.getParcelable(EXTRA_USER); mDraftItem = savedInstanceState.getParcelable(EXTRA_DRAFT); mShouldSaveAccounts = savedInstanceState.getBoolean(EXTRA_SHOULD_SAVE_ACCOUNTS); mOriginalText = savedInstanceState.getString(EXTRA_ORIGINAL_TEXT); } else { // The context was first created final int notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1); final long notificationAccount = intent.getLongExtra(EXTRA_NOTIFICATION_ACCOUNT, -1); if (notificationId != -1) { mTwitterWrapper.clearNotificationAsync(notificationId, notificationAccount); } if (!handleIntent(intent)) { handleDefaultIntent(intent); } final long[] accountIds = mAccountsAdapter.getSelectedAccountIds(); if (accountIds.length == 0) { final long[] idsInPrefs = TwidereArrayUtils .parseLongArray(mPreferences.getString(KEY_COMPOSE_ACCOUNTS, null), ','); final long[] intersection = TwidereArrayUtils.intersection(idsInPrefs, defaultAccountIds); mAccountsAdapter.setSelectedAccountIds(intersection.length > 0 ? intersection : defaultAccountIds); } mOriginalText = ParseUtils.parseString(mEditText.getText()); } if (!setComposeTitle(intent)) { setTitle(R.string.compose); } final Menu menu = mMenuBar.getMenu(); getMenuInflater().inflate(R.menu.menu_compose, menu); ThemeUtils.wrapMenuIcon(mMenuBar); mSendView.setOnClickListener(this); mSendView.setOnLongClickListener(this); final Intent composeExtensionsIntent = new Intent(INTENT_ACTION_EXTENSION_COMPOSE); Utils.addIntentToMenu(this, menu, composeExtensionsIntent, MENU_GROUP_COMPOSE_EXTENSION); final Intent imageExtensionsIntent = new Intent(INTENT_ACTION_EXTENSION_EDIT_IMAGE); final MenuItem mediaMenuItem = menu.findItem(R.id.media_menu); if (mediaMenuItem != null && mediaMenuItem.hasSubMenu()) { Utils.addIntentToMenu(this, mediaMenuItem.getSubMenu(), imageExtensionsIntent, MENU_GROUP_IMAGE_EXTENSION); } setMenu(); updateLocationState(); updateMediaPreview(); notifyAccountSelectionChanged(); mTextChanged = false; }
From source file:com.android.mms.ui.ComposeMessageActivity.java
private boolean handleSendIntent() { Intent intent = getIntent();//from w w w . j a va 2s . c om Bundle extras = intent.getExtras(); if (extras == null) { return false; } final String mimeType = intent.getType(); String action = intent.getAction(); if (Intent.ACTION_SEND.equals(action)) { if (extras.containsKey(Intent.EXTRA_STREAM)) { final Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM); getAsyncDialog().runAsync(new Runnable() { @Override public void run() { addAttachment(mimeType, uri, false); } }, null, R.string.adding_attachments_title); return true; } else if (extras.containsKey(Intent.EXTRA_TEXT)) { mWorkingMessage.setText(extras.getString(Intent.EXTRA_TEXT)); return true; } } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && extras.containsKey(Intent.EXTRA_STREAM)) { SlideshowModel slideShow = mWorkingMessage.getSlideshow(); final ArrayList<Parcelable> uris = extras.getParcelableArrayList(Intent.EXTRA_STREAM); int currentSlideCount = slideShow != null ? slideShow.size() : 0; int importCount = uris.size(); if (importCount + currentSlideCount > SlideshowEditor.MAX_SLIDE_NUM) { importCount = Math.min(SlideshowEditor.MAX_SLIDE_NUM - currentSlideCount, importCount); Toast.makeText(ComposeMessageActivity.this, getString(R.string.too_many_attachments, SlideshowEditor.MAX_SLIDE_NUM, importCount), Toast.LENGTH_LONG).show(); } // Attach all the pictures/videos asynchronously off of the UI thread. // Show a progress dialog if adding all the slides hasn't finished // within half a second. final int numberToImport = importCount; getAsyncDialog().runAsync(new Runnable() { @Override public void run() { for (int i = 0; i < numberToImport; i++) { Parcelable uri = uris.get(i); addAttachment(mimeType, (Uri) uri, true); } } }, null, R.string.adding_attachments_title); return true; } return false; }
From source file:me.willowcheng.makerthings.ui.OpenHABMainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate()"); // Check if we are in development mode perPreferences = getSharedPreferences("pref", this.MODE_PRIVATE); isDeveloper = false;//from ww w . j a v a 2 s .c o m // Set default values, false means do it one time during the very first launch PreferenceManager.setDefaultValues(this, R.xml.preferences, false); // Set non-persistent HABDroid version preference to current version from application package try { Log.d(TAG, "App version = " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName); PreferenceManager.getDefaultSharedPreferences(this).edit().putString(Constants.PREFERENCE_APPVERSION, getPackageManager().getPackageInfo(getPackageName(), 0).versionName).commit(); } catch (PackageManager.NameNotFoundException e1) { if (e1 != null) Log.d(TAG, e1.getMessage()); } checkDiscoveryPermissions(); checkVoiceRecognition(); // initialize loopj async http client mAsyncHttpClient = new MyAsyncHttpClient(this); // Set the theme to one from preferences mSettings = PreferenceManager.getDefaultSharedPreferences(this); // Disable screen timeout if set in preferences if (mSettings.getBoolean(Constants.PREFERENCE_SCREENTIMEROFF, false)) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } // Fetch openHAB service type name from strings.xml openHABServiceType = getString(R.string.openhab_service_type); // Get username/password from preferences openHABUsername = mSettings.getString(Constants.PREFERENCE_USERNAME, null); openHABPassword = mSettings.getString(Constants.PREFERENCE_PASSWORD, null); mAsyncHttpClient.setBasicAuth(openHABUsername, openHABPassword, true); mAsyncHttpClient.setTimeout(30000); if (!isDeveloper) Util.initCrittercism(getApplicationContext(), "5117659f59e1bd4ba9000004"); Util.setActivityTheme(this); super.onCreate(savedInstanceState); if (!isDeveloper) ((HABDroid) getApplication()).getTracker(HABDroid.TrackerName.APP_TRACKER); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.openhab_toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // ProgressBar layout params inside the toolbar have to be done programmatically // because it doesn't work through layout file :-( mProgressBar = (SwipeRefreshLayout) findViewById(R.id.toolbar_progress_bar); mProgressBar.setColorSchemeColors(getResources().getColor(R.color.theme_accent)); mProgressBar.setEnabled(false); mProgressBar.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mProgressBar.setRefreshing(false); } }); // mProgressBar.setLayoutParams(new Toolbar.LayoutParams(Gravity.RIGHT)); startProgressIndicator(); gcmRegisterBackground(); // Enable app icon in action bar work as 'home' // this.getActionBar().setHomeButtonEnabled(true); pager = (OpenHABViewPager) findViewById(R.id.pager); pager.setScrollDurationFactor(2.5); pager.setOffscreenPageLimit(1); pagerAdapter = new OpenHABFragmentPagerAdapter(getSupportFragmentManager()); pagerAdapter.setColumnsNumber(getResources().getInteger(R.integer.pager_columns)); pagerAdapter.setOpenHABUsername(openHABUsername); pagerAdapter.setOpenHABPassword(openHABPassword); pager.setAdapter(pagerAdapter); pager.setOnPageChangeListener(pagerAdapter); MemorizingTrustManager.setResponder(this); // pager.setPageMargin(1); // pager.setPageMarginDrawable(android.R.color.darker_gray); // Check if we have openHAB page url in saved instance state? if (savedInstanceState != null) { openHABBaseUrl = savedInstanceState.getString("openHABBaseUrl"); sitemapRootUrl = savedInstanceState.getString("sitemapRootUrl"); mStartedWithNetworkConnectivityInfo = savedInstanceState .getParcelable("startedWithNetworkConnectivityInfo"); mOpenHABVersion = savedInstanceState.getInt("openHABVersion"); mSitemapList = savedInstanceState.getParcelableArrayList("sitemapList"); } mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.app_name, R.string.app_name) { public void onDrawerClosed(View view) { Log.d(TAG, "onDrawerClosed"); getSupportActionBar().setTitle(pagerAdapter.getPageTitle(pager.getCurrentItem())); } public void onDrawerOpened(View drawerView) { Log.d(TAG, "onDrawerOpened"); getSupportActionBar().setTitle("Makerthings"); loadSitemapList(OpenHABMainActivity.this.openHABBaseUrl); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); if (mSitemapList == null) mSitemapList = new ArrayList<OpenHABSitemap>(); mDrawerItemList = new ArrayList<OpenHABDrawerItem>(); mDrawerAdapter = new OpenHABDrawerAdapter(this, R.layout.openhabdrawer_sitemap_item, mDrawerItemList); mDrawerAdapter.setOpenHABUsername(openHABUsername); mDrawerAdapter.setOpenHABPassword(openHABPassword); mDrawerList.setAdapter(mDrawerAdapter); mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) { Log.d(TAG, "Drawer selected item " + String.valueOf(item)); if (mDrawerItemList != null && mDrawerItemList.get(item) .getItemType() == OpenHABDrawerItem.DrawerItemType.SITEMAP_ITEM) { Log.d(TAG, "This is sitemap " + mDrawerItemList.get(item).getSiteMap().getLink()); mDrawerLayout.closeDrawers(); openSitemap(mDrawerItemList.get(item).getSiteMap().getHomepageLink()); } else { Log.d(TAG, "This is not sitemap"); if (mDrawerItemList.get(item).getTag() == DRAWER_NOTIFICATIONS) { Log.d(TAG, "Notifications selected"); mDrawerLayout.closeDrawers(); OpenHABMainActivity.this.openNotifications(); } else if (mDrawerItemList.get(item).getTag() == DRAWER_BINDINGS) { Log.d(TAG, "Bindings selected"); mDrawerLayout.closeDrawers(); OpenHABMainActivity.this.openBindings(); } else if (mDrawerItemList.get(item).getTag() == DRAWER_INBOX) { Log.d(TAG, "Inbox selected"); mDrawerLayout.closeDrawers(); OpenHABMainActivity.this.openDiscoveryInbox(); } } } }); loadDrawerItems(); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); if (getIntent() != null) { Log.d(TAG, "Intent != null"); if (getIntent().getAction() != null) { Log.d(TAG, "Intent action = " + getIntent().getAction()); if (getIntent().getAction().equals("android.nfc.action.NDEF_DISCOVERED")) { Log.d(TAG, "This is NFC action"); if (getIntent().getDataString() != null) { Log.d(TAG, "NFC data = " + getIntent().getDataString()); mNfcData = getIntent().getDataString(); } } else if (getIntent().getAction().equals("org.openhab.notification.selected")) { onNotificationSelected(getIntent()); } else if (getIntent().getAction().equals("android.intent.action.VIEW")) { Log.d(TAG, "This is URL Action"); String URL = getIntent().getDataString(); mNfcData = URL; } } } /** * If we are 4.4 we can use fullscreen mode and Daydream features */ supportsKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; boolean fullScreen = mSettings.getBoolean("default_openhab_fullscreen", false); if (supportsKitKat && fullScreen) { registerReceiver(dreamReceiver, new IntentFilter("android.intent.action.DREAMING_STARTED")); registerReceiver(dreamReceiver, new IntentFilter("android.intent.action.DREAMING_STOPPED")); checkFullscreen(); } }
From source file:de.uni_koblenz_landau.apow.ObsDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.obs_detail_fragment, container, false); // Create UI references. mDeleteDialog = (DeleteDialogFragment) getFragmentManager().findFragmentByTag(DELETE_DIALOG_ID); if (mDeleteDialog != null) { mDeleteDialog.setListener(this); }/*from w ww . ja va2s . c o m*/ mClassLayout = (LinearLayout) view.findViewById(R.id.obs_detail_class); mClassSpinner = (Spinner) view.findViewById(R.id.obs_detail_class_spinner); mClassSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) { mQuestionLayout.setVisibility(View.GONE); mTestLayout.setVisibility(View.GONE); mFindingLayout.setVisibility(View.GONE); mSymptomLayout.setVisibility(View.GONE); switch (pos) { case Constants.CLASS_QUESTION: mQuestionLayout.setVisibility(View.VISIBLE); break; case Constants.CLASS_TEST: mTestLayout.setVisibility(View.VISIBLE); break; case Constants.CLASS_FINDING: mFindingLayout.setVisibility(View.VISIBLE); break; case Constants.CLASS_SYMPTOM: mSymptomLayout.setVisibility(View.VISIBLE); break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mQuestionLayout = (LinearLayout) view.findViewById(R.id.obs_detail_question); mQuestionTextView = (EditText) view.findViewById(R.id.obs_detail_question_text); mTestLayout = (LinearLayout) view.findViewById(R.id.obs_detail_test); mTestConceptView = (Spinner) view.findViewById(R.id.obs_detail_test_concept); mTestConceptView.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) { ListViewItem item = (ListViewItem) parent.getItemAtPosition(pos); mTestUnitView.setText(item.getField2()); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mTestUnitView = (TextView) view.findViewById(R.id.obs_detail_test_unit); mTestValueView = (EditText) view.findViewById(R.id.obs_detail_test_value); mFindingLayout = (LinearLayout) view.findViewById(R.id.obs_detail_finding); mFindingValueCodedView = (AutoCompleteTextView) view.findViewById(R.id.obs_detail_finding_value_coded); mFindingValueCodedView.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!findingCodeBlock) { findingCode = -1; } findingCodeBlock = false; searchFindings(s.toString().trim()); } }); mFindingValueCodedView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listView, View view, int position, long id) { findingCode = (int) id; } }); mFindingCertaintyView = (CheckBox) view.findViewById(R.id.obs_detail_finding_certainty); mFindingSeverityCodedView = (CheckBox) view.findViewById(R.id.obs_detail_finding_severity_coded); mSymptomLayout = (LinearLayout) view.findViewById(R.id.obs_detail_symptom); mSymptomValueView = (AutoCompleteTextView) view.findViewById(R.id.obs_detail_symptom_value); mSymptomValueView.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!symptomCodeBlock) { symptomCode = -1; } symptomCodeBlock = false; searchSymptoms(s.toString().trim()); } }); mSymptomValueView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listView, View view, int position, long id) { symptomCode = (int) id; } }); // Restore UI from saved instance or load data. if (savedInstanceState != null) { findingCode = savedInstanceState.getInt(ARG_FINDING_CODE); symptomCode = savedInstanceState.getInt(ARG_SYMPTOM_CODE); mObs = (Obs) savedInstanceState.getSerializable(ARG_OBS); if (mObs != null) { mTestConcepts = savedInstanceState.getParcelableArrayList(ARG_TEST_CONCEPTS); ArrayAdapter<ListViewItem> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, mTestConcepts); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mTestConceptView.setAdapter(adapter); restoreView(); } } else { findingCode = -1; symptomCode = -1; loadObs(); } return view; }
From source file:com.bitants.wally.fragments.SearchFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_search, container, false); if (rootView != null) { super.onCreateView(rootView); quickReturnBackground = rootView.findViewById(R.id.quick_return_protective_background); quickReturnView = rootView.findViewById(R.id.quick_return_view); quickReturnEditTextClearButton = (ImageButton) rootView.findViewById(R.id.quick_return_edittext_clear); quickReturnEditTextClearButton.setOnClickListener(new View.OnClickListener() { @Override/*w w w. jav a 2s. co m*/ public void onClick(View v) { if (quickReturnEditText != null) { query = ""; quickReturnEditText.setText(""); quickReturnEditText.performClick(); showKeyboard(quickReturnEditText); } } }); quickReturnEditText = (EditText) rootView.findViewById(R.id.quick_return_edittext); quickReturnEditText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { quickReturnEditText.setCursorVisible(true); restoreQuickReturnView(); } }); quickReturnEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { return search(); } return false; } }); quickReturnEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!TextUtils.isEmpty(s)) { quickReturnEditTextClearButton.setVisibility(View.VISIBLE); } else { quickReturnEditTextClearButton.setVisibility(View.GONE); } } @Override public void afterTextChanged(Editable s) { } }); gridView.setOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); float currentTranslationY = quickReturnView.getTranslationY(); float maxTranslationY = quickReturnHeight; float newTranslationY = currentTranslationY + -dy; if (newTranslationY > 0) { newTranslationY = 0; } else if (newTranslationY < -maxTranslationY) { newTranslationY = -maxTranslationY; } quickReturnView.setTranslationY(newTranslationY); float percent = (-maxTranslationY) / 100.0f; float currentPercent = 100 - (newTranslationY / percent); quickReturnBackground.setAlpha(currentPercent / 100); quickReturnBackground.setTranslationY(newTranslationY); } }); colorPickerButton = rootView.findViewById(R.id.quick_return_color_picker); colorPickerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showColorPickerDialog(); } }); colorTagCard = rootView.findViewById(R.id.search_color_card); colorTagTextView = (TextView) rootView.findViewById(R.id.search_color_textview); colorTagTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showColorPickerDialog(); } }); colorTagClearButton = (ImageButton) rootView.findViewById(R.id.search_color_button_clear); colorTagClearButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { colorTagCard.setVisibility(View.GONE); colorPickerButton.setVisibility(View.VISIBLE); currentColor = null; query = quickReturnEditText.getText().toString(); gridView.setAdapter(null); showLoader(); getImages(1, query); } }); setupAutoSizeGridView(); if (savedInstanceState != null && savedInstanceState.containsKey(STATE_IMAGES)) { query = savedInstanceState.getString(STATE_QUERY, ""); Message msgObj = uiHandler.obtainMessage(); msgObj.what = MSG_IMAGES_REQUEST_CREATE; msgObj.arg1 = 1; msgObj.obj = savedInstanceState.getParcelableArrayList(STATE_IMAGES); uiHandler.sendMessage(msgObj); currentColor = savedInstanceState.getString(STATE_COLOR); if (currentColor != null) { int backgroundColor = Color.parseColor("#" + currentColor); int textColor = savedInstanceState.getInt(STATE_COLOR_TEXT); colorizeColorTag(backgroundColor, textColor, textColor, currentColor); colorTagCard.setVisibility(View.VISIBLE); colorPickerButton.setVisibility(View.GONE); } currentPage = savedInstanceState.getInt(STATE_CURRENT_PAGE); } ((MainActivity) getActivity()).addOnFileChangedListener(this); ((MainActivity) getActivity()).addOnFiltersChangedListener(this); } return rootView; }
From source file:com.musenkishi.wally.fragments.SearchFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_search, container, false); if (rootView != null) { super.onCreateView(rootView); quickReturnBackground = rootView.findViewById(R.id.quick_return_protective_background); quickReturnView = rootView.findViewById(R.id.quick_return_view); quickReturnEditTextClearButton = (ImageButton) rootView.findViewById(R.id.quick_return_edittext_clear); quickReturnEditTextClearButton.setOnClickListener(new View.OnClickListener() { @Override/*from ww w . j a va 2 s . c o m*/ public void onClick(View v) { if (quickReturnEditText != null) { query = ""; quickReturnEditText.setText(""); quickReturnEditText.performClick(); showKeyboard(quickReturnEditText); } } }); quickReturnEditText = (EditText) rootView.findViewById(R.id.quick_return_edittext); quickReturnEditText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { quickReturnEditText.setCursorVisible(true); quickReturnView.animate().translationY(0.0f).setDuration(300) .setInterpolator(new EaseInOutBezierInterpolator()).start(); quickReturnBackground.animate().translationY(0.0f).alpha(1.0f).setDuration(300) .setInterpolator(new EaseInOutBezierInterpolator()).start(); } }); quickReturnEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { return search(); } return false; } }); quickReturnEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!TextUtils.isEmpty(s)) { quickReturnEditTextClearButton.setVisibility(View.VISIBLE); } else { quickReturnEditTextClearButton.setVisibility(View.GONE); } } @Override public void afterTextChanged(Editable s) { } }); gridView.setOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); float currentTranslationY = quickReturnView.getTranslationY(); float maxTranslationY = quickReturnHeight; float newTranslationY = currentTranslationY + -dy; if (newTranslationY > 0) { newTranslationY = 0; } else if (newTranslationY < -maxTranslationY) { newTranslationY = -maxTranslationY; } quickReturnView.setTranslationY(newTranslationY); float percent = (-maxTranslationY) / 100.0f; float currentPercent = 100 - (newTranslationY / percent); quickReturnBackground.setAlpha(currentPercent / 100); quickReturnBackground.setTranslationY(newTranslationY); } }); colorPickerButton = rootView.findViewById(R.id.quick_return_color_picker); colorPickerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showColorPickerDialog(); } }); colorTagCard = rootView.findViewById(R.id.search_color_card); colorTagTextView = (TextView) rootView.findViewById(R.id.search_color_textview); colorTagTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showColorPickerDialog(); } }); colorTagClearButton = (ImageButton) rootView.findViewById(R.id.search_color_button_clear); colorTagClearButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { colorTagCard.setVisibility(View.GONE); colorPickerButton.setVisibility(View.VISIBLE); currentColor = null; query = quickReturnEditText.getText().toString(); gridView.setAdapter(null); showLoader(); getImages(1, query); } }); setupAutoSizeGridView(); if (savedInstanceState != null && savedInstanceState.containsKey(STATE_IMAGES)) { query = savedInstanceState.getString(STATE_QUERY, ""); Message msgObj = uiHandler.obtainMessage(); msgObj.what = MSG_IMAGES_REQUEST_CREATE; msgObj.arg1 = 1; msgObj.obj = savedInstanceState.getParcelableArrayList(STATE_IMAGES); uiHandler.sendMessage(msgObj); currentColor = savedInstanceState.getString(STATE_COLOR); if (currentColor != null) { int backgroundColor = Color.parseColor("#" + currentColor); int textColor = savedInstanceState.getInt(STATE_COLOR_TEXT); colorizeColorTag(backgroundColor, textColor, textColor, currentColor); colorTagCard.setVisibility(View.VISIBLE); colorPickerButton.setVisibility(View.GONE); } currentPage = savedInstanceState.getInt(STATE_CURRENT_PAGE); ((MainActivity) getActivity()).addOnFileChangedListener(this); ((MainActivity) getActivity()).addOnFiltersChangedListener(this); } } return rootView; }
From source file:com.tct.mail.compose.ComposeActivity.java
private int getShareAttachmentSize(Intent intent) { Bundle extras = intent.getExtras(); if (extras == null) { extras = Bundle.EMPTY;//w w w . j av a2 s .c om } final String action = intent.getAction(); int totalSize = 0; if (Intent.ACTION_SEND_MULTIPLE.equals(action)) { final ArrayList<Uri> uris = extras.getParcelableArrayList(Intent.EXTRA_STREAM); ArrayList<Attachment> attachments = new ArrayList<Attachment>(); for (Uri uri : uris) { if (uri == null) { continue; } try { if (handleSpecialAttachmentUri(uri)) { continue; } final Attachment a = mAttachmentsView.generateLocalAttachment(uri); //TS: rong-tang 2016-03-02 EMAIL BUGFIX-1712549 ADD_S if (a == null) { continue; } //TS: rong-tang 2016-03-02 EMAIL BUGFIX-1712549 ADD_E attachments.add(a); Analytics.getInstance().sendEvent("send_intent_attachment", Utils.normalizeMimeType(a.getContentType()), null, a.size); } catch (AttachmentFailureException e) { LogUtils.e(LOG_TAG, e, "Error adding attachment"); String maxSize = AttachmentUtils.convertToHumanReadableSize(getApplicationContext(), mAccount.settings.getMaxAttachmentSize()); showErrorToast(getString(R.string.generic_attachment_problem, maxSize)); } } // TS: zhaotianyong 2015-05-08 EMAIL BUGFIX_988459 MOD_S totalSize += addAttachments(attachments, false); // TS: zhaotianyong 2015-05-08 EMAIL BUGFIX_988459 MOD_E } else { final Uri uri = extras.getParcelable(Intent.EXTRA_STREAM); if (uri != null) { long size = 0; //[BUGFIX]-Modified-BEGIN by TCTNJ.wenlu.wu,12/03/2014,PR-857886 if (!handleSpecialAttachmentUri(uri)) { new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { try { Attachment mAttachment = mAttachmentsView.generateLocalAttachment(uri); android.os.Message msg = new android.os.Message(); msg.what = ADD_ATTACHMENT_MSG; msg.obj = mAttachment; mHandler.sendMessage(msg); } catch (AttachmentFailureException e) { LogUtils.e(LOG_TAG, e, "Error adding attachment"); // TS: jian.xu 2016-01-11 EMAIL BUGFIX-1307962 MOD_S //Note: show toast must be on ui thread. android.os.Message errorMsg = new android.os.Message(); errorMsg.what = ADD_ATTACHMENT_MSG_ERROR; errorMsg.obj = e.getErrorRes(); mHandler.sendMessage(errorMsg); //showAttachmentTooBigToast(e.getErrorRes()); // TS: jian.xu 2016-01-11 EMAIL BUGFIX-1307962 MOD_E } return null; } @Override protected void onPostExecute(Void result) { } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } //[BUGFIX]-Modified-END by TCTNJ.wenlu.wu,12/03/2014,PR-857886 totalSize += size; } } return totalSize; }