<commit_before>package com.ddiehl.android.htn.presenter;

import android.support.annotation.NonNull;
import android.text.TextUtils;

import com.ddiehl.android.htn.HoldTheNarwhal;
import com.ddiehl.android.htn.R;
import com.ddiehl.android.htn.view.ListingsView;
import com.ddiehl.android.htn.view.MainView;
import com.ddiehl.android.htn.view.UserProfileView;
import com.ddiehl.reddit.identity.UserIdentity;

import rx.functions.Action1;

public class UserProfilePresenter extends AbsListingsPresenter {
  private UserProfileView mSummaryView;

  public UserProfilePresenter(
      MainView main, ListingsView view, UserProfileView view2,
      String show, String username, String sort, String timespan) {
    super(main, view, show, username, null, sort, timespan);
    mSummaryView = view2;
  }

  @Override
  public void requestData() {
    if (mShow.equals("summary")) {
      getSummaryData();
      // TODO: Analytics event for user profile summary screen
    } else {
      getListingData();
      mAnalytics.logLoadUserProfile(mShow, mSort, mTimespan);
    }
  }

  private void getSummaryData() {
    mRedditService.getUserInfo(mUsernameContext)
        .doOnTerminate(() -> {
          mMainView.dismissSpinner();
          mListingsRequested = false;
        })
        .doOnNext(getFriendInfo())
        .subscribe(mSummaryView::showUserInfo, mMainView::showError);
    mRedditService.getUserTrophies(mUsernameContext)
        .subscribe(mSummaryView::showTrophies, mMainView::showError);
  }

  private Action1<UserIdentity> getFriendInfo() {
    return user -> {
      if (user.isFriend()) {
        mRedditService.getFriendInfo(user.getName())
            .subscribe(response -> {
              UserIdentity self = HoldTheNarwhal.getIdentityManager().getUserIdentity();
              if (self != null && self.isGold()) {
                mSummaryView.showFriendNote(response.getNote());
              }
            }, mMainView::showError);
      }
    };
  }

  public void addFriend() {<commit_msg>Logging analytics event for user profile summary screen<commit_after>package com.ddiehl.android.htn.presenter;

import android.support.annotation.NonNull;
import android.text.TextUtils;

import com.ddiehl.android.htn.HoldTheNarwhal;
import com.ddiehl.android.htn.R;
import com.ddiehl.android.htn.view.ListingsView;
import com.ddiehl.android.htn.view.MainView;
import com.ddiehl.android.htn.view.UserProfileView;
import com.ddiehl.reddit.identity.UserIdentity;

import rx.functions.Action1;

public class UserProfilePresenter extends AbsListingsPresenter {
  private UserProfileView mSummaryView;

  public UserProfilePresenter(
      MainView main, ListingsView view, UserProfileView view2,
      String show, String username, String sort, String timespan) {
    super(main, view, show, username, null, sort, timespan);
    mSummaryView = view2;
  }

  @Override
  public void requestData() {
    mAnalytics.logLoadUserProfile(mShow, mSort, mTimespan);
    if (mShow.equals("summary")) {
      getSummaryData();
    } else {
      getListingData();
    }
  }

  private void getSummaryData() {
    mRedditService.getUserInfo(mUsernameContext)
        .doOnTerminate(() -> {
          mMainView.dismissSpinner();
          mListingsRequested = false;
        })
        .doOnNext(getFriendInfo())
        .subscribe(mSummaryView::showUserInfo, mMainView::showError);
    mRedditService.getUserTrophies(mUsernameContext)
        .subscribe(mSummaryView::showTrophies, mMainView::showError);
  }

  private Action1<UserIdentity> getFriendInfo() {
    return user -> {
      if (user.isFriend()) {
        mRedditService.getFriendInfo(user.getName())
            .subscribe(response -> {
              UserIdentity self = HoldTheNarwhal.getIdentityManager().getUserIdentity();
              if (self != null && self.isGold()) {
                mSummaryView.showFriendNote(response.getNote());
              }
            }, mMainView::showError);
      }
    };
  }

  public void addFriend() {
{'fraction_non_alphanumeric': 0.10766924806395203, 'fraction_numerical': 0.0019985011241568824, 'mean_word_length': 3.3474484256243215, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3959045', 'n_tokens_mistral': 1218, 'n_tokens_neox': 1200, 'n_words': 215}