<commit_before>package org.zeroxlab.momodict.widget;

import android.support.annotation.NonNull;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;

public class PagerFocusBroadcaster implements ViewPager.OnPageChangeListener {

    private final FragmentStatePagerAdapter mAdapter;

    public PagerFocusBroadcaster(@NonNull FragmentStatePagerAdapter adapter) {
        mAdapter = adapter;
    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        notifyViewPager(position);
    }

    @Override
    public void onPageSelected(int position) {
        notifyViewPager(position);
    }

    @Override
    public void onPageScrollStateChanged(int state) {
    }

    private void notifyViewPager(int pos) {
        Object item = mAdapter.getItem(pos);
        if ((item != null) && (item instanceof ViewPagerFocusable)) {
            ((ViewPagerFocusable) item).onViewPagerFocused();
        }
    }<commit_msg>bug: do not notify too many times<commit_after>package org.zeroxlab.momodict.widget;

import android.support.annotation.NonNull;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;

public class PagerFocusBroadcaster implements ViewPager.OnPageChangeListener {

    private final FragmentStatePagerAdapter mAdapter;

    public PagerFocusBroadcaster(@NonNull FragmentStatePagerAdapter adapter) {
        mAdapter = adapter;
    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    }

    @Override
    public void onPageSelected(int position) {
        notifyViewPager(position);
    }

    @Override
    public void onPageScrollStateChanged(int state) {
    }

    private void notifyViewPager(int pos) {
        Object item = mAdapter.getItem(pos);
        if ((item != null) && (item instanceof ViewPagerFocusable)) {
            ((ViewPagerFocusable) item).onViewPagerFocused();
        }
    }
{'fraction_non_alphanumeric': 0.08074839980305268, 'fraction_numerical': 0.0019694731659281144, 'mean_word_length': 3.7255813953488373, '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': '3230087', 'n_tokens_mistral': 579, 'n_tokens_neox': 561, 'n_words': 123}