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.ternup.caddisfly.activity.VideoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_video);

    final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
    File sdDir = this.getExternalFilesDir(null);
    final File videoFile = new File(sdDir, "training.mp4");

    if (videoFile.exists()) {
        playVideo(videoFile);//  ww  w  .ja  v a 2s .  c o  m
    } else {

        if (NetworkUtils.checkInternetConnection(this)) {
            progressBar.setVisibility(View.VISIBLE);
            downloading = true;
            AsyncHttpClient client = new AsyncHttpClient();
            client.get("http://caddisfly.ternup.com/akvoapp/caddisfly-training.mp4",
                    new FileAsyncHttpResponseHandler(videoFile) {
                        @Override
                        public void onFailure(int i, Header[] headers, Throwable throwable, File file) {
                            progressBar.setVisibility(View.GONE);
                        }

                        @Override
                        public void onSuccess(int statusCode, Header[] headers, File response) {
                            playVideo(response);
                            progressBar.setVisibility(View.GONE);
                        }

                        @Override
                        public void onProgress(int bytesWritten, int totalSize) {
                            //int progressPercentage = (int)100*bytesWritten/totalSize;
                            progressBar.setMax(totalSize);
                            progressBar.setProgress(bytesWritten);
                        }

                        @Override
                        public void onFinish() {
                            super.onFinish();
                            progressBar.setVisibility(View.GONE);
                            downloading = false;
                        }
                    });
        }
    }

}

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

/**
 * Perform a Foursquare checkin for the current venue
 * @throws TembooException//  w  ww .  ja va  2s.c  om
 */
private void doFoursquareCheckin() throws TembooException {

    // If the current venue isn't set, display a message and return
    if (currentVenueID == null) {
        Toast.makeText(FoursquareConnectedActivity.this, "Please look up the current venue first.",
                Toast.LENGTH_SHORT).show();
        return;
    }

    // Prevent duplicate checkins
    if (lastCheckinVenueID != null && lastCheckinVenueID.equals(currentVenueID)) {
        Toast.makeText(FoursquareConnectedActivity.this, "You've already checked in at " + currentVenueName,
                Toast.LENGTH_SHORT).show();
        return;
    }

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

    // Start a new thread that will actually perform the Foursquare checkin; after completing the checkin, the thread
    // will call the finishedCheckin handler below, to return results to the UI. We do this so that the Foursquare checkin
    // doesn't block the UI.
    Thread t = new Thread(new FoursquareCheckinTask(session, currentVenueID));
    t.start();
}

From source file:com.stephenmcgruer.threethingstoday.MainActivity.java

public void submitThreeThings() {
    ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
    progressBar.setVisibility(View.VISIBLE);

    String firstThingText = getTextFromEditText(R.id.first_edit_text);
    String secondThingText = getTextFromEditText(R.id.second_edit_text);
    String thirdThingText = getTextFromEditText(R.id.third_edit_text);

    ContentValues values = new ContentValues();
    values.put(ThreeThingsEntry.COLUMN_NAME_YEAR, mSelectedYear);
    values.put(ThreeThingsEntry.COLUMN_NAME_MONTH, mSelectedMonth);
    values.put(ThreeThingsEntry.COLUMN_NAME_DAY_OF_MONTH, mSelectedDayOfMonth);
    values.put(ThreeThingsEntry.COLUMN_NAME_FIRST_THING, firstThingText);
    values.put(ThreeThingsEntry.COLUMN_NAME_SECOND_THING, secondThingText);
    values.put(ThreeThingsEntry.COLUMN_NAME_THIRD_THING, thirdThingText);

    if (mWriteDatabaseTask != null) {
        mWriteDatabaseTask.cancel();//from  w  w w .  j a v  a2 s.  com
    }
    mWriteDatabaseTask = new DatabaseWriteTask(progressBar, mThreeThingsDatabase, values);
    mWriteDatabaseTimer.schedule(mWriteDatabaseTask, 500l);
}

From source file:ca.rmen.android.networkmonitor.app.log.LogActivity.java

/**
 * Read the data from the DB, export it to an HTML file, and load the HTML file in the WebView.
 *//*from  w ww. ja  v  a 2 s . c o m*/
private void loadHTMLFile() {
    Log.v(TAG, "loadHTMLFile");
    final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
    progressBar.setVisibility(View.VISIBLE);
    startRefreshIconAnimation();
    AsyncTask<Void, Void, File> asyncTask = new AsyncTask<Void, Void, File>() {

        @Override
        protected File doInBackground(Void... params) {
            Log.v(TAG, "loadHTMLFile:doInBackground");
            // Export the DB to the HTML file.
            HTMLExport htmlExport = new HTMLExport(LogActivity.this, false);
            int recordCount = NetMonPreferences.getInstance(LogActivity.this).getFilterRecordCount();
            return htmlExport.export(recordCount, null);
        }

        @SuppressLint("SetJavaScriptEnabled")
        @Override
        protected void onPostExecute(File result) {
            Log.v(TAG, "loadHTMLFile:onPostExecute, result=" + result);
            if (isFinishing()) {
                Log.v(TAG, "finishing, ignoring loadHTMLFile result");
                return;
            }
            if (result == null) {
                Toast.makeText(LogActivity.this, R.string.error_reading_log, Toast.LENGTH_LONG).show();
                return;
            }
            // Load the exported HTML file into the WebView.
            mWebView = (WebView) findViewById(R.id.web_view);
            // Save our current horizontal scroll position so we can keep our
            // horizontal position after reloading the page.
            final int oldScrollX = mWebView.getScrollX();
            mWebView.getSettings().setUseWideViewPort(true);
            mWebView.getSettings().setBuiltInZoomControls(true);
            mWebView.getSettings().setJavaScriptEnabled(true);
            mWebView.loadUrl("file://" + result.getAbsolutePath());
            mWebView.setWebViewClient(new WebViewClient() {

                @Override
                public void onPageStarted(WebView view, String url, Bitmap favicon) {
                    super.onPageStarted(view, url, favicon);
                    Log.v(TAG, "onPageStarted");
                    // Javascript hack to scroll back to our old X position.
                    // http://stackoverflow.com/questions/6855715/maintain-webview-content-scroll-position-on-orientation-change
                    if (oldScrollX > 0) {
                        String jsScrollX = "javascript:window:scrollTo(" + oldScrollX
                                + " / window.devicePixelRatio,0);";
                        view.loadUrl(jsScrollX);
                    }
                }

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

                @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    Log.v(TAG, "url: " + url);
                    // If the user clicked on one of the column names, let's update
                    // the sorting preference (column name, ascending or descending order).
                    if (url.startsWith(HTMLExport.URL_SORT)) {
                        NetMonPreferences prefs = NetMonPreferences.getInstance(LogActivity.this);
                        SortPreferences oldSortPreferences = prefs.getSortPreferences();
                        // The new column used for sorting will be the one the user tapped on.
                        String newSortColumnName = url.substring(HTMLExport.URL_SORT.length());
                        SortOrder newSortOrder = oldSortPreferences.sortOrder;
                        // If the user clicked on the column which is already used for sorting,
                        // toggle the sort order between ascending and descending.
                        if (newSortColumnName.equals(oldSortPreferences.sortColumnName)) {
                            if (oldSortPreferences.sortOrder == SortOrder.DESC)
                                newSortOrder = SortOrder.ASC;
                            else
                                newSortOrder = SortOrder.DESC;
                        }
                        // Update the sorting preferences (our shared preference change listener will be notified
                        // and reload the page).
                        prefs.setSortPreferences(new SortPreferences(newSortColumnName, newSortOrder));
                        return true;
                    }
                    // If the user clicked on the filter icon, start the filter activity for this column.
                    else if (url.startsWith(HTMLExport.URL_FILTER)) {
                        Intent intent = new Intent(LogActivity.this, FilterColumnActivity.class);
                        String columnName = url.substring(HTMLExport.URL_FILTER.length());
                        intent.putExtra(FilterColumnActivity.EXTRA_COLUMN_NAME, columnName);
                        startActivityForResult(intent, REQUEST_CODE_FILTER_COLUMN);
                        return true;
                    } else {
                        return super.shouldOverrideUrlLoading(view, url);
                    }
                }
            });
        }
    };
    asyncTask.execute();
}

From source file:online.privacy.SetupActivity.java

private void setWorkingState(boolean isWorking) {
    Button buttonSave = (Button) findViewById(R.id.button_save);
    ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_save);

    if (isWorking) {
        buttonSave.setVisibility(View.GONE);
        progressBar.setVisibility(View.VISIBLE);
    } else {/*from  w  ww  .ja v  a  2s .co m*/
        progressBar.setVisibility(View.GONE);
        buttonSave.setVisibility(View.VISIBLE);
    }
}

From source file:com.cjones.taskforcemamba.activity.WebActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mTitle = mDrawerTitle = getTitle();/*  www . j  a  va2  s. c  om*/

    //WebView
    Intent launchingIntent = getIntent();
    //        String content = launchingIntent.getData().toString();
    String home = "http://www.tfmamba.com";
    //        Log.i(TAG, "Content = " + content + " . Home = " + home);
    //        if(content == home){
    //            content = content + "&styleid=2";
    //            Log.i(TAG, "IF Statement - Content = " + content + " . Home = " + home);
    //        } else {
    //            Log.i(TAG, "Else Statement - Content = " + content + " . Home = " + home);
    //        }
    //        Log.i(TAG, "conte = " + content);
    myWebView = (WebView) findViewById(R.id.webview);
    //            if(content == null){
    myWebView.loadUrl(home);
    //        }else {
    //                myWebView.loadUrl(content);
    //            }
    myWebView.setWebViewClient(new WebViewClient());
    myWebView.getSettings().setBuiltInZoomControls(true);
    myWebView.getSettings().setJavaScriptEnabled(true);
    myWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

    final ProgressBar Pbar;
    Pbar = (ProgressBar) findViewById(R.id.pB1);

    myWebView.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress) {
            if (progress < 100 && Pbar.getVisibility() == ProgressBar.GONE) {
                Pbar.setVisibility(ProgressBar.VISIBLE);
            }
            Pbar.setProgress(progress);
            if (progress == 100) {
                Pbar.setVisibility(ProgressBar.GONE);
            }
        }
    });
    if (savedInstanceState != null) {
        myWebView.restoreState(savedInstanceState);
    } else {
        //            if(content == null && !content.isEmpty()){
        //            myWebView.loadUrl("http://www.tfmamba.com");
    }
}

From source file:com.luorrak.ouroboros.reply.ReplyCommentFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_attach_file) {
        if (reply.filePath.size() < 5) {
            if (ActivityCompat.checkSelfPermission(getActivity(),
                    Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
                    || ContextCompat.checkSelfPermission(getActivity(),
                            Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                requestPermissions(new String[] { Manifest.permission.READ_EXTERNAL_STORAGE,
                        Manifest.permission.WRITE_EXTERNAL_STORAGE }, Util.REQUEST_STORAGE_PERMISSION);
            } else {
                selectFile();//w  ww .ja  v a2s.  co m
            }
        } else {
            Snackbar.make(getView(), "Maximum amount of attachments reached", Snackbar.LENGTH_LONG).show();
        }
    }

    if (id == R.id.action_submit && !isPosting) {
        isPosting = true;
        ProgressBar progressBar = (ProgressBar) getActivity().findViewById(R.id.progress_bar);
        progressBar.setVisibility(View.VISIBLE);

        EditText nameText = (EditText) getActivity().findViewById(R.id.post_comment_editText_name);
        EditText emailText = (EditText) getActivity().findViewById(R.id.post_comment_editText_email);
        EditText subjectText = (EditText) getActivity().findViewById(R.id.post_comment_editText_subject);
        EditText commentText = (EditText) getActivity().findViewById(R.id.post_comment_editText_comment);
        EditText captchaText = (EditText) getActivity().findViewById(R.id.post_comment_captcha_editText);
        ImageView captchaImage = (ImageView) getActivity().findViewById(R.id.post_comment_captcha_image);

        reply.name = nameText.getText().toString();
        reply.email = emailText.getText().toString();
        reply.subject = subjectText.getText().toString();
        reply.comment = commentText.getText().toString();
        reply.captchaText = captchaText.getText().toString();

        if (captchaImage.getTag() != null) {
            reply.captchaCookie = captchaImage.getTag().toString();
        }
        reply.resto = resto;
        reply.board = boardName;

        reply.password = SettingsHelper.getPostPassword(getContext());

        networkHelper.postReply(getActivity(), reply, sharedPreferences, new JsonParser(),
                new InfiniteDbHelper(getActivity()), getView());
    }
    return super.onOptionsItemSelected(item);
}

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

synchronized void verifySampleLoaderTask() {
    ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
    if (s_sampleLoaderTask == null) {
        progressBar.setVisibility(View.GONE);

    } else {/*from  w w  w. j a v  a  2  s.  c o m*/
        progressBar.setVisibility(View.VISIBLE);
    }
}

From source file:com.ptts.fragments.BusLocation.java

private void makeProgressBarDisappear() {
    ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
    progressBar.setVisibility(View.INVISIBLE);
}

From source file:com.ptts.fragments.BusLocation.java

private void showProgressBar() {
    ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
    progressBar.setVisibility(View.VISIBLE);
}