Example usage for android.os Bundle putLong

List of usage examples for android.os Bundle putLong

Introduction

In this page you can find the example usage for android.os Bundle putLong.

Prototype

public void putLong(@Nullable String key, long value) 

Source Link

Document

Inserts a long value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.dwdesign.tweetings.fragment.ParcelableStatusesListFragment.java

@Override
public final int getStatuses(final long[] account_ids, final long[] max_ids, final long[] since_ids) {
    final long max_id = max_ids != null && max_ids.length == 1 ? max_ids[0] : -1;
    final long since_id = since_ids != null && since_ids.length == 1 ? since_ids[0] : -1;
    final Bundle args = (Bundle) getArguments().clone();
    args.putLong(INTENT_KEY_MAX_ID, max_id);
    args.putLong(INTENT_KEY_SINCE_ID, since_id);
    getLoaderManager().restartLoader(0, args, this);
    return -1;//from  ww  w .j a  v a  2s  . co  m
}

From source file:com.nextgis.ngm_clink_monitoring.fragments.ObjectTypesFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    if (null != mLineRemoteId) {
        outState.putLong(FoclConstants.FOCL_STRUCT_REMOTE_ID, mLineRemoteId);
    }// w w w . j a  v a 2 s  . co  m
}

From source file:com.facebook.internal.BundleJSONConverterTests.java

@SmallTest
public void testSimpleValues() throws JSONException {
    ArrayList<String> arrayList = new ArrayList<String>();
    arrayList.add("1st");
    arrayList.add("2nd");
    arrayList.add("third");

    Bundle innerBundle1 = new Bundle();
    innerBundle1.putInt("inner", 1);

    Bundle innerBundle2 = new Bundle();
    innerBundle2.putString("inner", "2");
    innerBundle2.putStringArray("deep list", new String[] { "7", "8" });

    innerBundle1.putBundle("nested bundle", innerBundle2);

    Bundle b = new Bundle();
    b.putBoolean("boolValue", true);
    b.putInt("intValue", 7);
    b.putLong("longValue", 5000000000l);
    b.putDouble("doubleValue", 3.14);
    b.putString("stringValue", "hello world");
    b.putStringArray("stringArrayValue", new String[] { "first", "second" });
    b.putStringArrayList("stringArrayListValue", arrayList);
    b.putBundle("nested", innerBundle1);

    JSONObject json = BundleJSONConverter.convertToJSON(b);
    assertNotNull(json);/*from w  ww.  j a  v  a 2  s  .  c  om*/

    assertEquals(true, json.getBoolean("boolValue"));
    assertEquals(7, json.getInt("intValue"));
    assertEquals(5000000000l, json.getLong("longValue"));
    assertEquals(3.14, json.getDouble("doubleValue"));
    assertEquals("hello world", json.getString("stringValue"));

    JSONArray jsonArray = json.getJSONArray("stringArrayValue");
    assertEquals(2, jsonArray.length());
    assertEquals("first", jsonArray.getString(0));
    assertEquals("second", jsonArray.getString(1));

    jsonArray = json.getJSONArray("stringArrayListValue");
    assertEquals(3, jsonArray.length());
    assertEquals("1st", jsonArray.getString(0));
    assertEquals("2nd", jsonArray.getString(1));
    assertEquals("third", jsonArray.getString(2));

    JSONObject innerJson = json.getJSONObject("nested");
    assertEquals(1, innerJson.getInt("inner"));
    innerJson = innerJson.getJSONObject("nested bundle");
    assertEquals("2", innerJson.getString("inner"));

    jsonArray = innerJson.getJSONArray("deep list");
    assertEquals(2, jsonArray.length());
    assertEquals("7", jsonArray.getString(0));
    assertEquals("8", jsonArray.getString(1));

    Bundle finalBundle = BundleJSONConverter.convertToBundle(json);
    assertNotNull(finalBundle);

    assertEquals(true, finalBundle.getBoolean("boolValue"));
    assertEquals(7, finalBundle.getInt("intValue"));
    assertEquals(5000000000l, finalBundle.getLong("longValue"));
    assertEquals(3.14, finalBundle.getDouble("doubleValue"));
    assertEquals("hello world", finalBundle.getString("stringValue"));

    List<String> stringList = finalBundle.getStringArrayList("stringArrayValue");
    assertEquals(2, stringList.size());
    assertEquals("first", stringList.get(0));
    assertEquals("second", stringList.get(1));

    stringList = finalBundle.getStringArrayList("stringArrayListValue");
    assertEquals(3, stringList.size());
    assertEquals("1st", stringList.get(0));
    assertEquals("2nd", stringList.get(1));
    assertEquals("third", stringList.get(2));

    Bundle finalInnerBundle = finalBundle.getBundle("nested");
    assertEquals(1, finalInnerBundle.getInt("inner"));
    finalBundle = finalInnerBundle.getBundle("nested bundle");
    assertEquals("2", finalBundle.getString("inner"));

    stringList = finalBundle.getStringArrayList("deep list");
    assertEquals(2, stringList.size());
    assertEquals("7", stringList.get(0));
    assertEquals("8", stringList.get(1));
}

From source file:com.facebook.internal.BundleJSONConverterTest.java

@Test
public void testSimpleValues() throws JSONException {
    ArrayList<String> arrayList = new ArrayList<String>();
    arrayList.add("1st");
    arrayList.add("2nd");
    arrayList.add("third");

    Bundle innerBundle1 = new Bundle();
    innerBundle1.putInt("inner", 1);

    Bundle innerBundle2 = new Bundle();
    innerBundle2.putString("inner", "2");
    innerBundle2.putStringArray("deep list", new String[] { "7", "8" });

    innerBundle1.putBundle("nested bundle", innerBundle2);

    Bundle b = new Bundle();
    b.putBoolean("boolValue", true);
    b.putInt("intValue", 7);
    b.putLong("longValue", 5000000000l);
    b.putDouble("doubleValue", 3.14);
    b.putString("stringValue", "hello world");
    b.putStringArray("stringArrayValue", new String[] { "first", "second" });
    b.putStringArrayList("stringArrayListValue", arrayList);
    b.putBundle("nested", innerBundle1);

    JSONObject json = BundleJSONConverter.convertToJSON(b);
    assertNotNull(json);//from w  w  w  .ja v a2s . c  o m

    assertEquals(true, json.getBoolean("boolValue"));
    assertEquals(7, json.getInt("intValue"));
    assertEquals(5000000000l, json.getLong("longValue"));
    assertEquals(3.14, json.getDouble("doubleValue"), TestUtils.DOUBLE_EQUALS_DELTA);
    assertEquals("hello world", json.getString("stringValue"));

    JSONArray jsonArray = json.getJSONArray("stringArrayValue");
    assertEquals(2, jsonArray.length());
    assertEquals("first", jsonArray.getString(0));
    assertEquals("second", jsonArray.getString(1));

    jsonArray = json.getJSONArray("stringArrayListValue");
    assertEquals(3, jsonArray.length());
    assertEquals("1st", jsonArray.getString(0));
    assertEquals("2nd", jsonArray.getString(1));
    assertEquals("third", jsonArray.getString(2));

    JSONObject innerJson = json.getJSONObject("nested");
    assertEquals(1, innerJson.getInt("inner"));
    innerJson = innerJson.getJSONObject("nested bundle");
    assertEquals("2", innerJson.getString("inner"));

    jsonArray = innerJson.getJSONArray("deep list");
    assertEquals(2, jsonArray.length());
    assertEquals("7", jsonArray.getString(0));
    assertEquals("8", jsonArray.getString(1));

    Bundle finalBundle = BundleJSONConverter.convertToBundle(json);
    assertNotNull(finalBundle);

    assertEquals(true, finalBundle.getBoolean("boolValue"));
    assertEquals(7, finalBundle.getInt("intValue"));
    assertEquals(5000000000l, finalBundle.getLong("longValue"));
    assertEquals(3.14, finalBundle.getDouble("doubleValue"), TestUtils.DOUBLE_EQUALS_DELTA);
    assertEquals("hello world", finalBundle.getString("stringValue"));

    List<String> stringList = finalBundle.getStringArrayList("stringArrayValue");
    assertEquals(2, stringList.size());
    assertEquals("first", stringList.get(0));
    assertEquals("second", stringList.get(1));

    stringList = finalBundle.getStringArrayList("stringArrayListValue");
    assertEquals(3, stringList.size());
    assertEquals("1st", stringList.get(0));
    assertEquals("2nd", stringList.get(1));
    assertEquals("third", stringList.get(2));

    Bundle finalInnerBundle = finalBundle.getBundle("nested");
    assertEquals(1, finalInnerBundle.getInt("inner"));
    finalBundle = finalInnerBundle.getBundle("nested bundle");
    assertEquals("2", finalBundle.getString("inner"));

    stringList = finalBundle.getStringArrayList("deep list");
    assertEquals(2, stringList.size());
    assertEquals("7", stringList.get(0));
    assertEquals("8", stringList.get(1));
}

From source file:com.firebase.ui.auth.ui.phone.SubmitConfirmationCodeFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putLong(EXTRA_MILLIS_UNTIL_FINISHED, mMillisUntilFinished);
}

From source file:com.chocopepper.chococam.activity.friends.manage.FriendsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.friends);//from  ww w . j a  va2 s .com

    sharedPref = getSharedPreferences(Constants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE);
    selectedPagerIndex = sharedPref.getInt(PAGER_INDEX, VIEW_FRIENDLIST);

    ImageView btnCreatechat = (ImageView) findViewById(R.id.btnCreateChat);
    btnCreatechat.setVisibility(View.GONE);

    TextView txt_title = (TextView) findViewById(R.id.title);
    txt_title.setText(R.string.friends_tab_sub_suggestion);

    List<Fragment> fragments = new Vector<Fragment>();

    final Fragment frFreindsList = Fragment.instantiate(this, FriendsList.class.getName());

    Intent i = getIntent();
    long target_user_id = i.getLongExtra(Constants.TARGET_USER_ID,
            UserService.getDefaultUserId(FriendsActivity.this));
    Bundle args = new Bundle();
    args.putLong(Constants.TARGET_USER_ID, target_user_id);

    selectedPagerIndex = i.getIntExtra(PAGER_INDEX, selectedPagerIndex);

    frFreindsList.setArguments(args);
    fragments.add(frFreindsList);
    //fragments.add(Fragment.instantiate(this, FriendsList.class.getName()));

    fragments.add(Fragment.instantiate(this, RecommendedFriends.class.getName()));
    fragments.add(Fragment.instantiate(this, ReceivedRequests.class.getName()));

    btnEdit = (RelativeLayout) findViewById(R.id.btnEdit);
    btnEdit.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // ? ? ?   ?
            ((FriendsList) frFreindsList).switchEditMode();
        }
    });

    mAdapter = new FriendsAdapter(getSupportFragmentManager(), fragments);
    mAdapter.addTitle(this.getString(R.string.friends_tab_sub_current_friends));
    mAdapter.addTitle(this.getString(R.string.friends_tab_sub_suggestion));
    //mAdapter.addTitle(this.getString(R.string.friends_tab_sub_invitation));
    mAdapter.addTitle(this.getString(R.string.friends_tab_sub_received_invitation));

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAdapter);

    //  .
    mViewPager.setCurrentItem(selectedPagerIndex);
    // 2012-05-23 brucewang
    if (selectedPagerIndex == 0) {
        btnEdit.setVisibility(View.VISIBLE);
    }

    //mIndicator = (TitlePageIndicator)findViewById(R.id.indicator);
    //        mIndicator = (ViewPagerIndicator)findViewById(R.id.indicator);
    //      mIndicator.addPageChangeListener(this);
    //        mViewPager.setOnPageChangeListener(mIndicator);

    indicator = (TitlePageIndicator) findViewById(R.id.indicator);
    indicator.setFooterIndicatorStyle(IndicatorStyle.None);
    indicator.setViewPager(mViewPager, selectedPagerIndex);
    indicator.setOnPageChangeListener(this);
    mViewPager.setOnPageChangeListener(indicator);

}

From source file:com.popumovies.MainActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    Log.d(LOG_TAG, "onSaveInstanceState");
    outState.putLong(MOVIE_SAVE_KEY, mMovieId);
    outState.putInt(POSITION_SAVE_KEY, mPosition);

}

From source file:com.popumovies.DetailActivityFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putLong(MainActivity.MOVIE_SAVE_KEY, mMovieId);
    //outState.putInt("POSITION", mPosition);

}

From source file:com.robwilliamson.healthyesther.fragment.dialog.AbstractAddNamedDialogFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    if (mSuggestions != null) {
        Utils.Bundles.put(outState, SUGGESTIONS, mSuggestions, new Utils.Bundles.HashPutter() {
            @Override// w w  w.  j  a  va 2 s.  c o  m
            public void put(Bundle bundle, String bundleKey, String key) {
                Long value = mSuggestions.get(key);
                if (value != null) {
                    bundle.putLong(bundleKey, value);
                }
            }
        });
    }
}

From source file:com.folkcat.run.activity.PhotoViewPagerActivity.java

@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
    if (isViewPagerActive()) {
        outState.putBoolean(ISLOCKED_ARG, ((HackyViewPager) mViewPager).isLocked());
    }//from  w  w w.  j  a  v  a2 s  . c o m
    outState.putLong("runningId", mRunningId);
    outState.putInt("position", mPosition);
    super.onSaveInstanceState(outState);
}