Giter Site home page Giter Site logo

Comments (4)

IceMimosa avatar IceMimosa commented on July 25, 2024

@lizwangying

from androiddemo.

lizwangying avatar lizwangying commented on July 25, 2024

半自动 imp 的统计触发时机是, view 从屏幕中出现。上下滚动,会造成头部和顶部的 item 被统计。
可以给您提供一个 针对 RecyclerView 的demo, 如下:

public class RecyclerViewImpActivity extends Activity {

    RecyclerView recyclerView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_imp_recycler);
        recyclerView = findViewById(R.id.rv_imp);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        Adapter adapter = new Adapter();
        recyclerView.setAdapter(adapter);
        findViewById(R.id.btn_imp_notify).setOnClickListener(v -> {
            adapter.notifyDataSetChanged();
        });
    }

    private static class Adapter extends RecyclerView.Adapter<ViewHolder>{

        @NonNull
        @Override
        public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View rootView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_imp, parent, false);
            return new ViewHolder(rootView);
        }

        @Override
        public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
            holder.left.setText("position: " + position);
            JSONObject jsonObject = new JSONObject();
            try {
                jsonObject.put("position", position);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            if (position == 0){
                LogUtil.d("LDK", "herererere");
            }
            GrowingIO.getInstance().markViewImpression(new ImpressionMark(holder.left, "列表项:" + position)
                    .setGlobalId(String.valueOf(position))
                    .setVariable(jsonObject));
        }

        @Override
        public int getItemCount() {
            return 100;
        }
    }

    private static class ViewHolder extends RecyclerView.ViewHolder{
        private TextView left, middle, right;

        public ViewHolder(View itemView) {
            super(itemView);
            left = itemView.findViewById(R.id.tv_left);
            middle = itemView.findViewById(R.id.tv_middle);
            right = itemView.findViewById(R.id.tv_right);
            middle.setText("中间部分");
            right.setText("两边部分");
        }
    }
}

image

from androiddemo.

lizwangying avatar lizwangying commented on July 25, 2024

另外,SDK 相关问题可以直接提交工单,接到反馈可能会更快。
我们的帮助文档,希望能在产品使用上帮助到您。

半自动IMP文档:
https://docs.growingio.com/docs/developer-manual/sdkintegrated/android-sdk/android-imp

from androiddemo.

lizwangying avatar lizwangying commented on July 25, 2024

@ikkyu0319 忘记艾特了。。。。。

from androiddemo.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.