<commit_before>package com.ternaryop.photoshelf.counter;

import android.content.Context;
import android.os.AsyncTask;
import android.view.View;
import android.widget.BaseAdapter;
import android.widget.TextView;

public abstract class AbsCountRetriever implements CountRetriever, CountChangedListener {
    private Context context;
    private String blogName;
    private AsyncTask<Void, Void, Long> task;
    private Long lastCount;
    private BaseAdapter adapter;

    public AbsCountRetriever(Context context, String blogName, BaseAdapter adapter) {
        this.context = context;
        this.blogName = blogName;
        this.adapter = adapter;
    }

    public Context getContext() {
        return context;
    }

    public void setContext(Context context) {
        this.context = context;
    }

    @Override
    public String getBlogName() {
        return blogName;
    }

    @Override
    public void setBlogName(String blogName) {
        this.blogName = blogName;
    }

    /**
     * This method will be executed always asynchronously
     * @return the number of items for counter or null if error occurred
     */
    protected abstract Long getCount();
    
    @Override
    public void updateCount(final TextView textView) {
        // if available use the cached value
        if (lastCount != null) {
            textView.setText(lastCount.toString());
            textView.setVisibility(View.VISIBLE);
            return;
        }
        if (task != null && task.getStatus().equals(AsyncTask.Status.RUNNING)) {<commit_msg>when blog name changes the counters aren't updated<commit_after>package com.ternaryop.photoshelf.counter;

import android.content.Context;
import android.os.AsyncTask;
import android.view.View;
import android.widget.BaseAdapter;
import android.widget.TextView;

public abstract class AbsCountRetriever implements CountRetriever, CountChangedListener {
    private Context context;
    private String blogName;
    private AsyncTask<Void, Void, Long> task;
    private Long lastCount;
    private BaseAdapter adapter;

    public AbsCountRetriever(Context context, String blogName, BaseAdapter adapter) {
        this.context = context;
        this.blogName = blogName;
        this.adapter = adapter;
    }

    public Context getContext() {
        return context;
    }

    public void setContext(Context context) {
        this.context = context;
    }

    @Override
    public String getBlogName() {
        return blogName;
    }

    @Override
    public void setBlogName(String blogName) {
        this.blogName = blogName;
        // clear cached value
        lastCount = null;
    }

    /**
     * This method will be executed always asynchronously
     * @return the number of items for counter or null if error occurred
     */
    protected abstract Long getCount();
    
    @Override
    public void updateCount(final TextView textView) {
        // if available use the cached value
        if (lastCount != null) {
            textView.setText(lastCount.toString());
            textView.setVisibility(View.VISIBLE);
            return;
        }
        if (task != null && task.getStatus().equals(AsyncTask.Status.RUNNING)) {
{'fraction_non_alphanumeric': 0.07961286294099282, 'fraction_numerical': 0.0, 'mean_word_length': 2.7473684210526317, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7489411', 'n_tokens_mistral': 850, 'n_tokens_neox': 825, 'n_words': 248}