<commit_before>package mn.devfest.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import butterknife.Bind;
import butterknife.ButterKnife;
import mn.devfest.R;
import mn.devfest.api.model.Speaker;

/**
 * Custom view that displays information about a speaker
 *
 * @author pfuentes
 */
public class SpeakerView extends LinearLayout {

    @Bind(R.id.speaker_view_image)
    ImageView mProfileImageview;
    @Bind(R.id.speaker_view_name)
    TextView mNameTextview;
    @Bind(R.id.speaker_view_company)
    TextView mCompanyTextview;
    @Bind(R.id.speaker_view_bio)
    TextView mBioTextview;
    @Bind(R.id.twitter_heading)
    TextView mTwitterHeading;
    @Bind(R.id.speaker_twitter)
    TextView mTwitterTextview;
    @Bind(R.id.website_heading)
    TextView mWebsiteHeading;
    @Bind(R.id.speaker_website)
    TextView mWebsiteTextview;

    Context mContext;
    Speaker mSpeaker;

    public SpeakerView(Context context) {
        super(context);
        init(context);
    }

    public SpeakerView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public SpeakerView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context) {
        mContext = context;
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.view_speaker, this);
        ButterKnife.bind(this, view);
    }

    public void setSpeaker(Speaker speaker) {
        mSpeaker = speaker;
        updateTextAndImage();
    }

    /**
     * Updates the imageview and textviews using the currently set Speaker object.
     * TODO maybe replace this method with data binding
     */
    private void updateTextAndImage() {
        Picasso.with(mContext)
                .load(mSpeaker.getImageUrl())
                .placeholder(R.drawable.ic_account_circle_white_48dp)
                .into(mProfileImageview);
        mNameTextview.setText(mSpeaker.getName());
        mBioTextview.setText(mSpeaker.getBio());
        if (mSpeaker.getCompany().isEmpty()) {
            mCompanyTextview.setVisibility(GONE);
        } else {
            mCompanyTextview.setText(mSpeaker.getCompany());
        }
        if (mSpeaker.getTwitter().isEmpty()) {
            mTwitterHeading.setVisibility(GONE);
            mTwitterTextview.setVisibility(GONE);
        } else {
            mTwitterTextview.setText(mSpeaker.getTwitter());
        }
        if (mSpeaker.getWebsite().isEmpty()) {
            mWebsiteHeading.setVisibility(GONE);
            mWebsiteTextview.setVisibility(GONE);
        } else {
            mWebsiteTextview.setText(mSpeaker.getWebsite());
        }
    }

}
<commit_msg>Add circle transform to speaker view Improve null-handling in speaker view<commit_after>package mn.devfest.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import butterknife.Bind;
import butterknife.ButterKnife;
import mn.devfest.R;
import mn.devfest.api.model.Speaker;
import mn.devfest.speakers.SpeakerImageTransformation;

/**
 * Custom view that displays information about a speaker
 *
 * @author pfuentes
 */
public class SpeakerView extends LinearLayout {

    @Bind(R.id.speaker_view_image)
    ImageView mProfileImageview;
    @Bind(R.id.speaker_view_name)
    TextView mNameTextview;
    @Bind(R.id.speaker_view_company)
    TextView mCompanyTextview;
    @Bind(R.id.speaker_view_bio)
    TextView mBioTextview;
    @Bind(R.id.twitter_heading)
    TextView mTwitterHeading;
    @Bind(R.id.speaker_twitter)
    TextView mTwitterTextview;
    @Bind(R.id.website_heading)
    TextView mWebsiteHeading;
    @Bind(R.id.speaker_website)
    TextView mWebsiteTextview;

    Context mContext;
    Speaker mSpeaker;

    public SpeakerView(Context context) {
        super(context);
        init(context);
    }

    public SpeakerView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public SpeakerView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context) {
        mContext = context;
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.view_speaker, this);
        ButterKnife.bind(this, view);
    }

    public void setSpeaker(Speaker speaker) {
        mSpeaker = speaker;
        updateTextAndImage();
    }

    /**
     * Updates the imageview and textviews using the currently set Speaker object.
     * TODO maybe replace this method with data binding
     */
    private void updateTextAndImage() {
        Picasso.with(mContext)
                .load(mSpeaker.getImageUrl())
                .placeholder(R.drawable.ic_account_circle_white_48dp)
                .transform(new SpeakerImageTransformation())
                .into(mProfileImageview);
        mNameTextview.setText(mSpeaker.getName());
        mBioTextview.setText(mSpeaker.getBio());
        if (mSpeaker.getCompany() == null || mSpeaker.getCompany().isEmpty()) {
            mCompanyTextview.setVisibility(GONE);
        } else {
            mCompanyTextview.setText(mSpeaker.getCompany());
        }
        if (mSpeaker.getTwitter() == null || mSpeaker.getTwitter().isEmpty()) {
            mTwitterHeading.setVisibility(GONE);
            mTwitterTextview.setVisibility(GONE);
        } else {
            mTwitterTextview.setText(mSpeaker.getTwitter());
        }
        if (mSpeaker.getWebsite() == null || mSpeaker.getWebsite().isEmpty()) {
            mWebsiteHeading.setVisibility(GONE);
            mWebsiteTextview.setVisibility(GONE);
        } else {
            mWebsiteTextview.setText(mSpeaker.getWebsite());
        }
    }

}

{'fraction_non_alphanumeric': 0.09850413749204329, 'fraction_numerical': 0.0006365372374283895, 'mean_word_length': 2.9404388714733543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '972887', 'n_tokens_mistral': 1948, 'n_tokens_neox': 1828, 'n_words': 340}