Commit e0c161b3 authored by Craig Earley's avatar Craig Earley
Browse files

removes unnecessary type casts, as pointed out by Lint

parent 91e311f4
......@@ -81,7 +81,7 @@ public class BenchSampleActivity extends AppCompatActivity {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
tripName = settings.getString("trip", "");
Log.d("BenchSampleActivity", "tripName: "+tripName);
TextView trip_name = (TextView) findViewById(R.id.tripNameText);
TextView trip_name = findViewById(R.id.tripNameText);
trip_name.setText(String.format("Trip Name: %s", tripName));
siteList = new ArrayList<>();
......@@ -92,8 +92,8 @@ public class BenchSampleActivity extends AppCompatActivity {
remote_db = getIntent().getBooleanExtra(REMOTE_DB, false);
readingNotes = "";
recordButton = (Button) findViewById(R.id.recordButton);
addPictureButton = (Button) findViewById(R.id.addPicture);
recordButton = findViewById(R.id.recordButton);
addPictureButton = findViewById(R.id.addPicture);
baseDir = new File(directory);
if (!baseDir.exists()){
baseDir.mkdir();
......@@ -102,21 +102,21 @@ public class BenchSampleActivity extends AppCompatActivity {
// Site spinner, site adapter
if (remote_db) { siteList = db.getSites(null); }
siteList.add(0, new Pair<>("Site", "0"));
siteSpinner = (Spinner) findViewById(R.id.selectSite);
siteSpinner = findViewById(R.id.selectSite);
siteAdapter = new DropdownListAdapter(this);
siteAdapter.addItems(siteList);
siteSpinner.setAdapter(siteAdapter);
// Sector spinner, sector adapter
sectorSpinner = (Spinner) findViewById(R.id.selectSector);
sectorSpinner = findViewById(R.id.selectSector);
// Spot spinner, spot adapter
spotSpinner = (Spinner) findViewById(R.id.selectSpot);
spotSpinner = findViewById(R.id.selectSpot);
// Platform spinner, platform adapter
if (remote_db) { platformList.addAll(db.getPlatforms()); }
platformList.add(0, "Platform");
platformSpinner = (Spinner) findViewById(R.id.selectPlatform);
platformSpinner = findViewById(R.id.selectPlatform);
ArrayAdapter<String> platformAdapter = new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, platformList);
platformAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
......@@ -124,7 +124,7 @@ public class BenchSampleActivity extends AppCompatActivity {
// Sensor spinner, sensor adapter
sensorList.add(0, new Pair<>("Sensor", "0"));
sensorSpinner = (Spinner) findViewById(R.id.selectSensor);
sensorSpinner = findViewById(R.id.selectSensor);
sensorAdapter = new DropdownListAdapter(this);
sensorAdapter.addItems(sensorList);
sensorSpinner.setAdapter(sensorAdapter);
......@@ -216,7 +216,7 @@ public class BenchSampleActivity extends AppCompatActivity {
}
});
notesET = (EditText) findViewById(R.id.readingNotes);
notesET = findViewById(R.id.readingNotes);
notesET.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
......@@ -234,7 +234,7 @@ public class BenchSampleActivity extends AppCompatActivity {
}
});
valueET = (EditText) findViewById(R.id.sensorValue);
valueET = findViewById(R.id.sensorValue);
valueET.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
......@@ -257,7 +257,7 @@ public class BenchSampleActivity extends AppCompatActivity {
}
});
qualityET = (EditText) findViewById(R.id.sensorQuality);
qualityET = findViewById(R.id.sensorQuality);
qualityET.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
......@@ -371,7 +371,7 @@ public class BenchSampleActivity extends AppCompatActivity {
super.onActivityResult(requestCode, resultCode, data);
LayoutInflater layoutInflater = this.getLayoutInflater();
final View dialog = layoutInflater.inflate(R.layout.alert_picture_name, null);
final EditText name = (EditText) dialog.findViewById(R.id.pictureName);
final EditText name = dialog.findViewById(R.id.pictureName);
if (resultCode != Activity.RESULT_CANCELED) {
Dialog d = new AlertDialog.Builder(BenchSampleActivity.this)
......
......@@ -86,20 +86,20 @@ public class DatabaseActionsActivity extends AppCompatActivity {
uploadColumnCount += db.getColumns(table).length;
}
dbSizeTV = (TextView) findViewById(R.id.databaseSize);
dbSizeTV = findViewById(R.id.databaseSize);
dbSizeTV.setText(String.format(res.getString(R.string.databaseSize), Formatter.formatFileSize(this, db.getSize())));
dbStatusTV = (TextView) findViewById(R.id.databaseStatus);
dbStatusTV = findViewById(R.id.databaseStatus);
dbStatusTV.setText(String.format(res.getString(R.string.databaseStatus), ""));
displayDatabaseStatus(db.getStatus());
cleanTV = (TextView) findViewById(R.id.lastClean);
cleanTV = findViewById(R.id.lastClean);
cleanTV.setText(String.format(res.getString(R.string.lastClean), settings.getString("lastClean", "Never")));
uploadTV = (TextView) findViewById(R.id.lastUpload);
uploadTV = findViewById(R.id.lastUpload);
uploadTV.setText(String.format(res.getString(R.string.lastUpload), settings.getString("lastUpload", "Never")));
downloadTV = (TextView) findViewById(R.id.lastDownload);
downloadTV = findViewById(R.id.lastDownload);
downloadTV.setText(String.format(res.getString(R.string.lastDownload), settings.getString("lastDownload", "Never")));
server = (EditText) findViewById(R.id.serverIp);
server = findViewById(R.id.serverIp);
host = settings.getString("host", "cluster.earlham.edu");
server.setText(host);
editor.putString("host", host);
......@@ -123,7 +123,7 @@ public class DatabaseActionsActivity extends AppCompatActivity {
}
});
dbName = (EditText) findViewById(R.id.database);
dbName = findViewById(R.id.database);
database = settings.getString("database_name", "field_science");
dbName.setText(database);
editor.putString("database_name", database);
......@@ -147,7 +147,7 @@ public class DatabaseActionsActivity extends AppCompatActivity {
}
});
username = (EditText) findViewById(R.id.username);
username = findViewById(R.id.username);
uname = settings.getString("username", "fieldsci");
username.setText(uname);
editor.putString("username", uname);
......@@ -171,7 +171,7 @@ public class DatabaseActionsActivity extends AppCompatActivity {
}
});
password = (EditText) findViewById(R.id.password);
password = findViewById(R.id.password);
pass = settings.getString("password", "skalanes");
password.setText(pass);
editor.putString("password", pass);
......@@ -195,7 +195,7 @@ public class DatabaseActionsActivity extends AppCompatActivity {
}
});
port = (EditText) findViewById(R.id.port);
port = findViewById(R.id.port);
pNum = settings.getString("port", "5432");
port.setText(pNum);
editor.putString("port", pNum);
......@@ -219,7 +219,7 @@ public class DatabaseActionsActivity extends AppCompatActivity {
}
});
setup = (Button) findViewById(R.id.setupDbButton);
setup = findViewById(R.id.setupDbButton);
setup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -227,7 +227,7 @@ public class DatabaseActionsActivity extends AppCompatActivity {
}
});
clean = (Button) findViewById(R.id.wipeDatabase);
clean = findViewById(R.id.wipeDatabase);
clean.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v){
......@@ -235,7 +235,7 @@ public class DatabaseActionsActivity extends AppCompatActivity {
}
});
cleanReadings = (Button) findViewById(R.id.wipeReadingsTable);
cleanReadings = findViewById(R.id.wipeReadingsTable);
cleanReadings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v){
......@@ -243,7 +243,7 @@ public class DatabaseActionsActivity extends AppCompatActivity {
}
});
cleanStreaming = (Button) findViewById(R.id.wipeStreamingTable);
cleanStreaming = findViewById(R.id.wipeStreamingTable);
cleanStreaming.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v){
......@@ -251,7 +251,7 @@ public class DatabaseActionsActivity extends AppCompatActivity {
}
});
cleanField = (Button) findViewById(R.id.wipeFieldData);
cleanField = findViewById(R.id.wipeFieldData);
cleanField.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v){
......@@ -259,7 +259,7 @@ public class DatabaseActionsActivity extends AppCompatActivity {
}
});
upload = (Button) findViewById(R.id.uploadButton);
upload = findViewById(R.id.uploadButton);
upload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v){
......
......@@ -28,8 +28,8 @@ public class DriveResultsAdapter extends DataBufferAdapter<Metadata> {
}
Metadata metadata = getItem(position);
TextView titleTextView =
(TextView) convertView.findViewById(R.id.objectName);
ImageView objectType = (ImageView) convertView.findViewById(R.id.objectType);
convertView.findViewById(R.id.objectName);
ImageView objectType = convertView.findViewById(R.id.objectType);
Resources res = context.getResources();
switch(metadata.getMimeType()){
case DriveFolder.MIME_TYPE:
......
......@@ -64,7 +64,7 @@ public class DropdownListAdapter extends BaseAdapter {
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = Objects.requireNonNull(inflater).inflate(R.layout.dropdown_item, parent, false);
holder = new ViewHolderItem();
holder.itemName = (TextView) view.findViewById(R.id.itemName);
holder.itemName = view.findViewById(R.id.itemName);
view.setTag(holder);
} else {
......
......@@ -38,7 +38,7 @@ public class GoogleDriveFileBrowser extends GoogleDriveConnect {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_drive);
ListView filesListView = (ListView) findViewById(R.id.listFileResults);
ListView filesListView = findViewById(R.id.listFileResults);
filesAdapter = new DriveResultsAdapter(this);
filesListView.setAdapter(filesAdapter);
filesListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
......@@ -59,7 +59,7 @@ public class GoogleDriveFileBrowser extends GoogleDriveConnect {
fileName = "";
Button fileButton = (Button) findViewById(R.id.createFileButton);
Button fileButton = findViewById(R.id.createFileButton);
fileButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -67,7 +67,7 @@ public class GoogleDriveFileBrowser extends GoogleDriveConnect {
}
});
Button folderButton = (Button) findViewById(R.id.createFolderButton);
Button folderButton = findViewById(R.id.createFolderButton);
folderButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......
......@@ -25,7 +25,7 @@ public class MyDocumentViewer extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mydocviewier);
docImageView = (ImageView) findViewById(R.id.myDocView);
docImageView = findViewById(R.id.myDocView);
fileToOpen = (File) Objects.requireNonNull(getIntent().getExtras()).get("fileToOpen");
if (Objects.requireNonNull(fileToOpen).getName().endsWith(".pdf")){
......
......@@ -57,7 +57,7 @@ public class MyDocumentsActivity extends AppCompatActivity {
setContentView(R.layout.activity_mydocuments);
downloadFiles = (Button) findViewById(R.id.downloadFileButton);
downloadFiles = findViewById(R.id.downloadFileButton);
downloadFiles.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -81,7 +81,7 @@ public class MyDocumentsActivity extends AppCompatActivity {
firstPage = true;
context = this;
ListView filesListView = (ListView) findViewById(R.id.listFileResults);
ListView filesListView = findViewById(R.id.listFileResults);
myDocumentsAdapter = new MyDocumentsAdapter(context, localDirList);
filesListView.setAdapter(myDocumentsAdapter);
filesListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
......@@ -113,9 +113,9 @@ public class MyDocumentsActivity extends AppCompatActivity {
androidx.appcompat.app.AlertDialog.Builder builder = new androidx.appcompat.app.AlertDialog.Builder(MyDocumentsActivity.this);
LayoutInflater layoutInflater = this.getLayoutInflater();
final View dialog = layoutInflater.inflate(R.layout.alert_dialog_sigin, null);
final EditText host = (EditText) dialog.findViewById(R.id.fileHost);
final EditText host = dialog.findViewById(R.id.fileHost);
host.setText(settings.getString("docURL", ""));
final EditText path = (EditText) dialog.findViewById(R.id.directoryPath);
final EditText path = dialog.findViewById(R.id.directoryPath);
path.setText(settings.getString("docPath", ""));
builder.setView(dialog);
builder.setNegativeButton("Cancel", null);
......
......@@ -31,8 +31,8 @@ public class MyDocumentsAdapter extends ArrayAdapter<File> {
convertView = Objects.requireNonNull(layoutInflater).inflate(R.layout.file_list, parent, false);
}
TextView fName = (TextView) convertView.findViewById(R.id.objectName);
ImageView fType = (ImageView) convertView.findViewById(R.id.objectType);
TextView fName = convertView.findViewById(R.id.objectName);
ImageView fType = convertView.findViewById(R.id.objectType);
fName.setText(Objects.requireNonNull(file).getName());
......
......@@ -33,8 +33,8 @@ public class SensorListAdapter extends ArrayAdapter<aSensor> {
convertView = Objects.requireNonNull(inflater).inflate(R.layout.fragment_sensorlist, parent, false);
holder = new ViewHolderItem();
holder.sensorName = (TextView)convertView.findViewById(R.id.sensor);
holder.sensorValue = (TextView)convertView.findViewById(R.id.sensorValue);
holder.sensorName = convertView.findViewById(R.id.sensor);
holder.sensorValue = convertView.findViewById(R.id.sensorValue);
convertView.setTag(holder);
} else {
......
......@@ -169,14 +169,14 @@ public class SensorSampleActivity extends AppCompatActivity {
progress.setCancelable(false);
progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progress.show();
RadioButton three = (RadioButton) findViewById(R.id.threeSeconds);
RadioButton three = findViewById(R.id.threeSeconds);
three.setVisibility(View.INVISIBLE);
} else {
RadioButton one = (RadioButton) findViewById(R.id.oneSecond);
RadioButton one = findViewById(R.id.oneSecond);
one.setVisibility(View.VISIBLE);
}
ListView mSensors = (ListView) findViewById(android.R.id.list);
ListView mSensors = findViewById(android.R.id.list);
adapter = new SensorListAdapter(this, listSensors);
mSensors.setAdapter(adapter);
Intent i = new Intent(context, SensorSampleService.class);
......@@ -311,7 +311,7 @@ public class SensorSampleActivity extends AppCompatActivity {
super.onActivityResult(requestCode, resultCode, data);
LayoutInflater layoutInflater = this.getLayoutInflater();
final View dialog = layoutInflater.inflate(R.layout.alert_picture_name, null);
final EditText name = (EditText) dialog.findViewById(R.id.pictureName);
final EditText name = dialog.findViewById(R.id.pictureName);
if (resultCode != Activity.RESULT_CANCELED) {
Dialog d = new androidx.appcompat.app.AlertDialog.Builder(SensorSampleActivity.this)
......@@ -420,20 +420,20 @@ public class SensorSampleActivity extends AppCompatActivity {
private void initializeVariables() {
res = getResources();
longAndLat = (TextView) findViewById(R.id.longandlat);
satellites = (TextView) findViewById(R.id.satellites);
accuracy = (TextView) findViewById(R.id.accuracy);
elevation = (TextView) findViewById(R.id.elevation);
siteSpinner = (Spinner) findViewById(R.id.site);
sectorSpinner = (Spinner) findViewById(R.id.sector);
spotET = (EditText) findViewById(R.id.spotNumber);
streamButton = (ImageButton) findViewById(R.id.streamButton);
sampleButton = (ImageButton) findViewById(R.id.sampleButton);
longAndLat = findViewById(R.id.longandlat);
satellites = findViewById(R.id.satellites);
accuracy = findViewById(R.id.accuracy);
elevation = findViewById(R.id.elevation);
siteSpinner = findViewById(R.id.site);
sectorSpinner = findViewById(R.id.sector);
spotET = findViewById(R.id.spotNumber);
streamButton = findViewById(R.id.streamButton);
sampleButton = findViewById(R.id.sampleButton);
streamOn = res.getDrawable(R.drawable.stream_pushed, null);
streamOff = res.getDrawable(R.drawable.stream_button, null);
pictureButton = (Button) findViewById(R.id.addPictureButton);
notesButton = (Button) findViewById(R.id.addNotesButton);
calibrateButton = (Button) findViewById(R.id.calibrateSensorButton);
pictureButton = findViewById(R.id.addPictureButton);
notesButton = findViewById(R.id.addNotesButton);
calibrateButton = findViewById(R.id.calibrateSensorButton);
spot = "";
sampleNotes = "";
......@@ -443,7 +443,7 @@ public class SensorSampleActivity extends AppCompatActivity {
baseDir.mkdir();
}
logIntervalButton = (RadioGroup) findViewById(R.id.interval);
logIntervalButton = findViewById(R.id.interval);
locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
locationListener = new myLocationListener();
......@@ -460,7 +460,7 @@ public class SensorSampleActivity extends AppCompatActivity {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
tripName = settings.getString("trip", "");
Log.d("SensorSample", "tripName: " + tripName);
TextView trip_name = (TextView) findViewById(R.id.tripNameText);
TextView trip_name = findViewById(R.id.tripNameText);
trip_name.setText(String.format("Trip Name: %s", tripName));
context = this;
......@@ -602,7 +602,7 @@ public class SensorSampleActivity extends AppCompatActivity {
public void addNotes(View v) {
LayoutInflater layoutInflater = this.getLayoutInflater();
final View dialog = layoutInflater.inflate(R.layout.alert_sample_notes, null);
final EditText notes = (EditText) dialog.findViewById(R.id.sampleNotes);
final EditText notes = dialog.findViewById(R.id.sampleNotes);
Dialog d = new AlertDialog.Builder(SensorSampleActivity.this)
.setNegativeButton("Cancel", null)
......@@ -703,8 +703,8 @@ public class SensorSampleActivity extends AppCompatActivity {
public void calibrateSensor(View v){
LayoutInflater layoutInflater = this.getLayoutInflater();
final View dialog = layoutInflater.inflate(R.layout.alert_calibration_value, null);
final EditText value = (EditText) dialog.findViewById(R.id.calibrationValue);
final Spinner dropdown = (Spinner) dialog.findViewById(R.id.sensorSpinner);
final EditText value = dialog.findViewById(R.id.calibrationValue);
final Spinner dropdown = dialog.findViewById(R.id.sensorSpinner);
ArrayList<String> sensorCalib = new ArrayList<>();
for (aSensor s : sensors){
sensorCalib.add(s.getName());
......
......@@ -232,8 +232,8 @@ public class SensorScanActivity extends ListActivity {
if (view == null) {
view = mInflator.inflate(R.layout.activity_scan, null);
viewHolder = new ViewHolderItem();
viewHolder.deviceAddress = (TextView) view.findViewById(R.id.device_address);
viewHolder.deviceName = (TextView) view.findViewById(R.id.device_name);
viewHolder.deviceAddress = view.findViewById(R.id.device_address);
viewHolder.deviceName = view.findViewById(R.id.device_name);
view.setTag(viewHolder);
} else {
viewHolder = (ViewHolderItem) view.getTag();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment