Приложение перезапускается при попытке установить значение в Firebase - PullRequest
0 голосов
/ 25 апреля 2020

При попытке запустить приложение и нажать кнопку «Обновить», приложение перезапускается и переходит к основному действию. но в Firebase значения обновляются и изменяются, но в приложении возникают проблемы

public class BookBlood extends AppCompatActivity {
    TextView tvName,tvLocation,tvUnit,tvGroup,tvMsg;
    Button btnSubmit,btnDone;
    ImageView ivCheck;
    String group,id,requireBlood,unit,Name;
    long currentSystemTime;
    FirebaseDatabase databaseReq,databaseOrder;
    DatabaseReference requests,userOrder;
    MyOrder myOrder;
    Requests request;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_book_blood);

         Name=getIntent().getStringExtra("name");
        group=getIntent().getStringExtra("group");
        unit=getIntent().getStringExtra("unit");
        String location=getIntent().getStringExtra("location");
        id=getIntent().getStringExtra("id");
        requireBlood=getIntent().getStringExtra("requireBlood");

        databaseReq = FirebaseDatabase.getInstance();
        databaseOrder = FirebaseDatabase.getInstance();

        requests = databaseReq.getReference("bloodbank").child(id).child("Requests");
        userOrder=databaseOrder.getReference("user").child(Common.currentUser.getMobile());

         myOrder=new MyOrder(id,Name,group,requireBlood);
        request = new Requests(Common.currentUser.getName(),
                Common.currentUser.getMobile(),
                Common.currentUser.getAddress(),
                group,
                requireBlood);

        tvName=findViewById(R.id.bankName);
        tvLocation=findViewById(R.id.bankLocation);
        tvUnit=findViewById(R.id.groupUnit);
        tvGroup=findViewById(R.id.chooseGroup);
        btnSubmit=findViewById(R.id.btnConfirm);
        btnDone=findViewById(R.id.btnDone);
        tvMsg=findViewById(R.id.tvMsg);
        ivCheck=findViewById(R.id.ivCheck);
        tvName.setText(Name);
        tvUnit.setText(requireBlood);
        tvLocation.setText(location);

        String type="";

        if(group.equals("Aposi")){
            type="A+";
        }

        if(group.equals("ABposi")){
            type="AB+";
        }
        if(group.equals("Aneg")){
            type="A-";
        }if(group.equals("Bposi")){
            type="B+";
        }if(group.equals("Bneg")){
            type="B-";
        }if(group.equals("Oposi")){
            type="O+";
        }
        if(group.equals("Oneg")){
            type="O-";
        }

        tvGroup.setText(type);

        btnSubmit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                currentSystemTime=System.currentTimeMillis();  //in milli seconds.. for transaction id
                 showAlertDialog();
            }
        });
    }
    private void showAlertDialog() {
        final AlertDialog.Builder builder= new AlertDialog.Builder(BookBlood.this);
        builder.setTitle("Confirm Booking... ");
         builder.setPositiveButton("Confirm", new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {

                 userOrder.child("Myorder").child(String.valueOf(currentSystemTime)).setValue(myOrder);
                 requests.child(String.valueOf(currentSystemTime)).setValue(request);

                Toast.makeText(BookBlood.this, "Request is send to bank", Toast.LENGTH_SHORT).show();
                 btnSubmit.setVisibility(View.INVISIBLE);
                 ivCheck.setVisibility(View.VISIBLE);
                 tvMsg.setVisibility(View.VISIBLE);
                 btnDone.setVisibility(View.VISIBLE);

             }
         });

         builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {
                 dialog.dismiss();
             }
         });
         builder.show();
    }}

В этой строке возникают проблемы. значения устанавливаются в разных узлах, и когда я пытаюсь выполнить только один запрос, код работает отлично, но в обоих setValue возникает проблема userOrder.child("Myorder").child(String.valueOf(currentSystemTime)).setValue(myOrder); requests.child(String.valueOf(currentSystemTime)).setValue(request);

public class MyOrder
{
   private String bankid,bankname,group,units,status;

    public MyOrder(String bankid, String bankname, String group, String units) {
        this.bankid = bankid;
        this.bankname = bankname;
        this.group = group;
        this.units = units;
        this.status="0";
    }

    public MyOrder(String bankid, String bankName, String group, String units, String status) {
        this.bankid = bankid;
        this.bankname = bankName;
        this.group = group;
        this.units = units;
        this.status = status;
    }

    public MyOrder() {
    }

    public String getBankid() {
        return bankid;
    }

    public void setBankid(String bankid) {
        this.bankid = bankid;
    }

    public String getBankName() {
        return bankname;
    }

    public void setBankName(String bankname) {
        this.bankname = bankname;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public String getUnits() {
        return units;
    }

    public void setUnits(String units) {
        this.units = units;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }
}
12:41:07.609 14762-14762/com.ashokcouhan.blooduser I/Choreographer: Skipped 2 frames!  The application may be doing too much work on its main thread.
2020-04-25 12:41:07.707 14762-14762/com.ashokcouhan.blooduser I/Choreographer: Skipped 5 frames!  The application may be doing too much work on its main thread.
2020-04-25 12:41:08.655 14762-14762/com.ashokcouhan.blooduser I/Choreographer: Skipped 1 frames!  The application may be doing too much work on its main thread.
2020-04-25 12:41:08.671 14762-14762/com.ashokcouhan.blooduser W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@d60cd8c
2020-04-25 12:41:08.674 14762-17036/com.ashokcouhan.blooduser D/libEGL: [oppo_test] for feedback 1785468: dpy=1
2020-04-25 12:41:08.724 14762-14762/com.ashokcouhan.blooduser D/WindowManager: Add to mViews: DecorView@91762f0[BookBlood], this = android.view.WindowManagerGlobal@be12ec,pkg=com.ashokcouhan.blooduser
2020-04-25 12:41:08.800 14762-14762/com.ashokcouhan.blooduser I/Choreographer: Skipped 1 frames!  The application may be doing too much work on its main thread.
2020-04-25 12:41:10.404 14762-14762/com.ashokcouhan.blooduser D/WindowManager: Add to mViews: DecorView@c947a7c[BookBlood], this = android.view.WindowManagerGlobal@be12ec,pkg=com.ashokcouhan.blooduser
2020-04-25 12:41:10.415 14762-14762/com.ashokcouhan.blooduser I/Choreographer: Skipped 5 frames!  The application may be doing too much work on its main thread.
2020-04-25 12:41:10.450 14762-14762/com.ashokcouhan.blooduser I/Choreographer: Skipped 1 frames!  The application may be doing too much work on its main thread.
2020-04-25 12:41:11.234 14762-14956/com.ashokcouhan.blooduser D/OpenGLRenderer: endAllActiveAnimators on 0x761fe41b00 (RippleDrawable) with handle 0x7621a9e120
2020-04-25 12:41:11.251 14762-14762/com.ashokcouhan.blooduser I/Choreographer: Skipped 3 frames!  The application may be doing too much work on its main thread.
2020-04-25 12:41:11.255 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Myorder found on class com.ashokcouhan.blooduser.Model.User (fields/setters are case sensitive!)
2020-04-25 12:41:11.286 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Group found on class com.ashokcouhan.blooduser.Model.BloodBank (fields/setters are case sensitive!)
2020-04-25 12:41:11.287 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Group found on class com.ashokcouhan.blooduser.Model.BloodBank (fields/setters are case sensitive!)
2020-04-25 12:41:11.287 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Requests found on class com.ashokcouhan.blooduser.Model.BloodBank
2020-04-25 12:41:11.288 14762-14762/com.ashokcouhan.blooduser D/Group: Social Animal
2020-04-25 12:41:11.288 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Group found on class com.ashokcouhan.blooduser.Model.BloodBank (fields/setters are case sensitive!)
2020-04-25 12:41:11.288 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Requests found on class com.ashokcouhan.blooduser.Model.BloodBank
2020-04-25 12:41:11.289 14762-14762/com.ashokcouhan.blooduser D/Group: Ambika Blood Bank
2020-04-25 12:41:11.289 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Group found on class com.ashokcouhan.blooduser.Model.BloodBank (fields/setters are case sensitive!)
2020-04-25 12:41:11.290 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Requests found on class com.ashokcouhan.blooduser.Model.BloodBank
2020-04-25 12:41:11.291 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Group found on class com.ashokcouhan.blooduser.Model.BloodBank (fields/setters are case sensitive!)
2020-04-25 12:41:11.291 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Requests found on class com.ashokcouhan.blooduser.Model.BloodBank
2020-04-25 12:41:11.292 14762-14762/com.ashokcouhan.blooduser D/Group: Solanki Blood Bank
2020-04-25 12:41:11.293 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Group found on class com.ashokcouhan.blooduser.Model.BloodBank (fields/setters are case sensitive!)
2020-04-25 12:41:11.293 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Requests found on class com.ashokcouhan.blooduser.Model.BloodBank
2020-04-25 12:41:11.294 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Group found on class com.ashokcouhan.blooduser.Model.BloodBank (fields/setters are case sensitive!)
2020-04-25 12:41:11.294 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Requests found on class com.ashokcouhan.blooduser.Model.BloodBank
2020-04-25 12:41:11.295 14762-14762/com.ashokcouhan.blooduser D/Group: Meena Blood Bank
2020-04-25 12:41:11.296 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Group found on class com.ashokcouhan.blooduser.Model.BloodBank (fields/setters are case sensitive!)
2020-04-25 12:41:11.298 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Group found on class com.ashokcouhan.blooduser.Model.BloodBank (fields/setters are case sensitive!)
2020-04-25 12:41:11.298 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Requests found on class com.ashokcouhan.blooduser.Model.BloodBank
2020-04-25 12:41:11.298 14762-14762/com.ashokcouhan.blooduser D/Group: Social Animal
2020-04-25 12:41:11.299 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Group found on class com.ashokcouhan.blooduser.Model.BloodBank (fields/setters are case sensitive!)
2020-04-25 12:41:11.299 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Requests found on class com.ashokcouhan.blooduser.Model.BloodBank
2020-04-25 12:41:11.300 14762-14762/com.ashokcouhan.blooduser D/Group: Ambika Blood Bank
2020-04-25 12:41:11.300 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Group found on class com.ashokcouhan.blooduser.Model.BloodBank (fields/setters are case sensitive!)
2020-04-25 12:41:11.300 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Requests found on class com.ashokcouhan.blooduser.Model.BloodBank
2020-04-25 12:41:11.301 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Group found on class com.ashokcouhan.blooduser.Model.BloodBank (fields/setters are case sensitive!)
2020-04-25 12:41:11.302 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Requests found on class com.ashokcouhan.blooduser.Model.BloodBank
2020-04-25 12:41:11.302 14762-14762/com.ashokcouhan.blooduser D/Group: Solanki Blood Bank
2020-04-25 12:41:11.303 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Group found on class com.ashokcouhan.blooduser.Model.BloodBank (fields/setters are case sensitive!)
2020-04-25 12:41:11.303 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Requests found on class com.ashokcouhan.blooduser.Model.BloodBank
2020-04-25 12:41:11.304 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Group found on class com.ashokcouhan.blooduser.Model.BloodBank (fields/setters are case sensitive!)
2020-04-25 12:41:11.304 14762-14762/com.ashokcouhan.blooduser W/ClassMapper: No setter/field for Requests found on class com.ashokcouhan.blooduser.Model.BloodBank
2020-04-25 12:41:11.305 14762-14762/com.ashokcouhan.blooduser D/Group: Meena Blood Bank
2020-04-25 12:41:11.315 14762-14762/com.ashokcouhan.blooduser D/WindowManager: Add to mViews: com.color.internal.widget.ColorToastLayout{4dce703 V.E...... ......I. 0,0-0,0 #c0204f9 oppo:id/color_toast_layout}, this = android.view.WindowManagerGlobal@be12ec,pkg=com.ashokcouhan.blooduser
2020-04-25 12:41:11.337 14762-14762/com.ashokcouhan.blooduser I/Choreographer: Skipped 1 frames!  The application may be doing too much work on its main thread.
2020-04-25 12:41:11.354 14762-14762/com.ashokcouhan.blooduser W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@d50b0fe
2020-04-25 12:41:11.358 14762-17040/com.ashokcouhan.blooduser D/libEGL: [oppo_test] for feedback 1785468: dpy=1
2020-04-25 12:41:11.445 14762-14762/com.ashokcouhan.blooduser D/WindowManager: Add to mViews: DecorView@7ffbff8[MainActivity], this = android.view.WindowManagerGlobal@be12ec,pkg=com.ashokcouhan.blooduser
2020-04-25 12:41:11.455 14762-14762/com.ashokcouhan.blooduser I/Choreographer: Skipped 6 frames!  The application may be doing too much work on its main thread.
2020-04-25 12:41:11.571 14762-14762/com.ashokcouhan.blooduser I/Choreographer: Skipped 4 frames!  The application may be doing too much work on its main thread.
2020-04-25 12:41:13.310 14762-14762/com.ashokcouhan.blooduser I/Choreographer: Skipped 2 frames!  The application may be doing too much work on its main thread.
...