title: running firebase transaction within ArrayAdapter and getView
body: <p>Could you run a firebase transaction within an Array adapter and getView as this ;</p>
  
  <pre><code>      public class upImgAdapter extends ArrayAdapter {
  
      public List&lt;uploadedContentModels&gt; upImgModelsList;
      private int resource;
      private LayoutInflater inflater;
  
      public upImgAdapter(Context context, int resource,
                          List&lt;uploadedContentModels&gt; objects) {
          super(context, resource, objects);
          upImgModelsList = objects;
          this.resource = resource;
          inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
  
      }
  
      /** getting the view ref. to be implemented in the listview &amp; declaring layout elements **/
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent){
  
          if(convertView == null){
              convertView = inflater.inflate(resource, null);
          }
  
          /** passing the image to the UIL **/
  
          ImageView imageViewDisplayMemebers;
          imageViewDisplayMemebers = (ImageView)convertView.findViewById(R.id.imageViewDisplayMemebers);
  
          ImageLoader.getInstance().displayImage(upImgModelsList.get(position).getAddress(), imageViewDisplayMemebers);
         final String imgToBeRatedRef = upImgModelsList.get(position).getPublic_id();
  
          RatingBar ratingBar;
          ratingBar = (RatingBar)convertView.findViewById(R.id.ratingBar);
          ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
              @Override
              public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
                  newRatingImg = (ratingBar.getRating());
              }
          });
  
          Button buttonRatingSubm;
          buttonRatingSubm = (Button)convertView.findViewById(R.id.buttonRatingSubm);
          buttonRatingSubm.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v){
                  final Firebase firebaseRefRating = new Firebase("https://cloudname.firebaseio.com//data/images/" + imgToBeRatedRef + "/rating");
                  firebaseRefRating.runTransaction(new Transaction.Handler() {
                      @Override
                      public Transaction.Result doTransaction(MutableData mutableData) {
                          int currentRating = (int) mutableData.getValue();
                          int updatedRating = (currentRating + newRatingImg);
                          mutableData.setValue(updatedRating);
  
                          return Transaction.success(mutableData);
                      }
  
                      @Override
                      public void onComplete(FirebaseError firebaseError, boolean b, DataSnapshot dataSnapshot) {
  
                      }
                  });
              }
          });
  
              return convertView;
  </code></pre>
  
  <p>the problem i am facing that when i run the debug and after i clikc the button, i see that the execution jumps from the address line</p>
  
  <pre><code>   public Transaction.Result doTransaction(MutableData mutableData) {
  </code></pre>
  
  <p>to the end of the getView method ( after return convertView )
  i've tried several ways, by passing a method inside the click listener ( i.e submitRating(); ) and created that method passing the same code in it, and the same behavior happened, i also tried to use setValue without the transaction, and also the same thing went on !?</p>
  
  <p>could someone explain this behavior to me, is it because of the Array Adapter and the get view or something wrong with my code that i could not spot !?</p>
  
  <pre><code>                  public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
                 ratingNew[0] = (ratingBar.getRating());
              }
          });
  
          Button buttonRatingSubm;
          buttonRatingSubm = (Button)convertView.findViewById(R.id.buttonRatingSubm);
          buttonRatingSubm.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v){
                  Log.e("myTag","Before doTransaction()");
  
                  final Firebase firebaseRefRating = new Firebase("https://wi4x4.firebaseio.com//data/images");
                  firebaseRefRating.child(imgToBeRatedRef).child("rating").runTransaction(new Transaction.Handler() {
                      @Override
                      public Transaction.Result doTransaction(MutableData mutableData) {
                          Log.e("myTag","Inside doTransaction()");
  
                          int currentRating = (int) mutableData.getValue();
                          int updatedRating = (currentRating + ratingNew[0]);
                          mutableData.setValue(updatedRating);
                          Toast.makeText(getApplicationContext(),
                                  "submitting rating"
                                  , Toast.LENGTH_SHORT).show();
                          return Transaction.success(mutableData);
                      }
  
                      @Override
                      public void onComplete(FirebaseError firebaseError, boolean b, DataSnapshot dataSnapshot) {
                          if(firebaseError != null){
                              Log.e("myTag","After doTransaction()");
  
                              Toast.makeText(getApplicationContext(),
                                      "Rating Submitted"
                                      , Toast.LENGTH_SHORT).show();
                          }else {
                              Log.e("myTag","Error doTransaction()");
  
                              Toast.makeText(getApplicationContext(),
                                      "Error submitting rating failed"
                                      , Toast.LENGTH_SHORT).show();
                          }
                      }
                  });
              }
          });
  </code></pre>