mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-30 22:34:02 +01:00 
			
		
		
		
	Merge pull request #1505 from ashishkumar468/feature/switch_to_butterknife
Feature/switch to butterknife
This commit is contained in:
		
						commit
						0cfcd4e942
					
				
					 3 changed files with 153 additions and 149 deletions
				
			
		|  | @ -26,6 +26,8 @@ import android.widget.GridView; | |||
| import android.widget.RelativeLayout; | ||||
| import android.widget.TextView; | ||||
| 
 | ||||
| import butterknife.BindView; | ||||
| import butterknife.ButterKnife; | ||||
| import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; | ||||
| import com.facebook.drawee.view.SimpleDraweeView; | ||||
| 
 | ||||
|  | @ -41,9 +43,13 @@ public class MultipleUploadListFragment extends Fragment { | |||
|         void OnMultipleUploadInitiated(); | ||||
|     } | ||||
| 
 | ||||
|     private GridView photosGrid; | ||||
|     @BindView(R.id.multipleShareBackground) | ||||
|     GridView photosGrid; | ||||
| 
 | ||||
|     @BindView(R.id.multipleBaseTitle) | ||||
|     EditText baseTitle; | ||||
| 
 | ||||
|     private PhotoDisplayAdapter photosAdapter; | ||||
|     private EditText baseTitle; | ||||
|     private TitleTextWatcher textWatcher = new TitleTextWatcher(); | ||||
| 
 | ||||
|     private Point photoSize; | ||||
|  | @ -166,9 +172,7 @@ public class MultipleUploadListFragment extends Fragment { | |||
|     @Override | ||||
|     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||||
|         View view = inflater.inflate(R.layout.fragment_multiple_uploads_list, container, false); | ||||
|         photosGrid = view.findViewById(R.id.multipleShareBackground); | ||||
|         baseTitle = view.findViewById(R.id.multipleBaseTitle); | ||||
| 
 | ||||
|         ButterKnife.bind(this,view); | ||||
|         photosAdapter = new PhotoDisplayAdapter(); | ||||
|         photosGrid.setAdapter(photosAdapter); | ||||
|         photosGrid.setOnItemClickListener((AdapterView.OnItemClickListener) getActivity()); | ||||
|  |  | |||
|  | @ -8,7 +8,6 @@ import android.animation.AnimatorSet; | |||
| import android.animation.ObjectAnimator; | ||||
| import android.content.ContentResolver; | ||||
| import android.content.Context; | ||||
| import android.content.DialogInterface; | ||||
| import android.content.Intent; | ||||
| import android.content.SharedPreferences; | ||||
| import android.content.pm.PackageManager; | ||||
|  | @ -32,16 +31,16 @@ import android.support.v4.app.ActivityCompat; | |||
| import android.support.v4.app.FragmentManager; | ||||
| import android.support.v4.content.ContextCompat; | ||||
| import android.support.v4.graphics.BitmapCompat; | ||||
| import android.support.v7.app.AlertDialog; | ||||
| import android.util.Log; | ||||
| import android.view.MenuItem; | ||||
| import android.view.View; | ||||
| import android.view.WindowManager; | ||||
| import android.view.animation.DecelerateInterpolator; | ||||
| import android.view.inputmethod.InputMethodManager; | ||||
| import android.widget.FrameLayout; | ||||
| import android.widget.TextView; | ||||
| import android.widget.Toast; | ||||
| 
 | ||||
| import butterknife.BindView; | ||||
| import butterknife.OnClick; | ||||
| import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; | ||||
| import com.facebook.drawee.view.SimpleDraweeView; | ||||
| import com.github.chrisbanes.photoview.PhotoView; | ||||
|  | @ -69,22 +68,18 @@ import fr.free.nrw.commons.caching.CacheController; | |||
| import fr.free.nrw.commons.category.CategorizationFragment; | ||||
| import fr.free.nrw.commons.category.OnCategoriesSaveHandler; | ||||
| import fr.free.nrw.commons.contributions.Contribution; | ||||
| import fr.free.nrw.commons.contributions.ContributionsActivity; | ||||
| import fr.free.nrw.commons.modifications.CategoryModifier; | ||||
| import fr.free.nrw.commons.modifications.ModificationsContentProvider; | ||||
| import fr.free.nrw.commons.modifications.ModifierSequence; | ||||
| import fr.free.nrw.commons.modifications.ModifierSequenceDao; | ||||
| import fr.free.nrw.commons.modifications.TemplateRemoveModifier; | ||||
| 
 | ||||
| import fr.free.nrw.commons.utils.ImageUtils; | ||||
| import fr.free.nrw.commons.mwapi.MediaWikiApi; | ||||
| import fr.free.nrw.commons.utils.ViewUtil; | ||||
| import timber.log.Timber; | ||||
| 
 | ||||
| import android.support.design.widget.FloatingActionButton; | ||||
| import static fr.free.nrw.commons.upload.ExistingFileAsync.Result.DUPLICATE_PROCEED; | ||||
| import static fr.free.nrw.commons.upload.ExistingFileAsync.Result.NO_DUPLICATE; | ||||
| import static java.lang.Long.min; | ||||
| 
 | ||||
| /** | ||||
|  * Activity for the title/desc screen after image is selected. Also starts processing image | ||||
|  | @ -95,6 +90,22 @@ public class ShareActivity | |||
|         implements SingleUploadFragment.OnUploadActionInitiated, | ||||
|         OnCategoriesSaveHandler,SimilarImageDialogFragment.onResponse { | ||||
| 
 | ||||
|     @BindView(R.id.container) | ||||
|     FrameLayout flContainer; | ||||
|     @BindView(R.id.backgroundImage) | ||||
|     SimpleDraweeView backgroundImageView; | ||||
|     @BindView(R.id.media_map) | ||||
|     FloatingActionButton mapsFragment; //Lets stick to camelCase | ||||
|     @BindView(R.id.media_upload_zoom_in) | ||||
|     FloatingActionButton zoomInButton; | ||||
|     @BindView(R.id.media_upload_zoom_out) | ||||
|     FloatingActionButton zoomOutButton; | ||||
|     @BindView(R.id.main_fab) | ||||
|     FloatingActionButton mainFab; | ||||
|     @BindView(R.id.expanded_image) | ||||
|     PhotoView expandedImageView; | ||||
| 
 | ||||
| 
 | ||||
|     private static final int REQUEST_PERM_ON_CREATE_STORAGE = 1; | ||||
|     private static final int REQUEST_PERM_ON_CREATE_LOCATION = 2; | ||||
|     private static final int REQUEST_PERM_ON_CREATE_STORAGE_AND_LOCATION = 3; | ||||
|  | @ -120,9 +131,6 @@ public class ShareActivity | |||
| 
 | ||||
|     private Uri mediaUri; | ||||
|     private Contribution contribution; | ||||
|     private SimpleDraweeView backgroundImageView; | ||||
|     private FloatingActionButton maps_fragment; | ||||
| 
 | ||||
|     private boolean cacheFound; | ||||
| 
 | ||||
|     private GPSExtractor imageObj; | ||||
|  | @ -143,11 +151,14 @@ public class ShareActivity | |||
| 
 | ||||
|     private Animator CurrentAnimator; | ||||
|     private long ShortAnimationDuration; | ||||
|     private FloatingActionButton zoomInButton; | ||||
|     private FloatingActionButton zoomOutButton; | ||||
|     private FloatingActionButton mainFab; | ||||
|     private boolean isFABOpen = false; | ||||
| 
 | ||||
|     //Had to make them class variables, to extract out the click listeners, also I see no harm in this | ||||
|     final Rect startBounds = new Rect(); | ||||
|     final Rect finalBounds = new Rect(); | ||||
|     final Point globalOffset = new Point(); | ||||
|     private float startScaleFinal; | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Called when user taps the submit button. | ||||
|  | @ -257,7 +268,6 @@ public class ShareActivity | |||
|         setContentView(R.layout.activity_share); | ||||
|         ButterKnife.bind(this); | ||||
|         initBack(); | ||||
|         backgroundImageView = (SimpleDraweeView) findViewById(R.id.backgroundImage); | ||||
|         backgroundImageView.setHierarchy(GenericDraweeHierarchyBuilder | ||||
|                 .newInstance(getResources()) | ||||
|                 .setPlaceholderImage(VectorDrawableCompat.create(getResources(), | ||||
|  | @ -286,37 +296,6 @@ public class ShareActivity | |||
|         if (mediaUri != null) { | ||||
|             backgroundImageView.setImageURI(mediaUri); | ||||
|         } | ||||
| 
 | ||||
|         mainFab = (FloatingActionButton) findViewById(R.id.main_fab); | ||||
|         /* | ||||
|          * called when upper arrow floating button | ||||
|          */ | ||||
|         mainFab.setOnClickListener(new View.OnClickListener() { | ||||
|             @Override | ||||
|             public void onClick(View v) { | ||||
|                 if(!isFABOpen){ | ||||
|                     showFABMenu(); | ||||
|                 }else{ | ||||
|                     closeFABMenu(); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|         zoomInButton = (FloatingActionButton) findViewById(R.id.media_upload_zoom_in); | ||||
|         try { | ||||
|             zoomInButton.setOnClickListener(new View.OnClickListener() { | ||||
|                 @Override | ||||
|                 public void onClick(View v) { | ||||
|                     zoomImageFromThumb(backgroundImageView, mediaUri); | ||||
|                 } | ||||
|             }); | ||||
|         } catch (Exception e){ | ||||
|             Log.i("exception", e.toString()); | ||||
|         } | ||||
|         zoomOutButton = (FloatingActionButton) findViewById(R.id.media_upload_zoom_out); | ||||
| 
 | ||||
|         if (savedInstanceState != null) { | ||||
|             contribution = savedInstanceState.getParcelable("contribution"); | ||||
|         } | ||||
|  | @ -378,25 +357,13 @@ public class ShareActivity | |||
|                     .commitAllowingStateLoss(); | ||||
|         } | ||||
|         uploadController.prepareService(); | ||||
|         maps_fragment = (FloatingActionButton) findViewById(R.id.media_map); | ||||
|         maps_fragment.setVisibility(View.VISIBLE); | ||||
|         mapsFragment.setVisibility(View.VISIBLE); | ||||
|         if( imageObj == null || imageObj.imageCoordsExists != true){ | ||||
|             maps_fragment.setVisibility(View.INVISIBLE); | ||||
|             mapsFragment.setVisibility(View.INVISIBLE); | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         maps_fragment.setOnClickListener(new View.OnClickListener() { | ||||
|             @Override | ||||
|             public void onClick(View v) { | ||||
|                 if( imageObj != null && imageObj.imageCoordsExists == true) { | ||||
|                     Uri gmmIntentUri = Uri.parse("google.streetview:cbll=" + imageObj.getDecLatitude() + "," + imageObj.getDecLongitude()); | ||||
|                     Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); | ||||
|                     mapIntent.setPackage("com.google.android.apps.maps"); | ||||
|                     startActivity(mapIntent); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|      * Function to display the zoom and map FAB | ||||
|      */ | ||||
|  | @ -404,11 +371,11 @@ public class ShareActivity | |||
|         isFABOpen=true; | ||||
| 
 | ||||
|         if( imageObj != null && imageObj.imageCoordsExists == true) | ||||
|         maps_fragment.setVisibility(View.VISIBLE); | ||||
|         mapsFragment.setVisibility(View.VISIBLE); | ||||
|         zoomInButton.setVisibility(View.VISIBLE); | ||||
| 
 | ||||
|         mainFab.animate().rotationBy(180); | ||||
|         maps_fragment.animate().translationY(-getResources().getDimension(R.dimen.second_fab)); | ||||
|         mapsFragment.animate().translationY(-getResources().getDimension(R.dimen.second_fab)); | ||||
|         zoomInButton.animate().translationY(-getResources().getDimension(R.dimen.first_fab)); | ||||
|     } | ||||
| 
 | ||||
|  | @ -418,7 +385,7 @@ public class ShareActivity | |||
|     private void closeFABMenu(){ | ||||
|         isFABOpen=false; | ||||
|         mainFab.animate().rotationBy(-180); | ||||
|         maps_fragment.animate().translationY(0); | ||||
|         mapsFragment.animate().translationY(0); | ||||
|         zoomInButton.animate().translationY(0).setListener(new Animator.AnimatorListener() { | ||||
|             @Override | ||||
|             public void onAnimationStart(Animator animator) { | ||||
|  | @ -428,7 +395,7 @@ public class ShareActivity | |||
|             @Override | ||||
|             public void onAnimationEnd(Animator animator) { | ||||
|                 if(!isFABOpen){ | ||||
|                     maps_fragment.setVisibility(View.GONE); | ||||
|                     mapsFragment.setVisibility(View.GONE); | ||||
|                     zoomInButton.setVisibility(View.GONE); | ||||
|                 } | ||||
| 
 | ||||
|  | @ -700,8 +667,9 @@ public class ShareActivity | |||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     //I might not be supposed to change it, but still, I saw it | ||||
|     @Override | ||||
|     public void onPostiveResponse() { | ||||
|     public void onPositiveResponse() { | ||||
|         imageObj = tempImageObj; | ||||
|         decimalCoords = imageObj.getCoords(false);// Not necessary to use gps as image already ha EXIF data | ||||
|         Timber.d("EXIF from tempImageObj"); | ||||
|  | @ -865,26 +833,19 @@ public class ShareActivity | |||
|             scaled = bitmap; | ||||
|         } | ||||
|         // Load the high-resolution "zoomed-in" image. | ||||
|         PhotoView expandedImageView = (PhotoView) findViewById( | ||||
|                 R.id.expanded_image); | ||||
|         expandedImageView.setImageBitmap(scaled); | ||||
| 
 | ||||
| 
 | ||||
|          | ||||
| 
 | ||||
|         // Calculate the starting and ending bounds for the zoomed-in image. | ||||
|         // This step involves lots of math. Yay, math. | ||||
|         final Rect startBounds = new Rect(); | ||||
|         final Rect finalBounds = new Rect(); | ||||
|         final Point globalOffset = new Point(); | ||||
| 
 | ||||
|         // The start bounds are the global visible rectangle of the thumbnail, | ||||
|         // and the final bounds are the global visible rectangle of the container | ||||
|         // view. Also set the container view's offset as the origin for the | ||||
|         // bounds, since that's the origin for the positioning animation | ||||
|         // properties (X, Y). | ||||
|         thumbView.getGlobalVisibleRect(startBounds); | ||||
|         findViewById(R.id.container) | ||||
|                 .getGlobalVisibleRect(finalBounds, globalOffset); | ||||
|         flContainer.getGlobalVisibleRect(finalBounds, globalOffset); | ||||
|         startBounds.offset(-globalOffset.x, -globalOffset.y); | ||||
|         finalBounds.offset(-globalOffset.x, -globalOffset.y); | ||||
| 
 | ||||
|  | @ -955,53 +916,86 @@ public class ShareActivity | |||
|         // Upon clicking the zoomed-in image, it should zoom back down | ||||
|         // to the original bounds and show the thumbnail instead of | ||||
|         // the expanded image. | ||||
|         final float startScaleFinal = startScale; | ||||
|         zoomOutButton.setOnClickListener(new View.OnClickListener() { | ||||
|             @Override | ||||
|             public void onClick(View view) { | ||||
|                 if (CurrentAnimator != null) { | ||||
|                     CurrentAnimator.cancel(); | ||||
|                 } | ||||
|                 zoomOutButton.setVisibility(View.GONE); | ||||
|                 mainFab.setVisibility(View.VISIBLE); | ||||
|         startScaleFinal = startScale; | ||||
| 
 | ||||
|                 // Animate the four positioning/sizing properties in parallel, | ||||
|                 // back to their original values. | ||||
|                 AnimatorSet set = new AnimatorSet(); | ||||
|                 set.play(ObjectAnimator | ||||
|                         .ofFloat(expandedImageView, View.X, startBounds.left)) | ||||
|                         .with(ObjectAnimator | ||||
|                                 .ofFloat(expandedImageView, | ||||
|                                         View.Y,startBounds.top)) | ||||
|                         .with(ObjectAnimator | ||||
|                                 .ofFloat(expandedImageView, | ||||
|                                         View.SCALE_X, startScaleFinal)) | ||||
|                         .with(ObjectAnimator | ||||
|                                 .ofFloat(expandedImageView, | ||||
|                                         View.SCALE_Y, startScaleFinal)); | ||||
|                 set.setDuration(ShortAnimationDuration); | ||||
|                 set.setInterpolator(new DecelerateInterpolator()); | ||||
|                 set.addListener(new AnimatorListenerAdapter() { | ||||
|                     @Override | ||||
|                     public void onAnimationEnd(Animator animation) { | ||||
|                         thumbView.setAlpha(1f); | ||||
|                         expandedImageView.setVisibility(View.GONE); | ||||
|                         CurrentAnimator = null; | ||||
|                     } | ||||
| 
 | ||||
|                    @Override | ||||
|                     public void onAnimationCancel(Animator animation) { | ||||
|                        thumbView.setAlpha(1f); | ||||
|                        expandedImageView.setVisibility(View.GONE); | ||||
|                         CurrentAnimator = null; | ||||
|                     } | ||||
|                 }); | ||||
|                 set.start(); | ||||
|                 CurrentAnimator = set; | ||||
| 
 | ||||
|             } | ||||
| 
 | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|      * called when upper arrow floating button | ||||
|      */ | ||||
|     @OnClick(R.id.main_fab) | ||||
|     public void onMainFabClicked() { | ||||
|         if (!isFABOpen) { | ||||
|             showFABMenu(); | ||||
|         } else { | ||||
|             closeFABMenu(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @OnClick(R.id.media_upload_zoom_in) | ||||
|     public void onZoomInFabClicked() { | ||||
|         //This try catch block was originally holding the entire click listener on the fab button, I did not wanted to risk exceptions | ||||
|         try { | ||||
|             zoomImageFromThumb(backgroundImageView, mediaUri); | ||||
|         } catch (Exception e) { | ||||
|             Log.i("exception", e.toString()); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @OnClick(R.id.media_upload_zoom_out) | ||||
|     public void onZoomOutFabClicked() { | ||||
|         if (CurrentAnimator != null) { | ||||
|             CurrentAnimator.cancel(); | ||||
|         } | ||||
|         zoomOutButton.setVisibility(View.GONE); | ||||
|         mainFab.setVisibility(View.VISIBLE); | ||||
| 
 | ||||
|         // Animate the four positioning/sizing properties in parallel, | ||||
|         // back to their original values. | ||||
|         AnimatorSet set = new AnimatorSet(); | ||||
|         set.play(ObjectAnimator | ||||
|                 .ofFloat(expandedImageView, View.X, startBounds.left)) | ||||
|                 .with(ObjectAnimator | ||||
|                         .ofFloat(expandedImageView, | ||||
|                                 View.Y, startBounds.top)) | ||||
|                 .with(ObjectAnimator | ||||
|                         .ofFloat(expandedImageView, | ||||
|                                 View.SCALE_X, startScaleFinal)) | ||||
|                 .with(ObjectAnimator | ||||
|                         .ofFloat(expandedImageView, | ||||
|                                 View.SCALE_Y, startScaleFinal)); | ||||
|         set.setDuration(ShortAnimationDuration); | ||||
|         set.setInterpolator(new DecelerateInterpolator()); | ||||
|         set.addListener(new AnimatorListenerAdapter() { | ||||
|             @Override | ||||
|             public void onAnimationEnd(Animator animation) { | ||||
|                 //background image view is thumbView | ||||
|                 backgroundImageView.setAlpha(1f); | ||||
|                 expandedImageView.setVisibility(View.GONE); | ||||
|                 CurrentAnimator = null; | ||||
|             } | ||||
| 
 | ||||
|             @Override | ||||
|             public void onAnimationCancel(Animator animation) { | ||||
|                 //background image view is thumbView | ||||
|                 backgroundImageView.setAlpha(1f); | ||||
|                 expandedImageView.setVisibility(View.GONE); | ||||
|                 CurrentAnimator = null; | ||||
|             } | ||||
|         }); | ||||
|         set.start(); | ||||
|         CurrentAnimator = set; | ||||
|     } | ||||
| 
 | ||||
|     @OnClick(R.id.media_map) | ||||
|     public void onFabShowMapsClicked() { | ||||
|         if (imageObj != null && imageObj.imageCoordsExists == true) { | ||||
|             Uri gmmIntentUri = Uri | ||||
|                     .parse("google.streetview:cbll=" + imageObj.getDecLatitude() + "," + imageObj | ||||
|                             .getDecLongitude()); | ||||
|             Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); | ||||
|             mapIntent.setPackage("com.google.android.apps.maps"); | ||||
|             startActivity(mapIntent); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -13,6 +13,9 @@ import android.view.ViewGroup; | |||
| import android.view.Window; | ||||
| import android.widget.Button; | ||||
| 
 | ||||
| import butterknife.BindView; | ||||
| import butterknife.ButterKnife; | ||||
| import butterknife.OnClick; | ||||
| import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; | ||||
| import com.facebook.drawee.view.SimpleDraweeView; | ||||
| import com.facebook.imagepipeline.listener.RequestListener; | ||||
|  | @ -29,29 +32,33 @@ import fr.free.nrw.commons.R; | |||
|  */ | ||||
| 
 | ||||
| public class SimilarImageDialogFragment extends DialogFragment { | ||||
| 
 | ||||
|     @BindView(R.id.orginalImage) | ||||
|     SimpleDraweeView originalImage; | ||||
|     @BindView(R.id.possibleImage) | ||||
|     SimpleDraweeView possibleImage; | ||||
|     @BindView(R.id.postive_button) | ||||
|     Button positiveButton; | ||||
|     @BindView(R.id.negative_button) | ||||
|     Button negativeButton; | ||||
|     onResponse mOnResponse;//Implemented interface from shareActivity | ||||
|     Boolean gotResponse = false; | ||||
| 
 | ||||
|     public SimilarImageDialogFragment() { | ||||
|     } | ||||
|     public interface onResponse{ | ||||
|         public void onPostiveResponse(); | ||||
|         public void onPositiveResponse(); | ||||
| 
 | ||||
|         public void onNegativeResponse(); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||||
|         View view =  inflater.inflate(R.layout.fragment_similar_image_dialog, container, false); | ||||
|         ButterKnife.bind(this,view); | ||||
|         Set<RequestListener> requestListeners = new HashSet<>(); | ||||
|         requestListeners.add(new RequestLoggingListener()); | ||||
| 
 | ||||
|         originalImage =(SimpleDraweeView) view.findViewById(R.id.orginalImage); | ||||
|         possibleImage =(SimpleDraweeView) view.findViewById(R.id.possibleImage); | ||||
|         positiveButton = (Button) view.findViewById(R.id.postive_button); | ||||
|         negativeButton = (Button) view.findViewById(R.id.negative_button); | ||||
| 
 | ||||
|         originalImage.setHierarchy(GenericDraweeHierarchyBuilder | ||||
|                 .newInstance(getResources()) | ||||
|                 .setPlaceholderImage(VectorDrawableCompat.create(getResources(), | ||||
|  | @ -70,22 +77,6 @@ public class SimilarImageDialogFragment extends DialogFragment { | |||
|         originalImage.setImageURI(Uri.fromFile(new File(getArguments().getString("originalImagePath")))); | ||||
|         possibleImage.setImageURI(Uri.fromFile(new File(getArguments().getString("possibleImagePath")))); | ||||
| 
 | ||||
|         negativeButton.setOnClickListener(new View.OnClickListener() { | ||||
|             @Override | ||||
|             public void onClick(View view) { | ||||
|                 mOnResponse.onNegativeResponse(); | ||||
|                 gotResponse = true; | ||||
|                 dismiss(); | ||||
|             } | ||||
|         }); | ||||
|         positiveButton.setOnClickListener(new View.OnClickListener() { | ||||
|             @Override | ||||
|             public void onClick(View view) { | ||||
|                 mOnResponse.onPostiveResponse(); | ||||
|                 gotResponse = true; | ||||
|                 dismiss(); | ||||
|             } | ||||
|         }); | ||||
|         return view; | ||||
|     } | ||||
| 
 | ||||
|  | @ -105,8 +96,23 @@ public class SimilarImageDialogFragment extends DialogFragment { | |||
|     @Override | ||||
|     public void onDismiss(DialogInterface dialog) { | ||||
| //        I user dismisses dialog by pressing outside the dialog. | ||||
|         if(!gotResponse) | ||||
|         if (!gotResponse) { | ||||
|             mOnResponse.onNegativeResponse(); | ||||
|         } | ||||
|         super.onDismiss(dialog); | ||||
|     } | ||||
| 
 | ||||
|     @OnClick(R.id.negative_button) | ||||
|     public void onNegativeButtonClicked() { | ||||
|         mOnResponse.onNegativeResponse(); | ||||
|         gotResponse = true; | ||||
|         dismiss(); | ||||
|     } | ||||
| 
 | ||||
|     @OnClick(R.id.postive_button) | ||||
|     public void onPositiveButtonClicked() { | ||||
|         mOnResponse.onPositiveResponse(); | ||||
|         gotResponse = true; | ||||
|         dismiss(); | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vivek Maskara
						Vivek Maskara