Java Code Examples for android.os.Bundle.isEmpty()

The following are Jave code examples for showing how to use isEmpty() of the android.os.Bundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: financisto1-holo   File: GCMIntentService.java   View Source Code Vote up 6 votes
@Override
protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    String messageType = gcm.getMessageType(intent);
    if (!extras.isEmpty()) {
    	if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {	    		
    		if (FlowzrSyncEngine.isRunning) {
     		Log.i(TAG,"sync already in progess");
    			return;
    		}
    		Log.i(TAG,"starting sync from GCM");
    		new FlowzrSyncTask(getApplicationContext()).execute();
        }
    }
}
 
Example 2
Project: LaunchEnr   File: AutoInstallsLayout.java   View Source Code Vote up 6 votes
protected long verifyAndInsert(ComponentName cn, Bundle extras) {
    mValues.put(Favorites.APPWIDGET_PROVIDER, cn.flattenToString());
    mValues.put(Favorites.RESTORED,
            LauncherAppWidgetInfo.FLAG_ID_NOT_VALID |
                    LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY |
                    LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG);
    mValues.put(Favorites._ID, mCallback.generateNewItemId());
    if (!extras.isEmpty()) {
        mValues.put(Favorites.INTENT, new Intent().putExtras(extras).toUri(0));
    }

    long insertedId = mCallback.insertAndCheck(mDb, mValues);
    if (insertedId < 0) {
        return -1;
    } else {
        return insertedId;
    }
}
 
Example 3
Project: gamecollection   File: GameActivity.java   View Source Code Vote up 6 votes
private boolean saveGame() {
    Bundle bundle = new Bundle();
    onSaveGame(bundle);
    if (!bundle.isEmpty()) {
        Savegame savegame;
        if (savegameUuid == null) {
            savegame = new Savegame(game.getUuid(), bundle);
            savegameUuid = savegame.uuid;
        } else {
            savegame = savegameStorage.getFromUuid(savegameUuid);
            savegame.update(bundle);
        }
        savegameStorage.updateSavegame(savegame);
        Bundle extras = getIntent().getExtras();
        extras.putString(KEY_SAVEGAME_UUID, savegame.uuid);
        return true;
    }
    return false;
}
 
Example 4
Project: NavigationTools   File: NavigationManager.java   View Source Code Vote up 6 votes
private void switchActivity(Class<?> screen, Bundle bundle, AnimationType animation, boolean isActivityRoot) {
    Intent intent = activityFactory.getActivityByName(screen);
    if (isActivityRoot) {
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    }
    if (bundle != null && !bundle.isEmpty()) {
        intent.putExtras(bundle);
    }
    activity.startActivity(intent);
    switch (animation) {
        case FADE_TYPE:
            activity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
            break;
        case RIGHT_TO_LEFT_TYPE:
            activity.overridePendingTransition(R.anim.right_to_left_in, R.anim.right_to_left_out);
            break;
        case LEFT_TO_RIGHT_TYPE:
            activity.overridePendingTransition(R.anim.left_to_right_in, R.anim.left_to_right_out);
            break;
    }
}
 
Example 5
Project: dcs-sdk-java   File: CommonUtil.java   View Source Code Vote up 6 votes
/**
 * 将key-value形式的参数串,转换成key1=value1&key2=value2格式的query
 *
 * @param params key-value参数
 * @return key1=value1&key2=value2格式的query
 */
public static String encodeUrl(Bundle params) {
    if (params == null || params.isEmpty()) {
        return null;
    }
    boolean first = true;
    StringBuilder sb = new StringBuilder();
    for (String key : params.keySet()) {
        String paramValue = params.getString(key);
        if (paramValue == null) {
            continue;
        }
        if (first) {
            first = false;
        } else {
            sb.append("&");
        }
        sb.append(URLEncoder.encode(key)).append("=").append(URLEncoder.encode(paramValue));
    }
    return sb.toString();
}
 
Example 6
Project: bridge   File: BridgeDelegate.java   View Source Code Vote up 6 votes
void saveInstanceState(@NonNull Object target, @NonNull Bundle state) {
    String uuid = mObjectUuidMap.get(target);
    if (uuid == null) {
        uuid = UUID.randomUUID().toString();
        mObjectUuidMap.put(target, uuid);
    }
    state.putString(getKeyForUuid(target), uuid);
    Bundle bundle = new Bundle();
    mSavedStateHandler.saveInstanceState(target, bundle);
    if (bundle.isEmpty()) {
        // Don't bother saving empty bundles
        return;
    }
    WrapperUtils.wrapOptimizedObjects(bundle);
    mRecentUuids.add(uuid);
    mUuidBundleMap.put(uuid, bundle);
    writeToDisk(uuid, bundle);
    clearStaleData();
}
 
Example 7
Project: Router   File: ImplicitActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scheme);

    TextView text = (TextView) findViewById(R.id.text_test);
    Bundle bundle = getIntent().getExtras();
    if (bundle != null && !bundle.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        sb.append("id:")
                .append(bundle.getString("id"))
                .append("\n")
                .append("status:")
                .append(bundle.getString("status"));
        text.setText(sb.toString());
    }

}
 
Example 8
Project: Router   File: TestActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test);

    Router.injectParams(this);

    Bundle mExtras = getIntent().getExtras();
    id = mExtras.getString("id", id);

    TextView text = (TextView) findViewById(R.id.text_test);
    Bundle bundle = getIntent().getExtras();
    if (bundle != null && !bundle.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        sb.append("id:")
                .append(id)
                .append("\n")
                .append("status:")
                .append(sts);
        text.setText(sb.toString());
    }
}
 
Example 9
Project: keepass2android   File: DecodeHintManager.java   View Source Code Vote up 5 votes
static Map<DecodeHintType, Object> parseDecodeHints(Intent intent) {
  Bundle extras = intent.getExtras();
  if (extras == null || extras.isEmpty()) {
    return null;
  }
  Map<DecodeHintType,Object> hints = new EnumMap<DecodeHintType,Object>(DecodeHintType.class);

  for (DecodeHintType hintType: DecodeHintType.values()) {

    if (hintType == DecodeHintType.CHARACTER_SET ||
        hintType == DecodeHintType.NEED_RESULT_POINT_CALLBACK ||
        hintType == DecodeHintType.POSSIBLE_FORMATS) {
      continue; // This hint is specified in another way
    }

    String hintName = hintType.name();
    if (extras.containsKey(hintName)) {
      if (hintType.getValueType().equals(Void.class)) {
        // Void hints are just flags: use the constant specified by the DecodeHintType
        hints.put(hintType, Boolean.TRUE);
      } else {
        Object hintData = extras.get(hintName);
        if (hintType.getValueType().isInstance(hintData)) {
          hints.put(hintType, hintData);
        } else {
          Log.w(TAG, "Ignoring hint " + hintType + " because it is not assignable from " + hintData);
        }
      }
    }
  }

  Log.i(TAG, "Hints from the Intent: " + hints);
  return hints;
}
 
Example 10
Project: CodeScaner   File: DecodeHintManager.java   View Source Code Vote up 5 votes
static Map<DecodeHintType, Object> parseDecodeHints(Intent intent) {
  Bundle extras = intent.getExtras();
  if (extras == null || extras.isEmpty()) {
    return null;
  }
  Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class);

  for (DecodeHintType hintType: DecodeHintType.values()) {

    if (hintType == DecodeHintType.CHARACTER_SET ||
        hintType == DecodeHintType.NEED_RESULT_POINT_CALLBACK ||
        hintType == DecodeHintType.POSSIBLE_FORMATS) {
      continue; // This hint is specified in another way
    }

    String hintName = hintType.name();
    if (extras.containsKey(hintName)) {
      if (hintType.getValueType().equals(Void.class)) {
        // Void hints are just flags: use the constant specified by the DecodeHintType
        hints.put(hintType, Boolean.TRUE);
      } else {
        Object hintData = extras.get(hintName);
        if (hintType.getValueType().isInstance(hintData)) {
          hints.put(hintType, hintData);
        } else {
          Log.w(TAG, "Ignoring hint " + hintType + " because it is not assignable from " + hintData);
        }
      }
    }
  }

  Log.i(TAG, "Hints from the Intent: " + hints);
  return hints;
}
 
Example 11
Project: airgram   File: LoginActivity.java   View Source Code Vote up 5 votes
@Override
public void setParams(Bundle params) {
    if (params == null) {
        return;
    }
    if (params.isEmpty()) {
        resetAccountButton.setVisibility(VISIBLE);
        resetAccountText.setVisibility(VISIBLE);
        AndroidUtilities.hideKeyboard(codeField);
        return;
    }
    resetAccountButton.setVisibility(GONE);
    resetAccountText.setVisibility(GONE);
    codeField.setText("");
    currentParams = params;
    current_salt = Utilities.hexToBytes(currentParams.getString("current_salt"));
    hint = currentParams.getString("hint");
    has_recovery = currentParams.getInt("has_recovery") == 1;
    email_unconfirmed_pattern = currentParams.getString("email_unconfirmed_pattern");
    requestPhone = params.getString("phoneFormated");
    phoneHash = params.getString("phoneHash");
    phoneCode = params.getString("code");

    AndroidUtilities.showKeyboard(codeField);
    codeField.requestFocus();


    if (hint != null && hint.length() > 0) {
        codeField.setHint(hint);
    } else {
        codeField.setHint(LocaleController.getString("LoginPassword", R.string.LoginPassword));
    }
}
 
Example 12
Project: weex-3d-map   File: DecodeHintManager.java   View Source Code Vote up 5 votes
static Map<DecodeHintType, Object> parseDecodeHints(Intent intent) {
  Bundle extras = intent.getExtras();
  if (extras == null || extras.isEmpty()) {
    return null;
  }
  Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class);

  for (DecodeHintType hintType: DecodeHintType.values()) {

    if (hintType == DecodeHintType.CHARACTER_SET ||
        hintType == DecodeHintType.NEED_RESULT_POINT_CALLBACK ||
        hintType == DecodeHintType.POSSIBLE_FORMATS) {
      continue; // This hint is specified in another way
    }

    String hintName = hintType.name();
    if (extras.containsKey(hintName)) {
      if (hintType.getValueType().equals(Void.class)) {
        // Void hints are just flags: use the constant specified by the DecodeHintType
        hints.put(hintType, Boolean.TRUE);
      } else {
        Object hintData = extras.get(hintName);
        if (hintType.getValueType().isInstance(hintData)) {
          hints.put(hintType, hintData);
        } else {
          Log.w(TAG, "Ignoring hint " + hintType + " because it is not assignable from " + hintData);
        }
      }
    }
  }

  Log.i(TAG, "Hints from the Intent: " + hints);
  return hints;
}
 
Example 13
Project: PlusGram   File: LoginActivity.java   View Source Code Vote up 5 votes
@Override
public void setParams(Bundle params) {
    if (params == null) {
        return;
    }
    if (params.isEmpty()) {
        resetAccountButton.setVisibility(VISIBLE);
        resetAccountText.setVisibility(VISIBLE);
        AndroidUtilities.hideKeyboard(codeField);
        return;
    }
    resetAccountButton.setVisibility(GONE);
    resetAccountText.setVisibility(GONE);
    codeField.setText("");
    currentParams = params;
    current_salt = Utilities.hexToBytes(currentParams.getString("current_salt"));
    hint = currentParams.getString("hint");
    has_recovery = currentParams.getInt("has_recovery") == 1;
    email_unconfirmed_pattern = currentParams.getString("email_unconfirmed_pattern");
    requestPhone = params.getString("phoneFormated");
    phoneHash = params.getString("phoneHash");
    phoneCode = params.getString("code");

    if (hint != null && hint.length() > 0) {
        codeField.setHint(hint);
    } else {
        codeField.setHint(LocaleController.getString("LoginPassword", R.string.LoginPassword));
    }
}
 
Example 14
Project: tvConnect_android   File: DecodeHintManager.java   View Source Code Vote up 5 votes
public static Map<DecodeHintType, Object> parseDecodeHints(Intent intent) {
  Bundle extras = intent.getExtras();
  if (extras == null || extras.isEmpty()) {
    return null;
  }
  Map<DecodeHintType,Object> hints = new EnumMap(DecodeHintType.class);

  for (DecodeHintType hintType: DecodeHintType.values()) {

    if (hintType == DecodeHintType.CHARACTER_SET ||
        hintType == DecodeHintType.NEED_RESULT_POINT_CALLBACK ||
        hintType == DecodeHintType.POSSIBLE_FORMATS) {
      continue; // This hint is specified in another way
    }

    String hintName = hintType.name();
    if (extras.containsKey(hintName)) {
      if (hintType.getValueType().equals(Void.class)) {
        // Void hints are just flags: use the constant specified by the DecodeHintType
        hints.put(hintType, Boolean.TRUE);
      } else {
        Object hintData = extras.get(hintName);
        if (hintType.getValueType().isInstance(hintData)) {
          hints.put(hintType, hintData);
        } else {
          Log.w(TAG, "Ignoring hint " + hintType + " because it is not assignable from " + hintData);
        }
      }
    }
  }

  Log.i(TAG, "Hints from the Intent: " + hints);
  return hints;
}
 
Example 15
Project: QrCode   File: DecodeHintManager.java   View Source Code Vote up 5 votes
static Map<DecodeHintType, Object> parseDecodeHints(Intent intent) {
  Bundle extras = intent.getExtras();
  if (extras == null || extras.isEmpty()) {
    return null;
  }
  Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class);

  for (DecodeHintType hintType: DecodeHintType.values()) {

    if (hintType == DecodeHintType.CHARACTER_SET ||
        hintType == DecodeHintType.NEED_RESULT_POINT_CALLBACK ||
        hintType == DecodeHintType.POSSIBLE_FORMATS) {
      continue; // This hint is specified in another way
    }

    String hintName = hintType.name();
    if (extras.containsKey(hintName)) {
      if (hintType.getValueType().equals(Void.class)) {
        // Void hints are just flags: use the constant specified by the DecodeHintType
        hints.put(hintType, Boolean.TRUE);
      } else {
        Object hintData = extras.get(hintName);
        if (hintType.getValueType().isInstance(hintData)) {
          hints.put(hintType, hintData);
        } else {
          Log.w(TAG, "Ignoring hint " + hintType + " because it is not assignable from " + hintData);
        }
      }
    }
  }

  Log.i(TAG, "Hints from the Intent: " + hints);
  return hints;
}
 
Example 16
Project: letv   File: Util.java   View Source Code Vote up 5 votes
public static Statistic upload(Context context, String str, Bundle bundle) throws MalformedURLException, IOException, NetworkUnavailableException, HttpStatusException {
    int size;
    int i;
    byte[] byteArray;
    if (context != null) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
        if (connectivityManager != null) {
            NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
            if (activeNetworkInfo == null || !activeNetworkInfo.isAvailable()) {
                throw new NetworkUnavailableException(NetworkUnavailableException.ERROR_INFO);
            }
        }
    }
    Bundle bundle2 = new Bundle(bundle);
    String str2 = "";
    str2 = bundle2.getString("appid_for_getting_config");
    bundle2.remove("appid_for_getting_config");
    HttpClient httpClient = HttpUtils.getHttpClient(context, str2, str);
    HttpUriRequest httpPost = new HttpPost(str);
    Bundle bundle3 = new Bundle();
    for (String str22 : bundle2.keySet()) {
        Object obj = bundle2.get(str22);
        if (obj instanceof byte[]) {
            bundle3.putByteArray(str22, (byte[]) obj);
        }
    }
    httpPost.setHeader(HttpRequest.HEADER_CONTENT_TYPE, "multipart/form-data; boundary=3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f");
    httpPost.setHeader("Connection", "Keep-Alive");
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    byteArrayOutputStream.write(getBytesUTF8("--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n"));
    byteArrayOutputStream.write(getBytesUTF8(encodePostBody(bundle2, "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f")));
    if (!bundle3.isEmpty()) {
        size = bundle3.size();
        byteArrayOutputStream.write(getBytesUTF8("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n"));
        i = -1;
        for (String str222 : bundle3.keySet()) {
            i++;
            byteArrayOutputStream.write(getBytesUTF8("Content-Disposition: form-data; name=\"" + str222 + "\"; filename=\"" + "value.file" + "\"" + "\r\n"));
            byteArrayOutputStream.write(getBytesUTF8("Content-Type: application/octet-stream\r\n\r\n"));
            byteArray = bundle3.getByteArray(str222);
            if (byteArray != null) {
                byteArrayOutputStream.write(byteArray);
            }
            if (i < size - 1) {
                byteArrayOutputStream.write(getBytesUTF8("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n"));
            }
        }
    }
    byteArrayOutputStream.write(getBytesUTF8("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f--\r\n"));
    byteArray = byteArrayOutputStream.toByteArray();
    i = byteArray.length + 0;
    byteArrayOutputStream.close();
    httpPost.setEntity(new ByteArrayEntity(byteArray));
    HttpResponse execute = httpClient.execute(httpPost);
    size = execute.getStatusLine().getStatusCode();
    if (size == 200) {
        return new Statistic(a(execute), i);
    }
    throw new HttpStatusException(HttpStatusException.ERROR_INFO + size);
}
 
Example 17
Project: letv   File: AppbarAgent.java   View Source Code Vote up 5 votes
private String a(Bundle bundle) {
    if (bundle == null || bundle.isEmpty()) {
        return "";
    }
    StringBuilder stringBuilder = new StringBuilder();
    for (String str : bundle.keySet()) {
        stringBuilder.append(str).append(SearchCriteria.EQ).append(bundle.get(str)).append("&");
    }
    String str2 = stringBuilder.toString();
    if (str2.endsWith("&")) {
        str2 = str2.substring(0, str2.length() - 1);
    }
    f.b("AppbarAgent", "-->encodeParams, result: " + str2);
    return str2;
}
 
Example 18
Project: FlickLauncher   File: AutoInstallsLayout.java   View Source Code Vote up 5 votes
protected long verifyAndInsert(ComponentName cn, Bundle extras) {
    mValues.put(Favorites.APPWIDGET_PROVIDER, cn.flattenToString());
    mValues.put(Favorites.RESTORED,
            LauncherAppWidgetInfo.FLAG_ID_NOT_VALID |
                    LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY |
                    LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG);
    mValues.put(Favorites._ID, mCallback.generateNewItemId());
    if (!extras.isEmpty()) {
        mValues.put(Favorites.INTENT, new Intent().putExtras(extras).toUri(0));
    }

    long insertedId = mCallback.insertAndCheck(mDb, mValues);
    if (insertedId < 0) {
        return -1;
    } else {
        return insertedId;
    }
}
 
Example 19
Project: ZXingAndroidExt   File: DecodeHintManager.java   View Source Code Vote up 5 votes
static Map<DecodeHintType, Object> parseDecodeHints(Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras == null || extras.isEmpty()) {
        return null;
    }
    Map<DecodeHintType, Object> hints = new EnumMap<>(DecodeHintType.class);

    for (DecodeHintType hintType : DecodeHintType.values()) {

        if (hintType == DecodeHintType.CHARACTER_SET ||
                hintType == DecodeHintType.NEED_RESULT_POINT_CALLBACK ||
                hintType == DecodeHintType.POSSIBLE_FORMATS) {
            continue; // This hint is specified in another way
        }

        String hintName = hintType.name();
        if (extras.containsKey(hintName)) {
            if (hintType.getValueType().equals(Void.class)) {
                // Void hints are just flags: use the constant specified by the DecodeHintType
                hints.put(hintType, Boolean.TRUE);
            } else {
                Object hintData = extras.get(hintName);
                if (hintType.getValueType().isInstance(hintData)) {
                    hints.put(hintType, hintData);
                } else {
                    Log.w(TAG, "Ignoring hint " + hintType + " because it is not assignable from " + hintData);
                }
            }
        }
    }

    Log.i(TAG, "Hints from the Intent: " + hints);
    return hints;
}
 
Example 20
Project: Saiy-PS   File: UtilsBundle.java   View Source Code Vote up 4 votes
public static boolean notNaked(@Nullable final Bundle bundle) {
    return bundle != null && !bundle.isEmpty();
}