找到名称冲突的getter:isFocusable

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

当我在聊天系统中发送图像时,它崩溃并显示此错误:

 Found conflicting getters for name: isFocusable

我可以将图像存储到firebase存储中,但我无法将其存储在firebase实时数据库中。

@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

这个数据库会在用户输入文本和发送时生成,如果用户发送图像,数据库结构几乎相同,只需“类型”将其更改为图像而“消息”不是存储文本。这是一个uri的存储

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

模型类

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());
}

任何人都可以帮我解决这个问题吗?

android firebase-realtime-database firebase-storage
1个回答
0
投票

尝试将这些数据传递给另一个方法并将其添加到数据库中。它应该有效

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