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:gov.sfmta.sfpark.MainScreenActivity.java

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    // Restore the previously serialized current dropdown position.
    if (savedInstanceState.containsKey(STATE_SELECTED_NAVIGATION_ITEM)) {
        getSupportActionBar()/*from   www  .  ja v  a 2  s .c  o m*/
                .setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM));
    }
}

From source file:com.googlecode.CallerLookup.Main.java

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

    mIgnoreItemSelection = true;//w w w . j a va  2  s.  c om
    mLookup.setSelection(savedInstanceState.getInt(PREFS_LOOKUP));
    mURL.setText(savedInstanceState.getString(PREFS_URL));
    mRegExp.setText(savedInstanceState.getString(PREFS_REGEXP));
    mTestInput.setText(savedInstanceState.getString(STATE_TESTINPUT));
    mNotify.setChecked(savedInstanceState.getBoolean(PREFS_NOTIFY));
}

From source file:net.networksaremadeofstring.rhybudd.ZenossWidgetGraph.java

public void onUpdate(final Context context, final AppWidgetManager appWidgetManager, final int[] appWidgetIds) {
    if (settings == null)
        settings = PreferenceManager.getDefaultSharedPreferences(context);

    wContext = context;//from  w w  w.j av a2  s .  c o m

    Refresh();

    handler = new Handler() {
        public void handleMessage(Message msg) {
            if (msg.what == 1) {
                Bundle Values = msg.getData();

                final int N = appWidgetIds.length;
                RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.zenoss_widget_graph);
                //Intent intent = new Intent(context, rhestr.class);
                //PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);

                //Log.i("GraphWidget","Drawing Graph!");
                for (int i = 0; i < N; i++) {
                    int appWidgetId = appWidgetIds[i];
                    views.setImageViewBitmap(R.id.graphCanvas, RenderBarGraph(Values.getInt("CritCount"),
                            Values.getInt("ErrCount"), Values.getInt("WarnCount")));
                    appWidgetManager.updateAppWidget(appWidgetId, views);
                }
            }
        }
    };
}

From source file:com.samknows.measurement.activity.SamKnowsTestViewerActivity.java

/** Called when the activity is first created. */
@Override//from   w w w.  j a  v a 2s . c  o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    cxt = this;

    Bundle b = getIntent().getExtras();
    int testID = -1;

    if (b != null) {
        testID = b.getInt("testID");
    }

    storage = CachingStorage.getInstance();
    config = storage.loadScheduleConfig();
    if (config == null) {
        config = new ScheduleConfig();
    }
    testList = config.manual_tests;
    array_spinner = new String[testList.size() + 1];
    array_spinner_int = new int[testList.size() + 1];

    this.setTitle(R.string.running_test);

    // choose which test to run
    setContentView(R.layout.individual_stat_test);

    Util.initializeFonts(this);
    Util.overrideFonts(this, findViewById(android.R.id.content));
    try {

        handler = new Handler() {

            @Override
            public void handleMessage(Message msg) {
                TextView tv = null;

                JSONObject message_json;
                message_json = (JSONObject) msg.obj;
                String value;
                int success;
                int testname;
                int status_complete;
                int metric;

                try {

                    String type = message_json.getString(TestResult.JSON_TYPE_ID);

                    if (type == "completed") {

                        result = 1;
                        SamKnowsTestViewerActivity.this.finish();
                        overridePendingTransition(0, 0);
                    }

                    if (type == "test") {
                        testname = message_json.getInt(TestResult.JSON_TESTNUMBER);
                        status_complete = message_json.getInt(TestResult.JSON_STATUS_COMPLETE);
                        value = message_json.getString(TestResult.JSON_HRRESULT);
                        if (status_complete == 100 && message_json.has(TestResult.JSON_SUCCESS)) {

                            success = message_json.getInt(TestResult.JSON_SUCCESS);
                            if (success == 0) {
                                value = getString(R.string.failed);
                            }
                        }

                        switch (testname) {
                        // active metrics
                        case TestResult.DOWNLOAD_TEST_ID:
                            pw = (ProgressWheel) findViewById(R.id.ProgressWheel1);
                            tv = (TextView) findViewById(R.id.download_result);
                            pw.setProgress((int) (status_complete * 3.6));
                            pw.setContentDescription("Status " + status_complete + "%");
                            if (status_complete == 100) {
                                pw.setVisibility(View.GONE);
                                tv.setText(value);
                                tv.setContentDescription(getString(R.string.download) + " " + value);
                                tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
                            } else {
                                pw.setVisibility(View.VISIBLE);
                                tv.setText("");
                            }
                            break;
                        case TestResult.UPLOAD_TEST_ID:
                            pw = (ProgressWheel) findViewById(R.id.ProgressWheel2);
                            tv = (TextView) findViewById(R.id.upload_result);
                            pw.setProgress((int) (status_complete * 3.6));
                            pw.setContentDescription("Status " + status_complete + "%");
                            if (status_complete == 100) {
                                pw.setVisibility(View.GONE);

                                tv.setText(value);
                                tv.setContentDescription(getString(R.string.upload) + " " + value);
                                tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
                            } else {
                                pw.setVisibility(View.VISIBLE);
                                tv.setText("");
                            }
                            break;
                        case TestResult.PACKETLOSS_TEST_ID:
                            pw = (ProgressWheel) findViewById(R.id.ProgressWheel3);
                            tv = (TextView) findViewById(R.id.packetloss_result);
                            pw.setProgress((int) (status_complete * 3.6));
                            pw.setContentDescription("Status " + status_complete + "%");
                            if (status_complete == 100) {
                                pw.setVisibility(View.GONE);
                                tv.setText(value);
                                tv.setContentDescription(getString(R.string.packet_loss) + " " + value);
                                tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
                            } else {
                                pw.setVisibility(View.VISIBLE);
                                tv.setText("");
                            }
                            break;
                        case TestResult.LATENCY_TEST_ID:
                            pw = (ProgressWheel) findViewById(R.id.ProgressWheel4);
                            tv = (TextView) findViewById(R.id.latency_result);
                            pw.setProgress((int) (status_complete * 3.6));
                            pw.setContentDescription("Status " + status_complete + "%");
                            if (status_complete == 100) {
                                pw.setVisibility(View.GONE);
                                tv.setText(value);
                                tv.setContentDescription(getString(R.string.latency) + " " + value);
                                tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
                            } else {
                                pw.setVisibility(View.VISIBLE);
                                tv.setText("");
                            }
                            break;
                        case TestResult.JITTER_TEST_ID:
                            pw = (ProgressWheel) findViewById(R.id.ProgressWheel5);
                            tv = (TextView) findViewById(R.id.jitter_result);
                            pw.setProgress((int) (status_complete * 3.6));
                            pw.setContentDescription("Status " + status_complete + "%");
                            if (status_complete == 100) {
                                pw.setVisibility(View.GONE);
                                tv.setText(value);
                                tv.setContentDescription(getString(R.string.jitter) + " " + value);
                                tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
                            } else {
                                pw.setVisibility(View.VISIBLE);
                                tv.setText("");
                            }
                            break;

                        }
                    }

                    if (type == "passivemetric") {
                        metric = message_json.getInt("metric");
                        value = message_json.getString("value");

                        switch (metric) {

                        // passive metrics
                        case 1:
                            tv = (TextView) findViewById(R.id.passivemetric1);
                            tv.setText(value);
                            break;

                        case 2:
                            tv = (TextView) findViewById(R.id.passivemetric2);
                            tv.setText(value);
                            break;

                        case 3:
                            tv = (TextView) findViewById(R.id.passivemetric3);
                            tv.setText(value);
                            break;

                        case 4:
                            tv = (TextView) findViewById(R.id.passivemetric4);
                            tv.setText(value);
                            break;

                        case 5:
                            tv = (TextView) findViewById(R.id.passivemetric5);
                            tv.setText(value);
                            break;

                        case 6:
                            tv = (TextView) findViewById(R.id.passivemetric6);
                            tv.setText(value);
                            break;

                        case 7:
                            tv = (TextView) findViewById(R.id.passivemetric7);
                            tv.setText(value);
                            break;

                        case 8:
                            tv = (TextView) findViewById(R.id.passivemetric8);
                            tv.setText(value);
                            break;

                        case 9:
                            tv = (TextView) findViewById(R.id.passivemetric9);
                            tv.setText(value);
                            break;

                        case 10:
                            tv = (TextView) findViewById(R.id.passivemetric10);
                            tv.setText(value);
                            break;

                        case 11:
                            tv = (TextView) findViewById(R.id.passivemetric11);
                            tv.setText(value);
                            break;
                        case 12:
                            tv = (TextView) findViewById(R.id.passivemetric12);
                            tv.setText(value);
                            break;
                        case 13:
                            tv = (TextView) findViewById(R.id.passivemetric13);
                            tv.setText(value);
                            break;
                        case 14:
                            tv = (TextView) findViewById(R.id.passivemetric14);
                            tv.setText(value);
                            break;
                        case 15:
                            tv = (TextView) findViewById(R.id.passivemetric15);
                            tv.setText(value);
                            break;
                        case 16:
                            tv = (TextView) findViewById(R.id.passivemetric16);
                            tv.setText(value);
                            break;
                        case 17:
                            tv = (TextView) findViewById(R.id.passivemetric17);
                            tv.setText(value);
                            break;
                        case 18:
                            tv = (TextView) findViewById(R.id.passivemetric18);
                            tv.setText(value);
                            break;
                        case 19:
                            tv = (TextView) findViewById(R.id.passivemetric19);
                            tv.setText(value);
                            break;
                        case 20:
                            tv = (TextView) findViewById(R.id.passivemetric20);
                            tv.setText(value);
                            break;
                        case 21:
                            tv = (TextView) findViewById(R.id.passivemetric21);
                            tv.setText(value);
                            break;
                        case 22:
                            tv = (TextView) findViewById(R.id.passivemetric22);
                            tv.setText(value);
                            break;
                        case 23:
                            tv = (TextView) findViewById(R.id.passivemetric23);
                            tv.setText(value);
                            break;
                        case 24:
                            tv = (TextView) findViewById(R.id.passivemetric24);
                            tv.setText(value);
                            break;
                        case 25:
                            tv = (TextView) findViewById(R.id.passivemetric25);
                            tv.setText(value);
                            break;
                        case 26:
                            tv = (TextView) findViewById(R.id.passivemetric26);
                            tv.setText(value);
                            break;
                        case 27:
                            tv = (TextView) findViewById(R.id.passivemetric27);
                            tv.setText(value);
                            break;
                        case 28:
                            tv = (TextView) findViewById(R.id.passivemetric28);
                            tv.setText(value);
                            break;
                        case 29:
                            tv = (TextView) findViewById(R.id.passivemetric29);
                            tv.setText(value);
                            break;
                        case 30:
                            tv = (TextView) findViewById(R.id.passivemetric30);
                            tv.setText(value);
                            break;
                        case 31:
                            tv = (TextView) findViewById(R.id.passivemetric31);
                            tv.setText(value);
                            break;
                        case 32:
                            tv = (TextView) findViewById(R.id.passivemetric32);
                            tv.setText(value);
                            break;
                        default:
                            //

                        }
                        if (!value.equals("") && tv != null) {

                            TableLayout tl1 = (TableLayout) findViewById(R.id.passive_metrics_status);
                            tl1.setVisibility(View.GONE);
                            TableLayout tl = (TableLayout) tv.getParent().getParent();
                            tl.setVisibility(View.VISIBLE);
                        }

                        if (value.equals("") && tv != null) {
                            TableLayout tl = (TableLayout) tv.getParent().getParent();
                            tl.setVisibility(View.GONE);
                        }

                    }

                } catch (JSONException e) {
                    Logger.e(this, e.getMessage());
                }
            }
        };

        launchTest(testID);
    } catch (Throwable t) {
        Logger.e(this, "handler or test failure", t);
    }
}

From source file:com.chess.genesis.engine.GameState.java

@Override
public boolean handleMessage(final Message msg) {
    try {/*from w  w w  .  j a v a2s. co m*/
        switch (msg.what) {
        case GenEngine.MSG:
        case RegEngine.MSG:
            final Bundle bundle = (Bundle) msg.obj;

            if (bundle.getLong("time") == 0) {
                cpu.setBoard(board);
                new Thread(cpu).start();
                return true;
            } else if (activity.isFinishing()) {
                // activity is gone, so give up!
                return true;
            }
            currentMove();

            final Move tmove = bundle.getParcelable("move");
            final Move move = board.newMove();
            if (board.validMove(tmove, move))
                applyMove(move, true, true);
            break;
        case CpuTimeDialog.MSG:
            final PrefEdit pref = new PrefEdit(activity);
            pref.putInt(R.array.pf_cputime, (Integer) msg.obj);
            pref.commit();
            cpu.setTime((Integer) msg.obj);
            break;
        case NetworkClient.GAME_DRAW:
        case NetworkClient.SUBMIT_MOVE:
            JSONObject json = (JSONObject) msg.obj;

            if (json.getString("result").equals("error")) {
                undoMove();
                progress.remove();
                Toast.makeText(activity, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show();
                return true;
            }
            progress.setText("Checking Game Status");

            net.game_status(settings.getString("gameid"));
            new Thread(net).start();
            break;
        case ResignConfirm.MSG:
            progress.setText("Sending Resignation");

            net.resign_game(settings.getString("gameid"));
            new Thread(net).start();
            break;
        case NudgeConfirm.MSG:
            progress.setText("Sending Nudge");

            net.nudge_game(settings.getString("gameid"));
            new Thread(net).start();
            break;
        case IdleResignConfirm.MSG:
            progress.setText("Sending Idle Resign");

            net.idle_resign(settings.getString("gameid"));
            new Thread(net).start();
            break;
        case DrawDialog.MSG:
        case AcceptDrawDialog.MSG:
            final String value = (String) msg.obj;
            progress.setText("Sending Draw");

            net.game_draw(settings.getString("gameid"), value);
            new Thread(net).start();
            break;
        case PawnPromoteDialog.MSG:
            applyMove((RegMove) msg.obj, true, true);
            break;
        case NetworkClient.RESIGN_GAME:
        case NetworkClient.IDLE_RESIGN:
            json = (JSONObject) msg.obj;

            if (json.getString("result").equals("error")) {
                progress.remove();
                Toast.makeText(activity, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show();
                return true;
            }
            progress.setText("Resignation Sent");

            net.game_status(settings.getString("gameid"));
            new Thread(net).start();
            break;
        case NetworkClient.NUDGE_GAME:
            json = (JSONObject) msg.obj;

            if (json.getString("result").equals("error"))
                Toast.makeText(activity, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show();
            progress.remove();
            break;
        case NetworkClient.GAME_STATUS:
            json = (JSONObject) msg.obj;

            if (json.getString("result").equals("error")) {
                progress.remove();
                Toast.makeText(activity, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show();
                return true;
            }
            final int status = Enums.GameStatus(json.getString("status"));

            settings.putString("status", String.valueOf(status));

            final GameDataDB db = new GameDataDB(activity);
            db.updateOnlineGame(json);
            db.close();
            GenesisNotifier.clearNotification(activity, GenesisNotifier.YOURTURN_NOTE);

            applyRemoteMove(json.getString("history"));
            if (status != Enums.ACTIVE) {
                if (Integer.parseInt(settings.getString("eventtype")) == Enums.INVITE) {
                    progress.remove();
                    ShowGameStats(json);
                    return true;
                }
                progress.setText("Retrieving Score");

                net.game_score(settings.getString("gameid"));
                new Thread(net).start();
            } else {
                progress.setText("Status Synced");
                progress.remove();
            }
            break;
        case NetworkClient.GAME_SCORE:
            json = (JSONObject) msg.obj;

            if (json.getString("result").equals("error")) {
                progress.remove();
                Toast.makeText(activity, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show();
                return true;
            }
            progress.setText("Score Loaded");
            progress.remove();

            ShowGameStats(json);
            break;
        case RematchConfirm.MSG:
            final Bundle data = (Bundle) msg.obj;
            progress.setText("Sending Newgame Request");

            final String opponent = data.getString("opp_name");
            final String color = Enums.ColorType(data.getInt("color"));
            final String gametype = Enums.GameType(data.getInt("gametype"));

            net.new_game(opponent, gametype, color);
            new Thread(net).start();
            break;
        case NetworkClient.NEW_GAME:
            json = (JSONObject) msg.obj;

            if (json.getString("result").equals("error")) {
                progress.remove();
                Toast.makeText(activity, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show();
                return true;
            }
            progress.setText(json.getString("reason"));
            progress.remove();
            break;
        }
        return true;
    } catch (final JSONException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}

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

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context ctx = getActivity();//from  w ww.ja  va 2s .  co m
    if (ctx == null)
        return null;

    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.dialog_edit_connection, null);
    init(v);

    if (savedInstanceState != null && savedInstanceState.containsKey("cid"))
        server = ServersDataSource.getInstance().getServer(savedInstanceState.getInt("cid"));

    final AlertDialog d = new AlertDialog.Builder(ctx)
            .setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
            .setTitle((server == null) ? "Add A Network" : "Edit Connection").setView(v)
            .setPositiveButton((server == null) ? "Add" : "Save", null)
            .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    NetworkConnection.getInstance().removeHandler(EditConnectionFragment.this);
                }
            }).create();
    d.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialogInterface) {
            Button b = d.getButton(AlertDialog.BUTTON_POSITIVE);
            b.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    NetworkConnection.getInstance().removeHandler(EditConnectionFragment.this);
                    NetworkConnection.getInstance().addHandler(EditConnectionFragment.this);
                    reqid = save();
                }
            });
        }
    });
    d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    return d;
}

From source file:com.hybris.mobile.lib.commerce.provider.CatalogProvider.java

@Override
public boolean onCreate() {
    authority = getContext().getString(R.string.sync_default_authority);
    String dbName = getContext().getString(R.string.sync_default_db_name);
    int dbVersion = getContext().getResources().getInteger(R.integer.sync_default_db_version);

    try {//from  w w w . j  ava 2s  . c  o m
        ComponentName componentName = new ComponentName(getContext(), this.getClass());

        // Authority name from the manifest file
        String tmpAuthority = getContext().getPackageManager().getProviderInfo(componentName,
                PackageManager.GET_META_DATA).authority;

        if (StringUtils.isNotBlank(tmpAuthority)) {
            authority = tmpAuthority;
        }

        // Database configuration from manifest file
        Bundle bundle = getContext().getPackageManager().getProviderInfo(componentName,
                PackageManager.GET_META_DATA).metaData;

        if (bundle != null) {
            String dbNameTmp = bundle.getString(getContext().getString(R.string.sync_db_name));
            int dbVersionTmp = bundle.getInt(getContext().getString(R.string.sync_db_version));

            if (StringUtils.isNotBlank(dbNameTmp)) {
                dbName = dbNameTmp;
            }

            if (dbVersion != 0) {
                dbVersion = dbVersionTmp;
            }
        }

        // Account name and type
        componentName = new ComponentName(getContext(), CatalogAuthenticatorService.class);
        bundle = getContext().getPackageManager().getServiceInfo(componentName,
                PackageManager.GET_META_DATA).metaData;

        String accountName = bundle.getString(getContext().getString(R.string.sync_account_name));
        String accountType = bundle.getString(getContext().getString(R.string.sync_account_type));

        if (StringUtils.isBlank(accountName) || StringUtils.isBlank(accountType)) {
            throw new IllegalArgumentException(
                    "You must provide the metadata " + getContext().getString(R.string.sync_account_name) + ", "
                            + getContext().getString(R.string.sync_account_type) + " for " + this.getClass());
        }

        account = new Account(accountType, accountName);

    } catch (PackageManager.NameNotFoundException e) {
        Log.e(TAG, "Package name not found. Details:" + e.getLocalizedMessage());
        throw new IllegalArgumentException(
                "Error getting the information from the metadata of " + this.getClass());
    }
    // Unit test case - the mock context does not have any package manager or provider info
    catch (UnsupportedOperationException e) {
        Log.e(TAG, "Unsupported operation:" + e.getLocalizedMessage());
    }

    mDatabaseHelper = new CatalogDatabaseHelper(getContext(), dbName, dbVersion);

    URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH);
    URI_MATCHER.addURI(authority, CatalogContract.Provider.SEGMENT_GROUP, CatalogContract.Provider.CODE_GROUP);
    URI_MATCHER.addURI(authority, CatalogContract.Provider.SEGMENT_GROUP + "/*",
            CatalogContract.Provider.CODE_GROUP_ID);
    URI_MATCHER.addURI(authority, CatalogContract.Provider.SEGMENT_DATA, CatalogContract.Provider.CODE_DATA);
    URI_MATCHER.addURI(authority, CatalogContract.Provider.SEGMENT_DATA + "/*",
            CatalogContract.Provider.CODE_DATA_ID);
    URI_MATCHER.addURI(authority, CatalogContract.Provider.SEGMENT_DATA_DETAILS,
            CatalogContract.Provider.CODE_DATA_DETAILS);
    URI_MATCHER.addURI(authority, CatalogContract.Provider.SEGMENT_DATA_DETAILS + "/*",
            CatalogContract.Provider.CODE_DATA_DETAILS_ID);
    URI_MATCHER.addURI(authority, CatalogContract.Provider.SEGMENT_SYNC_GROUP + "/*",
            CatalogContract.Provider.CODE_SYNC_GROUP);

    return true;
}

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

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK && data != null) {
        Bundle extras = data.getExtras();
        int SC;/*  w  ww.  java 2s. c  o m*/

        switch (requestCode) {
        case ACT_COMMENT:
            String comment = extras.getString(AR_COMMENT);
            int datepos = extras.getInt(AR_DTID);
            getAvailForPerson(curpid, adates.get(datepos).getId());
            updateAvailCommentForPerson(curpid, adates.get(datepos).getId(), comment);
            voteadateadapter.notifyDataSetChanged();
            break;
        case ACT_ADDINVITEE:
            String participant = extras.getString(AR_EMAIL);
            SC = PleftBroker.inviteAnotherParticipant(aid, participant, apserver, auser, avcode);
            if (SC >= HttpStatus.SC_BAD_REQUEST) { //400
                Toast.makeText(this, R.string.toast_problemrequest, Toast.LENGTH_LONG).show();
            } else {
                startActivity(getIntent());
                finish();
            }
            break;
        case ACT_NEWDATE:
            int[] thedate = extras.getIntArray(AR_DATE);
            int[] thetime = extras.getIntArray(AR_TIME);
            PDate td = new PDate(thedate, thetime);
            String newdate = td.getPleftDate();
            //TODO Check if this date and time is the same of one of the current dates!!!
            SC = PleftBroker.proposeNewDate(aid, newdate, apserver, auser, avcode);
            if (SC >= HttpStatus.SC_BAD_REQUEST) { //400
                Toast.makeText(this, R.string.toast_problemrequest, Toast.LENGTH_LONG).show();
            } else {
                startActivity(getIntent());
                finish();
            }
            break;
        }
    }
}

From source file:com.cettco.buycar.activity.BargainActivity.java

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (data == null)
        return;/*from w ww .  ja v a 2s.c om*/
    //System.out.println("resultcode :" + resultCode + " requestcode:"
    //+ requestCode);
    Bundle b = data.getExtras();
    switch (resultCode) { // resultCodeBRESULT_OK
    case RESULT_OK:
        // dataBIntent
        // int position = b.getInt("result");
        if (requestCode == RESULT_COLOR) {
            colors = b.getStringArrayList("colors");
        } else if (requestCode == RESULT_TIME) {
            getcarTimeSelection = b.getInt("result");
        } else if (requestCode == RESULT_LOAN) {
            loanSelection = b.getInt("result");
        } else if (requestCode == RESULT_LOCATION) {
            locationSelection = b.getInt("result");
        } else if (requestCode == RESULT_PLATE) {
            plateSelection = b.getInt("result");
        } else if (requestCode == RESULT_SHOP) {
            dealers = b.getStringArrayList("dealers");
            //System.out.println("dealer size:" + dealers.size());
        }
        break;
    default:
        break;
    }
}

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 av  a2 s . c  om

    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();
        }
    }
}