简体   繁体   中英

Found conflicting getters for name: isFocusable

when I sending an image in my chat system, it crash and showing this error:

 Found conflicting getters for name: isFocusable

I can store the image into firebase storage but I cant store it in firebase real-time database.

@Override
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) {
        Uri imageUri = data.getData();

        databaseReference = FirebaseDatabase.getInstance().getReference().child("Chats");

        final StorageReference fileReference = storageReference.child(System.currentTimeMillis()
                + "." + getFileExtension(imageUri));

        final String id = firebaseUser.getUid();
        final String key = firebaseDatabase.getReference("Chats").push().getKey();

        mUploadTask = fileReference.putFile(imageUri);

        mUploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
            @Override
            public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
                if (!task.isSuccessful()) {
                    throw task.getException();
                }
                return fileReference.getDownloadUrl();
            }
        }).addOnCompleteListener(new OnCompleteListener<Uri>() {
            @Override
            public void onComplete(@NonNull Task<Uri> task) {

                if (task.isSuccessful()) {
                    String downloadUrl = task.getResult().toString();

                    final HashMap<String, Object> messageMap = new HashMap();
                    messageMap.put("Key", key);
                    messageMap.put("Sender", id);
                    messageMap.put("Receiver", userid);
                    messageMap.put("Message", downloadUrl);
                    messageMap.put("isseen", false);
                    messageMap.put("time", time);
                    messageMap.put("type", "image");
                    System.out.println("haha chat " + downloadUrl);

                    databaseReference.child(key).updateChildren(messageMap);

                }
            }
        }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Toast.makeText(getApplicationContext(), "" + e, Toast.LENGTH_LONG).show();
                System.out.println("haha chat e " + e);
            }
        });

    }
}

this is my database structure

this database will generated when users enter text and send, if users are sending image, the database structure almost same, just the "type" will change it to image and the "Message" is not store text. It is store an uri like

https://firebasestorage.googleapis.com/v0/b/final-year-project-51c9a.appspot.com/o/Chat%20Images%2F1551454994072.jpg?alt=media&token=6ef744f8-0a7c-42a3-b5ba-9ea660a0ec76

Model Class

import android.support.annotation.NonNull;

private String Key, Sender, Receiver, Message, time, type;
private boolean isseen;

public Chat(String Key, String Sender, String Receiver, String Message, String time, boolean isseen,String type) {
    this.Key = Key;
    this.Sender = Sender;
    this.Receiver = Receiver;
    this.Message = Message;
    this.isseen = isseen;
    this.time = time;
    this.type=type;

}

public Chat() {

}

public String getKey() {
    return Key;
}

public String getSender() {
    return Sender;
}

public String getReceiver() {
    return Receiver;
}

public String getMessage() {
    return Message;
}

public boolean isIsseen() {
    return isseen;
}

public String getTime() {
    return time;
}

public String getType() {
    return type;
}

public void setTime(String time) {
    this.time = time;
}


@Override
public int compareTo(@NonNull Chat o) {
    if (getTime() == null || o.getTime() == null)
        return 0;

    return o.getTime().compareTo(getTime());
}

Can anyone help me to solve this?

Try to pass those data to another method and add it into database. It should works

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM