From 9650660e4ade4586b47d5ff9a221c19be9dc054e Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Fri, 26 Oct 2018 23:49:38 +0200 Subject: [PATCH] Remove unneeded casts --- .../Plugins/MousePadPlugin/MousePadActivity.java | 2 +- .../kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java | 8 ++++---- .../NotificationsPlugin/NotificationFilterActivity.java | 2 +- .../Plugins/RunCommandPlugin/RunCommandActivity.java | 6 +++--- .../RunCommandPlugin/RunCommandWidgetDeviceSelector.java | 2 +- .../kde/kdeconnect/Plugins/SharePlugin/ShareActivity.java | 4 ++-- .../Plugins/SystemvolumePlugin/SystemvolumeFragment.java | 4 ++-- .../kdeconnect/UserInterface/CustomDevicesActivity.java | 6 +++--- src/org/kde/kdeconnect/UserInterface/DeviceFragment.java | 2 +- src/org/kde/kdeconnect/UserInterface/List/EntryItem.java | 4 ++-- .../kdeconnect/UserInterface/List/PairingDeviceItem.java | 6 +++--- src/org/kde/kdeconnect/UserInterface/List/PluginItem.java | 4 ++-- .../kde/kdeconnect/UserInterface/List/SectionItem.java | 2 +- .../kde/kdeconnect/UserInterface/List/SmallEntryItem.java | 2 +- src/org/kde/kdeconnect/UserInterface/PairingFragment.java | 4 ++-- 15 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadActivity.java b/src/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadActivity.java index 3a265da6..90f3dd65 100644 --- a/src/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadActivity.java +++ b/src/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadActivity.java @@ -98,7 +98,7 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect mMousePadGestureDetector = new MousePadGestureDetector(this, this); mDetector.setOnDoubleTapListener(this); - keyListenerView = (KeyListenerView) findViewById(R.id.keyListener); + keyListenerView = findViewById(R.id.keyListener); keyListenerView.setDeviceId(deviceId); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); diff --git a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java index fc73ff4e..46ff15ac 100644 --- a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java +++ b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java @@ -110,7 +110,7 @@ public class MprisActivity extends AppCompatActivity { adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); runOnUiThread(() -> { - Spinner spinner = (Spinner) findViewById(R.id.player_spinner); + Spinner spinner = findViewById(R.id.player_spinner); //String prevPlayer = (String)spinner.getSelectedItem(); spinner.setAdapter(adapter); @@ -209,7 +209,7 @@ public class MprisActivity extends AppCompatActivity { } String song = playerStatus.getCurrentSong(); - TextView nowPlaying = (TextView) findViewById(R.id.now_playing_textview); + TextView nowPlaying = findViewById(R.id.now_playing_textview); if (!nowPlaying.getText().toString().equals(song)) { nowPlaying.setText(song); } @@ -225,7 +225,7 @@ public class MprisActivity extends AppCompatActivity { if (playerStatus.isSeekAllowed()) { ((TextView) findViewById(R.id.time_textview)).setText(milisToProgress(playerStatus.getLength())); - SeekBar positionSeek = (SeekBar) findViewById(R.id.positionSeek); + SeekBar positionSeek = findViewById(R.id.positionSeek); positionSeek.setMax((int) (playerStatus.getLength())); positionSeek.setProgress((int) (playerStatus.getPosition())); findViewById(R.id.progress_slider).setVisibility(View.VISIBLE); @@ -377,7 +377,7 @@ public class MprisActivity extends AppCompatActivity { }); positionSeekUpdateRunnable = () -> { - final SeekBar positionSeek = (SeekBar) findViewById(R.id.positionSeek); + final SeekBar positionSeek = findViewById(R.id.positionSeek); BackgroundService.RunCommand(MprisActivity.this, service -> { if (targetPlayer != null) { positionSeek.setProgress((int) (targetPlayer.getPosition())); diff --git a/src/org/kde/kdeconnect/Plugins/NotificationsPlugin/NotificationFilterActivity.java b/src/org/kde/kdeconnect/Plugins/NotificationsPlugin/NotificationFilterActivity.java index 5cd96628..0cb8bbb1 100644 --- a/src/org/kde/kdeconnect/Plugins/NotificationsPlugin/NotificationFilterActivity.java +++ b/src/org/kde/kdeconnect/Plugins/NotificationsPlugin/NotificationFilterActivity.java @@ -128,7 +128,7 @@ public class NotificationFilterActivity extends AppCompatActivity { private void displayAppList() { - listView = (ListView) findViewById(R.id.lvFilterApps); + listView = findViewById(R.id.lvFilterApps); AppListAdapter adapter = new AppListAdapter(); listView.setAdapter(adapter); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); diff --git a/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandActivity.java b/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandActivity.java index 299f747c..54a2a867 100644 --- a/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandActivity.java +++ b/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandActivity.java @@ -67,7 +67,7 @@ public class RunCommandActivity extends AppCompatActivity { } runOnUiThread(() -> { - ListView view = (ListView) findViewById(R.id.runcommandslist); + ListView view = findViewById(R.id.runcommandslist); registerForContextMenu(view); @@ -96,7 +96,7 @@ public class RunCommandActivity extends AppCompatActivity { }); - TextView explanation = (TextView) findViewById(R.id.addcomand_explanation); + TextView explanation = findViewById(R.id.addcomand_explanation); String text = getString(R.string.addcommand_explanation); if (!plugin.canAddCommand()) { text += "\n" + getString(R.string.addcommand_explanation2); @@ -117,7 +117,7 @@ public class RunCommandActivity extends AppCompatActivity { boolean canAddCommands = BackgroundService.getInstance().getDevice(deviceId).getPlugin(RunCommandPlugin.class).canAddCommand(); - FloatingActionButton addCommandButton = (FloatingActionButton) findViewById(R.id.add_command_button); + FloatingActionButton addCommandButton = findViewById(R.id.add_command_button); addCommandButton.setVisibility(canAddCommands ? View.VISIBLE : View.GONE); addCommandButton.setOnClickListener(view -> BackgroundService.RunCommand(RunCommandActivity.this, service -> { diff --git a/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandWidgetDeviceSelector.java b/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandWidgetDeviceSelector.java index c9167e52..ae5fa65e 100644 --- a/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandWidgetDeviceSelector.java +++ b/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandWidgetDeviceSelector.java @@ -26,7 +26,7 @@ public class RunCommandWidgetDeviceSelector extends AppCompatActivity { setContentView(R.layout.widget_remotecommandplugin_dialog); BackgroundService.RunCommand(this, service -> runOnUiThread(() -> { - ListView view = (ListView) findViewById(R.id.runcommandsdevicelist); + ListView view = findViewById(R.id.runcommandsdevicelist); final ArrayList deviceItems = new ArrayList<>(); diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareActivity.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareActivity.java index f2eccd67..38de5d76 100644 --- a/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareActivity.java +++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareActivity.java @@ -108,7 +108,7 @@ public class ShareActivity extends AppCompatActivity { } runOnUiThread(() -> { - ListView list = (ListView) findViewById(R.id.devices_list); + ListView list = findViewById(R.id.devices_list); list.setAdapter(new ListAdapter(ShareActivity.this, items)); list.setOnItemClickListener((adapterView, view, i, l) -> { @@ -129,7 +129,7 @@ public class ShareActivity extends AppCompatActivity { setContentView(R.layout.devices_list); ActionBar actionBar = getSupportActionBar(); - mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_list_layout); + mSwipeRefreshLayout = findViewById(R.id.refresh_list_layout); mSwipeRefreshLayout.setOnRefreshListener( this::updateComputerListAction ); diff --git a/src/org/kde/kdeconnect/Plugins/SystemvolumePlugin/SystemvolumeFragment.java b/src/org/kde/kdeconnect/Plugins/SystemvolumePlugin/SystemvolumeFragment.java index 15324db7..f2c1681a 100644 --- a/src/org/kde/kdeconnect/Plugins/SystemvolumePlugin/SystemvolumeFragment.java +++ b/src/org/kde/kdeconnect/Plugins/SystemvolumePlugin/SystemvolumeFragment.java @@ -121,12 +121,12 @@ public class SystemvolumeFragment extends ListFragment implements Sink.UpdateLis ((TextView) view.findViewById(R.id.systemvolume_label)).setText(getItem(position).getDescription()); - final SeekBar seekBar = (SeekBar) view.findViewById(R.id.systemvolume_seek); + final SeekBar seekBar = view.findViewById(R.id.systemvolume_seek); seekBar.setMax(getItem(position).getMaxVolume()); seekBar.setProgress(getItem(position).getVolume()); seekBar.setOnSeekBarChangeListener(listener); - ImageButton button = (ImageButton) view.findViewById(R.id.systemvolume_mute); + ImageButton button = view.findViewById(R.id.systemvolume_mute); int iconRes = getItem(position).isMute() ? R.drawable.ic_volume_mute_black : R.drawable.ic_volume_black; button.setImageResource(iconRes); button.setOnClickListener(listener); diff --git a/src/org/kde/kdeconnect/UserInterface/CustomDevicesActivity.java b/src/org/kde/kdeconnect/UserInterface/CustomDevicesActivity.java index 2c509ad1..60d06074 100644 --- a/src/org/kde/kdeconnect/UserInterface/CustomDevicesActivity.java +++ b/src/org/kde/kdeconnect/UserInterface/CustomDevicesActivity.java @@ -58,14 +58,14 @@ public class CustomDevicesActivity extends AppCompatActivity { ThemeUtil.setUserPreferredTheme(this); setContentView(R.layout.custom_ip_list); - list = (ListView) findViewById(android.R.id.list); + list = findViewById(android.R.id.list); list.setOnItemClickListener(onClickListener); list.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, ipAddressList)); findViewById(android.R.id.button1).setOnClickListener(v -> addNewDevice()); - EditText ipEntryBox = (EditText) findViewById(R.id.ip_edittext); + EditText ipEntryBox = findViewById(R.id.ip_edittext); ipEntryBox.setOnEditorActionListener((v, actionId, event) -> { if (actionId == EditorInfo.IME_ACTION_SEND) { addNewDevice(); @@ -108,7 +108,7 @@ public class CustomDevicesActivity extends AppCompatActivity { }; private void addNewDevice() { - EditText ipEntryBox = (EditText) findViewById(R.id.ip_edittext); + EditText ipEntryBox = findViewById(R.id.ip_edittext); String enteredText = ipEntryBox.getText().toString().trim(); if (!enteredText.isEmpty()) { // don't add empty string (after trimming) diff --git a/src/org/kde/kdeconnect/UserInterface/DeviceFragment.java b/src/org/kde/kdeconnect/UserInterface/DeviceFragment.java index dbe279f0..2818f023 100644 --- a/src/org/kde/kdeconnect/UserInterface/DeviceFragment.java +++ b/src/org/kde/kdeconnect/UserInterface/DeviceFragment.java @@ -125,7 +125,7 @@ public class DeviceFragment extends Fragment { }); - final Button pairButton = (Button) rootView.findViewById(R.id.pair_button); + final Button pairButton = rootView.findViewById(R.id.pair_button); pairButton.setOnClickListener(view -> { pairButton.setVisibility(View.GONE); ((TextView) rootView.findViewById(R.id.pair_message)).setText(""); diff --git a/src/org/kde/kdeconnect/UserInterface/List/EntryItem.java b/src/org/kde/kdeconnect/UserInterface/List/EntryItem.java index 16b10629..ceb1bb00 100644 --- a/src/org/kde/kdeconnect/UserInterface/List/EntryItem.java +++ b/src/org/kde/kdeconnect/UserInterface/List/EntryItem.java @@ -45,11 +45,11 @@ public class EntryItem implements ListAdapter.Item { public View inflateView(LayoutInflater layoutInflater) { View v = layoutInflater.inflate(R.layout.list_item_entry, null); - TextView titleView = (TextView) v.findViewById(R.id.list_item_entry_title); + TextView titleView = v.findViewById(R.id.list_item_entry_title); if (titleView != null) titleView.setText(title); if (subtitle != null) { - TextView subtitleView = (TextView) v.findViewById(R.id.list_item_entry_summary); + TextView subtitleView = v.findViewById(R.id.list_item_entry_summary); if (subtitleView != null) { subtitleView.setVisibility(View.VISIBLE); subtitleView.setText(subtitle); diff --git a/src/org/kde/kdeconnect/UserInterface/List/PairingDeviceItem.java b/src/org/kde/kdeconnect/UserInterface/List/PairingDeviceItem.java index 7bff491d..1446add3 100644 --- a/src/org/kde/kdeconnect/UserInterface/List/PairingDeviceItem.java +++ b/src/org/kde/kdeconnect/UserInterface/List/PairingDeviceItem.java @@ -50,14 +50,14 @@ public class PairingDeviceItem implements ListAdapter.Item { public View inflateView(LayoutInflater layoutInflater) { final View v = layoutInflater.inflate(R.layout.list_item_with_icon_entry, null); - ImageView icon = (ImageView) v.findViewById(R.id.list_item_entry_icon); + ImageView icon = v.findViewById(R.id.list_item_entry_icon); icon.setImageDrawable(device.getIcon()); - TextView titleView = (TextView) v.findViewById(R.id.list_item_entry_title); + TextView titleView = v.findViewById(R.id.list_item_entry_title); titleView.setText(device.getName()); if (device.compareProtocolVersion() != 0) { - TextView summaryView = (TextView) v.findViewById(R.id.list_item_entry_summary); + TextView summaryView = v.findViewById(R.id.list_item_entry_summary); if (device.compareProtocolVersion() > 0) { summaryView.setText(R.string.protocol_version_newer); diff --git a/src/org/kde/kdeconnect/UserInterface/List/PluginItem.java b/src/org/kde/kdeconnect/UserInterface/List/PluginItem.java index 515e3d8d..a7fa6d4d 100644 --- a/src/org/kde/kdeconnect/UserInterface/List/PluginItem.java +++ b/src/org/kde/kdeconnect/UserInterface/List/PluginItem.java @@ -43,10 +43,10 @@ public class PluginItem implements ListAdapter.Item { public View inflateView(final LayoutInflater layoutInflater) { View v = layoutInflater.inflate(R.layout.list_item_with_icon_entry, null); - TextView titleView = (TextView) v.findViewById(R.id.list_item_entry_title); + TextView titleView = v.findViewById(R.id.list_item_entry_title); titleView.setText(plugin.getActionName()); - ImageView imageView = (ImageView) v.findViewById(R.id.list_item_entry_icon); + ImageView imageView = v.findViewById(R.id.list_item_entry_icon); imageView.setImageDrawable(plugin.getIcon()); v.setOnClickListener(clickListener); diff --git a/src/org/kde/kdeconnect/UserInterface/List/SectionItem.java b/src/org/kde/kdeconnect/UserInterface/List/SectionItem.java index 2bdbb313..e16985cc 100644 --- a/src/org/kde/kdeconnect/UserInterface/List/SectionItem.java +++ b/src/org/kde/kdeconnect/UserInterface/List/SectionItem.java @@ -45,7 +45,7 @@ public class SectionItem implements ListAdapter.Item { v.setOnClickListener(null); v.setOnLongClickListener(null); - TextView sectionView = (TextView) v.findViewById(R.id.list_item_category_text); + TextView sectionView = v.findViewById(R.id.list_item_category_text); sectionView.setText(title); if (isEmpty) { diff --git a/src/org/kde/kdeconnect/UserInterface/List/SmallEntryItem.java b/src/org/kde/kdeconnect/UserInterface/List/SmallEntryItem.java index f8538943..b6145287 100644 --- a/src/org/kde/kdeconnect/UserInterface/List/SmallEntryItem.java +++ b/src/org/kde/kdeconnect/UserInterface/List/SmallEntryItem.java @@ -46,7 +46,7 @@ public class SmallEntryItem implements ListAdapter.Item { public View inflateView(LayoutInflater layoutInflater) { View v = layoutInflater.inflate(android.R.layout.simple_list_item_1, null); - TextView titleView = (TextView) v.findViewById(android.R.id.text1); + TextView titleView = v.findViewById(android.R.id.text1); if (titleView != null) { titleView.setText(title); if (clickListener != null) { diff --git a/src/org/kde/kdeconnect/UserInterface/PairingFragment.java b/src/org/kde/kdeconnect/UserInterface/PairingFragment.java index ce14c09d..94c3950c 100644 --- a/src/org/kde/kdeconnect/UserInterface/PairingFragment.java +++ b/src/org/kde/kdeconnect/UserInterface/PairingFragment.java @@ -77,7 +77,7 @@ public class PairingFragment extends Fragment implements PairingDeviceItem.Callb rootView = inflater.inflate(R.layout.devices_list, container, false); View listRootView = rootView.findViewById(R.id.devices_list); - mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.refresh_list_layout); + mSwipeRefreshLayout = rootView.findViewById(R.id.refresh_list_layout); mSwipeRefreshLayout.setOnRefreshListener( this::updateComputerListAction ); @@ -172,7 +172,7 @@ public class PairingFragment extends Fragment implements PairingDeviceItem.Callb items.remove(items.size() - 1); //Remove remembered devices section if empty } - final ListView list = (ListView) rootView.findViewById(R.id.devices_list); + final ListView list = rootView.findViewById(R.id.devices_list); //Store current scroll int index = list.getFirstVisiblePosition();