Created
          December 4, 2014 16:24 
        
      - 
      
 - 
        
Save alorma/31e7e2fe52f423f0eeb0 to your computer and use it in GitHub Desktop.  
    Class that allows to check number of clicks available on a view
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class RetryClickListener implements View.OnClickListener { | |
| private int maxRetries; | |
| private int current = 0; | |
| private OnRetryClickListener onRetryClickListener; | |
| public RetryClickListener(int maxRetries, OnRetryClickListener onRetryClickListener) { | |
| this.maxRetries = maxRetries; | |
| this.onRetryClickListener = onRetryClickListener; | |
| } | |
| @Override | |
| public void onClick(View v) { | |
| if (onRetryClickListener != null) { | |
| if (current++ < maxRetries) { | |
| onRetryClickListener.onClick(v); | |
| } else { | |
| onRetryClickListener.onClickNotAllowed(v); | |
| } | |
| } | |
| } | |
| public interface OnRetryClickListener { | |
| void onClick(View v); | |
| void onClickNotAllowed(View v); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment