Example usage for android.os Bundle getLong

List of usage examples for android.os Bundle getLong

Introduction

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

Prototype

public long getLong(String key) 

Source Link

Document

Returns the value associated with the given key, or 0L if no mapping of the desired type exists for the given key.

Usage

From source file:com.glanznig.beepme.view.SampleListFragment.java

private void updateStats() {
    BeeperApp app = (BeeperApp) getActivity().getApplication();
    Bundle stats = Statistics.getStatsOfToday(getActivity(), app.getTimerProfile());

    int numAccepted = 0;
    int numDeclined = 0;
    long uptimeDur = 0;

    if (stats != null) {
        if (stats.containsKey("uptimeDuration")) {
            uptimeDur = stats.getLong("uptimeDuration") / 1000;
        }//from  ww w.  j  a  va 2  s  .co  m
        if (stats.containsKey("acceptedSamples")) {
            numAccepted = stats.getInt("acceptedSamples");
        }
        if (stats.containsKey("declinedSamples")) {
            numDeclined = stats.getInt("declinedSamples");
        }
    }

    TextView acceptedToday = (TextView) getView().findViewById(R.id.samples_list_today_accepted);
    TextView declinedToday = (TextView) getView().findViewById(R.id.samples_list_today_declined);
    TextView beeperActive = (TextView) getView().findViewById(R.id.samples_list_today_elapsed);

    String timeActive = String.format("%02d:%02d:%02d", uptimeDur / 3600, (uptimeDur % 3600) / 60,
            (uptimeDur % 60));

    acceptedToday.setText(String.valueOf(numAccepted));
    declinedToday.setText(String.valueOf(numDeclined));
    beeperActive.setText(String.valueOf(timeActive));
}

From source file:com.bydavy.card.receipts.fragments.ReceiptAddFragment.java

private void refreshView(Bundle savedInstanceState) {
    if (savedInstanceState == null) {
        mViewShop.setText("");
        mViewNote.setText("");
        mViewTotal.setText("");
    } else {/*from  ww  w .jav  a2 s  .c o m*/
        mCalendar.setTimeInMillis(savedInstanceState.getLong(STATE_DATE));
        mViewShop.setText(savedInstanceState.getString(STATE_SHOP));
        mViewNote.setText(savedInstanceState.getString(STATE_NOTE));
        mViewTotal.setText(savedInstanceState.getString(STATE_TOTAL));
    }
    refreshDate();
}

From source file:com.nononsenseapps.feeder.ui.ReaderFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        _id = savedInstanceState.getLong(ARG_ID);
        mRssItem = RssItemFromBundle(savedInstanceState);

    } else if (mRssItem == null) {
        // Construct from arguments
        _id = getArguments().getLong(ARG_ID, -1);
        mRssItem = RssItemFromBundle(getArguments());
    }/*ww  w .  ja v a  2  s.  c  o m*/

    if (_id > 0) {
        RssContentProvider.MarkItemAsRead(getActivity(), _id);
    }

    setHasOptionsMenu(true);
}

From source file:com.pseudosudostudios.jdd.activities.WinActivity.java

/**
 * Method for unlocks(Entry) from a bundle
 *///ww w  . j a va2  s.c  o  m
public void unlocks(Bundle data) {
    Entry n = new Entry(data.getString(WinActivity.levelKey), data.getInt(WinActivity.moveKey),
            data.getLong(WinActivity.timeKey), Grid.numberOfColors);
    unlocks(n);
}

From source file:com.nextgis.firereporter.ScanexNotificationsActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mReceiver = new FiresResultReceiver(new Handler());
    mReceiver.setReceiver(this);

    setContentView(R.layout.scanex_notifications_activity);

    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    mNotesFragment = (ScanexNotificationsFragment) getSupportFragmentManager().findFragmentByTag("COMPASS");
    if (mNotesFragment == null) {
        mNotesFragment = new ScanexNotificationsFragment();
        fragmentTransaction.add(R.id.scanex_notes_container, mNotesFragment, "DETAILES").commit();
    }/*from w  ww. j av  a2  s . c  o  m*/

    getSupportFragmentManager().executePendingTransactions();

    //
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        ScanexSubscriptionItem item = extras.getParcelable(GetFiresService.ITEM);
        mNotesFragment.add(item.GetItems());
        mnSubscriptionId = extras.getLong(GetFiresService.SUBSCRIPTION_ID);
        mNotesFragment.addSubscriptionId(mnSubscriptionId);
    }

    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    StartService();
}

From source file:bbct.android.common.activity.BaseballCardDetails.java

@SuppressLint("StaticFieldLeak")
private void populateTextEdits() {
    Bundle args = getArguments();
    if (args != null) {
        id = args.getLong(ID);
        new AsyncTask<Long, Void, BaseballCard>() {
            @Override/*from   ww w .j  a va 2  s  .  co  m*/
            protected BaseballCard doInBackground(Long... args) {
                long id = args[0];
                BaseballCardDatabase database = BaseballCardDatabase.getInstance(getActivity());
                BaseballCardDao dao = database.getBaseballCardDao();
                return dao.getBaseballCard(id);
            }

            @Override
            protected void onPostExecute(BaseballCard card) {
                setCard(card);
            }
        }.execute(id);
    }
}

From source file:com.eleybourn.bookcatalogue.goodreads.api.BookshelfListApiHandler.java

/**
 * /*from  w w  w  .ja  v a  2 s . c  om*/
 * @param page
 * @return
 * @throws ClientProtocolException
 * @throws OAuthMessageSignerException
 * @throws OAuthExpectationFailedException
 * @throws OAuthCommunicationException
 * @throws NotAuthorizedException
 * @throws BookNotFoundException
 * @throws IOException
 * @throws NetworkException 
 */
public Bundle run(int page) throws ClientProtocolException, OAuthMessageSignerException,
        OAuthExpectationFailedException, OAuthCommunicationException, NotAuthorizedException,
        BookNotFoundException, IOException, NetworkException {
    long t0 = System.currentTimeMillis();

    // Sort by update_dte (descending) so sync is faster. Specify 'shelf=all' because it seems goodreads returns 
    // the shelf that is selected in 'My Books' on the web interface by default.
    final String urlBase = "http://www.goodreads.com/shelf/list.xml?key=%1$s&page=%2$s&user_id=%3$s";
    final String url = String.format(urlBase, mManager.getDeveloperKey(), page, mManager.getUserid());
    HttpGet get = new HttpGet(url);

    // Inital debug code:
    //TrivialParser handler = new TrivialParser();
    //mManager.execute(get, handler, true);
    //String s = handler.getHtml();
    //System.out.println(s);

    // Get a handler and run query.
    XmlResponseParser handler = new XmlResponseParser(mRootFilter);

    // Even thought it's only a GET, it needs a signature.
    mManager.execute(get, handler, true);

    // When we get here, the data has been collected but needs to be processed into standard form.
    Bundle results = mFilters.getData();

    // Return parsed results.
    long t1 = System.currentTimeMillis();
    System.out.println(
            "Found " + results.getLong(BookshelfListFieldNames.TOTAL) + " shelves in " + (t1 - t0) + "ms");
    return results;
}

From source file:com.andrew.apollo.ui.fragments.profile.PlaylistSongFragment.java

/**
 * {@inheritDoc}/* w  w w. ja  v a  2s. c  o  m*/
 */
@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    // Enable the options menu
    setHasOptionsMenu(true);
    // Start the loader
    final Bundle arguments = getArguments();
    if (arguments != null) {
        mPlaylistId = arguments.getLong(Config.ID);
        getLoaderManager().initLoader(LOADER, arguments, this);
    }
}

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 ww  w  .ja v  a 2s .c o  m*/

    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:de.elanev.studip.android.app.frontend.forums.ForumEntryFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle args = getArguments();
    mEntryId = args.getString(ForumEntry.ID);
    mContent = args.getString(ForumEntry.CONTENT);
    mSubject = args.getString(ForumEntry.SUBJECT);
    mDate = args.getLong(ForumEntry.DATE);
    mFullName = args.getString(User.NAME);
    mAvatar = args.getString(User.AVATAR);

    mAdapter = new ForumEntryAdapter(new ArrayList<ForumEntry>(), new ListItemClicks() {

        @Override/*from  w w  w. j  av  a  2 s.com*/
        public void onListItemClicked(View v, int position) {
        }

    }, getActivity());

    mObserver = new RecyclerView.AdapterDataObserver() {

        @Override
        public void onChanged() {
            super.onChanged();

            mEmptyView.setText(R.string.no_entries);
            toggleEmptyView(mAdapter.isEmpty());
        }
    };

    mAdapter.registerAdapterDataObserver(mObserver);
}