Update
This commit is contained in:
1 parent
1d40c9d873
commit
1488163e8f
13 files changed
+64
-44
No files matched your search
@@ -43,7 +43,6 @@ import com.hippo.util.UiUtils;
|
||||
import com.hippo.util.ViewUtils;
|
||||
import com.hippo.widget.FloatLabelEditText;
|
||||
import com.hippo.widget.FloatingActionButton;
|
||||
import com.hippo.widget.PrefixEditText;
|
||||
import com.hippo.widget.recyclerview.EasyRecyclerView;
|
||||
|
||||
public class SearchLayout extends FrameLayout implements CompoundButton.OnCheckedChangeListener,
|
||||
@@ -85,7 +84,7 @@ public class SearchLayout extends FrameLayout implements CompoundButton.OnChecke
|
||||
private View mNormalView;
|
||||
private CategoryTable mTableCategory;
|
||||
private CheckBox mCheckSpecifyAuthor;
|
||||
private PrefixEditText mTextSearch;
|
||||
private FloatLabelEditText mTextSearch;
|
||||
private SwitchCompat mSwitchEnableAdvance;
|
||||
|
||||
private View mAdvanceView;
|
||||
@@ -391,7 +390,7 @@ public class SearchLayout extends FrameLayout implements CompoundButton.OnChecke
|
||||
mNormalView = holder.content.getChildAt(0);
|
||||
mTableCategory = (CategoryTable) mNormalView.findViewById(R.id.search_category_table);
|
||||
mCheckSpecifyAuthor = (CheckBox) mNormalView.findViewById(R.id.search_specify_author);
|
||||
mTextSearch = (PrefixEditText) mNormalView.findViewById(R.id.search_text);
|
||||
mTextSearch = (FloatLabelEditText) mNormalView.findViewById(R.id.search_text);
|
||||
mSwitchEnableAdvance = (SwitchCompat) mNormalView.findViewById(R.id.search_enable_advance);
|
||||
|
||||
// Restore state
|
||||
|
||||
@@ -78,7 +78,7 @@ public class FixedAspectImageView extends ImageView {
|
||||
|
||||
a = context.obtainStyledAttributes(
|
||||
attrs, R.styleable.FixedAspectImageView, defStyle, 0);
|
||||
setAspect(a.getFloat(R.styleable.FixedAspectImageView_faiAspect, -1f));
|
||||
setAspect(a.getFloat(R.styleable.FixedAspectImageView_aspect, -1f));
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class FixedAspectLayout extends FrameLayout {
|
||||
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
TypedArray a = context.obtainStyledAttributes(
|
||||
attrs, R.styleable.FixedAspectLayout, defStyleAttr, defStyleRes);
|
||||
setAspect(a.getFloat(R.styleable.FixedAspectLayout_falAspect, -1f));
|
||||
setAspect(a.getFloat(R.styleable.FixedAspectLayout_aspect, -1f));
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -54,7 +53,7 @@ public class FloatLabelEditText extends FrameLayout {
|
||||
};
|
||||
|
||||
private TextView mLabel;
|
||||
private EditText mEditText;
|
||||
private PrefixEditText mEditText;
|
||||
|
||||
private Trigger mTrigger = Trigger.TEXT;
|
||||
|
||||
@@ -78,35 +77,39 @@ public class FloatLabelEditText extends FrameLayout {
|
||||
|
||||
private void init(Context context, AttributeSet attrs) {
|
||||
mLabel = new TextView(context);
|
||||
mLabel.setVisibility(View.INVISIBLE);
|
||||
|
||||
final TypedArray a = context
|
||||
.obtainStyledAttributes(attrs, R.styleable.FloatLabelEditText);
|
||||
mLabel.setTextAppearance(context,
|
||||
a.getResourceId(R.styleable.FloatLabelEditText_fllLabelAppearance,
|
||||
android.R.style.TextAppearance_Small));
|
||||
final int index = a.getInt(R.styleable.FloatLabelEditText_fllTrigger, -1);
|
||||
if (index >= 0) {
|
||||
setTrigger(sTriggerArray[index]);
|
||||
}
|
||||
a.recycle();
|
||||
addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
|
||||
EditText attrCollector = new EditText(context, attrs);
|
||||
mEditText = (EditText) LayoutInflater.from(getContext()).inflate(
|
||||
PrefixEditText attrCollector = new PrefixEditText(context, attrs);
|
||||
mEditText = (PrefixEditText) LayoutInflater.from(getContext()).inflate(
|
||||
R.layout.widget_float_label_edit_text, this, false);
|
||||
|
||||
// Collect attr
|
||||
mHint = attrCollector.getHint();
|
||||
mEditText.setInputType(attrCollector.getInputType());
|
||||
|
||||
final LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
lp.gravity = Gravity.BOTTOM;
|
||||
lp.topMargin = (int) mLabel.getTextSize();
|
||||
addView(mEditText, lp);
|
||||
|
||||
// Collect attr
|
||||
mHint = attrCollector.getHint();
|
||||
mEditText.setInputType(attrCollector.getInputType());
|
||||
|
||||
final TypedArray a = context
|
||||
.obtainStyledAttributes(attrs, R.styleable.FloatLabelEditText);
|
||||
mLabel.setTextAppearance(context,
|
||||
a.getResourceId(R.styleable.FloatLabelEditText_labelAppearance,
|
||||
android.R.style.TextAppearance_Small));
|
||||
CharSequence labelHint = a.getText(R.styleable.FloatLabelEditText_labelHint);
|
||||
if (labelHint == null) {
|
||||
labelHint = mHint;
|
||||
}
|
||||
mLabel.setText(labelHint);
|
||||
final int index = a.getInt(R.styleable.FloatLabelEditText_trigger, -1);
|
||||
if (index >= 0) {
|
||||
setTrigger(sTriggerArray[index]);
|
||||
}
|
||||
a.recycle();
|
||||
|
||||
mLabel.setVisibility(View.INVISIBLE);
|
||||
|
||||
mEditText.setHint(mHint);
|
||||
mLabel.setText(mHint);
|
||||
|
||||
// Add a TextWatcher so that we know when the text input has changed
|
||||
mEditText.addTextChangedListener(mTextWatcher);
|
||||
@@ -183,6 +186,14 @@ public class FloatLabelEditText extends FrameLayout {
|
||||
return mEditText.getText();
|
||||
}
|
||||
|
||||
public void setPrefix(int resId) {
|
||||
mEditText.setPrefix(resId);
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
mEditText.setPrefix(prefix);
|
||||
}
|
||||
|
||||
private TextWatcher mTextWatcher = new TextWatcher() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -60,8 +60,8 @@ public class FloatingActionButton extends View {
|
||||
TypedArray a;
|
||||
|
||||
a = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, defStyleRes);
|
||||
int bgColor = a.getColor(R.styleable.FloatingActionButton_fabColor, Color.BLACK);
|
||||
mDrawable = a.getDrawable(R.styleable.FloatingActionButton_fabDrawable);
|
||||
int bgColor = a.getColor(R.styleable.FloatingActionButton_color, Color.BLACK);
|
||||
mDrawable = a.getDrawable(R.styleable.FloatingActionButton_drawable);
|
||||
a.recycle();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
|
||||
Reference in new issue
Block a user