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, long defaultValue) 

Source Link

Document

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

Usage

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

@Override
public Loader<SynchronizedStateSavedList<ParcelableStatus, Long>> newLoaderInstance(final Bundle args) {
    final long account_id = args != null ? args.getLong(INTENT_KEY_ACCOUNT_ID, -1) : -1;
    return new DummyParcelableStatusesLoader(getActivity(), account_id, getData());
}

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

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mApplication = getApplication();/*  w  w w.  j ava2  s  . c  o  m*/
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    final Bundle args = getArguments() != null ? getArguments() : new Bundle();
    if (args != null) {
        mAccountId = args.getLong(INTENT_KEY_ACCOUNT_ID, -1);
        mUserId = args.getLong(INTENT_KEY_USER_ID, -1);
        mScreenName = args.getString(INTENT_KEY_SCREEN_NAME);
    }
    mAdapter = new UserListsAdapter(getActivity());
    mListView = getListView();
    final long account_id = args.getLong(INTENT_KEY_ACCOUNT_ID, -1);
    if (mAccountId != account_id) {
        mAdapter.clear();
        mData.clear();
    }
    mAccountId = account_id;
    mListView.setOnItemClickListener(this);
    mListView.setOnItemLongClickListener(this);
    mListView.setOnScrollListener(this);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        mListView.setCacheColorHint(0);
    }
    setMode(Mode.BOTH);
    setListAdapter(mAdapter);
    getLoaderManager().initLoader(0, getArguments(), this);
    setListShown(false);
}

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

@Override
public Loader<List<ParcelableUser>> newLoaderInstance() {
    final Bundle args = getArguments();
    int list_id = -1;
    long account_id = -1, user_id = -1;
    String screen_name = null, list_name = null;
    if (args != null) {
        list_id = args.getInt(INTENT_KEY_LIST_ID, -1);
        account_id = args.getLong(INTENT_KEY_ACCOUNT_ID, -1);
        user_id = args.getLong(INTENT_KEY_USER_ID, -1);
        screen_name = args.getString(INTENT_KEY_SCREEN_NAME);
        list_name = args.getString(INTENT_KEY_LIST_NAME);
    }/*  w w  w . ja  v a  2 s  .  c o m*/
    return new UserListMembersLoader(getActivity(), account_id, list_id, user_id, screen_name, list_name,
            mCursor, getData());
}

From source file:com.kunze.androidlocaltodo.TaskActivityFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log("onCreateView");
    mProgrammaticChange = true;//from  www . j a  v  a2 s .  c om
    TaskDatabase db = new TaskDatabase(getActivity());
    View rootView = inflater.inflate(R.layout.activity_task, container, false);
    Bundle args = getArguments();
    long id = args.getLong(TaskActivity.TASK_ID, 0);
    Task task = db.LoadTask(id);
    mOriginalTask = task;
    if (savedInstanceState != null) {
        mNewTask = (Task) savedInstanceState.getSerializable("mNewTask");
        if (!mOriginalTask.equals(mNewTask)) {
            mProgrammaticChange = false;
            TaskChanged(rootView);
            mProgrammaticChange = true;
        }
    } else {
        mNewTask = new Task(task);
    }

    InitializeView(rootView);
    InitializeViewFields(rootView, task);
    return rootView;
}

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

@Override
public Loader<SynchronizedStateSavedList<ParcelableStatus, Long>> newLoaderInstance(final Bundle args) {
    int list_id = -1;
    long account_id = -1, max_id = -1, since_id = -1, user_id = -1;
    String screen_name = null, list_name = null;
    boolean is_home_tab = false;
    if (args != null) {
        list_id = args.getInt(INTENT_KEY_LIST_ID, -1);
        account_id = args.getLong(INTENT_KEY_ACCOUNT_ID, -1);
        max_id = args.getLong(INTENT_KEY_MAX_ID, -1);
        since_id = args.getLong(INTENT_KEY_SINCE_ID, -1);
        user_id = args.getLong(INTENT_KEY_USER_ID, -1);
        screen_name = args.getString(INTENT_KEY_SCREEN_NAME);
        list_name = args.getString(INTENT_KEY_LIST_NAME);
        is_home_tab = args.getBoolean(INTENT_KEY_IS_HOME_TAB);
    }//w  w w. j a  v  a2s.  c o  m
    return new UserListTimelineLoader(getActivity(), account_id, list_id, user_id, screen_name, list_name,
            max_id, since_id, getData(), getClass().getSimpleName(), is_home_tab);
}

From source file:de.vanita5.twittnuker.activity.support.MediaViewerActivity.java

@Override
public Loader<TileImageLoader.Result> onCreateLoader(final int id, final Bundle args) {
    mProgress.setVisibility(View.VISIBLE);
    mProgress.setIndeterminate(true);/* w  w w  .j  a  v a2  s .c  o  m*/
    invalidateOptionsMenu();
    final Uri uri = args.getParcelable(EXTRA_URI);
    final long accountId = args.getLong(EXTRA_ACCOUNT_ID, -1);
    return new TileImageLoader(this, this, accountId, uri);
}

From source file:de.spiritcroc.ownlog.ui.fragment.LogAttachmentsShowFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);//from w  w w .  ja v a2s  .c om

    if (savedInstanceState != null) {
        mLogId = savedInstanceState.getLong(Constants.EXTRA_LOG_ITEM_ID, -1);
        if (mLogId == -1) {
            Log.w(TAG, "onCreate: could not find out log id from saved instance");
        }
    } else if (getArguments() == null) {
        Log.e(TAG, "onCreate: getArguments() == null");
    } else {
        mLogId = getArguments().getLong(Constants.EXTRA_LOG_ITEM_ID, -1);
        if (mLogId == -1) {
            Log.w(TAG, "onCreate: could not find out log id");
        }
    }

    calculateViewWidth();
    mPicturePreviewScale = getResources().getInteger(R.integer.attachment_picture_preview_scale);
}

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

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setPullToRefreshEnabled(false);/*from  w w w  .ja  v a2  s  .  c  o m*/
    mAdapter = getListAdapter();
    mAdapter.setGapDisallowed(true);
    Bundle bundle = getArguments();
    if (bundle == null) {
        bundle = new Bundle();
    }
    account_id = bundle.getLong(INTENT_KEY_ACCOUNT_ID, INVALID_ID);
    final long status_id = bundle.getLong(INTENT_KEY_STATUS_ID, INVALID_ID);

    if (mShowConversationTask != null && !mShowConversationTask.isCancelled()) {
        mShowConversationTask.cancel(true);
    }
    mStatusHandler = new StatusHandler(mAdapter, account_id);
    mShowConversationTask = new ShowConversationTask(mStatusHandler, account_id, status_id);

    if (account_id != INVALID_ID && status_id != INVALID_ID) {

        mShowConversationTask.execute();
    }
}

From source file:jp.sonymusicstudio.cast.castcompanionlibrary.utils.Utils.java

/**
 * Builds and returns a {@link MediaInfo} that was wrapped in a {@link Bundle} by
 * <code>mediaInfoToBundle</code>. It is assumed that the type of the {@link MediaInfo} is
 * {@code MediaMetaData.MEDIA_TYPE_MOVIE}
 *
 * @see <code>mediaInfoToBundle()</code>
 *///from w ww .  j  a v a  2  s. co  m
public static MediaInfo bundleToMediaInfo(Bundle wrapper) {
    if (wrapper == null) {
        return null;
    }

    MediaMetadata metaData = new MediaMetadata(wrapper.getInt(KEY_MEDIA_TYPE));

    metaData.putString(MediaMetadata.KEY_SUBTITLE, wrapper.getString(MediaMetadata.KEY_SUBTITLE));
    metaData.putString(MediaMetadata.KEY_TITLE, wrapper.getString(MediaMetadata.KEY_TITLE));
    metaData.putString(MediaMetadata.KEY_STUDIO, wrapper.getString(MediaMetadata.KEY_STUDIO));
    metaData.putString(MediaMetadata.KEY_ALBUM_ARTIST, wrapper.getString(MediaMetadata.KEY_ALBUM_ARTIST));
    metaData.putString(MediaMetadata.KEY_ALBUM_TITLE, wrapper.getString(MediaMetadata.KEY_ALBUM_TITLE));
    metaData.putString(MediaMetadata.KEY_COMPOSER, wrapper.getString(MediaMetadata.KEY_COMPOSER));
    metaData.putString(MediaMetadata.KEY_SERIES_TITLE, wrapper.getString(MediaMetadata.KEY_SERIES_TITLE));

    metaData.putInt(MediaMetadata.KEY_SEASON_NUMBER, wrapper.getInt(MediaMetadata.KEY_SEASON_NUMBER));
    metaData.putInt(MediaMetadata.KEY_EPISODE_NUMBER, wrapper.getInt(MediaMetadata.KEY_EPISODE_NUMBER));

    long releaseDateMillis = wrapper.getLong(MediaMetadata.KEY_RELEASE_DATE, 0);
    if (releaseDateMillis > 0) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(releaseDateMillis);
        metaData.putDate(MediaMetadata.KEY_RELEASE_DATE, calendar);
    }

    ArrayList<String> images = wrapper.getStringArrayList(KEY_IMAGES);
    if (images != null && !images.isEmpty()) {
        for (String url : images) {
            Uri uri = Uri.parse(url);
            metaData.addImage(new WebImage(uri));
        }
    }

    String customDataStr = wrapper.getString(KEY_CUSTOM_DATA);
    JSONObject customData = null;
    if (!TextUtils.isEmpty(customDataStr)) {
        try {
            customData = new JSONObject(customDataStr);
        } catch (JSONException e) {
            LOGE(TAG, "Failed to deserialize the custom data string: custom data= " + customDataStr);
        }
    }

    List<MediaTrack> mediaTracks = null;
    if (wrapper.getString(KEY_TRACKS_DATA) != null) {
        try {
            JSONArray jsonArray = new JSONArray(wrapper.getString(KEY_TRACKS_DATA));
            mediaTracks = new ArrayList<MediaTrack>();

            if (jsonArray.length() > 0) {
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject jsonObj = (JSONObject) jsonArray.get(i);
                    MediaTrack.Builder builder = new MediaTrack.Builder(jsonObj.getLong(KEY_TRACK_ID),
                            jsonObj.getInt(KEY_TRACK_TYPE));
                    if (jsonObj.has(KEY_TRACK_NAME)) {
                        builder.setName(jsonObj.getString(KEY_TRACK_NAME));
                    }
                    if (jsonObj.has(KEY_TRACK_SUBTYPE)) {
                        builder.setSubtype(jsonObj.getInt(KEY_TRACK_SUBTYPE));
                    }
                    if (jsonObj.has(KEY_TRACK_CONTENT_ID)) {
                        builder.setContentType(jsonObj.getString(KEY_TRACK_CONTENT_ID));
                    }
                    if (jsonObj.has(KEY_TRACK_LANGUAGE)) {
                        builder.setLanguage(jsonObj.getString(KEY_TRACK_LANGUAGE));
                    }
                    if (jsonObj.has(KEY_TRACKS_DATA)) {
                        builder.setCustomData(new JSONObject(jsonObj.getString(KEY_TRACKS_DATA)));
                    }
                    mediaTracks.add(builder.build());
                }
            }

        } catch (JSONException e) {
            LOGE(TAG, "Failed to build media tracks from the wrapper bundle", e);
        }
    }
    MediaInfo.Builder mediaBuilder = new MediaInfo.Builder(wrapper.getString(KEY_URL))
            .setStreamType(wrapper.getInt(KEY_STREAM_TYPE)).setContentType(wrapper.getString(KEY_CONTENT_TYPE))
            .setMetadata(metaData).setCustomData(customData).setMediaTracks(mediaTracks);

    if (wrapper.containsKey(KEY_STREAM_DURATION) && wrapper.getLong(KEY_STREAM_DURATION) >= 0) {
        mediaBuilder.setStreamDuration(wrapper.getLong(KEY_STREAM_DURATION));
    }

    return mediaBuilder.build();
}