Remove SimpleImageView

This commit is contained in:
seven332 committed 2016-03-14 22:39:03 +08:00
1 parent 15d4819089
commit 9276244b28
5 files changed
+16 -145

No files matched your search

@@ -39,12 +39,12 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.hippo.ehviewer.R;
import com.hippo.view.ViewTransition;
import com.hippo.widget.SimpleImageView;
import com.hippo.yorozuya.AnimationUtils;
import com.hippo.yorozuya.MathUtils;
import com.hippo.yorozuya.SimpleAnimatorListener;
@@ -75,9 +75,9 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
private int mBaseHeight;
private float mProgress;
private SimpleImageView mMenuButton;
private ImageView mMenuButton;
private TextView mTitleTextView;
private SimpleImageView mActionButton;
private ImageView mActionButton;
private SearchEditText mEditText;
private View mListContainer;
private View mListHeader;
@@ -117,9 +117,9 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
LayoutInflater inflater = LayoutInflater.from(context);
inflater.inflate(R.layout.widget_search_bar, this);
mMenuButton = (SimpleImageView) ViewUtils.$$(this, R.id.search_menu);
mMenuButton = (ImageView) ViewUtils.$$(this, R.id.search_menu);
mTitleTextView = (TextView) ViewUtils.$$(this, R.id.search_title);
mActionButton = (SimpleImageView) ViewUtils.$$(this, R.id.search_action);
mActionButton = (ImageView) ViewUtils.$$(this, R.id.search_action);
mEditText = (SearchEditText) ViewUtils.$$(this, R.id.search_edit_text);
mListContainer = ViewUtils.$$(this, R.id.list_container);
ListView list = (ListView) ViewUtils.$$(mListContainer, R.id.search_bar_list);
@@ -219,11 +219,11 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
}
public void setLeftDrawable(Drawable drawable) {
mMenuButton.setDrawable(drawable);
mMenuButton.setImageDrawable(drawable);
}
public void setRightDrawable(Drawable drawable) {
mActionButton.setDrawable(drawable);
mActionButton.setImageDrawable(drawable);
}
public void setLeftIconVisibility(int visibility) {
@@ -1,127 +0,0 @@
/*
* Copyright (C) 2015 Hippo Seven
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hippo.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.View;
import com.hippo.yorozuya.ViewUtils;
public class SimpleImageView extends View implements Drawable.Callback {
private Drawable mDrawable;
private static final int[] LAYOUT_ATTRS = new int[] {
android.R.attr.src
};
public SimpleImageView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
public SimpleImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs);
}
private void init(Context context, AttributeSet attrs) {
final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
setDrawable(a.getDrawable(0));
a.recycle();
// Mostly drawable is VectorDrawable, it has cache already
setWillNotCacheDrawing(true);
}
@SuppressWarnings("deprecation")
public void setDrawable(@DrawableRes int resId) {
setDrawable(getContext().getResources().getDrawable(resId));
}
public void setDrawable(Drawable drawable) {
if (mDrawable != null) {
mDrawable.setCallback(null);
}
mDrawable = drawable;
if (drawable != null) {
drawable.setCallback(this);
if (drawable.isStateful()) {
drawable.setState(getDrawableState());
}
}
requestLayout();
}
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
Drawable d = mDrawable;
if (d != null && d.isStateful()) {
d.setState(getDrawableState());
}
}
@Override
public void invalidateDrawable(@NonNull Drawable who) {
invalidate();
}
@Override
protected int getSuggestedMinimumWidth() {
int superMinWidth = super.getSuggestedMinimumWidth();
return (mDrawable == null) ? superMinWidth :
Math.max(superMinWidth, mDrawable.getMinimumWidth() + getPaddingLeft() + getPaddingRight());
}
@Override
protected int getSuggestedMinimumHeight() {
int superMinHeight = super.getSuggestedMinimumHeight();
return (mDrawable == null) ? superMinHeight :
Math.max(superMinHeight, mDrawable.getMinimumHeight() + getPaddingTop() + getPaddingBottom());
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(ViewUtils.getSuitableSize(getSuggestedMinimumWidth(), widthMeasureSpec),
ViewUtils.getSuitableSize(getSuggestedMinimumHeight(), heightMeasureSpec));
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
int width = right - left;
int height = bottom - top;
if (mDrawable != null) {
mDrawable.setBounds(getPaddingLeft(), getPaddingTop(),
width - getPaddingRight(), height - getPaddingBottom());
}
}
@Override
protected void onDraw(Canvas canvas) {
if (mDrawable != null) {
mDrawable.draw(canvas);
}
}
}