<commit_before>package com.example.kaveon14.workoutbuddy.Fragments.Managers;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;

public class FragmentStackManager {

    private int currFragId = 0;
    private FragmentManager fragmentManager;

    public FragmentStackManager(FragmentManager fragmentManager) {
        this.fragmentManager = fragmentManager;
    }

    public void addFragmentToStack(Fragment frag,int fragId) {
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        if(currFragId==0) {
            fragmentTransaction.add(fragId,frag);
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();
        } else {
            fragmentTransaction.hide(fragmentManager.findFragmentById(currFragId));
            fragmentTransaction.add(fragId, frag);
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();
        }
        currFragId = fragId;
    }
}
<commit_msg>fixed fragmentStackManager null pointer bug<commit_after>package com.example.kaveon14.workoutbuddy.Fragments.Managers;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;

public class FragmentStackManager {

    private int currFragId = 0;
    private FragmentManager fragmentManager;

    public FragmentStackManager(FragmentManager fragmentManager) {
        this.fragmentManager = fragmentManager;
    }

    public void addFragmentToStack(Fragment frag,int fragId) {
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        /*if(currFragId==0) {
            fragmentTransaction.add(fragId,frag);
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();
        } else if(currFragId==fragId) {
            fragmentTransaction.add(fragId, frag);
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();
        } else {
            fragmentTransaction.hide(fragmentManager.findFragmentById(currFragId));
            fragmentTransaction.add(fragId, frag);
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();
        }*/




        Fragment fragment = fragmentManager.findFragmentById(currFragId);
        if(fragment != null && fragment.isVisible()) {
            fragmentTransaction.hide(fragment);
            fragmentTransaction.add(fragId, frag);
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();
        } else {
            fragmentTransaction.add(fragId,frag);
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();
        }




        currFragId = fragId;
    }
}

{'fraction_non_alphanumeric': 0.08604008293020042, 'fraction_numerical': 0.0048375950241879755, 'mean_word_length': 3.0947666195190946, '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': '6445218', 'n_tokens_mistral': 736, 'n_tokens_neox': 710, 'n_words': 111}