<commit_before>package de.markusfisch.android.shadereditor.activity;

import de.markusfisch.android.shadereditor.app.ShaderEditorApplication;
import de.markusfisch.android.shadereditor.R;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

public abstract class AbstractSubsequentActivity extends AppCompatActivity {
	private FragmentManager fm;

	public static void addFragment(
			FragmentManager fm,
			Fragment fragment) {
		fm.beginTransaction()
				.replace(
						R.id.content_frame,
						fragment)
				.addToBackStack(null)
				.commit();
	}

	public static void setFragment(
			FragmentManager fm,
			Fragment fragment) {
		fm.beginTransaction()
				.replace(
						R.id.content_frame,
						fragment)
				.commit();
	}

	public static void initToolbar(AppCompatActivity activity) {
		Toolbar toolbar = (Toolbar) activity.findViewById(R.id.toolbar);
		activity.setSupportActionBar(toolbar);
		activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	}

	public static void initSystemBars(AppCompatActivity activity) {
		MainActivity.setSystemBarColor(
				activity.getWindow(),
				ShaderEditorApplication
						.preferences
						.getSystemBarColor(),
				false);
	}

	@Override
	public boolean onSupportNavigateUp() {
		if (fm.getBackStackEntryCount() > 0) {
			fm.popBackStack();
		} else {
			finish();
		}

		return true;
	}

	@Override
	protected void onCreate(Bundle state) {
		super.onCreate(state);
		fm = getSupportFragmentManager();
	}

	protected void setFragmentForIntent(
			Fragment fragment,
			Intent intent) {
		if (fragment == null || intent == null) {
			finish();
			return;
		}

		fragment.setArguments(intent.getExtras());
		setFragment(getSupportFragmentManager(), fragment);
	}
}
<commit_msg>Replace fragment in just one place<commit_after>package de.markusfisch.android.shadereditor.activity;

import de.markusfisch.android.shadereditor.app.ShaderEditorApplication;
import de.markusfisch.android.shadereditor.R;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

public abstract class AbstractSubsequentActivity extends AppCompatActivity {
	private FragmentManager fm;

	public static void addFragment(
			FragmentManager fm,
			Fragment fragment) {
		getReplaceFragmentTransaction(fm, fragment)
				.addToBackStack(null)
				.commit();
	}

	public static void setFragment(
			FragmentManager fm,
			Fragment fragment) {
		getReplaceFragmentTransaction(fm, fragment).commit();
	}

	public static void initToolbar(AppCompatActivity activity) {
		Toolbar toolbar = (Toolbar) activity.findViewById(R.id.toolbar);
		activity.setSupportActionBar(toolbar);
		activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	}

	public static void initSystemBars(AppCompatActivity activity) {
		MainActivity.setSystemBarColor(
				activity.getWindow(),
				ShaderEditorApplication
						.preferences
						.getSystemBarColor(),
				false);
	}

	@Override
	public boolean onSupportNavigateUp() {
		if (fm.getBackStackEntryCount() > 0) {
			fm.popBackStack();
		} else {
			finish();
		}

		return true;
	}

	@Override
	protected void onCreate(Bundle state) {
		super.onCreate(state);
		fm = getSupportFragmentManager();
	}

	protected void setFragmentForIntent(
			Fragment fragment,
			Intent intent) {
		if (fragment == null || intent == null) {
			finish();
			return;
		}

		fragment.setArguments(intent.getExtras());
		setFragment(getSupportFragmentManager(), fragment);
	}

	@SuppressLint("CommitTransaction")
	private static FragmentTransaction getReplaceFragmentTransaction(
			FragmentManager fm,
			Fragment fragment) {
		return fm.beginTransaction().replace(R.id.content_frame, fragment);
	}
}

{'fraction_non_alphanumeric': 0.09943943456007799, 'fraction_numerical': 0.002680965147453083, 'mean_word_length': 4.73986013986014, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5111764', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1199, 'n_words': 242}