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.fairphone.fplauncher3.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 va2s  . c o  m
public Folder(Context context, AttributeSet attrs) {
    super(context, attrs);

    mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);

    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);
}

From source file:com.achep.acdisplay.Config.java

/**
 * Loads saved values from shared preferences.
 * This is called on {@link App app's} create.
 *//*from   w  w w.  j  a  v a 2s .  c  o m*/
void init(@NonNull Context context) {
    mListeners = new ArrayList<>(6);

    Resources res = context.getResources();
    SharedPreferences prefs = getSharedPreferences(context);
    mAcDisplayEnabled = prefs.getBoolean(KEY_ENABLED, res.getBoolean(R.bool.config_default_enabled));
    mKeyguardEnabled = prefs.getBoolean(KEY_KEYGUARD, res.getBoolean(R.bool.config_default_keyguard_enabled));
    mActiveMode = prefs.getBoolean(KEY_ACTIVE_MODE, res.getBoolean(R.bool.config_default_active_mode_enabled));
    mActiveModeWithoutNotifies = prefs.getBoolean(KEY_ACTIVE_MODE_WITHOUT_NOTIFICATIONS,
            res.getBoolean(R.bool.config_default_active_mode_without_notifies_enabled));

    // notifications
    mNotifyLowPriority = prefs.getBoolean(KEY_NOTIFY_LOW_PRIORITY,
            res.getBoolean(R.bool.config_default_notify_low_priority));
    mNotifyWakeUpOn = prefs.getBoolean(KEY_NOTIFY_WAKE_UP_ON,
            res.getBoolean(R.bool.config_default_notify_wake_up_on));

    // timeout
    mTimeoutNormal = prefs.getInt(KEY_TIMEOUT_NORMAL, res.getInteger(R.integer.config_default_timeout_normal));
    mTimeoutShort = prefs.getInt(KEY_TIMEOUT_SHORT, res.getInteger(R.integer.config_default_timeout_short));

    // inactive time
    mInactiveTimeFrom = prefs.getInt(KEY_INACTIVE_TIME_FROM,
            res.getInteger(R.integer.config_default_inactive_time_from));
    mInactiveTimeTo = prefs.getInt(KEY_INACTIVE_TIME_TO,
            res.getInteger(R.integer.config_default_inactive_time_to));
    mInactiveTimeEnabled = prefs.getBoolean(KEY_INACTIVE_TIME_ENABLED,
            res.getBoolean(R.bool.config_default_inactive_time_enabled));

    // interface
    mUiWallpaper = prefs.getBoolean(KEY_UI_WALLPAPER_SHOWN,
            res.getBoolean(R.bool.config_default_ui_show_wallpaper));
    mUiWallpaperShadow = prefs.getBoolean(KEY_UI_SHADOW_TOGGLE,
            res.getBoolean(R.bool.config_default_ui_show_shadow));
    mUiDynamicBackground = prefs.getInt(KEY_UI_DYNAMIC_BACKGROUND_MODE,
            res.getInteger(R.integer.config_default_ui_show_shadow_dynamic_bg));
    mUiMirroredTimeoutBar = prefs.getBoolean(KEY_UI_MIRRORED_TIMEOUT_BAR,
            res.getBoolean(R.bool.config_default_ui_mirrored_timeout_bar));
    mUiNotifyCircledIcon = prefs.getBoolean(KEY_UI_NOTIFY_CIRCLED_ICON,
            res.getBoolean(R.bool.config_default_ui_notify_circled_icon));
    mUiBatterySticky = prefs.getBoolean(KEY_UI_STATUS_BATTERY_STICKY,
            res.getBoolean(R.bool.config_default_ui_status_battery_sticky));
    mUiFullScreen = prefs.getBoolean(KEY_UI_FULLSCREEN, res.getBoolean(R.bool.config_default_ui_full_screen));
    mUiUnlockAnimation = prefs.getBoolean(KEY_UI_UNLOCK_ANIMATION,
            res.getBoolean(R.bool.config_default_ui_unlock_animation));
    mUiIconSize = prefs.getInt(KEY_UI_ICON_SIZE, res.getInteger(R.integer.config_default_ui_icon_size_dp));

    // development
    mDevSensorsDump = prefs.getBoolean(KEY_DEV_SENSORS_DUMP,
            res.getBoolean(R.bool.config_default_dev_sensors_dump));

    // other
    mEnabledOnlyWhileCharging = prefs.getBoolean(KEY_ONLY_WHILE_CHARGING,
            res.getBoolean(R.bool.config_default_enabled_only_while_charging));
    mScreenOffAfterLastNotify = prefs.getBoolean(KEY_FEEL_SCREEN_OFF_AFTER_LAST_NOTIFY,
            res.getBoolean(R.bool.config_default_feel_screen_off_after_last_notify));
    mFeelWidgetPinnable = prefs.getBoolean(KEY_FEEL_WIDGET_PINNABLE,
            res.getBoolean(R.bool.config_default_feel_widget_pinnable));
    mFeelWidgetReadable = prefs.getBoolean(KEY_FEEL_WIDGET_READABLE,
            res.getBoolean(R.bool.config_default_feel_widget_readable));

    // triggers
    mTrigHelpRead = prefs.getBoolean(KEY_TRIG_HELP_READ, false);
    mTrigTranslated = prefs.getBoolean(KEY_TRIG_TRANSLATED, false);
    mTrigPreviousVersion = prefs.getInt(KEY_TRIG_PREVIOUS_VERSION, 0);
}

From source file:com.syncedsynapse.kore2.ui.AlbumDetailsFragment.java

/**
 * Display the album details//w ww. j  a  v  a  2 s .c om
 *
 * @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);

    int year = cursor.getInt(AlbumDetailsQuery.YEAR);
    String genres = cursor.getString(AlbumDetailsQuery.GENRE);
    String label = (year > 0)
            ? (!TextUtils.isEmpty(genres) ? genres + "  |  " + String.valueOf(year) : String.valueOf(year))
            : genres;
    mediaYear.setText(label);

    double rating = cursor.getDouble(AlbumDetailsQuery.RATING);
    if (rating > 0) {
        mediaRating.setVisibility(View.VISIBLE);
        mediaMaxRating.setVisibility(View.VISIBLE);
        mediaRating.setText(String.format("%01.01f", rating));
        mediaMaxRating.setText(getString(R.string.max_rating_music));
    } 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(0, R.drawable.ic_expand_less_white_24dp);
        final int iconExpandResId = styledAttributes.getResourceId(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;
    if (!TextUtils.isEmpty(fanart)) {
        int posterWidth = resources.getDimensionPixelOffset(R.dimen.albumdetail_poster_width);
        int posterHeight = resources.getDimensionPixelOffset(R.dimen.albumdetail_poster_heigth);
        mediaPoster.setVisibility(View.VISIBLE);
        UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, poster, albumTitle, mediaPoster,
                posterWidth, posterHeight);
        UIUtils.loadImageIntoImageview(hostManager, fanart, mediaArt, artWidth, artHeight);
    } else {
        // No fanart, just present the poster
        mediaPoster.setVisibility(View.GONE);
        UIUtils.loadImageIntoImageview(hostManager, poster, mediaArt, artWidth, artHeight);
        // Reset padding
        int paddingLeft = mediaTitle.getPaddingRight(), paddingRight = mediaTitle.getPaddingRight(),
                paddingTop = mediaTitle.getPaddingTop(), paddingBottom = mediaTitle.getPaddingBottom();
        mediaTitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
        mediaUndertitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
    }
}

From source file:net.czlee.debatekeeper.DebatingActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_debate);

    mLeftControlButton = (Button) findViewById(R.id.mainScreen_leftControlButton);
    mLeftCentreControlButton = (Button) findViewById(R.id.mainScreen_leftCentreControlButton);
    mCentreControlButton = (Button) findViewById(R.id.mainScreen_centreControlButton);
    mRightControlButton = (Button) findViewById(R.id.mainScreen_rightControlButton);
    mPlayBellButton = (Button) findViewById(R.id.mainScreen_playBellButton);

    ///*from  w w w.j a va  2  s.  co m*/
    // ViewPager
    mViewPager = (EnableableViewPager) findViewById(R.id.mainScreen_debateTimerViewPager);
    mViewPager.setAdapter(new DebateTimerDisplayPagerAdapter());
    mViewPager.addOnPageChangeListener(new DebateTimerDisplayOnPageChangeListener());
    mViewPager.setPageMargin(1);
    mViewPager.setPageMarginDrawable(R.drawable.divider);

    //
    // OnClickListeners
    mPlayBellButton.setOnClickListener(new PlayBellButtonOnClickListener());

    mLastStateBundle = savedInstanceState; // This could be null

    //
    // Find the style file name
    String filename = loadXmlFileName();

    // If there doesn't appear to be an existing style selected, then start
    // the Activity to select the style immediately, and don't bother with the
    // rest.
    if (filename == null) {
        Intent getStyleIntent = new Intent(DebatingActivity.this, FormatChooserActivity.class);
        startActivityForResult(getStyleIntent, CHOOSE_STYLE_REQUEST);
    }

    //
    // Start the timer service
    Intent intent = new Intent(this, DebatingTimerService.class);
    startService(intent);
    bindService(intent, mConnection, Context.BIND_AUTO_CREATE);

    //
    // If there's been an update, show the changelog.
    SharedPreferences prefs = getPreferences(MODE_PRIVATE);
    Resources res = getResources();
    int thisChangelogVersion = res.getInteger(R.integer.changelogDialog_versionCode);
    int lastChangelogVersionShown = prefs.getInt(LAST_CHANGELOG_VERSION_SHOWN, 0);
    if (lastChangelogVersionShown < thisChangelogVersion) {
        if (isFirstInstall()) {
            // Don't show on the dialog on first install, but take note of the version.
            Editor editor = prefs.edit();
            editor.putInt(LAST_CHANGELOG_VERSION_SHOWN, thisChangelogVersion);
            editor.apply();
        } else {
            // The dialog will update the preference to the new version code.
            showDialog(new DialogChangelogFragment(), DIALOG_TAG_CHANGELOG);
        }
    }
}

From source file:com.phonemetra.turbo.launcher.AsyncTaskCallback.java

@Override
protected void init() {
    super.init();
    mCenterPagesVertically = false;//from   w w  w .  j  av a 2  s  .  co  m

    Context context = getContext();
    Resources r = context.getResources();
    mCameraDistance = (int) CAMERA_DISTANCE;//r.getInteger(R.integer.config_cameraDistance);
    setDragSlopeThreshold(r.getInteger(R.integer.config_appsCustomizeDragSlopeThreshold) / 100f);
    mOverviewModeShrinkFactor = r.getInteger(R.integer.config_workspaceOverviewShrinkPercentage) / 100.0f;
    mOverviewModePageOffset = r.getDimensionPixelSize(R.dimen.overview_mode_page_offset);

    setMinScale(mOverviewModeShrinkFactor - 0.2f);
}

From source file:com.android.systemui.qs.QSDragPanel.java

public void updateResources() {
    final Resources res = mContext.getResources();
    final int columns = Math.max(1, res.getInteger(R.integer.quick_settings_num_columns));
    mCellHeight = res.getDimensionPixelSize(R.dimen.qs_tile_height);
    mCellWidth = (int) (mCellHeight * TILE_ASPECT);
    mLargeCellHeight = res.getDimensionPixelSize(R.dimen.qs_dual_tile_height);
    mLargeCellWidth = (int) (mLargeCellHeight * TILE_ASPECT);
    mPanelPaddingBottom = res.getDimensionPixelSize(R.dimen.qs_panel_padding_bottom);
    mDualTileUnderlap = res.getDimensionPixelSize(R.dimen.qs_dual_tile_padding_vertical);
    mBrightnessPaddingTop = res.getDimensionPixelSize(R.dimen.qs_brightness_padding_top);
    mPageIndicatorHeight = res.getDimensionPixelSize(R.dimen.qs_panel_page_indicator_height);
    if (mColumns != columns) {
        mColumns = columns;// w w w  . j  av  a 2  s  .  c  o m
        if (isLaidOut())
            postInvalidate();
    }
    if (isLaidOut()) {
        for (TileRecord r : mRecords) {
            r.tile.clearState();
        }
        updateDetailText();
        mQsPanelTop.updateResources();
        if (mListening) {
            refreshAllTiles();
        }
    }
}

From source file:com.androzic.MapFragment.java

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    Resources resources = getResources();
    if (getString(R.string.pref_wakelock).equals(key)) {
        keepScreenOn = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_wakelock));
        map.setKeepScreenOn(keepScreenOn);
    } else if (getString(R.string.pref_showdistance_int).equals(key)) {
        showDistance = Integer.parseInt(sharedPreferences.getString(key, getString(R.string.def_showdistance)));
    } else if (getString(R.string.pref_hidemapinfo).equals(key)) {
        mapInfoHideDelay = Integer.parseInt(sharedPreferences.getString(key, "2147483647"));
    } else if (getString(R.string.pref_hidesatinfo).equals(key)) {
        satInfoHideDelay = Integer.parseInt(sharedPreferences.getString(key, "2147483647"));
    } else if (getString(R.string.pref_hidenavinfo).equals(key)) {
        navInfoHideDelay = Integer.parseInt(sharedPreferences.getString(key, "2147483647"));
    } else if (getString(R.string.pref_maprenderinterval).equals(key)) {
        updatePeriod = sharedPreferences.getInt(key, resources.getInteger(R.integer.def_maprenderinterval))
                * 100;/*from www.j a  v  a2  s. c o  m*/
    } else if (getString(R.string.pref_mapfollowonloc).equals(key)) {
        followOnLocation = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapfollowonloc));
    } else if (getString(R.string.pref_mapdiminterval).equals(key)) {
        dimInterval = sharedPreferences.getInt(key, resources.getInteger(R.integer.def_mapdiminterval)) * 1000;
    } else if (getString(R.string.pref_mapdimvalue).equals(key)) {
        dimValue = sharedPreferences.getInt(key, resources.getInteger(R.integer.def_mapdimvalue));
    } else if (getString(R.string.pref_mapdim).equals(key)) {
        autoDim = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapdim));
        dimScreen();
    } else if (getString(R.string.pref_unfollowontap).equals(key)) {
        map.setStrictUnfollow(
                !sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_unfollowontap)));
    } else if (getString(R.string.pref_lookahead).equals(key)) {
        map.setLookAhead(sharedPreferences.getInt(key, resources.getInteger(R.integer.def_lookahead)));
    } else if (getString(R.string.pref_mapbest).equals(key)) {
        map.setBestMapEnabled(sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapbest)));
    } else if (getString(R.string.pref_mapbestinterval).equals(key)) {
        map.setBestMapInterval(
                sharedPreferences.getInt(key, resources.getInteger(R.integer.def_mapbestinterval)) * 1000);
    } else if (getString(R.string.pref_scalebarbg).equals(key)) {
        map.setDrawScaleBarBackground(
                sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_scalebarbg)));
    } else if (getString(R.string.pref_scalebarcolor).equals(key)) {
        map.setScaleBarColor(sharedPreferences.getInt(key, resources.getColor(R.color.scalebar)));
    } else if (getString(R.string.pref_scalebarbgcolor).equals(key)) {
        map.setScaleBarBackgroundColor(sharedPreferences.getInt(key, resources.getColor(R.color.scalebarbg)));
    } else if (getString(R.string.pref_hidemapcross).equals(key)) {
        int delay = Integer.parseInt(sharedPreferences.getString(key, "5"));
        map.setCrossCursorHideDelay(delay);
    } else if (getString(R.string.pref_mapcrosscolor).equals(key)) {
        map.setCrossColor(sharedPreferences.getInt(key, resources.getColor(R.color.mapcross)));
    } else if (getString(R.string.pref_cursorvector).equals(key)
            || getString(R.string.pref_cursorvectormlpr).equals(key)) {
        map.setCursorVector(
                Integer.parseInt(sharedPreferences.getString(getString(R.string.pref_cursorvector),
                        getString(R.string.def_cursorvector))),
                sharedPreferences.getInt(getString(R.string.pref_cursorvectormlpr),
                        resources.getInteger(R.integer.def_cursorvectormlpr)));
    } else if (getString(R.string.pref_cursorcolor).equals(key)) {
        map.setCursorColor(sharedPreferences.getInt(key, resources.getColor(R.color.cursor)));
    } else if (getString(R.string.pref_navigation_proximity).equals(key)) {
        map.setProximity(Integer
                .parseInt(sharedPreferences.getString(key, getString(R.string.def_navigation_proximity))));
    } else if (getString(R.string.pref_unitspeed).equals(key)) {
        speedUnit.setText(StringFormatter.speedAbbr);
    } else if (getString(R.string.pref_unitelevation).equals(key)) {
        elevationUnit.setText(StringFormatter.elevationAbbr);
    } else if (getString(R.string.pref_unitangle).equals(key)) {
        trackUnit.setText(StringFormatter.angleAbbr);
        bearingUnit.setText(StringFormatter.angleAbbr);
        turnUnit.setText(StringFormatter.angleAbbr);
    }
}

From source file:com.tct.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 www .j  a v a  2s . 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);
    // TS: zhaotianyong 2015-03-13 EMAIL BUGFIX-932165 ADD_S
    mWebView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            final int action = event.getActionMasked();
            if (action == MotionEvent.ACTION_UP && webViewScaleHasChanged) {
                mWebView.loadUrl(String.format("javascript:setConversationHeaderSpacerHeight(%s);",
                        mCovHeaderHeight * mWebView.getInitialScale() / mWebView.getScale()));
                if (mAdapter.getMessageHeaderItem() != null) {
                    mWebView.loadUrl(String.format("javascript:setMessageHeaderSpacerHeight('%s', %s);",
                            mTemplates.getMessageDomId(mAdapter.getMessageHeaderItem().getMessage()),
                            mMsgHeaderHeight * mWebView.getInitialScale() / mWebView.getScale()));
                }
                mWebView.loadUrl(String.format("javascript:setConversationFooterSpacerHeight(%s);",
                        mCovFooterHegiht * mWebView.getInitialScale() / mWebView.getScale()));
                webViewScaleHasChanged = false;
            }
            return mWebView.onTouchEvent(event);
        }
    });
    // TS: zhaotianyong 2015-03-13 EMAIL BUGFIX-932165 ADD_E

    //TS: tao.gan 2015-09-10 EMAIL FEATURE-559891 ADD_S
    mFabButton.setAccountController(this);
    //Because we can't get the webview's contentHeight when onPageFinished(),so set the PictureListener
    //to get the contentHeight and judge if it's initialized bottom,and then do the animation.
    mWebView.setPictureListener(new PictureListener() {
        int previousHeight;

        @Deprecated
        public void onNewPicture(WebView w, Picture picture) {
            // TODO Auto-generated method stub
            int height = w.getContentHeight();
            if (previousHeight == height)
                return;
            previousHeight = height;
            if (mWebView.isInitializedBottom()) {
                mWebView.animateBottom(true);
            } else {
                mWebView.animateHideFooter();
            }
        }
    });
    //TS: tao.gan 2015-09-10 EMAIL FEATURE-559891 ADD_E
    // 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();
    //[BUGFIX]-Add-BEGIN?by?TSCD.zheng.zou,01/14/2015,887972
    //[Email]It?still?display?download?remaining?when?rotate?the?screen?during?loading
    //note:use initLoader to reconnect with the previous loader.
    if (savedInstanceState != null) {
        mIsDownloadingRemaining = savedInstanceState.getBoolean(IS_DOWNLOADING_REMAINING);
        mIsPopDownloadRemain = savedInstanceState.getBoolean(IS_POP_DOWNLOAD_REMAIN);
    }
    LoaderManager lm = getLoaderManager();
    if (lm.getLoader(LOADER_DOWNLOAD_REMAINING) != null) {
        lm.initLoader(LOADER_DOWNLOAD_REMAINING, null, mDownloadRemainCallback);
    }
    //[BUGFIX]-Add-END?by?TSCD.zheng.zou
}

From source file:com.android.leanlauncher.Workspace.java

public void animateWidgetDrop(ItemInfo info, CellLayout cellLayout, DragView dragView,
        final Runnable onCompleteRunnable, int animationType, final View finalView, boolean external) {
    Rect from = new Rect();
    mLauncher.getDragLayer().getViewRectRelativeToSelf(dragView, from);

    int[] finalPos = new int[2];
    float scaleXY[] = new float[2];
    getFinalPositionForDropAnimation(finalPos, scaleXY, dragView, cellLayout, info, mTargetCell, external,
            true);/*from   www.  j  a va  2s .c  o m*/

    Resources res = mLauncher.getResources();
    final int duration = res.getInteger(R.integer.config_dropAnimMaxDuration) - 200;

    // In the case where we've prebound the widget, we remove it from the DragLayer
    if (finalView instanceof AppWidgetHostView && external) {
        Log.d(TAG, "6557954 Animate widget drop, final view is appWidgetHostView");
        mLauncher.getDragLayer().removeView(finalView);
    }
    if ((animationType == ANIMATE_INTO_POSITION_AND_RESIZE || external) && finalView != null) {
        Bitmap crossFadeBitmap = createWidgetBitmap(info, finalView);
        dragView.setCrossFadeBitmap(crossFadeBitmap);
        dragView.crossFade((int) (duration * 0.8f));
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET && external) {
        scaleXY[0] = scaleXY[1] = Math.min(scaleXY[0], scaleXY[1]);
    }

    DragLayer dragLayer = mLauncher.getDragLayer();
    if (animationType == CANCEL_TWO_STAGE_WIDGET_DROP_ANIMATION) {
        mLauncher.getDragLayer().animateViewIntoPosition(dragView, finalPos, 0f, 0.1f, 0.1f,
                DragLayer.ANIMATION_END_DISAPPEAR, onCompleteRunnable, duration);
    } else {
        int endStyle;
        if (animationType == ANIMATE_INTO_POSITION_AND_REMAIN) {
            endStyle = DragLayer.ANIMATION_END_REMAIN_VISIBLE;
        } else {
            endStyle = DragLayer.ANIMATION_END_DISAPPEAR;
        }

        Runnable onComplete = new Runnable() {
            @Override
            public void run() {
                if (finalView != null) {
                    finalView.setVisibility(VISIBLE);
                }
                if (onCompleteRunnable != null) {
                    onCompleteRunnable.run();
                }
            }
        };
        dragLayer.animateViewIntoPosition(dragView, from.left, from.top, finalPos[0], finalPos[1], 1, 1, 1,
                scaleXY[0], scaleXY[1], onComplete, endStyle, duration, this);
    }
}

From source file:com.android.mail.browse.ConversationItemViewCoordinates.java

private ConversationItemViewCoordinates(final Context context, final Config config,
        final CoordinatesCache cache) {
    Utils.traceBeginSection("CIV coordinates constructor");
    final Resources res = context.getResources();

    final int layoutId = R.layout.conversation_item_view;

    ViewGroup view = (ViewGroup) cache.getView(layoutId);
    if (view == null) {
        view = (ViewGroup) LayoutInflater.from(context).inflate(layoutId, null);
        cache.put(layoutId, view);/*from w  w  w.  j ava 2s . c  om*/
    }

    // Show/hide optional views before measure/layout call
    final TextView folders = (TextView) view.findViewById(R.id.folders);
    folders.setVisibility(config.areFoldersVisible() ? View.VISIBLE : View.GONE);

    View contactImagesView = view.findViewById(R.id.contact_image);

    switch (config.getGadgetMode()) {
    case GADGET_CONTACT_PHOTO:
        contactImagesView.setVisibility(View.VISIBLE);
        break;
    case GADGET_CHECKBOX:
        contactImagesView.setVisibility(View.GONE);
        contactImagesView = null;
        break;
    default:
        contactImagesView.setVisibility(View.GONE);
        contactImagesView = null;
        break;
    }

    final View replyState = view.findViewById(R.id.reply_state);
    replyState.setVisibility(config.isReplyStateVisible() ? View.VISIBLE : View.GONE);

    final View personalIndicator = view.findViewById(R.id.personal_indicator);
    personalIndicator.setVisibility(config.isPersonalIndicatorVisible() ? View.VISIBLE : View.GONE);

    setFramePadding(context, view, config.useFullPadding());

    // Layout the appropriate view.
    ViewCompat.setLayoutDirection(view, config.getLayoutDirection());
    final int widthSpec = MeasureSpec.makeMeasureSpec(config.getWidth(), MeasureSpec.EXACTLY);
    final int heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);

    view.measure(widthSpec, heightSpec);
    view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());

    // Once the view is measured, let's calculate the dynamic width variables.
    folderLayoutWidth = (int) (view.getWidth() * res.getInteger(R.integer.folder_max_width_proportion) / 100.0);
    folderCellWidth = (int) (view.getWidth() * res.getInteger(R.integer.folder_cell_max_width_proportion)
            / 100.0);

    //        Utils.dumpViewTree((ViewGroup) view);

    // Records coordinates.

    // Contact images view
    if (contactImagesView != null) {
        contactImagesWidth = contactImagesView.getWidth();
        contactImagesHeight = contactImagesView.getHeight();
        contactImagesX = getX(contactImagesView);
        contactImagesY = getY(contactImagesView);
    } else {
        contactImagesX = contactImagesY = contactImagesWidth = contactImagesHeight = 0;
    }

    final boolean isRtl = ViewUtils.isViewRtl(view);

    final View star = view.findViewById(R.id.star);
    final int starPadding = res.getDimensionPixelSize(R.dimen.conv_list_star_padding_start);
    starX = getX(star) + (isRtl ? 0 : starPadding);
    starY = getY(star);
    starWidth = star.getWidth();

    final TextView senders = (TextView) view.findViewById(R.id.senders);
    final int sendersTopAdjust = getLatinTopAdjustment(senders);
    sendersX = getX(senders);
    sendersY = getY(senders) + sendersTopAdjust;
    sendersWidth = senders.getWidth();
    sendersHeight = senders.getHeight();
    sendersLineCount = SINGLE_LINE;
    sendersFontSize = senders.getTextSize();

    final TextView subject = (TextView) view.findViewById(R.id.subject);
    final int subjectTopAdjust = getLatinTopAdjustment(subject);
    subjectX = getX(subject);
    subjectY = getY(subject) + subjectTopAdjust;
    subjectWidth = subject.getWidth();
    subjectHeight = subject.getHeight();
    subjectFontSize = subject.getTextSize();

    final TextView snippet = (TextView) view.findViewById(R.id.snippet);
    final int snippetTopAdjust = getLatinTopAdjustment(snippet);
    snippetX = getX(snippet);
    snippetY = getY(snippet) + snippetTopAdjust;
    maxSnippetWidth = snippet.getWidth();
    snippetHeight = snippet.getHeight();
    snippetFontSize = snippet.getTextSize();

    if (config.areFoldersVisible()) {
        foldersLeft = getX(folders);
        foldersRight = foldersLeft + folders.getWidth();
        foldersY = getY(folders);
        foldersTypeface = folders.getTypeface();
        foldersFontSize = folders.getTextSize();
    } else {
        foldersLeft = 0;
        foldersRight = 0;
        foldersY = 0;
        foldersTypeface = null;
        foldersFontSize = 0;
    }

    final View colorBlock = view.findViewById(R.id.color_block);
    if (config.isColorBlockVisible() && colorBlock != null) {
        colorBlockX = getX(colorBlock);
        colorBlockY = getY(colorBlock);
        colorBlockWidth = colorBlock.getWidth();
        colorBlockHeight = colorBlock.getHeight();
    } else {
        colorBlockX = colorBlockY = colorBlockWidth = colorBlockHeight = 0;
    }

    if (config.isReplyStateVisible()) {
        replyStateX = getX(replyState);
        replyStateY = getY(replyState);
    } else {
        replyStateX = replyStateY = 0;
    }

    if (config.isPersonalIndicatorVisible()) {
        personalIndicatorX = getX(personalIndicator);
        personalIndicatorY = getY(personalIndicator);
    } else {
        personalIndicatorX = personalIndicatorY = 0;
    }

    final View infoIcon = view.findViewById(R.id.info_icon);
    infoIconX = getX(infoIcon);
    infoIconXRight = infoIconX + infoIcon.getWidth();
    infoIconY = getY(infoIcon);

    final TextView date = (TextView) view.findViewById(R.id.date);
    dateX = getX(date);
    dateXRight = dateX + date.getWidth();
    dateY = getY(date);
    datePaddingStart = ViewUtils.getPaddingStart(date);
    dateFontSize = date.getTextSize();
    dateYBaseline = dateY + getLatinTopAdjustment(date) + date.getBaseline();

    final View paperclip = view.findViewById(R.id.paperclip);
    paperclipY = getY(paperclip);
    paperclipPaddingStart = ViewUtils.getPaddingStart(paperclip);

    height = view.getHeight() + sendersTopAdjust;
    Utils.traceEndSection();
}