From 6c6542302a54119fef3a0ed15e20399d2ab13e26 Mon Sep 17 00:00:00 2001 From: Neamar Date: Sat, 18 May 2019 11:50:20 +0200 Subject: [PATCH] Replace deprecated Stack with an ArrayDeque --- .../java/fr/neamar/kiss/SettingsActivity.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/fr/neamar/kiss/SettingsActivity.java b/app/src/main/java/fr/neamar/kiss/SettingsActivity.java index f5681df48..4e260cc6e 100644 --- a/app/src/main/java/fr/neamar/kiss/SettingsActivity.java +++ b/app/src/main/java/fr/neamar/kiss/SettingsActivity.java @@ -1,7 +1,6 @@ package fr.neamar.kiss; import android.Manifest; -import android.app.ActionBar; import android.app.Dialog; import android.content.Intent; import android.content.SharedPreferences; @@ -23,20 +22,16 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.view.ViewParent; -import android.widget.FrameLayout; -import android.widget.ImageButton; -import android.widget.LinearLayout; import android.widget.Toast; import android.widget.Toolbar; import androidx.annotation.NonNull; +import java.util.ArrayDeque; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Set; -import java.util.Stack; import fr.neamar.kiss.broadcast.IncomingCallHandler; import fr.neamar.kiss.dataprovider.AppProvider; @@ -137,11 +132,11 @@ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preferen final Dialog dialog = ((PreferenceScreen) preference).getDialog(); ViewGroup root = (ViewGroup) dialog.getWindow().getDecorView(); - Stack viewGroups = new Stack<>(); + ArrayDeque viewGroups = new ArrayDeque<>(); viewGroups.push(root); - bfs: while(!viewGroups.empty()) { - ViewGroup e = viewGroups.pop(); + bfs: while(!viewGroups.isEmpty()) { + ViewGroup e = viewGroups.removeFirst(); for (int i = 0; i < e.getChildCount(); i++) { View child = e.getChildAt(i); @@ -160,7 +155,7 @@ public void onClick(View v) { } if (child instanceof ViewGroup) { - viewGroups.push((ViewGroup) child); + viewGroups.addFirst((ViewGroup) child); } } }