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.moonpi.swiftnotes.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        Bundle mBundle = data.getExtras();

        if (mBundle != null) {
            // If new note was saved
            if (requestCode == NEW_NOTE_REQUEST) {
                try {
                    // Add new note to array
                    JSONObject newNote = new JSONObject();
                    newNote.put("title", mBundle.getString("title"));
                    newNote.put("body", mBundle.getString("body"));
                    newNote.put("colour", mBundle.getString("colour"));
                    newNote.put("favoured", false);
                    newNote.put("fontSize", mBundle.getInt("fontSize"));

                    notes.put(newNote);//from  w  ww  .j  av  a  2 s . c o m
                    adapter.notifyDataSetChanged();

                    writeToJSON();

                    // If no notes, show 'Press + to add new note' text, invisible otherwise
                    if (notes.length() == 0)
                        noNotes.setVisibility(View.VISIBLE);
                    else
                        noNotes.setVisibility(View.INVISIBLE);

                    Toast toast = Toast.makeText(getApplicationContext(),
                            getResources().getString(R.string.toast_new_note), Toast.LENGTH_SHORT);
                    toast.show();

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

            // If existing note was saved
            else {
                try {
                    // Update array with new data
                    JSONObject newNote = notes.getJSONObject(requestCode);
                    newNote.put("title", mBundle.getString("title"));
                    newNote.put("body", mBundle.getString("body"));
                    newNote.put("colour", mBundle.getString("colour"));
                    newNote.put("fontSize", mBundle.getInt("fontSize"));

                    // Update note at position
                    notes.put(requestCode, newNote);
                    adapter.notifyDataSetChanged();

                    writeToJSON();

                    Toast toast = Toast.makeText(getApplicationContext(),
                            getResources().getString(R.string.toast_note_saved), Toast.LENGTH_SHORT);
                    toast.show();

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

    else if (resultCode == RESULT_CANCELED) {
        Bundle mBundle = null;

        if (data != null && data.hasExtra("request"))
            mBundle = data.getExtras();

        if (requestCode == NEW_NOTE_REQUEST) {
            if (mBundle != null) {
                // If new note discarded, show toast
                if (mBundle.getString("request").equals("discard")) {
                    Toast toast = Toast.makeText(getApplicationContext(),
                            getResources().getString(R.string.toast_empty_note_discarded), Toast.LENGTH_SHORT);
                    toast.show();
                }
            }
        }

        else {
            if (mBundle != null) {
                // If delete pressed in EditActivity, call deleteNote method with
                // requestCode as position
                if (mBundle.getString("request").equals("delete"))
                    deleteNote(this, requestCode);
            }
        }
    }

    super.onActivityResult(requestCode, resultCode, data);
}

From source file:fr.bde_eseo.eseomega.lydia.LydiaActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    // Set view / call parent
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lydia);
    context = this;

    // Init intent flag
    INTENT_REQUEST intent_request = INTENT_REQUEST.ERROR;

    // Get intent parameters
    if (savedInstanceState == null) {
        Intent intent = getIntent();// w w  w  .  j  a  v a  2  s  .  c o m
        Bundle extras = intent.getExtras();
        String action = intent.getAction();

        if (action != null) {

            // Check if intent's action is correct (obviously yes, but prevents Manifest modifications)
            if (action.equals(Intent.ACTION_VIEW)) {

                // Intent depuis Lydia
                intent_request = INTENT_REQUEST.FROM_LYDIA;

                // Get all parameters
                Uri qUri = intent.getData();

                // Order ID
                String sOrderID = qUri.getQueryParameter("id");

                if (sOrderID != null) {
                    orderID = Integer.parseInt(sOrderID);
                }

                orderType = qUri.getQueryParameter("cat");
            }

        } else if (extras != null) {

            // Intent interne
            intent_request = INTENT_REQUEST.FROM_APP;
            orderID = extras.getInt(Constants.KEY_LYDIA_ORDER_ID);
            orderType = extras.getString(Constants.KEY_LYDIA_ORDER_TYPE);

            // Demande de check ?  donc ask dj effectu
            if (extras.getBoolean(Constants.KEY_LYDIA_ORDER_ASKED)) {
                intent_request = INTENT_REQUEST.FROM_LYDIA;
            }
        }
    }

    // No intent received
    if (intent_request == INTENT_REQUEST.ERROR || orderID == -1) {
        Toast.makeText(context, "Erreur de l'application (c'est pas normal)", Toast.LENGTH_SHORT).show();
        close();
    }

    // Get objects
    userProfile = new UserProfile();
    userProfile.readProfilePromPrefs(context);
    prefsUser = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    // Init dialog
    dialogInit();

    // Get intent type
    if (intent_request == INTENT_REQUEST.FROM_APP) {

        /**
         * FROM_APP : On doit demander le numro de tlphone du client, puis lorsqu'il clique sur "Payer", effectuer une demande de paiement auprs de Lydia.
         * Il faut ensuite lancer l'Intent vers Lydia avec le bon numro de requte.
         *
         * A afficher :
         * - InputText tlphone
         * - Checkbox mmorisation numro
         * - Texte "lgal" sur le numro de tlphone
         * - Boutons Annuler / Valider  AsyncTask ask.php
         */
        dialogFromApp();

    } else {

        /**
         * FROM_LYDIA : L'activit vient d'tre ouverte aprs que le client ait cliqu sur "Accepter" depuis l'app Lydia.
         * Dans 100% des cas, le retour  notre activit se fait si il a eu un paiement valid.
         * Cependant, on vrifiera le statut de la commande auprs de notre serveur malgr tout.
         *
         * A afficher :
         * - Texte "tat de votre commande"  titre dialogue
         * - Texte status : actualis toutes les 3 secondes  asyncTask
         * - Bouton Fermer si status diffrent de "en cours"
         */
        dialogFromLydia();
    }
}

From source file:com.ryan.ryanreader.activities.PostSubmitActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    PrefsUtility.applyTheme(this);

    super.onCreate(savedInstanceState);

    final LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.post_submit);

    typeSpinner = (Spinner) layout.findViewById(R.id.post_submit_type);
    usernameSpinner = (Spinner) layout.findViewById(R.id.post_submit_username);
    subredditEdit = (EditText) layout.findViewById(R.id.post_submit_subreddit);
    titleEdit = (EditText) layout.findViewById(R.id.post_submit_title);
    textEdit = (EditText) layout.findViewById(R.id.post_submit_body);

    if (getIntent() != null && getIntent().hasExtra("subreddit")) {
        final String subreddit = getIntent().getStringExtra("subreddit");
        if (subreddit != null && subreddit.length() > 0 && !subreddit.equals("all")
                && subreddit.matches("\\w+")) {
            subredditEdit.setText(subreddit);
        }//  ww w.  ja  v  a 2  s  .c o m

    } else if (savedInstanceState != null && savedInstanceState.containsKey("post_title")) {
        titleEdit.setText(savedInstanceState.getString("post_title"));
        textEdit.setText(savedInstanceState.getString("post_body"));
        subredditEdit.setText(savedInstanceState.getString("subreddit"));
        typeSpinner.setSelection(savedInstanceState.getInt("post_type"));
    }

    final ArrayList<RedditAccount> accounts = RedditAccountManager.getInstance(this).getAccounts();
    final ArrayList<String> usernames = new ArrayList<String>();

    for (RedditAccount account : accounts) {
        if (!account.isAnonymous()) {
            usernames.add(account.username);
        }
    }

    if (usernames.size() == 0) {
        General.quickToast(this, R.string.error_toast_notloggedin);
        finish();
    }

    usernameSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, usernames));
    typeSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, postTypes));

    // TODO remove the duplicate code here
    if (typeSpinner.getSelectedItem().equals("Link")) {
        textEdit.setHint("URL"); // TODO string
        textEdit.setInputType(android.text.InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
        textEdit.setSingleLine(true);
    } else {
        textEdit.setHint("Self Text"); // TODO string
        textEdit.setInputType(android.text.InputType.TYPE_CLASS_TEXT
                | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
        textEdit.setSingleLine(false);
    }

    typeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (typeSpinner.getSelectedItem().equals("Link")) {
                textEdit.setHint("URL"); // TODO string
                textEdit.setInputType(
                        android.text.InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
                textEdit.setSingleLine(true);
            } else {
                textEdit.setHint("Self Text"); // TODO string
                textEdit.setInputType(android.text.InputType.TYPE_CLASS_TEXT
                        | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
                textEdit.setSingleLine(false);
            }
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    final ScrollView sv = new ScrollView(this);
    sv.addView(layout);
    setContentView(sv);
}

From source file:org.ednovo.goorusearchwidget.ResourcePlayer.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog = new ProgressDialog(this);
    prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    setContentViewLayout = new RelativeLayout(ResourcePlayer.this);
    prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE);

    token = prefsPrivate.getString("token", "");

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    Bundle extra = getIntent().getExtras();

    if (extra != null) {
        value = extra.getInt("key");
        gooruOID1 = extra.getStringArrayList("goor");

        searchkeyword = extra.getString("searchkey");
        limit = gooruOID1.size();//from www .  j a  v  a2s  .co  m
        gooruOID = gooruOID1.get(value);
        resourceGooruId = gooruOID;

        if (!gooruOID.isEmpty() || !gooruOID.equalsIgnoreCase("") || gooruOID != null) {
            if (checkInternetConnection()) {
                dialog = new ProgressDialog(ResourcePlayer.this);
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getResourcesInfo().execute();
            } else {

                dialog = new ProgressDialog(ResourcePlayer.this);
                dialog.setTitle("gooru");
                dialog.setMessage("No internet connection");
                dialog.show();
            }

        }
    }
    Editor prefsPrivateEditor = prefsPrivate.edit();

    // Authentication details
    prefsPrivateEditor.putString("searchkeyword", searchkeyword);
    prefsPrivateEditor.commit();

    wvPlayer = new WebView(ResourcePlayer.this);
    wvPlayer.resumeTimers();
    wvPlayer.getSettings().setJavaScriptEnabled(true);
    wvPlayer.getSettings().setPluginState(PluginState.ON);
    wvPlayer.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    wvPlayer.setWebViewClient(new HelloWebViewClient());

    wvPlayer.setWebChromeClient(new MyWebChromeClient() {
    });
    wvPlayer.getSettings().setPluginsEnabled(true);
    new getResourcesInfo().execute();

    RelativeLayout temp = new RelativeLayout(ResourcePlayer.this);
    temp.setId(668);
    temp.setBackgroundColor(getResources().getColor(android.R.color.transparent));

    header = new RelativeLayout(ResourcePlayer.this);
    header.setId(1);

    header.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar));
    RelativeLayout.LayoutParams headerParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, 53);
    headerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1);
    headerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, -1);

    ivCloseIcon = new ImageView(ResourcePlayer.this);
    ivCloseIcon.setId(130);
    ivCloseIcon.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams ivCloseIconIconParams = new RelativeLayout.LayoutParams(50, 50);
    ivCloseIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    ivCloseIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1);
    ivCloseIcon.setPadding(0, 0, 0, 0);

    ivCloseIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            finish();

        }
    });

    ivCloseIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.close_corner));
    header.addView(ivCloseIcon, ivCloseIconIconParams);

    ivmoveforward = new ImageView(ResourcePlayer.this);
    ivmoveforward.setId(222);
    if (value == limit - 1) {
        ivmoveforward.setVisibility(View.GONE);
    }
    ivmoveforward.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams ivmoveforwardIconIconParams = new RelativeLayout.LayoutParams(21, 38);

    ivmoveforwardIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1);
    ivmoveforwardIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    ivmoveforwardIconIconParams.setMargins(0, 0, 30, 0);

    imageshare = new ImageView(ResourcePlayer.this);
    imageshare.setId(440);
    imageshare.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams imageshareIconParams = new RelativeLayout.LayoutParams(50, 50);
    imageshareIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1);
    imageshareIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    imageshareIconParams.setMargins(0, 10, 100, 0);
    tvDescriptionn = new TextView(ResourcePlayer.this);
    tvDescriptionn1 = new TextView(ResourcePlayer.this);
    edittext_copyurl = new EditText(ResourcePlayer.this);
    imageshare.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            if (desc == 0) {
                new getShortUrl().execute();

                imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_selected));

                subheader.setVisibility(View.VISIBLE);
                subheader.removeAllViews();

                tvDescriptionn.setVisibility(View.VISIBLE);
                tvDescriptionn1.setVisibility(View.VISIBLE);
                edittext_copyurl.setVisibility(View.VISIBLE);
                tvDescriptionn.setText("Share this with other by copying and pasting these links");
                tvDescriptionn.setId(221);

                tvDescriptionn.setTextSize(18);
                tvDescriptionn.setTypeface(null, Typeface.BOLD);
                tvDescriptionn.setTextColor(getResources().getColor(android.R.color.white));
                RelativeLayout.LayoutParams tvDescriptionParams = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
                tvDescriptionParams.setMargins(20, 10, 0, 20);
                subheader.addView(tvDescriptionn, tvDescriptionParams);

                tvDescriptionn1.setText("Collections");
                tvDescriptionn1.setId(226);

                tvDescriptionn1.setTextSize(18);
                tvDescriptionn1.setTypeface(null, Typeface.BOLD);
                tvDescriptionn1.setTextColor(getResources().getColor(android.R.color.white));
                RelativeLayout.LayoutParams tvDescriptionParams1 = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
                tvDescriptionParams1.setMargins(20, 42, 0, 20);
                subheader.addView(tvDescriptionn1, tvDescriptionParams1);

                edittext_copyurl.setId(266);

                edittext_copyurl.setTextSize(18);
                edittext_copyurl.setTypeface(null, Typeface.BOLD);
                edittext_copyurl.setTextColor(getResources().getColor(android.R.color.white));
                RelativeLayout.LayoutParams tvDescriptionParams11 = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
                tvDescriptionParams11.setMargins(130, 35, 0, 20);
                subheader.addView(edittext_copyurl, tvDescriptionParams11);
                desc = 1;
                flag = 0;

            } else {

                imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_normal));
                subheader.removeAllViews();
                subheader.setVisibility(View.GONE);
                desc = 0;
            }
        }
    });

    imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_normal));

    ivmoveforward.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (value < limit - 1) {
                Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class);
                Bundle extras = new Bundle();
                // extras.putString("gooruOId",s);
                extras.putStringArrayList("goor", gooruOID1);
                value++;
                extras.putInt("key", value);
                intentResPlayer.putExtras(extras);
                urlcheck = 0;
                finish();
                startActivity(intentResPlayer);
            }

        }
    });

    ivmoveforward.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrowright));

    ivmoveback = new ImageView(ResourcePlayer.this);
    ivmoveback.setId(220);
    if (value == 0) {
        ivmoveback.setVisibility(View.GONE);
    }
    ivmoveback.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams ivmovebackIconIconParams = new RelativeLayout.LayoutParams(21, 38);
    ivmovebackIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1);
    ivmovebackIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    ivmovebackIconIconParams.setMargins(55, 0, 0, 0);

    ivmoveback.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            if (!(value <= 0)) {
                value--;
                Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class);
                Bundle extras = new Bundle();
                extras.putStringArrayList("goor", gooruOID1);

                extras.putInt("key", value);
                intentResPlayer.putExtras(extras);
                urlcheck = 0;
                finish();
                startActivity(intentResPlayer);
            }

        }
    });

    ivmoveback.setBackgroundDrawable(getResources().getDrawable(R.drawable.left));

    webViewBack = new ImageView(ResourcePlayer.this);
    webViewBack.setId(323);
    webViewBack.setScaleType(ImageView.ScaleType.FIT_XY);

    RelativeLayout.LayoutParams webViewBackIconParams = new RelativeLayout.LayoutParams(25, 26);

    webViewBackIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1);
    webViewBackIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    webViewBackIconParams.setMargins(175, 0, 0, 0);

    webViewBack.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrow_leftactive));
    webViewBack.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (wvPlayer.canGoBack()) {

                wvPlayer.goBack();

            }

        }
    });

    webViewRefresh = new ImageView(ResourcePlayer.this);
    webViewRefresh.setId(322);
    webViewRefresh.setScaleType(ImageView.ScaleType.FIT_XY);

    RelativeLayout.LayoutParams webViewRefreshIconParams = new RelativeLayout.LayoutParams(30, 30);

    webViewRefreshIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1);
    webViewRefreshIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    webViewRefreshIconParams.setMargins(305, 0, 0, 0);

    webViewRefresh.setBackgroundDrawable(getResources().getDrawable(R.drawable.refresh));
    webViewRefresh.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            wvPlayer.reload();
        }
    });

    webViewForward = new ImageView(ResourcePlayer.this);
    webViewForward.setId(321);
    webViewForward.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams webViewForwardIconParams = new RelativeLayout.LayoutParams(25, 26);

    webViewForwardIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1);
    webViewForwardIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    webViewForwardIconParams.setMargins(245, 0, 0, 0);
    webViewForward.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrow_rightactive));
    webViewForward.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (wvPlayer.canGoForward()) {

                wvPlayer.goForward();

            }
        }
    });

    ivResourceIcon = new ImageView(ResourcePlayer.this);
    ivResourceIcon.setId(30);
    ivResourceIcon.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams ivResourceIconParams = new RelativeLayout.LayoutParams(50, 25);
    ivResourceIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    ivResourceIconParams.addRule(RelativeLayout.LEFT_OF, 130);
    ivResourceIcon.setPadding(50, 0, 0, 0);

    ivResourceIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.handouts));
    header.addView(ivResourceIcon, ivResourceIconParams);

    tvLearn = new TextView(this);
    tvLearn.setText("Learn More");
    tvLearn.setId(20);
    tvLearn.setPadding(100, 0, 0, 0);
    tvLearn.setTextSize(20);
    tvLearn.setTextColor(getResources().getColor(android.R.color.white));
    RelativeLayout.LayoutParams tvLearnParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    tvLearnParams.addRule(RelativeLayout.CENTER_VERTICAL, 1);
    tvLearnParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1);
    tvAbout = new ImageView(ResourcePlayer.this);
    tvAbout.setId(21);
    tvAbout.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams webViewForwardIconParamsa = new RelativeLayout.LayoutParams(32, 32);

    webViewForwardIconParamsa.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1);

    webViewForwardIconParamsa.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    webViewForwardIconParamsa.setMargins(0, 0, 200, 0);

    tvAbout.setBackgroundDrawable(getResources().getDrawable(R.drawable.info));

    header.addView(tvAbout, webViewForwardIconParamsa);

    RelativeLayout fortvtitle = new RelativeLayout(this);
    RelativeLayout.LayoutParams tvTitleParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    tvTitleParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1);
    tvTitleParams.addRule(RelativeLayout.CENTER_VERTICAL, 1);
    tvTitleParams.addRule(RelativeLayout.RIGHT_OF, 322);
    tvTitleParams.addRule(RelativeLayout.LEFT_OF, 21);
    header.addView(fortvtitle, tvTitleParams);

    tvTitle = new TextView(this);
    tvTitle.setText("");
    tvTitle.setId(22);
    tvTitle.setPadding(0, 0, 0, 0);
    tvTitle.setTextSize(25);
    tvTitle.setSingleLine(true);
    tvTitle.setTextColor(getResources().getColor(android.R.color.white));
    RelativeLayout.LayoutParams tvTitleParamstv = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    tvTitleParamstv.addRule(RelativeLayout.CENTER_HORIZONTAL, 1);
    tvTitleParamstv.addRule(RelativeLayout.CENTER_VERTICAL, 1);

    fortvtitle.addView(tvTitle, tvTitleParamstv);

    tvViewsNLikes = new TextView(this);
    tvViewsNLikes.setText("");
    tvViewsNLikes.setId(23);
    tvViewsNLikes.setPadding(0, 0, 5, 5);
    tvViewsNLikes.setTextSize(18);
    tvViewsNLikes.setTextColor(getResources().getColor(android.R.color.white));
    RelativeLayout.LayoutParams tvViewsNLikesParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    tvViewsNLikesParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1);
    tvViewsNLikesParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1);

    subheader = new RelativeLayout(ResourcePlayer.this);
    subheader.setId(100);
    subheader.setVisibility(View.GONE);
    subheader.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar));

    RelativeLayout.LayoutParams subheaderParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, 100);
    subheaderParams.addRule(RelativeLayout.BELOW, 1);
    subheaderParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1);

    RelativeLayout.LayoutParams wvPlayerParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
    wvPlayerParams.addRule(RelativeLayout.BELOW, 100);
    wvPlayerParams.addRule(RelativeLayout.CENTER_IN_PARENT, 100);

    LinearLayout videoLayout = new LinearLayout(this);
    videoLayout.setVisibility(View.GONE);

    header.addView(webViewBack, webViewBackIconParams);
    header.addView(webViewRefresh, webViewRefreshIconParams);
    header.addView(webViewForward, webViewForwardIconParams);
    header.addView(ivmoveforward, ivmoveforwardIconIconParams);
    header.addView(imageshare, imageshareIconParams);
    header.addView(ivmoveback, ivmovebackIconIconParams);
    temp.addView(header, headerParams);
    temp.addView(subheader, subheaderParams);
    temp.addView(wvPlayer, wvPlayerParams);
    temp.addView(videoLayout, wvPlayerParams);

    setContentViewLayout.addView(temp, layoutParams);

    setContentView(setContentViewLayout);
    tvDescription = new TextView(ResourcePlayer.this);
    tvDescription1 = new TextView(ResourcePlayer.this);
    tvAbout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (flag == 0) {
                subheader.setVisibility(View.VISIBLE);
                subheader.removeAllViews();
                // tvDescriptionn.setVisibility(View.INVISIBLE);
                tvDescription1.setVisibility(View.VISIBLE);
                tvDescription.setVisibility(View.VISIBLE);

                tvDescription.setText("Description");
                tvDescription.setId(221);

                tvDescription.setTextSize(18);
                tvDescription.setTypeface(null, Typeface.BOLD);
                tvDescription.setTextColor(getResources().getColor(android.R.color.white));
                RelativeLayout.LayoutParams tvDescriptionParams = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
                tvDescriptionParams.setMargins(20, 10, 0, 20);
                tvDescriptionParams.addRule(RelativeLayout.BELOW, 220);

                tvDescription1.setText(description);
                tvDescription1.setLines(3);
                tvDescription1.setId(321);

                tvDescription1.setTextSize(15);
                tvDescription1.setTextColor(getResources().getColor(android.R.color.white));
                RelativeLayout.LayoutParams tvDescription1Params = new RelativeLayout.LayoutParams(1100, 100);
                tvDescription1Params.addRule(RelativeLayout.CENTER_IN_PARENT, -1);
                tvDescription1.setPadding(100, 20, 100, 0);
                subheader.addView(tvDescription1, tvDescription1Params);
                desc = 0;
                flag = 1;
                flag1 = 0;

            } else {
                subheader.removeAllViews();
                subheader.setVisibility(View.GONE);

                flag = 0;
            }
        }
    });

}

From source file:com.google.android.apps.authenticator.dataimport.Importer.java

private void importAccountDbFromBundle(Bundle bundle, AccountDb accountDb) {
    // Each account is stored in a Bundle whose key is a string representing the ordinal (integer)
    // position of the account in the database.
    List<String> sortedAccountBundleKeys = new ArrayList<String>(bundle.keySet());
    Collections.sort(sortedAccountBundleKeys, new IntegerStringComparator());
    int importedAccountCount = 0;
    for (String accountBundleKey : sortedAccountBundleKeys) {
        Bundle accountBundle = bundle.getBundle(accountBundleKey);
        String name = accountBundle.getString(KEY_NAME);
        if (name == null) {
            Log.w(LOG_TAG, "Skipping account #" + accountBundleKey + ": name missing");
            continue;
        }//from   w  w  w  .  j  av  a 2  s . com
        if (accountDb.nameExists(name)) {
            // Don't log account name here and below because it's considered PII
            Log.w(LOG_TAG, "Skipping account #" + accountBundleKey + ": already configured");
            continue;
        }
        String encodedSecret = accountBundle.getString(KEY_ENCODED_SECRET);
        if (encodedSecret == null) {
            Log.w(LOG_TAG, "Skipping account #" + accountBundleKey + ": secret missing");
            continue;
        }
        String typeString = accountBundle.getString(KEY_TYPE);
        AccountDb.OtpType type;
        if ("totp".equals(typeString)) {
            type = AccountDb.OtpType.TOTP;
        } else if ("hotp".equals(typeString)) {
            type = AccountDb.OtpType.HOTP;
        } else {
            Log.w(LOG_TAG,
                    "Skipping account #" + accountBundleKey + ": unsupported type: \"" + typeString + "\"");
            continue;
        }

        Integer counter = accountBundle.containsKey(KEY_COUNTER) ? accountBundle.getInt(KEY_COUNTER) : null;
        if (counter == null) {
            if (type == AccountDb.OtpType.HOTP) {
                Log.w(LOG_TAG, "Skipping account #" + accountBundleKey + ": counter missing");
                continue;
            } else {
                // TOTP
                counter = AccountDb.DEFAULT_HOTP_COUNTER;
            }
        }

        accountDb.update(name, encodedSecret, name, type, counter);
        importedAccountCount++;
    }

    Log.i(LOG_TAG, "Imported " + importedAccountCount + " accounts");
}

From source file:com.ichi2.anki.NoteEditor.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == DeckPicker.RESULT_DB_ERROR) {
        closeNoteEditor(DeckPicker.RESULT_DB_ERROR);
    }//from  ww w. j av a2 s. c  om

    switch (requestCode) {
    case REQUEST_ADD:
        if (resultCode != RESULT_CANCELED) {
            mChanged = true;
        }
        break;
    case REQUEST_MULTIMEDIA_EDIT:
        if (resultCode != RESULT_CANCELED) {
            Collection col = getCol();
            Bundle extras = data.getExtras();
            int index = extras.getInt(MultimediaEditFieldActivity.EXTRA_RESULT_FIELD_INDEX);
            IField field = (IField) extras.get(MultimediaEditFieldActivity.EXTRA_RESULT_FIELD);
            IMultimediaEditableNote mNote = NoteService.createEmptyNote(mEditorNote.model());
            NoteService.updateMultimediaNoteFromJsonNote(col, mEditorNote, mNote);
            mNote.setField(index, field);
            FieldEditText fieldEditText = mEditFields.get(index);
            // Completely replace text for text fields (because current text was passed in)
            if (field.getType() == EFieldType.TEXT) {
                fieldEditText.setText(field.getFormattedValue());
            }
            // Insert text at cursor position if the field has focus
            else if (fieldEditText.hasFocus()) {
                fieldEditText.getText().replace(fieldEditText.getSelectionStart(),
                        fieldEditText.getSelectionEnd(), field.getFormattedValue());
            }
            // Append text if the field doesn't have focus
            else {
                fieldEditText.getText().append(field.getFormattedValue());
            }
            NoteService.saveMedia(col, (MultimediaEditableNote) mNote);
            mChanged = true;
        }
        break;
    case REQUEST_TEMPLATE_EDIT:
        if (resultCode == RESULT_OK) {
            mReloadRequired = true;
        }
        updateCards(mEditorNote.model());
    }
}

From source file:android.webkit.AccessibilityInjector.java

/**
 * Packs an accessibility action into a JSON object and sends it to AndroidVox.
 *
 * @param action The action identifier./*from   w  w  w .  ja va  2s .c  o m*/
 * @param arguments The action arguments, if applicable.
 * @return The result of the action.
 */
private boolean sendActionToAndroidVox(int action, Bundle arguments) {
    if (mAccessibilityJSONObject == null) {
        mAccessibilityJSONObject = new JSONObject();
    } else {
        // Remove all keys from the object.
        final Iterator<?> keys = mAccessibilityJSONObject.keys();
        while (keys.hasNext()) {
            keys.next();
            keys.remove();
        }
    }

    try {
        mAccessibilityJSONObject.accumulate("action", action);

        switch (action) {
        case AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
        case AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
            if (arguments != null) {
                final int granularity = arguments
                        .getInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT);
                mAccessibilityJSONObject.accumulate("granularity", granularity);
            }
            break;
        case AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT:
        case AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT:
            if (arguments != null) {
                final String element = arguments
                        .getString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING);
                mAccessibilityJSONObject.accumulate("element", element);
            }
            break;
        }
    } catch (JSONException e) {
        return false;
    }

    final String jsonString = mAccessibilityJSONObject.toString();
    final String jsCode = String.format(ACCESSIBILITY_ANDROIDVOX_TEMPLATE, jsonString);
    return mCallback.performAction(mWebView, jsCode);
}

From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityCreateOrEditRoute.java

/**
 * Constructor// ww  w .  jav  a  2s  . c om
 */
@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    acList = new ArrayList<InitDestFrame>();
    r = getResources();

    //Calls the initAutoComplete method, adding the autocomplete listeners to acTo and acFrom
    initAutocomplete();

    //Calls the initAddDestButton method, adding the driving through button
    initAddDestButton();

    //Sets hasDrawn to false
    hasDrawn = false;

    Bundle extras = getIntent().getExtras();

    if (extras != null) {
        inEditMode = extras.getBoolean("editMode");
        positionOfRoute = extras.getInt("routePosition");
    }

    //Hides the checkbox
    chk_saveRoute = (CheckBox) findViewById(R.id.checkBoxSave);
    chk_saveRoute.setVisibility(8);

    //Initialises the draw/next button
    final Button button = ((Button) findViewById(R.id.btnChooseRoute));

    //Adjustments to the gui if in editmode
    if (inEditMode) {
        chk_saveRoute.setVisibility(View.GONE);
        button.setText("Update the route");
        button.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));
        fillFieldsInEdit();
        button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                createInputDialog("Route", "Insert name of Route", false);
            }
        });
    } else {
        button.setText("Show on map");
        button.setEnabled(false);
    }

    //Initialises the textviews and the clear buttons
    final AutoCompleteTextView acFrom = (AutoCompleteTextView) findViewById(R.id.etGoingFrom);
    final AutoCompleteTextView acTo = (AutoCompleteTextView) findViewById(R.id.etGoingTo);
    ImageView bClearFrom = ((ImageView) findViewById(R.id.etGoingFromClearIcon));
    ImageView bClearTo = ((ImageView) findViewById(R.id.etGoingToClearIcon));

    //If map is drawn fill the textviews
    if (selectedRoute.getMapPoints().size() != 0) {
        fillFieldsOnClick();
    }

    /**
     * onClickListener on the clearButton on the acFrom field {@link OnClickListener()}
     */
    //Adds onClickListener to the clearbutton on the acFrom field
    bClearFrom.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            acFrom.setText("");
            button.setEnabled(false);
            button.setText("Show on Map");

        }

    });

    /**
     * onClickListener on the clearButton on the acTo field {@link OnClickListener}
     */
    //Adds onClickListener to the clearbutton on the acTo field
    bClearTo.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            acTo.setText("");
            button.setEnabled(false);
            button.setText("Show on Map");

        }

    });

    /**
     * TextWatcher to the acFrom {@link autoCompleteTextView} autoCompleteTextView {@link TextWatcher()}
     */
    //Adds a TextWatcher to the acFrom field, to update the draw/nextbutton, and its functionality
    acFrom.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            hasDrawn = false;
            if (checkFields() && selectedRoute.getMapPoints().size() > 1 && hasDrawn == true) {
                button.setEnabled(true);
                button.setText("Next");
            } else if (checkFields() && selectedRoute.getMapPoints().size() > 1 && hasDrawn == false) {
                button.setEnabled(true);
                button.setText("Show on Map");

            } else if (checkFields() && selectedRoute.getMapPoints().size() == 0) {
                button.setEnabled(true);
                button.setText("Show on map");

            } else if (checkFields() == false && selectedRoute.getMapPoints().size() == 0) {
                button.setText("Show on map");
                button.setEnabled(false);
            } else if (inEditMode) {

            } else {
                button.setText("Show on map");
                button.setEnabled(false);
            }

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }

    });

    /**
     * TextWatcher to the acTo {@link autoCompleteTextView} autoCompleteTextView {@link TextWatcher()}
     */
    //Adds a TextWatcher to the acFrom field, to update the draw/nextbutton, and its functionality
    acTo.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            hasDrawn = false;
            if (checkFields() && selectedRoute.getMapPoints().size() > 2 && hasDrawn == true) {
                button.setEnabled(true);
                button.setText("Next");
            } else if (checkFields() && selectedRoute.getMapPoints().size() > 2 && hasDrawn == false) {
                button.setEnabled(true);
                button.setText("Show on Map");

            } else if (checkFields() && selectedRoute.getMapPoints().size() == 0) {
                button.setEnabled(true);
                button.setText("Show on map");

            } else if (checkFields() == false && selectedRoute.getMapPoints().size() == 0) {
                button.setText("Show on map");
                button.setEnabled(false);
            } else if (inEditMode) {

            } else {
                button.setText("Show on map");
                button.setEnabled(false);
            }

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }

    });

    /**
     * onClickListener on the button(draw/next) {@link OnClickListener}
     */
    //adds the onclickListener to the draw/next button
    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);

            if (checkFields() && selectedRoute.getMapPoints().size() > 1 && hasDrawn == true) {
                button.setText("Next");
                createOneTimeJourney();

            } else if (checkFields() && selectedRoute.getMapPoints().size() > 1 && hasDrawn == false) {
                mapView.getOverlays().clear();
                createMap();
                button.setText("Next");
            } else if (checkFields() && selectedRoute.getMapPoints().size() == 0) {
                mapView.getOverlays().clear();
                createMap();
                button.setText("Next");

            } else if (checkFields() == false && selectedRoute.getMapPoints().size() == 0) {
            } else if (inEditMode) {
                createInputDialog("Route", "Insert name of Route", false);
                button.setText("Next");

            } else {

            }
        }
    });

}

From source file:com.github.chenxiaolong.dualbootpatcher.patcher.PatchFileFragment.java

/**
 * {@inheritDoc}/*from   www  . j  a v a2s  . c  om*/
 */
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (savedInstanceState != null) {
        mSelectedPatcherId = savedInstanceState.getString(EXTRA_SELECTED_PATCHER_ID);
        mSelectedInputUri = savedInstanceState.getParcelable(EXTRA_SELECTED_INPUT_URI);
        mSelectedOutputUri = savedInstanceState.getParcelable(EXTRA_SELECTED_OUTPUT_URI);
        mSelectedInputFileName = savedInstanceState.getString(EXTRA_SELECTED_INPUT_FILE_NAME);
        mSelectedInputFileSize = savedInstanceState.getLong(EXTRA_SELECTED_INPUT_FILE_SIZE);
        mSelectedTaskId = savedInstanceState.getInt(EXTRA_SELECTED_TASK_ID);
        mSelectedDevice = savedInstanceState.getParcelable(EXTRA_SELECTED_DEVICE);
        mSelectedRomId = savedInstanceState.getString(EXTRA_SELECTED_ROM_ID);
        mQueryingMetadata = savedInstanceState.getBoolean(EXTRA_QUERYING_METADATA);
    }

    // Initialize UI elements
    mRecycler = (RecyclerView) getActivity().findViewById(R.id.files_list);
    mFAB = (FloatingActionMenu) getActivity().findViewById(R.id.fab);
    mFABAddZip = (FloatingActionButton) getActivity().findViewById(R.id.fab_add_flashable_zip);
    mFABAddOdin = (FloatingActionButton) getActivity().findViewById(R.id.fab_add_odin_image);
    mProgressBar = (ProgressBar) getActivity().findViewById(R.id.loading);
    mAddZipMessage = (TextView) getActivity().findViewById(R.id.add_zip_message);

    mItemTouchCallback = new DragSwipeItemTouchCallback(this);
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(mItemTouchCallback);
    itemTouchHelper.attachToRecyclerView(mRecycler);

    // Disable change animation since we frequently update the progress, which makes the
    // animation very ugly
    ItemAnimator animator = mRecycler.getItemAnimator();
    if (animator instanceof SimpleItemAnimator) {
        ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
    }

    // Set up listener for the FAB
    mFABAddZip.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            startFileSelection(PatcherUtils.PATCHER_ID_MULTIBOOTPATCHER);
            mFAB.close(true);
        }
    });
    mFABAddOdin.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            startFileSelection(PatcherUtils.PATCHER_ID_ODINPATCHER);
            mFAB.close(true);
        }
    });

    // Set up adapter for the files list
    mAdapter = new PatchFileItemAdapter(getActivity(), mItems, this);
    mRecycler.setHasFixedSize(true);
    mRecycler.setAdapter(mAdapter);

    LinearLayoutManager llm = new LinearLayoutManager(getActivity());
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    mRecycler.setLayoutManager(llm);

    // Hide FAB initially
    mFAB.hideMenuButton(false);

    // Show loading progress bar
    updateLoadingStatus();

    // Initialize the patcher once the service is connected
    executeNeedsService(new Runnable() {
        @Override
        public void run() {
            mService.initializePatcher();
        }
    });

    // NOTE: No further loading should be done here. All initialization should be done in
    // onPatcherLoaded(), which is called once the patcher's data files have been extracted and
    // loaded.
}