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:remoteeyes.bsp.vn.uilt.ImageWorker.java

public void loadGalleryImage(Object data, RecyclingImageView imageView, ProgressBar progressBarGallery,
        TextView txtLabel) {/*w w  w.  j  av  a  2  s . com*/
    if (data == null) {
        return;
    }

    BitmapDrawable value = null;

    if (mImageCache != null) {
        value = mImageCache.getBitmapFromMemCache(String.valueOf(data));
    }

    if (value != null) {
        // Bitmap found in memory cache
        imageView.setImageDrawable(value);
        imageView.setVisibility(View.VISIBLE);
        progressBarGallery.setVisibility(View.INVISIBLE);
        txtLabel.setVisibility(View.INVISIBLE);
    } else if (cancelPotentialWork(data, imageView)) {
        final BitmapWorkerTask task = new BitmapWorkerTask(imageView);
        final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task);
        imageView.setImageDrawable(asyncDrawable);
        // TODO
        new mAsynctask(imageView, progressBarGallery, txtLabel).execute();

        // NOTE: This uses a custom version of AsyncTask that has been
        // pulled from the
        // framework and slightly modified. Refer to the docs at the top of
        // the class
        // for more info on what was changed.
        task.executeOnExecutor(AsyncTask.DUAL_THREAD_EXECUTOR, data);
    }
}

From source file:org.alfresco.mobile.android.application.fragments.node.browser.ProgressNodeAdapter.java

@Override
protected void updateTopText(TwoLinesProgressViewHolder vh, Node item) {
    ProgressBar progressView = vh.progress;

    if (item instanceof NodePlaceHolder) {
        vh.topText.setText(item.getName());
        vh.topText.setEnabled(false);/*from  w w w  .j ava  2s  .c om*/
        long totalSize = ((NodePlaceHolder) item).getLength();

        if ((Integer) item.getPropertyValue(PublicAPIPropertyIds.REQUEST_STATUS) == Operation.STATUS_PAUSED
                || (Integer) item
                        .getPropertyValue(PublicAPIPropertyIds.REQUEST_STATUS) == Operation.STATUS_PENDING) {
            progressView.setVisibility(View.GONE);
        } else {
            progressView.setVisibility(View.VISIBLE);
            progressView.setIndeterminate(false);
            if (totalSize == -1) {
                progressView.setMax(MAX_PROGRESS);
                progressView.setProgress(0);
            } else {
                long progress = ((NodePlaceHolder) item).getProgress();
                float value = (((float) progress / ((float) totalSize)) * MAX_PROGRESS);
                int percentage = Math.round(value);

                if (percentage == MAX_PROGRESS) {
                    if ((Integer) item
                            .getPropertyValue(PublicAPIPropertyIds.REQUEST_TYPE) == DownloadRequest.TYPE_ID) {
                        progressView.setVisibility(View.GONE);
                        super.updateTopText(vh, item);
                        vh.bottomText.setVisibility(View.VISIBLE);
                        super.updateBottomText(vh, item);
                        super.updateIcon(vh, item);
                    } else {
                        progressView.setIndeterminate(true);
                    }
                } else {
                    progressView.setIndeterminate(false);
                    progressView.setMax(MAX_PROGRESS);
                    progressView.setProgress(percentage);
                }
            }
        }
    } else {
        progressView.setVisibility(View.GONE);
        super.updateTopText(vh, item);
    }
}

From source file:android.kostalms.fragment.WebViewFragment.java

@SuppressLint("SetJavaScriptEnabled")
@Override/*from w  ww  . ja v a  2 s.  c  om*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // xml   .
    final View v = inflater.inflate(R.layout.webview, container, false);

    // viewContentProgress has a
    final ProgressBar viewContentProgress = (ProgressBar) v.findViewById(R.id.progress);

    // viewContentWebView has a
    viewContentWebView = (WebView) v.findViewById(R.id.webview);
    viewContentWebView.getSettings().setJavaScriptEnabled(true);
    viewContentWebView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return super.shouldOverrideUrlLoading(view, url);
        }
    });

    // WebChromeClient    .
    viewContentWebView.setWebChromeClient(new WebChromeClient() {

        //    
        @Override
        public void onProgressChanged(WebView view, int newProgress) {

            // viewContentProgress set
            viewContentProgress.setProgress(newProgress);

            // 100   .    .
            viewContentProgress.setVisibility(newProgress == 100 ? View.GONE : View.VISIBLE);

            //      url   ?
            //     .
            if (newProgress == 100 && resetHistory) {
                viewContentWebView.clearHistory();
                resetHistory = false;
            }
        }
    });
    return v;
}

From source file:fm.krui.kruifm.StreamFragment.java

/**
 * Enables and disables the loading indicator for UI views.
 * @param showLoadingIndicator True to enable, false to disable.
 *///  w  ww.jav a2 s.  c o  m
private void setLoadingIndicator(final boolean showLoadingIndicator) {
    Log.v(TAG, "setLoadingIndicator called!");
    Log.v(TAG, "Called with " + showLoadingIndicator + " parameter.");
    // Instantiate views
    ProgressBar progressBar = (ProgressBar) getActivity().findViewById(R.id.album_art_progressbar);
    ImageView albumArtPaneImageView = (ImageView) getActivity().findViewById(R.id.album_art_pane);
    ImageView albumArtLoadingPaneImageView = (ImageView) getActivity()
            .findViewById(R.id.album_art_loading_pane);
    if (showLoadingIndicator) {
        // Show loading indicators
        progressBar.setVisibility(View.VISIBLE);
        albumArtLoadingPaneImageView.setVisibility(View.VISIBLE);
        albumArtPaneImageView.setVisibility(View.INVISIBLE);

    } else {
        // Hide progressBar and placeholder image and re-show album art pane.
        progressBar.setVisibility(View.INVISIBLE);
        albumArtLoadingPaneImageView.setVisibility(View.INVISIBLE);
        albumArtPaneImageView.setVisibility(View.VISIBLE);
    }
}

From source file:fm.krui.kruifm.StreamActivity.java

/**
 * Enables and disables the loading indicator for UI views.
 * @param showLoadingIndicator True to enable, false to disable.
 *///from  w  ww  . j  av a 2 s.  c o m
private void setLoadingIndicator(final boolean showLoadingIndicator) {
    Log.v(TAG, "setLoadingIndicator called!");
    Log.v(TAG, "Called with " + showLoadingIndicator + " parameter.");
    // Instantiate views
    ProgressBar progressBar = (ProgressBar) this.findViewById(R.id.album_art_progressbar);
    ImageView albumArtPaneImageView = (ImageView) this.findViewById(R.id.album_art_pane);
    ImageView albumArtLoadingPaneImageView = (ImageView) this.findViewById(R.id.album_art_loading_pane);
    if (showLoadingIndicator) {
        // Show loading indicators
        progressBar.setVisibility(View.VISIBLE);
        albumArtLoadingPaneImageView.setVisibility(View.VISIBLE);
        albumArtPaneImageView.setVisibility(View.INVISIBLE);

    } else {
        // Hide progressBar and placeholder image and re-show album art pane.
        progressBar.setVisibility(View.INVISIBLE);
        albumArtLoadingPaneImageView.setVisibility(View.INVISIBLE);
        albumArtPaneImageView.setVisibility(View.VISIBLE);
    }
}

From source file:fr.bmartel.android.flowerpower.FlowerPowerActivity.java

/**
 * trigger a BLE scan//  ww w.  j a  va2s.c o m
 */
public void triggerNewScan() {

    Button button_stop_scanning = (Button) findViewById(R.id.stop_scanning_button);
    ProgressBar progress_bar = (ProgressBar) findViewById(R.id.scanningProgress);
    TextView scanText = (TextView) findViewById(R.id.scanText);

    if (button_stop_scanning != null && progress_bar != null && scanText != null) {
        if (!currentService.isScanning()) {

            Toast.makeText(FlowerPowerActivity.this, "Looking for new accessories", Toast.LENGTH_SHORT).show();

            if (button_stop_scanning != null)
                button_stop_scanning.setEnabled(true);

            if (progress_bar != null) {
                progress_bar.setEnabled(true);
                progress_bar.setVisibility(View.VISIBLE);
            }

            if (scanText != null)
                scanText.setText("Scanning ...");

            //start scan so clear list view
            currentService.getListViewAdapter().clear();
            currentService.getListViewAdapter().notifyDataSetChanged();

            currentService.clearListAdapter();

            currentService.scanLeDevice(true);
        } else {
            Toast.makeText(FlowerPowerActivity.this, "Scanning already engaged...", Toast.LENGTH_SHORT).show();
        }
    }
}

From source file:fr.bmartel.android.dotti.DottiActivity.java

/**
 * trigger a BLE scan//from  ww w . j ava2 s  . c  o  m
 */
public void triggerNewScan() {

    Button button_stop_scanning = (Button) findViewById(R.id.stop_scanning_button);
    ProgressBar progress_bar = (ProgressBar) findViewById(R.id.scanningProgress);
    TextView scanText = (TextView) findViewById(R.id.scanText);

    if (button_stop_scanning != null && progress_bar != null && scanText != null) {
        if (currentService != null && !currentService.isScanning()) {

            Toast.makeText(DottiActivity.this, "Looking for new accessories", Toast.LENGTH_SHORT).show();

            if (button_stop_scanning != null)
                button_stop_scanning.setEnabled(true);

            if (progress_bar != null) {
                progress_bar.setEnabled(true);
                progress_bar.setVisibility(View.VISIBLE);
            }

            if (scanText != null)
                scanText.setText("Scanning ...");

            //start scan so clear list view
            currentService.getListViewAdapter().clear();
            currentService.getListViewAdapter().notifyDataSetChanged();
            currentService.clearListAdapter();

            Log.i(TAG, "START SCAN");

            currentService.disconnectall();

            currentService.scanLeDevice(true);

        } else {
            Toast.makeText(DottiActivity.this, "Scanning already engaged...", Toast.LENGTH_SHORT).show();
        }
    }
}

From source file:com.umeng.comm.ui.imagepicker.adapters.ImagePagerAdapter.java

/**
 * ,ImageItem?,originImage?true./*from  www . j av  a2  s .  c o m*/
 * 
 * @param imageView ImageView
 * @param progressBar ?
 * @param image ImageItem
 * @param originImage ?
 */
private void displayImage(ImageView imageView, final ProgressBar progressBar, final ImageItem image,
        boolean originImage) {
    String imageUrl = originImage ? image.originImageUrl : image.middleImageUrl;
    // URLMD5,
    storeImageItemMd5(imageUrl);
    // 
    Bitmap bitmap = LocalImageLoader.getInstance().loadBitmap(imageUrl, getSize(imageView));
    ImgDisplayOption option = null;
    if (bitmap == null) {
        option = ImgDisplayOption.getCommonDisplayOption();
    } else {
        imageView.setImageBitmap(bitmap);
        option = new ImgDisplayOption();
    }
    // ?
    option.requestOrigin = true;
    mImageLoader.displayImage(imageUrl, imageView, option, new ImageLoadingListener() {

        @Override
        public void onLoadingStarted(String imageUri, View view) {
            // Dialog
            progressBar.setVisibility(View.VISIBLE);
        }

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

        }

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            // Dialog
            progressBar.setVisibility(View.GONE);
            if (view == null) {
                return;
            }

            ScaleImageView imageView = (ScaleImageView) view;
            if (isUriEqualsWithImageViewTag(imageView.getTag(), imageUri) && loadedImage != null) {
                imageView.setImageBitmap(loadedImage);
                imageView.updateScale();
            }
        }
    });
}

From source file:com.crearo.gpslogger.GpsMainActivity.java

public void onWaitingForLocation(boolean inProgress) {
    ProgressBar fixBar = (ProgressBar) findViewById(R.id.progressBarGpsFix);
    fixBar.setVisibility(inProgress ? View.VISIBLE : View.INVISIBLE);
}

From source file:com.velia_systems.menuphoto.connection.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.
 *///w ww . j a v  a  2 s .c  o  m
private void forceDownload(String url, ImageView imageView, Bitmap bitmap, ProgressBar progress) {
    // State sanity: url is guaranteed to never be null in DownloadedDrawable and cache keys.
    if (url == null) {
        imageView.setImageDrawable(null);
        return;
    }

    if (cancelPotentialDownload(url, imageView)) {
        switch (mode) {
        case NO_ASYNC_TASK:
            bitmap = downloadBitmap(url);
            //                    Log.d("ImageDownloader", "Sizes: " + bitmap.getWidth() + "x" + bitmap.getHeight());
            int width = bitmap.getWidth();
            int height = bitmap.getHeight();

            int destHeight = 100 * height / width;

            Bitmap bmp1 = Bitmap.createScaledBitmap(bitmap, 100, destHeight, false);
            bitmap.recycle();

            addBitmapToCache(url, bmp1);
            imageView.setImageBitmap(bmp1);
            progress.setVisibility(View.GONE);
            break;

        case NO_DOWNLOADED_DRAWABLE:
            imageView.setMinimumHeight(50);
            BitmapDownloaderTask task = new BitmapDownloaderTask(imageView, progress);
            task.execute(url);
            break;

        case CORRECT:
            task = new BitmapDownloaderTask(imageView, progress);
            DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task);
            imageView.setImageDrawable(downloadedDrawable);
            imageView.setMinimumHeight(50);
            task.execute(url);
            break;
        }
    }
}