在cardview Android中,收藏夹按钮出错

问题描述 投票:0回答:1

卡片视图中我最喜欢的按钮有问题。我是编程初学者。所以我不知道错误到底是什么。我使用firebase在cardview中设置数据和文本,然后我得到src并设置为另一个活动。

E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 19121696)
E/AndroidRuntime: Error reporting crash
                  android.os.TransactionTooLargeException: data parcel size 19121696 bytes
                      at android.os.BinderProxy.transactNative(Native Method)
                      at android.os.BinderProxy.transact(Binder.java:503)
                      at android.app.ActivityManagerProxy.handleApplicationCrash(ActivityManagerNative.java:5523)
                      at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:96)
                      at com.google.firebase.crash.FirebaseCrash$zzc.uncaughtException(Unknown Source)
                      at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
                      at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)

我的代码

viewHolder.mStarBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
    mProccessStar = true;
    mDatabaseStar.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            DatabaseReference newPost = mDatabaseStar.push();
            newPost.child("title").setValue(model.getTitle());
            newPost.child("desc").setValue(model.getDesc());

            if (mProccessStar) {
                if (dataSnapshot.child(post_key1).hasChild(mAuth1.getCurrentUser().getUid())) {
                    mDatabaseStar.child(post_key1).child(mAuth1.getCurrentUser().getUid()).removeValue();
                    mProccessStar = false;
                } else {
                    mDatabaseStar.child(post_key1).child(mAuth1.getCurrentUser().getUid()).setValue(newPost);
                    mProccessStar = false;
                }
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });

    public void setStarBtn (final String post_key1){
        mDatabaseStar.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                if (dataSnapshot.child(post_key1).hasChild(mAuth.getCurrentUser().getUid())){
                    mStarBtn.setImageResource(R.mipmap.ic_star_gold);
                }else {
                    mStarBtn.setImageResource(R.mipmap.ic_star_gray);
                }
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });
    }
java firebase firebase-realtime-database parameter-passing android-cardview
1个回答
0
投票

使用方法synetask或doInBackground

© www.soinside.com 2019 - 2024. All rights reserved.