Skip to content


[M3][Search] Improve performance by preventing item change notificati…
Browse files Browse the repository at this point in the history
…ons during inflation.

PiperOrigin-RevId: 522612855
  • Loading branch information
raajkumars authored and paulfthomas committed Apr 10, 2023
1 parent 0184b5b commit 203d5ec
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/java/com/google/android/material/search/
Expand Up @@ -35,11 +35,13 @@
import android.os.Parcel;
import android.os.Parcelable;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.widget.ActionMenuView;
import androidx.appcompat.widget.Toolbar;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
Expand Down Expand Up @@ -413,8 +415,16 @@ private void setNavigationIconDecorative(boolean decorative) {

public void inflateMenu(@MenuRes int resId) {
// Pause dispatching item changes during inflation to improve performance.
Menu menu = getMenu();
if (menu instanceof MenuBuilder) {
((MenuBuilder) menu).stopDispatchingItemsChanged();
this.menuResId = resId;
if (menu instanceof MenuBuilder) {
((MenuBuilder) menu).startDispatchingItemsChanged();

Expand Down

0 comments on commit 203d5ec

Please sign in to comment.