Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
8.9 kB
1
Indexable
Never
    private void showReportsheet(String name, String url, String useruri, String userid,
                                 String type, String postkey, String time) {


        final Dialog dialog = new Dialog(getActivity());
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.report_file_post);

        Button cancel = dialog.findViewById(R.id.cancel_report_post);
        Button submitreport = dialog.findViewById(R.id.submit_report_post);

        RadioButton sexualrb = dialog.findViewById(R.id.sexualTv_report);
        RadioButton violentrb = dialog.findViewById(R.id.violenTv_report);
        RadioButton hatefulrb = dialog.findViewById(R.id.hatefulTv_report);
        RadioButton harassmentrb = dialog.findViewById(R.id.harassmentTv_report);
        RadioButton childrb = dialog.findViewById(R.id.childTv_report);
        RadioButton infringesrb = dialog.findViewById(R.id.infringesTv_report);
        RadioButton spamrb = dialog.findViewById(R.id.spamTv_report);
        RadioButton terrorismrb = dialog.findViewById(R.id.terrorismTv_report);

        DatabaseReference reportRefPost = database.getReference("Report Post");

        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                dialog.dismiss();

            }
        });


        submitreport.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                if (sexualrb.isChecked()){

                    reportClass.setIssue("Sexual Content");
                    reportClass.setName(name);
                    reportClass.setTime(time);
                    reportClass.setType(type);
                    reportClass.setUid(userid);
                    reportClass.setUrl(url);
                    reportClass.setUseruri(useruri);

                    String key = reportRefPost.push().getKey();
                    reportRefPost.child(key).setValue(reportClass).addOnSuccessListener(new OnSuccessListener<Void>() {
                        @Override
                        public void onSuccess(Void aVoid) {
                            Toast.makeText(getActivity(), "Reported Successfully", Toast.LENGTH_SHORT).show();
                        }
                    });



                }else if (violentrb.isChecked()){

                    reportClass.setIssue("Violent of repulsive ");
                    reportClass.setName(name);
                    reportClass.setTime(time);
                    reportClass.setType(type);
                    reportClass.setUid(userid);
                    reportClass.setUrl(url);
                    reportClass.setUseruri(useruri);

                    String key = reportRefPost.push().getKey();
                    reportRefPost.child(key).setValue(reportClass).addOnSuccessListener(new OnSuccessListener<Void>() {
                        @Override
                        public void onSuccess(Void aVoid) {
                            Toast.makeText(getActivity(), "Reported Successfully", Toast.LENGTH_SHORT).show();
                        }
                    });
                }else if (hatefulrb.isChecked()){

                    reportClass.setIssue("Hateful of abusive content");
                    reportClass.setName(name);
                    reportClass.setTime(time);
                    reportClass.setType(type);
                    reportClass.setUid(userid);
                    reportClass.setUrl(url);
                    reportClass.setUseruri(useruri);

                    String key = reportRefPost.push().getKey();
                    reportRefPost.child(key).setValue(reportClass).addOnSuccessListener(new OnSuccessListener<Void>() {
                        @Override
                        public void onSuccess(Void aVoid) {
                            Toast.makeText(getActivity(), "Reported Successfully", Toast.LENGTH_SHORT).show();
                        }
                    });

                }else if (childrb.isChecked()){

                    reportClass.setIssue("Child Abuse");
                    reportClass.setName(name);
                    reportClass.setTime(time);
                    reportClass.setType(type);
                    reportClass.setUid(userid);
                    reportClass.setUrl(url);
                    reportClass.setUseruri(useruri);

                    String key = reportRefPost.push().getKey();
                    reportRefPost.child(key).setValue(reportClass).addOnSuccessListener(new OnSuccessListener<Void>() {
                        @Override
                        public void onSuccess(Void aVoid) {
                            Toast.makeText(getActivity(), "Reported Successfully", Toast.LENGTH_SHORT).show();
                        }
                    });

                }else if (infringesrb.isChecked()){

                    reportClass.setIssue("Infringes my rights");
                    reportClass.setName(name);
                    reportClass.setTime(time);
                    reportClass.setType(type);
                    reportClass.setUid(userid);
                    reportClass.setUrl(url);
                    reportClass.setUseruri(useruri);

                    String key = reportRefPost.push().getKey();
                    reportRefPost.child(key).setValue(reportClass).addOnSuccessListener(new OnSuccessListener<Void>() {
                        @Override
                        public void onSuccess(Void aVoid) {
                            Toast.makeText(getActivity(), "Reported Successfully", Toast.LENGTH_SHORT).show();
                        }
                    });
                }else if (terrorismrb.isChecked()){

                    reportClass.setIssue(" Promotes Terrorism ");
                    reportClass.setName(name);
                    reportClass.setTime(time);
                    reportClass.setType(type);
                    reportClass.setUid(userid);
                    reportClass.setUrl(url);
                    reportClass.setUseruri(useruri);

                    String key = reportRefPost.push().getKey();
                    reportRefPost.child(key).setValue(reportClass).addOnSuccessListener(new OnSuccessListener<Void>() {
                        @Override
                        public void onSuccess(Void aVoid) {
                            Toast.makeText(getActivity(), "Reported Successfully", Toast.LENGTH_SHORT).show();
                        }
                    });
                }else if (spamrb.isChecked()){

                    reportClass.setIssue("Spam or misleading");
                    reportClass.setName(name);
                    reportClass.setTime(time);
                    reportClass.setType(type);
                    reportClass.setUid(userid);
                    reportClass.setUrl(url);
                    reportClass.setUseruri(useruri);

                    String key = reportRefPost.push().getKey();
                    reportRefPost.child(key).setValue(reportClass).addOnSuccessListener(new OnSuccessListener<Void>() {
                        @Override
                        public void onSuccess(Void aVoid) {
                            Toast.makeText(getActivity(), "Reported Successfully", Toast.LENGTH_SHORT).show();
                        }
                    });
                }else if (harassmentrb.isChecked()){

                    reportClass.setIssue("Harassment Content");
                    reportClass.setName(name);
                    reportClass.setTime(time);
                    reportClass.setType(type);
                    reportClass.setUid(userid);
                    reportClass.setUrl(url);
                    reportClass.setUseruri(useruri);

                    String key = reportRefPost.push().getKey();
                    reportRefPost.child(key).setValue(reportClass).addOnSuccessListener(new OnSuccessListener<Void>() {
                        @Override
                        public void onSuccess(Void aVoid) {
                            Toast.makeText(getActivity(), "Reported Successfully", Toast.LENGTH_SHORT).show();
                        }
                    });

                }



            }
        });






        dialog.show();
        dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog.getWindow().getAttributes().windowAnimations = R.style.Bottomanim;
        dialog.getWindow().setGravity(Gravity.BOTTOM);
    }