Firestore卡在“进度”对话框中

时间:2019-12-10 05:49:56

标签: android google-cloud-firestore

大家好,我可以尝试将文件保存到Firestore上,但我无法解决我的问题,但这不会转到我的pdf文件中,因为论文可以帮助我,我的辩护是明天我真的需要完成此操作,首先这是可以的然后我尝试了其他方法,然后在另一天发生了错误

FirebaseAuth mAuth;
FirebaseFirestore db3 = FirebaseFirestore.getInstance();
ProgressDialog progressDialog;
Button b1,b2;
TextView t3,t4;
EditText e1;


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



    b2 = (Button)findViewById(R.id.button7);
    b1 = (Button)findViewById(R.id.button6);
    e1 = (EditText)findViewById(R.id.editText10);
    t3 = (TextView)findViewById(R.id.textView5);


    progressDialog = new ProgressDialog(Blood.this);
    progressDialog.setTitle("OSIX");
    progressDialog.setMessage("Saving Profile, Please Wait.....");


    mAuth = FirebaseAuth.getInstance();
    ActionBar ac = getSupportActionBar();
    ac.hide();

    Calendar calendar = Calendar.getInstance();
    SimpleDateFormat format = new SimpleDateFormat("hh:mm a");
    final String time  = format.format(calendar.getTime());
    TextView t2 =  findViewById(R.id.textView24);
    t2.setText("Current Time : " +  time);


    Calendar calendar2 = Calendar.getInstance();
    SimpleDateFormat format1 = new SimpleDateFormat(("MMMM dd, YYYY"));
    final String date =  format1.format(calendar2.getTime());
    TextView t1 = findViewById(R.id.textView23);
    t1.setText("Current Date : " + date);




    b1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final String blood_glucose = e1.getText().toString();


            if (Integer.parseInt(blood_glucose)>=101 && Integer.parseInt(blood_glucose)<=125){
                t3.setText("Impaired Glucose");
                t3.setTextColor(Color.YELLOW);
            }else if (Integer.parseInt(blood_glucose)>=80 && Integer.parseInt(blood_glucose)<=100) {
                t3.setText("Normal Glucose");
                t3.setTextColor(Color.GREEN);
            }else if (Integer.parseInt(blood_glucose)>=126 && Integer.parseInt(blood_glucose)<=179){
                 t3.setText("Diabetic");
                 t3.setTextColor(Color.RED);
            }else if (Integer.parseInt(blood_glucose)>=73 && Integer.parseInt(blood_glucose)<=79) {
                t3.setText("Low Glucose");
                t3.setTextColor(Color.RED);
            }else if (Integer.parseInt(blood_glucose)<=72) {
                t3.setText("Risk of Having Hypoglycemia");
                t3.setTextColor(Color.RED);
            }else if (Integer.parseInt(blood_glucose)>=180) {
                t3.setText("Risk of Having Hyperglycemia");
                t3.setTextColor(Color.RED);
            }
        }
    });




b2.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        String blood_glucose = e1.getText().toString();
        String result = t3.getText().toString();


        if (blood_glucose.isEmpty()) {
            e1.setError("Field is Empty");
            e1.requestFocus();



        }else if (Integer.parseInt(blood_glucose)>=73 && Integer.parseInt(blood_glucose)<=79) {
            progressDialog.show();
            FirebaseUser user= mAuth.getCurrentUser();
            sugar answer = new sugar(date,time,blood_glucose,result);
            db3.collection("Blood Glucose").document(user.getEmail()).collection("Date").document(date).collection("Time").document(time).set(answer)
                    .addOnCompleteListener(new OnCompleteListener<Void>() {
                        @Override
                        public void onComplete(@NonNull Task<Void> task) {
                            if(task.isSuccessful()){
                                startActivity(new Intent(Blood.this, Tips_Low.class));
                                progressDialog.dismiss();
                            }
                        }
                    });


        }else if (Integer.parseInt(blood_glucose)>=126 && Integer.parseInt(blood_glucose)<=179){
            progressDialog.show();
            FirebaseUser user= mAuth.getCurrentUser();
            sugar answer = new sugar(date,time,blood_glucose,result);
            db3.collection("Blood Glucose").document(user.getEmail()).collection("Date").document(date).collection("Time").document(time).set(answer)
                    .addOnCompleteListener(new OnCompleteListener<Void>() {
                        @Override
                        public void onComplete(@NonNull Task<Void> task) {
                            if(task.isSuccessful()){
                                startActivity(new Intent(Blood.this,Tips_Diabetic.class));
                                progressDialog.dismiss();
                            }
                        }
                    });


        }else if (Integer.parseInt(blood_glucose)>=101 && Integer.parseInt(blood_glucose)<=125){
            progressDialog.show();
            FirebaseUser user= mAuth.getCurrentUser();
            sugar answer = new sugar(date,time,blood_glucose,result);
            db3.collection("Blood Glucose").document(user.getEmail()).collection("Date").document(date).collection("Time").document(time).set(answer)
                    .addOnCompleteListener(new OnCompleteListener<Void>() {
                        @Override
                        public void onComplete(@NonNull Task<Void> task) {
                            if(task.isSuccessful()){
                                startActivity(new Intent(Blood.this,Navbar.class));
                                progressDialog.dismiss();
                            }
                        }
                    });

        }else if (Integer.parseInt(blood_glucose)>=80 && Integer.parseInt(blood_glucose)<=100){
            progressDialog.show();
            FirebaseUser user= mAuth.getCurrentUser();
            sugar answer = new sugar(date,time,blood_glucose,result);
            db3.collection("Blood Glucose").document(user.getEmail()).collection("Date").document(date).collection("Time").document(time).set(answer)
                    .addOnCompleteListener(new OnCompleteListener<Void>() {
                        @Override
                        public void onComplete(@NonNull Task<Void> task) {
                            if(task.isSuccessful()){
                                startActivity(new Intent(Blood.this,Navbar.class));
                                progressDialog.dismiss();
                            }
                        }
                    });


        }else if (Integer.parseInt(blood_glucose)<=72){
            progressDialog.show();
            FirebaseUser user= mAuth.getCurrentUser();
            sugar answer = new sugar(date,time,blood_glucose,result);
            db3.collection("Blood Glucose").document(user.getEmail()).collection("Date").document(date).collection("Time").document(time).set(answer)
                    .addOnCompleteListener(new OnCompleteListener<Void>() {
                        @Override
                        public void onComplete(@NonNull Task<Void> task) {
                            if(task.isSuccessful()){
                                startActivity(new Intent(Blood.this,Navbar.class));
                                progressDialog.dismiss();
                            }
                        }
                    });


        }else if (Integer.parseInt(blood_glucose)>=180){
            progressDialog.show();
            FirebaseUser user= mAuth.getCurrentUser();
            sugar answer = new sugar(date,time,blood_glucose,result);
            db3.collection("Blood Glucose").document(user.getEmail()).collection("Date").document(date).collection("Time").document(time).set(answer)
                    .addOnCompleteListener(new OnCompleteListener<Void>() {
                        @Override
                        public void onComplete(@NonNull Task<Void> task) {
                            if(task.isSuccessful()){
                                startActivity(new Intent(Blood.this,Navbar.class));
                                progressDialog.dismiss();
                            }
                        }
                    });
        }

    }
});
}

如果此活动不存在此错误,则日志猫出现错误?你能告诉我在哪里吗?我是android studio的新手

enter image description here

0 个答案:

没有答案