Example usage for android.os Bundle getString

List of usage examples for android.os Bundle getString

Introduction

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

Prototype

@Nullable
public String getString(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:net.idlesoft.android.apps.github.activities.CommitChangeViewer.java

@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.commit_view);

    mPrefs = getSharedPreferences(Hubroid.PREFS_NAME, 0);
    mEditor = mPrefs.edit();//from  w  ww.ja v a  2  s.  c o  m

    mUsername = mPrefs.getString("username", "");
    mPassword = mPrefs.getString("password", "");

    mGapi.authenticate(mUsername, mPassword);

    ((ImageButton) findViewById(R.id.btn_search)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            startActivity(new Intent(CommitChangeViewer.this, Search.class));
        }
    });

    final TextView title = (TextView) findViewById(R.id.tv_page_title);
    title.setText("Commit Diff");

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
        mRepositoryName = extras.getString("repo_name");
        mRepositoryOwner = extras.getString("repo_owner");
        try {
            mJson = new JSONObject(extras.getString("json"));

            /*
             * This new method of displaying file diffs was inspired by
             * iOctocat's approach. Thanks to Dennis Bloete (dbloete on
             * GitHub) for creating iOctocat and making me realize Android
             * needed some GitHub love too. ;-)
             */
            final WebView webView = (WebView) findViewById(R.id.wv_commitView_diff);

            /*
             * Prepare CSS for diff: Added lines are green, removed lines
             * are red, and the special lines that specify how many lines
             * were affected in the chunk are a light blue.
             */
            String content = "<style type=\"text/css\">" + "div {" + "margin-right: 100%25;"
                    + "font-family: monospace;" + "white-space: nowrap;" + "display: inline-block;" + "}"
                    + ".lines {" + "background-color: #EAF2F5;" + "}" + ".added {"
                    + "background-color: #DDFFDD;" + "}" + ".removed {" + "background-color: #FFDDDD;" + "}"
                    + "</style>";

            final String[] splitDiff = mJson.getString("diff").split("\n");
            for (int i = 0; i < splitDiff.length; i++) {
                // HTML encode any elements, else any diff containing
                // "<div>" or any HTML element will be interpreted as one by
                // the browser
                splitDiff[i] = TextUtils.htmlEncode(splitDiff[i]);

                // Replace all tabs with four non-breaking spaces (most
                // browsers truncate "\t+" to " ").
                splitDiff[i] = splitDiff[i].replaceAll("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");

                // Replace any sequence of two or more spaces with &nbsps
                // (most browsers truncate " +" to " ").
                splitDiff[i] = splitDiff[i].replaceAll("(?<= ) ", "&nbsp;");

                if (splitDiff[i].startsWith("@@")) {
                    splitDiff[i] = "<div class=\"lines\">".concat(splitDiff[i].concat("</div>"));
                } else if (splitDiff[i].startsWith("+")) {
                    splitDiff[i] = "<div class=\"added\">".concat(splitDiff[i].concat("</div>"));
                } else if (splitDiff[i].startsWith("-")) {
                    splitDiff[i] = "<div class=\"removed\">".concat(splitDiff[i].concat("</div>"));
                } else {
                    // Add an extra space before lines not beginning with
                    // "+" or "-" to make them line up properly
                    if (splitDiff[i].length() > 0) {
                        splitDiff[i] = "<div>&nbsp;".concat(splitDiff[i].substring(1).concat("</div>"));
                    }
                }
                content += splitDiff[i];
            }
            webView.loadData(content, "text/html", "UTF-8");

        } catch (final JSONException e) {
            e.printStackTrace();
        }
    }
}

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

public ZenossEvent(Bundle extras) {
    if (null != extras.getString("count"))
        this.Count = Integer.getInteger(extras.getString("count"));

    this.evid = extras.getString("evid");
    this.device = extras.getString("device");
    this.summary = extras.getString("summary");
    this.severity = extras.getString("severity");
    this.eventClass = extras.getString("event_class");
    //String event_class_key = intent.getExtras().getString("event_class_key");
    //String sent = intent.getExtras().getString("sent");
}

From source file:net.reichholf.dreamdroid.loader.AsyncByteLoader.java

@SuppressWarnings("unchecked")
private void init(Context context, Bundle args) {
    DreamDroid.loadCurrentProfile(context);
    mShc = new SimpleHttpClient();
    if (args != null && args.containsKey("params"))
        mParams = (ArrayList<NameValuePair>) args.getSerializable("params");
    else//w w w .java 2 s .  c  o m
        mParams = null;

    mUri = args.getString("uri");
}

From source file:com.mikecorrigan.bohrium.pubsub.PubSubClient.java

@Override
public boolean register(final Bundle bundle) {
    Log.v(TAG, "register: bundle=" + Utils.bundleToString(bundle));

    // Create JSON request body.
    JSONObject j = new JSONObject();
    try {//from w ww. ja  v a2 s  . c o m
        j.put("name", bundle.getString(RegistrationClient.APP_NAME));
        j.put("resource", bundle.getString(RegistrationClient.RESOURCE));
        j.put("type", GCM_DEVICE_TYPE);
        j.put("reg_id", bundle.getString(RegistrationClient.REG_ID));
        j.put("dev_id", mDevId);
    } catch (JSONException e) {
        Log.w(TAG, "Registration failure: URI failed=" + e);
        return false;
    }

    ITransaction transaction = mTransactionService.createTransaction("PUT", "device/" + mDevId + "/", j);
    transaction.run();
    if (transaction.getStatusCode() == 200) {
        // Save user ID.
        try {
            JSONObject responseBody = (JSONObject) transaction.getResponseBody();
            mDevice = JSONCodec.fromJson(responseBody);

            mUser = new Bundle();
            mUser.putString("user_id", responseBody.getString("user_id"));

        } catch (JSONException e) {
            Log.e(TAG, "Exception " + e);
            Log.e(TAG, Log.getStackTraceString(e));
        }
    }

    Log.e(TAG, "onRegisterComplete: statusCode=" + transaction.getStatusCode());
    return transaction.getStatusCode() == 200;
}

From source file:fr.cph.chicago.core.activity.BusBoundActivity.java

@Override
public void onRestoreInstanceState(final Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    busRouteId = savedInstanceState.getString(bundleBusRouteId);
    busRouteName = savedInstanceState.getString(bundleBusRouteName);
    bound = savedInstanceState.getString(bundleBusBound);
    boundTitle = savedInstanceState.getString(bundleBusBoundTitle);
}

From source file:com.QuarkLabs.BTCeClient.fragments.OrdersBookFragment.java

@Override
public Loader<JSONObject> onCreateLoader(int id, Bundle args) {
    mAsksList.setAdapter(null);/*  www.j  a va2s. com*/
    mBidsList.setAdapter(null);
    return new OrderBookLoader(getActivity(), args.getString("pair"));
}

From source file:eu.thecoder4.gpl.pleftdroid.EditEventActivity.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();

        switch (requestCode) {
        case ACT_INVITEE:
            String email = extras.getString(DN_EMAIL);
            String dname = extras.getString(DN_NAME);
            if (isUseDispNameSet()) {
                email = dname + " <" + email + ">";
            }//  ww  w. j a  v a  2 s.com
            mEmails.add(email);
            ((EditText) findViewById(R.id.einvitees)).setText(getInvitees());
            break;
        case ACT_ADDDATE:
            mDates = data.getParcelableArrayListExtra(PickDateDialogActivity.DTLIST);
            ((EditText) findViewById(R.id.edatetimes)).setText(getDates());
            break;

        }
    }

}

From source file:net.idlesoft.android.apps.github.activities.FileViewer.java

@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.file_view);//from  w w w .  j  ava  2  s . c  o  m

    mPrefs = getSharedPreferences(Hubroid.PREFS_NAME, 0);
    mEditor = mPrefs.edit();

    mUsername = mPrefs.getString("username", "");
    mPassword = mPrefs.getString("password", "");

    mGapi.authenticate(mUsername, mPassword);

    ((ImageButton) findViewById(R.id.btn_search)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            startActivity(new Intent(FileViewer.this, Search.class));
        }
    });

    final TextView title = (TextView) findViewById(R.id.tv_page_title);
    title.setText("File Viewer");

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
        mRepositoryName = extras.getString("repo_name");
        mRepositoryOwner = extras.getString("repo_owner");
        mTreeSha = extras.getString("tree_sha");
        mBlobPath = extras.getString("blob_path");

        mLoadBlobTask = (LoadBlobTask) getLastNonConfigurationInstance();
        if (mLoadBlobTask == null) {
            mLoadBlobTask = new LoadBlobTask();
        }
        mLoadBlobTask.activity = FileViewer.this;
        if (mLoadBlobTask.getStatus() == AsyncTask.Status.RUNNING) {
            mProgressDialog.show();
        } else if (mLoadBlobTask.getStatus() == AsyncTask.Status.PENDING) {
            mLoadBlobTask.execute();
        }
    }
}

From source file:gov.wa.wsdot.android.wsdot.ui.FerriesRouteSchedulesDaySailingsFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    Bundle args = activity.getIntent().getExtras();
    mDates = args.getString("date");
}

From source file:net.idlesoft.android.apps.github.activities.Profile.java

@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.profile);//from  www .jav a  2  s  .c  o m

    mPrefs = getSharedPreferences(Hubroid.PREFS_NAME, 0);

    mUsername = mPrefs.getString("username", "");
    mPassword = mPrefs.getString("password", "");

    mGapi = new GitHubAPI();
    mGapi.authenticate(mUsername, mPassword);

    ((ImageButton) findViewById(R.id.btn_search)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            startActivity(new Intent(Profile.this, Search.class));
        }
    });

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
        mTarget = extras.getString("username");
    }
    try {
        if ((mTarget == null) || mTarget.equals("")) {
            mTarget = mUsername;
        }
        Response userInfoResp;
        userInfoResp = mGapi.user.info(mTarget);
        if (userInfoResp.statusCode == 200) {
            mJson = new JSONObject(userInfoResp.resp);
        }
        if (mJson == null) {
            // User doesn't really exist, return to the previous activity
            this.setResult(5005);
            finish();
        } else {
            mJson = mJson.getJSONObject("user");

            final JSONArray following_list = new JSONObject(mGapi.user.following(mUsername).resp)
                    .getJSONArray("users");
            final int length = following_list.length() - 1;
            for (int i = 0; i <= length; i++) {
                if (following_list.getString(i).equalsIgnoreCase(mTarget)) {
                }
            }

            String company, location, full_name, email, blog;

            // Replace empty values with "N/A"
            if (mJson.has("company") && !mJson.getString("company").equals("null")
                    && !mJson.getString("company").equals("")) {
                company = mJson.getString("company");
            } else {
                company = "N/A";
            }
            if (mJson.has("location") && !mJson.getString("location").equals("null")
                    && !mJson.getString("location").equals("")) {
                location = mJson.getString("location");
            } else {
                location = "N/A";
            }
            if (mJson.has("name") && !mJson.getString("name").equals("null")) {
                full_name = mJson.getString("name");
            } else {
                full_name = mTarget;
            }
            if (mJson.has("email") && !mJson.getString("email").equals("null")
                    && !mJson.getString("email").equals("")) {
                email = mJson.getString("email");
            } else {
                email = "N/A";
            }
            if (mJson.has("blog") && !mJson.getString("blog").equals("null")
                    && !mJson.getString("blog").equals("")) {
                blog = mJson.getString("blog");
            } else {
                blog = "N/A";
            }

            // Set all the values in the layout
            // ((TextView)findViewById(R.id.tv_top_bar_title)).setText(m_targetUser);
            ((ImageView) findViewById(R.id.iv_user_info_gravatar)).setImageBitmap(GravatarCache.getDipGravatar(
                    GravatarCache.getGravatarID(mTarget), 50.0f, getResources().getDisplayMetrics().density));
            ((TextView) findViewById(R.id.tv_user_info_full_name)).setText(full_name);
            ((TextView) findViewById(R.id.tv_user_info_company)).setText(company);
            ((TextView) findViewById(R.id.tv_user_info_email)).setText(email);
            ((TextView) findViewById(R.id.tv_user_info_location)).setText(location);
            ((TextView) findViewById(R.id.tv_user_info_blog)).setText(blog);

            // Make the buttons work
            final Button activityBtn = (Button) findViewById(R.id.btn_user_info_public_activity);
            final Button repositoriesBtn = (Button) findViewById(R.id.btn_user_info_repositories);
            final Button followersFollowingBtn = (Button) findViewById(R.id.btn_user_info_followers_following);

            activityBtn.setOnClickListener(onButtonClick);
            repositoriesBtn.setOnClickListener(onButtonClick);
            followersFollowingBtn.setOnClickListener(onButtonClick);
        }
    } catch (final JSONException e) {
        e.printStackTrace();
    }
}