List of usage examples for android.widget ProgressBar setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:com.andrewshu.android.reddit.threads.BitmapManager.java
public void fetchBitmapOnThread(final String urlString, final ImageView imageView, final ProgressBar indeterminateProgressBar, final Activity act) { SoftReference<Bitmap> ref = mCache.get(urlString); if (ref != null && ref.get() != null) { imageView.setImageBitmap(ref.get()); return;//from w w w . j av a 2 s . com } final Runnable progressBarShow = new Runnable() { public void run() { if (indeterminateProgressBar != null) { imageView.setVisibility(View.GONE); indeterminateProgressBar.setVisibility(View.VISIBLE); } } }; final Runnable progressBarHide = new Runnable() { public void run() { if (indeterminateProgressBar != null) { indeterminateProgressBar.setVisibility(View.GONE); imageView.setVisibility(View.VISIBLE); } } }; final Handler handler = new Handler() { @Override public void handleMessage(Message message) { if (indeterminateProgressBar != null && act != null) act.runOnUiThread(progressBarHide); imageView.setImageBitmap((Bitmap) message.obj); } }; Thread thread = new Thread() { @Override public void run() { if (indeterminateProgressBar != null && act != null) act.runOnUiThread(progressBarShow); Bitmap bitmap = fetchBitmap(urlString); Message message = handler.obtainMessage(1, bitmap); handler.sendMessage(message); } }; thread.start(); }
From source file:azad.hallaji.farzad.com.masirezendegi.ExplainMoshaver.java
void setAlage() { ProgressBar progressbarsandaha = (ProgressBar) findViewById(R.id.progressbarsandaha); progressbarsandaha.setVisibility(View.VISIBLE); String url = "http://telyar.dmedia.ir/webservice/Set_favourite/"; StringRequest MyStringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() { @Override/* w ww . j a v a2 s . com*/ public void onResponse(String response) { //This code is executed if the server responds, whether or not the response contains data. //The String 'response' contains the server's response. Log.i("aladfffgree", response); //Toast.makeText(getApplicationContext(), response , Toast.LENGTH_LONG).show(); //Toast.makeText(getApplicationContext(), response , Toast.LENGTH_LONG).show(); ProgressBar progressbarsandaha = (ProgressBar) findViewById(R.id.progressbarsandaha); progressbarsandaha.setVisibility(View.INVISIBLE); try { JSONObject jsonObject = new JSONObject(response); if (jsonObject.getString("Status").equals("1")) { IsFavorite = !IsFavorite; if (IsFavorite) { alagestarmoshaver.setImageResource(R.drawable.alage1); } else { alagestarmoshaver.setImageResource(R.drawable.alage0); } } Toast.makeText(getApplicationContext(), jsonObject.getString("Message"), Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } }, 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() { String s = IsFavorite ? "-1" : "1"; Map<String, String> MyData = new HashMap<String, String>(); //Log.i("asasasasasasa",adviseridm+"/"+GlobalVar.getDeviceID()); MyData.put("userid", GlobalVar.getUserID()); //Add the data you'd like to send to the server. MyData.put("contentid", adviseridm); //Add the data you'd like to send to the server. MyData.put("status", s); //Add the data you'd like to send to the server. MyData.put("contenttype", "adviser"); //Add the data you'd like to send to the server. MyData.put("deviceid", GlobalVar.getDeviceID()); //Add the data you'd like to send to the server. Log.i("aladfffgree", MyData.toString()); return MyData; } }; MyRequestQueue.add(MyStringRequest); }
From source file:br.org.fiscal65.bitmaps.ImageWorker.java
public void loadImage(Object data, ImageView imageView, ProgressBar progressBar) { if (data == null) { return;//from ww w . j a v a 2 s. c o m } BitmapDrawable value = null; if (progressBar != null) progressBar.setVisibility(View.VISIBLE); if (mImageCache != null) { value = mImageCache.getBitmapFromMemCache(String.valueOf(data)); } if (value != null) { // Bitmap found in memory cache imageView.setImageDrawable(value); if (progressBar != null) progressBar.setVisibility(View.GONE); } else if (cancelPotentialWork(data, imageView)) { final BitmapWorkerTask task = new BitmapWorkerTask(data, imageView, progressBar); final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task); imageView.setImageDrawable(asyncDrawable); // 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); } }
From source file:wb.android.workers.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView.//from w w w . j ava 2s .c o m * * @param imageView * @param drawable */ @SuppressWarnings("deprecation") private void setImageDrawable(ImageView imageView, ProgressBar progressBar, Drawable drawable) { if (progressBar != null) { progressBar.setVisibility(View.GONE); } imageView.setVisibility(View.VISIBLE); if (mFadeInBitmap) { // Transition drawable with a transparent drawable and the final drawable final TransitionDrawable td = new TransitionDrawable( new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable }); // Set background to loading bitmap imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(drawable); } }
From source file:com.binroot.fatpita.BitmapManager2.java
public void fetchBitmapOnThread(final String urlString, final ImageView imageView, final ProgressBar indeterminateProgressBar, final Activity act, final int sample) { SoftReference<Bitmap> ref = mCache.get(urlString); if (ref != null && ref.get() != null) { imageView.setImageBitmap(ref.get()); return;/*from w w w .j a v a 2 s.c om*/ } final Runnable progressBarShow = new Runnable() { public void run() { if (indeterminateProgressBar != null) { imageView.setVisibility(View.GONE); indeterminateProgressBar.setVisibility(View.VISIBLE); } } }; final Runnable progressBarHide = new Runnable() { public void run() { if (indeterminateProgressBar != null) { indeterminateProgressBar.setVisibility(View.GONE); imageView.setVisibility(View.VISIBLE); } } }; final Handler handler = new Handler() { @Override public void handleMessage(Message message) { if (indeterminateProgressBar != null && act != null) act.runOnUiThread(progressBarHide); imageView.setImageBitmap((Bitmap) message.obj); } }; Thread thread = new Thread() { @Override public void run() { if (indeterminateProgressBar != null && act != null) act.runOnUiThread(progressBarShow); Bitmap bitmap = fetchBitmap(urlString, sample); Message message = handler.obtainMessage(1, bitmap); handler.sendMessage(message); } }; thread.start(); }
From source file:io.github.hidroh.materialistic.WebFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { if (mIsHackerNewsUrl) { return createLocalView(container, savedInstanceState); }// w w w. j a v a 2 s. c om final View view = getLayoutInflater(savedInstanceState).inflate(R.layout.fragment_web, container, false); mScrollView = (NestedScrollView) view.findViewById(R.id.nested_scroll_view); final ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progress); mWebView = (WebView) view.findViewById(R.id.web_view); mWebView.setBackgroundColor(Color.TRANSPARENT); mWebView.setWebViewClient(new WebViewClient()); mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { progressBar.setVisibility(View.VISIBLE); progressBar.setProgress(newProgress); if (newProgress == 100) { progressBar.setVisibility(View.GONE); mWebView.setBackgroundColor(Color.WHITE); mWebView.setVisibility(mExternalRequired ? View.GONE : View.VISIBLE); } } }); mWebView.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { if (getActivity() == null) { return; } final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); if (intent.resolveActivity(getActivity().getPackageManager()) == null) { return; } mExternalRequired = true; mWebView.setVisibility(View.GONE); view.findViewById(R.id.empty).setVisibility(View.VISIBLE); view.findViewById(R.id.download_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(intent); } }); } }); mWebView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK) { if (mWebView.canGoBack()) { mWebView.goBack(); return true; } } return false; } }); setWebViewSettings(mWebView.getSettings()); return view; }
From source file:com.cloverstudio.spika.utils.BitmapManager.java
public void loadBitmap(final String url, final ImageView imageView, ProgressBar pbLoading) { imageViews.put(imageView, url);//from www.j a va2 s. c o m Bitmap bitmap = getBitmapFromCache(url); // check in UI thread, so no concurrency issues if (bitmap != null) { if (smallImg) { imageView.setScaleType(ImageView.ScaleType.CENTER); } else { imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); } imageView.setImageBitmap(bitmap); if (pbLoading != null) pbLoading.setVisibility(View.GONE); } else { imageView.setImageBitmap(null); imageView.setBackgroundResource(R.color.loading_background); queueJob(url, imageView, pbLoading); } }
From source file:com.uzmap.pkg.uzmodules.photoBrowser.ImageBrowserAdapter.java
@Override public Object instantiateItem(ViewGroup container, final int position) { mViewContainer = container;//from w ww . j a va 2s . com int item_view_id = UZResourcesIDFinder.getResLayoutID("photo_browser_item_layout"); View itemView = View.inflate(mContext, item_view_id, null); itemView.setTag(position); int photo_view_id = UZResourcesIDFinder.getResIdID("photoView"); final PhotoView imageView = (PhotoView) itemView.findViewById(photo_view_id); imageView.setZoomable(this.zoomEnable); int load_progress_id = UZResourcesIDFinder.getResIdID("loadProgress"); final ProgressBar progress = (ProgressBar) itemView.findViewById(load_progress_id); progress.setTag(position); mImageLoader.load(imageView, progress, mImagePaths.get(position)); mImageLoader.setOnLoadCompleteListener(new OnLoadCompleteListener() { @Override public void onLoadComplete(ProgressBar bar) { PhotoBrowser.callback(mUZContext, PhotoBrowser.EVENT_TYPE_LOADSUCCESSED, (Integer) bar.getTag()); } @Override public void onLoadFailed(final ProgressBar bar) { PhotoBrowser.callback(mUZContext, PhotoBrowser.EVENT_TYPE_LOADFAILED, (Integer) bar.getTag()); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { bar.setVisibility(View.GONE); } }); } }); imageView.setOnViewTapListener(new OnViewTapListener() { @Override public void onViewTap(View arg0, float arg1, float arg2) { PhotoBrowser.callback(mUZContext, PhotoBrowser.EVENT_TYPE_CLICK, position); } }); imageView.setOnPhotoTapListener(new OnPhotoTapListener() { @Override public void onPhotoTap(View arg0, float arg1, float arg2) { PhotoBrowser.callback(mUZContext, PhotoBrowser.EVENT_TYPE_CLICK, position); } }); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PhotoBrowser.callback(mUZContext, PhotoBrowser.EVENT_TYPE_CLICK, position); } }); imageView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { PhotoBrowser.callback(mUZContext, PhotoBrowser.EVENT_TYPE_LONG_CLICK, position); return false; } }); container.addView(itemView); return itemView; }
From source file:com.lastorder.pushnotifications.data.ImageDownloader.java
/** * Download the specified image from the Internet and binds it to the provided ImageView. The * binding is immediate if the image is found in the cache and will be done asynchronously * otherwise. A null bitmap will be associated to the ImageView if an error occurs. * * @param url The URL of the image to download. * @param imageView The ImageView to bind the downloaded image to. *//*from w w w. j a v a 2 s . co m*/ public void download(String url, ImageView imageView, Context context, ProgressBar bar) { resetPurgeTimer(); Bitmap bitmap = getBitmapFromCache(url); myWeakContext = new WeakReference<Context>(context); if (bitmap == null) { bar.setVisibility(0); imageView.setVisibility(8); forceDownload(url, imageView, bar); } else { bar.setVisibility(8); cancelPotentialDownload(url, imageView); imageView.setImageBitmap(bitmap); imageView.setVisibility(0); imageView.bringToFront(); } }
From source file:com.esource42.whyapp.utility.ImageDownloader.java
/** * Download the specified image from the Internet and binds it to the provided ImageView. The * binding is immediate if the image is found in the cache and will be done asynchronously * otherwise. A null bitmap will be associated to the ImageView if an error occurs. * * @param url The URL of the image to download. * @param imageView The ImageView to bind the downloaded image to. *//*from w w w . j a v a 2 s .com*/ public void download(String url, ImageView imageView, ProgressBar progress) { resetPurgeTimer(); Bitmap bitmap = getBitmapFromCache(url); if (bitmap == null) { forceDownload(url, imageView, progress); } else { cancelPotentialDownload(url, imageView); imageView.setImageBitmap(bitmap); progress.setVisibility(View.GONE); } }