Example usage for android.os Bundle getInt

List of usage examples for android.os Bundle getInt

Introduction

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

Prototype

public int getInt(String key) 

Source Link

Document

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

Usage

From source file:com.seregil13.literarytracker.lightnovel.LightNovelEditFragment.java

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

    Bundle arguments = getArguments();
    this.mCreateOrEdit = (Mode) arguments.getSerializable(CREATE_OR_EDIT_KEY);
    if (this.mCreateOrEdit == null) {
        this.mCreateOrEdit = Mode.CREATE;
    }// w w w  .ja v a2  s.  c o  m

    switch (this.mCreateOrEdit) {
    case CREATE:
        this.mTitle = "";
        this.mAuthor = "";
        this.mDescription = "";
        this.mCompleted = "false";
        this.mTranslatorSite = "";
        this.mGenres = new ArrayList<>();
        break;
    case EDIT:
        this.mId = arguments.getInt(JsonKeys.ID.toString());
        this.mTitle = arguments.getString(JsonKeys.TITLE.toString());
        this.mAuthor = arguments.getString(JsonKeys.AUTHOR.toString());
        this.mDescription = arguments.getString(JsonKeys.DESCRIPTION.toString());
        this.mCompleted = arguments.getString(JsonKeys.COMPLETED.toString());
        this.mTranslatorSite = arguments.getString(JsonKeys.TRANSLATOR_SITE.toString());
        this.mGenres = arguments.getStringArrayList(JsonKeys.GENRES.toString());
        break;
    }
}

From source file:eu.thecoder4.gpl.pleftdroid.EventDetailActivity.java

/** Called when the activity is first created. */
@Override//from www  .j  ava 2  s. co m
public void onCreate(Bundle savedInstanceState) {
    if (AppPreferences.INSTANCE.getUsePleftTheme()) {
        setTheme(R.style.Theme_Pleft);
    }

    super.onCreate(savedInstanceState);

    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    initOK = true;

    Bundle extras = getIntent().getExtras();
    aid = extras.getInt(AID);
    theurl = extras.getString(THEURL);

    if (extras.getString(FROMHL) != null) {
        back2main = true;
    }

    setContentView(R.layout.event_detail);

    // Initialize Adapters and ListViews
    lvd = (ListView) findViewById(R.id.pdateslv);
    adates = new ArrayList<ADate>();
    adateadapter = new ADateAdapter(this, R.layout.detail_invitee_rowc, adates);
    voteadateadapter = new VoteADateAdapter(this, R.layout.detail_voting_rowdbc, adates);
    lvd.setAdapter(voteadateadapter);

    lvp = (ListView) findViewById(R.id.peoplelv);
    apeople = new ArrayList<APerson>();
    apeopleadapter = new APersonAdapter(this, R.layout.detail_ppl_row, apeople);
    lvp.setAdapter(apeopleadapter);

    lvp.setOnItemClickListener(this);

    lvp.setSelection(curppos);
    lvp.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    initEvent = new Runnable() {
        @Override
        public void run() {
            initializeEventDetail(theurl);
        }
    };
    Thread thread = new Thread(null, initEvent, "Initializer");
    thread.start();

    mProgressDialog = ProgressDialog.show(this, this.getString(R.string.dialog_title_pleasewaitdetails),
            this.getString(R.string.dialog_msg_pleasewaitdetails), true);

    //Toast.makeText(this, ev.toString(), Toast.LENGTH_LONG).show();

}

From source file:com.mohamnag.inappbilling.InAppBillingPlugin.java

/**
 * Buy an already loaded item./*from ww w.  ja  v a2s. c  o m*/
 *
 * @param productId
 * @param callbackContext
 */
private void buy(final String productId, final CallbackContext callbackContext) throws JSONException {

    jsLog("buy called for productId: " + productId);

    SkuDetails product = myInventory.getSkuDetails(productId);
    if (product == null) {
        callbackContext
                .error(new Error(ERR_PRODUCT_NOT_LOADED, "Product intended to be bought has not been loaded.")
                        .toJavaScriptJSON());
    } else if (BILLING_ITEM_TYPE_SUBS.equals(product.getType()) && !subscriptionSupported) {
        callbackContext.error(new Error(ERR_SUBSCRIPTION_NOT_SUPPORTED, "Subscriptions are not supported")
                .toJavaScriptJSON());
    } else {
        cordova.setActivityResultCallback(this);
        int requestCode = REQUEST_CODE_BASE++;

        try {
            jsLog("Preparing purchase flow");

            Bundle buyIntentBundle = iabService.getBuyIntent(3, cordova.getActivity().getPackageName(),
                    product.getSku(), product.getType(), null);

            int response = buyIntentBundle.getInt("RESPONSE_CODE");
            if (response == BILLING_RESPONSE_RESULT_OK) {
                PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");

                pendingPurchaseCallbacks.put(requestCode, callbackContext);

                cordova.getActivity().startIntentSenderForResult(pendingIntent.getIntentSender(), requestCode,
                        new Intent(), 0, 0, 0);

                jsLog("Purchase flow launched successfully");
            } else if (response == BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED) {
                callbackContext.error(
                        new Error(ERR_PURCHASE_OWNED_ITEM, "Item requested to be bought is already owned.")
                                .toJavaScriptJSON());
            } else {
                callbackContext.error(
                        new Error(ERR_PURCHASE_FAILED, "Could not get buy intent. Response code: " + response)
                                .toJavaScriptJSON());
            }
        } catch (RemoteException ex) {
            Logger.getLogger(InAppBillingPlugin.class.getName()).log(Level.SEVERE, null, ex);
            callbackContext.error(new Error(ERR_PURCHASE_FAILED, ex.getMessage()).toJavaScriptJSON());
        } catch (IntentSender.SendIntentException ex) {
            Logger.getLogger(InAppBillingPlugin.class.getName()).log(Level.SEVERE, null, ex);
            callbackContext.error(new Error(ERR_PURCHASE_FAILED, ex.getMessage()).toJavaScriptJSON());
        }

    }
}

From source file:com.example.main.BandWViewPagerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final GlobalID globalID = ((GlobalID) getApplication());
    overridePendingTransition(R.anim.item_in, R.anim.list_out);

    setContentView(R.layout.activity_view_pager);
    mViewPager = (HackyViewPager) findViewById(R.id.view_pager);
    setContentView(mViewPager);/* w  w  w .j  a va  2  s.co m*/
    work = false;
    if (null != savedInstanceState) {
        final String decode = savedInstanceState.getString("ALL_List");
        index = savedInstanceState.getInt("index");
        if (log)
            Log.e(TAG, "null != savedInstanceState ALL_List = " + decode);
        globalID.start(context);
        if (globalID.BandWArrays.isEmpty()) {
            globalID.PD(context, "", "...");
            Thread decode_thread = new Thread() {
                public void run() {
                    getmArrays(decode);
                    Message msg = new Message();
                    globalID.BandWArrays = ALL_List;
                    mhandler.sendMessage(msg);
                }
            };
            decode_thread.start();
        }
    } else {
        Intent intent = getIntent();
        Bundle data = intent.getExtras();
        index = data.getInt("i");

        ALL_List = globalID.BandWArrays;
        work = true;
    }

    samplePagerAdapter = new SamplePagerAdapter(BandWViewPagerActivity.this, IMG_List);
    mViewPager.setAdapter(samplePagerAdapter);
    samplePagerAdapter.notifyDataSetChanged();

    Thread check = new Thread() {
        public void run() {
            while (!work) {
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    continue;
                }
            }

            for (int i = 0; i < ALL_List.size(); i++) {
                BandWEntity entity = ALL_List.get(i);
                if (!entity.getList_type()) {
                    Message msg = new Message();
                    msg.what = i;
                    msg.obj = entity;
                    add_img_handler.sendMessage(msg);
                }
            }
        }
    };
    check.start();
}

From source file:com.example.main.ViewPagerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final GlobalID globalID = (GlobalID) getApplication();
    overridePendingTransition(R.anim.item_in, R.anim.list_out);

    setContentView(R.layout.activity_view_pager);
    mViewPager = (HackyViewPager) findViewById(R.id.view_pager);
    setContentView(mViewPager);//  w  ww.jav  a2s.c  o m
    work = false;

    if (null != savedInstanceState) {
        final String decode = savedInstanceState.getString("ALL_List");
        index = savedInstanceState.getInt("index");
        if (log)
            Log.e(TAG, "null != savedInstanceState ALL_List = " + decode);
        globalID.start(context);
        if (globalID.BandWArrays.isEmpty()) {
            globalID.PD(context, "", "...");
            Thread decode_thread = new Thread() {
                public void run() {
                    getTalkDataArrays(decode);
                    Message msg = new Message();
                    globalID.TalkList = ALL_List;
                    mhandler.sendMessage(msg);
                }
            };
            decode_thread.start();
        }
    } else {
        Intent intent = getIntent();
        Bundle data = intent.getExtras();
        index = data.getInt("i");

        ALL_List = globalID.TalkList;
        work = true;
    }

    samplePagerAdapter = new SamplePagerAdapter(ViewPagerActivity.this, IMG_List);
    mViewPager.setAdapter(samplePagerAdapter);
    samplePagerAdapter.notifyDataSetChanged();

    Thread check = new Thread() {
        public void run() {
            while (!work) {
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    continue;
                }
            }

            for (int i = 0; i < ALL_List.size(); i++) {
                TalkEntity entity = ALL_List.get(i);
                if (!entity.getIsMsg()) {
                    Message msg = new Message();
                    msg.what = i;
                    msg.obj = entity;
                    add_img_handler.sendMessage(msg);
                }
            }
        }
    };
    check.start();
}

From source file:edu.cens.loci.ui.PlaceListActivity.java

/**
 * USE CASES://from  ww w. java 2s  . c o m
 * 
 * 1. DEFAULT :
 *       list places and when selected, ACTION_VIEW
 * 
 *       ACTION ... send ACTION_VIEW content://places/pid 
 *       SHOW ...
 *    - Suggested places ... add "View GPS Places"
 *    - Registered places ...
 *    - Blocked places ...
 *    - Filter by tag ...
 * 
 * 2. INSERT_OR_EDIT :
 *    list "create a new place" and "registered" places, when selected, ACTION_EDIT
 *    
 *    ACTION ... send ACTION_EDIT content://places/pid or ACTION_INSERT content://places
 *    - show all suggested/registered/blocked places
 *    SHOW...
 *    - "create a new place" and "registered places"
 *    
 * 3. PICK :
 *       list places and when selected, return with a uri.
 * 
 *       ACTION ... return a data URL back to the caller
 *       SHOW... 
 * 
 * 4. SEARCH :
 *     TBD
 * 
 */

@Override
protected void onCreate(Bundle icicle) {

    super.onCreate(icicle);

    setContentView(R.layout.place_list);

    // Resolve the intent
    final Intent intent = getIntent();

    String title = intent.getStringExtra(UI.TITLE_EXTRA_KEY);
    if (title != null) {
        setTitle(title);
    }

    String action = intent.getAction();

    if (Intent.ACTION_VIEW.equals(action)) {
        mMode = MODE_VIEW;
    } else if (Intents.UI.ACTION_INSERT.equals(action)) {
        mMode = MODE_INSERT;
    } else if (Intents.UI.ACTION_CREATE_OR_ADDTO_FROM_SUGGESTED_PLACE.equals(action)) {
        mMode = MODE_REGISTER_SUGGESTED;
    } else if (Intent.ACTION_PICK.equals(action)) {
        mMode = MODE_PICK;
    }

    MyLog.i(LociConfig.D.UI.DEBUG, TAG, String.format("List: mode=%d (%s)", mMode, action));

    Bundle extras = intent.getExtras();

    if (extras != null) {
        if (extras.containsKey(Intents.UI.FILTER_STATE_EXTRA_KEY))
            mFilterState = extras.getInt(Intents.UI.FILTER_STATE_EXTRA_KEY);
        if (extras.containsKey(Intents.UI.FILTER_TYPE_EXTRA_KEY))
            mFilterType = extras.getInt(Intents.UI.FILTER_TYPE_EXTRA_KEY);
        if (extras.containsKey(Intents.UI.FILTER_TAG_EXTRA_KEY))
            mFilterTag = extras.getString(Intents.UI.FILTER_TAG_EXTRA_KEY);
        if (extras.containsKey(Intents.UI.LIST_ORDER_EXTRA_KEY))
            mListOrder = extras.getInt(Intents.UI.LIST_ORDER_EXTRA_KEY);
    }

    mDbUtils = new LociDbUtils(this);
}

From source file:com.spoiledmilk.cykelsuperstier.navigation.SMRouteNavigationActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == BreakRouteActivity.RESULT_ROUTE_BROKEN) {
        if (data != null && data.getExtras() != null) {
            Bundle args = data.getExtras();
            startStat = Util.locationFromCoordinates(args.getDouble("start_station_lat"),
                    args.getDouble("start_station_lon"));
            endStat = Util.locationFromCoordinates(args.getDouble("end_station_lat"),
                    args.getDouble("end_station_lon"));
            aStationName = args.getString("start_stat_name");
            bStationName = args.getString("end_stat_name");
            distance = args.getDouble("distance");
            stationIconId = args.getInt("iconId");
            getMapFragment().jsonRoot = null;
            List<Location> viaList = new LinkedList<Location>();
            viaList.add(startStat);/*from  www. java  2 s  . co m*/
            viaList.add(endStat);
            new SMHttpRequest().getRoute(getMapFragment().startLocation, getMapFragment().endLocation, viaList,
                    this);
        }
    }
}

From source file:com.nextgis.maplibui.dialog.CreateFromQMSLayerDialog.java

@NonNull
@Override//from   w  w  w .  j  av a  2  s .c  o m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    mNet = new NetworkUtil(mContext);
    mQMSIconsDir = MapUtil.prepareTempDir(mContext, "qms_icons");

    if (null != savedInstanceState) {
        int id = savedInstanceState.getInt(KEY_ID);
        MapBase map = MapBase.getInstance();
        if (null != map) {
            ILayer iLayer = map.getLayerById(id);
            if (iLayer instanceof LayerGroup) {
                mGroupLayer = (LayerGroup) iLayer;
            }
        }
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setTitle(mTitle).setView(R.layout.list_content).setPositiveButton(R.string.add, null)
            .setNeutralButton(R.string.new_tms, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    CreateRemoteTMSLayerDialog newFragment = new CreateRemoteTMSLayerDialog();
                    newFragment.setLayerGroup(mGroupLayer)
                            .setTitle(mContext.getString(R.string.create_tms_layer))
                            .setTheme(((NGActivity) getActivity()).getThemeId())
                            .show(getActivity().getSupportFragmentManager(), "create_tms_layer");
                }
            }).setNegativeButton(R.string.cancel, null);

    final AlertDialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(false);

    mData = new ArrayList<>();
    mChecked = new ArrayList<>();

    IGISApplication application = (IGISApplication) getActivity().getApplication();
    application.sendScreen(ConstantsUI.GA_DIALOG_QMS);
    return dialog;
}

From source file:com.github.chenxiaolong.dualbootpatcher.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.drawer_layout);

    mHandler = new Handler();

    mPrefs = getSharedPreferences("settings", 0);

    if (savedInstanceState != null) {
        mTitle = savedInstanceState.getInt(EXTRA_TITLE);
    }/*from  ww  w  .j a  va2 s  . c om*/

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open,
            R.string.drawer_close) {
        @Override
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);

            if (mPending != null) {
                mHandler.post(mPending);
                mPending = null;
            }
        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }

    mDrawerView = (NavigationView) findViewById(R.id.left_drawer);
    mDrawerView.setNavigationItemSelectedListener(this);

    // There's a weird performance issue when the drawer is first opened, no matter if we set
    // the background on the nav header RelativeLayout, set the image on an ImageView, or use
    // Picasso to do either asynchronously. By accident, I noticed that using Picasso's resize()
    // method with any dimensions (even the original) works around the performance issue. Maybe
    // something doesn't like PNGs exported from GIMP?
    View header = mDrawerView.inflateHeaderView(R.layout.nav_header);
    ImageView navImage = (ImageView) header.findViewById(R.id.nav_header_image);
    BitmapFactory.Options dimensions = new BitmapFactory.Options();
    dimensions.inJustDecodeBounds = true;
    BitmapFactory.decodeResource(getResources(), R.drawable.material, dimensions);
    Picasso.with(this).load(R.drawable.material).resize(dimensions.outWidth, dimensions.outHeight)
            .into(navImage);

    // Set nav drawer header text
    TextView appName = (TextView) header.findViewById(R.id.nav_header_app_name);
    appName.setText(BuildConfig.APP_NAME_RESOURCE);
    TextView appVersion = (TextView) header.findViewById(R.id.nav_header_app_version);
    appVersion.setText(String.format(getString(R.string.version), BuildConfig.VERSION_NAME));

    // Nav drawer width according to material design guidelines
    // http://www.google.com/design/spec/patterns/navigation-drawer.html
    // https://medium.com/sebs-top-tips/material-navigation-drawer-sizing-558aea1ad266
    final Display display = getWindowManager().getDefaultDisplay();
    final Point size = new Point();
    display.getSize(size);

    final ViewGroup.LayoutParams params = mDrawerView.getLayoutParams();
    int toolbarHeight = getResources().getDimensionPixelSize(R.dimen.abc_action_bar_default_height_material);
    params.width = Math.min(size.x - toolbarHeight, 6 * toolbarHeight);
    mDrawerView.setLayoutParams(params);

    if (savedInstanceState != null) {
        mFragment = savedInstanceState.getInt(EXTRA_FRAGMENT);

        showFragment();

        mDrawerItemSelected = savedInstanceState.getInt(EXTRA_SELECTED_ITEM);
    } else {
        String[] initialScreens = getResources().getStringArray(R.array.initial_screen_entry_values);
        String initialScreen = mPrefs.getString("initial_screen", null);
        if (initialScreen == null || !ArrayUtils.contains(initialScreens, initialScreen)) {
            initialScreen = INITIAL_SCREEN_ABOUT;
            Editor e = mPrefs.edit();
            e.putString("initial_screen", initialScreen);
            e.apply();
        }

        int navId;
        switch (initialScreen) {
        case INITIAL_SCREEN_ABOUT:
            navId = R.id.nav_about;
            break;
        case INITIAL_SCREEN_ROMS:
            navId = R.id.nav_roms;
            break;
        case INITIAL_SCREEN_PATCHER:
            navId = R.id.nav_patch_zip;
            break;
        default:
            throw new IllegalStateException("Invalid initial screen value");
        }

        // Show about screen by default
        mDrawerItemSelected = navId;
    }

    onDrawerItemClicked(mDrawerItemSelected, false);

    refreshOptionalItems();

    // Open drawer on first start
    new Thread() {
        @Override
        public void run() {
            boolean isFirstStart = mPrefs.getBoolean("first_start", true);
            if (isFirstStart) {
                mDrawerLayout.openDrawer(mDrawerView);
                Editor e = mPrefs.edit();
                e.putBoolean("first_start", false);
                e.apply();
            }
        }
    }.start();
}

From source file:io.v.android.apps.syncslides.NavigationDrawerFragment.java

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

    // Read in the flag indicating whether or not the user has demonstrated awareness of the
    // drawer. See PREF_USER_LEARNED_DRAWER for details.
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
    mUserLearnedDrawer = prefs.getBoolean(PREF_USER_LEARNED_DRAWER, false);
    mUserEmail = SignInActivity.getUserEmail(getActivity());
    mUserName = SignInActivity.getUserName(getActivity());

    if (savedInstanceState != null) {
        mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION);
        mFromSavedInstanceState = true;/* w ww.  j  a  va  2 s  . com*/
    }

    // Select either the default item (0) or the last selected item.
    selectItem(mCurrentSelectedPosition);
}