All Projects → wp529 → Exposure

wp529 / Exposure

Licence: Apache-2.0 license
Exposure是一个帮助做曝光统计需求的库,可以很方便的对曝光事件进行埋点,在现有代码上少量侵入即可实现曝光埋点。支持RV的线性布局、网格布局、瀑布流布局、横向滑动RV,ScrollView等各种滚动布局。支持配置item的有效曝光面积。

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Exposure

Bouncy
RecyclerView and NestedScrollView with physics-based bouncy overscroll effect
Stars: ✭ 166 (+225.49%)
Mutual labels:  recyclerview
SortedListAdapter
The RecyclerView.Adapter that makes your life easy!
Stars: ✭ 48 (-5.88%)
Mutual labels:  recyclerview
PullSeparateRecyclerView
No description or website provided.
Stars: ✭ 29 (-43.14%)
Mutual labels:  recyclerview
XamarinItemTouchHelper
Basic example of using ItemTouchHelper to add drag & drop and swipe-to-dismiss to RecyclerView for Xamarin
Stars: ✭ 35 (-31.37%)
Mutual labels:  recyclerview
meetups-archivos
Ppts, códigos y videos de las meetups, data science days, videollamadas y workshops. Data Science Research es una organización sin fines de lucro que busca difundir, descentralizar y difundir los conocimientos en Ciencia de Datos e Inteligencia Artificial en el Perú, dando oportunidades a nuevos talentos mediante MeetUps, Workshops y Semilleros …
Stars: ✭ 60 (+17.65%)
Mutual labels:  bigdata
cds
Data syncing in golang for ClickHouse.
Stars: ✭ 839 (+1545.1%)
Mutual labels:  bigdata
BirthdayReminder
Open source Android application which keeps track of and reminds users of their loved ones birthdays. View on the PlayStore here: https://play.google.com/store/apps/details?id=website.julianrosser.birthdays
Stars: ✭ 29 (-43.14%)
Mutual labels:  recyclerview
UnROOT.jl
Native Julia I/O package to work with CERN ROOT files
Stars: ✭ 52 (+1.96%)
Mutual labels:  bigdata
awesome-bigdata
A curated list of awesome big data frameworks, ressources and other awesomeness.
Stars: ✭ 11,093 (+21650.98%)
Mutual labels:  bigdata
MultiSelectionRecyclerView
Android RecyclerView multi selection expand list items and change list items color
Stars: ✭ 19 (-62.75%)
Mutual labels:  recyclerview
PinnedSectionRecyclerView
simple RecyclerView with pinned sections for Android.
Stars: ✭ 21 (-58.82%)
Mutual labels:  recyclerview
TwerkyListView
A beautifully animated recycler-list-view, that twerks the way African earthworms do in order to move
Stars: ✭ 19 (-62.75%)
Mutual labels:  recyclerview
App-Manager-Android
An app manager for Android written in Kotlin. View app related info, launch or uninstall apps.
Stars: ✭ 31 (-39.22%)
Mutual labels:  recyclerview
environmental-exposure-ontology
Modular environmental exposures ontology
Stars: ✭ 20 (-60.78%)
Mutual labels:  exposure
SparkTwitterAnalysis
An Apache Spark standalone application using the Spark API in Scala. The application uses Simple Build Tool(SBT) for building the project.
Stars: ✭ 29 (-43.14%)
Mutual labels:  bigdata
flink-learn
Learning Flink : Flink CEP,Flink Core,Flink SQL
Stars: ✭ 70 (+37.25%)
Mutual labels:  bigdata
Statik
A simple static list information backed by RecyclerView for Android in Kotlin
Stars: ✭ 22 (-56.86%)
Mutual labels:  recyclerview
solid
Solid Android components
Stars: ✭ 33 (-35.29%)
Mutual labels:  recyclerview
Searchable-RecyclerView-Demo
An example app using a SearchView to filter items in a RecyclerView while taking full advantage of item animations!
Stars: ✭ 722 (+1315.69%)
Mutual labels:  recyclerview
InfiniteScroll
You can do a Endless scroll in ListView or RecyclerView with simple steps, with a listener for do request to your web service.
Stars: ✭ 28 (-45.1%)
Mutual labels:  recyclerview

Exposure

Exposure是一个很方便对View进行曝光埋点收集的库,不用修改现有布局实现方式,只需在现有代码上做极少量修改即可实现View的曝光埋点。支持判断View是否达到有效曝光面积,支持RecyclerView的线性布局、网格布局、瀑布流布局,横向滑动曝光埋点,支持对指定View进行曝光收集。

添加依赖:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}
dependencies {
	implementation 'com.github.wp529:Exposure:1.2.2'
}
使用方式:
  1. 将需要采集曝光的View替换为对应的曝光View,库里面提供了三个曝光View (ExposureLinearLayout,ExposureFrameLayout,ExposureRelativeLayout),若需其他类型的曝光View可以自行让对应View实现IProvideExposureData接口

    <?xml version="1.0" encoding="utf-8"?>
    <com.wp.exposure.view.ExposureFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/exposureRoot"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <TextView
            android:id="@+id/tvText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            tools:text="TEXT" />
    </com.wp.exposure.view.ExposureLinearLayout>
  2. 为曝光View绑定上对应的曝光数据

    //注:这里的data对象最好实现了equals方法
    exposureRoot.exposureBindData = data

以下两种方式根据布局方式选择其一

RecyclerView添加曝光收集

在给RecyclerView设置完adapter后实例化RecyclerViewExposureHelper,必须在设置完adapter后才能实例化的原因是为了能让RecyclerViewExposureHelper在adapter调用更新item方法后可以自动计算曝光数据。实例化时需传递五个参数

  • recyclerView 需要收集曝光的RecyclerView
  • exposureValidAreaPercent 判定曝光的面积,即大于这个面积才算做曝光,百分制,eg:设置为50 item的面积为200平方,则必须要展示200 * 50% = 100平方及以上才算为曝光
  • lifecycleOwner RecyclerView感知此生命周期组件,根据生命周期感知RV可见性,以便自动处理开始曝光和结束曝光,一般情况RV在Activity中传Activity,在Fragment中传Fragment
  • mayBeCoveredViewList 可能会遮挡RV的View集合
  • exposureStateChangeListener 曝光状态改变监听器
    recyclerViewExposureHelper =
             RecyclerViewExposureHelper(
                 recyclerView = rvList,
                 exposureValidAreaPercent = 50,
                 lifecycleOwner = this,
                 mayBeCoveredViewList = null,
                 exposureStateChangeListener = object : IExposureStateChangeListener<String> {
                     override fun onExposureStateChange(
                         bindExposureData: String,
                         position: Int,
                         inExposure: Boolean
                     ) {
                         Log.i(
                             "ListActivity", "${bindExposureData}${
                                 if (inExposure) {
                                     "开始曝光"
                                 } else {
                                     "结束曝光"
                                 }
                             }"
                         )
                     }
                 }
             )

其他情况:若RecyclerView被嵌套在可滚动控件(eg:ScrollView,NestedScrollView,RecyclerView等)中,将会导致RecyclerViewExposureHelper中持有的RecyclerView不能响应滑动的情况,就必须由外部告知RecyclerView滚动状态然后触发曝光收集。具体做法:给可滚动控件添加滚动监听,滚动监听中调用recyclerViewExposureHelper.onScroll()

对指定View添加曝光收集

实例化ViewExposureHelper,实例化时需传递五个参数,与RecyclerViewExposureHelper基本一致

  • viewList 需要指定收集曝光的View集合

       val helper = ViewExposureHelper(
             viewList = list,
             exposureValidAreaPercent = 50,
             lifecycleOwner = this,
             mayBeCoveredViewList = null,
             exposureStateChangeListener = object : IExposureStateChangeListener<String> {
                 @SuppressLint("LongLogTag")
                 override fun onExposureStateChange(
                     bindExposureData: String,
                     position: Int,
                     inExposure: Boolean
                 ) {
                     Log.i(
                         "CollectViewGroupActivity", "${bindExposureData}${
                             if (inExposure) {
                                 "开始曝光"
                             } else {
                                 "结束曝光"
                             }
                         }"
                     )
                 }
             }
         )

1.若指定收集曝光的View在可滚动的布局中,那么在滚动时,需调用helper.onScroll()

2.若指定收集曝光的View Visible状态变更,helper.childViewVisibleChange()

3.若需动态添加指定收集曝光的View,则需调用helper.addViewToRecordExposure(view)


至此,曝光收集接入完成,只需在onExposureStateChange回调中进行处理即可。onExposureStateChange回调会回传三个参数。

  1. view绑定的曝光数据
  2. 曝光状态改变的位置
  3. 曝光状态。曝光状态true代表view从未曝光状态进入曝光中状态,false代表view从曝光中状态进入结束曝光状态

View曝光埋点对客户端来说只用处理三个问题,此库的作用即是处理这三个问题

  • view可见(开始曝光)

  • view不可见(结束曝光)

  • view可见面积是否为有效曝光面积

埋点SDK一般会提供三个api供客户端调用

  • onItemExposureStart()

  • onItemExposureEnd()

  • onItemExposureUpload()

所以只需在onExposureStateChange里调用埋点SDK对应的api即可,至于曝光时长是否为有效曝光一般由埋点SDK进行计算

若没有埋点SDK,也可通过onExposureStateChange自行处理相关逻辑

可查看demo获知更多使用姿势
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].