<commit_before>package com.manoj.dlt.features;

import android.content.Context;

import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseReference;
import com.manoj.dlt.DbConstants;
import com.manoj.dlt.utils.FirebaseChildAddedListener;
import com.manoj.dlt.utils.Utilities;

public class LinkQueueHandler {
    private static LinkQueueHandler _QHandler;

    private Context _context;
    private boolean _isProcessing;

    private LinkQueueHandler(Context context)
    {
        _context = context;
        _isProcessing = false;
    }

    public static LinkQueueHandler getInstance(Context context)
    {
        if(_QHandler == null)
        {
            _QHandler = new LinkQueueHandler(context);
        }
        return _QHandler;
    }

    public void runQueueListener()
    {
        if(_isProcessing)
        {
            //Already attached listener on queue. do nothing
            return;
        } else
        {
            DatabaseReference baseUserReference = ProfileFeature.getInstance(_context).getCurrentUserFirebaseBaseRef();
            final DatabaseReference queueReference = baseUserReference.child(DbConstants.LINK_QUEUE);
            queueReference.addChildEventListener(new FirebaseChildAddedListener()
            {
                @Override
                public void onChildAdded(DataSnapshot dataSnapshot, String s)
                {
                    String qId = dataSnapshot.getKey();
                    String deepLink = dataSnapshot.getValue().toString();
                    Utilities.checkAndFireDeepLink(deepLink, _context);
                    queueReference.child(qId).setValue(null);
                }
            });
            _isProcessing = true;
        }
    }
}<commit_msg>refactor, function to remove queue listener<commit_after>package com.manoj.dlt.features;

import android.content.Context;
import android.support.annotation.NonNull;

import com.google.firebase.database.ChildEventListener;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.manoj.dlt.DbConstants;
import com.manoj.dlt.utils.FirebaseChildAddedListener;
import com.manoj.dlt.utils.Utilities;

public class LinkQueueHandler {
    private static LinkQueueHandler _QHandler;

    private Context _context;
    private boolean _isProcessing;
    private ChildEventListener _queueListener;
    private DatabaseReference _queueReference;

    private LinkQueueHandler(Context context)
    {
        _context = context;
        _isProcessing = false;
        _queueReference = ProfileFeature.getInstance(_context).getCurrentUserFirebaseBaseRef().child(DbConstants.LINK_QUEUE);
        _queueListener = getQueueListener();
    }

    public static LinkQueueHandler getInstance(Context context)
    {
        if(_QHandler == null)
        {
            _QHandler = new LinkQueueHandler(context);
        }
        return _QHandler;
    }

    public void runQueueListener()
    {
        if(_isProcessing)
        {
            //Already attached listener on queue. do nothing
            return;
        } else
        {
            _queueReference.addChildEventListener(_queueListener);
            _isProcessing = true;
        }
    }

    public void stopQueueListener()
    {
        if(_isProcessing)
        {
            _queueReference.removeEventListener(_queueListener);
            _isProcessing = false;
        }
    }

    @NonNull
    private FirebaseChildAddedListener getQueueListener() {
        return new FirebaseChildAddedListener()
        {
            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s)
            {
                String qId = dataSnapshot.getKey();
                String deepLink = dataSnapshot.getValue().toString();
                Utilities.checkAndFireDeepLink(deepLink, _context);
                _queueReference.child(qId).setValue(null);
            }
        };
    }
}
{'fraction_non_alphanumeric': 0.07461576598909271, 'fraction_numerical': 0.0, 'mean_word_length': 2.422391857506361, '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': '14258', 'n_tokens_mistral': 1014, 'n_tokens_neox': 998, 'n_words': 199}