Beispiel #1
0
 @Override
 protected void onPostExecute(String result) {
   // TODO Auto-generated method stub
   super.onPostExecute(result);
   if (pd != null && pd.isShowing()) pd.dismiss();
   if (result != null && result.equals("1")) {
     Log.d("check", result + "_");
     // if(upload!=null)
     uploadList = db.retriveUpload();
     for (Upload up : uploadList) {
       db.deleteUpload(up);
     }
     Editor edit = preference.edit();
     edit.putInt("upload", 2);
     edit.putInt("playMode", 2);
     edit.putString("activity", null);
     edit.clear();
     edit.commit();
     finish();
   } else {
     try {
       alert.showAlertDialog(home.this, "Error", "Unable to process server", true);
     } catch (Exception e) {
       // TODO: handle exception
       e.printStackTrace();
     }
   }
 }
  @Override
  public void onSortSelected(boolean always, int flags, int sort) {
    boolean manualSettingChanged =
        SortHelper.isManualSort(sortFlags) != SortHelper.isManualSort(flags);

    sortFlags = flags;
    sortSort = sort;

    if (always) {
      SharedPreferences publicPrefs = AstridPreferences.getPublicPrefs(ContextManager.getContext());
      if (publicPrefs != null) {
        Editor editor = publicPrefs.edit();
        if (editor != null) {
          editor.putInt(SortHelper.PREF_SORT_FLAGS, flags);
          editor.putInt(SortHelper.PREF_SORT_SORT, sort);
          editor.commit();
          TasksWidget.updateWidgets(ContextManager.getContext());
        }
      }
    }

    try {
      if (manualSettingChanged) toggleDragDrop(SortHelper.isManualSort(sortFlags));
      else setUpTaskList();
    } catch (IllegalStateException e) {
      // TODO: Fragment got detached somehow (rare)
    }
  }
  /** Save current audio mode in order to be able to restore it once done */
  @SuppressWarnings("deprecation")
  private synchronized void saveAudioState() {
    if (prefs.getBoolean("isSavedAudioState", false)) {
      // If we have already set, do not set it again !!!
      return;
    }
    ContentResolver ctntResolver = service.getContentResolver();

    Editor ed = prefs.edit();
    // ed.putInt("savedVibrateRing",
    // audioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER));
    // ed.putInt("savedVibradeNotif",
    // audioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION));
    // ed.putInt("savedRingerMode", audioManager.getRingerMode());
    ed.putInt(
        "savedWifiPolicy",
        android.provider.Settings.System.getInt(
            ctntResolver,
            android.provider.Settings.System.WIFI_SLEEP_POLICY,
            Settings.System.WIFI_SLEEP_POLICY_DEFAULT));

    int inCallStream = Compatibility.getInCallStream(userWantBluetooth);
    ed.putInt("savedVolume", audioManager.getStreamVolume(inCallStream));

    int targetMode = getAudioTargetMode();
    if (service.getPrefs().useRoutingApi()) {
      ed.putInt("savedRoute", audioManager.getRouting(targetMode));
    } else {
      ed.putBoolean("savedSpeakerPhone", audioManager.isSpeakerphoneOn());
    }
    ed.putInt("savedMode", audioManager.getMode());

    ed.putBoolean("isSavedAudioState", true);
    ed.commit();
  }
 void saveSettings() {
   if (!PreferenceManager.getDefaultSharedPreferences(Receiver.mContext)
       .getBoolean(
           org.sipdroid.sipua.ui.Settings.PREF_OLDVALID,
           org.sipdroid.sipua.ui.Settings.DEFAULT_OLDVALID)) {
     int oldvibrate = am.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);
     int oldvibrate2 = am.getVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION);
     if (!PreferenceManager.getDefaultSharedPreferences(Receiver.mContext)
         .contains(org.sipdroid.sipua.ui.Settings.PREF_OLDVIBRATE2))
       oldvibrate2 = AudioManager.VIBRATE_SETTING_ON;
     int oldpolicy =
         android.provider.Settings.System.getInt(
             cr,
             android.provider.Settings.System.WIFI_SLEEP_POLICY,
             Settings.System.WIFI_SLEEP_POLICY_DEFAULT);
     Editor edit = PreferenceManager.getDefaultSharedPreferences(Receiver.mContext).edit();
     edit.putInt(org.sipdroid.sipua.ui.Settings.PREF_OLDVIBRATE, oldvibrate);
     edit.putInt(org.sipdroid.sipua.ui.Settings.PREF_OLDVIBRATE2, oldvibrate2);
     edit.putInt(org.sipdroid.sipua.ui.Settings.PREF_OLDPOLICY, oldpolicy);
     edit.putInt(
         org.sipdroid.sipua.ui.Settings.PREF_OLDRING,
         am.getStreamVolume(AudioManager.STREAM_RING));
     edit.putBoolean(org.sipdroid.sipua.ui.Settings.PREF_OLDVALID, true);
     edit.commit();
   }
 }
  public void apply(View v) {
    // read raw values from the input widgets
    master_switch = switch_master_switch.isChecked();
    left_margin = Integer.parseInt(ET_left_margin.getText().toString());
    right_margin = Integer.parseInt(ET_right_margin.getText().toString());
    top_margin = Integer.parseInt(ET_top_margin.getText().toString());
    bottom_margin = Integer.parseInt(ET_bottom_margin.getText().toString());

    // save the values
    Editor editor = pref.edit();
    editor.putBoolean(Keys.MASTER_SWITCH, master_switch);
    editor.putInt(Keys.LEFT_MARGIN, left_margin);
    editor.putInt(Keys.RIGHT_MARGIN, right_margin);
    editor.putInt(Keys.TOP_MARGIN, top_margin);
    editor.putInt(Keys.BOTTOM_MARGIN, bottom_margin);
    editor.apply();

    int viewH = (screen_height - top_margin - bottom_margin);
    Log.d("VIEW H", Integer.toString(viewH));

    int viewW = screen_width - left_margin - right_margin;
    Log.d("VIEW W", Integer.toString(viewW));

    Toast.makeText(this, "Changes applied!", Toast.LENGTH_SHORT).show();
    if (viewW < screen_width * 0.5 || viewH < screen_height * 0.5)
      Toast.makeText(this, "Warning, the view area may be too small!", Toast.LENGTH_LONG).show();
    if (left_margin > screen_width
        || top_margin > screen_height
        || right_margin < 0
        || bottom_margin < 0)
      Toast.makeText(this, "Your view area goes off the screen!", Toast.LENGTH_LONG).show();

    finish();
  }
Beispiel #6
0
 /**
  * Moves sorting prefs to public pref store
  *
  * @param context
  */
 private void upgrade3To3_6(final Context context) {
   SharedPreferences publicPrefs = AstridPreferences.getPublicPrefs(context);
   Editor editor = publicPrefs.edit();
   editor.putInt(SortHelper.PREF_SORT_FLAGS, Preferences.getInt(SortHelper.PREF_SORT_FLAGS, 0));
   editor.putInt(SortHelper.PREF_SORT_SORT, Preferences.getInt(SortHelper.PREF_SORT_SORT, 0));
   editor.commit();
 }
 public void run() {
   Editor editor = sp.edit();
   editor.putInt("paramsX", x);
   editor.putInt("paramsY", y);
   editor.putInt("paramsWidth", width);
   editor.putInt("paramsHeith", heith);
   editor.commit();
 }
 public static void setInt(String key, int value, boolean isPublic) {
   if (isPublic) {
     mEditor.putInt(key, value);
   } else {
     mEditor.putInt(userId() + key, value);
   }
   mEditor.commit();
 }
Beispiel #9
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int br = 1;

    switch (item.getItemId()) {
      case R.id.menu_settings:
        Intent i = new Intent(this, UserSettingActivity.class);
        startActivityForResult(i, RESULT_SETTINGS);
        break;
      case R.id.menu_upload:
        if (global.getLogin() != null) {
          brands = db.retriveBrand();
          for (Brand bra : brands) {
            if (bra.getBrandStatus().equals("true")) {
              ++br;
            }
          }
          uploadList = db.retriveUpload();
          if (br >= 2) {
            if (connection.isConnectingToInternet()) {
              try {
                new Load().execute(uploadList);
              } catch (Exception e) {
                // TODO: handle exception
              }
              Editor edit = preference.edit();
              edit.putInt("upload", 2);
              edit.putInt("playMode", 2);
              edit.clear();
              edit.commit();
              db.resetTables(MySQLiteHelper.TABLE_NAME);
              db.resetTables(MySQLiteHelper.server_table);
              global.setLogin(null);
              Toast.makeText(home.this, "success", Toast.LENGTH_LONG).show();
              finish();
            } else {
              alert.showAlertDialog(home.this, "Warning", "Check your network connection", true);
            }
          } else {
            alert.showAlertDialog(home.this, "Warning", "You need to play atleast two brand", true);
          }
        } else {
          {
            Constants.name = preference.getString("name", null);
            Constants.age = preference.getString("age", null);
            Constants.gender = preference.getString("gender", null);
            if (Constants.name != null && Constants.age != null && Constants.gender != null)
              new InsertData().execute();
            else
              alert.showAlertDialog(
                  home.this, "Warning", "You are not logged in and no data to upload", true);
          }
        }
        break;
    }

    return true;
  }
Beispiel #10
0
  private boolean loadSharedPreferencesFromFile(File src) {
    // this should probably be in a thread if it ever gets big
    boolean res = false;
    ObjectInputStream input = null;
    try {
      input = new ObjectInputStream(new FileInputStream(src));
      Editor prefEdit = PreferenceManager.getDefaultSharedPreferences(this).edit();
      prefEdit.clear();
      // first object is preferences
      Map<String, ?> entries = (Map<String, ?>) input.readObject();
      for (Entry<String, ?> entry : entries.entrySet()) {
        Object v = entry.getValue();
        String key = entry.getKey();

        if (v instanceof Boolean) prefEdit.putBoolean(key, ((Boolean) v).booleanValue());
        else if (v instanceof Float) prefEdit.putFloat(key, ((Float) v).floatValue());
        else if (v instanceof Integer) prefEdit.putInt(key, ((Integer) v).intValue());
        else if (v instanceof Long) prefEdit.putLong(key, ((Long) v).longValue());
        else if (v instanceof String) prefEdit.putString(key, ((String) v));
      }
      prefEdit.commit();

      // second object is admin options
      Editor adminEdit = getSharedPreferences(AdminPreferencesActivity.ADMIN_PREFERENCES, 0).edit();
      adminEdit.clear();
      // first object is preferences
      Map<String, ?> adminEntries = (Map<String, ?>) input.readObject();
      for (Entry<String, ?> entry : adminEntries.entrySet()) {
        Object v = entry.getValue();
        String key = entry.getKey();

        if (v instanceof Boolean) adminEdit.putBoolean(key, ((Boolean) v).booleanValue());
        else if (v instanceof Float) adminEdit.putFloat(key, ((Float) v).floatValue());
        else if (v instanceof Integer) adminEdit.putInt(key, ((Integer) v).intValue());
        else if (v instanceof Long) adminEdit.putLong(key, ((Long) v).longValue());
        else if (v instanceof String) adminEdit.putString(key, ((String) v));
      }
      adminEdit.commit();

      res = true;
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } finally {
      try {
        if (input != null) {
          input.close();
        }
      } catch (IOException ex) {
        ex.printStackTrace();
      }
    }
    return res;
  }
Beispiel #11
0
 /**
  * Sets the reminder time. If the reminder service is currently enabled then its reminder time is
  * adjusted to this time as well.
  *
  * @param hourOfDay the hours to set.
  * @param minute the minute of the reminder time.
  */
 public void setReminderTime(int hourOfDay, int minute) {
   if (isServiceScheduled()) {
     setReminder(hourOfDay, minute);
   }
   Editor edit = getPreferences().edit();
   edit.putInt(HOURS, hourOfDay);
   edit.putInt(MINUTES, minute);
   edit.commit();
 }
  @Override
  protected void onDialogClosed(boolean positiveResult) {
    SharedPreferences mySharedPreferences =
        PreferenceManager.getDefaultSharedPreferences(getContext());
    Editor ed = mySharedPreferences.edit();

    ed.putInt("FontIndex", mSpinner.getSelectedItemPosition());
    ed.putInt("FontSize", mFontSize);
    ed.commit();
  }
 public static void saveAdjustedTextSizes() {
   Editor editor = DDGApplication.getSharedPreferences().edit();
   editor.putInt("fontPrevProgress", DDGControlVar.fontPrevProgress);
   editor.putFloat("mainFontSize", DDGControlVar.mainTextSize);
   editor.putFloat("recentFontSize", DDGControlVar.recentTextSize);
   editor.putInt("webViewFontSize", DDGControlVar.webViewTextSize);
   editor.putInt("ptrHeaderTextSize", DDGControlVar.ptrHeaderSize);
   editor.putInt("ptrHeaderSubTextSize", DDGControlVar.ptrSubHeaderSize);
   editor.putFloat("leftTitleTextSize", DDGControlVar.leftTitleTextSize);
   editor.commit();
 }
  /** Implements onItemSelected(). */
  @Override
  public void onItemSelected(AdapterView<?> parent, View view, int position, long is) {
    // Set the textSize preference based on selected spSettingsTextSize view
    // position.
    mEditor.putInt("textSize", position);
    mEditor.putInt("spinnerDefaultItem", position);
    mEditor.commit();

    // Update the preview based on the new preference.
    updateView();
  }
Beispiel #15
0
 public static void randomNumber(Context context, int number) {
   prefs = context.getSharedPreferences(PREFS, 0);
   long f = prefs.getLong("firststart", 0);
   long lasstamp = prefs.getLong("lasstamp", 0);
   int x_number = prefs.getInt("occurance" + number, 0); // times this number has been drawn
   int x = prefs.getInt("occurance", 0); // times any number has been drwan
   long tsl = prefs.getLong("timesincelastalert_long", 0);
   Date d = new Date();
   // now get some values done...
   month = d.getMonth();
   year = d.getYear() + 1900;
   Editor editor = prefs.edit();
   x++;
   x_number++;
   if (laststamp == 0) {
     laststamp = d.getTime();
   } else {
     long difsum = avDifBetweenStamps * stamps;
     long difnow = d.getTime() - laststamp;
     laststamp = d.getTime();
     stamps++;
     difsum = difsum + difnow;
     avDifBetweenStamps = difsum / stamps;
     Log.d(TAG, "now: " + difnow);
     Log.d(TAG, "av: " + avDifBetweenStamps);
     tsl = tsl + difnow;
     editor.putLong("timesincelastalert_long", tsl);
     if (difnow < 120000) {
       long mseconds = prefs.getLong("mseconds", 0);
       long msecondsmonth = prefs.getLong("mseconds_" + month + "_" + year, 0);
       mseconds = mseconds + difnow;
       msecondsmonth = msecondsmonth + difnow;
       editor.putLong("mseconds", mseconds);
       editor.putLong("mseconds_" + month + "_" + year, msecondsmonth);
     }
     editor.putLong("lasttamp", laststamp);
   }
   if (f == 0) {
     // this is the first time this app runs
     editor.putLong("firststart", d.getTime());
   }
   editor.putInt("occurance" + number, x_number);
   editor.putInt("occurance", x);
   editor.commit();
   // reset for the average every 1.000.000 calls, if the environment changes, the averag has to
   // change to.
   // This happens every 17 days (ca.)
   if (stamps > 1000000) {
     stamps = 0;
     avDifBetweenStamps = 0;
   }
 }
Beispiel #16
0
 public void savePreset() {
   final int sbOne = sb1.getProgress();
   final int sbTwo = sb2.getProgress();
   final int sbThree = sb3.getProgress();
   final int sbFour = sb4.getProgress();
   final int sbFive = sb5.getProgress();
   final int skOne = sk1.getProgress();
   final int skTwo = sk2.getProgress();
   final String preset = presetsSpinner.getSelectedItem().toString().trim();
   Editor editor = prefs.edit();
   editor.putBoolean(EQUALIZER_SAVE, true);
   editor.putString(EQUALIZER_PRESET, preset);
   if ("Custom".equals(preset)) {
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_ONE, sbOne);
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_TWO, sbTwo);
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_THREE, sbThree);
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_FOUR, sbFour);
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_FIVE, sbFive);
     editor.putInt(EQUALIZER_SEEKBAR_CUSTOM_ONE, skOne);
     editor.putInt(EQUALIZER_SEEKBAR_CUSTOM_TWO, skTwo);
   } else {
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_ONE, sbOne);
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_TWO, sbTwo);
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_THREE, sbThree);
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_FOUR, sbFour);
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_FIVE, sbFive);
     editor.putInt(EQUALIZER_SEEKBAR_ONE, skOne);
     editor.putInt(EQUALIZER_SEEKBAR_TWO, skTwo);
   }
   editor.apply();
 }
Beispiel #17
0
 @Override
 protected void onPause() {
   // TODO Auto-generated method stub
   super.onPause();
   position = pagefactory.getPosition();
   Editor editor = sp.edit();
   editor.putInt(id + "begin", position[0]);
   editor.putInt(id + "end", position[1]);
   editor.commit();
   int fontSize = pagefactory.getTextFont();
   Editor editor2 = sp.edit();
   editor2.putInt("fontsize", fontSize);
   editor2.commit();
 }
 public static boolean putMap(Context ct, String prefName, Map<String, ?> map) {
   boolean rs = true;
   try {
     SharedPreferences sp = ct.getSharedPreferences(prefName, Context.MODE_PRIVATE);
     Editor editor = sp.edit();
     Set<String> keys = map.keySet();
     Iterator<String> it = keys.iterator();
     while (it.hasNext()) {
       String key = it.next();
       Object value = map.get(key);
       if (value instanceof Integer) {
         editor.putInt(key, Integer.valueOf(String.valueOf(value)).intValue());
       } else if (value instanceof Boolean) {
         editor.putBoolean(key, Boolean.valueOf(String.valueOf(value)).booleanValue());
       } else if (value instanceof Float) {
         editor.putFloat(key, Float.valueOf(String.valueOf(value)).floatValue());
       } else if (value instanceof Long) {
         editor.putLong(key, Long.valueOf(String.valueOf(value)).longValue());
       } else if (value instanceof String) {
         editor.putString(key, String.valueOf(value));
       }
     }
     editor.commit();
   } catch (Exception e) {
     rs = false;
   }
   return rs;
 }
 void saveVolume() {
   if (restored) {
     Editor edit = PreferenceManager.getDefaultSharedPreferences(Receiver.mContext).edit();
     edit.putInt("volume" + speakermode, am.getStreamVolume(stream()));
     edit.commit();
   }
 }
 /**
  * 写入整型数据
  *
  * @param context 上下文
  * @param key 键
  * @param value 值
  */
 public static void wirteInt(Context context, String key, int value) {
   SharedPreferences preference =
       context.getSharedPreferences(AppConstant.SHARPREFER_FILENAME, Context.MODE_PRIVATE);
   Editor editor = preference.edit();
   editor.putInt(key, value);
   editor.commit();
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.game);

    mQuestionImage = (ImageSwitcher) findViewById(R.id.ImageSwitcher_QuestionImage);
    mQuestionImage.setFactory(new MyImageSwitcherFactory());

    mQuestionText = (TextSwitcher) findViewById(R.id.TextSwitcher_QuestionText);
    mQuestionText.setFactory(new MyTextSwitcherFactory());

    mQuestions = new Hashtable<Integer, Question>(QUESTION_BATCH_SIZE);

    mGameSettings = getSharedPreferences(GAME_PREFERENCES, Context.MODE_PRIVATE);
    int staringQuestionNumber = mGameSettings.getInt(GAME_PREFERENCES_CURRENT_QUESTION, 0);
    if (staringQuestionNumber == 0) {
      Editor editor = mGameSettings.edit();
      editor.putInt(GAME_PREFERENCES_CURRENT_QUESTION, 1);
      editor.commit();
      staringQuestionNumber = 1;
    }
    downloader = new QuizTask();
    downloader.execute(TRIVIA_SERVER_QUESTIONS, staringQuestionNumber);
  }
  public void onClick(View v) {
    int selRBColor = ((RadioGroup) findViewById(R.id.rgColor)).getCheckedRadioButtonId();
    int color = Color.RED;
    switch (selRBColor) {
      case R.id.radioRed:
        color = Color.parseColor("#66ff0000");
        break;
      case R.id.radioGreen:
        color = Color.parseColor("#6600ff00");
        break;
      case R.id.radioBlue:
        color = Color.parseColor("#660000ff");
        break;
    }
    EditText etText = (EditText) findViewById(R.id.etText);

    // Записываем значения с экрана в Preferences
    SharedPreferences sp = getSharedPreferences(WIDGET_PREF, MODE_PRIVATE);
    Editor editor = sp.edit();
    editor.putString(WIDGET_TEXT + widgetID, etText.getText().toString());
    editor.putInt(WIDGET_COLOR + widgetID, color);
    editor.commit();

    // necessary
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
    WidgetNextStart.updateWidget(this, appWidgetManager, sp, widgetID);

    // положительный ответ
    setResult(RESULT_OK, resultValue);

    Log.d(LOG_TAG, "finish config " + widgetID);
    finish();
  }
Beispiel #23
0
 protected void setWeight(int w) {
   SharedPreferences prefs = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
   Editor mEditor = prefs.edit();
   mEditor.putInt(WEIGHT, w);
   mEditor.commit();
   session.setWeight(w);
 }
  /**
   * This function is used for calculating the offset of the Toast, by checking how many are
   * on-screen. It locks (along with closeToast) to ensure that there are not concurrency problems
   * with the preference which may lead to 'residual' toasts - i.e. toasts no longer shown but that
   * the system thinks are shown. There is also time checking 'just in case' I screwed up the
   * concurrency, so that it will clear after the longest period that a toast can be on screen.
   *
   * @return
   */
  public int openToast() {
    int toastCount;

    synchronized (lock) {
      Editor editor = this.prefs.edit();
      toastCount = this.prefs.getInt(CURRENT_TOAST_COUNT, 0);
      long currentTime = System.currentTimeMillis();

      if (toastCount > 0) {
        long lastToastTime = this.prefs.getLong(LAST_TOAST_TIME, 0);

        // Toast LONG_DELAY = 3.5s, SHORT_DELAY = 2 seconds
        switch (getNotificationDuration()) {
          case Toast.LENGTH_SHORT:
            lastToastTime += 2000;
            break;
          case Toast.LENGTH_LONG:
            lastToastTime += 3500;
            break;
        }

        if (lastToastTime < currentTime) {
          toastCount = 0;
        }
      }

      editor.putInt(CURRENT_TOAST_COUNT, toastCount++);
      editor.putLong(LAST_TOAST_TIME, currentTime);
      editor.commit();
    }
    return toastCount;
  }
  public void onTabSelected(Tab tab, FragmentTransaction ft) {

    ft.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);

    switch (tab.getPosition()) {
      case 0:
        ft.show(adaptiveFragment);
        break;
      case 1:
        ft.show(gaugesFragment);
        break;
      case 2:
        if (connected != null && connected.isAlive()) {
          progress = ProgressDialog.show(ctx, "Fuel Map", "Reading map values 0/512...");

          mapOffset = 0;
          mapMode = true;
          sendRequest(mapOffset);
        }

        ft.show(fuelFragment);
        break;
    }

    // we don't want to overwrite our pref if we're in onCreate
    if (lvDevices != null) {
      Editor edit = prefs.edit();
      edit.putInt("prefs_last_tab", tab.getPosition());
      edit.commit();
    }
  }
Beispiel #26
0
 public void saveToPreferences(SharedPreferences preferences) {
   Editor editor = preferences.edit();
   editor.putInt(USER_ID, userId);
   editor.putString(USERNAME, username);
   editor.putString(TOKEN, token);
   editor.commit();
 }
  /**
   * Change list sort mode. Update list.
   *
   * @param sortMode The new sort mode.
   */
  private void doChangeSortMode(int sortMode) {
    Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
    editor.putInt(Constants.PREFERENCES_BOOKMARKS_SORT_MODE, sortMode);
    editor.commit();

    fillData();
  }
Beispiel #28
0
 public static void savePreferences(Activity activity, String key, int value) {
   SharedPreferences sp =
       PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext());
   Editor editor = sp.edit();
   editor.putInt(key, value);
   editor.commit();
 }
 /**
  * 本地保存channel & 对应版本号
  *
  * @param context
  * @param channel
  */
 private static void saveChannelBySharedPreferences(Context context, String channel) {
   SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
   Editor editor = sp.edit();
   editor.putString(CHANNEL_KEY, channel);
   editor.putInt(CHANNEL_VERSION_KEY, getVersionCode(context));
   editor.commit();
 }
Beispiel #30
0
 private void storeOsisVersion() {
   final Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
   editor.putString("osis", osis);
   if (!version.endsWith("demo") && !version.equals("")) {
     editor.putString("version", version);
   }
   editor.putString("verse", verse);
   editor.putInt("fontsize", fontsize);
   if (!book.equals("") && !chapter.equals("")) {
     editor.putString(book, chapter);
   }
   if (!version.equals("")) {
     editor.putInt("fontsize-" + version, fontsize);
   }
   editor.commit();
 }