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:azad.hallaji.farzad.com.masirezendegi.PageVirayesh.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/Edit_profile/";
    StringRequest MyStringRequest = new StringRequest(Request.Method.POST, url,
            new Response.Listener<String>() {

                @Override//  w w w .ja  v  a2s  .  c  o m
                public void onResponse(String response) {

                    Log.i("dfvflgnkjdfd", response);

                    try {
                        JSONObject jsonObject = new JSONObject(response);
                        jostaruzunueymahziba(jsonObject.getString("Message"));

                        //Toast.makeText(getApplicationContext(),jsonObject.getString("Message"), Toast.LENGTH_LONG).show();

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    //Log.i("aladffgree", response);

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

                }
            }, 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> p = new HashMap<String, String>();
            try {
                p.put("name", namexanivadeEdit.getText().toString());
                //p.setParam("name",namexanivadeEdit.getText().toString());

            } catch (Exception ignored) {
                //p.setParam("familyname","");  //
                p.put("name", " ");
            }
            p.put("userid", GlobalVar.getUserID());

            try {
                p.put("email", emailEdit.getText().toString());

            } catch (Exception ignored) {
                p.put("email", " ");
            }
            try {
                p.put("gender", sexEdit.getText().toString());
            } catch (Exception ignored) {
                p.put("gender", " ");
            }
            try {
                p.put("telephone", shomareteleEdit.getText().toString());

            } catch (Exception ignored) {
                p.put("telephone", " ");

            }
            try {

                p.put("pic", selectedImageString);
                //Log.i("asssasasa",selectedImageString);
            } catch (Exception ignored) {
                p.put("pic", " ");

            }
            try {
                p.put("aboutme", aboutmeEdit.getText().toString());

            } catch (Exception ignored) {
                p.put("aboutme", " ");
            }
            try {
                p.put("costpermin", costperminEdit.getText().toString());

            } catch (Exception ignored) {

                p.put("costpermin", "");

            }
            try {
                p.put("dialect", dialtecEdit.getText().toString());

            } catch (Exception ignored) {
                p.put("dialect", "");

            }
            try {
                p.put("advisermaxtim", maxtimeEdit.getText().toString());
            } catch (Exception ignored) {
                p.put("advisermaxtim", " ");
            }
            try {
                p.put("license", " ");
            } catch (Exception ignored) {
                p.put("license", " ");
            }
            try {
                p.put("tag", barchasbEdit.getText().toString());
            } catch (Exception ignored) {
                p.put("tag", " ");
            }
            //Log.i("aladffgree", "gedir ba");

            Log.i("dfvflgnkjdfd", p.toString());

            return p;
        }

        @Override
        protected void onFinish() {

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

        }
    };

    MyRequestQueue.add(MyStringRequest);
}

From source file:me.fireant.photoselect.ui.PhotoPreviewActivity.java

@Override
protected void initData() {
    Intent intent = getIntent();//from  w w w.j a va2  s . c o  m
    if (intent != null) {
        mPhotos = intent.getParcelableArrayListExtra(BUNDLE_PHOTOS);
        mSelectIndex = intent.getIntExtra(BUNDLE_SELECT_INDEX, 0);
        mSelectedPhotos = intent.getParcelableArrayListExtra(BUNDLE_SELECTED_PHOTOS);
        mMaxSelectPhotoCount = intent.getIntExtra(BUNDLE_MAX_SELECT_COUNT, 1);
    }

    if (mSelectedPhotos == null) {
        mSelectedPhotos = new ArrayList<>();
    }

    mPagerAdapter = new PagerAdapter() {
        @Override
        public int getCount() {
            return mPhotos.size();
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            View rootView = LayoutInflater.from(PhotoPreviewActivity.this)
                    .inflate(R.layout.list_cell_photo_preview, null);
            final ImageView photoView = (ImageView) rootView.findViewById(R.id.iv_photo);
            final ProgressBar pbLoading = (ProgressBar) rootView.findViewById(R.id.pb_loading);
            final Photo photo = mPhotos.get(position);

            Picasso.with(PhotoPreviewActivity.this).load(new File(photo.getPath()))
                    .error(R.drawable.ic_photo_error).into(photoView, new Callback() {
                        @Override
                        public void onSuccess() {
                            photoView.setVisibility(View.VISIBLE);
                            pbLoading.setVisibility(View.GONE);
                        }

                        @Override
                        public void onError() {

                        }
                    });

            container.addView(rootView);

            return rootView;
        }
    };

    mViewPager.setAdapter(mPagerAdapter);

    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            checkChecked(position);
            mSelectIndex = position + 1;
            setActionTitle();
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
    if (mSelectIndex == 0) {
        checkChecked(mSelectIndex);
        mSelectIndex = mSelectIndex + 1;
        setActionTitle();
    } else {
        mViewPager.setCurrentItem(mSelectIndex, false);
    }
}

From source file:com.yi4all.rupics.IssueListFragment.java

private void initPostList() {

    // post list/*from w  ww  . j a  v  a  2s  .c  om*/
    postListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(PLA_AdapterView<?> adapter, View arg1, int position, long arg3) {
            // for the last row
            if (issueList.size() == 0 || position > issueList.size())
                return;

            selected_item = position;

            final Intent i = new Intent(getActivity(), ImageDetailActivity.class);
            i.putExtra("issue", issueList.get(position - 1));

            startActivity(i);
        }

    });

    postListView.setIconDrawable(R.drawable.refresh_icon);

    postListView.setShowLastUpdatedText(true);

    postListView.setLastUpdatedDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));

    postListView.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            new Thread(new Runnable() {

                @Override
                public void run() {

                    List<IssueModel> list = ((BaseActivity) getActivity()).getService()
                            .getIssueByCategoryRemote(category, 1);

                    boolean isUpdated = false;
                    int updateAmount = 0;

                    if (issueList.size() > 0) {
                        for (IssueModel im : list) {
                            if (im.getId() == issueList.get(0).getId()) {
                                break;
                            } else {
                                updateAmount++;
                            }
                        }
                        isUpdated = updateAmount > 0;
                    } else {
                        if (list.size() > 0) {
                            updateAmount = list.size();
                        }
                    }

                    if (isUpdated) {
                        Utils.toastMsg(getActivity(), R.string.update_amount, String.valueOf(updateAmount));
                        issueList = list;
                    } else {
                        Utils.toastMsg(getActivity(), R.string.nomore);
                    }

                    refreshList(0);
                }
            }).start();

        }
    });

    LayoutInflater inflater = LayoutInflater.from(this.getActivity());
    final View row = inflater.inflate(R.layout.more_list_item, null);

    final ProgressBar pb = (ProgressBar) row.findViewById(R.id.postListPB);
    pb.setVisibility(View.GONE);

    final TextView title = (TextView) row.findViewById(R.id.row_title);

    postListView.addFooterView(row);

    postListView.setOnScrollListener(new OnScrollListener() {

        @Override
        public void onScrollStateChanged(PLA_AbsListView view, int scrollState) {

        }

        @Override
        public void onScroll(PLA_AbsListView view, int firstVisibleItem, int visibleItemCount,
                int totalItemCount) {
            if (issueList.size() == 0)
                return;

            if ((firstVisibleItem + visibleItemCount) >= (issueList.size() - 1)
                    && (postTask.getStatus() != postTask.getStatus().RUNNING)) {
                if (category == null) {
                    title.setText(R.string.need_select_source);
                    pb.setVisibility(View.GONE);
                } else {

                    // set the title
                    if (isNoMoreIssue) {
                        title.setText(R.string.nomore);
                        pb.setVisibility(View.GONE);

                        new Handler().postDelayed(new Runnable() {

                            @Override
                            public void run() {
                                row.setVisibility(View.GONE);
                            }
                        }, 1000);

                    } else {
                        pb.setVisibility(View.VISIBLE);
                        if (postTask != null && !postTask.isCancelled()) {
                            postTask.cancel(true);
                        }
                        postTask = new DownloadPostTask(pb, title, issueList.size() - 1);
                        postTask.execute();
                    }
                }
            }

        }
    });

    if (category == null) {
        title.setText(R.string.need_select_source);
        pb.setVisibility(View.GONE);
    } else {
        if (postTask != null && !postTask.isCancelled()) {
            postTask.cancel(true);
        }
        postTask = new DownloadPostTask(pb, title, issueList.size() - 1);
        postTask.execute();
    }
}

From source file:com.aero2.android.DefaultActivities.SmogMapActivity.java

public void showNoInternetScreen() {
    showLoadingScreen();/*w ww  . ja va  2 s.c  o m*/
    ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
    progressBar.setVisibility(View.INVISIBLE);
    TextView noConnectionTV = (TextView) findViewById(R.id.loading_tv);
    noConnectionTV.setText("NO INTERNET CAN'T DOWNLOAD DATA FOR THE FIRST TIME :(");
    noConnectionTV.setTextColor(Color.GRAY);
    noConnectionTV.setPadding(40, 30, 40, 0);
}

From source file:com.ijiaban.yinxiang.MainActivity.java

/**
 * Locks / unlocks the GUI through boolean field and
 * hides / shows the progress bar./*from www .  j  a  va  2s.c o m*/
 *
 * @param isBusy Will be applied to mGuiIsLocked field
 */
private void setGuiIsBusy(boolean isBusy) {
    mGuiIsLocked = isBusy;
    ProgressBar mLoadingCircle = (ProgressBar) findViewById(R.id.progressBar);
    if (isBusy)
        mLoadingCircle.setVisibility(View.VISIBLE);
    else
        mLoadingCircle.setVisibility(View.GONE);
}

From source file:com.autoparts.buyers.action_content.fragment.WebViewFragment.java

@SuppressLint("SetJavaScriptEnabled")
@Override// w  w  w  . ja  v  a2  s .co m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View v = inflater.inflate(R.layout.webview_fragment, container, false);

    final ProgressBar viewContentProgress = (ProgressBar) v.findViewById(R.id.progress);
    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);
        }
    });
    viewContentWebView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            viewContentProgress.setProgress(newProgress);
            viewContentProgress.setVisibility(newProgress == 100 ? View.GONE : View.VISIBLE);

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

From source file:com.anxpp.blog.fragment.WebViewFragment.java

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

    final ProgressBar viewContentProgress = (ProgressBar) v.findViewById(R.id.progress);
    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);
        }
    });
    viewContentWebView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            viewContentProgress.setProgress(newProgress);
            viewContentProgress.setVisibility(newProgress == 100 ? View.GONE : View.VISIBLE);

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

From source file:org.ale.scanner.zotero.MainActivity.java

public void resetUploadStatus() {
    ProgressBar prog = (ProgressBar) findViewById(R.id.upload_progress_bar);
    prog.setVisibility(View.VISIBLE);

    TextView error = (TextView) findViewById(R.id.upload_error);
    error.setVisibility(View.GONE);

    TextView output = (TextView) findViewById(R.id.upload_output);
    output.setText(getText(ZoteroAPIClient.UPLOADING));
}

From source file:org.ale.scanner.zotero.MainActivity.java

public void uploadFailure(Integer reason) {
    mUploadState = UPLOAD_STATE_FAILURE;
    ProgressBar prog = (ProgressBar) findViewById(R.id.upload_progress_bar);
    prog.setVisibility(View.GONE);

    TextView error = (TextView) findViewById(R.id.upload_error);
    error.setVisibility(View.VISIBLE);

    TextView output = (TextView) findViewById(R.id.upload_output);
    output.setText(getText(reason));/*from  ww w. j a va2s.com*/
}

From source file:me.fireant.photoselect.ui.PhotoSelectedPreviewActivity.java

@Override
protected void initData() {
    if (getIntent() != null) {
        Intent intent = getIntent();//from   www  .jav  a 2 s .  c om
        mSelectedPhotos = intent.getParcelableArrayListExtra(BUNDLE_SELECTED_PHOTOS);
        mSelectIndex = intent.getIntExtra(BUNDLE_SELECT_INDEX, 0);
    }

    if (mSelectedPhotos == null || mSelectedPhotos.isEmpty()) {
        throw new IllegalStateException("selectPhotos must > 0");
    }

    mPagerAdapter = new PagerAdapter() {
        @Override
        public int getCount() {
            return mSelectedPhotos.size();
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);
        }

        @Override
        public int getItemPosition(Object object) {
            return POSITION_NONE;
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            View rootView = LayoutInflater.from(PhotoSelectedPreviewActivity.this)
                    .inflate(R.layout.list_cell_photo_preview, null);
            final ImageView photoView = (ImageView) rootView.findViewById(R.id.iv_photo);
            final ProgressBar pbLoading = (ProgressBar) rootView.findViewById(R.id.pb_loading);
            final Photo photo = mSelectedPhotos.get(position);

            Picasso.with(PhotoSelectedPreviewActivity.this).load(new File(photo.getPath()))
                    .error(R.drawable.ic_photo_error).into(photoView, new Callback() {
                        @Override
                        public void onSuccess() {
                            photoView.setVisibility(View.VISIBLE);
                            pbLoading.setVisibility(View.GONE);
                        }

                        @Override
                        public void onError() {

                        }
                    });

            container.addView(rootView);

            return rootView;
        }
    };

    mViewPager.setAdapter(mPagerAdapter);

    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            mSelectIndex = position + 1;
            setActionTitle();
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }

    });

    if (mSelectIndex == 0) {
        mSelectIndex = mSelectIndex + 1;
        setActionTitle();
    } else {
        mViewPager.setCurrentItem(mSelectIndex, false);
    }
}