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:yet.another.hackernews.reader.ViewFragment.java

public void update(ProgressBar progressBar) {
    if (news == null) {
        return;/*from  w w w.jav  a 2  s.  c  om*/
    }

    if (progressBar == null) {
        progressBar = (ProgressBar) getSherlockActivity().findViewById(R.id.view_progress);
    }

    if (progressBar.getVisibility() != View.VISIBLE) {
        progressBar.setVisibility(View.VISIBLE);
    }

    if (menuBrowser.getProgress() < 100) {
        menuBrowser.stopLoading();
    }

    menuBrowser.loadUrl(news.getURL());
}

From source file:com.google.maps.android.utils.demo.HeatmapsPlacesDemoActivity.java

/**
 * Takes the input from the user and generates the required heatmap.
 * Called when a search query is submitted
 *///from   w ww  .  j  ava  2 s .  c  om
public void submit() {
    if ("YOUR_KEY_HERE".equals(API_KEY)) {
        Toast.makeText(this,
                "Please sign up for a Places API key and add it to HeatmapsPlacesDemoActivity.API_KEY",
                Toast.LENGTH_LONG).show();
        return;
    }
    EditText editText = (EditText) findViewById(R.id.input_text);
    String keyword = editText.getText().toString();
    if (mOverlays.contains(keyword)) {
        Toast.makeText(this, "This keyword has already been inputted :(", Toast.LENGTH_SHORT).show();
    } else if (mOverlaysRendered == MAX_CHECKBOXES) {
        Toast.makeText(this, "You can only input " + MAX_CHECKBOXES + " keywords. :(", Toast.LENGTH_SHORT)
                .show();
    } else if (keyword.length() != 0) {
        mOverlaysInput++;
        ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
        progressBar.setVisibility(View.VISIBLE);
        new MakeOverlayTask().execute(keyword);
        editText.setText("");

        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
    }
}

From source file:com.scm.reader.resultPage.ui.ItemViewFragment.java

@SuppressLint("SetJavaScriptEnabled")
@Override/*from ww  w .j  a v a  2  s  . c o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View v = inflater.inflate(R.layout.fragment_result, container, false);

    mWebView = (WebView) v.findViewById(R.id.webView);

    // set WebViewClient
    mWebViewClient = createWebViewClient(getActivity());
    mWebView.setWebViewClient(mWebViewClient);

    final ProgressBar progressBar = (ProgressBar) v.findViewById(R.id.progressBar);

    mWebView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int progress) {
            if (progress == 100) {
                progressBar.setVisibility(View.GONE);
            } else {
                progressBar.setVisibility(View.VISIBLE);
                progressBar.setProgress(progress);
            }
        }
    });

    initializeWebView(mWebView);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        if (0 != (getActivity().getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) {
            WebView.setWebContentsDebuggingEnabled(true);
        }
    }

    mWebView.loadUrl(mUrl);

    return v;
}

From source file:eu.inmite.apps.smsjizdenka.dialog.EulaDialogFragment.java

private View getCustomView() {
    View customView = LayoutInflater.from(getActivity()).inflate(R.layout.view_eula_dialog, null);
    final TextView txtEulaContent = (TextView) customView.findViewById(R.id.txt_eula_content);
    final ProgressBar progressWheel = (ProgressBar) customView.findViewById(R.id.progress_bar);

    new BaseAsyncTask() {
        String eula;/*w w w .j av  a2 s.com*/
        Spanned spannedEula;

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            progressWheel.setVisibility(View.VISIBLE);
        }

        @Override
        public void doInBackground() {
            eula = getStringFromAssets(getActivity(), "eula.html");
            spannedEula = Html.fromHtml(eula);
        }

        @Override
        public void onPostExecute() {
            super.onPostExecute();
            progressWheel.setVisibility(View.GONE);
            txtEulaContent.setText(spannedEula);

        }
    }.start();

    return customView;
}

From source file:fr.unix_experience.owncloud_sms.activities.remote_account.RestoreMessagesActivity.java

private void errorNotification(int err) {
    TextView tv = (TextView) findViewById(R.id.tv_error_default_smsapp);
    Button fix_button = (Button) findViewById(R.id.button_fix_permissions);
    Button launch_restore = (Button) findViewById(R.id.button_launch_restore);
    ProgressBar pb = (ProgressBar) findViewById(R.id.progressbar_restore);
    tv.setText(err);//w w  w .j a va2 s  . co  m
    tv.setVisibility(View.VISIBLE);
    fix_button.setVisibility(View.INVISIBLE);
    launch_restore.setVisibility(View.INVISIBLE);
    pb.setVisibility(View.INVISIBLE);
}

From source file:io.github.minime89.passbeam.activities.KeyboardLayoutActivity.java

private void setupKeyboardLayoutMenu() {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        ProgressBar progressBar = new ProgressBar(this);
        progressBar.setVisibility(View.GONE);
        progressBar.setIndeterminate(true);

        ActionBar.LayoutParams layoutParams = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
                ActionBar.LayoutParams.WRAP_CONTENT, Gravity.END | Gravity.CENTER_VERTICAL);
        progressBar.setLayoutParams(layoutParams);

        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(progressBar);
    }/*from   w  ww.  j av  a2  s.  c om*/
}

From source file:org.ciasaboark.tacere.activity.fragment.BugReportDialogFragment.java

@Nullable
@Override/*from www . j ava  2 s.  c  o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.activity_bug_report, container, false);

    final Spinner spinner = (Spinner) rootView.findViewById(R.id.spinner);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.report_types,
            android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    spinner.setAdapter(adapter);

    Button closeButton = (Button) rootView.findViewById(R.id.bug_report_button_cancel);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            BugReportDialogFragment.this.dismiss();
        }
    });

    final Button sendButton = (Button) rootView.findViewById(R.id.bug_report_button_send);
    sendButton.setEnabled(false);
    sendButton.setVisibility(View.INVISIBLE);
    sendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            sendButton.setEnabled(false);

            final ProgressBar busySpinner = (ProgressBar) rootView.findViewById(R.id.bug_report_progressbar);
            busySpinner.setVisibility(View.VISIBLE);

            EditText messageEditText = (EditText) rootView.findViewById(R.id.bug_report_message);
            final String messageText = messageEditText.getText().toString();

            EditText emailEditText = (EditText) rootView.findViewById(R.id.bug_report_email);
            String emailText = emailEditText.getText().toString();
            final String emailString = emailText.length() == 0 ? "no email address given" : emailText;

            final String spinnerSelection = spinner.getSelectedItem() == null ? "bug"
                    : spinner.getSelectedItem().toString();

            new Thread(new Runnable() {
                @Override
                public void run() {
                    boolean reportSent = false;
                    GitHubClient client = new GitHubClient();
                    client.setOAuth2Token(GitHubKeySet.GITHUB_OAUTH);

                    RepositoryService repositoryService = new RepositoryService(client);
                    try {
                        Repository repository = repositoryService.getRepository("ciasaboark", "Tacere");

                        IssueService issueService = new IssueService();
                        issueService.getClient().setOAuth2Token(GitHubKeySet.GITHUB_OAUTH);
                        Issue issue = new Issue();
                        issue.setTitle("Tacere issue submit");

                        String bodyText = "";
                        bodyText += messageText;
                        bodyText += "\n\nEmail : " + emailString;
                        bodyText += "\nAndroid Version: " + Build.VERSION.RELEASE;
                        bodyText += "\nTacere version: " + Versioning.getVersionCode();
                        bodyText += "\nDevice: " + Build.MANUFACTURER + " - " + Build.MODEL;
                        bodyText += "\nRom: " + Build.DISPLAY;

                        issue.setBody(bodyText);

                        Label label = new Label();
                        label.setName("autosubmit");
                        List<Label> labels = new ArrayList<Label>();
                        labels.add(label);

                        String reportTypeLabel;
                        switch (spinnerSelection.toLowerCase()) {
                        case "bug":
                            reportTypeLabel = "bug";
                            break;
                        case "wishlist":
                            reportTypeLabel = "wishlist";
                            break;
                        default:
                            Log.w(TAG, "unknown reportType " + spinnerSelection + ", assuming to "
                                    + "be a bug report");
                            reportTypeLabel = "bug";
                        }

                        Label reportLabel = new Label();
                        reportLabel.setName(reportTypeLabel);
                        labels.add(reportLabel);
                        issue.setLabels(labels);

                        UserService userService = new UserService(client);
                        User user = userService.getUser("ciasaboark");
                        issue.setAssignee(user);

                        try {
                            issueService.createIssue(repository, issue);
                            reportSent = true;
                        } catch (IOException e) {
                            Log.e(TAG, "unable to create issue in repository");
                        }

                    } catch (IOException e) {
                        Log.e(TAG, "unable to get list of user repositories");
                    }

                    if (reportSent) {
                        getActivity().runOnUiThread(new Runnable() {
                            public void run() {
                                Toast.makeText(getActivity(), R.string.bug_report_toast_sent, Toast.LENGTH_LONG)
                                        .show();
                                BugReportDialogFragment.this.dismiss();

                            }
                        });
                    } else {
                        getActivity().runOnUiThread(new Runnable() {
                            public void run() {
                                Toast.makeText(getActivity(), R.string.bug_report_toast_failed,
                                        Toast.LENGTH_LONG).show();
                                busySpinner.setVisibility(View.INVISIBLE);
                                sendButton.setEnabled(true);
                                sendButton.setVisibility(View.VISIBLE);
                            }
                        });
                    }
                }
            }).start();

        }
    });

    EditText messageEditText = (EditText) rootView.findViewById(R.id.bug_report_message);
    messageEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            //nothing to do here
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            //nothing to do here
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (s.length() > 0) {
                sendButton.setVisibility(View.VISIBLE);
                sendButton.setEnabled(true);
            } else {
                sendButton.setVisibility(View.INVISIBLE);
                sendButton.setEnabled(false);
            }
        }
    });

    return rootView;
}

From source file:com.richtodd.android.quiltdesign.app.MainActivity.java

synchronized void setSampleLoaderTask(AsyncTask<?, ?, ?> task) {
    if (s_sampleLoaderTask != null) {
        throw new IllegalStateException("Sample loader task already in progress.");
    }/*w w w  .  ja  v a 2 s .c o m*/

    s_sampleLoaderTask = task;

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

From source file:com.richtodd.android.quiltdesign.app.MainActivity.java

synchronized void clearSampleLoaderTask(AsyncTask<?, ?, ?> task) {
    if (s_sampleLoaderTask != task) {
        throw new IllegalStateException("Sample loader task not in progress.");
    }//  w ww .  jav  a  2s. c  om

    s_sampleLoaderTask = null;

    ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
    progressBar.setVisibility(View.GONE);
}

From source file:com.temboo.example.FoursquareConnectedActivity.java

/**
 * Get the nearest Foursquare venue ID for the current location
 * @throws TembooException//w w  w  .ja v  a  2s .c om
 */
public void getFoursquareVenueForCurrentLocation() throws Exception {

    if (currentLocation == null) {
        Toast.makeText(FoursquareConnectedActivity.this, "Waiting for location", Toast.LENGTH_SHORT).show();
        return;
    }

    // Show spinner
    ProgressBar b = (ProgressBar) findViewById(R.id.spinner);
    b.setVisibility(View.VISIBLE);

    // Begin a new thread that will actually perform the Foursquare venue query; after completing the query, the thread
    // will call the gotVenue handler below, to return results to the UI. We do this so that the Foursquare lookup
    // doesn't block the UI.
    Thread t = new Thread(new FoursquareVenueGetter(session, currentLocation));
    t.start();
}