Example usage for android.os Bundle getLongArray

List of usage examples for android.os Bundle getLongArray

Introduction

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

Prototype

@Nullable
public long[] getLongArray(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:org.sufficientlysecure.keychain.ui.EncryptAsymmetricFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case REQUEST_CODE_PUBLIC_KEYS: {
        if (resultCode == Activity.RESULT_OK) {
            Bundle bundle = data.getExtras();
            setEncryptionKeyIds(bundle.getLongArray(SelectPublicKeyActivity.RESULT_EXTRA_MASTER_KEY_IDS));
        }//from ww  w .j a va  2s . com
        break;
    }

    case REQUEST_CODE_SECRET_KEYS: {
        if (resultCode == Activity.RESULT_OK) {
            Uri uriMasterKey = data.getData();
            setSignatureKeyId(Long.valueOf(uriMasterKey.getLastPathSegment()));
        } else {
            setSignatureKeyId(Constants.key.none);
        }
        break;
    }

    default: {
        super.onActivityResult(requestCode, resultCode, data);

        break;
    }
    }
}

From source file:com.btmura.android.reddit.app.FragmentStateItemPagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);/*ww  w.j  a v  a2  s . c o m*/
        mItemIds = bundle.getLongArray("itemIds");
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();
        mFragments.clear();
        if (fss != null) {
            for (int i = 0; i < fss.length; i++) {
                mSavedState.add((Fragment.SavedState) fss[i]);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (mFragments.size() <= index) {
                        mFragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}

From source file:ca.marklauman.dominionpicker.MarketActivity.java

/** Setup the black market. */
private void setupMarketStall() {
    Bundle extras = getIntent().getExtras();

    // load the supply
    HashSet<Long> supply = new HashSet<>();
    long[] supply_arr = extras.getLongArray(PARAM_SUPPLY);
    if (supply_arr != null)
        for (long id : supply_arr)
            supply.add(id);//www  .  ja v a 2s  .c  om

    // load the deck of available cards
    long[] deck_arr = extras.getLongArray(PARAM_CARDS);
    ArrayList<Long> deck = new ArrayList<>(deck_arr.length);
    for (long card : deck_arr)
        if (!supply.contains(card))
            deck.add(card);

    // shuffle the deck to make the stock
    stock = new LinkedList<>();
    while (deck.size() > 0) {
        int pick = (int) (Math.random() * deck.size());
        stock.add(deck.get(pick));
        deck.remove(pick);
    }
}

From source file:com.example.craiger.nav.FragmentItemIdStatePagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);//from   www.j a  v  a  2 s . c o m
        long[] itemIdsForState = bundle.getLongArray("itemIdsForState");
        Parcelable[] fss = bundle.getParcelableArray("states");
        mFragmentToItemIdMap.clear();
        mItemIdToFragmentMap.clear();
        mUnusedRestoredFragments.clear();
        mSavedState.clear();
        if (fss != null) {
            for (int i = 0; i < fss.length; i++) {
                mSavedState.put(itemIdsForState[i], (Fragment.SavedState) fss[i]);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith(KEY_FRAGMENT)) {
                Long itemId = Long.parseLong(key.substring(KEY_FRAGMENT.length()));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    f.setMenuVisibility(false);
                    mFragmentToItemIdMap.put(f, itemId);
                    mItemIdToFragmentMap.put(itemId, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
        mUnusedRestoredFragments.addAll(mFragmentToItemIdMap.keySet());
    }
}

From source file:org.projectbuendia.client.ui.dialogs.OrderExecutionDialogFragment.java

void updateUi(boolean orderExecutedNow) {
    Bundle args = getArguments();
    LocalDate date = new DateTime(Utils.getLong(args, "intervalStartMillis")).toLocalDate();
    List<DateTime> executionTimes = new ArrayList<>();
    for (long millis : args.getLongArray("executionTimes")) {
        executionTimes.add(new DateTime(millis));
    }//from w  ww  .  j a  v a  2 s  . c  o  m

    // Show what was ordered and when the order started.
    mOrderInstructions.setText(args.getString("instructions"));
    DateTime start = Utils.getDateTime(args, "orderStartMillis");
    mOrderStartTime.setText(getResources().getString(R.string.order_started_on_date_at_time,
            Utils.toShortString(start.toLocalDate()), Utils.toTimeOfDayString(start)));

    // Describe how many times the order was executed during the selected interval.
    int count = executionTimes.size() + (orderExecutedNow ? 1 : 0);
    boolean plural = count != 1;
    mOrderExecutionCount.setText(Html.fromHtml(getResources().getString(
            date.equals(LocalDate.now())
                    ? (plural ? R.string.order_execution_today_plural_html
                            : R.string.order_execution_today_singular_html)
                    : (plural ? R.string.order_execution_historical_plural_html
                            : R.string.order_execution_historical_singular_html),
            count, Utils.toShortString(date))));

    // Show the list of times that the order was executed during the selected interval.
    boolean editable = args.getBoolean("editable");
    Utils.showIf(mOrderExecutionList, executionTimes.size() > 0 || editable);
    List<String> htmlItems = new ArrayList<>();
    for (DateTime executionTime : executionTimes) {
        htmlItems.add(Utils.toTimeOfDayString(executionTime));
    }
    if (editable) {
        DateTime encounterTime = Utils.getDateTime(args, "encounterTimeMillis");
        htmlItems.add(
                orderExecutedNow ? "<b>" + Utils.toTimeOfDayString(encounterTime) + "</b>" : "<b>&nbsp;</b>"); // keep total height stable
    }
    mOrderExecutionList.setText(Html.fromHtml(Joiner.on("<br>").join(htmlItems)));
}

From source file:com.example.newfragmentstatepageradapter.NewFragmentStatePagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);//from  w w  w .  ja v  a 2s  .  co m
        mItemIds = bundle.getLongArray("itemids");
        if (mItemIds == null) {
            mItemIds = new long[] {};
        }
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();
        mFragments.clear();
        if (fss != null) {
            for (int i = 0; i < fss.length; i++) {
                mSavedState.add((Fragment.SavedState) fss[i]);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (mFragments.size() <= index) {
                        mFragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}

From source file:com.kevinread.sortablefragmentpager.SortableFragmentStatePagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);//www. ja v  a2 s.  co m

        mItemIds = bundle.getLongArray("itemids");
        if (mItemIds == null) {
            mItemIds = new long[] {};
        }

        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();
        mFragments.clear();
        if (fss != null) {
            for (int i = 0; i < fss.length; i++) {
                mSavedState.add((Fragment.SavedState) fss[i]);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (mFragments.size() <= index) {
                        mFragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
        checkForIdChanges();
    }
}

From source file:mobisocial.musubi.ui.FeedIdentityGrid.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    long[] ids;//from  w  w  w  .j a v  a2 s.c om
    if (args == null) {
        ids = new long[0];
    } else {
        ids = args.getLongArray("ids");
    }
    switch (id) {
    case LOAD_FEEDS:
        return new FeedsWithMembersLoader(this, mFeedManager, ids);
    }
    return null;
}

From source file:org.totschnig.myexpenses.activity.ManageCategories.java

@Override
public void onCategorySelected(Bundle args) {
    finishActionMode();//ww  w. j ava 2s  .c om
    final long target = args.getLong(SelectMainCategoryDialogFragment.KEY_RESULT);
    startTaskExecution(TaskExecutionFragment.TASK_MOVE_CATEGORY,
            ArrayUtils.toObject(args.getLongArray(TaskExecutionFragment.KEY_OBJECT_IDS)),
            target == 0L ? null : target, R.string.progress_dialog_saving);
}

From source file:com.aboveware.actionbar.support.ExpandableListFragmentSupport.java

/**
 * Attach to list view once the view hierarchy has been created.
 *///  w  ww . ja v  a2 s .  c  o m
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ensureList();
    if (savedInstanceState != null) {
        expandedIds = savedInstanceState.getLongArray(ExpandableListAdapter.EXPANDED_IDS);
    }
}