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:edu.rit.csh.androidwebnews.PostSwipeableActivity.java

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

    ViewPager mViewPager;/*w w w . j a va2s. co m*/
    setContentView(R.layout.activity_post_swipable);
    hc = new HttpsConnector(this);

    Bundle extras = getIntent().getExtras();
    newsgroupName = extras.getString("SELECTED_NEWSGROUP");
    id = extras.getInt("SELECTED_ID");
    int selected_id = extras.getInt("GOTO_THIS");
    fromSearch = extras.getBoolean("SEARCH_RESULTS");

    ppa = new PostPagerAdapter(getSupportFragmentManager(), fromSearch);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(ppa);
    dialog = new InvalidApiKeyDialog(this);
    mViewPager.setCurrentItem(selected_id);

    if (!fromSearch) {
        for (int x = 0; x < DisplayThreadsActivity.lastFetchedThreads.size(); x++) {
            if (DisplayThreadsActivity.lastFetchedThreads.get(x).getNumber() == id) {
                rootThread = DisplayThreadsActivity.lastFetchedThreads.get(x);
                break;
            }
        }
    }
}

From source file:com.whamads.nativecamera.NativeCameraLauncher.java

@Override
public void onRestoreStateForActivityResult(Bundle state, CallbackContext callbackContext) {
    this.callbackContext = callbackContext;

    this.mQuality = state.getInt("mQuality");
    this.targetWidth = state.getInt("targetWidth");
    this.targetHeight = state.getInt("targetHeight");

    this.imageUri = state.getParcelable("imageUri");
    this.photo = (File) state.getSerializable("photo");

    this.date = state.getString("date");

    super.onRestoreStateForActivityResult(state, callbackContext);
}

From source file:androidx.navigation.fragment.NavHostFragment.java

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Context context = requireContext();

    mNavController = new NavController(context);
    mNavController.getNavigatorProvider().addNavigator(createFragmentNavigator());

    Bundle navState = null;/*from  w  w  w .j  a  va 2  s .co m*/
    if (savedInstanceState != null) {
        navState = savedInstanceState.getBundle(KEY_NAV_CONTROLLER_STATE);
        if (savedInstanceState.getBoolean(KEY_DEFAULT_NAV_HOST, false)) {
            mDefaultNavHost = true;
            requireFragmentManager().beginTransaction().setPrimaryNavigationFragment(this).commit();
        }
    }

    if (navState != null) {
        // Navigation controller state overrides arguments
        mNavController.restoreState(navState);
    } else {
        final Bundle args = getArguments();
        final int graphId = args != null ? args.getInt(KEY_GRAPH_ID) : 0;
        if (graphId != 0) {
            mNavController.setGraph(graphId);
        } else {
            mNavController.setMetadataGraph();
        }
    }
}

From source file:in.codehex.facilis.PlaceBidFragment.java

/**
 * Implement and manipulate the objects.
 *//*from   w ww.  ja  v a 2s.c o m*/
private void prepareObjects() {
    Bundle bundle = getArguments();
    // TODO: handle null value of arguments
    if (bundle != null) {
        mOrderId = bundle.getInt(Config.KEY_BUNDLE_ORDER_ID);
    }

    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());

    processOrderItems();
}

From source file:com.example.app.ArticleFragment.java

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

    // If activity recreated (such as from screen rotate), restore
    // the previous article selection set by onSaveInstanceState().
    // This is primarily necessary when in the two-pane layout.
    if (savedInstanceState != null) {
        mCurrentPosition = savedInstanceState.getInt(ARG_POSITION);
    }/*  w w w .  j ava  2s .c  o m*/

    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.article_view, container, false);
}

From source file:com.shanet.relayremote.Main.java

private void setRelayStates(ArrayList<BasicNameValuePair> states) {
    if (states == null)
        return;/*from  w ww  .  ja v  a2s.  c o m*/

    // The server these states correspond to is the first entry
    String server = states.get(0).getValue();

    Relay relay;
    ArrayList<Bundle> widgets = database.selectAllWidgets();

    relay_loop: for (int i = 0; i < relays.size(); i++) {
        relay = relays.get(i);

        // If the current relay belongs to the server the states belong to, find it's state by matching pins
        if (relay.getServer().equals(server)) {
            for (int j = 1; j < states.size(); j++) {
                if (relay.getPin() == Integer.valueOf(states.get(j).getName())) {
                    if (states.get(j).getValue().charAt(0) == Constants.CMD_ON) {
                        relay.turnOn();
                    } else {
                        relay.turnOff();
                    }

                    // Check if any widgets are assigned to this relay, and if so, update them
                    for (Bundle widget : widgets) {
                        if (widget.getInt("type") == Constants.WIDGET_RELAY
                                && widget.getInt("id") == relay.getRid()) {
                            // Update the indicator image
                            RemoteViews views = new RemoteViews(this.getPackageName(), R.layout.widget);
                            views.setImageViewResource(R.id.widgetIndicator,
                                    (states.get(i).getValue().charAt(0) == Constants.CMD_ON)
                                            ? R.drawable.widget_on
                                            : R.drawable.widget_off);
                            AppWidgetManager.getInstance(this).updateAppWidget(widget.getInt("wid"), views);

                            // Set the state of the widget in the widget class
                            Widget.setState(widget.getInt("wid"),
                                    (states.get(i).getValue().charAt(0) == Constants.CMD_ON) ? Widget.STATE_ON
                                            : Widget.STATE_OFF);
                        }
                    }

                    // Done with this relay; move to the next one
                    continue relay_loop;
                }
            }
        }
    }
}

From source file:com.github.chenxiaolong.dualbootpatcher.switcher.ZipFlashingOutputFragment.java

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

    if (savedInstanceState != null) {
        mTaskIdFlashZips = savedInstanceState.getInt(EXTRA_TASK_ID_FLASH_ZIPS);
    }//  w  w w.  j ava  2 s .com
}

From source file:com.irccloud.android.fragment.ChannelOptionsFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (savedInstanceState != null && savedInstanceState.containsKey("cid") && cid == -1) {
        cid = savedInstanceState.getInt("cid");
        bid = savedInstanceState.getInt("bid");
    }//w ww . ja  v  a  2s.c  om
    Context ctx = getActivity();
    if (ctx == null)
        return null;
    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.dialog_channel_options, null);
    members = (SwitchCompat) v.findViewById(R.id.members);
    unread = (SwitchCompat) v.findViewById(R.id.unread);
    notifyAll = (SwitchCompat) v.findViewById(R.id.notifyAll);
    joinpart = (SwitchCompat) v.findViewById(R.id.joinpart);
    collapse = (SwitchCompat) v.findViewById(R.id.collapse);
    autosuggest = (SwitchCompat) v.findViewById(R.id.autosuggest);

    return new AlertDialog.Builder(ctx)
            .setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
            .setTitle("Display Options").setView(v).setPositiveButton("Save", new SaveClickListener())
            .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();
}

From source file:com.facebook.internal.BundleJSONConverterTests.java

@SmallTest
public void testSimpleValues() throws JSONException {
    ArrayList<String> arrayList = new ArrayList<String>();
    arrayList.add("1st");
    arrayList.add("2nd");
    arrayList.add("third");

    Bundle innerBundle1 = new Bundle();
    innerBundle1.putInt("inner", 1);

    Bundle innerBundle2 = new Bundle();
    innerBundle2.putString("inner", "2");
    innerBundle2.putStringArray("deep list", new String[] { "7", "8" });

    innerBundle1.putBundle("nested bundle", innerBundle2);

    Bundle b = new Bundle();
    b.putBoolean("boolValue", true);
    b.putInt("intValue", 7);
    b.putLong("longValue", 5000000000l);
    b.putDouble("doubleValue", 3.14);
    b.putString("stringValue", "hello world");
    b.putStringArray("stringArrayValue", new String[] { "first", "second" });
    b.putStringArrayList("stringArrayListValue", arrayList);
    b.putBundle("nested", innerBundle1);

    JSONObject json = BundleJSONConverter.convertToJSON(b);
    assertNotNull(json);/*from  ww w.j a v a  2s  .com*/

    assertEquals(true, json.getBoolean("boolValue"));
    assertEquals(7, json.getInt("intValue"));
    assertEquals(5000000000l, json.getLong("longValue"));
    assertEquals(3.14, json.getDouble("doubleValue"));
    assertEquals("hello world", json.getString("stringValue"));

    JSONArray jsonArray = json.getJSONArray("stringArrayValue");
    assertEquals(2, jsonArray.length());
    assertEquals("first", jsonArray.getString(0));
    assertEquals("second", jsonArray.getString(1));

    jsonArray = json.getJSONArray("stringArrayListValue");
    assertEquals(3, jsonArray.length());
    assertEquals("1st", jsonArray.getString(0));
    assertEquals("2nd", jsonArray.getString(1));
    assertEquals("third", jsonArray.getString(2));

    JSONObject innerJson = json.getJSONObject("nested");
    assertEquals(1, innerJson.getInt("inner"));
    innerJson = innerJson.getJSONObject("nested bundle");
    assertEquals("2", innerJson.getString("inner"));

    jsonArray = innerJson.getJSONArray("deep list");
    assertEquals(2, jsonArray.length());
    assertEquals("7", jsonArray.getString(0));
    assertEquals("8", jsonArray.getString(1));

    Bundle finalBundle = BundleJSONConverter.convertToBundle(json);
    assertNotNull(finalBundle);

    assertEquals(true, finalBundle.getBoolean("boolValue"));
    assertEquals(7, finalBundle.getInt("intValue"));
    assertEquals(5000000000l, finalBundle.getLong("longValue"));
    assertEquals(3.14, finalBundle.getDouble("doubleValue"));
    assertEquals("hello world", finalBundle.getString("stringValue"));

    List<String> stringList = finalBundle.getStringArrayList("stringArrayValue");
    assertEquals(2, stringList.size());
    assertEquals("first", stringList.get(0));
    assertEquals("second", stringList.get(1));

    stringList = finalBundle.getStringArrayList("stringArrayListValue");
    assertEquals(3, stringList.size());
    assertEquals("1st", stringList.get(0));
    assertEquals("2nd", stringList.get(1));
    assertEquals("third", stringList.get(2));

    Bundle finalInnerBundle = finalBundle.getBundle("nested");
    assertEquals(1, finalInnerBundle.getInt("inner"));
    finalBundle = finalInnerBundle.getBundle("nested bundle");
    assertEquals("2", finalBundle.getString("inner"));

    stringList = finalBundle.getStringArrayList("deep list");
    assertEquals(2, stringList.size());
    assertEquals("7", stringList.get(0));
    assertEquals("8", stringList.get(1));
}

From source file:cn.newgxu.android.bbs.ui.RepliesFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mPosition = savedInstanceState.getInt(REPLY_INDEX);
    }/*from   w  ww  .j  a  v a  2s  .c  o m*/
}