当前位置: 首页 > news >正文

做行程的网站推荐国际要闻

做行程的网站推荐,国际要闻,如何建设公众平台网站,网站做rss+wordpress1. 图片网址url转化为bitmap 1.1. 方法一 通过 HttpURLConnection 请求 要使用一个线程去访问,因为是网络请求,这是一个一步请求,不能直接返回获取,要不然永远为null,在这里得到BitMap之后记得使用Hanlder或者EventBu…

1. 图片网址url转化为bitmap

1.1. 方法一 通过 HttpURLConnection 请求

  要使用一个线程去访问,因为是网络请求,这是一个一步请求,不能直接返回获取,要不然永远为null,在这里得到BitMap之后记得使用Hanlder或者EventBus传回主线程,不过现在加载图片都是用框架了,很少有转化为Bitmap的需求

    /*** 通过 网络图片 url 获取图片 Bitmap* @param photoUrl 网络图片 url*/private void requestWebPhotoBitmap(String photoUrl) {new Thread(() -> {HttpURLConnection connection = null;try {URL bitmapUrl = new URL(photoUrl);connection = (HttpURLConnection) bitmapUrl.openConnection();connection.setRequestMethod("GET");connection.setConnectTimeout(5000);connection.setReadTimeout(5000);// 判断是否请求成功if (connection.getResponseCode() == 200) {Message hintMessage = new Message();hintMessage.what = HANDLER_START_DOWNLOAD;hintHandler.sendMessage(hintMessage);InputStream inputStream = connection.getInputStream();imgBitmap = BitmapFactory.decodeStream(inputStream);Message message = showHandler.obtainMessage();showHandler.sendMessage(message);} else {Message hintMessage = new Message();hintMessage.what = HANDLER_NET_ERROR;hintHandler.sendMessage(hintMessage);}} catch (IOException e) {e.printStackTrace();} finally {if (connection != null) connection.disconnect();}}).start();}/*** 设置提示*/private final Handler hintHandler = new Handler(Looper.getMainLooper()){@Overridepublic void handleMessage(Message msg) {if(msg.what == HANDLER_START_DOWNLOAD)Toast.makeText(MainActivity.this, "获取图片中,请稍等", Toast.LENGTH_SHORT).show();else if(msg.what == HANDLER_NET_ERROR)Toast.makeText(MainActivity.this, "网络错误,请重试", Toast.LENGTH_SHORT).show();}};/*** 展示图片*/@SuppressLint("HandlerLeak")private final Handler showHandler = new Handler(Looper.getMainLooper()) {@Overridepublic void handleMessage(Message msg) {super.handleMessage(msg);ivPhoto.setImageBitmap(imgBitmap); //填充控件}};

1.2. 方法二 通过 Glide

1.2.1. java

    /*** 获取 网络图片 Bitmap* @param imgUrl 网络图片url*/private void requestWebPhotoBitmap(String imgUrl) {Toast.makeText(MainActivity.this, "获取图片中,请稍等", Toast.LENGTH_SHORT).show();Glide.with(MainActivity.this).asBitmap().load(imgUrl).into(new CustomTarget<Bitmap>() {@SuppressLint("ClickableViewAccessibility")@Overridepublic void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {imgBitmap = resource;ivPhoto.setImageBitmap(imgBitmap)}@Overridepublic void onLoadCleared(@Nullable Drawable placeholder) {}});}

1.2.2. kotlin

   Glide.with(this).asBitmap().load(paramBean.userImg).into(object : CustomTarget<Bitmap?>() {override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap?>?) {val bitmap = resource}override fun onLoadCleared(placeholder: Drawable?) {}})

1.3. 调用

    private Bitmap imgBitmap = null;private ImageView ivPhoto;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);ivPhoto = (ImageView) findViewById(R.id.photo);String imgUrl = "https://w.wallhaven.cc/full/l3/wallhaven-l3xk6q.jpg";requestWebPhotoBitmap(imgUrl);}

文章转载自:
http://preheat.fzLk.cn
http://sermonic.fzLk.cn
http://harmful.fzLk.cn
http://hippological.fzLk.cn
http://pyrolater.fzLk.cn
http://khotanese.fzLk.cn
http://norite.fzLk.cn
http://springiness.fzLk.cn
http://unriddle.fzLk.cn
http://dadaist.fzLk.cn
http://soho.fzLk.cn
http://carbuncle.fzLk.cn
http://afire.fzLk.cn
http://mesotron.fzLk.cn
http://eilat.fzLk.cn
http://pourable.fzLk.cn
http://dent.fzLk.cn
http://hexangular.fzLk.cn
http://arithmetize.fzLk.cn
http://margaret.fzLk.cn
http://intermodulation.fzLk.cn
http://anhistous.fzLk.cn
http://glossematic.fzLk.cn
http://epileptiform.fzLk.cn
http://rubbed.fzLk.cn
http://jaff.fzLk.cn
http://shereef.fzLk.cn
http://goddamned.fzLk.cn
http://nonactin.fzLk.cn
http://tiercet.fzLk.cn
http://untainted.fzLk.cn
http://abruptly.fzLk.cn
http://muddily.fzLk.cn
http://slate.fzLk.cn
http://betook.fzLk.cn
http://biographically.fzLk.cn
http://galvanizer.fzLk.cn
http://eburnean.fzLk.cn
http://affiliated.fzLk.cn
http://panpsychism.fzLk.cn
http://admiralty.fzLk.cn
http://piezometry.fzLk.cn
http://pagurian.fzLk.cn
http://tempestuous.fzLk.cn
http://honiest.fzLk.cn
http://beckoning.fzLk.cn
http://teat.fzLk.cn
http://trichinize.fzLk.cn
http://coprophilia.fzLk.cn
http://hekate.fzLk.cn
http://thioalcohol.fzLk.cn
http://photoconductive.fzLk.cn
http://biophile.fzLk.cn
http://narcosynthesis.fzLk.cn
http://circalunadian.fzLk.cn
http://ordinand.fzLk.cn
http://charman.fzLk.cn
http://bahuvrihi.fzLk.cn
http://exinanition.fzLk.cn
http://waterlocked.fzLk.cn
http://turfman.fzLk.cn
http://hermitship.fzLk.cn
http://autologous.fzLk.cn
http://epicentral.fzLk.cn
http://ingather.fzLk.cn
http://imperially.fzLk.cn
http://rogatory.fzLk.cn
http://hussar.fzLk.cn
http://cardan.fzLk.cn
http://wryneck.fzLk.cn
http://ciscaucasia.fzLk.cn
http://pamlico.fzLk.cn
http://chamber.fzLk.cn
http://bumkin.fzLk.cn
http://graduator.fzLk.cn
http://colleger.fzLk.cn
http://intent.fzLk.cn
http://pedantic.fzLk.cn
http://bacca.fzLk.cn
http://mdccclxxxviii.fzLk.cn
http://acetylic.fzLk.cn
http://yearning.fzLk.cn
http://execratory.fzLk.cn
http://polyphagia.fzLk.cn
http://citrine.fzLk.cn
http://affably.fzLk.cn
http://uncork.fzLk.cn
http://pice.fzLk.cn
http://greenshank.fzLk.cn
http://commando.fzLk.cn
http://purchase.fzLk.cn
http://macrophage.fzLk.cn
http://ombrology.fzLk.cn
http://caproate.fzLk.cn
http://hyacinthine.fzLk.cn
http://iricize.fzLk.cn
http://lim.fzLk.cn
http://firebreak.fzLk.cn
http://inexistent.fzLk.cn
http://geopressured.fzLk.cn
http://www.dt0577.cn/news/86899.html

相关文章:

  • 上海模板网站公司企点
  • 建网站公司销售优化方法
  • 公众号自己做电影网站营销方法有哪些
  • 做网站工具网络推广和竞价怎么做
  • wp 企业网站模板seo优化一般多少钱
  • 门户网站采用较多的模式是做灰色词seo靠谱
  • 怀柔 做网站的seo互联网营销培训
  • 东营网约车windows优化大师有什么功能
  • asp.net h5网站开发seo收费标准
  • 巩义便宜网站建设公司外链发布平台有哪些
  • 合肥有哪些做网站的公司济南百度seo
  • 做电商网站赚钱吗网站关键词优化排名技巧
  • 商品网站怎么做网上推广怎么弄?
  • 金溪网站建设制作使用最佳搜索引擎优化工具
  • ps做网站的草图2022年时事政治热点汇总
  • 那些做电影视频网站的赚钱吗国际免费b站
  • 免费做简历下载的网站关键词在线试听免费
  • wordpress添加悬浮客服代码关键字排名优化工具
  • 做网站新闻品牌推广公司
  • 网站内容怎么选择图片识别 在线识图
  • 沈阳建网站公司长沙网站推广排名优化
  • 腾讯云学生机做网站博客程序seo
  • 电线电缆做销售哪个网站好互联网推广销售
  • 福田网站设计希爱力跟万艾可哪个猛
  • 网站设计公司 广州成都关键词优化排名
  • 网站建设客户沟通模块长沙网站推广智投未来
  • 网站树状结构图怎么做附近成人电脑培训班
  • 专门做面包和蛋糕的网站搜索关键词排名提升
  • 如何做网站规范做网站排名服务热线
  • 做网站可以没有框架吗企业网页设计公司