Ejemplo n.º 1
0
 public static CurrencyListDialog create(boolean[] prefs) {
   CurrencyListDialog dialog = new CurrencyListDialog();
   Bundle bundle = new Bundle();
   bundle.putBooleanArray(DIALOG_LISTPREFS, prefs);
   dialog.setArguments(bundle);
   return dialog;
 }
  @Override
  public void onSaveInstanceState(Bundle savedInstanceState) {

    // Saving title field
    if (titleEditText != null) {
      savedInstanceState.putString(STATE_TITLE, titleEditText.getText().toString());
    }

    // Saving description field
    if (descriptionEditText != null) {
      savedInstanceState.putString(STATE_DESCRIPTION, descriptionEditText.getText().toString());
    }

    // Saving time field
    if (time != null) {
      savedInstanceState.putInt(STATE_TIME_HOUR, time.first);
      savedInstanceState.putInt(STATE_TIME_MINUTES, time.second);
    }

    // Saving week days field
    if (weekDays != null) {
      savedInstanceState.putBooleanArray(STATE_WEEK_DAYS, weekDays);
    }

    // The call to super method must be at the end here
    super.onSaveInstanceState(savedInstanceState);
  }
Ejemplo n.º 3
0
 @Override
 public void onSaveInstanceState(Bundle savedInstanceState) {
   super.onSaveInstanceState(savedInstanceState);
   Log.i(TAG, "onSaveInstanceState");
   savedInstanceState.putInt(KEY_INDEX, mCurrentIndex);
   savedInstanceState.putBooleanArray(CHEATED_VALUES, mCheatedQuestionsBank);
 }
  private Builder setSingleChoiceMode(Builder builder, String[] choices) {
    // 選択された選択肢を保存しておく配列を作成し,argumentsに入れておく
    // 生成時に受け取っている場合は不要
    Bundle args = getArguments();
    if (!args.containsKey(CHOSEN) || args.getBooleanArray(CHOSEN) == null) {
      boolean[] checked = new boolean[choices.length];
      args.putBooleanArray(CHOSEN, checked);
    }
    boolean[] checked = args.getBooleanArray(CHOSEN);
    int chosenItem;
    for (chosenItem = 0; chosenItem < checked.length; chosenItem++) {
      if (checked[chosenItem]) break;
    }

    builder.setSingleChoiceItems(
        choices,
        chosenItem,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            Bundle args = getArguments();
            boolean[] checked = args.getBooleanArray(CHOSEN);
            for (int i = 0; i < checked.length; i++) {
              checked[i] = (i == which); // 選ばれたもの以外すべてfalseにする
            }
            args.putBooleanArray(CHOSEN, checked);
          }
        });

    return builder;
  }
Ejemplo n.º 5
0
 public static boolean putJSONValueInBundle(Bundle bundle, String key, Object value) {
   if (value == null) {
     bundle.remove(key);
   } else if (value instanceof Boolean) {
     bundle.putBoolean(key, ((Boolean) value).booleanValue());
   } else if (value instanceof boolean[]) {
     bundle.putBooleanArray(key, (boolean[]) value);
   } else if (value instanceof Double) {
     bundle.putDouble(key, ((Double) value).doubleValue());
   } else if (value instanceof double[]) {
     bundle.putDoubleArray(key, (double[]) value);
   } else if (value instanceof Integer) {
     bundle.putInt(key, ((Integer) value).intValue());
   } else if (value instanceof int[]) {
     bundle.putIntArray(key, (int[]) value);
   } else if (value instanceof Long) {
     bundle.putLong(key, ((Long) value).longValue());
   } else if (value instanceof long[]) {
     bundle.putLongArray(key, (long[]) value);
   } else if (value instanceof String) {
     bundle.putString(key, (String) value);
   } else if (value instanceof JSONArray) {
     bundle.putString(key, ((JSONArray) value).toString());
   } else if (value instanceof JSONObject) {
     bundle.putString(key, ((JSONObject) value).toString());
   } else {
     return false;
   }
   return true;
 }
Ejemplo n.º 6
0
 /**
  * Add extended data to the extra.
  *
  * @param name The name of the extra data, with package prefix.
  * @param value The boolean array data value.
  * @return Returns the same extra object, for chaining multiple calls into a single statement.
  * @see #putExtras
  * @see #removeExtra
  * @see #getBooleanArrayExtra(String)
  */
 public Request putExtra(String name, boolean[] value) {
   if (mExtras == null) {
     mExtras = new Bundle();
   }
   mExtras.putBooleanArray(name, value);
   return this;
 }
Ejemplo n.º 7
0
 @Override
 public void onSaveInstanceState(Bundle savedInstanceState) {
   super.onSaveInstanceState(savedInstanceState);
   Log.d(TAG, "sky test now");
   savedInstanceState.putInt(KEY_INDEX, mCurrentIndex);
   savedInstanceState.putBooleanArray(KEY_CHEATER, mIsCheater);
 }
 private static void putBooleanArray(String key, Bundle bundle) {
   int length = random.nextInt(50);
   boolean[] array = new boolean[length];
   for (int i = 0; i < length; i++) {
     array[i] = random.nextBoolean();
   }
   bundle.putBooleanArray(key, array);
 }
Ejemplo n.º 9
0
 private void updateFromPreferences() {
   // Log.e(TAG, "Update Preferences Fired");
   Context context = getApplicationContext();
   boolean[] isOutputCh = loadBooleanArray("isInput", context);
   boolean[] isDigCh = loadBooleanArray("isDig", context);
   boolean[] outputState = loadBooleanArray("outputState", context);
   boolean fromFreq = true;
   String[] desiredFreq = loadStringArray("desiredFreqs", context, fromFreq);
   fromFreq = false;
   String[] desiredDuty = loadStringArray("desiredDutys", context, fromFreq);
   Bundle myBundle = new Bundle();
   myBundle.putBooleanArray("isInput", isOutputCh);
   myBundle.putBooleanArray("isDig", isDigCh);
   myBundle.putBooleanArray("outputState", outputState);
   myBundle.putStringArray("desiredFreqs", desiredFreq);
   myBundle.putStringArray("desiredDutys", desiredDuty);
   ((AndroiDAQTCPAdapter) pager.getAdapter()).setUIStates(myBundle);
   /*Example
   countSecs = prefs.getInt("setTime", 5000);
   timeIsSet = prefs.getBoolean("timeSet", true);
   project = prefs.getString("project", "Project01");*/
 }
Ejemplo n.º 10
0
  /** Save the state of the panes */
  @Override
  public void onSaveInstanceState(Bundle savedInstanceState) {
    int[] panesType = new int[panesLayout.getNumPanes()];
    boolean[] panesFocused = new boolean[panesLayout.getNumPanes()];
    for (int i = 0; i < panesLayout.getNumPanes(); i++) {
      PaneView p = panesLayout.getPane(i);
      panesType[i] = p.type;
      panesFocused[i] = p.focused;
    }

    savedInstanceState.putIntArray("PanesLayout_panesType", panesType);
    savedInstanceState.putBooleanArray("PanesLayout_panesFocused", panesFocused);
    savedInstanceState.putInt("PanesLayout_currentIndex", panesLayout.getCurrentIndex());
  }
Ejemplo n.º 11
0
 public static void changeVisibility(
     Messenger paramMessenger, String[] paramArrayOfString, boolean[] paramArrayOfBoolean) {
   if ((paramArrayOfString != null) && (paramArrayOfBoolean != null)) {
     if (paramArrayOfString.length != paramArrayOfBoolean.length)
       Log.e(
           "Circle",
           "length different : " + paramArrayOfString.length + " " + paramArrayOfBoolean.length);
   } else return;
   Bundle localBundle = new Bundle();
   localBundle.putStringArray("visibility_shapes", paramArrayOfString);
   localBundle.putBooleanArray("visibility", paramArrayOfBoolean);
   Message localMessage = Message.obtain(null, 10);
   localMessage.setData(localBundle);
   CircleWidget3DProvider.sendMessage(paramMessenger, localMessage);
 }
Ejemplo n.º 12
0
 @Override
 protected Parcelable onSaveInstanceState() {
   Bundle bundle = new Bundle();
   mBitmapAlpha = new float[mCount];
   mMessageNumber = new int[mCount];
   mNews = new boolean[mCount];
   for (int i = 0; i < mCount; i++) {
     mBitmapAlpha[i] = mTabstrips.get(i).getBitmapAlpha();
     mMessageNumber[i] = mTabstrips.get(i).getMessageNumber();
     mNews[i] = mTabstrips.get(i).getNews();
   }
   bundle.putParcelable(INSTANCE_STATUS, super.onSaveInstanceState());
   bundle.putFloatArray(STATUS_ALPHAS, mBitmapAlpha);
   bundle.putIntArray(STATUS_MESSAGENUMBER, mMessageNumber);
   bundle.putBooleanArray(STATUS_NEWS, mNews);
   return bundle;
 }
Ejemplo n.º 13
0
 /**
  * Bundle contendo: int acertos; int total; int tentativas; boolean[] corretas;
  *
  * @return o bundle contendo as informações da lista totalmente respondida
  * @return null se nao tiver sido totalmente respondida
  */
 public Bundle verificaRespondeuTodas() {
   Log.d("BackService", "verificaRespondeuTodas");
   if (mUser.isCompletelyAnswered()) {
     Bundle b = new Bundle();
     b.putInt("acertos", mUser.getAcertos());
     b.putInt("total", mUser.QL.getArrayListQuestion().size());
     //			b.putInt("tentativas", mUser.getTentativas());
     boolean[] corretas = mUser.getRespostasCorretas();
     boolean[] corretas2 = new boolean[corretas.length];
     int i = 0;
     for (Question q : mUser.QL.getArrayListQuestion()) {
       corretas2[i] = corretas[q.ID];
       i++;
     }
     b.putBooleanArray("corretas", corretas2);
     return b;
   }
   return null;
 }
Ejemplo n.º 14
0
  private Builder setMutlipleChoiceMode(Builder builder, String[] choices) {
    // 選択された選択肢を保存しておく配列を作成し,argumentsに入れておく
    // 生成時に受け取っている場合は不要
    Bundle args = getArguments();
    if (!args.containsKey(CHOSEN) || args.getBooleanArray(CHOSEN) == null) {
      boolean[] checked = new boolean[choices.length];
      args.putBooleanArray(CHOSEN, checked);
    }

    builder.setMultiChoiceItems(
        choices,
        args.getBooleanArray(CHOSEN),
        new DialogInterface.OnMultiChoiceClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            Bundle args = getArguments();
            boolean[] checked = args.getBooleanArray(CHOSEN);
            checked[which] = isChecked;
            args.putBooleanArray(CHOSEN, checked);
          }
        });

    return builder;
  }
  private void deserializeKey(String key, Bundle bundle) throws JSONException {
    String jsonString = cache.getString(key, "{}");
    JSONObject json = new JSONObject(jsonString);

    String valueType = json.getString(JSON_VALUE_TYPE);

    if (valueType.equals(TYPE_BOOLEAN)) {
      bundle.putBoolean(key, json.getBoolean(JSON_VALUE));
    } else if (valueType.equals(TYPE_BOOLEAN_ARRAY)) {
      JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
      boolean[] array = new boolean[jsonArray.length()];
      for (int i = 0; i < array.length; i++) {
        array[i] = jsonArray.getBoolean(i);
      }
      bundle.putBooleanArray(key, array);
    } else if (valueType.equals(TYPE_BYTE)) {
      bundle.putByte(key, (byte) json.getInt(JSON_VALUE));
    } else if (valueType.equals(TYPE_BYTE_ARRAY)) {
      JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
      byte[] array = new byte[jsonArray.length()];
      for (int i = 0; i < array.length; i++) {
        array[i] = (byte) jsonArray.getInt(i);
      }
      bundle.putByteArray(key, array);
    } else if (valueType.equals(TYPE_SHORT)) {
      bundle.putShort(key, (short) json.getInt(JSON_VALUE));
    } else if (valueType.equals(TYPE_SHORT_ARRAY)) {
      JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
      short[] array = new short[jsonArray.length()];
      for (int i = 0; i < array.length; i++) {
        array[i] = (short) jsonArray.getInt(i);
      }
      bundle.putShortArray(key, array);
    } else if (valueType.equals(TYPE_INTEGER)) {
      bundle.putInt(key, json.getInt(JSON_VALUE));
    } else if (valueType.equals(TYPE_INTEGER_ARRAY)) {
      JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
      int[] array = new int[jsonArray.length()];
      for (int i = 0; i < array.length; i++) {
        array[i] = jsonArray.getInt(i);
      }
      bundle.putIntArray(key, array);
    } else if (valueType.equals(TYPE_LONG)) {
      bundle.putLong(key, json.getLong(JSON_VALUE));
    } else if (valueType.equals(TYPE_LONG_ARRAY)) {
      JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
      long[] array = new long[jsonArray.length()];
      for (int i = 0; i < array.length; i++) {
        array[i] = jsonArray.getLong(i);
      }
      bundle.putLongArray(key, array);
    } else if (valueType.equals(TYPE_FLOAT)) {
      bundle.putFloat(key, (float) json.getDouble(JSON_VALUE));
    } else if (valueType.equals(TYPE_FLOAT_ARRAY)) {
      JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
      float[] array = new float[jsonArray.length()];
      for (int i = 0; i < array.length; i++) {
        array[i] = (float) jsonArray.getDouble(i);
      }
      bundle.putFloatArray(key, array);
    } else if (valueType.equals(TYPE_DOUBLE)) {
      bundle.putDouble(key, json.getDouble(JSON_VALUE));
    } else if (valueType.equals(TYPE_DOUBLE_ARRAY)) {
      JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
      double[] array = new double[jsonArray.length()];
      for (int i = 0; i < array.length; i++) {
        array[i] = jsonArray.getDouble(i);
      }
      bundle.putDoubleArray(key, array);
    } else if (valueType.equals(TYPE_CHAR)) {
      String charString = json.getString(JSON_VALUE);
      if (charString != null && charString.length() == 1) {
        bundle.putChar(key, charString.charAt(0));
      }
    } else if (valueType.equals(TYPE_CHAR_ARRAY)) {
      JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
      char[] array = new char[jsonArray.length()];
      for (int i = 0; i < array.length; i++) {
        String charString = jsonArray.getString(i);
        if (charString != null && charString.length() == 1) {
          array[i] = charString.charAt(0);
        }
      }
      bundle.putCharArray(key, array);
    } else if (valueType.equals(TYPE_STRING)) {
      bundle.putString(key, json.getString(JSON_VALUE));
    } else if (valueType.equals(TYPE_STRING_LIST)) {
      JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
      int numStrings = jsonArray.length();
      ArrayList<String> stringList = new ArrayList<String>(numStrings);
      for (int i = 0; i < numStrings; i++) {
        Object jsonStringValue = jsonArray.get(i);
        stringList.add(i, jsonStringValue == JSONObject.NULL ? null : (String) jsonStringValue);
      }
      bundle.putStringArrayList(key, stringList);
    } else if (valueType.equals(TYPE_ENUM)) {
      try {
        String enumType = json.getString(JSON_VALUE_ENUM_TYPE);
        @SuppressWarnings({"unchecked", "rawtypes"})
        Class<? extends Enum> enumClass = (Class<? extends Enum>) Class.forName(enumType);
        @SuppressWarnings("unchecked")
        Enum<?> enumValue = Enum.valueOf(enumClass, json.getString(JSON_VALUE));
        bundle.putSerializable(key, enumValue);
      } catch (ClassNotFoundException e) {
      } catch (IllegalArgumentException e) {
      }
    }
  }
Ejemplo n.º 16
0
 /**
  * Saving the current state of the activity for configuration changes [ Portrait <=> Landscape ]
  */
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putBooleanArray("status", status);
 }