1313import android .view .Window ;
1414import android .widget .Button ;
1515
16+ import butterknife .BindView ;
17+ import butterknife .ButterKnife ;
18+ import butterknife .OnClick ;
1619import com .facebook .drawee .generic .GenericDraweeHierarchyBuilder ;
1720import com .facebook .drawee .view .SimpleDraweeView ;
1821import com .facebook .imagepipeline .listener .RequestListener ;
2932 */
3033
3134public class SimilarImageDialogFragment extends DialogFragment {
35+
36+ @ BindView (R .id .orginalImage )
3237 SimpleDraweeView originalImage ;
38+ @ BindView (R .id .possibleImage )
3339 SimpleDraweeView possibleImage ;
40+ @ BindView (R .id .postive_button )
3441 Button positiveButton ;
42+ @ BindView (R .id .negative_button )
3543 Button negativeButton ;
3644 onResponse mOnResponse ;//Implemented interface from shareActivity
3745 Boolean gotResponse = false ;
46+
3847 public SimilarImageDialogFragment () {
3948 }
4049 public interface onResponse {
41- public void onPostiveResponse ();
50+ public void onPositiveResponse ();
51+
4252 public void onNegativeResponse ();
4353 }
54+
4455 @ Override
4556 public View onCreateView (LayoutInflater inflater , @ Nullable ViewGroup container , @ Nullable Bundle savedInstanceState ) {
4657 View view = inflater .inflate (R .layout .fragment_similar_image_dialog , container , false );
58+ ButterKnife .bind (this ,view );
4759 Set <RequestListener > requestListeners = new HashSet <>();
4860 requestListeners .add (new RequestLoggingListener ());
4961
50- originalImage =(SimpleDraweeView ) view .findViewById (R .id .orginalImage );
51- possibleImage =(SimpleDraweeView ) view .findViewById (R .id .possibleImage );
52- positiveButton = (Button ) view .findViewById (R .id .postive_button );
53- negativeButton = (Button ) view .findViewById (R .id .negative_button );
54-
5562 originalImage .setHierarchy (GenericDraweeHierarchyBuilder
5663 .newInstance (getResources ())
5764 .setPlaceholderImage (VectorDrawableCompat .create (getResources (),
@@ -70,22 +77,6 @@ R.drawable.ic_error_outline_black_24dp, getContext().getTheme()))
7077 originalImage .setImageURI (Uri .fromFile (new File (getArguments ().getString ("originalImagePath" ))));
7178 possibleImage .setImageURI (Uri .fromFile (new File (getArguments ().getString ("possibleImagePath" ))));
7279
73- negativeButton .setOnClickListener (new View .OnClickListener () {
74- @ Override
75- public void onClick (View view ) {
76- mOnResponse .onNegativeResponse ();
77- gotResponse = true ;
78- dismiss ();
79- }
80- });
81- positiveButton .setOnClickListener (new View .OnClickListener () {
82- @ Override
83- public void onClick (View view ) {
84- mOnResponse .onPostiveResponse ();
85- gotResponse = true ;
86- dismiss ();
87- }
88- });
8980 return view ;
9081 }
9182
@@ -105,8 +96,23 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
10596 @ Override
10697 public void onDismiss (DialogInterface dialog ) {
10798// I user dismisses dialog by pressing outside the dialog.
108- if (!gotResponse )
99+ if (!gotResponse ) {
109100 mOnResponse .onNegativeResponse ();
101+ }
110102 super .onDismiss (dialog );
111103 }
104+
105+ @ OnClick (R .id .negative_button )
106+ public void onNegativeButtonClicked () {
107+ mOnResponse .onNegativeResponse ();
108+ gotResponse = true ;
109+ dismiss ();
110+ }
111+
112+ @ OnClick (R .id .postive_button )
113+ public void onPositiveButtonClicked () {
114+ mOnResponse .onPositiveResponse ();
115+ gotResponse = true ;
116+ dismiss ();
117+ }
112118}
0 commit comments