From 1f05057ddd4164acde04cbccd620102ebcaaa803 Mon Sep 17 00:00:00 2001 From: seven332 Date: Sun, 6 Mar 2016 14:53:44 +0800 Subject: [PATCH] Remove ThumbImageView --- .../hippo/ehviewer/widget/ThumbImageView.java | 60 ------------------- app/src/main/res/layout/item_download.xml | 2 +- app/src/main/res/layout/item_gallery_list.xml | 2 +- 3 files changed, 2 insertions(+), 62 deletions(-) delete mode 100644 app/src/main/java/com/hippo/ehviewer/widget/ThumbImageView.java diff --git a/app/src/main/java/com/hippo/ehviewer/widget/ThumbImageView.java b/app/src/main/java/com/hippo/ehviewer/widget/ThumbImageView.java deleted file mode 100644 index 21e9c3d41..000000000 --- a/app/src/main/java/com/hippo/ehviewer/widget/ThumbImageView.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2016 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.ehviewer.widget; - -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.util.AttributeSet; -import android.widget.ImageView; - -import com.hippo.widget.LoadImageView; - -public class ThumbImageView extends LoadImageView { - - public ThumbImageView(Context context) { - super(context); - } - - public ThumbImageView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public ThumbImageView(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - } - - @Override - public void setImageDrawable(Drawable drawable) { - if (drawable != null) { - int drawableWidth = drawable.getIntrinsicWidth(); - int drawableHeight = drawable.getIntrinsicHeight(); - int width = getWidth(); - int height = getHeight(); - - if (drawableWidth > 0 && drawableHeight > 0 && width > 0 && height > 0) { - float ratio = (float) height / width; - float drawableRatio = (float) drawableHeight / drawableWidth; - if (drawableRatio > ratio - 0.2f && drawableRatio < ratio + 0.2f) { - setScaleType(ImageView.ScaleType.CENTER_CROP); - } else { - setScaleType(ImageView.ScaleType.FIT_CENTER); - } - } - } - super.setImageDrawable(drawable); - } -} diff --git a/app/src/main/res/layout/item_download.xml b/app/src/main/res/layout/item_download.xml index a6e8c0c6a..58720b416 100644 --- a/app/src/main/res/layout/item_download.xml +++ b/app/src/main/res/layout/item_download.xml @@ -22,7 +22,7 @@ android:layout_height="wrap_content" android:background="@drawable/card_background"> - diff --git a/app/src/main/res/layout/item_gallery_list.xml b/app/src/main/res/layout/item_gallery_list.xml index 900f0a3df..e52afce22 100644 --- a/app/src/main/res/layout/item_gallery_list.xml +++ b/app/src/main/res/layout/item_gallery_list.xml @@ -21,7 +21,7 @@ android:layout_height="wrap_content" android:background="@drawable/card_background"> -