Example usage for android.widget ProgressBar setVisibility

List of usage examples for android.widget ProgressBar setVisibility

Introduction

In this page you can find the example usage for android.widget ProgressBar setVisibility.

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:net.kourlas.voipms_sms.Api.java

public void updateSmses(boolean silent) {
    if (preferences.getEmail().equals("")) {
        if (!silent) {
            Toast.makeText(context.getApplicationContext(), "Update SMSes: VoIP.ms portal email not set",
                    Toast.LENGTH_SHORT).show();
        }//from  w  w w.j a  v a2  s .com
    } else if (preferences.getPassword().equals("")) {
        if (!silent) {
            Toast.makeText(context.getApplicationContext(), "Update SMSes: VoIP.ms API password not set",
                    Toast.LENGTH_SHORT).show();
        }
    } else if (preferences.getDid().equals("")) {
        if (!silent) {
            Toast.makeText(context.getApplicationContext(), "Update SMSes: DID not set", Toast.LENGTH_SHORT)
                    .show();
        }
    } else if (isNetworkConnectionAvailable()) {
        Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        calendar.add(Calendar.DAY_OF_YEAR, -preferences.getDaysToSync());

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
        sdf.setTimeZone(TimeZone.getTimeZone("UTC"));

        try {
            String voipUrl = "https://www.voip.ms/api/v1/rest.php?" + "&" + "api_username="
                    + URLEncoder.encode(preferences.getEmail(), "UTF-8") + "&" + "api_password="
                    + URLEncoder.encode(preferences.getPassword(), "UTF-8") + "&" + "method=getSMS" + "&"
                    + "did=" + URLEncoder.encode(preferences.getDid(), "UTF-8") + "&" + "limit="
                    + URLEncoder.encode("1000000", "UTF-8") + "&" + "from="
                    + URLEncoder.encode(sdf.format(calendar.getTime()), "UTF-8") + "&" + "to="
                    + URLEncoder.encode(sdf.format(Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTime()),
                            "UTF-8")
                    + "&" + "timezone=-1";
            new UpdateSmsesAsyncTask().execute(voipUrl, Boolean.toString(silent));
            return;
        } catch (UnsupportedEncodingException ex) {
            if (!silent) {
                Toast.makeText(context.getApplicationContext(),
                        "Update SMSes: Email address or password contains invalid characters "
                                + "(UnsupportedEncodingException)",
                        Toast.LENGTH_SHORT).show();
            }
        }
    } else {
        if (!silent) {
            Toast.makeText(context.getApplicationContext(), "Update SMSes: Network connection unavailable",
                    Toast.LENGTH_SHORT).show();
        }
    }

    if (context instanceof ConversationsActivity) {
        SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) ((ConversationsActivity) context)
                .findViewById(R.id.swipe_refresh_layout);
        swipeRefreshLayout.setRefreshing(false);
    } else if (context instanceof ConversationActivity) {
        ProgressBar progressBar = (ProgressBar) ((ConversationActivity) context)
                .findViewById(R.id.progress_bar);
        progressBar.setVisibility(View.INVISIBLE);

    }
}

From source file:de.electricdynamite.pasty.ClipboardFragment.java

@Override
public void onLoadFinished(Loader<PastyLoader.PastyResponse> loader, PastyLoader.PastyResponse response) {

    ProgressBar pbLoading = (ProgressBar) getSherlockActivity().findViewById(R.id.progressbar_downloading);
    pbLoading.setVisibility(View.GONE);
    pbLoading = null;//from w  w  w.  j  a v  a  2s .co  m

    mHelpTextBig.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light));
    mHelpTextBig.setBackgroundDrawable(mBackground);

    if (response.isFinal) {
        getSherlockActivity().setSupportProgressBarIndeterminateVisibility(Boolean.FALSE);
        if (response.getResultSource() == PastyResponse.SOURCE_CACHE) {
            Toast.makeText(getSherlockActivity().getApplicationContext(),
                    getString(R.string.warning_no_network_short), Toast.LENGTH_SHORT).show();
        }
    }
    if (response.hasException) {
        if (LOCAL_LOG)
            Log.v(TAG, "onLoadFinished(): Loader delivered exception; calling handleException()");
        // an error occured

        getSherlockActivity().setSupportProgressBarIndeterminateVisibility(Boolean.FALSE);
        PastyException mException = response.getException();
        handleException(mException);
    } else {
        switch (loader.getId()) {
        case PastyLoader.TASK_CLIPBOARD_FETCH:
            JSONArray Clipboard = response.getClipboard();
            mItems.clear();
            mAdapter.notifyDataSetChanged();
            getListView().invalidateViews();
            try {
                if (Clipboard.length() == 0) {
                    //Clipboard is empty
                    mHelpTextBig.setText(R.string.helptext_PastyActivity_clipboard_empty);
                    mHelpTextSmall.setText(R.string.helptext_PastyActivity_how_to_add);
                } else {
                    for (int i = 0; i < Clipboard.length(); i++) {
                        JSONObject Item = Clipboard.getJSONObject(i);
                        ClipboardItem cbItem = new ClipboardItem(Item.getString("_id"), Item.getString("item"));
                        this.mItems.add(cbItem);
                    }

                    mHelpTextBig.setText(R.string.helptext_PastyActivity_copy);
                    mHelpTextSmall.setText(R.string.helptext_PastyActivity_options);

                    //Assign adapter to ListView
                    ListView listView = (ListView) getSherlockActivity().findViewById(R.id.listItems);
                    listView.setAdapter(mAdapter);
                    listView.setItemsCanFocus(false);
                    listView.setOnItemClickListener(new OnItemClickListener() {
                        @SuppressLint("NewApi")
                        @Override
                        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                            ClipboardItem Item = mItems.get(position); // get a ClipboardItem from the clicked position
                            if (Item.isLinkified() && prefs.getClickableLinks()) {
                                /* If the clicked item was originally linkified and prefs.getClickableLinks() is true, we manually
                                 * fire an ACTION_VIEW intent to simulate Linkify() behavior
                                 */
                                String url = Item.getText();
                                if (!URLUtil.isValidUrl(url))
                                    url = "http://" + url;
                                Intent i = new Intent(Intent.ACTION_VIEW);
                                i.setData(Uri.parse(url));
                                startActivity(i);
                            } else {
                                /* Else we copy the item to the systems clipboard,
                                 * show a Toast and finish() the activity
                                 */
                                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                                    android.content.ClipboardManager sysClipboard = (android.content.ClipboardManager) getSherlockActivity()
                                            .getSystemService(Context.CLIPBOARD_SERVICE);
                                    Item.copyToClipboard(sysClipboard);
                                    sysClipboard = null;
                                } else {
                                    ClipboardManager sysClipboard = (ClipboardManager) getSherlockActivity()
                                            .getSystemService(Context.CLIPBOARD_SERVICE);
                                    Item.copyToClipboard(sysClipboard);
                                    sysClipboard = null;
                                }
                                Toast.makeText(getSherlockActivity().getApplicationContext(),
                                        getString(R.string.item_copied), Toast.LENGTH_LONG).show();
                                getSherlockActivity().finish();
                            }
                        }
                    });
                    registerForContextMenu(listView);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            break;
        default:
            break;
        }
    }
}

From source file:azad.hallaji.farzad.com.masirezendegi.PageVirayesh.java

void setAlage() {

    ProgressBar progressbarsandaha = (ProgressBar) findViewById(R.id.progressbarsandaha);
    progressbarsandaha.setVisibility(View.VISIBLE);

    MyRequestQueue = Volley.newRequestQueue(this);
    String url = "http://telyar.dmedia.ir/webservice/Get_profile/";
    StringRequest MyStringRequest = new StringRequest(Request.Method.POST, url,
            new Response.Listener<String>() {
                @Override/* w  w  w  .j av  a2 s. c om*/
                public void onResponse(String response) {
                    //This code is executed if the server responds, whether or not the response contains data.
                    //The String 'response' contains the server's response.
                    Log.i("dfvflgnkjdfd", response);
                    //Toast.makeText(getApplicationContext(), response , Toast.LENGTH_LONG).show();
                    //Toast.makeText(getApplicationContext(), response , Toast.LENGTH_LONG).show();

                    try {
                        JSONObject jsonObject = new JSONObject(response);
                        GlobalVar.setUserID(jsonObject.getString("UID"));
                        try {
                            namexanivadeEdit.setText(
                                    jsonObject.getString("Name") + " " + jsonObject.getString("FamilyName"));
                        } catch (Exception ignored) {
                        }

                        try {
                            emailEdit.setText(jsonObject.getString("Email"));
                        } catch (Exception ignored) {
                        }
                        try {
                            sexEdit.setText(jsonObject.getString("Gender"));
                        } catch (Exception ignored) {
                        }
                        try {
                            shomareteleEdit.setText(jsonObject.getString("Telephone"));
                        } catch (Exception ignored) {
                        }
                        try {
                            selectedImage = Uri.parse(jsonObject.getString("PicAddress"));
                            imageviewuserVirayesh.setImageURI(selectedImage);
                        } catch (Exception ignored) {
                        }
                        try {
                            aboutmeEdit.setText(jsonObject.getString("AboutMe"));
                        } catch (Exception ignored) {
                        }
                        try {
                            costperminEdit.setText(jsonObject.getString("CostPerMin"));
                        } catch (Exception ignored) {
                        }
                        try {
                            dialtecEdit.setText(jsonObject.getString("Dialect"));
                        } catch (Exception ignored) {
                        }
                        try {
                            maxtimeEdit.setText(jsonObject.getString("AdviserMaxTime"));
                        } catch (Exception ignored) {
                        }

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

                    ProgressBar progressbarsandaha = (ProgressBar) findViewById(R.id.progressbarsandaha);
                    progressbarsandaha.setVisibility(View.INVISIBLE);

                }
            }, new Response.ErrorListener() { //Create an error listener to handle errors appropriately.
                @Override
                public void onErrorResponse(VolleyError error) {
                    //This code is executed if there is an error.
                }
            }) {
        protected Map<String, String> getParams() {
            Map<String, String> MyData = new HashMap<String, String>();
            //Log.i("asasasasasasa",adviseridm+"/"+GlobalVar.getDeviceID());
            MyData.put("userid", GlobalVar.getUserID()); //Add the data you'd like to send to the server.
            Log.i("dfvflgnkjdfd", MyData.toString());
            return MyData;
        }
    };
    MyRequestQueue.add(MyStringRequest);
}

From source file:jahirfiquitiva.iconshowcase.activities.WallpaperViewerActivity.java

@Override
protected void onResume() {
    super.onResume();
    makeStatusBarIconsWhite();/*from   ww w. ja  v  a 2 s .  co  m*/
    ProgressBar spinner = (ProgressBar) findViewById(R.id.progress);
    if (spinner != null)
        spinner.setVisibility(View.GONE);
}

From source file:at.bitfire.davdroid.ui.AccountActivity.java

@Override
public void onLoadFinished(Loader<AccountInfo> loader, final AccountInfo info) {
    accountInfo = info;// w  ww.ja  v  a 2 s.  c  o  m

    CardView card = (CardView) findViewById(R.id.carddav);
    if (info.carddav != null) {
        ProgressBar progress = (ProgressBar) findViewById(R.id.carddav_refreshing);
        progress.setVisibility(info.carddav.refreshing ? View.VISIBLE : View.GONE);

        listCardDAV = (ListView) findViewById(R.id.address_books);
        listCardDAV.setEnabled(!info.carddav.refreshing);
        listCardDAV.setAlpha(info.carddav.refreshing ? 0.5f : 1);

        tbCardDAV.getMenu().findItem(R.id.create_address_book).setEnabled(info.carddav.hasHomeSets);

        AddressBookAdapter adapter = new AddressBookAdapter(this);
        adapter.addAll(info.carddav.collections);
        listCardDAV.setAdapter(adapter);
        listCardDAV.setOnItemClickListener(onItemClickListener);
        listCardDAV.setOnItemLongClickListener(onItemLongClickListener);
    } else
        card.setVisibility(View.GONE);

    card = (CardView) findViewById(R.id.caldav);
    if (info.caldav != null) {
        ProgressBar progress = (ProgressBar) findViewById(R.id.caldav_refreshing);
        progress.setVisibility(info.caldav.refreshing ? View.VISIBLE : View.GONE);

        listCalDAV = (ListView) findViewById(R.id.calendars);
        listCalDAV.setEnabled(!info.caldav.refreshing);
        listCalDAV.setAlpha(info.caldav.refreshing ? 0.5f : 1);

        tbCalDAV.getMenu().findItem(R.id.create_calendar).setEnabled(info.caldav.hasHomeSets);

        final CalendarAdapter adapter = new CalendarAdapter(this);
        adapter.addAll(info.caldav.collections);
        listCalDAV.setAdapter(adapter);
        listCalDAV.setOnItemClickListener(onItemClickListener);
        listCalDAV.setOnItemLongClickListener(onItemLongClickListener);
    } else
        card.setVisibility(View.GONE);
}

From source file:com.egoclean.testpregnancy.util.ActivityHelper.java

/**
 * Adds an action button to the compatibility action bar, using menu information from a
 * {@link android.view.MenuItem}. If the menu item ID is <code>menu_refresh</code>, the menu item's state
 * can be changed to show a loading spinner using
 * {@link ActivityHelper#setRefreshActionButtonCompatState(boolean)}.
 *///from   w  w  w  .  ja v  a  2  s  .  c  om
private View addActionButtonCompatFromMenuItem(final MenuItem item) {
    final ViewGroup actionBar = getActionBarCompat();
    if (actionBar == null) {
        return null;
    }

    // Create the separator
    ImageView separator = new ImageView(mActivity, null, R.attr.actionbarCompatSeparatorStyle);
    separator.setLayoutParams(new ViewGroup.LayoutParams(2, ViewGroup.LayoutParams.FILL_PARENT));

    // Create the button
    ImageButton actionButton = new ImageButton(mActivity, null, R.attr.actionbarCompatButtonStyle);
    actionButton.setId(item.getItemId());
    actionButton.setLayoutParams(new ViewGroup.LayoutParams(
            (int) mActivity.getResources().getDimension(R.dimen.actionbar_compat_height),
            ViewGroup.LayoutParams.FILL_PARENT));
    actionButton.setImageDrawable(item.getIcon());
    actionButton.setScaleType(ImageView.ScaleType.CENTER);
    actionButton.setContentDescription(item.getTitle());
    actionButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            mActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
        }
    });

    actionBar.addView(separator);
    actionBar.addView(actionButton);

    if (item.getItemId() == R.id.menu_refresh) {
        // Refresh buttons should be stateful, and allow for indeterminate progress indicators,
        // so add those.
        int buttonWidth = mActivity.getResources().getDimensionPixelSize(R.dimen.actionbar_compat_height);
        int buttonWidthDiv3 = buttonWidth / 3;
        ProgressBar indicator = new ProgressBar(mActivity, null, R.attr.actionbarCompatProgressIndicatorStyle);
        LinearLayout.LayoutParams indicatorLayoutParams = new LinearLayout.LayoutParams(buttonWidthDiv3,
                buttonWidthDiv3);
        indicatorLayoutParams.setMargins(buttonWidthDiv3, buttonWidthDiv3, buttonWidth - 2 * buttonWidthDiv3,
                0);
        indicator.setLayoutParams(indicatorLayoutParams);
        indicator.setVisibility(View.GONE);
        indicator.setId(R.id.menu_refresh_progress);
        actionBar.addView(indicator);
    }

    return actionButton;
}

From source file:mp.paschalis.LoginFragment.java

/**
 * Clears login message and Progress dialog
 *///from  w w w  . j  a  v  a 2  s. c  o  m
private void clearLoginStaff() {
    ProgressBar progressBarLoginButton = (ProgressBar) getSherlockActivity()
            .findViewById(R.id.progressBarLoginButton);

    TextView editTextLoginMsg = (TextView) getSherlockActivity().findViewById(R.id.textViewLoginMessage);

    progressBarLoginButton.setVisibility(View.INVISIBLE);
    editTextLoginMsg.setText("");
}

From source file:br.org.funcate.dynamicforms.views.GPictureView.java

public ProgressBar getProgressBar(final Context context) {
    ProgressBar progressBar = new ProgressBar(context);
    // Get the Drawable custom_progressbar
    Drawable draw = getResources().getDrawable(R.drawable.customprogressbar);
    // set the drawable as progress drawable
    progressBar.setProgressDrawable(draw);
    progressBar.setVisibility(View.VISIBLE);
    progressBar.setPadding(5, 5, 5, 5);/* w w w. ja v a  2s.c  o m*/
    progressBar.setLayoutParams(new LinearLayout.LayoutParams(thumbnailWidth, thumbnailHeight));
    return progressBar;
}

From source file:io.github.hidroh.materialistic.OfflineWebActivity.java

@SuppressWarnings("ConstantConditions")
@Override/*from  w  ww  .  j av  a 2  s.  co m*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String url = getIntent().getStringExtra(EXTRA_URL);
    if (TextUtils.isEmpty(url)) {
        finish();
        return;
    }
    setTitle(url);
    setContentView(R.layout.activity_offline_web);
    final NestedScrollView scrollView = (NestedScrollView) findViewById(R.id.nested_scroll_view);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setOnClickListener(v -> scrollView.smoothScrollTo(0, 0));
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayOptions(
            ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
    getSupportActionBar().setSubtitle(R.string.offline);
    final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress);
    final WebView webView = (WebView) findViewById(R.id.web_view);
    webView.setBackgroundColor(Color.TRANSPARENT);
    webView.setWebViewClient(new AdBlockWebViewClient(Preferences.adBlockEnabled(this)) {
        @Override
        public void onPageFinished(WebView view, String url) {
            setTitle(view.getTitle());
        }
    });
    webView.setWebChromeClient(new CacheableWebView.ArchiveClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            progressBar.setVisibility(View.VISIBLE);
            progressBar.setProgress(newProgress);
            if (newProgress == 100) {
                progressBar.setVisibility(View.GONE);
                webView.setBackgroundColor(Color.WHITE);
                webView.setVisibility(View.VISIBLE);
            }
        }
    });
    AppUtils.toggleWebViewZoom(webView.getSettings(), true);
    webView.loadUrl(url);
}

From source file:com.jana.android.ui.impl.viewmodel.ImagePagerAdapter.java

public View getItem(int position) {

    if (mImageList == null || position < 0 || position >= mImageList.size()) {
        return null;
    }/*from   w w  w  .ja va2 s. c om*/

    View view = mInflater.inflate(R.layout.simple_image_pagger_item, null, false);

    UrlImageView imageView = (UrlImageView) view.findViewById(R.id.image);

    final ProgressBar spinner = (ProgressBar) view.findViewById(R.id.loading);

    Image image = mImageList.get(position);

    if (image == null) {
        return view;
    }

    String imageUrl = image.getPath();

    if (!mImageLoader.isInited()) {
        return view;
    }

    mImageLoader.displayImage(imageUrl, imageView, mOptions, new SimpleImageLoadingListener() {

        @Override
        public void onLoadingStarted(String imageUri, View view) {

            spinner.setVisibility(View.VISIBLE);
        }

        @Override
        public void onLoadingFailed(String imageUri, View view, FailReason failReason) {

            String message = null;

            switch (failReason.getType()) {

            case IO_ERROR:

                message = "Input/Output error";

                break;

            case DECODING_ERROR:

                message = "Image can't be decoded";

                break;

            case NETWORK_DENIED:

                message = "Downloads are denied";

                break;

            case OUT_OF_MEMORY:

                message = "Out Of Memory error";

                break;

            case UNKNOWN:

                message = "Unknown error";

                break;
            }

            Logger.w("Failed to load images due to this error = " + message);

            spinner.setVisibility(View.GONE);
        }

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {

            spinner.setVisibility(View.GONE);
        }
    });

    return view;
}