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.norman0406.slimgress.FragmentInventory.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_inventory, container, false);

    final ExpandableListView list = (ExpandableListView) rootView.findViewById(R.id.listView);
    final ProgressBar progress = (ProgressBar) rootView.findViewById(R.id.progressBar1);

    list.setVisibility(View.INVISIBLE);
    progress.setVisibility(View.VISIBLE);

    // create group names
    mGroupNames = new ArrayList<String>();
    mGroups = new ArrayList<Object>();

    mGroupMedia = new ArrayList<String>();
    mGroupMods = new ArrayList<String>();
    mGroupPortalKeys = new ArrayList<String>();
    mGroupPowerCubes = new ArrayList<String>();
    mGroupResonators = new ArrayList<String>();
    mGroupWeapons = new ArrayList<String>();

    final FragmentInventory thisObject = this;

    final Handler handler = new Handler();

    mGame.intGetInventory(new Handler(new Handler.Callback() {
        @Override/* www.j a  va  2s  .c  o  m*/
        public boolean handleMessage(Message msg) {
            fillInventory(new Runnable() {
                @Override
                public void run() {
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            InventoryList inventoryList = new InventoryList(mGroupNames, mGroups);
                            inventoryList.setInflater(inflater, thisObject.getActivity());
                            list.setAdapter(inventoryList);
                            list.setOnChildClickListener(thisObject);

                            list.setVisibility(View.VISIBLE);
                            progress.setVisibility(View.INVISIBLE);
                        }
                    });
                }
            });
            return true;
        }
    }));

    return rootView;
}

From source file:yet.another.hackernews.reader.ViewFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    menuBrowser = (WebView) getSherlockActivity().findViewById(R.id.view_webview);

    final ProgressBar progressBar = (ProgressBar) getSherlockActivity().findViewById(R.id.view_progress);

    webviewSettings();//  w ww.  ja  v a  2s  . co m

    menuBrowser.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int progress) {
            // Hide dialog on finished
            if (progress >= 100) {
                progressBar.setVisibility(View.GONE);
            } else {
                progressBar.setProgress(progress);
            }

        }
    });

    menuBrowser.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {

            progressBar.setVisibility(View.GONE);

            Toast.makeText(getActivity().getApplicationContext(), R.string.error, Toast.LENGTH_SHORT).show();
        }
    });

    final Bundle recieveArgs = this.getSherlockActivity().getIntent().getExtras();

    if (recieveArgs != null) {
        try {
            news = new News(new JSONObject(recieveArgs.getString("NewsObject")));
        } catch (JSONException e) {
        }

        update(progressBar);
    }
}

From source file:edu.berkeley.boinc.attach.BatchConflictListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    final ProjectAttachWrapper listItem = entries.get(position);

    if (Logging.VERBOSE)
        Log.d(Logging.TAG, "BatchConflictListAdapter.getView for: " + listItem.name + " at position: "
                + position + " with result: " + listItem.result);

    LayoutInflater vi = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = vi.inflate(R.layout.attach_project_batch_conflicts_listitem, null);
    TextView name = (TextView) v.findViewById(R.id.name);
    name.setText(listItem.name);//  www.j a va 2  s .  c  om
    TextView status = (TextView) v.findViewById(R.id.status);
    ImageView resolveIv = (ImageView) v.findViewById(R.id.resolve_button_image);
    ImageView statusImage = (ImageView) v.findViewById(R.id.status_image);
    ProgressBar statusPb = (ProgressBar) v.findViewById(R.id.status_pb);
    RelativeLayout itemWrapper = (RelativeLayout) v.findViewById(R.id.resolve_item_wrapper);
    if (listItem.result == ProjectAttachWrapper.RESULT_SUCCESS) {
        // success
        status.setVisibility(View.GONE);
        resolveIv.setVisibility(View.GONE);
        statusPb.setVisibility(View.GONE);
        statusImage.setVisibility(View.VISIBLE);
        statusImage.setImageDrawable(activity.getResources().getDrawable(R.drawable.checkb));
    } else if (listItem.result == ProjectAttachWrapper.RESULT_ONGOING
            || listItem.result == ProjectAttachWrapper.RESULT_UNINITIALIZED) {
        // ongoing
        status.setVisibility(View.GONE);
        resolveIv.setVisibility(View.GONE);
        statusImage.setVisibility(View.GONE);
        statusPb.setVisibility(View.VISIBLE);
    } else if (listItem.result == ProjectAttachWrapper.RESULT_READY) {
        // ready
        status.setVisibility(View.VISIBLE);
        status.setText(listItem.getResultDescription());
        resolveIv.setVisibility(View.VISIBLE);
        itemWrapper.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Logging.DEBUG)
                    Log.d(Logging.TAG,
                            "BatchConflictListAdapter: start resolution dialog for: " + listItem.name);
                IndividualCredentialInputFragment dialog = IndividualCredentialInputFragment
                        .newInstance(listItem);
                dialog.show(fmgr, listItem.name);
            }
        });
    } else if (listItem.result == ProjectAttachWrapper.RESULT_CONFIG_DOWNLOAD_FAILED) {
        // download failed, can not continue from here.
        // if user wants to retry, need to go back to selection activity
        status.setVisibility(View.VISIBLE);
        status.setText(listItem.getResultDescription());
        resolveIv.setVisibility(View.GONE);
        statusPb.setVisibility(View.GONE);
        statusImage.setVisibility(View.VISIBLE);
        statusImage.setImageDrawable(activity.getResources().getDrawable(R.drawable.failedb));
    } else {
        // failed
        status.setVisibility(View.VISIBLE);
        status.setText(listItem.getResultDescription());
        resolveIv.setVisibility(View.VISIBLE);
        itemWrapper.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Logging.DEBUG)
                    Log.d(Logging.TAG,
                            "BatchConflictListAdapter: start resolution dialog for: " + listItem.name);
                IndividualCredentialInputFragment dialog = IndividualCredentialInputFragment
                        .newInstance(listItem);
                dialog.show(fmgr, listItem.name);
            }
        });
        statusPb.setVisibility(View.GONE);
        statusImage.setVisibility(View.VISIBLE);
        statusImage.setImageDrawable(activity.getResources().getDrawable(R.drawable.failedb));
    }
    return v;
}

From source file:de.zell.android.util.fragments.WebviewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_webview, container, false);
    if (url != null && !url.isEmpty()) {
        content = ((WebView) rootView.findViewById(R.id.webview));
        //WebViewClient is enabled in order to force all links to load within the webview and also
        // in order to enable JavaScript
        content.setWebViewClient(new HelloWebViewClient());
        WebSettings webSettings = content.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setBuiltInZoomControls(true);
        webSettings.setSupportZoom(true);

        final ProgressBar progressBar = ((MainNavigationActivity) getActivity()).getProgressBar();
        content.setWebChromeClient(new WebChromeClient() {
            @Override//from   w ww .  java 2 s  .  c  o m
            public void onProgressChanged(WebView view, int newProgress) {
                progressBar.setProgress(newProgress);
                if (newProgress == 100)
                    progressBar.setVisibility(View.GONE);
            }
        });

        progressBar.setIndeterminate(true);
        progressBar.setVisibility(View.VISIBLE);
        content.loadUrl(url);
    }

    getActivity().setTitle(title);
    return rootView;
}

From source file:cm.aptoide.pt.adapters.ViewPagerAdapterScreenshots.java

@Override
public Object instantiateItem(ViewGroup container, final int position) {

    final View v = LayoutInflater.from(context).inflate(R.layout.row_item_screenshots_big, null);
    final ProgressBar pb = (ProgressBar) v.findViewById(R.id.screenshots_loading_big);

    imageLoader.displayImage(hd ? url.get(position) : screenshotToThumb(url.get(position)),
            (ImageView) v.findViewById(R.id.screenshot_image_big), options, new ImageLoadingListener() {

                @Override// w  w  w.  j  a v a  2  s. c o m
                public void onLoadingStarted(String uri, View view) {
                    pb.setVisibility(View.VISIBLE);
                }

                @Override
                public void onLoadingFailed(String uri, View v, FailReason failReason) {
                    ((ImageView) v.findViewById(R.id.screenshot_image_big))
                            .setImageResource(android.R.drawable.ic_delete);
                    pb.setVisibility(View.GONE);
                }

                @Override
                public void onLoadingComplete(String uri, View v, Bitmap loadedImage) {
                    pb.setVisibility(View.GONE);
                }

                @Override
                public void onLoadingCancelled(String uri, View v) {
                }
            });
    container.addView(v);
    if (!hd) {
        v.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                Intent i = new Intent(context, ScreenshotsViewer.class);
                i.putStringArrayListExtra("url", url);
                i.putExtra("position", position);
                i.putExtra("hashCode", hashCode + ".hd");
                context.startActivity(i);
            }
        });
    }
    return v;

}

From source file:helix.profitkey.hotelapp.ImagePagerFragment.java

/**  Setting image in view pager **/
@Override//from   www  .  j ava2 s .c o m
public Object instantiateItem(ViewGroup view, int position) {
    View imageLayout = inflater.inflate(R.layout.item_pager_image, view, false);
    assert imageLayout != null;
    ImageView imageView = (ImageView) imageLayout.findViewById(R.id.image);
    final ProgressBar spinner = (ProgressBar) imageLayout.findViewById(R.id.loading);

    /** Started loading and display*/
    ImageLoader.getInstance().displayImage(image_url[position], imageView, options,
            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;
                    }
                    Toast.makeText(view.getContext(), message, Toast.LENGTH_SHORT).show();

                    spinner.setVisibility(View.GONE);
                }

                /** Hide the spinner after the image is loaded*/
                @Override
                public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                    spinner.setVisibility(View.GONE);
                }
            });

    /** Add the image to the viewPager*/
    view.addView(imageLayout, 0);
    return imageLayout;
}

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

private void updateMessage(final int id, final String error) {
    runOnUiThread(new Runnable() {
        @Override//from  w  w  w.j  a v  a 2 s  . c om
        public void run() {
            TextView view = (TextView) findViewById(R.id.message);
            view.setText(id);
            if (id == R.string.error_download) {
                final ProgressBar bar = (ProgressBar) findViewById(R.id.working);
                bar.setVisibility(ProgressBar.INVISIBLE);
                final TextView errormsg = (TextView) findViewById(R.id.error);
                errormsg.setText(error);
            }
        }
    });
}

From source file:com.ndn.menurandom.ImageDownloader.java

private void hideLoadingProgress(ImageView imageView) {
    FrameLayout frameLayout = (FrameLayout) imageView.getParent();
    ProgressBar progressBar = (ProgressBar) frameLayout.findViewWithTag("pb_imagedownloader");
    progressBar.setVisibility(View.INVISIBLE);
}

From source file:com.ndn.menurandom.ImageDownloader.java

private void showLoadingProgress(ImageView imageView) {
    if (mUseLoadingProgress) {
        FrameLayout frameLayout = (FrameLayout) imageView.getParent();
        ProgressBar progressBar = (ProgressBar) frameLayout.findViewWithTag("pb_imagedownloader");
        progressBar.setVisibility(View.VISIBLE);
    }/* w w  w  .  jav  a 2s.co  m*/
}

From source file:com.digium.respoke.GroupListActivity.java

public void onConnect(RespokeClient sender) {
    Button presenceButton = (Button) findViewById(R.id.button1);
    presenceButton.setVisibility(View.VISIBLE);
    ProgressBar progressCircle = (ProgressBar) findViewById(R.id.progress_circle);
    progressCircle.setVisibility(View.INVISIBLE);

    if (null != groupsToJoin) {
        rejoinGroups();/*from ww w.  j ava 2s.c  o  m*/
    }
}