Handling configuration changes

> Adding a listener for device profile changes
> Updating various controllers instead of recreating them
> Clearing all-apps icon

Bug: 71709920
Change-Id: Ief7db199eb7494ebd8fb433198f333cd2e8e661d
This commit is contained in:
Sunny Goyal
2018-02-01 14:46:13 -08:00
parent c94cfc052c
commit fde5505d02
9 changed files with 90 additions and 26 deletions

View File

@@ -22,11 +22,16 @@ import android.content.ContextWrapper;
import android.content.Intent;
import android.view.View.AccessibilityDelegate;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.util.SystemUiController;
import java.util.ArrayList;
public abstract class BaseActivity extends Activity {
private final ArrayList<OnDeviceProfileChangeListener> mDPChangeListeners = new ArrayList<>();
protected DeviceProfile mDeviceProfile;
protected UserEventDispatcher mUserEventDispatcher;
protected SystemUiController mSystemUiController;
@@ -87,4 +92,15 @@ public abstract class BaseActivity extends Activity {
public boolean isStarted() {
return mStarted;
}
public void addOnDeviceProfileChangeListener(OnDeviceProfileChangeListener listener) {
mDPChangeListeners.add(listener);
}
protected void dispatchDeviceProfileChanged() {
int count = mDPChangeListeners.size();
for (int i = 0; i < count; i++) {
mDPChangeListeners.get(i).onDeviceProfileChanged(mDeviceProfile);
}
}
}