title: Android How can i generalize a Class for reuse
body: <p>In my android code i needed to place an edittext in a recyclerview and save the value entered using TextWatcher. For that purpose i used a customized TextWatcher as suggested here. </p>
  
  <pre><code>private class MyCustomEditTextListener implements TextWatcher {       
  int position;
  public void updatePosition(int position)
  { 
       this.position=position;
  }
  @Override
  public void beforeTextChanged(CharSequence charSequence, int i, int i2,
  int i3) {}
  
  @Override
  public void onTextChanged(CharSequence charSequence, int i, int i2,
  int i3) {}
  
  @Override
  public void afterTextChanged(Editable editable) {}}
  </code></pre>
  
  <p>The updatePosition is called from onBindViewHolder.. and i save the edittext contents to data model from the afterTextChanged.</p>
  
  <p>My situation now is i use the MyCustomEditTextListener as inner class. But the same usage logic is required in multiple activities. How can i rewrite the class so that i dont have to duplicate it in every recycler adapter.</p>
  
  <p>In the afterTextChanged()  method i use something like follows</p>
  
  <p>modelList.get(position).setQuantity(editable.toString());</p>
  
  <p>where modelList is an ArrayList of 'Model' objects. But my issue becomes that the Model class is different in each Adapter. </p>