<commit_before>package com.smartdevicelink.managers.screen;

import android.support.annotation.NonNull;
import android.util.Log;

import com.smartdevicelink.managers.BaseSubManager;
import com.smartdevicelink.managers.CompletionListener;
import com.smartdevicelink.managers.file.FileManager;
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
import com.smartdevicelink.proxy.interfaces.ISdl;
import com.smartdevicelink.proxy.rpc.SetDisplayLayout;
import com.smartdevicelink.proxy.rpc.enums.MetadataType;
import com.smartdevicelink.proxy.rpc.enums.PredefinedLayout;
import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
import com.smartdevicelink.util.DebugTool;

import java.lang.ref.WeakReference;
import java.util.List;

/**
 * <strong>ScreenManager</strong> <br>
 *
 * Note: This class must be accessed through the SdlManager. Do not instantiate it by itself. <br>
*/
public class ScreenManager extends BaseSubManager {

	private static String TAG = "ScreenManager";
	private final WeakReference<FileManager> fileManager;
	private SoftButtonManager softButtonManager;
	private TextAndGraphicManager textAndGraphicManager;

	// Sub manager listener
	private final CompletionListener subManagerListener = new CompletionListener() {
		@Override
		public synchronized void onComplete(boolean success) {
			if (softButtonManager != null && textAndGraphicManager != null) {
				if (softButtonManager.getState() == BaseSubManager.READY && textAndGraphicManager.getState() == BaseSubManager.READY) {
					DebugTool.logInfo("Starting screen manager, all sub managers are in ready state");
					transitionToState(READY);
				} else if (softButtonManager.getState() == BaseSubManager.ERROR && textAndGraphicManager.getState() == BaseSubManager.ERROR) {
					Log.e(TAG, "ERROR starting screen manager, both sub managers in error state");
					transitionToState(ERROR);
				} else if (textAndGraphicManager.getState() == BaseSubManager.SETTING_UP || softButtonManager.getState() == BaseSubManager.SETTING_UP) {
					DebugTool.logInfo("SETTING UP screen manager, one sub manager is still setting up");
					transitionToState(SETTING_UP);
				} else {
					Log.w(TAG, "LIMITED starting screen manager, one sub manager in error state and the other is ready");
					transitionToState(LIMITED);
				}
			} else {
				// We should never be here, but somehow one of the sub-sub managers is null
				Log.e(TAG, "ERROR one of the screen sub managers is null");
				transitionToState(ERROR);
			}
		}
	};

	public ScreenManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) {
		super(internalInterface);
		this.fileManager = new WeakReference<>(fileManager);
		initialize();
	}

	@Override
	public void start(CompletionListener listener) {
		super.start(listener);
	}

	private void initialize(){
		if (fileManager.get() != null) {
			this.softButtonManager = new SoftButtonManager(internalInterface, fileManager.get());
			this.textAndGraphicManager = new TextAndGraphicManager(internalInterface, fileManager.get(), softButtonManager);
			this.softButtonManager.start(subManagerListener);
			this.textAndGraphicManager.start(subManagerListener);
		}
	}<commit_msg>Start ScreenManager’s submanagers in start() method<commit_after>package com.smartdevicelink.managers.screen;

import android.support.annotation.NonNull;
import android.util.Log;

import com.smartdevicelink.managers.BaseSubManager;
import com.smartdevicelink.managers.CompletionListener;
import com.smartdevicelink.managers.file.FileManager;
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
import com.smartdevicelink.proxy.interfaces.ISdl;
import com.smartdevicelink.proxy.rpc.SetDisplayLayout;
import com.smartdevicelink.proxy.rpc.enums.MetadataType;
import com.smartdevicelink.proxy.rpc.enums.PredefinedLayout;
import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
import com.smartdevicelink.util.DebugTool;

import java.lang.ref.WeakReference;
import java.util.List;

/**
 * <strong>ScreenManager</strong> <br>
 *
 * Note: This class must be accessed through the SdlManager. Do not instantiate it by itself. <br>
*/
public class ScreenManager extends BaseSubManager {

	private static String TAG = "ScreenManager";
	private final WeakReference<FileManager> fileManager;
	private SoftButtonManager softButtonManager;
	private TextAndGraphicManager textAndGraphicManager;

	// Sub manager listener
	private final CompletionListener subManagerListener = new CompletionListener() {
		@Override
		public synchronized void onComplete(boolean success) {
			if (softButtonManager != null && textAndGraphicManager != null) {
				if (softButtonManager.getState() == BaseSubManager.READY && textAndGraphicManager.getState() == BaseSubManager.READY) {
					DebugTool.logInfo("Starting screen manager, all sub managers are in ready state");
					transitionToState(READY);
				} else if (softButtonManager.getState() == BaseSubManager.ERROR && textAndGraphicManager.getState() == BaseSubManager.ERROR) {
					Log.e(TAG, "ERROR starting screen manager, both sub managers in error state");
					transitionToState(ERROR);
				} else if (textAndGraphicManager.getState() == BaseSubManager.SETTING_UP || softButtonManager.getState() == BaseSubManager.SETTING_UP) {
					DebugTool.logInfo("SETTING UP screen manager, one sub manager is still setting up");
					transitionToState(SETTING_UP);
				} else {
					Log.w(TAG, "LIMITED starting screen manager, one sub manager in error state and the other is ready");
					transitionToState(LIMITED);
				}
			} else {
				// We should never be here, but somehow one of the sub-sub managers is null
				Log.e(TAG, "ERROR one of the screen sub managers is null");
				transitionToState(ERROR);
			}
		}
	};

	public ScreenManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) {
		super(internalInterface);
		this.fileManager = new WeakReference<>(fileManager);
		initialize();
	}

	@Override
	public void start(CompletionListener listener) {
		super.start(listener);
		this.softButtonManager.start(subManagerListener);
		this.textAndGraphicManager.start(subManagerListener);
	}

	private void initialize(){
		if (fileManager.get() != null) {
			this.softButtonManager = new SoftButtonManager(internalInterface, fileManager.get());
			this.textAndGraphicManager = new TextAndGraphicManager(internalInterface, fileManager.get(), softButtonManager);
		}
	}
{'fraction_non_alphanumeric': 0.09731333958138082, 'fraction_numerical': 0.0, 'mean_word_length': 5.428714859437751, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '5834980', 'n_tokens_mistral': 1986, 'n_tokens_neox': 1822, 'n_words': 443}