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.bdenney.locl.activity.LightboxActivity.java

private long getPostId() {
    final Intent intent = getIntent();
    Bundle extras = null;
    long postId = 0L;

    if (intent != null) {
        extras = intent.getExtras();/* ww  w.  jav a  2  s  .com*/
    }

    if (extras != null) {
        postId = extras.getLong(EXTRA_POST_ID);
    }

    return postId;
}

From source file:com.bydavy.card.receipts.fragments.PreviewPictureFragment.java

public long getReceiptId() {
    final Bundle args = getArguments();
    if (args != null) {
        return args.getLong(ARG_RECEIPT_ID);
    }/*from  ww  w .j a v  a2 s . c  o m*/
    return -1;
}

From source file:com.baqsoft.listas.ui.edit.EditItemFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Get reference to views
    View view = inflater.inflate(R.layout.fragment_edit, container, false);
    editTitle = (EditText) view.findViewById(R.id.edit_title);
    editNotes = (EditText) view.findViewById(R.id.edit_notes);
    mSpinner = (Spinner) view.findViewById(R.id.lists_spinner);

    // Get the item id
    Bundle extras = getActivity().getIntent().getExtras();
    if (extras.getBoolean("edit")) {
        itemId = extras.getLong("dataId");
        String[] projection = { ListasContract.ItemContract.COLUMN_TITLE,
                ListasContract.ItemContract.COLUMN_NOTE, ListasContract.ItemContract.COLUMN_CHECKLIST_ID };
        String uriString = ListasContract.ItemContract.URI_STRING + "/" + itemId;
        Cursor data = getActivity().getContentResolver().query(Uri.parse(uriString), projection, null, null,
                null);//from   w  ww  .  jav  a 2s  .  com
        data.moveToFirst();
        int titleIndex = data.getColumnIndex(ListasContract.ItemContract.COLUMN_TITLE);
        int noteIndex = data.getColumnIndex(ListasContract.ItemContract.COLUMN_NOTE);
        int checklistIndex = data.getColumnIndex(ListasContract.ItemContract.COLUMN_CHECKLIST_ID);
        editTitle.setText(data.getString(titleIndex));
        editNotes.setText(data.getString(noteIndex));
        checklistId = data.getLong(checklistIndex);
        data.close();
    }

    // Prepare the spinner
    String[] from = { ListasContract.CategoryContract.COLUMN_TITLE };
    int[] to = { android.R.id.text1 };
    checklistSpinnerAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_spinner_item, null,
            from, to, 0);
    checklistSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mSpinner.setAdapter(checklistSpinnerAdapter);

    // Launch category - checklist loader.
    getLoaderManager().initLoader(0, null, this);

    return view;
}

From source file:com.dahl.brendan.wordsearch.model.HighScore.java

public HighScore(Bundle bundle) {
    this.time = bundle.getLong(Constants.KEY_HIGH_SCORE_TIME);
    this.size = bundle.getInt(Constants.KEY_HIGH_SCORE_SIZE);
    this.theme = bundle.getString(Constants.KEY_HIGH_SCORE_THEME);
    this.wordCount = bundle.getInt(Constants.KEY_WORD_COUNT);
    this.name = bundle.getString(Constants.KEY_HIGH_SCORE_NAME);
    this.globalRank = bundle.getInt(Constants.KEY_GLOBAL_RANK);
    this.globalHighScore = bundle.getBoolean(Constants.KEY_GLOBAL_HIGH_SCORE);
    this.rank = bundle.getInt(Constants.KEY_RANK);
    this.score = bundle.getLong(Constants.KEY_HIGH_SCORE);
}

From source file:com.nearnotes.ChecklistDialog.java

/**
 * Creates a dialog to be returned depending if there is a preference to
 * automatically delete or clear the note it will return a confirmation dialog.
 * If no preference is selected it will come up with option to delete, clear
 * or do nothing to the note.//  ww  w.j  a v a  2 s  .c om
 * 
 * @param savedInstanceState
 *            this bundle has the unique identifier for the note in the database
 *            and the preferences to use a default action and which action
 *            the user is currently using.
 * @return Dialog depending on user settings
 * 
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    Bundle extras = getArguments();
    final Long mRowId = extras.getLong(NotesDbAdapter.KEY_ROWID);
    final boolean mUseDefault = extras.getBoolean("useDefault");
    final int listPref = extras.getInt("listPref");

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    if (mUseDefault) {

        // Set the dialog title
        switch (listPref) {
        case 0:
            builder.setTitle(R.string.checkfinished_clearnote);
            builder.setMessage(R.string.checkfinished_message);
            mWhich = 0;
            break;
        case 1:
            builder.setTitle(R.string.checkfinished_deletenote);
            builder.setMessage(R.string.checkfinished_message);
            mWhich = 1;
            break;
        }
        builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {
                mListener.onOptionSelected(mWhich, mRowId);
                // User clicked OK, so save the mSelectedItems results somewhere
                // or return them to the component that opened the dialog

            }
        }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {

            }
        }).setNeutralButton(R.string.dialog_checklist_settings, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {
                mListener.onOptionSelected(3, mRowId);
            }
        });

    } else {

        // Set the dialog title
        builder.setTitle(R.string.checkfinished)
                // Specify the list array, the items to be selected by default (null for none),
                // and the listener through which to receive callbacks when items are selected
                .setSingleChoiceItems(R.array.check_array, 2, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {

                        mWhich = which;

                        // The 'which' argument contains the index position
                        // of the selected item
                    }
                })

                // Set the action buttons
                .setPositiveButton(R.string.oncecheck, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        mListener.onOptionSelected(mWhich, mRowId);
                        // User clicked OK, so save the mSelectedItems results somewhere
                        // or return them to the component that opened the dialog

                    }
                }).setNegativeButton(R.string.alwayscheck, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        SharedPreferences settings = PreferenceManager
                                .getDefaultSharedPreferences(getActivity());
                        SharedPreferences.Editor editor1 = settings.edit();
                        editor1.putBoolean("pref_key_use_checklist_default", true);
                        editor1.putString("pref_key_checklist_listPref", String.valueOf(mWhich));
                        editor1.commit();

                        mListener.onOptionSelected(mWhich, mRowId);
                    }
                });

    }

    return builder.create();
}

From source file:cl.ipp.katbag.fragment.Worlds.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mainActivity = (MainActivity) super.getActivity();
    v = inflater.inflate(R.layout.fragment_worlds, container, false);
    mainActivity.supportInvalidateOptionsMenu();

    // rescues parameters
    Bundle bundle = getArguments();
    if (bundle != null) {
        id_app = bundle.getLong("id_app");
    }//from   w ww .  j a  v a2 s.c  o m

    notRegister = (TextView) v.findViewById(R.id.world_not_register);
    editMode = false;
    loadListView();

    worldsListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (!editMode) {
                TextView idWorld = (TextView) view.findViewById(R.id.world_row_id);

                Bundle bundle = new Bundle();
                bundle.putLong("id_world", Long.valueOf(idWorld.getText().toString()));
                bundle.putString("name_world", idWorld.getText().toString());

                mFragment = new OneWorld();
                mFragment.setArguments(bundle);
                FragmentTransaction t = getActivity().getSupportFragmentManager().beginTransaction();
                t.replace(R.id.fragment_main_container, mFragment);
                t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
                t.addToBackStack(mFragment.getClass().getSimpleName());
                t.commit();
            }
        }
    });

    return v;
}

From source file:com.androiddevbook.onyourbike.chapter10.activities.MapActivity.java

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

    int available = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

    Bundle extras = getIntent().getExtras();
    if (extras != null && extras.containsKey("trip_id")) {
        trip_id = extras.getLong("trip_id");
    } else {//from w w  w.jav  a2  s  .  c  om
        trip_id = -1;
    }

    if (available == ConnectionResult.SERVICE_MISSING
            || available == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED
            || available == ConnectionResult.SERVICE_DISABLED) {

        Log.e(CLASS_NAME, "Unable to access Google Play services");

        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(available, this, 0);

        dialog.show();

    } else {
        setContentView(R.layout.activity_map);

        map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    }
}

From source file:com.jaspersoft.android.jaspermobile.dialog.DateDialogFragment.java

protected void initDialogParams() {
    super.initDialogParams();

    Bundle args = getArguments();
    if (args != null) {
        if (args.containsKey(DATE_ARG)) {
            long dateMs = args.getLong(DATE_ARG);
            activeDate = Calendar.getInstance();
            activeDate.setTimeInMillis(dateMs);
        }/*from   w w w  .j  a  va  2s .c  om*/
        if (args.containsKey(IC_ID_ARG)) {
            icId = args.getString(IC_ID_ARG);
        }
        if (args.containsKey(TYPE_ARG)) {
            type = args.getInt(TYPE_ARG);
        }
    }
}

From source file:cl.ipp.katbag.fragment.Drawings.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mainActivity = (MainActivity) super.getActivity();
    v = inflater.inflate(R.layout.fragment_drawings, container, false);
    mainActivity.supportInvalidateOptionsMenu();

    // rescues parameters
    Bundle bundle = getArguments();
    if (bundle != null) {
        id_app = bundle.getLong("id_app");
        type_app = bundle.getString("type_app");
    }/* ww  w  . j a va 2  s .  c  o m*/

    notRegister = (TextView) v.findViewById(R.id.drawings_not_register);
    editMode = false;
    loadListView();

    drawingsListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (!editMode) {
                TextView idDrawing = (TextView) view.findViewById(R.id.drawing_row_id);

                Bundle bundle = new Bundle();
                bundle.putLong("id_drawing", Long.valueOf(idDrawing.getText().toString()));
                bundle.putString("name_drawing", idDrawing.getText().toString());
                bundle.putString("type_app", type_app);

                mFragment = new OneDrawing();
                mFragment.setArguments(bundle);
                FragmentTransaction t = getActivity().getSupportFragmentManager().beginTransaction();
                t.replace(R.id.fragment_main_container, mFragment);
                t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
                t.addToBackStack(mFragment.getClass().getSimpleName());
                t.commit();
            }
        }
    });

    return v;
}

From source file:com.wit.android.support.database.examples.database.ActorsEntity.java

/**
 *///  w  w  w.j a  v  a  2s. com
public Loader<Cursor> createDetailLoader(Bundle params) {
    return LoaderOptions.createLoader(getContext(), getContentUri(), new String[] { ID, FIRST_NAME, LAST_NAME },
            ID + "=?", new String[] { Long.toString(params.getLong(ID)) });
}