Skip to content

Instantly share code, notes, and snippets.

@HanCheng
Last active August 29, 2015 14:10
Show Gist options
  • Save HanCheng/32e4612a267d1f876dba to your computer and use it in GitHub Desktop.
Save HanCheng/32e4612a267d1f876dba to your computer and use it in GitHub Desktop.
Update for the filter message
1. So in order to save a copy of flightSearch in memory, one way to do that is create a copy constructor in FlightSearch.java, just copy all the private member variable, like:
public FlightSearch(FlightSearch flightSearch) {
this.mOriginAirport = flightSearch.getOriginAirport();
this.mDestinationAirport = flightSearch.getDestinationAirport();
this.mFlightSearchMode = flightSearch.getFlightSearchMode();
this.mBookingClass = ....
this.mPrefersNonStop = ...
this.mOutboundDate = ..
this.mReturnDate = ..
this.mNumberOfTravelers = ...
this.segments = ..
}
public FlightSearch() {}
2. So in FlightSearchFormResult.java, in method updateFlightSearchButton()
add:
if (!mOldFlightSearch.isValid() || mOldFlightSearch.equals(mFlightSearch)) {
mOldFlightSearch = new FlightSearch(mFlightSearch);
}
so we can update the old value by copying the value.
3. Then we can use oldFlightSearch.equals(newFlightSearch) to decide to reset filter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment