Skip to content

Commit

Permalink
Implement equals and string for dynamic colors
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavpandey committed Dec 14, 2021
1 parent 96228dc commit d5c1823
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.util.ObjectsCompat;

import com.pranavpandey.android.dynamic.theme.base.DynamicColor;
import com.pranavpandey.android.dynamic.util.DynamicColorUtils;
Expand Down Expand Up @@ -439,4 +440,21 @@ public void clear() {
getDark().clear();
getLight().clear();
}

@Override
public boolean equals(@Nullable Object obj) {
if (!(obj instanceof DynamicColors)) {
return super.equals(obj);
}

DynamicColors newColors = (DynamicColors) obj;
return ObjectsCompat.equals(getOriginal(), newColors.getOriginal())
&& ObjectsCompat.equals(getDark(), newColors.getDark())
&& ObjectsCompat.equals(getLight(), newColors.getLight());
}

@Override
public @NonNull String toString() {
return getOriginal().toString() + getDark().toString() + getLight().toString();
}
}

0 comments on commit d5c1823

Please sign in to comment.