2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 13:47:41 +00:00

Remove unneeded casts

This commit is contained in:
Nicolas Fella
2018-10-26 23:49:38 +02:00
parent c1426584c1
commit 9650660e4a
15 changed files with 29 additions and 29 deletions

View File

@@ -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);

View File

@@ -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()));

View File

@@ -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);

View File

@@ -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 -> {

View File

@@ -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<ListAdapter.Item> deviceItems = new ArrayList<>();

View File

@@ -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
);

View File

@@ -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);

View File

@@ -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)

View File

@@ -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("");

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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();