Example usage for android.content.res Resources getInteger

List of usage examples for android.content.res Resources getInteger

Introduction

In this page you can find the example usage for android.content.res Resources getInteger.

Prototype

public int getInteger(@IntegerRes int id) throws NotFoundException 

Source Link

Document

Return an integer associated with a particular resource ID.

Usage

From source file:com.android.launcher3.folder.Folder.java

/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attributes set containing the Workspace's customization values.
 *///  ww w  .  j av a  2 s . co  m
public Folder(Context context, AttributeSet attrs) {
    super(context, attrs);
    setAlwaysDrawnWithCacheEnabled(false);
    mInputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

    Resources res = getResources();
    mExpandDuration = res.getInteger(R.integer.config_folderExpandDuration);
    mMaterialExpandDuration = res.getInteger(R.integer.config_materialFolderExpandDuration);
    mMaterialExpandStagger = res.getInteger(R.integer.config_materialFolderExpandStagger);

    if (sDefaultFolderName == null) {
        sDefaultFolderName = res.getString(R.string.folder_name);
    }
    if (sHintText == null) {
        sHintText = res.getString(R.string.folder_hint_text);
    }
    mLauncher = Launcher.getLauncher(context);
    // We need this view to be focusable in touch mode so that when text editing of the folder
    // name is complete, we have something to focus on, thus hiding the cursor and giving
    // reliable behavior when clicking the text field (since it will always gain focus on click).
    setFocusableInTouchMode(true);
}

From source file:org.getlantern.firetweet.activity.support.ComposeActivity.java

private void updateMediaPreview() {
    final int count = mMediaPreviewAdapter.getCount();
    final Resources res = getResources();
    final int maxColumns = res.getInteger(R.integer.grid_column_image_preview);
    mMediaPreviewGrid.setNumColumns(MathUtils.clamp(count, maxColumns, 1));
}

From source file:com.wb.launcher3.Folder.java

/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attribtues set containing the Workspace's customization values.
 *///w  w w  .j a  va2  s .  c om
public Folder(Context context, AttributeSet attrs) {
    super(context, attrs);

    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    setAlwaysDrawnWithCacheEnabled(false);
    mInflater = LayoutInflater.from(context);
    mIconCache = app.getIconCache();

    Resources res = getResources();
    mMaxCountX = (int) grid.numColumns + 1;
    mMaxCountY = (int) grid.numRows;
    mMaxNumItems = mMaxCountX * mMaxCountY;

    mInputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

    mExpandDuration = res.getInteger(R.integer.config_folderAnimDuration);

    if (sDefaultFolderName == null) {
        sDefaultFolderName = res.getString(R.string.folder_name);
    }
    if (sHintText == null) {
        sHintText = res.getString(R.string.folder_hint_text);
    }
    mLauncher = (Launcher) context;
    // We need this view to be focusable in touch mode so that when text editing of the folder
    // name is complete, we have something to focus on, thus hiding the cursor and giving
    // reliable behvior when clicking the text field (since it will always gain focus on click).
    setFocusableInTouchMode(true);

}

From source file:com.tandong.sa.vpic.TitlePageIndicator.java

public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from  w w w . j a  v  a 2s. c o m*/

    // Load defaults from resources
    final Resources res = getResources();
    final int defaultFooterColor = res.getColor(context.getResources()
            .getIdentifier("default_title_indicator_footer_color", "color", context.getPackageName()));
    // final int defaultFooterColor = res
    // .getColor(R.color.default_title_indicator_footer_color);
    final float defaultFooterLineHeight = res.getDimension(context.getResources()
            .getIdentifier("default_title_indicator_footer_line_height", "dimen", context.getPackageName()));
    // final float defaultFooterLineHeight = res
    // .getDimension(R.dimen.default_title_indicator_footer_line_height);
    final int defaultFooterIndicatorStyle = res.getInteger(context.getResources().getIdentifier(
            "default_title_indicator_footer_indicator_style", "integer", context.getPackageName()));
    // final int defaultFooterIndicatorStyle = res
    // .getInteger(R.integer.default_title_indicator_footer_indicator_style);
    final float defaultFooterIndicatorHeight = res.getDimension(context.getResources().getIdentifier(
            "default_title_indicator_footer_indicator_height", "dimen", context.getPackageName()));
    // final float defaultFooterIndicatorHeight = res
    // .getDimension(R.dimen.default_title_indicator_footer_indicator_height);
    final float defaultFooterIndicatorUnderlinePadding = res.getDimension(context.getResources().getIdentifier(
            "default_title_indicator_footer_indicator_underline_padding", "dimen", context.getPackageName()));
    // final float defaultFooterIndicatorUnderlinePadding = res
    // .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding);
    final float defaultFooterPadding = res.getDimension(context.getResources()
            .getIdentifier("default_title_indicator_footer_padding", "dimen", context.getPackageName()));
    // final float defaultFooterPadding = res
    // .getDimension(R.dimen.default_title_indicator_footer_padding);
    final int defaultLinePosition = res.getInteger(context.getResources()
            .getIdentifier("default_title_indicator_line_position", "integer", context.getPackageName()));
    // final int defaultLinePosition = res
    // .getInteger(R.integer.default_title_indicator_line_position);
    final int defaultSelectedColor = res.getColor(context.getResources()
            .getIdentifier("default_title_indicator_selected_color", "color", context.getPackageName()));
    // final int defaultSelectedColor = res
    // .getColor(R.color.default_title_indicator_selected_color);
    final boolean defaultSelectedBold = res.getBoolean(context.getResources()
            .getIdentifier("default_title_indicator_selected_bold", "bool", context.getPackageName()));
    // final boolean defaultSelectedBold = res
    // .getBoolean(R.bool.default_title_indicator_selected_bold);
    final int defaultTextColor = res.getColor(context.getResources()
            .getIdentifier("default_title_indicator_text_color", "color", context.getPackageName()));
    // final int defaultTextColor = res
    // .getColor(R.color.default_title_indicator_text_color);
    final float defaultTextSize = res.getDimension(context.getResources()
            .getIdentifier("default_title_indicator_text_size", "dimen", context.getPackageName()));
    // final float defaultTextSize = res
    // .getDimension(R.dimen.default_title_indicator_text_size);
    final float defaultTitlePadding = res.getDimension(context.getResources()
            .getIdentifier("default_title_indicator_title_padding", "dimen", context.getPackageName()));
    // final float defaultTitlePadding = res
    // .getDimension(R.dimen.default_title_indicator_title_padding);
    final float defaultClipPadding = res.getDimension(context.getResources()
            .getIdentifier("default_title_indicator_clip_padding", "dimen", context.getPackageName()));
    // final float defaultClipPadding = res
    // .getDimension(R.dimen.default_title_indicator_clip_padding);
    final float defaultTopPadding = res.getDimension(context.getResources()
            .getIdentifier("default_title_indicator_top_padding", "dimen", context.getPackageName()));
    // final float defaultTopPadding = res
    // .getDimension(R.dimen.default_title_indicator_top_padding);

    // Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs,
            new int[] {
                    getResources().getIdentifier("TitlePageIndicator", "styleable", context.getPackageName()) },
            defStyle, 0);
    // TypedArray a = context.obtainStyledAttributes(attrs,
    // R.styleable.TitlePageIndicator, defStyle, 0);

    // Retrieve the colors to be used for this view and apply them.
    mFooterLineHeight = a.getDimension(getResources().getIdentifier("TitlePageIndicator_footerLineHeight",
            "styleable", context.getPackageName()), defaultFooterLineHeight);
    // mFooterLineHeight = a.getDimension(
    // R.styleable.TitlePageIndicator_footerLineHeight,
    // defaultFooterLineHeight);
    mFooterIndicatorStyle = IndicatorStyle
            .fromValue(a.getInteger(getResources().getIdentifier("TitlePageIndicator_footerIndicatorStyle",
                    "styleable", context.getPackageName()), defaultFooterIndicatorStyle));
    // mFooterIndicatorStyle = IndicatorStyle.fromValue(a.getInteger(
    // R.styleable.TitlePageIndicator_footerIndicatorStyle,
    // defaultFooterIndicatorStyle));
    mFooterIndicatorHeight = a.getDimension(getResources()
            .getIdentifier("TitlePageIndicator_footerIndicatorHeight", "styleable", context.getPackageName()),
            defaultFooterIndicatorHeight);
    // mFooterIndicatorHeight = a.getDimension(
    // R.styleable.TitlePageIndicator_footerIndicatorHeight,
    // defaultFooterIndicatorHeight);
    mFooterIndicatorUnderlinePadding = a
            .getDimension(getResources().getIdentifier("TitlePageIndicator_footerIndicatorUnderlinePadding",
                    "styleable", context.getPackageName()), defaultFooterIndicatorUnderlinePadding);
    // mFooterIndicatorUnderlinePadding = a.getDimension(
    // R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding,
    // defaultFooterIndicatorUnderlinePadding);
    mFooterPadding = a.getDimension(getResources().getIdentifier("TitlePageIndicator_footerPadding",
            "styleable", context.getPackageName()), defaultFooterPadding);
    // mFooterPadding = a.getDimension(
    // R.styleable.TitlePageIndicator_footerPadding,
    // defaultFooterPadding);
    mLinePosition = LinePosition
            .fromValue(a.getInteger(getResources().getIdentifier("TitlePageIndicator_linePosition", "styleable",
                    context.getPackageName()), defaultLinePosition));
    // mLinePosition = LinePosition.fromValue(a.getInteger(
    // R.styleable.TitlePageIndicator_linePosition,
    // defaultLinePosition));
    mTopPadding = a.getDimension(getResources().getIdentifier("TitlePageIndicator_topPadding", "styleable",
            context.getPackageName()), defaultTopPadding);
    // mTopPadding =
    // a.getDimension(R.styleable.TitlePageIndicator_topPadding,
    // defaultTopPadding);
    mTitlePadding = a.getDimension(getResources().getIdentifier("TitlePageIndicator_titlePadding", "styleable",
            context.getPackageName()), defaultTitlePadding);
    // mTitlePadding = a.getDimension(
    // R.styleable.TitlePageIndicator_titlePadding,
    // defaultTitlePadding);
    mClipPadding = a.getDimension(getResources().getIdentifier("TitlePageIndicator_clipPadding", "styleable",
            context.getPackageName()), defaultClipPadding);
    // mClipPadding = a.getDimension(
    // R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
    mColorSelected = a.getColor(getResources().getIdentifier("TitlePageIndicator_selectedColor", "styleable",
            context.getPackageName()), defaultSelectedColor);
    // mColorSelected = a.getColor(
    // R.styleable.TitlePageIndicator_selectedColor,
    // defaultSelectedColor);
    mColorText = a.getColor(getResources().getIdentifier("TitlePageIndicator_android_textColor", "styleable",
            context.getPackageName()), defaultTextColor);
    // mColorText = a.getColor(
    // R.styleable.TitlePageIndicator_android_textColor,
    // defaultTextColor);
    mBoldText = a.getBoolean(getResources().getIdentifier("TitlePageIndicator_selectedBold", "styleable",
            context.getPackageName()), defaultSelectedBold);
    // mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold,
    // defaultSelectedBold);

    final float textSize = a.getDimension(getResources().getIdentifier("TitlePageIndicator_android_textSize",
            "styleable", context.getPackageName()), defaultTextSize);
    // final float textSize = a.getDimension(
    // R.styleable.TitlePageIndicator_android_textSize,
    // defaultTextSize);
    final int footerColor = a.getColor(getResources().getIdentifier("TitlePageIndicator_footerColor",
            "styleable", context.getPackageName()), defaultFooterColor);
    // final int footerColor = a.getColor(
    // R.styleable.TitlePageIndicator_footerColor, defaultFooterColor);
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);
    mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterLine.setStrokeWidth(mFooterLineHeight);
    mPaintFooterLine.setColor(footerColor);
    mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterIndicator.setColor(footerColor);

    Drawable background = a.getDrawable(getResources().getIdentifier("TitlePageIndicator_android_background",
            "styleable", context.getPackageName()));
    // Drawable background = a
    // .getDrawable(R.styleable.TitlePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.auratech.launcher.Folder.java

/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attribtues set containing the Workspace's customization values.
 *///  ww  w . j  a v a 2s .  c  o  m
public Folder(Context context, AttributeSet attrs) {
    super(context, attrs);

    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    setAlwaysDrawnWithCacheEnabled(false);
    mInflater = LayoutInflater.from(context);
    mIconCache = app.getIconCache();

    Resources res = getResources();
    mMaxCountX = (int) grid.numColumns;
    // Allow scrolling folders when DISABLE_ALL_APPS is true.
    if (LauncherAppState.isDisableAllApps()) {
        mMaxCountY = mMaxNumItems = Integer.MAX_VALUE;
    } else {
        mMaxCountY = (int) grid.numRows;
        mMaxNumItems = mMaxCountX * mMaxCountY;
    }

    mInputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

    mExpandDuration = res.getInteger(R.integer.config_folderAnimDuration);

    if (sDefaultFolderName == null) {
        sDefaultFolderName = res.getString(R.string.folder_name);
    }
    if (sHintText == null) {
        sHintText = res.getString(R.string.folder_hint_text);
    }
    mLauncher = (Launcher) context;
    // We need this view to be focusable in touch mode so that when text editing of the folder
    // name is complete, we have something to focus on, thus hiding the cursor and giving
    // reliable behvior when clicking the text field (since it will always gain focus on click).
    setFocusableInTouchMode(true);
}

From source file:org.xbmc.kore.ui.AlbumDetailsFragment.java

/**
 * Display the album details/*  ww w.j a v  a2  s. co  m*/
 *
 * @param cursor Cursor with the data
 */
private void displayAlbumDetails(Cursor cursor) {
    final Resources resources = getActivity().getResources();

    cursor.moveToFirst();
    albumTitle = cursor.getString(AlbumDetailsQuery.TITLE);
    albumDisplayArtist = cursor.getString(AlbumDetailsQuery.DISPLAYARTIST);
    mediaTitle.setText(albumTitle);
    mediaUndertitle.setText(albumDisplayArtist);

    setMediaYear(cursor.getString(AlbumDetailsQuery.GENRE), cursor.getInt(AlbumDetailsQuery.YEAR));

    double rating = cursor.getDouble(AlbumDetailsQuery.RATING);
    if (rating > 0) {
        mediaRating.setVisibility(View.VISIBLE);
        mediaMaxRating.setVisibility(View.VISIBLE);
        setMediaRating(rating);
    } else {
        mediaRating.setVisibility(View.GONE);
        mediaMaxRating.setVisibility(View.GONE);
    }

    String description = cursor.getString(AlbumDetailsQuery.DESCRIPTION);
    if (!TextUtils.isEmpty(description)) {
        mediaDescription.setVisibility(View.VISIBLE);
        mediaDescription.setText(description);
        final int maxLines = resources.getInteger(R.integer.description_max_lines);
        Resources.Theme theme = getActivity().getTheme();
        TypedArray styledAttributes = theme
                .obtainStyledAttributes(new int[] { R.attr.iconExpand, R.attr.iconCollapse });
        final int iconCollapseResId = styledAttributes.getResourceId(styledAttributes.getIndex(0),
                R.drawable.ic_expand_less_white_24dp);
        final int iconExpandResId = styledAttributes.getResourceId(styledAttributes.getIndex(1),
                R.drawable.ic_expand_more_white_24dp);
        styledAttributes.recycle();

        mediaDescriptionContainer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!isDescriptionExpanded) {
                    mediaDescription.setMaxLines(Integer.MAX_VALUE);
                    mediaShowAll.setImageResource(iconExpandResId);
                } else {
                    mediaDescription.setMaxLines(maxLines);
                    mediaShowAll.setImageResource(iconCollapseResId);
                }
                isDescriptionExpanded = !isDescriptionExpanded;
            }
        });
    } else {
        mediaDescriptionContainer.setVisibility(View.GONE);
    }

    // Images
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

    String fanart = cursor.getString(AlbumDetailsQuery.FANART),
            poster = cursor.getString(AlbumDetailsQuery.THUMBNAIL);

    int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height),
            artWidth = displayMetrics.widthPixels;
    int posterWidth = resources.getDimensionPixelOffset(R.dimen.albumdetail_poster_width);
    int posterHeight = resources.getDimensionPixelOffset(R.dimen.albumdetail_poster_heigth);
    UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, poster, albumTitle, mediaPoster,
            posterWidth, posterHeight);
    UIUtils.loadImageIntoImageview(hostManager, TextUtils.isEmpty(fanart) ? poster : fanart, mediaArt, artWidth,
            artHeight);
}

From source file:com.android.mail.ui.ConversationViewFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    LogUtils.d(LOG_TAG, "IN CVF.onActivityCreated, this=%s visible=%s", this, isUserVisible());
    super.onActivityCreated(savedInstanceState);

    if (mActivity == null || mActivity.isFinishing()) {
        // Activity is finishing, just bail.
        return;/*from w  ww . j a  va 2  s.  c o m*/
    }

    Context context = getContext();
    mTemplates = new HtmlConversationTemplates(context);

    final FormattedDateBuilder dateBuilder = new FormattedDateBuilder(context);

    mNavigationController = mActivity.getKeyboardNavigationController();

    mAdapter = new ConversationViewAdapter(mActivity, this, getLoaderManager(), this, this,
            getContactInfoSource(), this, this, getListController(), this, mAddressCache, dateBuilder,
            mBidiFormatter, this);
    mConversationContainer.setOverlayAdapter(mAdapter);

    // set up snap header (the adapter usually does this with the other ones)
    mConversationContainer.getSnapHeader().initialize(this, mAddressCache, this, getContactInfoSource(),
            mActivity.getAccountController().getVeiledAddressMatcher());

    final Resources resources = getResources();
    mMaxAutoLoadMessages = resources.getInteger(R.integer.max_auto_load_messages);

    mSideMarginPx = resources.getDimensionPixelOffset(R.dimen.conversation_message_content_margin_side);

    mUrlToMessageIdMap = new ArrayMap<String, String>();
    final InlineAttachmentViewIntentBuilderCreator creator = InlineAttachmentViewIntentBuilderCreatorHolder
            .getInlineAttachmentViewIntentCreator();
    final WebViewContextMenu contextMenu = new WebViewContextMenu(getActivity(), creator
            .createInlineAttachmentViewIntentBuilder(mAccount, mConversation != null ? mConversation.id : -1));
    contextMenu.setCallbacks(this);
    mWebView.setOnCreateContextMenuListener(contextMenu);

    // set this up here instead of onCreateView to ensure the latest Account is loaded
    setupOverviewMode();

    // Defer the call to initLoader with a Handler.
    // We want to wait until we know which fragments are present and their final visibility
    // states before going off and doing work. This prevents extraneous loading from occurring
    // as the ViewPager shifts about before the initial position is set.
    //
    // e.g. click on item #10
    // ViewPager.setAdapter() actually first loads #0 and #1 under the assumption that #0 is
    // the initial primary item
    // Then CPC immediately sets the primary item to #10, which tears down #0/#1 and sets up
    // #9/#10/#11.
    getHandler().post(new FragmentRunnable("showConversation", this) {
        @Override
        public void go() {
            showConversation();
        }
    });

    if (mConversation != null && mConversation.conversationBaseUri != null
            && !Utils.isEmpty(mAccount.accountCookieQueryUri)) {
        // Set the cookie for this base url
        new SetCookieTask(getContext(), mConversation.conversationBaseUri.toString(),
                mAccount.accountCookieQueryUri).execute();
    }

    // Find the height of the screen for manually scrolling the webview via keyboard.
    final Rect screen = new Rect();
    mActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(screen);
    mMaxScreenHeight = screen.bottom;
    mTopOfVisibleScreen = screen.top + mActivity.getSupportActionBar().getHeight();
}

From source file:com.android.launcher2.AsyncTaskCallback.java

@Override
protected void init() {
    super.init();
    mCenterPagesVertically = false;//from   w ww. j a v a  2  s  .  c  om

    Context context = getContext();
    Resources r = context.getResources();
    setDragSlopeThreshold(r.getInteger(R.integer.config_appsCustomizeDragSlopeThreshold) / 100f);
}

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();/*  ww w  .j a  va  2  s. 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:com.android.launcher3.Folder.java

/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attribtues set containing the Workspace's customization values.
 *///from   w  w  w  .j av a  2 s .  c o m
public Folder(Context context, AttributeSet attrs) {
    super(context, attrs);

    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    setAlwaysDrawnWithCacheEnabled(false);
    mInflater = LayoutInflater.from(context);
    mIconCache = app.getIconCache();

    Resources res = getResources();
    mMaxCountX = (int) grid.numColumns;
    // Allow scrolling folders when DISABLE_ALL_APPS is true.
    if (LauncherAppState.isDisableAllApps()) {
        mMaxCountY = mMaxNumItems = Integer.MAX_VALUE;
    } else {
        mMaxCountY = (int) grid.numRows;
        mMaxNumItems = mMaxCountX * mMaxCountY;
    }

    mInputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

    mExpandDuration = res.getInteger(R.integer.config_folderExpandDuration);
    mMaterialExpandDuration = res.getInteger(R.integer.config_materialFolderExpandDuration);
    mMaterialExpandStagger = res.getInteger(R.integer.config_materialFolderExpandStagger);

    if (sDefaultFolderName == null) {
        sDefaultFolderName = res.getString(R.string.folder_name);
    }
    if (sHintText == null) {
        sHintText = res.getString(R.string.folder_hint_text);
    }
    mLauncher = (Launcher) context;
    // We need this view to be focusable in touch mode so that when text editing of the folder
    // name is complete, we have something to focus on, thus hiding the cursor and giving
    // reliable behvior when clicking the text field (since it will always gain focus on click).
    setFocusableInTouchMode(true);
}