Skip to content

Instantly share code, notes, and snippets.

/*
* Copyright 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@HanCheng
HanCheng / 1 search_bar.xml
Created November 4, 2015 03:32 — forked from nickbutcher/1 search_bar.xml
Demonstrating morphing a search icon into a search field. To do this we use an AnimatedVectorDrawable (https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html) made up of two paths. The first is the search icon (as a single line) the second is the horizontal bar. We then animate the 'trimPathStart' property …
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@HanCheng
HanCheng / gist:6dfdc2982a189ef05b79
Last active August 29, 2015 14:16
purchase_link_provider
"purchase_link_providers": {
"image_base_url": "http://flights.tacdn.com/en_US/1696/img/partners/",
"list": [
{
"id": "Travelocity",
"display_name": "Travelocity",
"is_ota": true,
"logo_url": "app_logos/travelocity.png"
},
{
Slot 1 is for partner merchandising
Slot 2 is for Air Watch when valid. If Air Watch is not valid then show ‘Click to Call’ for US and CA IPs if valid. For all other IPs, show partner merchandising
Slot 3 is for partner merchandising
Slot 4 is for Click to Call if it has not been shown and is valid. If it has been shown, or is not valid, then show Air Watch. Otherwise show partner merchandising
Remaining “n” slots are alternating between merchandising and Air Watch (if valid). Tapping a merchandising unit launches custom web view deep link
@HanCheng
HanCheng / gist:ff8f4957ef3fc57048a4
Last active August 29, 2015 14:14
FLT-2240 Solutions to Urgency messaging- Android
Overview:
Get the cached fare information from API and compare with the lowest price to decide whether to show price going up or down message.
Approaches:
1. Using PopupWindow.class to show urgency message
2. Adding new layout file of the popupWinwod and inflating this layout file
3. Adding new model of LastCachedFare and Fetching values of last_cached_fare from API
4. Using logic to decide to show the urgency message, conditions can be:
a. 24 hours timestamps
b. variables in last_cached_fare != null
1. adding the interface in SearchResultFragmentsPagerAdapter.java called OnFragmentScrollChangedListener() and declare virtual function called onPageMoved(int scrollY, boolean isDragging); (scrollY is horizontal position. )
2. creating the enum type called ScrollState, with UP, Down
3. instaniate that interface named mOnFragmentScrollChangedListener, and override the onTouchEvent() method, and deal with some variables
4. In FLightSearchResultsActivity, implements OnFragmentScrollChangedListener, and override onPageMoved() method,
onPageMoved() {
}
@HanCheng
HanCheng / gist:32e4612a267d1f876dba
Last active August 29, 2015 14:10
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 = ...
@HanCheng
HanCheng / gist:d2663c085a473e6a0f61
Last active August 29, 2015 14:09
changing the filter to remain active if do same search
1. In FlightSearchFormActivity, line FilterActivity.resetFilter() replaced with:
if (mFlightSearch == null || !isSameFlightSearch(mFlightSearch, mFile)) {
FiltersActivity.resetFilters();
}
2. isSameFlightSearch(FlightSearch flightSearch, File file) is defined in Utils file. I was trying to make this method
do less calculation in UI thread, so another way is create an AsyncTask, as we did in SaveFlightSearchTask.java
http://stackoverflow.com/questions/12575068/how-to-get-the-result-of-onpostexecute-to-main-activity-because-asynctask-is-a
public static boolean isSameFlightSearch(FlightSearch flightSearch, File file) {
if (flightSearch.isValid() && file != null) {
@HanCheng
HanCheng / gist:42a27ec8df2c56ea3b0c
Last active August 8, 2018 12:02
cleaning up lint warnings and errors
1. For paddingStart, Severity: Errors.
because we also have paddingLeft, so for old platform, the paddingStart is ignored; so api < 17, the lint tool
will show error about paddingStart, and we do not currently support RTL, and paddingStart work the same way as
paddingLeft, so i think it really about the NewApi. Because the lint tool just check whether paddingStart is
compatible with api < 17, and I check that when api == 16, it works fine and does not crash. I have checked all
the lint error list, i do not find other lint checks might solve this. So I think just add
tools:ignore="NewApi" will be fine.
2. the warnings in build.gradle showing that some of the tools are using the old version, do i need change
these to newest, or just suppress lint to ignore NewerVersionAvailable.
1. created method in FlightSearchResultsActivity called:
private boolean isFilterApplied() {}
private void updateFilterMessage() {
if (isFilterApplied() && mSearchHasCompleted) {
Set<ItineraryFilter> itineraryFilters = ItinerarySet.getInstance().itineraryFilters();
final String sb = getSelectedFiltersString(this, itineraryFilters);
mFilterMessagePanel.setVisibility(VISIBLE);
mFilterMessagePanel.post(new Runnable() {