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.akop.bach.fragment.AlertDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Bundle args = getArguments();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle(args.getString("title"))
            .setMessage(args.getString("message"));

    if (args.getInt("type") == TYPE_OK) {
        builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                dismiss();// w w  w  .java2  s.c  o m
            }
        });
    } else if (args.getInt("type") == TYPE_YES_NO) {
        builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                if (mOkListener != null) {
                    mOkListener.okClicked(args.getInt("code"), args.getLong("id"), args.getString("param"));
                }

                dismiss();
            }
        }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                dismiss();
            }
        });
    }

    AlertDialog dialog = builder.create();
    return dialog;
}

From source file:com.akop.bach.fragment.xboxlive.SentMessagesFragment.java

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

    if (mAccount == null) {
        Bundle args = getArguments();// www  .j  av a2s. c om
        ContentResolver cr = getActivity().getContentResolver();

        mAccount = (XboxLiveAccount) args.getParcelable("account");
        mTitleId = getFirstTitleId(cr.query(SentMessages.CONTENT_URI, new String[] { SentMessages._ID, },
                SentMessages.ACCOUNT_ID + "=" + mAccount.getId(), null, SentMessages.DEFAULT_SORT_ORDER));
    }

    if (state != null && state.containsKey("account")) {
        mAccount = (XboxLiveAccount) state.getParcelable("account");
        mTitleId = state.getLong("titleId");
    }

    setHasOptionsMenu(true);
}

From source file:com.brandroidtools.filemanager.activities.PickerActivity.java

/**
 * Method that displays a dialog with a {@link NavigationFragment} to select the
 * proposed file//from   w  w  w . ja  v  a  2 s  . c  o  m
 */
private void init() {
    final boolean pickingDirectory;
    final Intent intent = getIntent();

    if (isFilePickIntent(intent)) {
        // ok
        Log.d(TAG, "PickerActivity: got file pick intent: " + String.valueOf(intent)); //$NON-NLS-1$
        pickingDirectory = false;
    } else if (isDirectoryPickIntent(getIntent())) {
        // ok
        Log.d(TAG, "PickerActivity: got folder pick intent: " + String.valueOf(intent)); //$NON-NLS-1$
        pickingDirectory = true;
    } else {
        Log.d(TAG, "PickerActivity got unrecognized intent: " + String.valueOf(intent)); //$NON-NLS-1$
        setResult(Activity.RESULT_CANCELED);
        finish();
        return;
    }

    // Display restrictions
    Map<DisplayRestrictions, Object> restrictions = new HashMap<DisplayRestrictions, Object>();
    //- Mime/Type restriction
    String mimeType = getIntent().getType();
    if (mimeType != null) {
        if (!MimeTypeHelper.isMimeTypeKnown(this, mimeType)) {
            Log.i(TAG, String.format("Mime type %s unknown, falling back to wildcard.", //$NON-NLS-1$
                    mimeType));
            mimeType = MimeTypeHelper.ALL_MIME_TYPES;
        }
        restrictions.put(DisplayRestrictions.MIME_TYPE_RESTRICTION, mimeType);
    }
    // Other restrictions
    Bundle extras = getIntent().getExtras();
    Log.d(TAG, "PickerActivity. extras: " + String.valueOf(extras)); //$NON-NLS-1$
    if (extras != null) {
        //-- File size
        if (extras.containsKey(android.provider.MediaStore.Audio.Media.EXTRA_MAX_BYTES)) {
            long size = extras.getLong(android.provider.MediaStore.Audio.Media.EXTRA_MAX_BYTES);
            restrictions.put(DisplayRestrictions.SIZE_RESTRICTION, Long.valueOf(size));
        }
        //-- Local filesystems only
        if (extras.containsKey(Intent.EXTRA_LOCAL_ONLY)) {
            boolean localOnly = extras.getBoolean(Intent.EXTRA_LOCAL_ONLY);
            restrictions.put(DisplayRestrictions.LOCAL_FILESYSTEM_ONLY_RESTRICTION, Boolean.valueOf(localOnly));
        }
    }
    if (pickingDirectory) {
        restrictions.put(DisplayRestrictions.DIRECTORY_ONLY_RESTRICTION, Boolean.TRUE);
    }

    // Create or use the console
    if (!initializeConsole()) {
        // Something when wrong. Display a message and exit
        DialogHelper.showToast(this, R.string.msgs_cant_create_console, Toast.LENGTH_SHORT);
        cancel();
        return;
    }

    // Create the root file
    this.mRootView = getLayoutInflater().inflate(R.layout.picker, null, false);
    this.mRootView.post(new Runnable() {
        @Override
        public void run() {
            measureHeight();
        }
    });

    // Breadcrumb
    Breadcrumb breadcrumb = (Breadcrumb) this.mRootView.findViewById(R.id.breadcrumb_view);
    // Set the free disk space warning level of the breadcrumb widget
    String fds = Preferences.getSharedPreferences().getString(
            FileManagerSettings.SETTINGS_DISK_USAGE_WARNING_LEVEL.getId(),
            (String) FileManagerSettings.SETTINGS_DISK_USAGE_WARNING_LEVEL.getDefaultValue());
    breadcrumb.setFreeDiskSpaceWarningLevel(Integer.parseInt(fds));

    // Navigation view
    this.mNavigationFragment = (NavigationFragment) getSupportFragmentManager()
            .findFragmentById(R.id.navigation_fragment);
    this.mNavigationFragment.setRestrictions(restrictions);
    this.mNavigationFragment.setOnFilePickedListener(this);
    this.mNavigationFragment.setOnDirectoryChangedListener(this);
    this.mNavigationFragment.setBreadcrumb(breadcrumb);

    // Apply the current theme
    applyTheme();

    // Create the dialog
    this.mDialog = DialogHelper.createDialog(this, R.drawable.ic_launcher,
            pickingDirectory ? R.string.directory_picker_title : R.string.picker_title, this.mRootView);

    this.mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dlg, int which) {
                    dlg.cancel();
                }
            });
    if (pickingDirectory) {
        this.mDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.select),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dlg, int which) {
                        PickerActivity.this.mFso = PickerActivity.this.mCurrentDirectory;
                        dlg.dismiss();
                    }
                });
    }
    this.mDialog.setCancelable(true);
    this.mDialog.setOnCancelListener(this);
    this.mDialog.setOnDismissListener(this);
    DialogHelper.delegateDialogShow(this, this.mDialog);

    // Set content description of storage volume button
    ButtonItem fs = (ButtonItem) this.mRootView.findViewById(R.id.ab_filesystem_info);
    fs.setContentDescription(getString(R.string.actionbar_button_storage_cd));

    final File initialDir = getInitialDirectoryFromIntent(getIntent());
    final String rootDirectory;

    if (initialDir != null) {
        rootDirectory = initialDir.getAbsolutePath();
    } else {
        rootDirectory = FileHelper.ROOT_DIRECTORY;
    }

    this.mHandler = new Handler();
    this.mHandler.post(new Runnable() {
        @Override
        public void run() {
            // Navigate to. The navigation view will redirect to the appropriate directory
            PickerActivity.this.mNavigationFragment.changeCurrentDir(rootDirectory);
        }
    });

}

From source file:com.ultramegasoft.flavordex2.fragment.EditCatFragment.java

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

    final Activity activity = getActivity();
    if (activity == null) {
        return;//  w  w  w . j a  va 2  s .  c  o  m
    }

    final Bundle args = getArguments();
    mCatId = args != null ? args.getLong(ARG_CAT_ID) : 0;
    setHasOptionsMenu(true);
    if (mCatId > 0) {
        activity.setTitle(getString(R.string.title_edit_cat));
    }
}

From source file:com.nextgis.maplibui.control.DateTime.java

@Override
public void init(Field field, Bundle savedState, Cursor featureCursor) {
    if (null != field) {
        mFieldName = field.getName();/*from   w  w  w  .  j a v a  2 s . c o m*/
    }

    switch (mPickerType) {

    case GeoConstants.FTDate:
        mDateFormat = (SimpleDateFormat) DateFormat.getDateInstance();
        break;

    case GeoConstants.FTTime:
        mDateFormat = (SimpleDateFormat) DateFormat.getTimeInstance();
        break;

    default:
        mPickerType = GeoConstants.FTDateTime;
    case GeoConstants.FTDateTime:
        mDateFormat = (SimpleDateFormat) DateFormat.getDateTimeInstance();
        break;
    }

    String text = "";

    if (ControlHelper.hasKey(savedState, mFieldName)) {
        mValue = savedState.getLong(ControlHelper.getSavedStateKey(mFieldName));
    } else if (null != featureCursor) {
        int column = featureCursor.getColumnIndex(mFieldName);
        if (column >= 0) {
            mValue = featureCursor.getLong(column);
        }
    }

    if (null != mValue) {
        text = getText();
    }

    setText(text);
    setSingleLine(true);
    setFocusable(false);
    setOnClickListener(getDateUpdateWatcher(mPickerType));

    String pattern = mDateFormat.toLocalizedPattern();
    setHint(pattern);
}

From source file:com.silentcircle.contacts.group.GroupEditorFragment.java

private void onRestoreInstanceState(Bundle state) {
    mAction = state.getString(KEY_ACTION);
    mGroupUri = state.getParcelable(KEY_GROUP_URI);
    mGroupId = state.getLong(KEY_GROUP_ID);

    mStatus = (Status) state.getSerializable(KEY_STATUS);

    mGroupNameIsReadOnly = state.getBoolean(KEY_GROUP_NAME_IS_READ_ONLY);
    mOriginalGroupName = state.getString(KEY_ORIGINAL_GROUP_NAME);

    mListMembersToAdd = state.getParcelableArrayList(KEY_MEMBERS_TO_ADD);
    mListMembersToRemove = state.getParcelableArrayList(KEY_MEMBERS_TO_REMOVE);
    mListToDisplay = state.getParcelableArrayList(KEY_MEMBERS_TO_DISPLAY);
}

From source file:com.wirelessmoves.cl.MainActivity.java

@SuppressWarnings("deprecation")
@Override// ww w .  j a  v a 2 s.  c  o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    /* If saved variable state exists from last run, recover it */
    if (savedInstanceState != null) {
        NumberOfSignalStrengthUpdates = savedInstanceState.getLong("NumberOfSignalStrengthUpdates");

        LastCellId = savedInstanceState.getLong("LastCellId");
        NumberOfCellChanges = savedInstanceState.getLong("NumberOfCellChanges");

        LastLacId = savedInstanceState.getLong("LastLacId");
        NumberOfLacChanges = savedInstanceState.getLong("NumberOfLacChanges");

        PreviousCells = savedInstanceState.getLongArray("PreviousCells");
        PreviousCellsIndex = savedInstanceState.getInt("PreviousCellsIndex");
        NumberOfUniqueCellChanges = savedInstanceState.getLong("NumberOfUniqueCellChanges");

        outputDebugInfo = savedInstanceState.getBoolean("outputDebugInfo");

        CurrentLocationLong = savedInstanceState.getDouble("CurrentLocationLong");
        CurrentLocationLat = savedInstanceState.getDouble("CurrentLocationLat");

        /* attempt to restore the previous gps location information object */
        PrevLocation = (Location) getLastNonConfigurationInstance();

    } else {
        /* Initialize PreviousCells Array to defined values */
        for (int x = 0; x < PreviousCells.length; x++)
            PreviousCells[x] = 0;
    }

    /* Get a handle to the telephony manager service */
    /* A listener will be installed in the object from the onResume() method */
    MyListener = new MyPhoneStateListener();
    Tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

    /* get a handle to the power manager and set a wake lock so the screen saver
     * is not activated after a timeout */
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "DoNotDimScreen");

    /* Get a handle to the location system for getting GPS information */
    locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    gpsListener = new myLocationListener();
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, gpsListener);

}

From source file:com.example.android.snake.SnakeView.java

/**
 * Restore game state if our process is being relaunched
 *
 * @param icicle a Bundle containing the game state
 *///from ww  w .j  a v  a  2  s. co  m
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"));
}

From source file:com.nearnotes.NoteEdit.java

@Override
public void onStart() {
    super.onStart();
    mTitleText = (EditText) getActivity().findViewById(R.id.title_edit);

    mCallback.setActionItems(NOTE_EDIT);
    if (mRowId == null) {
        Bundle extras = getArguments();
        mRowId = extras.containsKey(NotesDbAdapter.KEY_ROWID) ? extras.getLong(NotesDbAdapter.KEY_ROWID) : null;
    }// www  . j  av a 2  s  .  c  o  m

    getActivity().setTitle(R.string.edit_note);

    Bundle bundle = getArguments();
    mLongitude = bundle.getDouble("longitude");
    mLatitude = bundle.getDouble("latitude");

    mTitleText = (EditText) getActivity().findViewById(R.id.title_edit);
    mBodyText = (EditText) getView().findViewById(R.id.body);

    mTblAddLayout = (TableLayout) getActivity().findViewById(R.id.checkbody);
    mTblAddLayout.setPadding(0, 0, 0, 0);

    acAdapter = new PlacesAutoCompleteAdapter(getActivity(), R.layout.list_item);

    mCheckBox = (CheckBox) getActivity().findViewById(R.id.checkbox_on_top);
    mCheckBox.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (((CheckBox) v).isChecked() && mRowId != null) {
                mDbHelper.updateSetting(mRowId);
            } else if (mRowId != null) {
                mDbHelper.removeSetting();
            }
        }
    });

    autoCompView = (DelayAutoCompleteTextView) getView().findViewById(R.id.autoCompleteTextView1);
    autoCompView.setAdapter(acAdapter);
    //int height = autoCompView.getDropDownHeight();
    //autoCompView.setDropDownHeight(height + 20);

    autoCompView.setOnItemClickListener(this);
    autoCompView.setLoadingIndicator((ProgressBar) getView().findViewById(R.id.progressAPI),
            (ImageView) getView().findViewById(R.id.location_icon));

    autoCompView.setCompletionHint("");
    if (mRowId != null) {
        autoCompView.setTextColor(getResources().getColor(R.color.deepgreen));
    } else {
        SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
        boolean checklistPref = sharedPref.getBoolean("pref_key_note_checklist", false);
        if (checklistPref) {
            mChecklist = true;
        }
    }

    mBodyText.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @SuppressWarnings("deprecation")
        @Override
        public void onGlobalLayout() {
            //This listener is added to make sure the globalLayout has been displayed
            // before accessing getLayout().getLineEnd()
            ViewTreeObserver obs = mBodyText.getViewTreeObserver();
            obs.removeGlobalOnLayoutListener(this);

            if (!mChecklist) {
                return;
            }
            mBodyText.addTextChangedListener(bodyTextWatcher);

            // Run the code below just once on startup to populate the global listArray mRealRow
            String tempBoxes = mBodyText.getText().toString();
            if (mBodyText.getLayout() != null) {
                mRealRow = populateBoxes(tempBoxes);

                int row = 0;
                for (NoteRow line : mRealRow) {
                    switch (line.getType()) {
                    case 0:
                        TableRow inflate = (TableRow) View.inflate(getActivity(), R.layout.table_row_invisible,
                                null);
                        mTblAddLayout.addView(inflate);
                        break;
                    case 1:
                        TableRow checkRow = (TableRow) View.inflate(getActivity(), R.layout.table_row, null);
                        CheckBox temp = (CheckBox) checkRow.getChildAt(0);
                        temp.setTag(Integer.valueOf(row));
                        mTblAddLayout.addView(checkRow);
                        temp.setOnClickListener(checkBoxListener);
                        break;
                    case 2:
                        TableRow checkRow1 = (TableRow) View.inflate(getActivity(), R.layout.table_row, null);
                        CheckBox temp1 = (CheckBox) checkRow1.getChildAt(0);
                        temp1.setTag(Integer.valueOf(row));
                        temp1.setChecked(true);
                        mTblAddLayout.addView(checkRow1);
                        temp1.setOnClickListener(checkBoxListener);
                        break;
                    }

                    for (int k = 1; line.getSize() > k; k++) {
                        TableRow inflate = (TableRow) View.inflate(getActivity(), R.layout.table_row_invisible,
                                null);
                        mTblAddLayout.addView(inflate);
                    }
                    row++;
                }
            }
        }
    });
}

From source file:com.roque.rueda.cashflows.fragments.AddMovementFragment.java

/**
 * Called to have the fragment instantiate its user interface view. This is optional,
 * and non-graphical fragments can return null (which is the default implementation). T
 * his will be called between onCreate(Bundle) and onActivityCreated(Bundle).
 *
 * If you return a View from here, you will later be called in onDestroyView
 * when the view is being released./*w w w. j a v a 2s.  c om*/
 *
 * @param inflater Inflater used to create the widgets.
 * @param container ViewGroup parent of this view.
 * @param savedInstanceState Bundle that contains all the information for this activity.
 * @return View that will be used to present the information.
 */
@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_add_amount, container, false);

    // Recover the values to restore the edit values.
    if (savedInstanceState != null) {
        mCurrentAmount = savedInstanceState.getDouble(AMOUNT_KEY);
        mSelectedAccount = savedInstanceState.getInt(ACCOUNT_KEY);
        mCurrentDate = savedInstanceState.getLong(DATE_KEY);
        mCurrentNotes = savedInstanceState.getString(NOTES_KEY);
        hideDialog = true;
    }

    customizeAmountButton(rootView, mCurrentAmount);
    if (!hideDialog) {
        displayInputMoneyDialog(mCurrentAmount);
    }

    // Get adapter this will be filled by the loader.
    mAccountsSpinner = (Spinner) rootView.findViewById(R.id.accounts_spinner);
    mAccountsSpinner.postInvalidate();
    mAccountsSpinner.setAdapter(mAdapter);

    // Set the current date as a formattedString.
    final Date currentDate = new Date();
    mDateText = (TextView) rootView.findViewById(R.id.current_date);
    if (mCurrentDate != 0) {
        currentDate.setTime(mCurrentDate);
    }

    // Set the date on the current label.
    setCurrentDateText(currentDate);
    createDateTimeDialog();

    mNotes = (EditText) rootView.findViewById(R.id.notesText);
    if (mCurrentNotes != null) {
        mNotes.setText(mCurrentNotes);
    }

    createActionBar(inflater);
    mFragmentTitle = (TextView) rootView.findViewById(R.id.title_amount);
    createAddCashInstance(getArguments().getBoolean(MainActivity.SUBSTRACT_MOVEMENT));
    return rootView;
}