diff options
-rw-r--r-- | java/com/android/dialer/app/DialtactsActivity.java | 7 | ||||
-rw-r--r-- | java/com/android/dialer/searchfragment/list/NewSearchFragment.java | 22 |
2 files changed, 29 insertions, 0 deletions
diff --git a/java/com/android/dialer/app/DialtactsActivity.java b/java/com/android/dialer/app/DialtactsActivity.java index 1c9718e40..99a16d931 100644 --- a/java/com/android/dialer/app/DialtactsActivity.java +++ b/java/com/android/dialer/app/DialtactsActivity.java @@ -678,6 +678,7 @@ public class DialtactsActivity extends TransactionSafeActivity mListsFragment.addOnPageChangeListener(this); } else if (fragment instanceof NewSearchFragment) { mNewSearchFragment = (NewSearchFragment) fragment; + updateSearchFragmentPosition(); } if (fragment instanceof SearchFragment) { final SearchFragment searchFragment = (SearchFragment) fragment; @@ -951,6 +952,12 @@ public class DialtactsActivity extends TransactionSafeActivity // available immediately which is required to update position. By forcing an animation, // position will be updated after a delay by when the dialpad height would be available. fragment.updatePosition(true /* animate */); + } else if (mNewSearchFragment != null) { + int animationDuration = getResources().getInteger(R.integer.dialpad_slide_in_duration); + int shadowHeight = getResources().getDrawable(R.drawable.search_shadow).getIntrinsicHeight(); + int start = isDialpadShown() ? mActionBarHeight - shadowHeight : 0; + int end = isDialpadShown() ? 0 : mActionBarHeight - shadowHeight; + mNewSearchFragment.animatePosition(start, end, animationDuration); } } diff --git a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java index d20bb1f8c..566ba77f3 100644 --- a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java +++ b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java @@ -27,10 +27,13 @@ import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.animation.Interpolator; import com.android.contacts.common.extensions.PhoneDirectoryExtenderAccessor; +import com.android.dialer.animation.AnimUtils; import com.android.dialer.common.concurrent.ThreadUtil; import com.android.dialer.searchfragment.cp2.SearchContactsCursorLoader; import com.android.dialer.searchfragment.nearbyplaces.NearbyPlacesCursorLoader; +import com.android.dialer.util.ViewUtil; /** Fragment used for searching contacts. */ public final class NewSearchFragment extends Fragment implements LoaderCallbacks<Cursor> { @@ -49,6 +52,8 @@ public final class NewSearchFragment extends Fragment implements LoaderCallbacks private final Runnable loadNearbyPlacesRunnable = () -> getLoaderManager().restartLoader(NEARBY_PLACES_ID, null, this); + private Runnable updatePositionRunnable; + @Nullable @Override public View onCreateView( @@ -62,6 +67,10 @@ public final class NewSearchFragment extends Fragment implements LoaderCallbacks getLoaderManager().initLoader(CONTACTS_LOADER_ID, null, this); loadNearbyPlacesCursor(); + + if (updatePositionRunnable != null) { + ViewUtil.doOnPreDraw(view, false, updatePositionRunnable); + } return view; } @@ -102,6 +111,19 @@ public final class NewSearchFragment extends Fragment implements LoaderCallbacks } } + public void animatePosition(int start, int end, int duration) { + // Called before the view is ready, prepare a runnable to run in onCreateView + if (getView() == null) { + updatePositionRunnable = () -> animatePosition(start, end, 0); + return; + } + boolean slideUp = start > end; + Interpolator interpolator = slideUp ? AnimUtils.EASE_IN : AnimUtils.EASE_OUT; + getView().setTranslationY(start); + getView().animate().translationY(end).setInterpolator(interpolator).setDuration(duration); + updatePositionRunnable = null; + } + @Override public void onDestroy() { super.onDestroy(); |