当前位置: 首页>>代码示例>>Java>>正文


Java SharedPreferences.getInt方法代码示例

本文整理汇总了Java中android.content.SharedPreferences.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java SharedPreferences.getInt方法的具体用法?Java SharedPreferences.getInt怎么用?Java SharedPreferences.getInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.SharedPreferences的用法示例。


在下文中一共展示了SharedPreferences.getInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onConnected

import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
 * Callback of Google API, when GoogleApiHelper is connected.
 * If there's a highscore not pushed online, it pushes it.
 * @param bundle
 */
@Override
public void onConnected(Bundle bundle) {
    Log.d("##FULLSCREEN ACTIVITY", "connected");
    final SharedPreferences pref = this.getSharedPreferences("PREF", Context.MODE_PRIVATE);
    int needToSyncClassic = pref.getInt(Constants.NEED_TO_SYNC_CLASSIC, 0);
    int needToSyncHard = pref.getInt(Constants.NEED_TO_SYNC_HARD, 0);
    if(needToSyncClassic != 0){
        Games.Leaderboards.submitScoreImmediate(App.getGoogleApiHelper().getGoogleApiClient(),
                Constants.LEADERBOARD_CLASSIC_ID, pref.getInt(Constants.PREF_KEY_LEAD_CLASSIC, 0))
                .setResultCallback(new ClassicLeaderboardCallback());
    }
    if(needToSyncHard != 0){
        Games.Leaderboards.submitScoreImmediate(App.getGoogleApiHelper().getGoogleApiClient(),
                Constants.LEADERBOARD_CLASSIC_ID, pref.getInt(Constants.PREF_KEY_LEAD_CLASSIC, 0))
                .setResultCallback(new HardLeaderboardCallback());
    }
}
 
开发者ID:simoneapp,项目名称:S3-16-simone,代码行数:23,代码来源:FullscreenBaseGameActivity.java

示例2: weatherHasChanged

import android.content.SharedPreferences; //导入方法依赖的package包/类
public boolean weatherHasChanged(){

        float savedHighTemp;
        float savedLowTemp;
        int savedWeatherId;

        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
        savedHighTemp=sp.getFloat(HIGH_TEMP_KEY,DEFAULT_HIGH_TEMP);
        savedLowTemp=sp.getFloat(LOW_TEMP_KEY,DEFAULT_LOW_TEMP);
        savedWeatherId=sp.getInt(WEATHER_ID_KEY,DEFAULT_WEATHER_ID);

        if (savedHighTemp!=(float) mHighTemp){
            return true;
        }else if (savedLowTemp!=(float) mLowTemp){
            return true;
        }else if(savedWeatherId!=mWeatherIcon){
            return true;
        }else{
            return false;
        }


    }
 
开发者ID:gmontoya2483,项目名称:GoUbiquitous,代码行数:24,代码来源:WatchInterface.java

示例3: QuietHours

import android.content.SharedPreferences; //导入方法依赖的package包/类
public QuietHours(SharedPreferences prefs) {
    uncLocked = prefs.getBoolean(QuietHoursActivity.PREF_KEY_QH_LOCKED, false);
    enabled = prefs.getBoolean(QuietHoursActivity.PREF_KEY_QH_ENABLED, false);
    start = prefs.getInt(QuietHoursActivity.PREF_KEY_QH_START, 1380);
    end = prefs.getInt(QuietHoursActivity.PREF_KEY_QH_END, 360);
    startAlt = prefs.getInt(QuietHoursActivity.PREF_KEY_QH_START_ALT, 1380);
    endAlt = prefs.getInt(QuietHoursActivity.PREF_KEY_QH_END_ALT, 360);
    muteLED = prefs.getBoolean(QuietHoursActivity.PREF_KEY_QH_MUTE_LED, false);
    muteVibe = prefs.getBoolean(QuietHoursActivity.PREF_KEY_QH_MUTE_VIBE, true);
    muteSystemSounds = prefs.getStringSet(QuietHoursActivity.PREF_KEY_QH_MUTE_SYSTEM_SOUNDS,
            new HashSet<String>());
    showStatusbarIcon = prefs.getBoolean(QuietHoursActivity.PREF_KEY_QH_STATUSBAR_ICON, true);
    mode = Mode.valueOf(prefs.getString(QuietHoursActivity.PREF_KEY_QH_MODE, "AUTO"));
    interactive = prefs.getBoolean(QuietHoursActivity.PREF_KEY_QH_INTERACTIVE, false);
    weekDays = prefs.getStringSet(QuietHoursActivity.PREF_KEY_QH_WEEKDAYS,
            new HashSet<String>(Arrays.asList("2","3","4","5","6")));
    muteSystemVibe = prefs.getBoolean(QuietHoursActivity.PREF_KEY_MUTE_SYSTEM_VIBE, false);
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:19,代码来源:QuietHours.java

示例4: ShareDialogCell

import android.content.SharedPreferences; //导入方法依赖的package包/类
public ShareDialogCell(Context context) {
    super(context);
    setBackgroundResource(R.drawable.list_selector);

    imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(27));
    addView(imageView, LayoutHelper.createFrame(54, 54, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 7, 0, 0));
    SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
    int nColor = themePrefs.getInt("chatAttachTextColor", 0xff757575);
    nameTextView = new TextView(context);
    //nameTextView.setTextColor(0xff212121);
    nameTextView.setTextColor(nColor != 0xff757575 ? nColor : 0xff212121);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    nameTextView.setMaxLines(2);
    nameTextView.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
    nameTextView.setLines(2);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 6, 64, 6, 0));

    checkBox = new CheckBox(context, R.drawable.round_check2);
    checkBox.setSize(24);
    checkBox.setCheckOffset(AndroidUtilities.dp(1));
    checkBox.setVisibility(VISIBLE);
    checkBox.setColor(0xff3ec1f9);
    addView(checkBox, LayoutHelper.createFrame(24, 24, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 17, 39, 0, 0));
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:27,代码来源:ShareDialogCell.java

示例5: scheduleNotificationRepeat

import android.content.SharedPreferences; //导入方法依赖的package包/类
private void scheduleNotificationRepeat() {
    try {
        PendingIntent pintent = PendingIntent.getService(ApplicationLoader.applicationContext, 0, new Intent(ApplicationLoader.applicationContext, NotificationRepeat.class), 0);
        SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
        int minutes = preferences.getInt("repeat_messages", 60);
        if (minutes > 0 && personal_count > 0) {
            alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + minutes * 60 * 1000, pintent);
        } else {
            alarmManager.cancel(pintent);
        }
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:15,代码来源:NotificationsController.java

示例6: incrementChargingReminderCount

import android.content.SharedPreferences; //导入方法依赖的package包/类
synchronized public static void incrementChargingReminderCount(Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    int chargingReminders = prefs.getInt(KEY_CHARGING_REMINDER_COUNT, DEFAULT_COUNT);

    SharedPreferences.Editor editor = prefs.edit();
    editor.putInt(KEY_CHARGING_REMINDER_COUNT, ++chargingReminders);
    editor.apply();
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:9,代码来源:PreferenceUtilities.java

示例7: decrCount

import android.content.SharedPreferences; //导入方法依赖的package包/类
private void decrCount() {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    int pCount = sp.getInt(AD_COUNT, 0);
    pCount--;
    SharedPreferences.Editor editor = sp.edit();
    editor.putInt(AD_COUNT, pCount);
    editor.commit();
    d("dCount is "+pCount);
}
 
开发者ID:shivam301296,项目名称:True-Weather,代码行数:10,代码来源:AdBhai.java

示例8: getVideoProfileIndex

import android.content.SharedPreferences; //导入方法依赖的package包/类
private int getVideoProfileIndex() {
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    int profileIndex = pref.getInt(ConstantApp.PrefManager.PREF_PROPERTY_PROFILE_IDX, ConstantApp.DEFAULT_PROFILE_IDX);
    if (profileIndex > ConstantApp.VIDEO_PROFILES.length - 1) {
        profileIndex = ConstantApp.DEFAULT_PROFILE_IDX;

        // save the new value
        SharedPreferences.Editor editor = pref.edit();
        editor.putInt(ConstantApp.PrefManager.PREF_PROPERTY_PROFILE_IDX, profileIndex);
        editor.apply();
    }
    return profileIndex;
}
 
开发者ID:AgoraIO,项目名称:OpenVideoCall-Android,代码行数:14,代码来源:ChatActivity.java

示例9: needLayout

import android.content.SharedPreferences; //导入方法依赖的package包/类
private void needLayout() {
    FrameLayout.LayoutParams layoutParams;
    int newTop = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight();
    if (listView != null) {
        layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
        if (layoutParams.topMargin != newTop) {
            layoutParams.topMargin = newTop;
            listView.setLayoutParams(layoutParams);
            ViewProxy.setTranslationY(extraHeightView, newTop);
        }
    }

    if (avatarImage != null) {
        float diff = extraHeight / (float) AndroidUtilities.dp(88);
        ViewProxy.setScaleY(extraHeightView, diff);
        ViewProxy.setTranslationY(shadowView, newTop + extraHeight);


        final boolean setVisible = diff > 0.2f;
        SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
        int aSize = themePrefs.getInt("prefAvatarSize", 42);
        //ViewProxy.setScaleX(avatarImage, (42 + 18 * diff) / 42.0f);
        //ViewProxy.setScaleY(avatarImage, (42 + 18 * diff) / 42.0f);
        ViewProxy.setScaleX(avatarImage, (aSize + 18 * diff) / (aSize * 1.0f));
        ViewProxy.setScaleY(avatarImage, (aSize + 18 * diff) / (aSize * 1.0f));
        float avatarY = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() / 2.0f * (1.0f + diff) - 21 * AndroidUtilities.density + 27 * AndroidUtilities.density * diff;
        ViewProxy.setTranslationX(avatarImage, -AndroidUtilities.dp(47) * diff);
        ViewProxy.setTranslationY(avatarImage, (float) Math.ceil(avatarY));
        ViewProxy.setTranslationX(nameTextView, -21 * AndroidUtilities.density * diff);
        ViewProxy.setTranslationY(nameTextView, (float) Math.floor(avatarY) - (float) Math.ceil(AndroidUtilities.density) + (float) Math.floor(7 * AndroidUtilities.density * diff));
        ViewProxy.setTranslationX(onlineTextView, -21 * AndroidUtilities.density * diff);
        ViewProxy.setTranslationY(onlineTextView, (float) Math.floor(avatarY) + AndroidUtilities.dp(22) + (float) Math.floor(11 * AndroidUtilities.density) * diff);
        //ViewProxy.setTranslationX(statusTextView, -21 * AndroidUtilities.density * diff);
        //ViewProxy.setTranslationY(statusTextView, (float) Math.floor(avatarY) + AndroidUtilities.dp(32) + (float) Math.floor(22 * AndroidUtilities.density) * diff);
        ViewProxy.setScaleX(nameTextView, 1.0f + 0.12f * diff);
        ViewProxy.setScaleY(nameTextView, 1.0f + 0.12f * diff);
        //if (diff > 0.85) {
        //    statusTextView.setVisibility(View.VISIBLE);
        //} else {
        //    statusTextView.setVisibility(View.GONE);
        //}
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:44,代码来源:takSettings.java

示例10: updateHighscore

import android.content.SharedPreferences; //导入方法依赖的package包/类
@SuppressLint("SetTextI18n")
private void updateHighscore() {
    SharedPreferences prefs = getPreferences(MODE_PRIVATE);
    highscore = prefs.getInt("highscore", MODE_PRIVATE);
    txtHighscore.setText("High score: " + highscore);
}
 
开发者ID:pontusstjerna,项目名称:SnakeWear,代码行数:7,代码来源:MainActivity.java

示例11: onResume

import android.content.SharedPreferences; //导入方法依赖的package包/类
@Override
protected void onResume() {
    super.onResume();

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    boolean showBoundaryLines = preferences.getBoolean("boundary_lines", true);
    boolean anotherCenterColor = preferences.getBoolean("another_center_color", true);
    int wordColor = preferences.getInt("word_color", getResources().getColor(R.color.word_color_default));
    int centerLetterColor = preferences.getInt("center_letter_color", getResources().getColor(R.color.center_letter_color_default));
    int textSize = Integer.parseInt(preferences.getString("text_size", "20"));
    int boundaryLinesColor = preferences.getInt("boundary_lines_color", R.color.boundary_lines_color_default);
    int backgroundColor = preferences.getInt("background_color", getResources().getColor(R.color.white));
    int boundaryLines_thickness = Integer.parseInt(preferences.getString("boundary_lines_thickness", "2"));

    hideStatusBarForReading = preferences.getBoolean("hide_status_bar", false);
    //getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark));

    topManagePanel.setBackgroundColor(backgroundColor);
    readingPanel.setBackgroundColor(backgroundColor);
    if (isColorDark(backgroundColor)) {
        currentBookProgress.setTextColor(Color.WHITE);
        newSpeedOnPlaying.setTextColor(Color.WHITE);
    } else {
        currentBookProgress.setTextColor(Color.BLACK);
        newSpeedOnPlaying.setTextColor(Color.BLACK);
    }

    if (showBoundaryLines) {
        topBoundaryLine.setVisibility(View.VISIBLE);
        bottomBoundaryLine.setVisibility(View.VISIBLE);


        ViewGroup.LayoutParams params = topBoundaryLine.getLayoutParams();
        params.height = boundaryLines_thickness;
        topBoundaryLine.setLayoutParams(params);

        params = bottomBoundaryLine.getLayoutParams();
        params.height = boundaryLines_thickness;
        bottomBoundaryLine.setLayoutParams(params);


        topBoundaryLine.setBackgroundColor(boundaryLinesColor);
        bottomBoundaryLine.setBackgroundColor(boundaryLinesColor);
    } else {
        topBoundaryLine.setVisibility(View.GONE);
        bottomBoundaryLine.setVisibility(View.GONE);
    }

    currentWordLeftPart.setTextColor(wordColor);
    currentWordRightPart.setTextColor(wordColor);

    if (anotherCenterColor) {
        currentWordCenterPart.setTextColor(centerLetterColor);
    } else {
        currentWordCenterPart.setTextColor(wordColor);
    }

    currentWordLeftPart.setTextSize(textSize);
    currentWordCenterPart.setTextSize(textSize);
    currentWordRightPart.setTextSize(textSize);
}
 
开发者ID:pashkobohdan,项目名称:FastReading,代码行数:62,代码来源:CurrentBook.java

示例12: getInt

import android.content.SharedPreferences; //导入方法依赖的package包/类
public static int getInt(Context context, String key) {
    SharedPreferences sp = getSP(context);
    return sp.getInt(key, -1);
}
 
开发者ID:StableChen,项目名称:easynote,代码行数:5,代码来源:SPUtil.java

示例13: getInt

import android.content.SharedPreferences; //导入方法依赖的package包/类
public static int getInt(Context context, String key, int defValue) {
    SharedPreferences pref = PreferenceManager
            .getDefaultSharedPreferences(context.getApplicationContext());
    return pref.getInt(key, defValue);
}
 
开发者ID:ayounes3333,项目名称:GSB-2017-Android,代码行数:6,代码来源:PrefUtils.java

示例14: getChanceRemaining

import android.content.SharedPreferences; //导入方法依赖的package包/类
private int getChanceRemaining() {
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    return pref.getInt(KEY_CHANCE, MAX_CHANCE_VALUE);
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:5,代码来源:DecodeAllProcessTextActivity.java

示例15: getLastTimeControlCheckIndex

import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
 * Get the stored selected time control position in the time control list.
 *
 * @return position of the last selected time control in the list.
 */
public static int getLastTimeControlCheckIndex(Context context) {
    SharedPreferences sp = getSharedPreferences(context);
    int idx = sp.getInt(TIME_CONTROL_SELECTED_PREF_IDX, 0);
    return Math.max(idx, 0);
}
 
开发者ID:ChessCom,项目名称:android-chessclock,代码行数:11,代码来源:TimeControlParser.java


注:本文中的android.content.SharedPreferences.getInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。