Example usage for android.app ProgressDialog ProgressDialog

List of usage examples for android.app ProgressDialog ProgressDialog

Introduction

In this page you can find the example usage for android.app ProgressDialog ProgressDialog.

Prototype

public ProgressDialog(Context context) 

Source Link

Document

Creates a Progress dialog.

Usage

From source file:com.zirconi.huaxiaclient.LoginActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login_layout);
    application = (SharedApplication) this.getApplication();
    pref = getSharedPreferences("LOGIN", MODE_PRIVATE);
    PAGE = SharedApplication.TEL_PAGE;// w w  w. j  a v a  2  s. c  o m
    INDEXPAGE = SharedApplication.HTTP_TEL_ADDR;
    runFlag = false;
    AUTHOR = (TextView) this.findViewById(R.id.author);
    AUTHOR.setText(AUT);

    this.login_et_username = (EditText) this.findViewById(R.id.login_et_username);
    this.login_et_password = (EditText) this.findViewById(R.id.login_et_password);
    this.login_cb_rempwd = (CheckBox) this.findViewById(R.id.login_cb_rempwd);
    this.login_rb_tel = (RadioButton) this.findViewById(R.id.login_rb_tel);
    this.login_rb_cer = (RadioButton) this.findViewById(R.id.login_rb_cer);
    this.login_btn_submit = (Button) this.findViewById(R.id.login_btn_submit);
    this.login_btn_cancel = (Button) this.findViewById(R.id.login_btn_cancel);
    this.login_rg_select = (RadioGroup) this.findViewById(R.id.login_rg_select);

    if (pref.getBoolean("TEL", true)) {
        this.login_rb_tel.setChecked(true);
        PAGE = SharedApplication.TEL_PAGE;
        INDEXPAGE = SharedApplication.HTTP_TEL_ADDR;
    } else {
        this.login_rb_cer.setChecked(true);
        PAGE = SharedApplication.CER_PAGE;
        INDEXPAGE = SharedApplication.HTTP_CER_ADDR;
    }

    if (pref.getBoolean("PASSWORD", false)) {
        this.login_cb_rempwd.setChecked(true);
    } else {
        this.login_cb_rempwd.setChecked(false);
    }

    if (this.login_cb_rempwd.isChecked() && !pref.getString("user", "").equals("")) {
        this.login_et_username.setText(pref.getString("user", ""));
        this.login_et_password.setText(pref.getString("pwd", ""));
    }

    this.login_cb_rempwd.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                Editor tmp = pref.edit();
                tmp.putBoolean("PASSWORD", true);
                tmp.commit();
            } else {
                Editor tmp = pref.edit();
                tmp.putBoolean("PASSWORD", false);
                tmp.putString("user", "");
                tmp.putString("pwd", "");
                tmp.commit();
            }
        }
    });

    this.login_rg_select.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (checkedId == R.id.login_rb_cer) {
                Editor tmp = pref.edit();
                tmp.putBoolean("TEL", false);
                tmp.commit();
                PAGE = SharedApplication.CER_PAGE;
                INDEXPAGE = SharedApplication.HTTP_CER_ADDR;
                Log.d(TAG, "SLELCT CER " + PAGE);
            } else {
                Editor tmp = pref.edit();
                tmp.putBoolean("TEL", true);
                tmp.commit();
                PAGE = SharedApplication.TEL_PAGE;
                INDEXPAGE = SharedApplication.HTTP_TEL_ADDR;
                Log.d(TAG, "SLELCT TEL " + PAGE);
            }
        }
    });

    this.login_btn_cancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            LoginActivity.this.finish();
        }
    });

    this.login_btn_submit.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (login_et_username.getText().toString().equals("")
                    || login_et_password.getText().toString().equals("")) {
                Toast.makeText(LoginActivity.this, "", Toast.LENGTH_LONG).show();
            } else {
                if (login_cb_rempwd.isChecked()) {
                    Editor tmp = pref.edit();
                    tmp.putString("user", login_et_username.getText().toString());
                    tmp.putString("pwd", login_et_password.getText().toString());
                    tmp.commit();

                    isNetwork = SharedApplication.networkIsAvailable(LoginActivity.this);
                    if (isNetwork) {
                        if (runFlag == false) {
                            t = new ProgressDialog(LoginActivity.this);
                            t.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                            t.setTitle("");
                            t.setMessage("");
                            t.show();
                            TASK = new Async();
                            TASK.execute(PAGE);
                            runFlag = true;
                        }
                    } else {
                        Toast.makeText(LoginActivity.this, "", Toast.LENGTH_LONG).show();
                    }
                } else {
                    // 
                    isNetwork = SharedApplication.networkIsAvailable(LoginActivity.this);
                    if (isNetwork) {
                        if (runFlag == false) {
                            t = new ProgressDialog(LoginActivity.this);
                            t.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                            t.setTitle("");
                            t.setMessage("");
                            t.show();
                            TASK = new Async();
                            TASK.execute(PAGE);
                            runFlag = true;
                        }
                    } else {
                        Toast.makeText(LoginActivity.this, "", Toast.LENGTH_LONG).show();
                    }
                }
            }
        }
    });
    Log.i(TAG, "ONCREATE");
}

From source file:fm.smart.r1.activity.CreateExampleActivity.java

public void onClick(View v) {
    EditText exampleInput = (EditText) findViewById(R.id.create_example_sentence);
    EditText translationInput = (EditText) findViewById(R.id.create_example_translation);
    EditText exampleTransliterationInput = (EditText) findViewById(R.id.sentence_transliteration);
    EditText translationTransliterationInput = (EditText) findViewById(R.id.translation_transliteration);
    final String example = exampleInput.getText().toString();
    final String translation = translationInput.getText().toString();
    if (TextUtils.isEmpty(example) || TextUtils.isEmpty(translation)) {
        Toast t = Toast.makeText(this, "Example and translation are required fields", 150);
        t.setGravity(Gravity.CENTER, 0, 0);
        t.show();/*from w ww . ja  va2s.co  m*/
    } else {
        final String example_language_code = Utils.LANGUAGE_MAP.get(example_language);
        final String translation_language_code = Utils.LANGUAGE_MAP.get(translation_language);
        final String example_transliteration = exampleTransliterationInput.getText().toString();
        final String translation_transliteration = translationTransliterationInput.getText().toString();

        if (Main.isNotLoggedIn(this)) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setClassName(this, LoginActivity.class.getName());
            intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid
            // navigation
            // back to this?
            LoginActivity.return_to = CreateExampleActivity.class.getName();
            LoginActivity.params = new HashMap<String, String>();
            LoginActivity.params.put("list_id", list_id);
            LoginActivity.params.put("item_id", item_id);
            LoginActivity.params.put("example", example);
            LoginActivity.params.put("translation", translation);
            LoginActivity.params.put("example_language", example_language);
            LoginActivity.params.put("translation_language", translation_language);
            LoginActivity.params.put("example_transliteration", example_transliteration);
            LoginActivity.params.put("translation_transliteration", translation_transliteration);
            startActivity(intent);
        } else {

            final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
            myOtherProgressDialog.setTitle("Please Wait ...");
            myOtherProgressDialog.setMessage("Creating Example ...");
            myOtherProgressDialog.setIndeterminate(true);
            myOtherProgressDialog.setCancelable(true);

            final Thread create_example = new Thread() {
                public void run() {
                    // TODO make this interruptable .../*if
                    // (!this.isInterrupted())*/
                    try {
                        // TODO failures here could derail all ...
                        CreateExampleActivity.add_item_list_result = ItemActivity.addItemToList(list_id,
                                item_id, CreateExampleActivity.this);
                        CreateExampleActivity.create_example_result = createExample(example,
                                example_language_code, example_transliteration, translation,
                                translation_language_code, translation_transliteration, item_id, list_id);
                        CreateExampleActivity.add_sentence_list_result = ItemActivity.addSentenceToList(
                                CreateExampleActivity.create_example_result.http_response, item_id, list_id,
                                CreateExampleActivity.this);
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    myOtherProgressDialog.dismiss();

                }
            };
            myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    create_example.interrupt();
                }
            });
            OnCancelListener ocl = new OnCancelListener() {
                public void onCancel(DialogInterface arg0) {
                    create_example.interrupt();
                }
            };
            myOtherProgressDialog.setOnCancelListener(ocl);
            myOtherProgressDialog.show();
            create_example.start();
        }
    }
}

From source file:com.ccxt.whl.activity.AddContactActivity.java

/**
 *  contact//from  w w  w  . j  a va2  s .co m
 * @param view
 */
public void addContact(View view) {
    /*String sendstr = data.getStringExtra("edittext");
    if(CommonUtils.isNullOrEmpty(sendstr)){
       sendstr = "";
    }
    //addUserToBlacklist(deleteMsg.getFrom());
    addContact(deleteMsg.getFrom(),sendstr);
    */
    //if(DemoApplication.getInstance().getUserName().equals(nameText.getText().toString())){
    if (DemoApplication.getInstance().getUser().equals(nameText.getText().toString())) {
        startActivity(new Intent(this, AlertDialog.class).putExtra("msg", "?"));
        return;
    }

    if (DemoApplication.getInstance().getContactList().containsKey(nameText.getText().toString())) {
        startActivity(new Intent(this, AlertDialog.class).putExtra("msg", "?"));
        return;
    }

    progressDialog = new ProgressDialog(this);
    progressDialog.setMessage("??...");
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.show();

    new Thread(new Runnable() {
        public void run() {

            try {
                //demoreason
                EMContactManager.getInstance().addContact(toAddUsername, "?");
                runOnUiThread(new Runnable() {
                    public void run() {
                        progressDialog.dismiss();
                        Toast.makeText(getApplicationContext(), "???,?", 1)
                                .show();
                    }
                });
            } catch (final Exception e) {
                runOnUiThread(new Runnable() {
                    public void run() {
                        progressDialog.dismiss();
                        Toast.makeText(getApplicationContext(), "?:" + e.getMessage(), 1)
                                .show();
                    }
                });
            }
        }
    }).start();
}

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();/* w w  w  .  java2  s . 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.eutectoid.dosomething.SomethingFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.something, container, false);

    profilePictureView = (ProfilePictureView) view.findViewById(R.id.selection_profile_pic);
    profilePictureView.setCropped(true);
    announceButton = (TextView) view.findViewById(R.id.announce_text);
    shareButton = (ShareButton) view.findViewById(R.id.share_button);
    messageButton = (SendButton) view.findViewById(R.id.message_button);
    if (mClient.isConnected()) {
        //getLocation();
    }//from w w w. j a  v a2 s .  co  m

    announceProgressDialog = new ProgressDialog(getActivity());
    announceProgressDialog.setMessage(getString(R.string.progress_dialog_text));

    if (MessageDialog.canShow(ShareOpenGraphContent.class)) {
        messageButton.setVisibility(View.VISIBLE);
    }

    announceButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            handleAnnounce();
        }
    });

    messageButton.registerCallback(callbackManager, shareCallback);
    messageButton.setFragment(this);
    shareButton.registerCallback(callbackManager, shareCallback);
    shareButton.setFragment(this);

    /* Adding DoSomething Button */
    Button doButton = (Button) view.findViewById(R.id.do_button);
    doButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            toggleWhatDoFragment();
        }
    });

    //TODO Add show FriendsList Function and Fragment FriendsListFragment

    profilePictureView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (AccessToken.getCurrentAccessToken() != null) {
                activity.showSettingsFragment();
            } else {
                activity.showSplashFragment();
            }
        }
    });

    init(savedInstanceState);
    updateWithToken(AccessToken.getCurrentAccessToken());

    return view;
}

From source file:com.ccxt.whl.activity.RegisterActivity.java

public void reg(final String username, final String pwd) {
    if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(pwd)) {
        final ProgressDialog pd = new ProgressDialog(this);
        pd.setMessage("...");
        pd.show();//from   w w  w.  j  a  va  2  s . c om
        new Thread(new Runnable() {
            public void run() {
                try {
                    // sdk
                    EMChatManager.getInstance().createAccountOnServer(username, pwd);
                    runOnUiThread(new Runnable() {
                        public void run() {
                            if (!RegisterActivity.this.isFinishing())
                                pd.dismiss();
                            RequestParams params = new RequestParams();
                            params.add("user", username);
                            if (DemoApplication.getInstance().getlastloc() != null) {
                                double Latitude = DemoApplication.getInstance().getlastloc().getLatitude();
                                double Longitude = DemoApplication.getInstance().getlastloc().getLongitude();
                                String adr = DemoApplication.getInstance().getlastloc().getAddrStr();
                                params.add("jiedao", adr);
                            }
                            HttpRestClient.get(Constant.REGISTER_URL_HUIZHI, params,
                                    new BaseJsonHttpResponseHandler() {

                                        @Override
                                        public void onSuccess(int statusCode, Header[] headers,
                                                String rawJsonResponse, Object response) {
                                            // TODO Auto-generated method stub
                                            Log.d("login_res_json" + rawJsonResponse);

                                            if (CommonUtils.isNullOrEmpty(rawJsonResponse)) {
                                                Toast.makeText(getApplicationContext(),
                                                        "?,?", 0).show();
                                                return;
                                            }
                                            Map<String, Object> lm = JsonToMapList.getMap(rawJsonResponse);

                                            if (lm.get("status").toString() != null
                                                    && lm.get("status").toString().equals("yes")) {
                                                Map<String, Object> result = JsonToMapList
                                                        .getMap(lm.get("result").toString());
                                                String resultStr = "status:" + lm.get("status") + "\n"
                                                        + "message:" + lm.get("message") + "\n" + "result:"
                                                        + lm.get("result") + "\n";

                                                Log.d("login_res_obj" + resultStr);

                                                pd.dismiss();
                                                // ???
                                                //                                 DemoApplication.getInstance().setUserName(username);
                                                DemoApplication.getInstance().setUser(username);
                                                Toast.makeText(getApplicationContext(), "?", 0)
                                                        .show();
                                                finish();
                                            } else {
                                                Toast.makeText(getApplicationContext(),
                                                        lm.get("message").toString(), 0).show();
                                                pd.dismiss();
                                            }

                                        }

                                        @Override
                                        public void onFailure(int statusCode, Header[] headers,
                                                Throwable throwable, String rawJsonData, Object errorResponse) {
                                            // TODO Auto-generated method stub
                                            Toast.makeText(getApplicationContext(),
                                                    "??", 0).show();
                                        }

                                        @Override
                                        protected Object parseResponse(String rawJsonData, boolean isFailure)
                                                throws Throwable {
                                            // TODO Auto-generated method stub
                                            return null;
                                        }

                                    });

                        }
                    });
                } catch (final Exception e) {
                    runOnUiThread(new Runnable() {
                        public void run() {
                            if (!RegisterActivity.this.isFinishing())
                                pd.dismiss();
                            if (e != null && e.getMessage() != null) {
                                String errorMsg = e.getMessage();
                                if (errorMsg.indexOf("EMNetworkUnconnectedException") != -1) {
                                    Toast.makeText(getApplicationContext(), "?",
                                            0).show();
                                } else if (errorMsg.indexOf("conflict") != -1) {
                                    //????
                                    Toast.makeText(getApplicationContext(), "??", 0)
                                            .show();
                                } else if (errorMsg.indexOf("not support the capital letters") != -1) {
                                    Toast.makeText(getApplicationContext(), "??????",
                                            0).show();
                                } else {
                                    Toast.makeText(getApplicationContext(), ": " + e.getMessage(),
                                            1).show();
                                }

                            } else {
                                Toast.makeText(getApplicationContext(), ": ", 1).show();
                            }
                        }
                    });
                }
            }
        }).start();

    }
}

From source file:com.jbsoft.farmtotable.FarmToTableActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    progress = new ProgressDialog(this);
    super.onCreate(savedInstanceState);

    if (readyToGo()) {
        setContentView(R.layout.activity_main);

        SupportMapFragment mapFrag = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);

        initListNav();/*from  www .j a v  a 2s . com*/

        getSupportActionBar().setHomeButtonEnabled(true);
        sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
        getPreferences(sharedPrefs);

        sharedPrefs.registerOnSharedPreferenceChangeListener(listener);

        map = mapFrag.getMap();
        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        // Getting GPS status
        boolean isNETWORKEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        boolean isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        // If GPS enabled, get latitude/longitude using GPS Services

        if (isGPSEnabled) {
            locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME_BW_UPDATES,
                    MIN_DISTANCE_CHANGE_FOR_UPDATES, gpsLocationListener);
            Log.d("GPS Enabled", "GPS Enabled");
            if (locationManager != null) {
                location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                if (location != null) {
                    latitude = location.getLatitude();
                    longitude = location.getLongitude();
                }
            }
        }

        if (savedInstanceState == null) {

            CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(latitude, longitude));
            map.moveCamera(center);
        }

        if (NOFM) {
            //Reverse geocoder to zipcode
            getZipFromLocation(location, this);

            //start progress box going
            //Call api to retrieve Farmers Market from the UDSA site 
            usdaurl = usdaurl + zipcode;
        } else {
            nozip = true;
        }
        //start progress box going
        progress.setMessage("Getting Farmers Markets and Other Organic Options in your area:)");
        progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progress.setIndeterminate(true);
        progress.show();
        gplaceurl = placeurl_save;
        placeurl_save = gplaceurl;
        if (NOVR) {
            gplaceurl = gplaceurl + queryvegan;
        }

        if (NOOR) {
            gplaceurl = placeurl_save;
            gplaceurl = gplaceurl + queryvegetarian;
        }

        if (NOFS) {
            gplaceurl = placeurl_save;
            gplaceurl = gplaceurl + queryfarms;
        }

        if ((NOVR) && (NOOR)) {
            gplaceurl = placeurl_save;
            gplaceurl = gplaceurl + queryvegan + "&" + queryvegetarian;
        }

        if ((NOVR) && (NOFS)) {
            gplaceurl = placeurl_save;
            gplaceurl = gplaceurl + queryvegan + "&" + queryfarms;
        }

        if ((NOOR) && (NOFS)) {
            gplaceurl = placeurl_save;
            gplaceurl = gplaceurl + queryvegetarian + "&" + queryfarms;
        }

        if ((NOVR) && (NOOR) && (NOFS)) {
            gplaceurl = placeurl_save;
            gplaceurl = gplaceurl + queryvegan + "&" + queryvegetarian + "&" + queryfarms;
        }

        //The Google Places API Text Search Service 
        gplaceurl = gplaceurl + "&location=" + latitude + "," + longitude
                + "&radius=10&key=AIzaSyA_fzl-7ZkF4EINWhuQ0bcXp3zkdAXZc5o";
        //Call Asynch process Api 

        new restAPICall().execute(usdaurl, gplaceurl);
    }

    map.setInfoWindowAdapter(new CustomToast(this, null));
    // map.setOnInfoWindowClickListener((OnInfoWindowClickListener) 
    map.setMyLocationEnabled(true);
    CameraUpdate zoom = CameraUpdateFactory.zoomTo(12);
    map.animateCamera(zoom);
}

From source file:nmtysh.android.test.speedtest.SpeedTestActivity.java

private void runHttpURLConnection() {
    final String url = urlEdit.getText().toString();
    if (url == null || (!url.startsWith("http://") && !url.startsWith("https://"))) {
        list.add("URL error!");
        adapter.notifyDataSetChanged();//from ww  w  .  j  a  v a 2s . c om
        return;
    }
    task = new AsyncTask<Void, Integer, Void>() {
        long startTime;
        ProgressDialog progress;

        // ??
        @Override
        protected void onPreExecute() {
            super.onPreExecute();

            progress = new ProgressDialog(SpeedTestActivity.this);
            progress.setMessage(getString(R.string.progress_message));
            progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            progress.setIndeterminate(false);
            progress.setCancelable(true);
            progress.setOnCancelListener(new OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    task.cancel(true);
                }
            });
            progress.setMax(10);
            progress.setProgress(0);
            progress.show();

            startTime = System.currentTimeMillis();
        }

        // ???
        @Override
        protected Void doInBackground(Void... params) {
            // 10?????
            for (int i = 0; i < 10; i++) {
                HttpURLConnection connection = null;
                InputStreamReader in = null;
                // BufferedReader br = null;
                try {
                    connection = (HttpURLConnection) (new URL(url)).openConnection();
                    connection.setRequestMethod("GET");
                    connection.connect();
                    in = new InputStreamReader(connection.getInputStream());
                    // br = new BufferedReader(in);
                    // while (br.readLine() != null) {
                    long len = 0;
                    while (in.read() != -1) {
                        len++;
                    }
                    Log.i("HttpURLConnection", len + " Bytes");
                } catch (IOException e) {
                } finally {
                    /*
                     * if (br != null) { try { br.close(); } catch
                     * (IOException e) { } br = null; }
                     */
                    if (in != null) {
                        try {
                            in.close();
                        } catch (IOException e) {
                        }
                        in = null;
                    }
                    if (connection != null) {
                        connection.disconnect();
                        connection = null;
                    }
                }
                publishProgress(i + 1);
                // Dos????????
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                }
            }
            return null;
        }

        @Override
        protected void onProgressUpdate(Integer... values) {
            super.onProgressUpdate(values);
            if (progress == null) {
                return;
            }
            progress.setProgress(values[0]);
        }

        // 
        @Override
        protected void onPostExecute(Void result) {
            long endTime = System.currentTimeMillis();

            // 
            progress.cancel();
            progress = null;

            list.add("HttpURLConnection:" + url + " " + (endTime - startTime) + "msec/10" + " "
                    + (endTime - startTime) / 10 + "msec");
            adapter.notifyDataSetChanged();
        }

        @Override
        protected void onCancelled() {
            super.onCancelled();
            progress.dismiss();
            progress = null;
        }
    }.execute();
}

From source file:com.ternup.caddisfly.fragment.DetailsFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case R.id.menu_sendResult:
        if (NetworkUtils.checkInternetConnection(mContext)) {
            if (progressDialog == null) {
                progressDialog = new ProgressDialog(getActivity());
                progressDialog.setMessage(getString(R.string.sending));
                progressDialog.setCancelable(false);
            }//w w w .j  av a 2 s  .c o m
            progressDialog.show();
            postResult(mFolderName);
        }
        return true;
    case R.id.menu_delete:
        AlertUtils.askQuestion(getActivity(), R.string.delete, R.string.selectedWillBeDeleted,
                new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        FileUtils.deleteFolder(getActivity(), mLocationId, mFolderName);

                        Uri uri = ContentUris.withAppendedId(TestContentProvider.CONTENT_URI, mId);
                        mContext.getContentResolver().delete(uri, null, null);

                        double value = 0;
                        int counter = 0;
                        while (value != -1) {
                            String key = String.format(getString(R.string.resultValueKey), mTestTypeId, mId,
                                    counter);
                            if (PreferencesUtils.contains(mContext, key)) {
                                PreferencesUtils.removeKey(mContext, key);
                            } else {
                                value = -1;
                            }
                            counter++;
                        }
                        goBack();
                    }

                }, null);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.gmail.nagamatu.radiko.installer.RadikoInstallerActivity.java

private Dialog onCreateProgressDialog() {
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setMessage("Loading...");
    dialog.setCancelable(false);/*from w  ww.j  av  a2s  .c  o m*/
    return dialog;
}