【0114】【项目实战】-【Android通用框架设计与完整电商APP开发】-【14】附加功能开发(二维码,一键分享,分页,搜索)


1.二维码高性能解决方案

1.1推荐的库的使用

【添加依赖】zxing是谷歌纯java写的;zbar是日本纯c写的,效率高;

【动态权限的添加】

【二维码事件处理的delegate】

【扫描view】

 

【二维码扫描框的view】

 

 【完善调用逻辑】

【权限的补充】

1.2 扫描到数据回调的处理

 

 

2. 一键分享功能的使用

2.1 第三方功能的使用

【说明】接入共需要五步;

 

【第一步】【需要增加shareSDK和第三方平台的key和secret】

 

【第二步】

 

【第三步】

【第四步】

 

【第五步】

 

2.2 逻辑增加

【在发现页面使用】

 

2.3 编译测试

【说明】在debug版本的apk在真机上是无法使用一键分享功能的,需要编译成为release版本才可以;

 

 

3.分页功能实现

 【下拉分页的功能】多条数据的加载

 4. 搜索功能的实现

 

 

【search的layout】使用到了recycleView;

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     android:orientation="vertical">
 6 
 7     <android.support.v7.widget.Toolbar
 8         android:id="@+id/tb_main_page"
 9         android:layout_width="match_parent"
10         android:layout_height="80dp"
11         android:background="@color/app_main">
12 
13         <android.support.v7.widget.LinearLayoutCompat
14             android:layout_width="match_parent"
15             android:layout_height="match_parent"
16             android:orientation="horizontal">
17 
18             <com.joanzapata.iconify.widget.IconTextView
19                 android:id="@+id/icon_top_search_back"
20                 android:layout_width="0dp"
21                 android:layout_height="match_parent"
22                 android:layout_gravity="left"
23                 android:layout_weight="0.6"
24                 android:gravity="center"
25                 android:paddingRight="10dp"
26                 android:text="{fa-arrow-left}"
27                 android:textColor="@android:color/white"
28                 android:textSize="25sp" />
29 
30             <android.support.v7.widget.AppCompatEditText
31                 android:id="@+id/et_search_view"
32                 android:layout_width="0dp"
33                 android:layout_height="40dp"
34                 android:layout_gravity="center"
35                 android:layout_weight="4"
36                 android:background="@android:color/white"
37                 android:gravity="center_vertical"
38                 android:hint="搜索"
39                 android:paddingLeft="20dp" />
40 
41             <android.support.v7.widget.AppCompatTextView
42                 android:id="@+id/tv_top_search"
43                 android:layout_width="0dp"
44                 android:layout_height="match_parent"
45                 android:layout_gravity="right"
46                 android:layout_weight="1"
47                 android:gravity="center"
48                 android:text="搜索"
49                 android:textColor="@android:color/white"
50                 android:textSize="18sp" />
51 
52         </android.support.v7.widget.LinearLayoutCompat>
53 
54     </android.support.v7.widget.Toolbar>
55 
56     <android.support.v7.widget.RecyclerView
57         android:id="@+id/rv_search"
58         android:layout_width="match_parent"
59         android:layout_height="match_parent" />
60 </LinearLayout>

 

【recycleView的数据转换】使用sp进行搜索之后的关键字的保存;

 

【数据适配器】

 

【搜索之后的数据的存储】

【数据适配器的设置】

 【补充】现在我们的数据是存储在sp中,一般的是存在数据库中;

 

【正常的数据的存储的做法】将请求的数据累计到数据库中,当打开searchView的时候,将数据取出,然后进行数据的取出转换,然后显示;


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM