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

The following are Jave code examples for showing how to use getLong() 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: OSchina_resources_android   File: TweetFragment.java   View Source Code Vote up 6 votes
@Override
protected void initBundle(Bundle bundle) {
    super.initBundle(bundle);
    isShowIdentityView = bundle.getBoolean("isShowIdentityView", true);
    mReqCatalog = bundle.getInt(BUNDLE_KEY_REQUEST_CATALOG, CATALOG_NEW);
    switch (mReqCatalog) {
        case CATALOG_FRIENDS:
        case CATALOG_SOMEONE:
        case CATALOG_MYSELF:
            mUserId = bundle.getLong(BUNDLE_KEY_USER_ID, AccountHelper.getUserId());
            break;
        case CATALOG_TAG:
            tag = bundle.getString(BUNDLE_KEY_TAG);
            setHasOptionsMenu(true);
            break;
    }
}
 
Example 2
Project: AndroidMuseumBleManager   File: BluetoothLeDevice.java   View Source Code Vote up 6 votes
/**
 * Instantiates a new bluetooth le device.
 *
 * @param in the in
 */
@SuppressWarnings("unchecked")
protected BluetoothLeDevice(final Parcel in) {
    final Bundle b = in.readBundle(getClass().getClassLoader());
    mCurrentRssi = b.getInt(PARCEL_EXTRA_CURRENT_RSSI, 0);
    mCurrentTimestamp = b.getLong(PARCEL_EXTRA_CURRENT_TIMESTAMP, 0);
    mDevice = b.getParcelable(PARCEL_EXTRA_BLUETOOTH_DEVICE);
    mFirstRssi = b.getInt(PARCEL_EXTRA_FIRST_RSSI, 0);
    mFirstTimestamp = b.getLong(PARCEL_EXTRA_FIRST_TIMESTAMP, 0);
    mRecordStore = b.getParcelable(PARCEL_EXTRA_DEVICE_SCANRECORD_STORE);
    mRssiLog = (Map<Long, Integer>) b.getSerializable(PARCEL_EXTRA_DEVICE_RSSI_LOG);
    mScanRecord = b.getByteArray(PARCEL_EXTRA_DEVICE_SCANRECORD);
}
 
Example 3
Project: LifeHelper   File: UpdateActivity.java   View Source Code Vote up 6 votes
@Override
public void handleMessage(Message msg) {
    super.handleMessage(msg);
    switch (msg.what) {
        case HANDLER_LOADING:
            //实时更新进度
            Bundle bundle = msg.getData();
            long transferedBytes = bundle.getLong("transferedBytes");
            long totalSize = bundle.getLong("totalSize");
            mTvTextSize.setText(transferedBytes + "/" + totalSize);
            //设置进度,百分比形式
            mNumberProgressBar.setProgress((int) (((float)transferedBytes / (float) totalSize) *
                    100));
            break;
        case HANDLER_OK:
            mTvTextSize.setText("下载成功");
            //启动这个应用安装
            startInstallApk();
            break;
        case HANDLER_FAIL:
            mTvTextSize.setText("下载失败");
            break;
    }
}
 
Example 4
Project: Todule-android   File: ToduleLabelAddFragment.java   View Source Code Vote up 6 votes
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    if(args.containsKey("label_id")){
        labelId = args.getLong("label_id");
    }
    if (savedInstanceState != null){
        selected_color = savedInstanceState.getInt("selected_color");
        labelId = savedInstanceState.getLong("label_id");
    }
    if(labelId != null){
        Uri labelUri = ContentUris.withAppendedId(ToduleDBContract.TodoLabel.CONTENT_ID_URI_BASE, labelId);
        Cursor cr = getContext().getContentResolver().query(labelUri, null, null, null, null);
        cr.moveToFirst();
        selected_color = cr.getInt(cr.getColumnIndexOrThrow(ToduleDBContract.TodoLabel.COLUMN_NAME_COLOR));
        label_text = cr.getString(cr.getColumnIndexOrThrow(ToduleDBContract.TodoLabel.COLUMN_NAME_TAG));
        label_text_color = cr.getInt(cr.getColumnIndexOrThrow(ToduleDBContract.TodoLabel.COLUMN_NAME_TEXT_COLOR));
        cr.close();
    }

}
 
Example 5
Project: justintrain-client-android   File: JourneyResultsPresenter.java   View Source Code Vote up 6 votes
@Override
public void setState(Bundle bundle) {
    if (bundle != null) {
        // Restore value of members from saved state
        if (bundle.getString(I_STATIONS) != null) {
            PreferredJourney journey = gson.fromJson(bundle.getString(I_STATIONS), PreferredJourney.class);
            this.departureStation = journey.getStation1();
            this.arrivalStation = journey.getStation2();
            view.setStationNames(departureStation.getNameLong(), arrivalStation.getNameLong());
            setFavouriteButtonStatus();
        }
        this.dateTime = new DateTime(bundle.getLong(I_TIME, DateTime.now().getMillis()));
        this.isSearchComingFromSwipe = bundle.getBoolean(I_FROM_SWIPE, false);
    } else {
    }
}
 
Example 6
Project: buildAPKsSamples   File: GestureBuilderActivity.java   View Source Code Vote up 6 votes
@Override
    protected void onRestoreInstanceState(Bundle state) {
        super.onRestoreInstanceState(state);

        long id = state.getLong(GESTURES_INFO_ID, -1);
        if (id != -1) {
            final Set<String> entries = sStore.getGestureEntries();
out:        for (String name : entries) {
                for (Gesture gesture : sStore.getGestures(name)) {
                    if (gesture.getID() == id) {
                        mCurrentRenameGesture = new NamedGesture();
                        mCurrentRenameGesture.name = name;
                        mCurrentRenameGesture.gesture = gesture;
                        break out;
                    }
                }
            }
        }
    }
 
Example 7
Project: AndroidBackendlessChat   File: TokenCachingStrategy.java   View Source Code Vote up 6 votes
/**
 * Returns a boolean indicating whether a Bundle contains properties that
 * could be a valid saved token.
 * 
 * @param bundle
 *            A Bundle to check for token information.
 * @return a boolean indicating whether a Bundle contains properties that
 *         could be a valid saved token.
 */
public static boolean hasTokenInformation(Bundle bundle) {
    if (bundle == null) {
        return false;
    }

    String token = bundle.getString(TOKEN_KEY);
    if ((token == null) || (token.length() == 0)) {
        return false;
    }

    long expiresMilliseconds = bundle.getLong(EXPIRATION_DATE_KEY, 0L);
    if (expiresMilliseconds == 0L) {
        return false;
    }

    return true;
}
 
Example 8
Project: aliyun-cloudphotos-android-demo   File: CloudPhotosActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cloud_photos);

    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();
    albumId = bundle.getLong("albumId", 0);

    adapter = new CloudPhotosAdapter(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 9
Project: schulcloud-mobile-android   File: BaseDialog.java   View Source Code Vote up 5 votes
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mActivityId = savedInstanceState != null ?
        savedInstanceState.getLong(KEY_ACTIVITY_ID)
        : NEXT_ID.getAndIncrement();
}
 
Example 10
Project: buildAPKsSamples   File: SnakeView.java   View Source Code Vote up 5 votes
/**
 * Restore game state if our process is being relaunched
 * 
 * @param icicle a Bundle containing the game state
 */
public void restoreState(Bundle icicle) {
    setMode(PAUSE);

    mAppleList = coordArrayToArrayList(icicle.getIntArray("mAppleList"));
    mDirection = icicle.getInt("mDirection");
    mNextDirection = icicle.getInt("mNextDirection");
    mMoveDelay = icicle.getLong("mMoveDelay");
    mScore = icicle.getLong("mScore");
    mSnakeTrail = coordArrayToArrayList(icicle.getIntArray("mSnakeTrail"));
}
 
Example 11
Project: dcs-sdk-java   File: AccessTokenManager.java   View Source Code Vote up 5 votes
/**
 * 通过Parcel流构建AccessTokenManager,主要用在Parcelable.Creator中
 *
 * @param source Parcel 流信息
 */
public AccessTokenManager(Parcel source) {
    Bundle bundle = Bundle.CREATOR.createFromParcel(source);
    if (bundle != null) {
        this.accessToken = bundle.getString(OauthConfig.BundleKey.KEY_ACCESS_TOKEN);
        this.expireTime = bundle.getLong(OauthConfig.BundleKey.KEY_EXPIRE_TIME);
    }
    compareWithConfig();
}
 
Example 12
Project: Project-Assistant   File: TasksFragment.java   View Source Code Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_tasks, container, false);
    ButterKnife.bind(this, v);

    Bundle bundle = getArguments();
    state = bundle.getInt("state");
    project_id = bundle.getLong("project_id");

    return v;
}
 
Example 13
Project: BonAppetit_Android-Project   File: MapsActivity.java   View Source Code Vote up 5 votes
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_PLACE_PICKER) {
        if (resultCode == Activity.RESULT_OK) {
            Place place = PlacePicker.getPlace(this,data);
            Map<String,Object>shareLocation=new HashMap<>();
            shareLocation.put("time", ServerValue.TIMESTAMP);
            //get data from Login Activity
            Intent in=getIntent();
            Bundle b=in.getExtras();
            String name=b.getString("name");
            Long number=b.getLong("contact_no");
            Toast.makeText(this,"name: "+name+" number: "+number.toString(),Toast.LENGTH_SHORT).show();
            //Map<String,Long>userData=new HashMap<>();
            //userData.put(name,number);
            Map userData=new HashMap();
            userData.put(name,number);
            mFirebase.child(FIREBASE_ROOT_NODE).child(place.getId()).setValue(shareLocation);
            Firebase fire=new Firebase(FIREBASE_URL);
            Firebase userRef=fire.child(FIREBASE_ROOT_NODE);
            Firebase people=userRef.child(place.getId());
            people.updateChildren(userData);
            //mFirebase.child(FIREBASE_ROOT_NODE).child(place.getId());
            //mFirebase.setValue(userData);
            Toast.makeText(this,"added:"+name+" "+number,Toast.LENGTH_SHORT).show();
            //Toast.makeText(this,"added location",Toast.LENGTH_SHORT).show();
        } else if (resultCode == PlacePicker.RESULT_ERROR) {
            Toast.makeText(this, "Places API failure! Check that the API is enabled for your key",
                    Toast.LENGTH_LONG).show();
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
Example 14
Project: aos-Video   File: Browser.java   View Source Code Vote up 5 votes
/**
 * Subclasses must create a new BrowserAdapter and according to the adapter
 * class, create a new ThumbnailRequester.
 */
@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    mSelectedPosition=0;
    mContext = getActivity().getApplicationContext();

    mPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());

    mThumbnailEngine = ThumbnailEngineVideo.getInstance(mContext);
    mThumbnailEngine.setThumbnailSize(
            getResources().getDimensionPixelSize(R.dimen.video_details_poster_width),
            getResources().getDimensionPixelSize(R.dimen.video_details_poster_height));
    Bundle posBundle = bundle!=null?bundle:getArguments();

    if (posBundle != null) {
        mFirstVisiblePosition = posBundle.getInt(FIRST_VISIBLE_POSITION);
        mSelectedPosition = posBundle.getInt(SELECTED_POSITION);
        mScroll = posBundle.getInt(CURRENT_SCROLL);
        mListState= posBundle.getParcelable(LIST_STATE_KEY);
    }
    if (bundle != null) {
        mCopyName = bundle.getString(COPY_NAME);
        mCopyLength = bundle.getLong(COPY_LENGTH);
        mCopyDialogID = bundle.getInt(COPY_DIALOG);
    }
    setHasOptionsMenu(true);
}
 
Example 15
Project: syncplayer   File: UserListDialogFragment.java   View Source Code Vote up 5 votes
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    if (getArguments().getBundle("0") == null) {

        holder.duration.setText("");
        holder.durationLabel.setText("");
        holder.fileSize.setText("");
        holder.fileSizeLabel.setText("");
        holder.fileName.setText("");
        holder.fileNameLabel.setText("");

        holder.userName.setText("No one else here");
        holder.userNameLabel.setText("");
    } else {
        Bundle user = getArguments().getBundle(String.valueOf(position));
        holder.userName.setText(user.getString("username"));
        if (user.getLong("duration") == 0) {
            holder.duration.setText("");
        } else {
            holder.duration.setText(String.valueOf(user.getLong("duration")));
        }
        if (user.getLong("size") == 0) {
            holder.fileSize.setText("");
        } else {
            holder.fileSize.setText(String.valueOf(user.getLong("size")));
        }
        holder.fileName.setText(user.getString("filename"));
    }
}
 
Example 16
Project: OSchina_resources_android   File: SignUpFragment.java   View Source Code Vote up 4 votes
@Override
protected void initBundle(Bundle bundle) {
    super.initBundle(bundle);
    mSourceId = bundle.getLong("sourceId", 0);
}
 
Example 17
Project: Todule-android   File: ToduleAddFragment.java   View Source Code Vote up 4 votes
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle bundle = this.getArguments();
    if(bundle != null){
        mode = bundle.getString("mode");
        if(bundle.containsKey("entry_id")){
            entryId = bundle.getLong("entry_id");
        } else {
            entryId = null;
        }
    }

    if(savedInstanceState != null){
        myCalendar = (Calendar) savedInstanceState.getSerializable("calendar");
        chosenLabelId = savedInstanceState.getLong("chosen_label_id", -1L);
        title = savedInstanceState.getString("title");
    } else {
        myCalendar = Calendar.getInstance();
        // Default for new entry
        myCalendar.set(Calendar.HOUR_OF_DAY, 23);
        myCalendar.set(Calendar.MINUTE, 59);
        myCalendar.set(Calendar.SECOND, 0);

        if (mode.equals("edit_entry")){
            Uri entryUri = ContentUris.withAppendedId(ToduleDBContract.TodoEntry.CONTENT_ID_URI_BASE, entryId);
            Cursor cr = getContext().getContentResolver().query(entryUri, TodoEntry.PROJECTION_ALL, null, null, TodoEntry.SORT_ORDER_DEFAULT);
            cr.moveToFirst();

            long dueDateInMillis = cr.getLong(cr.getColumnIndexOrThrow(TodoEntry.COLUMN_NAME_DUE_DATE));
            title = cr.getString(cr.getColumnIndexOrThrow(TodoEntry.COLUMN_NAME_TITLE));
            description = cr.getString(cr.getColumnIndexOrThrow(TodoEntry.COLUMN_NAME_DESCRIPTION));
            if(cr.isNull(cr.getColumnIndexOrThrow(TodoEntry.COLUMN_NAME_LABEL))){
                chosenLabelId = -1L;
            } else{
                chosenLabelId = cr.getLong(cr.getColumnIndexOrThrow(TodoEntry.COLUMN_NAME_LABEL));
            }

            myCalendar.setTimeInMillis(dueDateInMillis);

            cr.close();
        }
    }
}
 
Example 18
Project: Cable-Android   File: ConversationFragment.java   View Source Code Vote up 4 votes
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
  return new ConversationLoader(getActivity(), threadId, args.getLong("limit", PARTIAL_CONVERSATION_LIMIT), lastSeen);
}
 
Example 19
Project: conductor-attacher   File: AnimatorChangeHandler2.java   View Source Code Vote up 4 votes
@Override
public void restoreFromBundle(@NonNull Bundle bundle) {
  super.restoreFromBundle(bundle);
  animationDuration = bundle.getLong(KEY_DURATION);
}
 
Example 20
Project: AndroidBackendlessChat   File: TokenCachingStrategy.java   View Source Code Vote up 2 votes
/**
 * Gets the cached expiration date from a Bundle.
 * 
 * @param bundle
 *            A Bundle in which the expiration date was stored.
 * @return the long representing the cached expiration date in milliseconds
 *         since the epoch, or 0.
 *
 * @throws NullPointerException if the passed in Bundle is null
 */
public static long getExpirationMilliseconds(Bundle bundle) {
    Validate.notNull(bundle, "bundle");
    return bundle.getLong(EXPIRATION_DATE_KEY);
}