Add error log for adding parented complications.
Adding a complication view that already has a parent throws an IllegalStateException. This change adds an error log for that case that includes the class of the complication to make it easier to track down. The most likely cause of this is complication view reuse. Complication views should be created anew each time they are needed. Test: manually Bug: 220478774 Change-Id: Icaa070ae3c852e89e7203e4b3ff3ee42bf515ce0
This commit is contained in:
@@ -21,6 +21,7 @@ import static com.android.systemui.dreams.complication.dagger.ComplicationModule
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
@@ -42,6 +43,8 @@ import javax.inject.Named;
|
||||
* a {@link ComplicationLayoutEngine}.
|
||||
*/
|
||||
public class ComplicationHostViewController extends ViewController<ConstraintLayout> {
|
||||
public static final String TAG = "ComplicationHostViewController";
|
||||
|
||||
private final ComplicationLayoutEngine mLayoutEngine;
|
||||
private final LifecycleOwner mLifecycleOwner;
|
||||
private final ComplicationCollectionViewModel mComplicationCollectionViewModel;
|
||||
@@ -113,6 +116,12 @@ public class ComplicationHostViewController extends ViewController<ConstraintLay
|
||||
final Complication.ViewHolder viewHolder = complication.getComplication()
|
||||
.createView(complication);
|
||||
mComplications.put(id, viewHolder);
|
||||
if (viewHolder.getView().getParent() != null) {
|
||||
Log.e(TAG, "View for complication "
|
||||
+ complication.getComplication().getClass()
|
||||
+ " already has a parent. Make sure not to reuse complication "
|
||||
+ "views!");
|
||||
}
|
||||
mLayoutEngine.addComplication(id, viewHolder.getView(),
|
||||
viewHolder.getLayoutParams(), viewHolder.getCategory());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user