Example usage for android.os Bundle putInt

List of usage examples for android.os Bundle putInt

Introduction

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

Prototype

public void putInt(@Nullable String key, int value) 

Source Link

Document

Inserts an int value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.kennethmaffei.infinitegrid.HTTPCommManager.java

/**
 * Sets up a headless fragment that calls an asynctask to retrieve an image from a url
 * /*  ww  w  . j a  v  a2  s  . c om*/
 * @param url - the url which we will get data back from
 */
public void getURL(RecordDescriptor record) {
    if (activity == null)
        return;

    FragmentManager fm = activity.getFragmentManager();
    //Use the url as the fragment tag
    TaskFragment taskFragment = (TaskFragment) fm.findFragmentByTag(record.url);

    //If the Fragment is non-null, then it is currently being retained across a configuration change.
    if (taskFragment == null) {
        taskFragment = new TaskFragment();
        Bundle args = new Bundle();
        args.putInt("type", CALLTYPE.IMAGE.ordinal());
        args.putParcelable("record", record);
        taskFragment.setArguments(args);
        fm.beginTransaction().add(taskFragment, record.url).commit();
    }
}

From source file:com.kennethmaffei.infinitegrid.HTTPCommManager.java

/**
 * Sets up a headless fragment that calls an AsyncTask to retrieve records in the db
 * /*from  www .j  a  va2 s.c om*/
 * @param activity - the activity, needed to access the fragment manager
 */
public void getDBData() {
    if (activity == null)
        return;

    synchronized (synchronizeObject) {
        if (!retrievalDone)
            return;

        retrievalDone = false;
        imageCount = 0;
        FragmentManager fm = activity.getFragmentManager();
        TaskFragment taskFragment = (TaskFragment) fm.findFragmentByTag(Constants.TAG_TASK_GETALLRECORDS);

        //If the Fragment is non-null, then it is currently being retained across a configuration change.         
        if (taskFragment == null) {
            taskFragment = new TaskFragment();
            Bundle args = new Bundle();
            args.putInt("type", CALLTYPE.ALL_RECORDS.ordinal());
            taskFragment.setArguments(args);
            fm.beginTransaction().add(taskFragment, Constants.TAG_TASK_GETALLRECORDS).commit();
        }
    }
}

From source file:com.evvsoft.treeview.demo.DemoActivity.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (mTheme != 0)
        outState.putInt(IDENT_THEME, mTheme);
    if (mIndicator != 0)
        outState.putInt(IDENT_INDICATOR, mIndicator);
    if (mAdapter != null) {
        String json = mAdapter.toString();
        outState.putString(IDENT_JSON, json);
    }/*from w  w  w.j  av  a 2 s  .c om*/
}

From source file:com.example.android.fragments.MainActivity.java

public void onArticleSelected(int position) {
    // The user selected the headline of an article from the HeadlinesFragment

    // Capture the article fragment from the activity layout
    ArticlesFragment articleFrag = (ArticlesFragment) getSupportFragmentManager()
            .findFragmentById(R.id.article_fragment);

    if (articleFrag != null) {
        // If article frag is available, we're in two-pane layout...

        // Call a method in the ArticleFragment to update its content
        articleFrag.updateArticleView(position);

    } else {//from  w ww .  j  av a2s .  co  m
        // If the frag is not available, we're in the one-pane layout and must swap frags...

        // Create fragment and give it an argument for the selected article
        ArticlesFragment newFragment = new ArticlesFragment();
        Bundle args = new Bundle();
        args.putInt(ArticlesFragment.ARG_POSITION, position);
        newFragment.setArguments(args);
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

        // Replace whatever is in the fragment_container view with this fragment,
        // and add the transaction to the back stack so the user can navigate back
        transaction.replace(R.id.fragment_container, newFragment);
        transaction.addToBackStack(null);

        // Commit the transaction
        transaction.commit();
    }
}

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

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    // Save the current article selection in case we need to recreate the fragment
    outState.putInt(ARG_POSITION, mCurrentPosition);
}

From source file:com.group7.dragonwars.GameActivity.java

public final void endGame() {
    setContentView(R.layout.loading_screen);
    Intent intent = new Intent(this, Results.class);
    Bundle b = new Bundle();
    b.putString("winnerName", state.getWinner().getName());
    b.putInt("turns", state.getTurns());
    Statistics stats = state.getStatistics();
    Double damageDealt = stats.getStatistic("Damage dealt");
    Double damageReceived = stats.getStatistic("Damage received");
    Double distanceTravelled = stats.getStatistic("Distance travelled");
    Integer goldCollected = stats.getStatistic("Gold received").intValue();
    Integer unitsKilled = stats.getStatistic("Units killed").intValue();
    Integer unitsMade = stats.getStatistic("Units produced").intValue();

    Database db = new Database(getApplicationContext());
    db.AddEntry(damageDealt, damageReceived, distanceTravelled, goldCollected, unitsKilled, unitsMade);
    db.Close();/* w  w w  .  java2  s  . c  o  m*/

    for (Map.Entry<String, Double> ent : stats.getEntrySet()) {
        b.putDouble(ent.getKey(), ent.getValue().doubleValue());
    }

    intent.putExtras(b);
    startActivity(intent);
    finish();
}

From source file:com.krayzk9s.imgurholo.ui.ImagePager.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putParcelableArrayList("imageData", imageData);
    savedInstanceState.putInt("start", pager.getCurrentItem());
    // Always call the superclass so it can save the view hierarchy state
    super.onSaveInstanceState(savedInstanceState);
}

From source file:com.foxykeep.datadroidpoc.data.operation.ComputeSquareOperation.java

@Override
public Bundle execute(Context context, Request request)
        throws ConnectionException, DataException, CustomRequestException {
    String url;//www.j  a va  2  s.  co  m
    NetworkConnection.Method method;

    switch (request.getInt(PARAM_METHOD)) {
    case 0: // GET
        url = WSConfig.WS_REQUEST_TYPES_GET;
        method = NetworkConnection.Method.GET;
        break;
    case 1: // POST
        url = WSConfig.WS_REQUEST_TYPES_POST;
        method = NetworkConnection.Method.POST;
        break;
    case 2: // PUT
        // TODO for now hack to keep it as a GET method as my server doesn't accept PUT
        // requests
        url = WSConfig.WS_REQUEST_TYPES_GET;
        method = NetworkConnection.Method.GET;
        //                url = WSConfig.WS_REQUEST_TYPES_PUT;
        //                method = NetworkConnection.Method.PUT;
        break;
    case 3: // DELETE
        // TODO for now hack to keep it as a GET method as my server doesn't accept
        // DELETE requests
        url = WSConfig.WS_REQUEST_TYPES_GET;
        method = NetworkConnection.Method.GET;
        //                url = WSConfig.WS_REQUEST_TYPES_DELETE;
        //                method = NetworkConnection.Method.DELETE;
        break;
    default:
        throw new IllegalArgumentException("Unknown method: " + request.getInt(PARAM_METHOD));
    }

    NetworkConnection connection = new NetworkConnection(context, url);
    connection.setMethod(method);
    ArrayList<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
    params.add(new BasicNameValuePair(WSConfig.WS_REQUEST_TYPE_NUMBER, request.getIntAsString(PARAM_NUMBER)));
    connection.setParameters(params);
    NetworkConnection.ConnectionResult result = connection.execute();

    // Parse the result
    Bundle bundle = new Bundle();
    try {
        JSONObject root = new JSONObject(result.body);
        bundle.putInt(PoCRequestFactory.BUNDLE_EXTRA_SQUARE, root.getInt(JSONTag.REQUEST_TYPE_VALUE));
    } catch (JSONException e) {
        throw new DataException(e);
    }

    return bundle;
}

From source file:com.mikecorrigan.trainscorekeeper.Players.java

public void saveUi(Bundle bundle) {
    bundle.putInt(BUNDLE_SELECTED_ID, selectedId);
    Log.vc(VERBOSE, TAG, "saveUi: bundle=" + Utils.bundleToString(bundle));
}

From source file:it.sineo.android.tileMapEditor.TileMap.java

/**
 * Returns a Bundle representation of this map. No transient data is stored.
 * /*from ww  w .j a v a2 s  .c  om*/
 * @return
 */
public Bundle toBundle() {
    Bundle b = new Bundle();
    b.putString("name", name);

    b.putInt("rows", rows);
    b.putInt("columns", columns);
    b.putFloat("scale", scale);
    b.putFloat("xOff", xOff);
    b.putFloat("yOff", yOff);
    for (int idxRow = 0; idxRow < rows; idxRow++) {
        for (int idxCol = 0; idxCol < columns; idxCol++) {
            if (tilePaths[idxRow][idxCol] != null) {
                b.putString("paths_" + idxRow + "_" + idxCol, tilePaths[idxRow][idxCol]);
                b.putByte("angles_" + idxRow + "_" + idxCol, tileAngles[idxRow][idxCol]);
            }
        }
    }
    return b;
}