99import android .content .SharedPreferences ;
1010import android .graphics .Typeface ;
1111import android .os .Bundle ;
12- //import android.text.Spannable;
13- //import android.text.SpannableStringBuilder;
14- //import android.text.style.StyleSpan;
1512import android .view .LayoutInflater ;
1613import android .view .Menu ;
1714import android .view .MenuInflater ;
1815import android .view .MenuItem ;
1916import android .view .View ;
2017import android .view .ViewGroup ;
2118import android .view .inputmethod .EditorInfo ;
22- //import android.widget.Button;
2319import android .widget .EditText ;
2420import android .widget .ImageButton ;
2521import android .widget .Toast ;
2622import androidx .annotation .Nullable ;
2723import androidx .fragment .app .Fragment ;
2824import org .jetbrains .annotations .NotNull ;
2925import java .util .Objects ;
26+ //import android.text.Spannable;
27+ //import android.text.SpannableStringBuilder;
28+ //import android.text.style.StyleSpan;
29+ //import android.widget.Button;
3030
3131/**
3232 * A simple {@link Fragment} subclass.
@@ -61,7 +61,7 @@ public Notepad() {
6161 * @return A new instance of fragment Notepad.
6262 */
6363 // TODO: Rename and change types and number of parameters
64- @ SuppressWarnings ("unused" )
64+ @ SuppressWarnings ({ "unused" , "RedundantSuppression" } )
6565 public static Notepad newInstance (String param1 , String param2 ) {
6666 Notepad fragment = new Notepad ();
6767 Bundle args = new Bundle ();
@@ -76,7 +76,8 @@ public static Notepad newInstance(String param1, String param2) {
7676 public void onCreate (Bundle savedInstanceState ) {
7777 super .onCreate (savedInstanceState );
7878 setHasOptionsMenu (true );
79- if (getArguments () != null ) {
79+ if (getArguments () != null ) //noinspection RedundantSuppression
80+ {
8081 // TODO: Rename and change types of parameters
8182 //noinspection unused
8283 String mParam1 = getArguments ().getString (ARG_PARAM1 );
@@ -119,23 +120,19 @@ public void onClick(View view) {
119120 Typeface boldItalicTypeFace = Typeface .defaultFromStyle (Typeface .BOLD_ITALIC );
120121 bold_button_pressed = !bold_button_pressed ;
121122
122- //noinspection PointlessBooleanExpression
123- if ((bold_button_pressed == true ) && (italic_button_pressed == false )) {
123+ if ((bold_button_pressed ) && (!italic_button_pressed )) {
124124 notepad_edit .setTypeface (boldTypeFace );
125125 }
126126
127- //noinspection PointlessBooleanExpression
128- if ((bold_button_pressed == false ) && (italic_button_pressed == false )) {
127+ if ((!bold_button_pressed ) && (!italic_button_pressed )) {
129128 notepad_edit .setTypeface (regularTypeFace );
130129 }
131130
132- //noinspection PointlessBooleanExpression
133- if ((bold_button_pressed == true ) && (italic_button_pressed == true )) {
131+ if ((bold_button_pressed ) && (italic_button_pressed )) {
134132 notepad_edit .setTypeface (boldItalicTypeFace );
135133 }
136134
137- //noinspection PointlessBooleanExpression
138- if ((bold_button_pressed == false ) && (italic_button_pressed == true )) {
135+ if ((!bold_button_pressed ) && (italic_button_pressed )) {
139136 notepad_edit .setTypeface (italicTypeFace );
140137 }
141138 }
@@ -151,23 +148,20 @@ public void onClick(View view) {
151148 Typeface boldItalicTypeFace = Typeface .defaultFromStyle (Typeface .BOLD_ITALIC );
152149 italic_button_pressed = !italic_button_pressed ;
153150
154- //noinspection PointlessBooleanExpression
155- if ((italic_button_pressed == true ) && (bold_button_pressed == false )) {
151+
152+ if ((italic_button_pressed ) && (! bold_button_pressed )) {
156153 notepad_edit .setTypeface (italicTypeFace );
157154 }
158155
159- //noinspection PointlessBooleanExpression
160- if ((italic_button_pressed == false ) && (bold_button_pressed == false )) {
156+ if ((!italic_button_pressed ) && (!bold_button_pressed )) {
161157 notepad_edit .setTypeface (regularTypeFace );
162158 }
163159
164- //noinspection PointlessBooleanExpression
165- if ((italic_button_pressed == true ) && (bold_button_pressed == true )) {
160+ if ((italic_button_pressed ) && (bold_button_pressed )) {
166161 notepad_edit .setTypeface (boldItalicTypeFace );
167162 }
168163
169- //noinspection PointlessBooleanExpression
170- if ((italic_button_pressed == false ) && (bold_button_pressed == true )) {
164+ if ((!italic_button_pressed ) && (bold_button_pressed )) {
171165 notepad_edit .setTypeface (boldTypeFace );
172166 }
173167 }
@@ -221,14 +215,13 @@ public void saveData(boolean hidden) {
221215 public boolean onOptionsItemSelected (MenuItem item ) {
222216 if (item .getItemId () == android .R .id .home ) {
223217 // TODO: Maybe add a clear all on file and save action
224- //noinspection ConstantConditions
225- super .getActivity ().onBackPressed (); // Goto -> parent activity -> main
218+ Objects .requireNonNull (super .getActivity ()).onBackPressed (); // Goto -> parent activity -> main
226219 notepad_edit .onEditorAction (EditorInfo .IME_ACTION_DONE );
227220 } else if (item .getItemId () == R .id .action_notepad_save ) {
228221 saveData (false );
229222 } else if (item .getItemId () == R .id .action_notepad_clear ){
230223 notepad_edit .setText ("" );
231- // saveData(true);
224+ // saveData(true);
232225 } else {
233226 return super .onOptionsItemSelected (item );
234227 }
0 commit comments