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:com.codingspezis.android.metalonly.player.LicenseActivity.java

@SuppressLint("DefaultLocale")
@Override//from  w  ww  .j  a v  a  2s  . co m
public void onCreate(Bundle savedInstanceState) {
    // TODO refactor
    super.onCreate(savedInstanceState);

    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    String license = "";
    Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
        license = bundle.getString(KEY_BU_LICENSE_NAME);
    }
    setContentView(R.layout.activity_licensing);
    setTitle(license.toUpperCase());
    final TextView textView = (TextView) findViewById(R.id.license);
    final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress);
    final ThreadedLicenseReader reader = new ThreadedLicenseReader(this, license);
    reader.setOnLicenseReadListener(new OnLicenseReadListener() {
        @Override
        public void onLicenseRead() {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    String license = reader.getLicense();
                    if (license != null) {
                        textView.setText(license);
                    }
                    progressBar.setVisibility(View.INVISIBLE);
                    textView.setVisibility(View.VISIBLE);
                }
            });
        }
    });
    reader.start();
}

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

void postgetData() {

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

    MyRequestQueue = Volley.newRequestQueue(this);

    String url = "http://telyar.dmedia.ir/webservice/Get_adviser_profile/";
    StringRequest MyStringRequest = new StringRequest(Request.Method.POST, url,
            new Response.Listener<String>() {

                @Override/* w  ww  . j a  va  2 s  .  c  o m*/
                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("ExplainMoshaver", response);
                    //Toast.makeText(getApplicationContext(), response , Toast.LENGTH_LONG).show();
                    updatelistview(response);

                }
            }, 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("adviserid", adviseridm); //Add the data you'd like to send to the server.
            MyData.put("deviceid", GlobalVar.getDeviceID()); //Add the data you'd like to send to the server.
            MyData.put("userid", GlobalVar.getUserID()); //Add the data you'd like to send to the server.
            Log.i("ExplainMoshaver", MyData.toString());

            return MyData;
        }

        @Override
        protected void onFinish() {

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

            TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);

            TabHost.TabSpec tabSpec3 = tabHost.newTabSpec("nazar");
            TabHost.TabSpec tabSpec2 = tabHost.newTabSpec("madarek");
            TabHost.TabSpec tabSpec1 = tabHost.newTabSpec("map");

            tabSpec3.setIndicator("");
            Intent intent1 = new Intent(ExplainMoshaver.this, ListeComments.class);
            intent1.putExtra("adviseridm", adviseridm);
            intent1.putExtra("comments", comments);
            /*intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent1.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
            intent1.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);*/
            Log.i("aaaaaaaaaaaaaaa", comments + " ");
            tabSpec3.setContent(intent1);

            tabSpec2.setIndicator("");
            Intent intent2 = new Intent(ExplainMoshaver.this, ListeLiecence.class);
            intent2.putExtra("adviseridm", adviseridm);
            intent2.putExtra("License", License);
            /*intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
            intent2.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);*/
            tabSpec2.setContent(intent2);

            tabSpec1.setIndicator("");
            final Intent intent = new Intent(ExplainMoshaver.this, MapsActivity.class);
            intent.putExtra("adviseridm", adviseridm);
            intent.putExtra("Mainplace", Mainplace);
            intent.putExtra("menuya", "ya");
            /*intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);*/
            tabSpec1.setContent(intent);

            tabHost.addTab(tabSpec1);
            tabHost.addTab(tabSpec2);
            tabHost.addTab(tabSpec3);

            tabHost.setCurrentTab(2);
        }
    };

    MyRequestQueue.add(MyStringRequest);
}

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

public void sendSms(String contact, String message) {
    if (preferences.getEmail().equals("")) {
        Toast.makeText(context.getApplicationContext(), "Send SMS: VoIP.ms portal email not set",
                Toast.LENGTH_SHORT).show();
    } else if (preferences.getPassword().equals("")) {
        Toast.makeText(context.getApplicationContext(), "Send SMS: VoIP.ms API password not set",
                Toast.LENGTH_SHORT).show();
    } else if (preferences.getDid().equals("")) {
        Toast.makeText(context.getApplicationContext(), "Send SMS: DID not set", Toast.LENGTH_SHORT).show();
    } else if (isNetworkConnectionAvailable()) {
        try {/* w  w  w.  j  ava 2 s.  c  o  m*/
            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=sendSMS" + "&"
                    + "did=" + URLEncoder.encode(preferences.getDid(), "UTF-8") + "&" + "dst="
                    + URLEncoder.encode(contact, "UTF-8") + "&" + "message="
                    + URLEncoder.encode(message, "UTF-8");
            new SendSmsAsyncTask().execute(voipUrl);
            return;
        } catch (UnsupportedEncodingException ex) {
            Toast.makeText(context.getApplicationContext(),
                    "Send SMS: Email address or password contains invalid characters "
                            + "(UnsupportedOperationException)",
                    Toast.LENGTH_SHORT).show();
        }
    } else {
        Toast.makeText(context.getApplicationContext(), "Send SMS: Network connection unavailable",
                Toast.LENGTH_SHORT).show();
    }

    if (context instanceof ConversationActivity) {
        ProgressBar progressBar = (ProgressBar) ((ConversationActivity) context)
                .findViewById(R.id.progress_bar);
        progressBar.setVisibility(View.INVISIBLE);
    }
}

From source file:com.giovanniterlingen.windesheim.view.Adapters.NatschoolContentAdapter.java

@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
    final TextView contentName = holder.contentName;
    final ImageView icon = holder.icon;
    final FrameLayout menuButton = holder.menuButton;
    final ImageView menuButtonImage = holder.menuButtonImage;
    contentName.setText(content.get(position).name);
    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override/*ww w.java  2s.  c o m*/
        public void onClick(View v) {
            onContentClick(content.get(holder.getAdapterPosition()), holder.getAdapterPosition());
        }
    });
    if (content.get(position).type == -1) {
        icon.setImageDrawable(ResourcesCompat.getDrawable(activity.getResources(),
                getDrawableByName(content.get(position).name), null));
        menuButton.setVisibility(View.VISIBLE);
        menuButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                menuButtonImage.setImageDrawable(
                        ResourcesCompat.getDrawable(activity.getResources(), R.drawable.overflow_open, null));
                PopupMenu popupMenu = new PopupMenu(activity, menuButton);
                popupMenu.inflate(R.menu.menu_file);
                popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                    public boolean onMenuItemClick(MenuItem item) {
                        if (item.getItemId() == R.id.delete_file) {
                            showPromptDialog(holder.getAdapterPosition());
                            return true;
                        }
                        return true;
                    }
                });
                popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() {
                    @Override
                    public void onDismiss(PopupMenu menu) {
                        menuButtonImage.setImageDrawable(ResourcesCompat.getDrawable(activity.getResources(),
                                R.drawable.overflow_normal, null));
                    }
                });
                popupMenu.show();
            }
        });
    } else if (content.get(position).url == null || (content.get(position).url.length() == 0)) {
        if (content.get(position).imageUrl != null) {
            icon.setImageDrawable(
                    ResourcesCompat.getDrawable(activity.getResources(), R.drawable.ic_work, null));
        } else {
            icon.setImageDrawable(
                    ResourcesCompat.getDrawable(activity.getResources(), R.drawable.ic_folder, null));
        }
    } else {
        if (content.get(position).type == 1 || content.get(position).type == 3
                || content.get(position).type == 11) {
            icon.setImageDrawable(
                    ResourcesCompat.getDrawable(activity.getResources(), R.drawable.ic_link, null));
        } else if (content.get(position).type == 10) {
            icon.setImageDrawable(ResourcesCompat.getDrawable(activity.getResources(),
                    getDrawableByName(content.get(position).url), null));

            final TextView progressTextView = holder.progressTextView;
            final ProgressBar progressBar = holder.progressBar;
            final FrameLayout cancelButton = holder.cancelButton;

            if (content.get(position).downloading) {
                contentName.setVisibility(View.GONE);
                progressTextView.setVisibility(View.VISIBLE);
                progressBar.setVisibility(View.VISIBLE);
                if (content.get(position).progress == -1 && content.get(position).progressString == null) {
                    progressTextView.setText(activity.getResources().getString(R.string.downloading));
                    progressBar.setIndeterminate(true);
                } else {
                    progressTextView.setText(content.get(position).progressString);
                    progressBar.setIndeterminate(false);
                    progressBar.setMax(100);
                    progressBar.setProgress(content.get(position).progress);
                }
                cancelButton.setVisibility(View.VISIBLE);
                cancelButton.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        NotificationCenter.getInstance().postNotificationName(
                                NotificationCenter.downloadCancelled,
                                content.get(holder.getAdapterPosition()).id);
                        contentName.setVisibility(View.VISIBLE);
                        progressTextView.setVisibility(View.GONE);
                        progressBar.setVisibility(View.GONE);
                        cancelButton.setVisibility(View.GONE);
                    }
                });
            } else {
                contentName.setVisibility(View.VISIBLE);
                progressTextView.setVisibility(View.GONE);
                progressBar.setVisibility(View.GONE);
                cancelButton.setVisibility(View.GONE);
            }
        }
    }
}

From source file:com.sonymobile.dronecontrol.activity.MainActivity.java

private void loadLicense() {
    View view = getLayoutInflater().inflate(R.layout.licenses, null);

    Dialog dialog = new AlertDialog.Builder(this).setPositiveButton(R.string.settings_button_ok, null)
            .setView(view).setTitle(getString(R.string.settings_item_licenses)).create();

    final WebView webView = (WebView) view.findViewById(R.id.license_view);
    final ProgressBar webProgress = (ProgressBar) view.findViewById(R.id.license_progress);
    webProgress.setVisibility(View.VISIBLE);

    dialog.setOnDismissListener(new OnDismissListener() {
        @Override//from  ww  w.ja v a  2  s  .  c  o m
        public void onDismiss(DialogInterface dialog) {
            webView.stopLoading();
        }
    });

    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }

        @Override
        public void onScaleChanged(WebView view, float oldScale, float newScale) {
            super.onScaleChanged(view, oldScale, newScale);
            webProgress.setVisibility(View.GONE);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            webProgress.setVisibility(View.GONE);
        }
    });

    webView.loadUrl("file:///android_asset/licenses.html");
    dialog.show();
}

From source file:com.lastorder.pushnotifications.data.ImageDownloader.java

/**
 * Same as download but the image is always downloaded and the cache is not used.
 * Kept private at the moment as its interest is not clear.
 *//*from  w  w  w  .ja v  a  2 s .  co  m*/
private void forceDownload(String url, ImageView imageView, ProgressBar bar) {
    // State sanity: url is guaranteed to never be null in DownloadedDrawable and cache keys.
    if (url == null || !url.contains(".") || url.length() <= 6 || url.contains("null")) {
        bar.setVisibility(8);
        imageView.setImageResource(R.drawable.ic_launcher);
        imageView.setVisibility(0);
        return;
    }

    if (cancelPotentialDownload(url, imageView)) {
        BitmapDownloaderTask task = new BitmapDownloaderTask(imageView, bar);
        DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task);
        imageView.setImageDrawable(downloadedDrawable);
        imageView.setMinimumHeight(156);
        task.execute(url);
    }
}

From source file:com.binroot.fatpita.BitmapManager.java

public void fetchBitmapOnThread(final String urlString, final ImageView imageView,
        final ProgressBar indeterminateProgressBar, final Activity act, final boolean saveToHistory) {
    SoftReference<Bitmap> ref = mCache.get(urlString);
    if (ref != null && ref.get() != null) {
        imageView.setImageBitmap(ref.get());
        return;/*from   w ww.  ja v a 2 s. c o m*/
    }

    final Runnable progressBarShow = new Runnable() {
        public void run() {
            if (indeterminateProgressBar != null) {
                imageView.setVisibility(View.GONE);
                indeterminateProgressBar.setVisibility(View.VISIBLE);
            }
        }
    };
    final Runnable progressBarHide = new Runnable() {
        public void run() {
            if (indeterminateProgressBar != null) {
                indeterminateProgressBar.setVisibility(View.GONE);
                imageView.setVisibility(View.VISIBLE);
            }
        }
    };

    final Handler handler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            if (indeterminateProgressBar != null && act != null)
                act.runOnUiThread(progressBarHide);
            imageView.setImageBitmap((Bitmap) message.obj);
        }
    };

    Thread thread = new Thread() {
        @Override
        public void run() {
            if (indeterminateProgressBar != null && act != null)
                act.runOnUiThread(progressBarShow);
            Bitmap bitmap = fetchBitmap(urlString, saveToHistory);
            Message message = handler.obtainMessage(1, bitmap);
            handler.sendMessage(message);
        }
    };
    thread.start();
}

From source file:in.ac.dtu.subtlenews.InstapaperViewer.java

@SuppressLint("NewApi")
@Override//from w w  w  .  j a  v  a  2s .c o m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        setImmersive(true);
    }
    setTheme(R.style.AppTheme_NoActionBar);

    setContentView(R.layout.activity_instapaper_viewer);
    //setupActionBar();

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        urlId = extras.getInt("URLID");
        urlList = extras.getStringArrayList("URLList");

    }
    final WebView instapaperView = (WebView) findViewById(R.id.instapaper_viewer);
    final Activity activity = this;
    final ProgressBar progressBar;
    progressBar = (ProgressBar) findViewById(R.id.progressBar);

    instapaperView.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress) {
            if (progress < 100 && progressBar.getVisibility() == ProgressBar.GONE) {
                progressBar.setVisibility(ProgressBar.VISIBLE);
                //txtview.setVisibility(View.VISIBLE);
            }
            progressBar.setProgress(progress);
            if (progress == 100) {
                progressBar.setVisibility(ProgressBar.GONE);
                //txtview.setVisibility(View.GONE);
            }
        }
    });

    final View controlsView = findViewById(R.id.fullscreen_content_controls);
    final View contentView = findViewById(R.id.instapaper_viewer);

    final Button prevButton = (Button) findViewById(R.id.summary_prev_button);
    final Button nextButton = (Button) findViewById(R.id.summary_next_button);

    // Set up an instance of SystemUiHider to control the system UI for
    // this activity.
    mSystemUiHider = SystemUiHider.getInstance(this, contentView, HIDER_FLAGS);
    mSystemUiHider.setup();
    mSystemUiHider.setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() {
        // Cached values.
        int mControlsHeight;
        int mShortAnimTime;

        @Override
        @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
        public void onVisibilityChange(boolean visible) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                // If the ViewPropertyAnimator API is available
                // (Honeycomb MR2 and later), use it to animate the
                // in-layout UI controls at the bottom of the
                // screen.
                if (mControlsHeight == 0) {
                    mControlsHeight = controlsView.getHeight();
                }
                if (mShortAnimTime == 0) {
                    mShortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
                }
                controlsView.animate().translationY(visible ? 0 : mControlsHeight).setDuration(mShortAnimTime);
            } else {
                // If the ViewPropertyAnimator APIs aren't
                // available, simply show or hide the in-layout UI
                // controls.
                controlsView.setVisibility(visible ? View.VISIBLE : View.GONE);
            }

            if (visible && AUTO_HIDE) {
                // Schedule a hide().
                delayedHide(AUTO_HIDE_DELAY_MILLIS);
            }

        }
    });

    // Set up the user interaction to manually show or hide the system UI.
    contentView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (TOGGLE_ON_CLICK) {
                mSystemUiHider.toggle();
            } else {
                mSystemUiHider.show();
            }
        }
    });

    // Upon interacting with UI controls, delay any scheduled hide()
    // operations to prevent the jarring behavior of controls going away
    // while interacting with the UI.
    prevButton.setOnTouchListener(mDelayHideTouchListener);
    nextButton.setOnTouchListener(mDelayHideTouchListener);

    try {
        summaryUrl = "http://www.instapaper.com/text?u=" + urlList.get(urlId);
    } catch (Exception e) {
        e.printStackTrace();
    }

    instapaperView.loadUrl(summaryUrl);
    prevButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            try {
                summaryUrl = "http://www.instapaper.com/text?u=" + urlList.get(--urlId);
            } catch (Exception e) {
                e.printStackTrace();
            }
            instapaperView.loadUrl(summaryUrl);
        }
    });
    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            try {
                summaryUrl = "http://www.instapaper.com/text?u=" + urlList.get(++urlId);
            } catch (Exception e) {
                e.printStackTrace();
            }
            instapaperView.loadUrl(summaryUrl);
        }
    });

}

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

protected void startLoading() {
    //Log.d(TAG,"startLoading()");
    getSherlockActivity().setSupportProgressBarIndeterminateVisibility(Boolean.TRUE);
    ProgressBar pbLoading = (ProgressBar) getSherlockActivity().findViewById(R.id.progressbar_downloading);
    mHelpTextBig.setText(R.string.helptext_PastyActivity_loading);
    pbLoading.setVisibility(View.VISIBLE);
    pbLoading = null;//from  ww  w . j a  va  2 s .  co  m
    Bundle b = new Bundle();

    // first time we call this loader, so we need to create a new one
    getSherlockActivity().getSupportLoaderManager().initLoader(PastyLoader.TASK_CLIPBOARD_FETCH, b, this);
    b = null;
}

From source file:com.velia_systems.menuphoto.connection.ImageDownloader.java

/**
 * Download the specified image from the Internet and binds it to the provided ImageView. The
 * binding is immediate if the image is found in the cache and will be done asynchronously
 * otherwise. A null bitmap will be associated to the ImageView if an error occurs.
 *
 * @param url The URL of the image to download.
 * @param imageView The ImageView to bind the downloaded image to.
 *///from   w  w  w .ja  v  a2  s . c  o m
public void download(String url, ImageView imageView, ProgressBar progress) {
    resetPurgeTimer();
    Bitmap bitmap = getBitmapFromCache(url);
    if (bitmap == null) {
        forceDownload(url, imageView, bitmap, progress);
    } else {
        cancelPotentialDownload(url, imageView);
        imageView.setImageBitmap(bitmap);
        progress.setVisibility(View.GONE);
    }
}