Example usage for android.os Bundle getBoolean

List of usage examples for android.os Bundle getBoolean

Introduction

In this page you can find the example usage for android.os Bundle getBoolean.

Prototype

public boolean getBoolean(String key) 

Source Link

Document

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

Usage

From source file:com.starwood.anglerslong.LicenseAddActivity.java

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

    Bundle bundle = this.getIntent().getExtras();

    setContentView(R.layout.license_add);

    Spinner s = (Spinner) findViewById(R.id.spinner);
    @SuppressWarnings("unchecked")
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            getResources().getStringArray(R.array.state_array));
    s.setAdapter(adapter);// w w  w  .j  a va2 s  .com

    s.setOnItemSelectedListener(this);

    isPopulated = bundle.getBoolean("isPopulated");
    isArrayEmpty = bundle.getBoolean("isArrayEmpty");
    if (bundle.containsKey("isEdit"))
        isEdit = bundle.getBoolean("isEdit");
    if (bundle.containsKey("currentItemID"))
        currentItemID = bundle.getInt("currentItemID");

    getSupportActionBar().setTitle(bundle.getString("title"));
    //        getSupportActionBar().setSubtitle(bundle.getString("subtitle"));

    if (isEdit) {
        try {
            JsonStorage jsonStorage = new JsonStorage(getApplicationContext());
            String json = jsonStorage.readProfileJSON(); // Store the JSON into string
            JSONObject j = new JSONObject(json);
            JSONObject outer = j.getJSONObject("outermost"); // Outermost JSON
            JSONArray innerArray = outer.getJSONArray("license");
            JSONObject inner = innerArray.getJSONObject(currentItemID);

            Spinner editSpinner = (Spinner) findViewById(R.id.spinner);
            editSpinner.setSelection(inner.getInt("state") + 1); // Set spinner

            EditText edit = (EditText) findViewById(R.id.license_name);
            edit.setText(inner.getString("name"));
            edit = (EditText) findViewById(R.id.license_number);
            edit.setText(inner.getString("number"));
            edit = (EditText) findViewById(R.id.license_type);
            edit.setText(inner.getString("type"));
            edit = (EditText) findViewById(R.id.license_issue_date);
            edit.setText(inner.getString("issue_date"));
            edit = (EditText) findViewById(R.id.license_expiration_date);
            edit.setText(inner.getString("exp_date"));
            edit = (EditText) findViewById(R.id.license_birthday);
            edit.setText(inner.getString("birthday"));
            edit = (EditText) findViewById(R.id.license_huntered);
            edit.setText(inner.getString("huntered"));

        } catch (JSONException | IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

From source file:it.scoppelletti.mobilepower.app.ProgressDialogFragment.java

/**
 * Crea il dialogo.//from ww  w  .  ja v a 2 s.c o m
 * 
 * @param  savedInstanceState Stato dell&rsquo;istanza.
 * @return                    Dialogo.
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int max, resId;
    ProgressDialog dlg;
    Bundle args = getArguments();

    dlg = new ProgressDialog(getActivity(), AppUtils.getDialogTheme());

    resId = args.getInt(ProgressDialogFragment.ARG_TITLEID);
    dlg.setTitle(getString(resId));
    max = args.getInt(ProgressDialogFragment.ARG_MAX, -1);

    if (max > 0) {
        dlg.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        dlg.setIndeterminate(false);
        dlg.setMax(max);
    } else {
        dlg.setIndeterminate(true);
        dlg.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    }

    dlg.setCancelable(args.getBoolean(ProgressDialogFragment.ARG_CANCELABLE));
    dlg.setCanceledOnTouchOutside(false);

    return dlg;
}

From source file:mp.paschalis.WatchBookActivity.java

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

    app = (App) getApplication();/*ww  w. jav  a2s .  c om*/

    setContentView(R.layout.activity_watch_book);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Get arguments, to determine who opened this activity
    final Bundle extras = getIntent().getExtras();

    try {
        isAvailable = extras.getBoolean(App.ExtrasForWatchBookActivityFromBookSearch);
    } catch (Exception e) {
        isAvailable = false;
    }

    // Set the layout's data
    // Get layout's Data
    bookISBN = (TextView) findViewById(R.id.textViewBookISBN);

    bookTitle = (TextView) findViewById(R.id.textViewBookTitle);
    bookAuthors = (TextView) findViewById(R.id.textViewBookAuthors);
    bookPublishedYear = (TextView) findViewById(R.id.textViewBookPublishedYear);
    bookPageCount = (TextView) findViewById(R.id.textViewBookPageCount);
    bookDateOfInsert = (TextView) findViewById(R.id.textViewBookDateOfInsert);

    bookCoverImage = (ImageView) findViewById(R.id.imageViewBookCover);

    bookLanguage = (TextView) findViewById(R.id.textViewBookLanguage);

    textViewWatchBookAvailable = (TextView) findViewById(R.id.textViewWatchBookAvailable);

    buttonRequestBook = (Button) findViewById(R.id.buttonRequestBook);

    buttonSendMessage = (Button) findViewById(R.id.buttonSendMessage);
    progressBarSendMessage = (ProgressBar) findViewById(R.id.progressBarSendMessage);

    buttonSendMessage.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            final DataClassRequestABook dataClassRequestABook = new DataClassRequestABook();

            dataClassRequestABook.username = app.user.username;
            dataClassRequestABook.isbn = app.selectedBook.isbn;

            ArrayList<String> userWhoLent = new ArrayList<String>();
            // Find all users who lent this book
            for (Book.DataClassUser u : app.selectedBook.owners) {
                if (u.status == 0) {
                    userWhoLent.add(u.username);
                }
            }

            final CharSequence[] owners = userWhoLent.toArray(new CharSequence[userWhoLent.size()]);

            AlertDialog.Builder builder = new AlertDialog.Builder(WatchBookActivity.this);
            builder.setTitle(R.string.msgPickBookOwner_);
            builder.setItems(owners, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int item) {

                    dataClassRequestABook.owner = (String) owners[item];

                    // Send message to owner
                    Intent intent = new Intent(WatchBookActivity.this, SendMessageActivity.class);

                    intent.putExtra(App.ExtrasForSendMessage_DestinationUser, dataClassRequestABook.owner);

                    startActivity(intent);

                }
            });
            AlertDialog alert = builder.create();
            alert.show();
        }

    });

    if (!isAvailable) {
        textViewWatchBookAvailable.setText(R.string.no);
        App.setStyleErrorDirection(textViewWatchBookAvailable);
        buttonRequestBook.setEnabled(false);
    } else {

        textViewWatchBookAvailable.setText(R.string.yes);
        App.setStyleSuccessDirection(textViewWatchBookAvailable);

        // Requests a book
        buttonRequestBook.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                {

                    final DataClassRequestABook dataClassRequestABook = new DataClassRequestABook();

                    dataClassRequestABook.username = app.user.username;
                    dataClassRequestABook.isbn = app.selectedBook.isbn;

                    ArrayList<String> userWhoLent = new ArrayList<String>();
                    // Find all users who lent this book
                    for (Book.DataClassUser u : app.selectedBook.owners) {
                        if (u.status == 0) {
                            userWhoLent.add(u.username);
                        }
                    }

                    final CharSequence[] owners = userWhoLent.toArray(new CharSequence[userWhoLent.size()]);

                    AlertDialog.Builder builder = new AlertDialog.Builder(WatchBookActivity.this);
                    builder.setTitle(R.string.msgPickBookOwner_);
                    builder.setItems(owners, new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int item) {

                            dataClassRequestABook.owner = (String) owners[item];

                            // Request the book
                            new AsyncTaskRequestABook().execute(dataClassRequestABook);

                        }
                    });
                    AlertDialog alert = builder.create();
                    alert.show();
                }

            }
        });// End of Req Button!

    }

    TextView tvnc = (TextView) findViewById(R.id.textViewNoCover);
    ProgressBar pb = (ProgressBar) findViewById(R.id.progressBarLoadCover);

    // show The Image and save it to Library
    ImageLoader.DataClassDisplayBookCover bk = new ImageLoader.DataClassDisplayBookCover();
    bk.iv = bookCoverImage;
    bk.isCover = true;
    bk.tv = tvnc;
    bk.pb = pb;
    bk.book = app.selectedBook;
    App.imageLoader.DisplayCover(bk);

    bitmapBookCover = ((BitmapDrawable) bookCoverImage.getDrawable()).getBitmap();

    // new DownloadImageTask(bookCoverImage, bookInfo)
    // .execute(bookInfo.imgURL);

    // Assign the appropriate data from our alert object above
    bookISBN.setText(app.selectedBook.isbn);
    bookTitle.setText(app.selectedBook.title);
    bookAuthors.setText(app.selectedBook.authors);
    bookPublishedYear.setText(Integer.valueOf(app.selectedBook.publishedYear).toString());
    bookPageCount.setText(Integer.valueOf(app.selectedBook.pageCount).toString());
    bookDateOfInsert
            .setText(App.makeTimeStampHumanReadble(getApplicationContext(), app.selectedBook.dateOfInsert));
    bookLanguage.setText(app.selectedBook.lang);

    progressBarRequestBook = (ProgressBar) findViewById(R.id.progressBarRequestBook);

    buttonRequestBook = (Button) findViewById(R.id.buttonRequestBook);

}

From source file:com.alexandrepiveteau.library.tutorial.TutorialFragment.java

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

    Bundle arguments = getArguments();

    mTutorialImage = arguments.getInt(ARGUMENTS_TUTORIAL_IMAGE);
    mTutorialImageBackground = arguments.getInt(ARGUMENTS_TUTORIAL_IMAGE_BACKGROUND);
    mTutorialImageForeground = arguments.getInt(ARGUMENTS_TUTORIAL_IMAGE_FOREGROUND);

    mTutorialName = arguments.getString(ARGUMENTS_TUTORIAL_NAME);
    mTutorialDescription = arguments.getString(ARGUMENTS_TUTORIAL_DESCRIPTION);

    mHasAnimatedImage = arguments.getBoolean(ARGUMENTS_HAS_ANIMATED_IMAGE);
    mHasAnimatedImageBackground = arguments.getBoolean(ARGUMENTS_HAS_ANIMATED_IMAGE_BACKGROUND);
    mHasAnimatedImageForeground = arguments.getBoolean(ARGUMENTS_HAS_ANIMATED_IMAGE_FOREGROUND);

    View rootView = inflater.inflate(R.layout.fragment_tutorial, container, false);

    mTutorialImageImageView = (ImageView) rootView.findViewById(R.id.tutorial_image);
    mTutorialImageImageViewBackground = (ImageView) rootView.findViewById(R.id.tutorial_image_background);
    mTutorialImageImageViewForeground = (ImageView) rootView.findViewById(R.id.tutorial_image_foreground);

    TextView mTutorialNameTextView = (TextView) rootView.findViewById(R.id.tutorial_name);
    TextView mTutorialDescriptionTextView = (TextView) rootView.findViewById(R.id.tutorial_description);

    if (mTutorialImage != NO_IMAGE) {
        if (!mHasAnimatedImage) {
            Glide.with(getActivity()).load(mTutorialImage).fitCenter().into(mTutorialImageImageView);
        } else {/* w  ww.j  a  v a 2  s .co  m*/
            mTutorialImageImageView.setImageResource(mTutorialImage);
            AnimationDrawable animationDrawable = (AnimationDrawable) mTutorialImageImageView.getDrawable();
            animationDrawable.start();
        }
    }
    if (mTutorialImageBackground != NO_IMAGE) {
        if (!mHasAnimatedImageBackground) {
            Glide.with(getActivity()).load(mTutorialImageBackground).fitCenter()
                    .into(mTutorialImageImageViewBackground);
        } else {
            mTutorialImageImageViewBackground.setImageResource(mTutorialImageBackground);
            AnimationDrawable animationDrawable = (AnimationDrawable) mTutorialImageImageViewBackground
                    .getDrawable();
            animationDrawable.start();
        }
    }
    if (mTutorialImageForeground != NO_IMAGE) {
        if (!mHasAnimatedImageForeground) {
            Glide.with(getActivity()).load(mTutorialImageForeground).fitCenter()
                    .into(mTutorialImageImageViewForeground);
        } else {
            mTutorialImageImageViewForeground.setImageResource(mTutorialImageForeground);
            AnimationDrawable animationDrawable = (AnimationDrawable) mTutorialImageImageViewForeground
                    .getDrawable();
            animationDrawable.start();
        }
    }

    mTutorialNameTextView.setText(mTutorialName);
    mTutorialDescriptionTextView.setText(mTutorialDescription);

    return rootView;
}

From source file:com.amaze.filemanager.fragments.ZipExplorerFragment.java

private void onRestoreInstanceState(Bundle savedInstanceState) {
    realZipFile = new File(Uri.parse(savedInstanceState.getString(KEY_URI)).getPath());
    files = savedInstanceState.getParcelableArrayList(KEY_CACHE_FILES);
    isOpen = savedInstanceState.getBoolean(KEY_OPEN);
    if (realZipFile.getPath().endsWith(".rar")) {
        openmode = RAR_FILE;/* w  w w.j  a  va 2  s.  c o m*/
        String path = savedInstanceState.getString(KEY_FILE);
        if (path != null && path.length() > 0) {
            realZipFile = new File(path);
            relativeDirectory = savedInstanceState.getString(KEY_PATH, "");
            changeRarPath(relativeDirectory);
        } else {
            changePath("");
        }
    } else {
        openmode = ZIP_FILE;
        elements = savedInstanceState.getParcelableArrayList(KEY_ELEMENTS);
        relativeDirectory = savedInstanceState.getString(KEY_PATH, "");
        realZipFile = new File(savedInstanceState.getString(KEY_FILE));
        createZipViews(elements, relativeDirectory);
    }
}

From source file:cn.scujcc.bug.bitcoinplatformandroid.fragment.BuyAndSellFragment.java

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

    savedInstanceState = getArguments();
    if (savedInstanceState != null) {
        isSell = savedInstanceState.getBoolean(ARGS_IS_Sell);
    }/*  w w  w .ja  v a2  s  .c o m*/

}

From source file:com.oscarsalguero.solartracker.MainActivity.java

private void updateValuesFromBundle(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        // Update the value of mRequestingLocationUpdates from the Bundle, and
        // make sure that the Start Updates and Stop Updates buttons are
        // correctly enabled or disabled.
        if (savedInstanceState.keySet().contains(REQUESTING_LOCATION_UPDATES_KEY)) {
            mRequestingLocationUpdates = savedInstanceState.getBoolean(REQUESTING_LOCATION_UPDATES_KEY);
        }/* w w w.j a v a2  s .  c o  m*/

        // Update the value of mCurrentLocation from the Bundle and update the
        // UI to show the correct latitude and longitude.
        if (savedInstanceState.keySet().contains(LOCATION_KEY)) {
            // Since LOCATION_KEY was found in the Bundle, we can be sure that
            // mCurrentLocationis not null.
            mLastLocation = savedInstanceState.getParcelable(LOCATION_KEY);
        }

        // Update the value of mLastUpdateTime from the Bundle and update the UI.
        if (savedInstanceState.keySet().contains(LAST_UPDATED_TIME_STRING_KEY)) {
            mLastUpdateTime = savedInstanceState.getString(LAST_UPDATED_TIME_STRING_KEY);
        }
    }
}

From source file:de.uhrenbastler.watchcheck.ui.LogDialog.java

public LogDialog(Context context, Bundle logData) {
    super(context);

    setContentView(R.layout.log_dialog);
    setTitle(getContext().getString(R.string.enterLog));
    setCancelable(true);//from  w w  w  .ja  v  a  2 s  .  c  o m

    Button buttonSave = (Button) findViewById(R.id.buttonSave);
    buttonSave.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            makeLogEntry();
            saved = true;
            dismiss();
        }
    });

    watchId = logData.getInt(ATTR_WATCH_ID);
    deviation = logData.getDouble(ATTR_DEVIATION);
    modeNtp = logData.getBoolean(ATTR_MODE_NTP);
    localTime = (GregorianCalendar) logData.get(ATTR_LOCAL_TIME);
    ntpTime = (GregorianCalendar) logData.get(ATTR_NTP_TIME);
    lastLog = (Log) logData.get(ATTR_LAST_LOG);

    Logger.debug("watchId=" + watchId + ", deviation=" + deviation + ", modeNtp=" + modeNtp + ", localTime="
            + localTime.getTime() + ", ntpTime=" + (ntpTime != null ? ntpTime.getTime() : "NULL") + ", lastLog="
            + lastLog);

    TextView textDeviation = (TextView) findViewById(R.id.textViewDeviationValue);
    DecimalFormat df = new DecimalFormat("#.#");

    textDeviation.setText(
            (deviation > 0 ? "+" : deviation < 0 ? "-" : "+-") + df.format(Math.abs(deviation)) + " sec.");

    positionSpinner = (Spinner) findViewById(R.id.logSpinnerPosition);
    ArrayAdapter<?> positionAdapter = ArrayAdapter.createFromResource(getContext(), R.array.positions,
            android.R.layout.simple_spinner_item);
    positionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    positionSpinner.setAdapter(positionAdapter);

    if (lastLog != null && lastLog.getPosition() != null)
        positionSpinner.setSelection(ArrayUtils.indexOf(POSITIONARR, lastLog.getPosition()));
    else
        positionSpinner.setSelection(0);

    temperatureSpinner = (Spinner) findViewById(R.id.logSpinnerTemperature);
    ArrayAdapter<?> temperatureAdapter = ArrayAdapter.createFromResource(getContext(), R.array.temperatures,
            android.R.layout.simple_spinner_item);
    temperatureAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    temperatureSpinner.setAdapter(temperatureAdapter);

    if (lastLog != null)
        temperatureSpinner.setSelection(ArrayUtils.indexOf(TEMPARR, lastLog.getTemperature()));
    else
        temperatureSpinner.setSelection(0);

    comment = (EditText) findViewById(R.id.logComment);

    startFlag = (CheckBox) findViewById(R.id.logCheckBoxNewPeriod);
    startFlag.setChecked(lastLog == null);
    startFlag.setEnabled(lastLog != null);
}

From source file:de.elanev.studip.android.app.backend.net.oauth.SignInFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "onCreate Called!");
    super.onCreate(savedInstanceState);

    mContext = getActivity();/*  w  w w  . j  a  v a2  s  .com*/
    Bundle args = getArguments();
    if (args != null) {
        boolean resetFlag = args.getBoolean(AUTH_CANCELED);
        if (resetFlag) {
            resetSignInActivityState();
        }
    }
    int res = R.layout.list_item_single_text;
    if (!ApiUtils.isOverApi11()) {
        res = android.R.layout.simple_list_item_checked;
    }
    mAdapter = new ServerAdapter(mContext, res, getItems().getServers());
    slideUpIn = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_up_in);
    setHasOptionsMenu(true);
}

From source file:at.wada811.android.dialogfragments.AbstractDialogFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    Dialog dialog = getDialog();//w  ww . j  a  va  2 s.c  o  m
    if (dialog == null) {
        throw new NullPointerException("Dialog is null! #onCreateDialog must not return null.");
    }
    super.onActivityCreated(savedInstanceState);
    if (savedInstanceState != null) {
        isCanceledOnTouchOutside = savedInstanceState.getInt(CANCELED_TOUCH_OUTSIDE, VALUE_NULL);
        useOnShowListener = savedInstanceState.getBoolean(SHOW_LISTENER);
        useOnCancelListener = savedInstanceState.getBoolean(CANCEL_LISTENER);
        useOnDismissListener = savedInstanceState.getBoolean(DISMISS_LISTENER);
        useOnKeyListener = savedInstanceState.getBoolean(KEY_LISTENER);
        extra = savedInstanceState.getBundle(EXTRA);
    }
    if (isCanceledOnTouchOutside != VALUE_NULL) {
        dialog.setCanceledOnTouchOutside(isCanceledOnTouchOutside == VALUE_TRUE);
    }
    if (useOnShowListener) {
        setOnShowListener(dialog);
    }
    if (useOnCancelListener) {
        setOnCancelListener(dialog);
    }
    if (useOnDismissListener) {
        setOnDismissListener(dialog);
    }
    if (useOnKeyListener) {
        setOnKeyListener(dialog);
    }
}