List of usage examples for android.os Bundle getParcelableArrayList
@Nullable public <T extends Parcelable> ArrayList<T> getParcelableArrayList(@Nullable String key)
From source file:com.keylesspalace.tusky.activity.ComposeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_compose); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);// ww w . j a va 2 s . c om ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(null); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); Drawable closeIcon = AppCompatResources.getDrawable(this, R.drawable.ic_close_24dp); ThemeUtils.setDrawableTint(this, closeIcon, R.attr.compose_close_button_tint); actionBar.setHomeAsUpIndicator(closeIcon); } SharedPreferences preferences = getSharedPreferences(getString(R.string.preferences_file_key), Context.MODE_PRIVATE); floatingBtn = (Button) findViewById(R.id.floating_btn); pickBtn = (ImageButton) findViewById(R.id.compose_photo_pick); nsfwBtn = (Button) findViewById(R.id.action_toggle_nsfw); ImageButton visibilityBtn = (ImageButton) findViewById(R.id.action_toggle_visibility); floatingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { sendStatus(); } }); pickBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onMediaPick(); } }); nsfwBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleNsfw(); } }); visibilityBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showComposeOptions(); } }); String startingVisibility; boolean startingHideText; ArrayList<SavedQueuedMedia> savedMediaQueued = null; if (savedInstanceState != null) { showMarkSensitive = savedInstanceState.getBoolean("showMarkSensitive"); startingVisibility = savedInstanceState.getString("statusVisibility"); statusMarkSensitive = savedInstanceState.getBoolean("statusMarkSensitive"); startingHideText = savedInstanceState.getBoolean("statusHideText"); // Keep these until everything needed to put them in the queue is finished initializing. savedMediaQueued = savedInstanceState.getParcelableArrayList("savedMediaQueued"); // These are for restoring an in-progress commit content operation. InputContentInfoCompat previousInputContentInfo = InputContentInfoCompat .wrap(savedInstanceState.getParcelable("commitContentInputContentInfo")); int previousFlags = savedInstanceState.getInt("commitContentFlags"); if (previousInputContentInfo != null) { onCommitContentInternal(previousInputContentInfo, previousFlags); } } else { showMarkSensitive = false; startingVisibility = preferences.getString("rememberedVisibility", "public"); statusMarkSensitive = false; startingHideText = false; } updateNsfwButtonColor(); Intent intent = getIntent(); String[] mentionedUsernames = null; inReplyToId = null; if (intent != null) { inReplyToId = intent.getStringExtra("in_reply_to_id"); String replyVisibility = intent.getStringExtra("reply_visibility"); if (replyVisibility != null && startingVisibility != null) { // Lowest possible visibility setting in response if (startingVisibility.equals("private") || replyVisibility.equals("private")) { startingVisibility = "private"; } else if (startingVisibility.equals("unlisted") || replyVisibility.equals("unlisted")) { startingVisibility = "unlisted"; } else { startingVisibility = replyVisibility; } } mentionedUsernames = intent.getStringArrayExtra("mentioned_usernames"); } /* Only after the starting visibility is determined and the send button is initialised can * the status visibility be set. */ setStatusVisibility(startingVisibility); textEditor = createEditText(null); // new String[] { "image/gif", "image/webp" } final int mentionColour = ThemeUtils.getColor(this, R.attr.compose_mention_color); if (savedInstanceState != null) { restoreTextEditorState(savedInstanceState.getParcelable("textEditorState")); highlightSpans(textEditor.getText(), mentionColour); } RelativeLayout editArea = (RelativeLayout) findViewById(R.id.compose_edit_area); /* Adding this at index zero because it implicitly gives it the lowest input priority. So, * when media previews are added in front of the editor, they can receive click events * without the text editor stealing the events from behind them. */ editArea.addView(textEditor, 0); contentWarningEditor = (EditText) findViewById(R.id.field_content_warning); final TextView charactersLeft = (TextView) findViewById(R.id.characters_left); textEditor.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { int left = STATUS_CHARACTER_LIMIT - s.length() - contentWarningEditor.length(); charactersLeft.setText(String.format(Locale.getDefault(), "%d", left)); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable editable) { highlightSpans(editable, mentionColour); } }); if (mentionedUsernames != null) { StringBuilder builder = new StringBuilder(); for (String name : mentionedUsernames) { builder.append('@'); builder.append(name); builder.append(' '); } textEditor.setText(builder); textEditor.setSelection(textEditor.length()); } mediaPreviewBar = (LinearLayout) findViewById(R.id.compose_media_preview_bar); mediaQueued = new ArrayList<>(); waitForMediaLatch = new CountUpDownLatch(); contentWarningBar = findViewById(R.id.compose_content_warning_bar); contentWarningEditor.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) { int left = STATUS_CHARACTER_LIMIT - s.length() - textEditor.length(); charactersLeft.setText(String.format(Locale.getDefault(), "%d", left)); } @Override public void afterTextChanged(Editable s) { } }); showContentWarning(startingHideText); statusAlreadyInFlight = false; // These can only be added after everything affected by the media queue is initialized. if (savedMediaQueued != null) { for (SavedQueuedMedia item : savedMediaQueued) { addMediaToQueue(item.type, item.preview, item.uri, item.mediaSize); } } }
From source file:de.vanita5.twittnuker.activity.support.ComposeActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { // requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mPreferences = SharedPreferencesWrapper.getInstance(this, SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); mBottomSendButton = mPreferences.getBoolean(KEY_BOTTOM_SEND_BUTTON, false); mTwitterWrapper = getTwittnukerApplication().getTwitterWrapper(); mResolver = getContentResolver();//w ww . j a v a 2s . co m mValidator = new TwidereValidator(this); setContentView(getLayoutInflater().inflate(R.layout.activity_compose, null)); setProgressBarIndeterminateVisibility(false); setFinishOnTouchOutside(false); mAccountIds = getAccountIds(this); if (mAccountIds.length <= 0) { final Intent intent = new Intent(INTENT_ACTION_TWITTER_LOGIN); intent.setClass(this, SignInActivity.class); startActivity(intent); finish(); return; } mBottomMenuBar.setIsBottomBar(true); mBottomMenuBar.setOnMenuItemClickListener(this); mActionMenuBar.setOnMenuItemClickListener(this); mEditText.setOnEditorActionListener(mPreferences.getBoolean(KEY_QUICK_SEND, false) ? this : null); mEditText.addTextChangedListener(this); mAccountSelectorAdapter = new AccountSelectorAdapter(this); mAccountSelector.setAdapter(mAccountSelectorAdapter); mAccountSelector.setOnItemClickListener(this); mAccountSelector.setOnItemLongClickListener(this); mAccountSelector.setScrollAfterItemClickEnabled(false); mAccountSelector.setScrollRightSpacingEnabled(false); mMediaPreviewAdapter = new MediaPreviewAdapter(this); mMediasPreviewGrid.setAdapter(mMediaPreviewAdapter); final Intent intent = getIntent(); if (savedInstanceState != null) { // Restore from previous saved state mSendAccountIds = savedInstanceState.getLongArray(EXTRA_ACCOUNT_IDS); mIsPossiblySensitive = savedInstanceState.getBoolean(EXTRA_IS_POSSIBLY_SENSITIVE); final ArrayList<ParcelableMediaUpdate> mediasList = savedInstanceState .getParcelableArrayList(EXTRA_MEDIAS); if (mediasList != null) { addMedias(mediasList); } 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); mTempPhotoUri = savedInstanceState.getParcelable(EXTRA_TEMP_URI); } else { // The activity 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); } if (mSendAccountIds == null || mSendAccountIds.length == 0) { final long[] ids_in_prefs = ArrayUtils .parseLongArray(mPreferences.getString(KEY_COMPOSE_ACCOUNTS, null), ','); final long[] intersection = ArrayUtils.intersection(ids_in_prefs, mAccountIds); mSendAccountIds = intersection.length > 0 ? intersection : mAccountIds; } mOriginalText = ParseUtils.parseString(mEditText.getText()); } if (!setComposeTitle(intent)) { setTitle(R.string.compose); } final boolean useBottomMenu = isSingleAccount() || !mBottomSendButton; if (useBottomMenu) { mBottomMenuBar.inflate(R.menu.menu_compose); } else { mActionMenuBar.inflate(R.menu.menu_compose); } mBottomMenuBar.setVisibility(useBottomMenu ? View.VISIBLE : View.GONE); mActionMenuBar.setVisibility(useBottomMenu ? View.GONE : View.VISIBLE); mSendView.setVisibility(mBottomSendButton ? View.GONE : View.VISIBLE); mBottomSendDivider.setVisibility(mBottomSendButton ? View.VISIBLE : View.GONE); mBottomSendView.setVisibility(mBottomSendButton ? View.VISIBLE : View.GONE); mSendView.setOnClickListener(this); mBottomSendView.setOnClickListener(this); mSendView.setOnLongClickListener(this); mBottomSendView.setOnLongClickListener(this); final LinearLayout.LayoutParams bottomMenuContainerParams = (LinearLayout.LayoutParams) mBottomMenuContainer .getLayoutParams(); final LinearLayout.LayoutParams accountSelectorParams = (LinearLayout.LayoutParams) mAccountSelector .getLayoutParams(); final int maxItemsShown; final Resources res = getResources(); if (isSingleAccount()) { accountSelectorParams.weight = 0; accountSelectorParams.width = ViewGroup.LayoutParams.WRAP_CONTENT; bottomMenuContainerParams.weight = 1; bottomMenuContainerParams.width = ViewGroup.LayoutParams.MATCH_PARENT; maxItemsShown = res.getInteger(R.integer.max_compose_menu_buttons_bottom_singleaccount); mAccountSelectorDivider.setVisibility(View.VISIBLE); } else { accountSelectorParams.weight = 1; accountSelectorParams.width = ViewGroup.LayoutParams.MATCH_PARENT; bottomMenuContainerParams.weight = 0; bottomMenuContainerParams.width = ViewGroup.LayoutParams.WRAP_CONTENT; maxItemsShown = res.getInteger(R.integer.max_compose_menu_buttons_bottom); mAccountSelectorDivider.setVisibility(mBottomSendButton ? View.GONE : View.VISIBLE); } mBottomMenuContainer.setLayoutParams(bottomMenuContainerParams); mBottomMenuBar.setMaxItemsShown(maxItemsShown); setMenu(); updateAccountSelection(); updateMediasPreview(); }
From source file:de.sourcestream.movieDB.controller.TVDetailsInfo.java
/** * Fired when are restoring from backState or orientation has changed. * * @param args our bundle with saved state. Our parent fragment handles the saving. *///from w w w . jav a 2s. c o m @SuppressWarnings("ConstantConditions") private void onOrientationChange(Bundle args) { // BackDrop path backDropCheck = args.getInt("backDropCheck"); if (backDropCheck == 0) { activity.setBackDropImage(backDropPath, args.getString("backDropUrl")); backDropPath.setTag(args.getString("backDropUrl")); } // Release date and title activity.setTextFromHtml(title, args.getString("titleText")); // Status activity.setText(statusText, args.getString("status")); // Type if (!args.getString("typeText").isEmpty()) activity.setText(typeText, args.getString("typeText")); else activity.hideView(typeText); // Episode runtime if (!args.getString("episodeRuntime").isEmpty()) activity.setText(episodeRuntime, args.getString("episodeRuntime")); else activity.hideView(episodeRuntime); // Number of episodes if (!args.getString("numberOfEpisodesText").isEmpty()) activity.setText(numberOfEpisodesText, args.getString("numberOfEpisodesText")); else activity.hideView(numberOfEpisodesText); // Number of seasons if (!args.getString("numberOfSeasonsText").isEmpty()) activity.setText(numberOfSeasonsText, args.getString("numberOfSeasonsText")); else activity.hideView(numberOfSeasonsText); // First air date if (!args.getString("firstAirDateText").isEmpty()) activity.setText(firstAirDateText, args.getString("firstAirDateText")); else activity.hideView(firstAirDateText); // Last air date if (!args.getString("lastAirDateText").isEmpty()) activity.setText(lastAirDateText, args.getString("lastAirDateText")); else activity.hideView(lastAirDateText); // Genres if (!args.getString("genres").isEmpty()) activity.setText(genres, args.getString("genres")); else activity.hideView(genres); // Production Countries if (!args.getString("productionCountries").isEmpty()) activity.setText(countries, args.getString("productionCountries")); else activity.hideView(countries); // Production Companies if (!args.getString("productionCompanies").isEmpty()) { activity.setText(companies, args.getString("productionCompanies")); if (args.getString("productionCountries").isEmpty()) { ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) companies.getLayoutParams(); lp.setMargins(0, (int) (28 * getResources().getDisplayMetrics().density), 0, 0); } } else activity.hideView(companies); // Poster path if (args.getString("posterPathURL") != null) { activity.setImage(posterPath, args.getString("posterPathURL")); activity.setImageTag(posterPath, args.getString("posterPathURL")); } // Rating if (args.getString("voteCount").isEmpty()) { activity.hideRatingBar(ratingBar); activity.hideTextView(voteCount); } else { ratingBar.setRating(args.getFloat("rating")); activity.setText(voteCount, args.getString("voteCount")); } // Similar list similarList = args.getParcelableArrayList("similarList"); if (similarList != null && similarList.size() > 0) setSimilarList(similarList); else activity.hideView(similarHolder); }
From source file:info.icefilms.icestream.browse.BrowseFragment.java
@SuppressWarnings("unchecked") @Override//w ww .ja v a2 s. c o m public void onActivityCreated(Bundle savedInstanceState) { // Call base class method super.onActivityCreated(savedInstanceState); // Save the views mHeadingLayout[0] = (LinearLayout) getActivity().findViewById(R.id.heading1_layout); mHeading[0] = (HorizontalListView) getActivity().findViewById(R.id.heading1); mHeadingLayout[1] = (LinearLayout) getActivity().findViewById(R.id.heading2_layout); mHeading[1] = (HorizontalListView) getActivity().findViewById(R.id.heading2); mHeadingLayout[2] = (LinearLayout) getActivity().findViewById(R.id.heading3_layout); mHeading[2] = (HorizontalListView) getActivity().findViewById(R.id.heading3); mDivider = (ImageView) getActivity().findViewById(R.id.divider); mList = (ListView) getActivity().findViewById(R.id.list); mRetryLayout = (LinearLayout) getActivity().findViewById(R.id.retry_layout); mRetryButton = (Button) getActivity().findViewById(R.id.retry_button); // Create the array adapters mHeadingAdapter = new ItemArrayAdapter[3]; for (int i = 0; i < mHeadingAdapter.length; ++i) mHeadingAdapter[i] = new ItemArrayAdapter(getActivity(), 0, mHeadingItems[i]); mListAdapter = new ItemArrayAdapter(getActivity(), 0, mListItems); // Set the list adapters for (int i = 0; i < mHeading.length; ++i) mHeading[i].setAdapter(mHeadingAdapter[i]); mList.setAdapter(mListAdapter); // Set the heading click listeners for (int i = 0; i < mHeading.length; ++i) mHeading[i].setOnItemClickListener(mHeadingListener); mList.setOnItemClickListener(mListListener); // Create or load certain items if (savedInstanceState == null && mStopParcel == null) { // Set the initial connection boolean and create the current location and // list scroll position lists mInitialConnection = true; mCurrentState = new LinkedList<State>(); Log.d("Ice Stream", "New current state list created."); } else if (savedInstanceState != null) { // Get the initial connection boolean and the current location list mInitialConnection = savedInstanceState.getBoolean("InitialConnection"); mCurrentState = new LinkedList<State>((Collection<? extends State>) Arrays .asList(savedInstanceState.getParcelableArray("CurrentState"))); Log.d("Ice Stream", "Loaded current state list from saved instance state bundle."); Log.d("Ice Stream", "Current state list contains " + mCurrentState.size() + " state(s)."); // Get the heading items lists for (int i = 0; i < mHeadingItems.length; ++i) { mHeadingItems[i].addAll((Collection<? extends Item>) savedInstanceState .getParcelableArrayList("Heading" + (i + 1) + "Items")); Log.d("Ice Stream", "Loaded " + mHeadingItems[i].size() + " heading items " + "from saved instance state bundle into heading " + (i + 1) + " items list."); mHeadingAdapter[i].notifyDataSetChanged(); } // Get the list items list mListItems.addAll((Collection<? extends Item>) savedInstanceState.getParcelableArrayList("ListItems")); Log.d("Ice Stream", "Loaded " + mListItems.size() + " list items from saved instance " + "state bundle into list items list."); mListAdapter.notifyDataSetChanged(); // Get the stop parcel from the saved instance state bundle mStopParcel = savedInstanceState.getParcelable("StopParcel"); } // Get the current state State state; if (mCurrentState.isEmpty()) { // Create a new location based on the passed URL URL url = (URL) getArguments().get("URL"); state = new State(Location.CreateLocationForItem(new HeadingItem(url))); } else { state = mCurrentState.getLast(); } // Load the state StartLoadStateTask(state); // Set the retry button click listener final State retryState = state; mRetryButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { StartLoadStateTask(retryState); } }); }
From source file:net.maa123.tatuky.ComposeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_compose); ButterKnife.bind(this); // Setup the toolbar. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);// w ww. jav a 2 s .c o m ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(null); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); Drawable closeIcon = AppCompatResources.getDrawable(this, R.drawable.ic_close_24dp); ThemeUtils.setDrawableTint(this, closeIcon, R.attr.compose_close_button_tint); actionBar.setHomeAsUpIndicator(closeIcon); } // Setup the interface buttons. floatingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onSendClicked(); } }); pickBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onMediaPick(); } }); takeBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { initiateCameraApp(); } }); nsfwBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleNsfw(); } }); visibilityBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showComposeOptions(); } }); /* Initialise all the state, or restore it from a previous run, to determine a "starting" * state. */ SharedPreferences preferences = getPrivatePreferences(); String startingVisibility; boolean startingHideText; String startingContentWarning = null; ArrayList<SavedQueuedMedia> savedMediaQueued = null; if (savedInstanceState != null) { showMarkSensitive = savedInstanceState.getBoolean("showMarkSensitive"); startingVisibility = savedInstanceState.getString("statusVisibility"); statusMarkSensitive = savedInstanceState.getBoolean("statusMarkSensitive"); startingHideText = savedInstanceState.getBoolean("statusHideText"); // Keep these until everything needed to put them in the queue is finished initializing. savedMediaQueued = savedInstanceState.getParcelableArrayList("savedMediaQueued"); // These are for restoring an in-progress commit content operation. InputContentInfoCompat previousInputContentInfo = InputContentInfoCompat .wrap(savedInstanceState.getParcelable("commitContentInputContentInfo")); int previousFlags = savedInstanceState.getInt("commitContentFlags"); if (previousInputContentInfo != null) { onCommitContentInternal(previousInputContentInfo, previousFlags); } } else { showMarkSensitive = false; startingVisibility = preferences.getString("rememberedVisibility", "public"); statusMarkSensitive = false; startingHideText = false; } /* If the composer is started up as a reply to another post, override the "starting" state * based on what the intent from the reply request passes. */ Intent intent = getIntent(); String[] mentionedUsernames = null; inReplyToId = null; if (intent != null) { inReplyToId = intent.getStringExtra("in_reply_to_id"); String replyVisibility = intent.getStringExtra("reply_visibility"); if (replyVisibility != null && startingVisibility != null) { // Lowest possible visibility setting in response if (startingVisibility.equals("direct") || replyVisibility.equals("direct")) { startingVisibility = "direct"; } else if (startingVisibility.equals("private") || replyVisibility.equals("private")) { startingVisibility = "private"; } else if (startingVisibility.equals("unlisted") || replyVisibility.equals("unlisted")) { startingVisibility = "unlisted"; } else { startingVisibility = replyVisibility; } } mentionedUsernames = intent.getStringArrayExtra("mentioned_usernames"); if (inReplyToId != null) { startingHideText = !intent.getStringExtra("content_warning").equals(""); if (startingHideText) { startingContentWarning = intent.getStringExtra("content_warning"); } } } /* If the currently logged in account is locked, its posts should default to private. This * should override even the reply settings, so this must be done after those are set up. */ if (preferences.getBoolean("loggedInAccountLocked", false)) { startingVisibility = "private"; } // After the starting state is finalised, the interface can be set to reflect this state. setStatusVisibility(startingVisibility); postProgress.setVisibility(View.INVISIBLE); updateNsfwButtonColor(); // Setup the main text field. setEditTextMimeTypes(null); // new String[] { "image/gif", "image/webp" } final int mentionColour = ThemeUtils.getColor(this, R.attr.compose_mention_color); SpanUtils.highlightSpans(textEditor.getText(), mentionColour); textEditor.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { updateVisibleCharactersLeft(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable editable) { SpanUtils.highlightSpans(editable, mentionColour); } }); // Add any mentions to the text field when a reply is first composed. if (mentionedUsernames != null) { StringBuilder builder = new StringBuilder(); for (String name : mentionedUsernames) { builder.append('@'); builder.append(name); builder.append(' '); } textEditor.setText(builder); textEditor.setSelection(textEditor.length()); } // Initialise the content warning editor. contentWarningEditor.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) { updateVisibleCharactersLeft(); } @Override public void afterTextChanged(Editable s) { } }); showContentWarning(startingHideText); if (startingContentWarning != null) { contentWarningEditor.setText(startingContentWarning); } // Initialise the empty media queue state. mediaQueued = new ArrayList<>(); waitForMediaLatch = new CountUpDownLatch(); statusAlreadyInFlight = false; // These can only be added after everything affected by the media queue is initialized. if (savedMediaQueued != null) { for (SavedQueuedMedia item : savedMediaQueued) { addMediaToQueue(item.type, item.preview, item.uri, item.mediaSize); } } else if (intent != null && savedInstanceState == null) { /* Get incoming images being sent through a share action from another app. Only do this * when savedInstanceState is null, otherwise both the images from the intent and the * instance state will be re-queued. */ String type = intent.getType(); if (type != null) { if (type.startsWith("image/")) { List<Uri> uriList = new ArrayList<>(); switch (intent.getAction()) { case Intent.ACTION_SEND: { Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (uri != null) { uriList.add(uri); } break; } case Intent.ACTION_SEND_MULTIPLE: { ArrayList<Uri> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (list != null) { for (Uri uri : list) { if (uri != null) { uriList.add(uri); } } } break; } } for (Uri uri : uriList) { long mediaSize = getMediaSize(getContentResolver(), uri); pickMedia(uri, mediaSize); } } else if (type.equals("text/plain")) { String action = intent.getAction(); if (action != null && action.equals(Intent.ACTION_SEND)) { String text = intent.getStringExtra(Intent.EXTRA_TEXT); if (text != null) { int start = Math.max(textEditor.getSelectionStart(), 0); int end = Math.max(textEditor.getSelectionEnd(), 0); int left = Math.min(start, end); int right = Math.max(start, end); textEditor.getText().replace(left, right, text, 0, text.length()); } } } } } }
From source file:com.fa.mastodon.activity.ComposeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_compose); ButterKnife.bind(this); // Setup the toolbar. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from w ww. j a va 2 s . co m*/ ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(null); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); Drawable closeIcon = AppCompatResources.getDrawable(this, R.drawable.ic_close_24dp); ThemeUtils.setDrawableTint(this, closeIcon, R.attr.compose_close_button_tint); actionBar.setHomeAsUpIndicator(closeIcon); } // Setup the interface buttons. floatingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onSendClicked(); } }); pickBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onMediaPick(); } }); takeBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { initiateCameraApp(); } }); nsfwBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleNsfw(); } }); visibilityBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showComposeOptions(); } }); /* Initialise all the state, or restore it from a previous run, to determine a "starting" * state. */ SharedPreferences preferences = getPrivatePreferences(); String startingVisibility; boolean startingHideText; String startingContentWarning = null; ArrayList<SavedQueuedMedia> savedMediaQueued = null; if (savedInstanceState != null) { showMarkSensitive = savedInstanceState.getBoolean("showMarkSensitive"); startingVisibility = savedInstanceState.getString("statusVisibility"); statusMarkSensitive = savedInstanceState.getBoolean("statusMarkSensitive"); startingHideText = savedInstanceState.getBoolean("statusHideText"); // Keep these until everything needed to put them in the queue is finished initializing. savedMediaQueued = savedInstanceState.getParcelableArrayList("savedMediaQueued"); // These are for restoring an in-progress commit content operation. InputContentInfoCompat previousInputContentInfo = InputContentInfoCompat .wrap(savedInstanceState.getParcelable("commitContentInputContentInfo")); int previousFlags = savedInstanceState.getInt("commitContentFlags"); if (previousInputContentInfo != null) { onCommitContentInternal(previousInputContentInfo, previousFlags); } } else { showMarkSensitive = false; startingVisibility = preferences.getString("rememberedVisibility", "public"); statusMarkSensitive = false; startingHideText = false; } /* If the composer is started up as a reply to another post, override the "starting" state * based on what the intent from the reply request passes. */ Intent intent = getIntent(); String[] mentionedUsernames = null; inReplyToId = null; if (intent != null) { inReplyToId = intent.getStringExtra("in_reply_to_id"); String replyVisibility = intent.getStringExtra("reply_visibility"); if (replyVisibility != null && startingVisibility != null) { // Lowest possible visibility setting in response if (startingVisibility.equals("private") || replyVisibility.equals("private")) { startingVisibility = "private"; } else if (startingVisibility.equals("unlisted") || replyVisibility.equals("unlisted")) { startingVisibility = "unlisted"; } else { startingVisibility = replyVisibility; } } mentionedUsernames = intent.getStringArrayExtra("mentioned_usernames"); if (inReplyToId != null) { startingHideText = !intent.getStringExtra("content_warning").equals(""); if (startingHideText) { startingContentWarning = intent.getStringExtra("content_warning"); } } } /* If the currently logged in account is locked, its posts should default to private. This * should override even the reply settings, so this must be done after those are set up. */ if (preferences.getBoolean("loggedInAccountLocked", false)) { startingVisibility = "private"; } // After the starting state is finalised, the interface can be set to reflect this state. setStatusVisibility(startingVisibility); postProgress.setVisibility(View.INVISIBLE); updateNsfwButtonColor(); // Setup the main text field. setEditTextMimeTypes(null); // new String[] { "image/gif", "image/webp" } final int mentionColour = ThemeUtils.getColor(this, R.attr.compose_mention_color); SpanUtils.highlightSpans(textEditor.getText(), mentionColour); textEditor.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { updateVisibleCharactersLeft(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable editable) { SpanUtils.highlightSpans(editable, mentionColour); } }); // Add any mentions to the text field when a reply is first composed. if (mentionedUsernames != null) { StringBuilder builder = new StringBuilder(); for (String name : mentionedUsernames) { builder.append('@'); builder.append(name); builder.append(' '); } textEditor.setText(builder); textEditor.setSelection(textEditor.length()); } // Initialise the content warning editor. contentWarningEditor.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) { updateVisibleCharactersLeft(); } @Override public void afterTextChanged(Editable s) { } }); showContentWarning(startingHideText); if (startingContentWarning != null) { contentWarningEditor.setText(startingContentWarning); } // Initialise the empty media queue state. mediaQueued = new ArrayList<>(); waitForMediaLatch = new CountUpDownLatch(); statusAlreadyInFlight = false; // These can only be added after everything affected by the media queue is initialized. if (savedMediaQueued != null) { for (SavedQueuedMedia item : savedMediaQueued) { addMediaToQueue(item.type, item.preview, item.uri, item.mediaSize); } } else if (intent != null && savedInstanceState == null) { /* Get incoming images being sent through a share action from another app. Only do this * when savedInstanceState is null, otherwise both the images from the intent and the * instance state will be re-queued. */ String type = intent.getType(); if (type != null) { if (type.startsWith("image/")) { List<Uri> uriList = new ArrayList<>(); switch (intent.getAction()) { case Intent.ACTION_SEND: { Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (uri != null) { uriList.add(uri); } break; } case Intent.ACTION_SEND_MULTIPLE: { ArrayList<Uri> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (list != null) { for (Uri uri : list) { if (uri != null) { uriList.add(uri); } } } break; } } for (Uri uri : uriList) { long mediaSize = getMediaSize(getContentResolver(), uri); pickMedia(uri, mediaSize); } } else if (type.equals("text/plain")) { String action = intent.getAction(); if (action != null && action.equals(Intent.ACTION_SEND)) { String text = intent.getStringExtra(Intent.EXTRA_TEXT); if (text != null) { int start = Math.max(textEditor.getSelectionStart(), 0); int end = Math.max(textEditor.getSelectionEnd(), 0); int left = Math.min(start, end); int right = Math.max(start, end); textEditor.getText().replace(left, right, text, 0, text.length()); } } } } } }
From source file:se.tmeit.app.ui.members.MemberInfoFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_member_info, container, false); Bundle args = getArguments(); TextView realNameText = (TextView) view.findViewById(R.id.member_real_name); realNameText.setText(args.getString(Member.Keys.REAL_NAME)); TextView usernameText = (TextView) view.findViewById(R.id.member_username); usernameText.setText(args.getString(Member.Keys.USERNAME)); TextView titleText = (TextView) view.findViewById(R.id.member_title); setTextWithPrefix(titleText, R.string.member_title, args.getString(Member.Keys.TITLE_TEXT)); TextView teamText = (TextView) view.findViewById(R.id.member_team); setTextWithPrefix(teamText, R.string.member_team, args.getString(Member.Keys.TEAM_TEXT)); ImageView imageView = (ImageView) view.findViewById(R.id.member_face); List<String> faces = args.getStringArrayList(Member.Keys.FACES); if (null != faces && !faces.isEmpty()) { mFaceHelper.picasso(faces).placeholder(R.drawable.member_placeholder).into(imageView); imageView.setOnClickListener(mOnImageClickedListener); } else {//from w w w . j a v a2s.co m imageView.setImageResource(R.drawable.member_placeholder); } final String email = args.getString(Member.Keys.EMAIL); Button emailButton = (Button) view.findViewById(R.id.member_button_email); if (!TextUtils.isEmpty(email)) { emailButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MemberActions.sendEmailTo(email, MemberInfoFragment.this); } }); emailButton.setEnabled(true); } else { emailButton.setEnabled(false); } final String phoneNo = args.getString(Member.Keys.PHONE); Button smsButton = (Button) view.findViewById(R.id.member_button_message); Button callButton = (Button) view.findViewById(R.id.member_button_call); if (!TextUtils.isEmpty(phoneNo)) { smsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MemberActions.sendSmsTo(phoneNo, MemberInfoFragment.this); } }); callButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MemberActions.makeCallTo(phoneNo, MemberInfoFragment.this); } }); smsButton.setEnabled(true); callButton.setEnabled(true); } else { smsButton.setEnabled(false); callButton.setEnabled(false); } setTextWithPrefixIfNotEmpty(view, R.id.member_flags, R.string.member_info, args.getString(Member.Keys.FLAGS)); setTextWithPrefixIfNotEmpty(view, R.id.member_prao, R.string.member_prao, args.getString(Member.Keys.DATE_PRAO)); setTextWithPrefixIfNotEmpty(view, R.id.member_marskalk, R.string.member_marskalk, args.getString(Member.Keys.DATE_MARSKALK)); setTextWithPrefixIfNotEmpty(view, R.id.member_vraq, R.string.member_vraq, args.getString(Member.Keys.DATE_VRAQ)); int experiencePoints = args.getInt(Member.Keys.EXPERIENCE_POINTS); TextView experienceText = (TextView) view.findViewById(R.id.member_experience); if (experiencePoints >= EXPERIENCE_MIN) { setTextWithPrefix(experienceText, R.string.member_exp, String.format(getString(R.string.member_points_format), experiencePoints)); experienceText.setVisibility(View.VISIBLE); } else { experienceText.setVisibility(View.GONE); } List<MemberBadge> experienceBadges = args.getParcelableArrayList(Member.Keys.EXPERIENCE_BADGES); LinearLayout badgesLayout = (LinearLayout) view.findViewById(R.id.member_badges); if (null != experienceBadges && !experienceBadges.isEmpty()) { initializeListOfBadges(badgesLayout, experienceBadges); } else { badgesLayout.setVisibility(View.GONE); } return view; }
From source file:org.gdg.frisbee.android.activity.MainActivity.java
/** * Called when the activity is first created. * @param savedInstanceState If the activity is being re-initialized after * previously being shut down then this Bundle contains the data it most * recently supplied in onSaveInstanceState(Bundle). <b>Note: Otherwise it is null.</b> *///from w w w. ja v a 2s . c om @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.i(LOG_TAG, "onCreate"); setContentView(R.layout.activity_main); mClient = new GroupDirectory(); mLocationComparator = new ChapterComparator(mPreferences); mIndicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int i, float v, int i2) { //To change body of implemented methods use File | Settings | File Templates. } @Override public void onPageSelected(int i) { Log.d(LOG_TAG, "onPageSelected()"); trackViewPagerPage(i); } @Override public void onPageScrollStateChanged(int i) { //To change body of implemented methods use File | Settings | File Templates. } }); mViewPagerAdapter = new MyAdapter(this, getSupportFragmentManager()); mSpinnerAdapter = new ChapterAdapter(MainActivity.this, android.R.layout.simple_list_item_1); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); getSupportActionBar().setListNavigationCallbacks(mSpinnerAdapter, MainActivity.this); mFetchChaptersTask = mClient.getDirectory(new Response.Listener<Directory>() { @Override public void onResponse(final Directory directory) { getSupportActionBar().setListNavigationCallbacks(mSpinnerAdapter, MainActivity.this); App.getInstance().getModelCache().putAsync("chapter_list", directory, DateTime.now().plusDays(1), new ModelCache.CachePutListener() { @Override public void onPutIntoCache() { ArrayList<Chapter> chapters = directory.getGroups(); initChapters(chapters); } }); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { Crouton.makeText(MainActivity.this, getString(R.string.fetch_chapters_failed), Style.ALERT).show(); Log.e(LOG_TAG, "Could'nt fetch chapter list", volleyError); } }); if (savedInstanceState == null) { if (Utils.isOnline(this)) { App.getInstance().getModelCache().getAsync("chapter_list", new ModelCache.CacheListener() { @Override public void onGet(Object item) { Directory directory = (Directory) item; initChapters(directory.getGroups()); } @Override public void onNotFound(String key) { mFetchChaptersTask.execute(); } }); } else { App.getInstance().getModelCache().getAsync("chapter_list", false, new ModelCache.CacheListener() { @Override public void onGet(Object item) { Directory directory = (Directory) item; initChapters(directory.getGroups()); } @Override public void onNotFound(String key) { Crouton.makeText(MainActivity.this, getString(R.string.offline_alert), Style.ALERT).show(); } }); } } else { if (savedInstanceState.containsKey("chapters")) { ArrayList<Chapter> chapters = savedInstanceState.getParcelableArrayList("chapters"); mSpinnerAdapter.clear(); mSpinnerAdapter.addAll(chapters); if (savedInstanceState.containsKey("selected_chapter")) { Chapter selectedChapter = savedInstanceState.getParcelable("selected_chapter"); selectChapter(selectedChapter); } else { mViewPagerAdapter.setSelectedChapter(chapters.get(0)); } mViewPager.setAdapter(mViewPagerAdapter); mIndicator.setViewPager(mViewPager); } else { mFetchChaptersTask.execute(); } } Intent intent = getIntent(); if (intent != null && intent.getAction() != null && intent.getAction().equals("finish_first_start")) { Log.d(LOG_TAG, "Completed FirstStartWizard"); if (mPreferences.getBoolean(Const.SETTINGS_SIGNED_IN, false)) { mFirstStart = true; } Chapter homeGdgd = getIntent().getParcelableExtra("selected_chapter"); getSupportActionBar().setSelectedNavigationItem(mSpinnerAdapter.getPosition(homeGdgd)); mViewPagerAdapter.setSelectedChapter(homeGdgd); } }
From source file:org.getlantern.firetweet.activity.support.ComposeActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { // requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mPreferences = SharedPreferencesWrapper.getInstance(this, SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); final FiretweetApplication app = FiretweetApplication.getInstance(this); mTwitterWrapper = app.getTwitterWrapper(); mResolver = getContentResolver();//from w ww.ja va 2 s . c om mValidator = new FiretweetValidator(this); mImageLoader = app.getMediaLoaderWrapper(); setContentView(R.layout.activity_compose); // setSupportProgressBarIndeterminateVisibility(false); setFinishOnTouchOutside(false); final long[] defaultAccountIds = 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.setIsBottomBar(true); mMenuBar.setOnMenuItemClickListener(this); mEditText.setOnEditorActionListener(mPreferences.getBoolean(KEY_QUICK_SEND, false) ? this : null); mEditText.addTextChangedListener(this); mEditText.setCustomSelectionActionModeCallback(this); 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)); 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); mTempPhotoUri = savedInstanceState.getParcelable(EXTRA_TEMP_URI); } 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 = FiretweetArrayUtils .parseLongArray(mPreferences.getString(KEY_COMPOSE_ACCOUNTS, null), ','); final long[] intersection = FiretweetArrayUtils.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); 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()) { addIntentToMenu(this, mediaMenuItem.getSubMenu(), imageExtensionsIntent, MENU_GROUP_IMAGE_EXTENSION); } setMenu(); updateLocationState(); updateMediaPreview(); notifyAccountSelectionChanged(); }
From source file:org.openhab.habdroid.ui.OpenHABMainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate()"); // Set default values, false means do it one time during the very first launch PreferenceManager.setDefaultValues(this, R.xml.preferences, false); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); // Set non-persistent HABDroid version preference to current version from application package try {//from ww w .j av a 2s.c o m Log.d(TAG, "App version = " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName); sharedPrefs.edit().putString(Constants.PREFERENCE_APPVERSION, getPackageManager().getPackageInfo(getPackageName(), 0).versionName).commit(); } catch (PackageManager.NameNotFoundException e1) { Log.d(TAG, e1.getMessage()); } checkDiscoveryPermissions(); checkVoiceRecognition(); // initialize loopj async http client mAsyncHttpClient = new MyAsyncHttpClient(this, sharedPrefs.getBoolean(Constants.PREFERENCE_SSLHOST, false), sharedPrefs.getBoolean(Constants.PREFERENCE_SSLCERT, false)); // 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 (!BuildConfig.IS_DEVELOPER) { Util.initCrittercism(getApplicationContext(), "5117659f59e1bd4ba9000004"); } Util.setActivityTheme(this); super.onCreate(savedInstanceState); if (!BuildConfig.IS_DEVELOPER) { ((HABDroid) getApplication()).getTracker(HABDroid.TrackerName.APP_TRACKER); } setContentView(R.layout.activity_main); setupToolbar(); setupDrawer(); gcmRegisterBackground(); setupPager(); MemorizingTrustManager.setResponder(this); // 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"); pagerAdapter.setOpenHABBaseUrl(openHABBaseUrl); } if (mSitemapList == null) { mSitemapList = new ArrayList<>(); } 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"); mNfcData = getIntent().getDataString(); } } } if (isFullscreenEnabled()) { registerReceiver(dreamReceiver, new IntentFilter("android.intent.action.DREAMING_STARTED")); registerReceiver(dreamReceiver, new IntentFilter("android.intent.action.DREAMING_STOPPED")); checkFullscreen(); } Api api = new Api(this); api.process(); }