Should fix the fab being not moved to the correct position. Close kabouzeid/phonograph-issue-tracker#5

This commit is contained in:
Karim Abou Zeid 2015-09-07 21:56:24 +02:00
commit c3db8284d3
2 changed files with 46 additions and 82 deletions

View file

@ -0,0 +1,26 @@
package com.kabouzeid.gramophone.misc;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.support.design.widget.FloatingActionButton;
import android.util.Property;
import com.kabouzeid.gramophone.util.ColorUtil;
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public class FloatingActionButtonProperties {
public static final Property<FloatingActionButton, Integer> COLOR = new Property<FloatingActionButton, Integer>(Integer.class, "color") {
@Override
public void set(FloatingActionButton object, Integer value) {
object.setBackgroundTintList(ColorStateList.valueOf(value));
object.getDrawable().setColorFilter(ColorUtil.getPrimaryTextColorForBackground(object.getContext(), value), PorterDuff.Mode.SRC_IN);
}
@Override
public Integer get(FloatingActionButton object) {
return object.getBackgroundTintList() != null ? object.getBackgroundTintList().getDefaultColor() : 0;
}
};
}