如何更新Firebase Recyclerview适配器中的特定项目?

时间:2017-03-13 18:04:13

标签: android firebase firebase-realtime-database android-recyclerview firebaseui

我有一个项目列表,我正在使用Firebase回收站视图UI库适配器加载,现在我想从客户端(而不是数据库)的其他活动更新/刷新这些项目中的单个元素?我怎么能这样做?

MyViewholder:

public class LessonViewHolder extends RecyclerView.ViewHolder {

    public TextView title;
    public TextView short_title;
    public ImageView lessonIconView;
    private FirebaseRecyclerAdapter<Lesson, LessonViewHolder> mAdapter;


    public LessonViewHolder(View view) {
        super(view);

        title = (TextView) view.findViewById(R.id.cardTitle);
        lessonIconView =(ImageView) view.findViewById(R.id.lesson_icon);
        short_title = (TextView) view.findViewById(R.id.text_title);
    }
    public void bindToPost(Lesson post) {

        //  Log.d("Post", String.valueOf(post));
        if(post.getTitle() !=null)
        {
            title.setText(Html.fromHtml(post.getTitle()));
        }
        if(post.getShort_title()!=null) {

            short_title.setText(Html.fromHtml(post.getShort_title()));
        }
        if (post.getIcon() != null) {
            if(post.getColor()!=null) {
                TextDrawable drawableHindi = TextDrawable.builder()
                .buildRound(String.valueOf(getLayoutPosition() + 1), Color.parseColor(post.getColor()));
                lessonIconView.setImageDrawable(drawableHindi);
            }
            else {
                Picasso.with(itemView.getContext()).load(post.getIcon()).into(lessonIconView);
            }
        }
    }
}

我的片段:

LessonViewHolder.class, ref) {
    @Override
    protected void populateViewHolder(final LessonViewHolder viewHolder, final Lesson model, final int position) {

        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AppEventsLogger logger = AppEventsLogger.newLogger(getActivity());
                logger.logEvent("ClickedLessonItem;"+ Locale.getDefault()+";"+position);
            }
        }

详细说明:

我正在通过Firebase ui适配器从Firebase数据库加载项目,现在点击一个项目就打开了一个Web视图活动,在webview活动中{I}}事件之后,我需要更新项目中的一个特定项目在循环器视图中显示,请注意我需要更新客户端的项目而不是数据库。

我的网页浏览活动:

onPageStarted

0 个答案:

没有答案