Source:
<code>public TipBox(Context context, @Nullable AttributeSet attrs) throws Exception { super(context, attrs); inflate(context, R.layout.tip_box, this); TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.TipBox); identifier = attributes.getString(R.styleable.TipBox_identifier); if (identifier == null) { throw new Exception("Tip box identifier not set!!!"); } animate = attributes.getBoolean(R.styleable.TipBox_animate, true); tipMessage = findViewById(R.id.tipMessage); String message = attributes.getString(R.styleable.TipBox_message); if (message != null) { tipMessage.setText(context.getString(R.string.tip_message, message)); } arrow = findViewById(R.id.arrow); int marginStart = attributes.getDimensionPixelSize(R.styleable.TipBox_arrowMarginStart, 0); int marginEnd = attributes.getDimensionPixelSize(R.styleable.TipBox_arrowMarginEnd, 0); int arrowAlignment = attributes.getInt(R.styleable.TipBox_arrowAlignment, Gravity.START); setArrowAlignment(arrowAlignment, marginStart, marginEnd); setVisibility(View.GONE); findViewById(R.id.gotItBtn).setOnClickListener(v -> { hide(); prefs.edit().putBoolean(identifier, false).apply(); }); prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); <START> boolean canDisplayImmediately = attributes.getBoolean(R.styleable.TipBox_shouldDisplayImmediately, false); <END> tipMessage.setTextColor(attributes.getColor(R.styleable.TipBox_textColor, getResources().getColor(R.color.md_black_1000))); int toolTipColor = attributes.getColor(R.styleable.TipBox_backgroundColor, getResources().getColor(R.color.brand_light_blue)); findViewById(R.id.tipBoxContainer).setBackgroundColor(toolTipColor); arrow.setColorFilter(toolTipColor); attributes.recycle(); if (canDisplayImmediately) { loadToolTip(); } }</code><technical_language>I prefer if attributes need immediately call recycle() fast can. Please move canDisplayImmediately others attributes.get... create a var for attributes.getColor s</technical_language>

Target:
public TipBox(Context context, @Nullable AttributeSet attrs) throws Exception { super(context, attrs); inflate(context, R.layout.tip_box, this); TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.TipBox); identifier = attributes.getString(R.styleable.TipBox_identifier); if (identifier == null) { throw new Exception("Tip box identifier not set!!!"); } animate = attributes.getBoolean(R.styleable.TipBox_animate, true); tipMessage = findViewById(R.id.tipMessage); String message = attributes.getString(R.styleable.TipBox_message); if (message != null) { tipMessage.setText(context.getString(R.string.tip_message, message)); } arrow = findViewById(R.id.arrow); int marginStart = attributes.getDimensionPixelSize(R.styleable.TipBox_arrowMarginStart, 0); int marginEnd = attributes.getDimensionPixelSize(R.styleable.TipBox_arrowMarginEnd, 0); int arrowAlignment = attributes.getInt(R.styleable.TipBox_arrowAlignment, Gravity.START); boolean canDisplayImmediately = attributes.getBoolean(R.styleable.TipBox_shouldDisplayImmediately, false); setArrowAlignment(arrowAlignment, marginStart, marginEnd); int toolTipTextColor = attributes.getColor(R.styleable.TipBox_textColor, getResources().getColor(R.color.md_black_1000)); int toolTipBackgroundColor = attributes.getColor(R.styleable.TipBox_backgroundColor, getResources().getColor(R.color.brand_light_blue)); attributes.recycle(); setVisibility(View.GONE); findViewById(R.id.gotItBtn).setOnClickListener(v -> { hide(); prefs.edit().putBoolean(identifier, false).apply(); }); prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); tipMessage.setTextColor(toolTipTextColor); findViewById(R.id.tipBoxContainer).setBackgroundColor(toolTipBackgroundColor); arrow.setColorFilter(toolTipBackgroundColor); if (canDisplayImmediately) { loadToolTip(); } }