package amu.roboclub.ui.fragments;

import android.os.Bundle;
import android.support.design.widget.BottomSheetDialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

import amu.roboclub.R;
import butterknife.BindView;
import butterknife.ButterKnife;

public class FeedbackDialogFragment extends BottomSheetDialogFragment {

    private final DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference("feedback");
    @BindView(R.id.feedbackEdt)
    EditText edt;
    @BindView(R.id.send)
    ImageView send;

    public static FeedbackDialogFragment newInstance() {
        return new FeedbackDialogFragment();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View root = inflater.inflate(R.layout.bottomsheet_feedback, container, false);

        ButterKnife.bind(this, root);

        final FeedbackDialogFragment current = this;

        send.setOnClickListener(view -> {
            String feedback = edt.getText().toString();
            if (feedback.isEmpty()) {
                Toast.makeText(getContext(), R.string.empty_feedback, Toast.LENGTH_SHORT).show();
                return;
            }

            databaseReference.push().setValue(feedback, (databaseError, databaseReference1) -> {
                if (databaseError != null)
                    Toast.makeText(getContext(), databaseError.getMessage(), Toast.LENGTH_SHORT).show();
                else
                    Toast.makeText(getContext(), R.string.feedback_posted, Toast.LENGTH_SHORT).show();
            });

            current.dismiss();

        });
        return root;
    }
}

@@ -48,17 +48,92 @@
 oid.
-os.Bundle
+content.Context;%0Aimport android.os.Bundle;%0Aimport android.support.annotation.NonNull
 ;%0Aim
@@ -1011,16 +1011,25 @@
 ateView(
+@NonNull 
 LayoutIn
@@ -1303,16 +1303,87 @@
  = this;
+%0A        final Context context = getActivity().getApplicationContext();
 %0A%0A      
@@ -1742,9 +1742,8 @@
 ence
-1
 ) -%3E
@@ -1761,20 +1761,33 @@
         
-if (
+String message = 
 database
@@ -1803,140 +1803,85 @@
 null
-)%0A                    Toast.makeText(getContext(), databaseError.getMessage(), Toast.LENGTH_SHORT).show();%0A                else%0A    
+ ? databaseError.getMessage() : context.getString(R.string.feedback_posted);%0A
     
@@ -1911,46 +1911,24 @@
 ext(
-getC
+c
 ontext
-(), R.string.feedback_posted
+, message
 , To

Use application context to prevent app crash