Remove redundant type casts.

This commit is contained in:
Andreas Schildbach 2021-01-21 00:11:21 +01:00
parent d2a0d878b8
commit 0f9e241fe8
23 changed files with 150 additions and 150 deletions

View file

@ -76,12 +76,12 @@ public class MyActionBar extends LinearLayout {
backButtonView = findViewById(R.id.action_bar_back_button);
menuButtonView = findViewById(R.id.action_bar_menu_button);
titlesGroup = (ViewGroup) findViewById(R.id.action_bar_titles);
primaryTitleView = (TextView) findViewById(R.id.action_bar_primary_title);
secondaryTitleView = (TextView) findViewById(R.id.action_bar_secondary_title);
titlesGroup = findViewById(R.id.action_bar_titles);
primaryTitleView = findViewById(R.id.action_bar_primary_title);
secondaryTitleView = findViewById(R.id.action_bar_secondary_title);
progressView = findViewById(R.id.action_bar_progress);
progressButton = (ImageButton) findViewById(R.id.action_bar_progress_button);
progressImage = (ImageView) findViewById(R.id.action_bar_progress_image);
progressButton = findViewById(R.id.action_bar_progress_button);
progressImage = findViewById(R.id.action_bar_progress_image);
// Make sure action bar isn't stuck under a transparent status bar.
final int statusHeight = res

View file

@ -70,7 +70,7 @@ public abstract class OeffiActivity extends Activity {
listFrame.getLayoutParams().width = listShow && mapShow ? res.getDimensionPixelSize(R.dimen.layout_list_width)
: LinearLayout.LayoutParams.MATCH_PARENT;
final ViewGroup navigationDrawer = (ViewGroup) findViewById(R.id.navigation_drawer_layout);
final ViewGroup navigationDrawer = findViewById(R.id.navigation_drawer_layout);
if (navigationDrawer != null) {
final View child = navigationDrawer.getChildAt(1);
child.getLayoutParams().width = res.getDimensionPixelSize(R.dimen.layout_navigation_drawer_width);
@ -111,7 +111,7 @@ public abstract class OeffiActivity extends Activity {
}
protected final MyActionBar getMyActionBar() {
return (MyActionBar) findViewById(R.id.action_bar);
return findViewById(R.id.action_bar);
}
protected final void setPrimaryColor(final int colorResId) {

View file

@ -296,9 +296,9 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
initNavigation();
((Button) findViewById(R.id.directions_network_missing_capability_button))
.setOnClickListener((OnClickListener) v -> NetworkPickerActivity.start(DirectionsActivity.this));
connectivityWarningView = (TextView) findViewById(R.id.directions_connectivity_warning_box);
findViewById(R.id.directions_network_missing_capability_button)
.setOnClickListener(v -> NetworkPickerActivity.start(DirectionsActivity.this));
connectivityWarningView = findViewById(R.id.directions_connectivity_warning_box);
initLayoutTransitions();
@ -310,19 +310,19 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
requestFocusFirst();
};
viewFromLocation = (LocationView) findViewById(R.id.directions_from);
viewFromLocation = findViewById(R.id.directions_from);
viewFromLocation.setAdapter(autoCompleteAdapter);
viewFromLocation.setListener(locationChangeListener);
viewFromLocation.setContextMenuItemClickListener(new LocationContextMenuItemClickListener(viewFromLocation,
REQUEST_CODE_LOCATION_PERMISSION_FROM, REQUEST_CODE_PICK_CONTACT_FROM, REQUEST_CODE_PICK_STATION_FROM));
viewViaLocation = (LocationView) findViewById(R.id.directions_via);
viewViaLocation = findViewById(R.id.directions_via);
viewViaLocation.setAdapter(autoCompleteAdapter);
viewViaLocation.setListener(locationChangeListener);
viewViaLocation.setContextMenuItemClickListener(new LocationContextMenuItemClickListener(viewViaLocation,
REQUEST_CODE_LOCATION_PERMISSION_VIA, REQUEST_CODE_PICK_CONTACT_VIA, REQUEST_CODE_PICK_STATION_VIA));
viewToLocation = (LocationView) findViewById(R.id.directions_to);
viewToLocation = findViewById(R.id.directions_to);
viewToLocation.setAdapter(autoCompleteAdapter);
viewToLocation.setListener(locationChangeListener);
viewToLocation.setOnEditorActionListener((v, actionId, event) -> {
@ -340,15 +340,15 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
REQUEST_CODE_LOCATION_PERMISSION_TO, REQUEST_CODE_PICK_CONTACT_TO, REQUEST_CODE_PICK_STATION_TO));
viewProducts = findViewById(R.id.directions_products);
viewProductToggles.add((ToggleImageButton) findViewById(R.id.directions_products_i));
viewProductToggles.add((ToggleImageButton) findViewById(R.id.directions_products_r));
viewProductToggles.add((ToggleImageButton) findViewById(R.id.directions_products_s));
viewProductToggles.add((ToggleImageButton) findViewById(R.id.directions_products_u));
viewProductToggles.add((ToggleImageButton) findViewById(R.id.directions_products_t));
viewProductToggles.add((ToggleImageButton) findViewById(R.id.directions_products_b));
viewProductToggles.add((ToggleImageButton) findViewById(R.id.directions_products_p));
viewProductToggles.add((ToggleImageButton) findViewById(R.id.directions_products_f));
viewProductToggles.add((ToggleImageButton) findViewById(R.id.directions_products_c));
viewProductToggles.add(findViewById(R.id.directions_products_i));
viewProductToggles.add(findViewById(R.id.directions_products_r));
viewProductToggles.add(findViewById(R.id.directions_products_s));
viewProductToggles.add(findViewById(R.id.directions_products_u));
viewProductToggles.add(findViewById(R.id.directions_products_t));
viewProductToggles.add(findViewById(R.id.directions_products_b));
viewProductToggles.add(findViewById(R.id.directions_products_p));
viewProductToggles.add(findViewById(R.id.directions_products_f));
viewProductToggles.add(findViewById(R.id.directions_products_c));
initProductToggles();
final OnLongClickListener productLongClickListener = v -> {
@ -372,9 +372,9 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
for (final View view : viewProductToggles)
view.setOnLongClickListener(productLongClickListener);
viewBike = (CheckBox) findViewById(R.id.directions_option_bike);
viewBike = findViewById(R.id.directions_option_bike);
viewTimeDepArr = (Button) findViewById(R.id.directions_time_dep_arr);
viewTimeDepArr = findViewById(R.id.directions_time_dep_arr);
viewTimeDepArr.setOnClickListener(v -> {
final DialogBuilder builder = DialogBuilder.get(DirectionsActivity.this);
builder.setTitle(R.string.directions_set_time_prompt);
@ -400,13 +400,13 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
builder.show();
});
viewTime1 = (Button) findViewById(R.id.directions_time_1);
viewTime2 = (Button) findViewById(R.id.directions_time_2);
viewTime1 = findViewById(R.id.directions_time_1);
viewTime2 = findViewById(R.id.directions_time_2);
viewGo = (Button) findViewById(R.id.directions_go);
viewGo = findViewById(R.id.directions_go);
viewGo.setOnClickListener(v -> handleGo());
viewQueryHistoryList = (RecyclerView) findViewById(android.R.id.list);
viewQueryHistoryList = findViewById(android.R.id.list);
viewQueryHistoryList.setLayoutManager(new LinearLayoutManager(this));
viewQueryHistoryList.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
queryHistoryListAdapter = new QueryHistoryAdapter(this, network, this, this);
@ -430,7 +430,7 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
viewQueryMissingCapability.getPaddingRight(), viewQueryMissingCapability.getPaddingBottom());
});
mapView = (OeffiMapView) findViewById(R.id.directions_map);
mapView = findViewById(R.id.directions_map);
if (ContextCompat.checkSelfPermission(DirectionsActivity.this,
Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
android.location.Location location = locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER);
@ -453,7 +453,7 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
pinLocation = Location.coord(Point.fromDouble(p.getLatitude(), p.getLongitude()));
final View view = getLayoutInflater().inflate(R.layout.directions_map_pin, null);
final LocationTextView locationView = (LocationTextView) view
final LocationTextView locationView = view
.findViewById(R.id.directions_map_pin_location);
final View buttonGroup = view.findViewById(R.id.directions_map_pin_buttons);
buttonGroup.findViewById(R.id.directions_map_pin_button_from).setOnClickListener(v -> {
@ -496,7 +496,7 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
((TextView) findViewById(R.id.directions_map_disclaimer))
.setText(mapView.getTileProvider().getTileSource().getCopyrightNotice());
final ZoomControls zoom = (ZoomControls) findViewById(R.id.directions_map_zoom);
final ZoomControls zoom = findViewById(R.id.directions_map_zoom);
mapView.setZoomControls(zoom);
connectivityReceiver = new ConnectivityBroadcastReceiver(connectivityManager) {

View file

@ -262,7 +262,7 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
.setOnClickListener(v -> startActivity(scheduleTripIntent));
}
legsGroup = (ViewGroup) findViewById(R.id.directions_trip_details_legs_group);
legsGroup = findViewById(R.id.directions_trip_details_legs_group);
updateLocations();
updateFares(trip.fares);
@ -278,10 +278,10 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
((TextView) findViewById(R.id.directions_trip_details_footer))
.setText(Html.fromHtml(getString(R.string.directions_trip_details_realtime)));
final TextView disclaimerSourceView = (TextView) findViewById(R.id.directions_trip_details_disclaimer_source);
final TextView disclaimerSourceView = findViewById(R.id.directions_trip_details_disclaimer_source);
updateDisclaimerSource(disclaimerSourceView, network.name(), null);
mapView = (OeffiMapView) findViewById(R.id.directions_trip_details_map);
mapView = findViewById(R.id.directions_trip_details_map);
mapView.setTripAware(new TripAware() {
public Trip getTrip() {
return trip;
@ -527,16 +527,16 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
}
private void updateLocations() {
final LocationTextView fromView = (LocationTextView) findViewById(R.id.directions_trip_details_location_from);
final LocationTextView fromView = findViewById(R.id.directions_trip_details_location_from);
fromView.setLabel(R.string.directions_overview_from);
fromView.setLocation(trip.from);
final LocationTextView toView = (LocationTextView) findViewById(R.id.directions_trip_details_location_to);
final LocationTextView toView = findViewById(R.id.directions_trip_details_location_to);
toView.setLabel(R.string.directions_overview_to);
toView.setLocation(trip.to);
}
private void updateFares(final List<Fare> fares) {
final TableLayout faresTable = (TableLayout) findViewById(R.id.directions_trip_details_fares);
final TableLayout faresTable = findViewById(R.id.directions_trip_details_fares);
if (trip.fares != null && !trip.fares.isEmpty()) {
faresTable.setVisibility(View.VISIBLE);
@ -550,7 +550,7 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
((TextView) fareRow.findViewById(R.id.directions_trip_details_fare_entry_row_name)).setText(fare.name);
((TextView) fareRow.findViewById(R.id.directions_trip_details_fare_entry_row_fare))
.setText(String.format(Locale.US, "%s%.2f", fare.currency.getSymbol(), fare.fare));
final TextView unitView = (TextView) fareRow
final TextView unitView = fareRow
.findViewById(R.id.directions_trip_details_fare_entry_row_unit);
if (fare.units != null && fare.unitName != null)
unitView.setText(String.format("(%s %s)", fare.units, fare.unitName));
@ -573,12 +573,12 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
final boolean showBicycleCarriage = leg.line.hasAttr(Line.Attr.BICYCLE_CARRIAGE);
final List<Stop> intermediateStops = leg.intermediateStops;
final LineView lineView = (LineView) row.findViewById(R.id.directions_trip_details_public_entry_line);
final LineView lineView = row.findViewById(R.id.directions_trip_details_public_entry_line);
lineView.setLine(leg.line);
if (showDestination || showAccessibility)
lineView.setMaxWidth(res.getDimensionPixelSize(R.dimen.line_max_width));
final LinearLayout lineGroup = (LinearLayout) row
final LinearLayout lineGroup = row
.findViewById(R.id.directions_trip_details_public_entry_line_group);
if (showDestination)
lineGroup.setBaselineAlignedChildIndex(0);
@ -587,7 +587,7 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
else if (showBicycleCarriage)
lineGroup.setBaselineAlignedChildIndex(2);
final TextView destinationView = (TextView) row
final TextView destinationView = row
.findViewById(R.id.directions_trip_details_public_entry_destination);
if (destination != null) {
destinationView.setVisibility(View.VISIBLE);
@ -603,7 +603,7 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
final View bicycleCarriageView = row.findViewById(R.id.directions_trip_details_public_entry_bicycle_carriage);
bicycleCarriageView.setVisibility(showBicycleCarriage ? View.VISIBLE : View.GONE);
final ToggleImageButton expandButton = (ToggleImageButton) row
final ToggleImageButton expandButton = row
.findViewById(R.id.directions_trip_details_public_entry_expand);
final Boolean checked = legExpandStates.get(leg);
expandButton
@ -614,7 +614,7 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
updateGUI();
});
final TableLayout stopsView = (TableLayout) row.findViewById(R.id.directions_trip_details_public_entry_stops);
final TableLayout stopsView = row.findViewById(R.id.directions_trip_details_public_entry_stops);
stopsView.removeAllViews();
final CollapseColumns collapseColumns = new CollapseColumns();
collapseColumns.dateChanged(now);
@ -658,14 +658,14 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
stopsView.setColumnCollapsed(3, collapseColumns.collapseDelayColumn);
stopsView.setColumnCollapsed(4, collapseColumns.collapsePositionColumn);
final TextView messageView = (TextView) row.findViewById(R.id.directions_trip_details_public_entry_message);
final TextView messageView = row.findViewById(R.id.directions_trip_details_public_entry_message);
final String message = leg.message != null ? leg.message : leg.line.message;
messageView.setText(message);
messageView.setVisibility(message != null ? View.VISIBLE : View.GONE);
}
private void updateIndividualLeg(final View row, final Individual leg) {
final TextView textView = (TextView) row.findViewById(R.id.directions_trip_details_individual_entry_text);
final TextView textView = row.findViewById(R.id.directions_trip_details_individual_entry_text);
final String distanceStr = leg.distance != 0 ? "(" + leg.distance + "m) " : "";
final int textResId, iconResId;
if (leg.type == Individual.Type.WALK) {
@ -686,7 +686,7 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
textView.setText(Html.fromHtml(getString(textResId, leg.min, distanceStr, leg.arrival.uniqueShortName())));
textView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
final ImageButton mapView = (ImageButton) row.findViewById(R.id.directions_trip_details_individual_entry_map);
final ImageButton mapView = row.findViewById(R.id.directions_trip_details_individual_entry_map);
mapView.setVisibility(View.GONE);
mapView.setOnClickListener(null);
if (leg.arrival.hasCoord()) {
@ -745,7 +745,7 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
}
// name
final TextView stopNameView = (TextView) row.findViewById(R.id.directions_trip_details_public_entry_stop_name);
final TextView stopNameView = row.findViewById(R.id.directions_trip_details_public_entry_stop_name);
stopNameView.setText(stop.location.uniqueShortName());
setStrikeThru(stopNameView, isCancelled);
if (highlightLocation) {
@ -767,14 +767,14 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
stopNameView.setOnClickListener(null);
// pearl
final PearlView pearlView = (PearlView) row.findViewById(R.id.directions_trip_details_public_entry_stop_pearl);
final PearlView pearlView = row.findViewById(R.id.directions_trip_details_public_entry_stop_pearl);
pearlView.setType(pearlType);
pearlView.setStyle(style);
pearlView.setFontMetrics(stopNameView.getPaint().getFontMetrics());
// time
final TextView stopDateView = (TextView) row.findViewById(R.id.directions_trip_details_public_entry_stop_date);
final TextView stopTimeView = (TextView) row.findViewById(R.id.directions_trip_details_public_entry_stop_time);
final TextView stopDateView = row.findViewById(R.id.directions_trip_details_public_entry_stop_date);
final TextView stopTimeView = row.findViewById(R.id.directions_trip_details_public_entry_stop_time);
stopDateView.setText(null);
stopTimeView.setText(null);
boolean highlightTime = false;
@ -796,7 +796,7 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
+ (isTimePredicted ? Typeface.ITALIC : 0));
// delay
final TextView stopDelayView = (TextView) row
final TextView stopDelayView = row
.findViewById(R.id.directions_trip_details_public_entry_stop_delay);
if (delay != null) {
final long delayMins = delay / DateUtils.MINUTE_IN_MILLIS;
@ -808,7 +808,7 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
}
// position
final TextView stopPositionView = (TextView) row
final TextView stopPositionView = row
.findViewById(R.id.directions_trip_details_public_entry_stop_position);
if (position != null && !isCancelled) {
collapseColumns.collapsePositionColumn = false;
@ -834,7 +834,7 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
final View row = inflater.inflate(R.layout.directions_trip_details_public_entry_collapsed, null);
// message
final TextView stopNameView = (TextView) row
final TextView stopNameView = row
.findViewById(R.id.directions_trip_details_public_entry_collapsed_message);
stopNameView.setText(
res.getQuantityString(R.plurals.directions_trip_details_public_entry_collapsed_intermediate_stops,
@ -842,7 +842,7 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
stopNameView.setTextColor(colorInsignificant);
// pearl
final PearlView pearlView = (PearlView) row
final PearlView pearlView = row
.findViewById(R.id.directions_trip_details_public_entry_collapsed_pearl);
pearlView.setType(PearlView.Type.PASSING);
pearlView.setStyle(style);

View file

@ -147,7 +147,7 @@ public class TripsGallery extends Gallery {
long maxTime = 0;
for (int i = first; i <= last; i++) {
final Trip trip = (Trip) adapter.getItem(i);
final Trip trip = adapter.getItem(i);
if (trip != null) {
final Date tripMinTime = trip.getMinTime();
if (tripMinTime != null && tripMinTime.getTime() < minTime)

View file

@ -144,7 +144,7 @@ public class TripsOverviewActivity extends OeffiActivity {
actionBar.setCustomTitles(R.layout.directions_trip_overview_custom_title);
actionBar.addProgressButton().setOnClickListener(v -> handler.post(checkMoreRunnable));
barView = (TripsGallery) findViewById(R.id.trips_bar_view);
barView = findViewById(R.id.trips_bar_view);
barView.setOnItemClickListener((parent, v, position, id) -> {
final Trip trip = (Trip) barView.getAdapter().getItem(position);
@ -330,7 +330,7 @@ public class TripsOverviewActivity extends OeffiActivity {
// update server product
if (result.header != null) {
final TextView serverProductView = (TextView) findViewById(R.id.trips_server_product);
final TextView serverProductView = findViewById(R.id.trips_server_product);
serverProductView.setText(product(result.header));
serverProductView.setVisibility(View.VISIBLE);
}

View file

@ -52,11 +52,11 @@ public class QueryHistoryViewHolder extends RecyclerView.ViewHolder {
this.context = context;
this.network = network;
fromView = (LocationTextView) itemView.findViewById(R.id.directions_query_history_entry_from);
toView = (LocationTextView) itemView.findViewById(R.id.directions_query_history_entry_to);
fromView = itemView.findViewById(R.id.directions_query_history_entry_from);
toView = itemView.findViewById(R.id.directions_query_history_entry_to);
favoriteView = itemView.findViewById(R.id.directions_query_history_entry_favorite);
tripView = (Button) itemView.findViewById(R.id.directions_query_history_entry_trip);
contextButton = (ImageButton) itemView.findViewById(R.id.directions_query_history_entry_context_button);
tripView = itemView.findViewById(R.id.directions_query_history_entry_trip);
contextButton = itemView.findViewById(R.id.directions_query_history_entry_context_button);
}
public void bind(final long rowId, final Location from, final Location to, final boolean isFavorite,

View file

@ -122,23 +122,23 @@ public class NetworkPickerActivity extends Activity implements ActivityCompat.On
backgroundHandler = new Handler(backgroundThread.getLooper());
setContentView(R.layout.network_picker_content);
actionBar = (MyActionBar) findViewById(R.id.action_bar);
actionBar = findViewById(R.id.action_bar);
setPrimaryColor(R.color.bg_action_bar);
actionBar.setPrimaryTitle(getTitle());
listView = (RecyclerView) findViewById(android.R.id.list);
listView = findViewById(android.R.id.list);
listView.setLayoutManager(new LinearLayoutManager(this));
listView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
final String network = prefsGetNetwork();
listAdapter = new NetworksAdapter(this, network, this, this);
listView.setAdapter(listAdapter);
mapView = (OeffiMapView) findViewById(R.id.network_picker_map);
mapView = findViewById(R.id.network_picker_map);
((TextView) findViewById(R.id.network_picker_map_disclaimer))
.setText(mapView.getTileProvider().getTileSource().getCopyrightNotice());
if (network == null) {
((FrameLayout) findViewById(R.id.network_picker_firsttime_message_shadow)).setForeground(null);
findViewById(R.id.network_picker_firsttime_message_shadow).setForeground(null);
} else {
findViewById(R.id.network_picker_firsttime_message).setVisibility(View.GONE);
actionBar.setBack(v -> finish());

View file

@ -54,12 +54,12 @@ public class NetworkViewHolder extends RecyclerView.ViewHolder {
this.colorSignificant = res.getColor(R.color.fg_significant);
this.colorGrey600 = res.getColor(R.color.grey600);
iconView = (ImageView) itemView.findViewById(R.id.network_picker_entry_icon);
labelView = (TextView) itemView.findViewById(R.id.network_picker_entry_label);
stateView = (TextView) itemView.findViewById(R.id.network_picker_entry_state);
commentView = (TextView) itemView.findViewById(R.id.network_picker_entry_comment);
usageView = (TextView) itemView.findViewById(R.id.network_picker_entry_usage);
contextButton = (ImageButton) itemView.findViewById(R.id.network_picker_entry_context_button);
iconView = itemView.findViewById(R.id.network_picker_entry_icon);
labelView = itemView.findViewById(R.id.network_picker_entry_label);
stateView = itemView.findViewById(R.id.network_picker_entry_state);
commentView = itemView.findViewById(R.id.network_picker_entry_comment);
usageView = itemView.findViewById(R.id.network_picker_entry_usage);
contextButton = itemView.findViewById(R.id.network_picker_entry_context_button);
contextButtonSpace = itemView.findViewById(R.id.network_picker_entry_context_button_space);
}

View file

@ -27,7 +27,7 @@ public class SeparatorViewHolder extends RecyclerView.ViewHolder {
public SeparatorViewHolder(final View itemView) {
super(itemView);
textView = ((TextView) itemView.findViewById(android.R.id.text1));
textView = itemView.findViewById(android.R.id.text1);
}
public void bind(final NetworkListEntry.Separator entry) {

View file

@ -138,10 +138,10 @@ public class PlanActivity extends Activity {
final Animation zoomControlsAnimation = AnimationUtils.loadAnimation(this, R.anim.zoom_controls);
zoomControlsAnimation.setFillAfter(true); // workaround: set through code because XML does not work
viewAnimator = (ViewAnimator) findViewById(R.id.plans_layout);
viewAnimator = findViewById(R.id.plans_layout);
viewAnimator.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
plan = (ScrollImageView) findViewById(R.id.plans_plan);
plan = findViewById(R.id.plans_plan);
plan.setOnMoveListener(() -> {
updateBubble();
updateScale();
@ -167,11 +167,11 @@ public class PlanActivity extends Activity {
contextMenu.show();
});
bubbleName = (TextView) findViewById(R.id.plans_bubble_name);
bubbleName = findViewById(R.id.plans_bubble_name);
bubbleLinesView = (LineView) findViewById(R.id.plans_bubble_lines);
bubbleLinesView = findViewById(R.id.plans_bubble_lines);
zoom = (ZoomControls) findViewById(R.id.plans_zoom);
zoom = findViewById(R.id.plans_zoom);
zoom.setOnZoomInClickListener(v -> {
plan.animateScaleStepIn();
updateScale();

View file

@ -119,13 +119,13 @@ public class PlansPickerActivity extends OeffiMainActivity implements ActivityCo
cursor = getContentResolver().query(PlanContentProvider.CONTENT_URI, null, null, null, null);
listView = (RecyclerView) findViewById(android.R.id.list);
listView = findViewById(android.R.id.list);
listView.setLayoutManager(new LinearLayoutManager(this));
listView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
listAdapter = new PlansAdapter(this, cursor, thumbCache, this, this, application.okHttpClient());
listView.setAdapter(listAdapter);
connectivityWarningView = (TextView) findViewById(R.id.plans_picker_connectivity_warning_box);
connectivityWarningView = findViewById(R.id.plans_picker_connectivity_warning_box);
filterBox = findViewById(R.id.plans_picker_filter_box);
findViewById(R.id.plans_picker_filter_clear).setOnClickListener(v -> clearListFilter());

View file

@ -59,14 +59,14 @@ public class PlanViewHolder extends RecyclerView.ViewHolder {
this.context = context;
this.dateFormat = DateFormat.getDateFormat(context);
thumbView = (ImageView) itemView.findViewById(R.id.plans_picker_entry_thumb);
nameView = (TextView) itemView.findViewById(R.id.plans_picker_entry_name);
disclaimerView = (TextView) itemView.findViewById(R.id.plans_picker_entry_disclaimer);
loadedView = (ImageView) itemView.findViewById(R.id.plans_picker_entry_loaded);
progressView = (ProgressBar) itemView.findViewById(R.id.plans_picker_entry_progress);
validFromView = (TextView) itemView.findViewById(R.id.plans_picker_entry_valid_from);
networkLogoView = (ImageView) itemView.findViewById(R.id.plans_picker_entry_network_logo);
contextButton = (ImageButton) itemView.findViewById(R.id.plans_picker_entry_context_button);
thumbView = itemView.findViewById(R.id.plans_picker_entry_thumb);
nameView = itemView.findViewById(R.id.plans_picker_entry_name);
disclaimerView = itemView.findViewById(R.id.plans_picker_entry_disclaimer);
loadedView = itemView.findViewById(R.id.plans_picker_entry_loaded);
progressView = itemView.findViewById(R.id.plans_picker_entry_progress);
validFromView = itemView.findViewById(R.id.plans_picker_entry_valid_from);
networkLogoView = itemView.findViewById(R.id.plans_picker_entry_network_logo);
contextButton = itemView.findViewById(R.id.plans_picker_entry_context_button);
}
public void bind(final PlansAdapter.Plan plan, final PlanClickListener clickListener,

View file

@ -79,9 +79,9 @@ public class FavoriteStationsActivity extends OeffiActivity
actionBar.setPrimaryTitle(getTitle());
actionBar.setBack(v -> finish());
viewAnimator = (ViewAnimator) findViewById(R.id.favorites_layout);
viewAnimator = findViewById(R.id.favorites_layout);
listView = (RecyclerView) findViewById(R.id.favorites_list);
listView = findViewById(R.id.favorites_list);
listView.setLayoutManager(new LinearLayoutManager(this));
listView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
adapter = new FavoriteStationsAdapter(this, network, this, network == null ? this : null);

View file

@ -85,8 +85,8 @@ public class StationContextMenu extends PopupMenu {
builder.setTitle(R.string.station_context_launcher_shortcut_title);
builder.setView(view);
builder.setPositiveButton(R.string.create_launcher_shortcut_dialog_button_ok,
(DialogInterface.OnClickListener) (dialog, which) -> {
final EditText nameView = (EditText) view
(dialog, which) -> {
final EditText nameView = view
.findViewById(R.id.create_launcher_shortcut_dialog_name);
final String shortcutName = nameView.getText().toString();
final String shortcutId = "directions-to-" + networkId.name() + "-" + location.id;

View file

@ -167,20 +167,20 @@ public class StationDetailsActivity extends OeffiActivity implements StationsAwa
}
});
viewAnimator = (ViewAnimator) findViewById(R.id.stations_station_details_list_layout);
viewAnimator = findViewById(R.id.stations_station_details_list_layout);
listView = (RecyclerView) findViewById(R.id.stations_station_details_list);
listView = findViewById(R.id.stations_station_details_list);
listView.setLayoutManager(new LinearLayoutManager(this));
listView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
listAdapter = new DeparturesAdapter(this);
listView.setAdapter(listAdapter);
mapView = (OeffiMapView) findViewById(R.id.stations_station_details_map);
mapView = findViewById(R.id.stations_station_details_map);
mapView.setStationsAware(this);
((TextView) findViewById(R.id.stations_station_details_map_disclaimer))
.setText(mapView.getTileProvider().getTileSource().getCopyrightNotice());
resultStatusView = (TextView) findViewById(R.id.stations_station_details_result_status);
resultStatusView = findViewById(R.id.stations_station_details_result_status);
final Intent intent = getIntent();
final Uri uri = intent.getData();
@ -267,7 +267,7 @@ public class StationDetailsActivity extends OeffiActivity implements StationsAwa
favoriteButton
.setChecked(selectedFavState != null && selectedFavState == FavoriteStationsProvider.TYPE_FAVORITE);
disclaimerSourceView = (TextView) findViewById(R.id.stations_station_details_disclaimer_source);
disclaimerSourceView = findViewById(R.id.stations_station_details_disclaimer_source);
updateDisclaimerSource(disclaimerSourceView, selectedNetwork.name(), null);
}
@ -550,9 +550,9 @@ public class StationDetailsActivity extends OeffiActivity implements StationsAwa
public HeaderViewHolder(final Context context, final View itemView) {
super(itemView);
idView = (TextView) itemView.findViewById(R.id.stations_station_details_header_id);
linesGroup = (LinearLayout) itemView.findViewById(R.id.stations_station_details_header_lines);
additionalLinesView = (LineView) itemView
idView = itemView.findViewById(R.id.stations_station_details_header_id);
linesGroup = itemView.findViewById(R.id.stations_station_details_header_lines);
additionalLinesView = itemView
.findViewById(R.id.stations_station_details_header_additional_lines);
inflater = LayoutInflater.from(context);
@ -577,11 +577,11 @@ public class StationDetailsActivity extends OeffiActivity implements StationsAwa
final View lineRow = inflater.inflate(R.layout.stations_station_details_header_line, null);
linesGroup.addView(lineRow, LINES_LAYOUT_PARAMS);
final LineView lineView = (LineView) lineRow
final LineView lineView = lineRow
.findViewById(R.id.stations_station_details_header_line_line);
lineView.setLine(line);
final TextView destinationView = (TextView) lineRow
final TextView destinationView = lineRow
.findViewById(R.id.stations_station_details_header_line_destination);
final StringBuilder text = new StringBuilder();
for (final Location destination : destinations) {
@ -618,15 +618,15 @@ public class StationDetailsActivity extends OeffiActivity implements StationsAwa
public DepartureViewHolder(final Context context, final View itemView) {
super(itemView);
timeRelView = (TextView) itemView.findViewById(R.id.stations_station_entry_time_rel);
timeAbsView = (TextView) itemView.findViewById(R.id.stations_station_entry_time_abs);
delayView = (TextView) itemView.findViewById(R.id.stations_station_entry_delay);
lineView = (LineView) itemView.findViewById(R.id.stations_station_entry_line);
destinationView = (TextView) itemView.findViewById(R.id.stations_station_entry_destination);
positionView = (TextView) itemView.findViewById(R.id.stations_station_entry_position);
capacity1stView = (TextView) itemView.findViewById(R.id.stations_station_entry_capacity_1st_class);
capacity2ndView = (TextView) itemView.findViewById(R.id.stations_station_entry_capacity_2nd_class);
msgView = (TextView) itemView.findViewById(R.id.stations_station_entry_msg);
timeRelView = itemView.findViewById(R.id.stations_station_entry_time_rel);
timeAbsView = itemView.findViewById(R.id.stations_station_entry_time_abs);
delayView = itemView.findViewById(R.id.stations_station_entry_delay);
lineView = itemView.findViewById(R.id.stations_station_entry_line);
destinationView = itemView.findViewById(R.id.stations_station_entry_destination);
positionView = itemView.findViewById(R.id.stations_station_entry_position);
capacity1stView = itemView.findViewById(R.id.stations_station_entry_capacity_1st_class);
capacity2ndView = itemView.findViewById(R.id.stations_station_entry_capacity_2nd_class);
msgView = itemView.findViewById(R.id.stations_station_entry_msg);
this.context = context;
this.timeFormat = DateFormat.getTimeFormat(context);
@ -673,7 +673,7 @@ public class StationDetailsActivity extends OeffiActivity implements StationsAwa
final Location destination = departure.destination;
if (destination != null) {
destinationView.setText(Constants.DESTINATION_ARROW_PREFIX + destination.uniqueShortName());
itemView.setOnClickListener(destination.id != null ? (OnClickListener) v -> start(context, network, destination) : null);
itemView.setOnClickListener(destination.id != null ? v -> start(context, network, destination) : null);
} else {
destinationView.setText(null);
itemView.setOnClickListener(null);

View file

@ -242,33 +242,33 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
initNavigation();
locationProvidersView = (ViewGroup) findViewById(R.id.stations_list_location_providers);
locationProvidersView = findViewById(R.id.stations_list_location_providers);
final Button locationPermissionRequestButton = (Button) findViewById(
final Button locationPermissionRequestButton = findViewById(
R.id.stations_location_permission_request_button);
locationPermissionRequestButton.setOnClickListener(v -> ActivityCompat.requestPermissions(StationsActivity.this,
new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, 0));
final Button locationSettingsButton = (Button) findViewById(R.id.stations_list_location_settings);
final Button locationSettingsButton = findViewById(R.id.stations_list_location_settings);
locationSettingsButton.setOnClickListener(v -> startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)));
final OnClickListener selectNetworkListener = v -> NetworkPickerActivity.start(StationsActivity.this);
final Button networkSettingsButton = (Button) findViewById(R.id.stations_list_empty_network_settings);
final Button networkSettingsButton = findViewById(R.id.stations_list_empty_network_settings);
networkSettingsButton.setOnClickListener(selectNetworkListener);
final Button missingCapabilityButton = (Button) findViewById(R.id.stations_network_missing_capability_button);
final Button missingCapabilityButton = findViewById(R.id.stations_network_missing_capability_button);
missingCapabilityButton.setOnClickListener(selectNetworkListener);
mapView = (OeffiMapView) findViewById(R.id.stations_map);
mapView = findViewById(R.id.stations_map);
mapView.setStationsAware(this);
mapView.setLocationAware(this);
((TextView) findViewById(R.id.stations_map_disclaimer))
.setText(mapView.getTileProvider().getTileSource().getCopyrightNotice());
final ZoomControls zoom = (ZoomControls) findViewById(R.id.stations_map_zoom);
final ZoomControls zoom = findViewById(R.id.stations_map_zoom);
mapView.setZoomControls(zoom);
connectivityWarningView = (TextView) findViewById(R.id.stations_connectivity_warning_box);
disclaimerSourceView = (TextView) findViewById(R.id.stations_disclaimer_source);
connectivityWarningView = findViewById(R.id.stations_connectivity_warning_box);
disclaimerSourceView = findViewById(R.id.stations_disclaimer_source);
// initialize stations list
maxDeparturesPerStation = res.getInteger(R.integer.max_departures_per_station);
@ -394,7 +394,7 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
throw new IllegalStateException();
}
});
stationList = (RecyclerView) findViewById(R.id.stations_list);
stationList = findViewById(R.id.stations_list);
stationListLayoutManager = new LinearLayoutManager(this);
stationList.setLayoutManager(stationListLayoutManager);
stationList.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
@ -640,7 +640,7 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
final boolean isActive = products.size() < Product.values().length;
filterActionButton.setSelected(isActive);
final ViewAnimator viewAnimator = (ViewAnimator) findViewById(R.id.stations_list_layout);
final ViewAnimator viewAnimator = findViewById(R.id.stations_list_layout);
if (network == null || !NetworkProviderFactory.provider(network).hasCapabilities(Capability.DEPARTURES)) {
viewAnimator.setDisplayedChild(1); // Missing capability
} else if (searchQuery == null && ContextCompat.checkSelfPermission(this,
@ -1279,9 +1279,9 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
final boolean enabled = locationManager.isProviderEnabled(provider);
final boolean acquiring = provider.equals(accurateLocationProvider)
|| provider.equals(lowPowerLocationProvider);
final View row = (View) getLayoutInflater().inflate(R.layout.stations_location_provider_row, null);
final View row = getLayoutInflater().inflate(R.layout.stations_location_provider_row, null);
((TextView) row.findViewById(R.id.stations_location_provider_row_provider)).setText(provider + ":");
final TextView enabledView = (TextView) row.findViewById(R.id.stations_location_provider_row_enabled);
final TextView enabledView = row.findViewById(R.id.stations_location_provider_row_enabled);
enabledView.setText(enabled
? (acquiring ? R.string.stations_location_provider_acquiring
: R.string.stations_location_provider_enabled)

View file

@ -53,7 +53,7 @@ public class StationsFilterPopup extends PopupWindow
final View contentView = getContentView();
for (final Product product : Product.ALL) {
final CheckBox checkBox = (CheckBox) contentView.findViewWithTag(Character.toString(product.code));
final CheckBox checkBox = contentView.findViewWithTag(Character.toString(product.code));
checkBox.setChecked(filter.contains(product));
checkBox.setOnCheckedChangeListener(this);
checkBox.setOnLongClickListener(this);
@ -73,7 +73,7 @@ public class StationsFilterPopup extends PopupWindow
final Product product = Product.fromCode(((String) v.getTag()).charAt(0));
final View contentView = getContentView();
for (final Product p : Product.ALL) {
final CheckBox checkBox = (CheckBox) contentView.findViewWithTag(Character.toString(p.code));
final CheckBox checkBox = contentView.findViewWithTag(Character.toString(p.code));
checkBox.setChecked(p != product); // Implicit notify
}
return true;

View file

@ -50,10 +50,10 @@ public class FavoriteStationViewHolder extends RecyclerView.ViewHolder {
this.clickListener = clickListener;
this.contextMenuItemListener = contextMenuItemListener;
networkView = (TextView) itemView.findViewById(R.id.favorites_list_entry_network);
placeView = (TextView) itemView.findViewById(R.id.favorites_list_entry_place);
nameView = (TextView) itemView.findViewById(R.id.favorites_list_entry_name);
contextButton = (ImageButton) itemView.findViewById(R.id.favorites_list_entry_context_button);
networkView = itemView.findViewById(R.id.favorites_list_entry_network);
placeView = itemView.findViewById(R.id.favorites_list_entry_place);
nameView = itemView.findViewById(R.id.favorites_list_entry_name);
contextButton = itemView.findViewById(R.id.favorites_list_entry_context_button);
}
public void bind(final long rowId, final NetworkId network, final Location station, final boolean showNetwork,

View file

@ -94,16 +94,16 @@ public class StationViewHolder extends RecyclerView.ViewHolder {
super(itemView);
favoriteView = itemView.findViewById(R.id.station_entry_favorite);
nameView = (TextView) itemView.findViewById(R.id.station_entry_name);
name2View = (TextView) itemView.findViewById(R.id.station_entry_name2);
linesView = (LineView) itemView.findViewById(R.id.station_entry_lines);
distanceView = (TextView) itemView.findViewById(R.id.station_entry_distance);
bearingView = (CompassNeedleView) itemView.findViewById(R.id.station_entry_bearing);
contextButton = (ImageButton) itemView.findViewById(R.id.station_entry_context_button);
nameView = itemView.findViewById(R.id.station_entry_name);
name2View = itemView.findViewById(R.id.station_entry_name2);
linesView = itemView.findViewById(R.id.station_entry_lines);
distanceView = itemView.findViewById(R.id.station_entry_distance);
bearingView = itemView.findViewById(R.id.station_entry_bearing);
contextButton = itemView.findViewById(R.id.station_entry_context_button);
contextButtonSpace = itemView.findViewById(R.id.station_entry_context_button_space);
departuresViewGroup = (ViewGroup) itemView.findViewById(R.id.station_entry_departures);
departuresStatusView = (TextView) itemView.findViewById(R.id.station_entry_status);
messagesViewGroup = (ViewGroup) itemView.findViewById(R.id.station_entry_messages);
departuresViewGroup = itemView.findViewById(R.id.station_entry_departures);
departuresStatusView = itemView.findViewById(R.id.station_entry_status);
messagesViewGroup = itemView.findViewById(R.id.station_entry_messages);
this.context = context;
this.res = context.getResources();
@ -188,7 +188,7 @@ public class StationViewHolder extends RecyclerView.ViewHolder {
// context button
contextButton.setVisibility(itemView.isActivated() ? View.VISIBLE : View.GONE);
contextButtonSpace.setVisibility(itemView.isActivated() ? View.VISIBLE : View.GONE);
contextButton.setOnClickListener(itemView.isActivated() ? (View.OnClickListener) v -> {
contextButton.setOnClickListener(itemView.isActivated() ? v -> {
final PopupMenu contextMenu = new StationContextMenu(context, v, station.network, station.location,
favState, true, true, true, true, true);
contextMenu.setOnMenuItemClickListener(item -> {
@ -240,15 +240,15 @@ public class StationViewHolder extends RecyclerView.ViewHolder {
departureView = (ViewGroup) inflater.inflate(R.layout.stations_station_entry_departure,
departuresViewGroup, false);
departureViewHolder = new DepartureViewHolder();
departureViewHolder.line = (LineView) departureView
departureViewHolder.line = departureView
.findViewById(R.id.departure_entry_line);
departureViewHolder.destination = (TextView) departureView
departureViewHolder.destination = departureView
.findViewById(R.id.departure_entry_destination);
departureViewHolder.messageIndex = departureView
.findViewById(R.id.departure_entry_message_index);
departureViewHolder.time = (TextView) departureView
departureViewHolder.time = departureView
.findViewById(R.id.departure_entry_time);
departureViewHolder.delay = (TextView) departureView
departureViewHolder.delay = departureView
.findViewById(R.id.departure_entry_delay);
departureView.setTag(departureViewHolder);

View file

@ -102,9 +102,9 @@ public class NavigationMenuAdapter extends RecyclerView.Adapter<NavigationMenuAd
public ViewHolder(final View itemView, final MenuItem.OnMenuItemClickListener menuClickListener) {
super(itemView);
iconView = (ImageView) itemView.findViewById(R.id.navigation_drawer_entry_icon);
titleView = (TextView) itemView.findViewById(R.id.navigation_drawer_entry_title);
commentView = (TextView) itemView.findViewById(R.id.navigation_drawer_entry_comment);
iconView = itemView.findViewById(R.id.navigation_drawer_entry_icon);
titleView = itemView.findViewById(R.id.navigation_drawer_entry_title);
commentView = itemView.findViewById(R.id.navigation_drawer_entry_comment);
this.menuClickListener = menuClickListener;
}

View file

@ -57,7 +57,7 @@ public class Toast {
private void customToast(final int imageResId, final CharSequence text, final int duration) {
final android.widget.Toast toast = android.widget.Toast.makeText(context, text, duration);
final TextView toastText = (TextView) toast.getView().findViewById(android.R.id.message);
final TextView toastText = toast.getView().findViewById(android.R.id.message);
if (imageResId != 0 && toastText != null) {
toastText.setCompoundDrawablesWithIntrinsicBounds(imageResId, 0, 0, 0);
toastText.setCompoundDrawablePadding(

View file

@ -43,8 +43,8 @@ public class ZoomControls extends LinearLayout {
final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.zoom_controls, this, true);
mZoomIn = (ZoomButton) findViewById(R.id.zoomIn);
mZoomOut = (ZoomButton) findViewById(R.id.zoomOut);
mZoomIn = findViewById(R.id.zoomIn);
mZoomOut = findViewById(R.id.zoomOut);
setZoomSpeed(250);
}