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

The following are Jave code examples for showing how to use getLongArray() 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: SimpleDialogFragments   File: SimpleColorDialog.java   View Source Code Vote up 6 votes
@Override
protected Bundle onResult(int which) {
    Bundle b = super.onResult(which);
    int color = (int) b.getLong(SELECTED_SINGLE_ID);
    if (color == PICKER){
        b.putInt(COLOR, mCustomColor);
    } else {
        b.putInt(COLOR, color);
    }

    long[] ids = b.getLongArray(SELECTED_IDS);
    if (ids != null) {
        int[] colors = new int[ids.length];
        for (int i = 0; i < ids.length; i++) {
            if (ids[i] == PICKER) {
                colors[i] = mCustomColor;
            } else {
                colors[i] = (int) ids[i];
            }
        }
        b.putIntArray(COLORS, colors);
    }
    return b;
}
 
Example 2
Project: q-mail   File: MessageListFragment.java   View Source Code Vote up 5 votes
/**
 * Restore selected messages from a {@link Bundle}.
 */
private void restoreSelectedMessages(Bundle savedInstanceState) {
    long[] selected = savedInstanceState.getLongArray(STATE_SELECTED_MESSAGES);
    if (selected != null) {
        for (long id : selected) {
            this.selected.add(id);
        }
    }
}
 
Example 3
Project: GitHub   File: UpdatableFragmentPagerAdapter.java   View Source Code Vote up 5 votes
@Override
public void restoreState(@Nullable Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        long[] fss = bundle.getLongArray("states");
        mSavedStates.clear();
        mFragments.clear();
        if (fss != null) {
            for (long fs : fss) {
                mSavedStates.put(fs, (Fragment.SavedState) bundle.getParcelable(Long.toString(fs)));
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    f.setMenuVisibility(false);
                    mFragments.put(Long.parseLong(key.substring(1)), f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}
 
Example 4
Project: Quran   File: TagBookmarkDialog.java   View Source Code Vote up 5 votes
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  final Bundle args = getArguments();
  if (args != null) {
    long[] bookmarkIds = args.getLongArray(EXTRA_BOOKMARK_IDS);

    if (bookmarkIds != null) {
      mTagBookmarkPresenter.setBookmarksMode(bookmarkIds);
    }
  }
}
 
Example 5
Project: easyfilemanager   File: MultiSelectionUtil.java   View Source Code Vote up 5 votes
/**
 * This method should be called from your {@link AppCompatActivity} or
 * {@link android.support.v4.app.Fragment Fragment} to allow the controller to restore any
 * instance state.
 *
 * @param savedInstanceState - The state passed to your Activity or Fragment.
 */
public void restoreInstanceState(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        long[] checkedIds = savedInstanceState.getLongArray(getStateKey());
        if (checkedIds != null && checkedIds.length > 0) {
            HashSet<Long> idsToCheckOnRestore = new HashSet<Long>();
            for (long id : checkedIds) {
                idsToCheckOnRestore.add(id);
            }
            tryRestoreInstanceState(idsToCheckOnRestore);
        }
    }
}
 
Example 6
Project: orgzly-android   File: Selection.java   View Source Code Vote up 5 votes
/**
 * Restore selected items.
 * Saved with {@link Selection#saveIds(android.os.Bundle)}.
 */
public void restoreIds(Bundle bundle) {
    mSelectedIds.clear();

    if (bundle != null && bundle.containsKey(SAVED_BUNDLE_KEY)) {
        long[] ids = bundle.getLongArray(SAVED_BUNDLE_KEY);
        if (ids != null) {
            for (long id : ids) {
                mSelectedIds.add(id);
            }
        }
    }
}
 
Example 7
Project: revolution-irc   File: ChatPagerAdapter.java   View Source Code Vote up 5 votes
public void onRestoreInstanceState(Bundle bundle) {
    String[] keys = bundle.getStringArray("channel_ids_keys");
    long[] values = bundle.getLongArray("channel_ids_values");
    if (keys != null && values != null && keys.length == values.length) {
        for (int i = keys.length - 1; i >= 0; --i) {
            channelIds.put(keys[i], values[i]);
            nextChannelId = Math.max(nextChannelId, values[i] + 1);
        }
    }
    updateChannelList();
}
 
Example 8
Project: FireFiles   File: MultiSelectionUtil.java   View Source Code Vote up 5 votes
/**
 * This method should be called from your {@link AppCompatActivity} or
 * {@link android.support.v4.app.Fragment Fragment} to allow the controller to restore any
 * instance state.
 *
 * @param savedInstanceState - The state passed to your Activity or Fragment.
 */
public void restoreInstanceState(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        long[] checkedIds = savedInstanceState.getLongArray(getStateKey());
        if (checkedIds != null && checkedIds.length > 0) {
            HashSet<Long> idsToCheckOnRestore = new HashSet<Long>();
            for (long id : checkedIds) {
                idsToCheckOnRestore.add(id);
            }
            tryRestoreInstanceState(idsToCheckOnRestore);
        }
    }
}
 
Example 9
Project: simple-share-android   File: MultiSelectionUtil.java   View Source Code Vote up 5 votes
/**
 * This method should be called from your {@link AppCompatActivity} or
 * {@link android.support.v4.app.Fragment Fragment} to allow the controller to restore any
 * instance state.
 *
 * @param savedInstanceState - The state passed to your Activity or Fragment.
 */
public void restoreInstanceState(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        long[] checkedIds = savedInstanceState.getLongArray(getStateKey());
        if (checkedIds != null && checkedIds.length > 0) {
            HashSet<Long> idsToCheckOnRestore = new HashSet<Long>();
            for (long id : checkedIds) {
                idsToCheckOnRestore.add(id);
            }
            tryRestoreInstanceState(idsToCheckOnRestore);
        }
    }
}
 
Example 10
Project: aliyun-cloudphotos-android-demo   File: MoveActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_move_albums);

    unbinder = ButterKnife.bind(this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
    intentFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
    intentFilter.addDataScheme("file");

    Bundle bundle = getIntent().getExtras();
    sourceId = bundle.getLong("sourceId", 0);
    ids.clear();

    for (long item : bundle.getLongArray("ids")) {
        ids.add(item);
    }

    whatFragment = bundle.getInt("what", FragmentType.ALBUM_PHOTOS.ordinal());
    if (whatFragment == FragmentType.ALBUM_PHOTOS.ordinal()) {
        setTitle(getText(R.string.title_activity_move_albums));
    }
    else {
        setTitle(getText(R.string.title_activity_move_faces));
    }


    adapter = new MoveAdapter(this, cols);
    adapter.addHeader(new View(this));

    gridLayoutManager = new GridLayoutManager(this, cols);

    recyclerView.setLayoutManager(gridLayoutManager);
    recyclerView.setAdapter(adapter);
    gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return adapter.getSpanSize(position);
        }
    });
}
 
Example 11
Project: GitHub   File: Injector.java   View Source Code Vote up 4 votes
public long[] getLongArray(Bundle state, String key) {
    return state.getLongArray(key + baseKey);
}
 
Example 12
Project: android-state   File: InjectionHelper.java   View Source Code Vote up 4 votes
public long[] getLongArray(Bundle state, String key) {
    return state.getLongArray(key + mBaseKey);
}