From 7dc66b8ac2cf884f70f1a685add2628dbfb57d63 Mon Sep 17 00:00:00 2001 From: badaix Date: Mon, 22 Apr 2024 14:37:13 +0200 Subject: [PATCH] Cleanup code --- .../main/java/de/badaix/snapcast/ClientItem.java | 8 ++++---- .../de/badaix/snapcast/ClientSettingsFragment.java | 14 +++++++------- .../main/java/de/badaix/snapcast/GroupItem.java | 12 ++++++------ .../java/de/badaix/snapcast/GroupListFragment.java | 2 +- .../main/java/de/badaix/snapcast/MainActivity.java | 6 +++--- .../de/badaix/snapcast/ServerDialogFragment.java | 14 +++++++------- .../badaix/snapcast/control/json/ClientConfig.java | 2 +- .../java/de/badaix/snapcast/control/json/Host.java | 2 +- .../de/badaix/snapcast/control/json/Stream.java | 2 +- .../de/badaix/snapcast/control/json/StreamUri.java | 2 +- 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Snapcast/src/main/java/de/badaix/snapcast/ClientItem.java b/Snapcast/src/main/java/de/badaix/snapcast/ClientItem.java index d16dff28..c9d41407 100644 --- a/Snapcast/src/main/java/de/badaix/snapcast/ClientItem.java +++ b/Snapcast/src/main/java/de/badaix/snapcast/ClientItem.java @@ -53,12 +53,12 @@ public ClientItem(Context context, Client client) { LayoutInflater vi = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); vi.inflate(R.layout.client_item, this); - title = (TextView) findViewById(R.id.title); - volumeSeekBar = (SeekBar) findViewById(R.id.volumeSeekBar); - ibMute = (ImageButton) findViewById(R.id.ibMute); + title = findViewById(R.id.title); + volumeSeekBar = findViewById(R.id.volumeSeekBar); + ibMute = findViewById(R.id.ibMute); ibMute.setImageResource(R.drawable.ic_speaker_icon); ibMute.setOnClickListener(this); - ibOverflow = (ImageButton) findViewById(R.id.ibOverflow); + ibOverflow = findViewById(R.id.ibOverflow); ibOverflow.setOnClickListener(this); volumeSeekBar.setOnSeekBarChangeListener(this); setClient(client); diff --git a/Snapcast/src/main/java/de/badaix/snapcast/ClientSettingsFragment.java b/Snapcast/src/main/java/de/badaix/snapcast/ClientSettingsFragment.java index c8cc981c..15acdcf2 100644 --- a/Snapcast/src/main/java/de/badaix/snapcast/ClientSettingsFragment.java +++ b/Snapcast/src/main/java/de/badaix/snapcast/ClientSettingsFragment.java @@ -71,13 +71,13 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { } }); - prefMac = (Preference) findPreference("pref_client_mac"); - prefId = (Preference) findPreference("pref_client_id"); - prefIp = (Preference) findPreference("pref_client_ip"); - prefHost = (Preference) findPreference("pref_client_host"); - prefOS = (Preference) findPreference("pref_client_os"); - prefVersion = (Preference) findPreference("pref_client_version"); - prefLastSeen = (Preference) findPreference("pref_client_last_seen"); + prefMac = findPreference("pref_client_mac"); + prefId = findPreference("pref_client_id"); + prefIp = findPreference("pref_client_ip"); + prefHost = findPreference("pref_client_host"); + prefOS = findPreference("pref_client_os"); + prefVersion = findPreference("pref_client_version"); + prefLastSeen = findPreference("pref_client_last_seen"); prefLatency = (EditTextPreference) findPreference("pref_client_latency"); prefLatency.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override diff --git a/Snapcast/src/main/java/de/badaix/snapcast/GroupItem.java b/Snapcast/src/main/java/de/badaix/snapcast/GroupItem.java index 4f2b4d98..8e6b263f 100644 --- a/Snapcast/src/main/java/de/badaix/snapcast/GroupItem.java +++ b/Snapcast/src/main/java/de/badaix/snapcast/GroupItem.java @@ -69,17 +69,17 @@ public GroupItem(Context context, ServerStatus server, Group group) { .getSystemService(Context.LAYOUT_INFLATER_SERVICE); vi.inflate(R.layout.group_item, this); // title = (TextView) findViewById(R.id.title); - volumeSeekBar = (SeekBar) findViewById(R.id.volumeSeekBar); - ibMute = (ImageButton) findViewById(R.id.ibMute); + volumeSeekBar = findViewById(R.id.volumeSeekBar); + ibMute = findViewById(R.id.ibMute); ibMute.setImageResource(R.drawable.ic_speaker_icon); ibMute.setOnClickListener(this); - ibSettings = (ImageButton) findViewById(R.id.ibSettings); + ibSettings = findViewById(R.id.ibSettings); ibSettings.setOnClickListener(this); - llVolume = (LinearLayout) findViewById(R.id.llVolume); + llVolume = findViewById(R.id.llVolume); llVolume.setVisibility(GONE); - llClient = (LinearLayout) findViewById(R.id.llClient); + llClient = findViewById(R.id.llClient); llClient.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); - tvStreamName = (TextView) findViewById(R.id.tvStreamName); + tvStreamName = findViewById(R.id.tvStreamName); tvStreamName.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { diff --git a/Snapcast/src/main/java/de/badaix/snapcast/GroupListFragment.java b/Snapcast/src/main/java/de/badaix/snapcast/GroupListFragment.java index 881d50a3..6a944163 100644 --- a/Snapcast/src/main/java/de/badaix/snapcast/GroupListFragment.java +++ b/Snapcast/src/main/java/de/badaix/snapcast/GroupListFragment.java @@ -71,7 +71,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, // Inflate the layout for this fragment Log.d(TAG, "onCreateView: " + this); View view = inflater.inflate(R.layout.fragment_group_list, container, false); - ListView lvGroup = (ListView) view.findViewById(R.id.lvGroup); + ListView lvGroup = view.findViewById(R.id.lvGroup); groupAdapter = new GroupAdapter(getContext(), groupItemListener); groupAdapter.setHideOffline(hideOffline); groupAdapter.updateServer(serverStatus); diff --git a/Snapcast/src/main/java/de/badaix/snapcast/MainActivity.java b/Snapcast/src/main/java/de/badaix/snapcast/MainActivity.java index 3878d05b..68a8ed0d 100644 --- a/Snapcast/src/main/java/de/badaix/snapcast/MainActivity.java +++ b/Snapcast/src/main/java/de/badaix/snapcast/MainActivity.java @@ -156,11 +156,11 @@ protected void onCreate(Bundle savedInstanceState) { // tvInfo.setText("Sample rate: " + rate + ", buffer size: " + size); } - coordinatorLayout = (CoordinatorLayout) findViewById(R.id.myCoordinatorLayout); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + coordinatorLayout = findViewById(R.id.myCoordinatorLayout); + Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); - btnConnect = (Button) findViewById(R.id.btnConnect); + btnConnect = findViewById(R.id.btnConnect); btnConnect.setVisibility(View.GONE); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. diff --git a/Snapcast/src/main/java/de/badaix/snapcast/ServerDialogFragment.java b/Snapcast/src/main/java/de/badaix/snapcast/ServerDialogFragment.java index 27a5cafe..05b171a5 100644 --- a/Snapcast/src/main/java/de/badaix/snapcast/ServerDialogFragment.java +++ b/Snapcast/src/main/java/de/badaix/snapcast/ServerDialogFragment.java @@ -71,20 +71,20 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout View view = inflater.inflate(R.layout.dialog_server, null); - btnScan = (Button) view.findViewById(R.id.btn_scan); + btnScan = view.findViewById(R.id.btn_scan); btnScan.setOnClickListener(this); - editHost = (EditText) view.findViewById(R.id.host); - editStreamPort = (EditText) view.findViewById(R.id.stream_port); - editControlPort = (EditText) view.findViewById(R.id.control_port); - checkBoxAutoStart = (CheckBox) view.findViewById(R.id.checkBoxAutoStart); + editHost = view.findViewById(R.id.host); + editStreamPort = view.findViewById(R.id.stream_port); + editControlPort = view.findViewById(R.id.control_port); + checkBoxAutoStart = view.findViewById(R.id.checkBoxAutoStart); - spinnerAudioEngine = (Spinner) view.findViewById(R.id.audio_engine); + spinnerAudioEngine = view.findViewById(R.id.audio_engine); ArrayAdapter adapter = ArrayAdapter.createFromResource(getContext(), R.array.audio_engine_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerAudioEngine.setAdapter(adapter); - checkBoxResample = (CheckBox) view.findViewById(R.id.checkBoxResample); + checkBoxResample = view.findViewById(R.id.checkBoxResample); update(); diff --git a/Snapcast/src/main/java/de/badaix/snapcast/control/json/ClientConfig.java b/Snapcast/src/main/java/de/badaix/snapcast/control/json/ClientConfig.java index d1b47259..f0a8e155 100644 --- a/Snapcast/src/main/java/de/badaix/snapcast/control/json/ClientConfig.java +++ b/Snapcast/src/main/java/de/badaix/snapcast/control/json/ClientConfig.java @@ -109,7 +109,7 @@ public boolean equals(Object o) { if (latency != that.latency) return false; if (!Objects.equals(name, that.name)) return false; if (instance != that.instance) return false; - return !(!Objects.equals(volume, that.volume)); + return Objects.equals(volume, that.volume); } diff --git a/Snapcast/src/main/java/de/badaix/snapcast/control/json/Host.java b/Snapcast/src/main/java/de/badaix/snapcast/control/json/Host.java index 5936bd83..ac360b5c 100644 --- a/Snapcast/src/main/java/de/badaix/snapcast/control/json/Host.java +++ b/Snapcast/src/main/java/de/badaix/snapcast/control/json/Host.java @@ -105,7 +105,7 @@ public boolean equals(Object o) { if (!Objects.equals(mac, that.mac)) return false; if (!Objects.equals(os, that.os)) return false; if (!Objects.equals(arch, that.arch)) return false; - return !(!Objects.equals(ip, that.ip)); + return Objects.equals(ip, that.ip); } @Override diff --git a/Snapcast/src/main/java/de/badaix/snapcast/control/json/Stream.java b/Snapcast/src/main/java/de/badaix/snapcast/control/json/Stream.java index 7fa268c7..d08546e6 100644 --- a/Snapcast/src/main/java/de/badaix/snapcast/control/json/Stream.java +++ b/Snapcast/src/main/java/de/badaix/snapcast/control/json/Stream.java @@ -74,7 +74,7 @@ public boolean equals(Object o) { if (!Objects.equals(uri, stream.uri)) return false; if (!Objects.equals(id, stream.id)) return false; - return !(!Objects.equals(status, stream.status)); + return Objects.equals(status, stream.status); } @Override diff --git a/Snapcast/src/main/java/de/badaix/snapcast/control/json/StreamUri.java b/Snapcast/src/main/java/de/badaix/snapcast/control/json/StreamUri.java index 1d59a78f..eab76e19 100644 --- a/Snapcast/src/main/java/de/badaix/snapcast/control/json/StreamUri.java +++ b/Snapcast/src/main/java/de/badaix/snapcast/control/json/StreamUri.java @@ -92,7 +92,7 @@ public boolean equals(Object o) { if (!Objects.equals(path, stream.path)) return false; if (!Objects.equals(fragment, stream.fragment)) return false; - return !(!Objects.equals(query, stream.query)); + return Objects.equals(query, stream.query); } @Override