FirebaseError未解决

时间:2016-12-19 02:15:51

标签: android firebase firebase-realtime-database

我正在编写一个更新到Firebase的应用程序,但我无法编写oncancelled函数,因为它cannot resolve symbol FirebaseError

我的代码如下:

package com.test.myapplication;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Base64;
import android.util.Log;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.TextView;

import static com.test.myapplication.R.id.radioButton5;
import static com.test.myapplication.R.id.radioButton6;
import static com.test.myapplication.R.id.radioButton8;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;

import java.util.ArrayList;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.ChildEventListener;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;

public class OfficialDetail extends AppCompatActivity {

TextView textViewStreet;
TextView textViewLat;
TextView textViewLong;
TextView textViewDescription;
TextView textViewSeverity;
TextView textViewSize;
TextView textViewEmail;
RadioButton RadioButton5;
RadioButton RadioButton6;
RadioButton RadioButton8;
DatabaseReference mRef;
DatabaseReference dRef;

ArrayList<Report> reportArrayList;

Report value;
ListView mListView;


ImageView imgView;


@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.fragment_item_detail);
    RadioButton5 = (RadioButton)findViewById(radioButton5);
    RadioButton6 = (RadioButton)findViewById(radioButton6);
    RadioButton8 = (RadioButton)findViewById(radioButton8);
    Intent intent = getIntent();

    initialize();


    if(intent!=null) {

        textViewStreet.setText(intent.getStringExtra("street_of"));
        textViewLat.setText(intent.getStringExtra("lat_of"));
        textViewLong.setText(intent.getStringExtra("long_of"));
        textViewDescription.setText(intent.getStringExtra("descrip_of"));
        textViewSeverity.setText(intent.getStringExtra("severity_of"));
        textViewSize.setText(intent.getStringExtra("size_of"));

        if(intent.getStringExtra("Off").equals("Official")){
            RadioButton5.setEnabled(false);
            RadioButton8.setEnabled(false);
        }else{
            RadioButton5.setEnabled(false);
            RadioButton6.setEnabled(false);
        }
        if (RadioButton6.isChecked()){
            reportArrayList = new ArrayList<>();


            dRef = FirebaseDatabase.getInstance().getReference();
            mRef = dRef.child("report");
            Query qRef;
            qRef = dRef.orderByChild("Status").equalTo("still_there");

            qRef.addListenerForSingleValueEvent(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot tasksSnapshot) {
                    for (DataSnapshot snapshot: tasksSnapshot.getChildren()) {
                        snapshot.getRef().child("Status").setValue("removal_confirmed");
                    }
                }
                @Override
                public void onCancelled(**FirebaseError**  firebaseError) {
                    System.out.println("The read failed: " + firebaseError.getMessage());
                }
            });
        }
        byte[] decodedString = Base64.decode(intent.getStringExtra("img_of"), Base64.DEFAULT);
        Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
        imgView.setImageBitmap(decodedByte);


    }

}

private void initialize(){


    textViewStreet = (TextView) findViewById(R.id.textView22);
    imgView = (ImageView) findViewById(R.id.imageView);
    textViewDescription = (TextView) findViewById(R.id.item_detail);
    textViewSeverity = (TextView) findViewById(R.id.textView24);
    textViewSize = (TextView) findViewById(R.id.textView26);
    textViewLat = (TextView) findViewById(R.id.textView13);
    textViewLong = (TextView) findViewById(R.id.textView17);

}
}

我遗失了import声明吗?我该如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

尝试使用header('Location')课程更改FirebaseError课程。

我遇到了同样的问题,我所做的只是删除了所有方法代码,并允许Android Studio自己创建方法定义。然后DatabaseError自动替换为FirebaseError