首页 文章 精选 留言 我的

精选列表

搜索[图片显示],共10000篇文章
优秀的个人博客,低调大师

手机开发-京东360buy手机版的图片加载

JingDong:When it render the “search result” page ,(every item has the picture) ,it will buffer all the pictures in the SD card to accelerate the display. Tested from Kevin’s emulator, we can see ,that all the images that requested are downloaded intomnt/sdcard/imagefolder. We open it with image tool ,and see that the images are exactly the same that we see from the android client. So next time ,if we want to see the previous item ,we do not need to launch the REST call again ( because it is very slow for 1G /2G network) ,instead ,it only retrieved from the SDCard locally ,which leads to a faster speed. Result analysis: Advantage: obviously reduce the times to send REST request to server and reduce the network traffic. Disadvantage: we need to clear the temp contents (buffered images ,etc) regularly. 本文转自 charles_wang888 51CTO博客,原文链接:http://blog.51cto.com/supercharles888/835920,如需转载请自行联系原作者

优秀的个人博客,低调大师

Retrofit2.0+ .Net MVC4(WebApi) 上传多张图片

最近在做Android项目,使用的是MVP+Retrofit+rxjava+dagger的项目架构,RestFul 服务使用的.Net平台的WebApi。由于业务中需要有多文件上传的功能。所以在这里记载一下,便于以后查阅。 Android端Retrofit api 定义 在这次上传中,我们将实体类数据和文件数据一起上传到服务端。所以只写一个api就好 1 2 () Observable<HttpResult<String>>addEvent(()Evententity,()List<MultipartBody.Part>parts); 读取文件并将其转换成MuiltipartBody.Part 列表 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 List<MultipartBody.Part>getFilesMap(){ =ArrayList<MultipartBody.Part>(); Filefile=; { (!=&&.size()>){ (Stringpath:){ file=File(path); RequestBodyrequestBody=RequestBody.(MediaType.(),file); MultipartBody.Partpart=MultipartBody.Part.(,file.getName(),requestBody); .add(part); } } }(Exceptione){ e.printStackTrace(); } ; } 调用Retrofit 进行网络请求,并将实体类数据和文件数据一并发送到 服务端 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 addEvent(){ Evententity=.getEntity(); List<MultipartBody.Part>fileMap=.getFilesMap(); .clear(); { Subscriptionsubscription=.getRetrofitInstance() .create(EventInterface.) .addEvent(entity,fileMap) .subscribeOn(.io()).observeOn(.ui()).subscribe(Subscriber<HttpResult<String>>(){ onCompleted(){ } onError(Throwablee){ .setLoadingIndicator(); e.printStackTrace(); } onNext(HttpResult<String>httpResult){ (httpResult.getResultCode()!=ConstData.HttpResult.){ .setLoadingIndicator(); }{ .setLoadingIndicator(); } } }); .add(subscription); }(Exceptione){ e.printStackTrace(); } } 在webapi 端对文件以及数据进行接收。由上面转化MultipartBody 那一个环节我们可以看到,传到服务端的数据是以HTTP形式传送的。数据类型都是multipart/form-data类型的。所以我们在服务端要使用http相关协议来进行接收。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 [HttpPost] public HttpResult<string>AddEvent() { //获取EventET的属性 HttpRequestrequest=HttpContext.Current.Request; stringentity=request.Form[ 0 ]; BaseBNbaseBN= new BaseBN(); EventETet=baseBN.CTJsonSerializer<EventET>(entity); SystemBNbn= new SystemBN(); et.EVENT_ID=bn.CreateID( "EVENT" ,HaiQu.N, "EVENT_ID" , "EVENT" ,EventType.YiYou); List<string>addr= new List<string>(); //获取上传的文件 HttpFileCollectioncoll=request.Files; for ( int i= 0 ;i<coll.Count;i++) { HttpPostedFilefile=coll.Get(i); Stringfilename=file.FileName.Substring(file.FileName.LastIndexOf( "\\" )+ 1 ); if (!Directory.Exists(System.Web.HttpContext.Current.Server.MapPath( "~/Upload/" +et.EVENT_ID))) //如果不存在就创建file文件夹 { Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath( "~/Upload/" +et.EVENT_ID)); } stringfileSavePath=string.Format( "~/Upload/" +et.EVENT_ID+ "/{0}" ,filename); file.SaveAs(System.Web.HttpContext.Current.Server.MapPath(fileSavePath)); addr.Add(fileSavePath); } EventBNeventBN= new EventBN(); HttpResult<string>result=eventBN.AddEvent(et,addr,HaiQu.N); return result; } 这里有几点需要注意,实体类的数据,传输到服务端的时候,会以JSON字符串的形式传输到后台。这样的话,在后台使用的时候,需要对其进行反序列化。 另外,上传的文件,在HTTP中是以集合的形式存在,直接取出来,存储到本地就好。有一点需要注意的是,由于IIS对上传文件的限制,需要提前修改一下允许上传文件的上限。要不然,会上传不成功(这些都是已经踩过的坑)。 说在最后,其实上传文件很简单,网上有很多的大神已经讲解的非常详细。之所又自己啰嗦了一下,是因为,在做的过程中,踩了很多的坑,而且网上大多数人都只写了Android端,没有写服务端。再加上,.NET WebApi 用的人比较小众,所以就记录了一下。以后有时间会补上Spring 作为服务端的写法。以及Struts作为服务端的写法。 今天就到这里吧。 本文转自Eumenides_s 51CTO博客,原文链接:http://blog.51cto.com/xiaoshuaigege/1878634 ,如需转载请自行联系原作者

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册