parent
ecd43382c4
commit
410ae040c1
@ -0,0 +1,36 @@ |
|||||||
|
package com.example.open_nsfw_android |
||||||
|
|
||||||
|
import android.annotation.SuppressLint |
||||||
|
import android.support.v4.content.ContextCompat |
||||||
|
import android.widget.ImageView |
||||||
|
import android.widget.RelativeLayout |
||||||
|
import android.widget.TextView |
||||||
|
import com.chad.library.adapter.base.BaseQuickAdapter |
||||||
|
import com.chad.library.adapter.base.BaseViewHolder |
||||||
|
|
||||||
|
class MainAdapter(val nsfwList: List<MyNsfwBean>?) : |
||||||
|
BaseQuickAdapter<MyNsfwBean, BaseViewHolder>(R.layout.main_item, nsfwList) { |
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n") |
||||||
|
override fun convert(helper: BaseViewHolder, item: MyNsfwBean) { |
||||||
|
val textView = helper.getView<TextView>(R.id.tv_text) |
||||||
|
val imageView = helper.getView<ImageView>(R.id.iv) |
||||||
|
val view = helper.getView<RelativeLayout>(R.id.view) |
||||||
|
var nsfwStr = "色情图片" |
||||||
|
var color = ContextCompat.getColor(mContext,R.color.nsfw1) |
||||||
|
when (item.nsfw) { |
||||||
|
in 0.0..0.3 -> { |
||||||
|
nsfwStr = "正常图片" |
||||||
|
color = ContextCompat.getColor(mContext,R.color.nsfw3) |
||||||
|
} |
||||||
|
in 0.3..0.7 -> { |
||||||
|
nsfwStr = "👙比基尼" |
||||||
|
color = ContextCompat.getColor(mContext,R.color.nsfw2) |
||||||
|
} |
||||||
|
} |
||||||
|
textView.text = |
||||||
|
"path = ${"img/${item.path}"} \n\nSFW score: ${item.sfw}\nNSFW score: ${item.nsfw} \n\n 鉴定结果: ${nsfwStr}" |
||||||
|
imageView.setImageBitmap(item.bitmap) |
||||||
|
view.setBackgroundColor(color) |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
package com.example.open_nsfw_android |
||||||
|
|
||||||
|
import android.graphics.Bitmap |
||||||
|
import com.zwy.nsfw.api.NsfwBean |
||||||
|
|
||||||
|
data class MyNsfwBean(var sfw: Float,var nsfw: Float, val path: String,val bitmap:Bitmap) { |
||||||
|
|
||||||
|
} |
@ -1,27 +1,49 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
xmlns:tools="http://schemas.android.com/tools" |
xmlns:tools="http://schemas.android.com/tools" |
||||||
android:gravity="center" |
android:orientation="vertical" |
||||||
android:layout_width="match_parent" |
android:layout_width="match_parent" |
||||||
android:layout_height="match_parent"> |
android:layout_height="match_parent"> |
||||||
<ImageView android:layout_width="match_parent" |
|
||||||
|
|
||||||
android:id="@+id/iv" android:layout_height="300dp"/> |
|
||||||
<Button android:layout_width="wrap_content" |
|
||||||
android:layout_below="@+id/iv" |
|
||||||
android:layout_centerHorizontal="true" |
|
||||||
android:text="点击识别图片" |
|
||||||
android:id="@+id/bt_" |
|
||||||
android:gravity="center" |
|
||||||
android:layout_height="wrap_content"/> |
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" |
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" |
||||||
android:layout_below="@+id/bt_" |
android:textSize="18sp" |
||||||
android:id="@+id/tv_" |
android:id="@+id/tv_start" |
||||||
|
android:gravity="center" |
||||||
|
android:layout_gravity="center" |
||||||
android:padding="20dp" |
android:padding="20dp" |
||||||
android:text="sfw:适宜在公共场所浏览,nsfw:不适宜在公共场所浏览,两者都是0-1中间的浮点型值,nsfw数值越大表示色情程度越高,sfw反之"/> |
android:text="点击开始识别Assets下的测试图片"/> |
||||||
<TextView |
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" |
||||||
android:id="@+id/tvv" |
android:text="sfw:适宜在公共场所浏览,nsfw:不适宜在公共场所浏览,两者都是0-1中间的浮点型值,nsfw数值越大表示色情程度越高,sfw反之" |
||||||
android:layout_below="@+id/tv_" android:layout_width="match_parent" android:layout_height="match_parent"/> |
android:padding="15dp" |
||||||
|
android:textSize="14sp"/> |
||||||
|
<android.support.v7.widget.RecyclerView |
||||||
|
android:id="@+id/rv" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content"/> |
||||||
|
<!--<ScrollView android:layout_width="match_parent" android:layout_height="match_parent">--> |
||||||
|
<!--<LinearLayout android:layout_width="match_parent"--> |
||||||
|
<!--android:orientation="vertical" android:layout_height="match_parent">--> |
||||||
|
<!--<Button android:layout_width="wrap_content"--> |
||||||
|
<!--android:layout_centerHorizontal="true"--> |
||||||
|
<!--android:text="点击开始识别Assets下的测试图片"--> |
||||||
|
<!--android:layout_gravity="center"--> |
||||||
|
<!--android:id="@+id/bt_"--> |
||||||
|
<!--android:gravity="center"--> |
||||||
|
<!--android:layout_height="wrap_content"/>--> |
||||||
|
<!--<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"--> |
||||||
|
<!--android:layout_below="@+id/bt_"--> |
||||||
|
<!--android:id="@+id/tv_"--> |
||||||
|
<!--android:padding="20dp"--> |
||||||
|
<!--android:text="sfw:适宜在公共场所浏览,nsfw:不适宜在公共场所浏览,两者都是0-1中间的浮点型值,nsfw数值越大表示色情程度越高,sfw反之"/>--> |
||||||
|
<!--<TextView--> |
||||||
|
<!--android:id="@+id/tvv"--> |
||||||
|
<!--android:layout_width="match_parent"--> |
||||||
|
<!--android:padding="20dp"--> |
||||||
|
<!--android:textColor="@color/colorAccent"--> |
||||||
|
<!--android:textSize="16sp"--> |
||||||
|
<!--android:layout_height="match_parent"/>--> |
||||||
|
|
||||||
|
<!--</LinearLayout>--> |
||||||
|
<!--</ScrollView>--> |
||||||
|
|
||||||
|
|
||||||
</RelativeLayout> |
</LinearLayout> |
@ -0,0 +1,18 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:id="@+id/view" |
||||||
|
android:layout_marginTop="5dp" |
||||||
|
android:padding="20dp" |
||||||
|
|
||||||
|
android:layout_height="wrap_content"> |
||||||
|
<TextView android:layout_width="match_parent" |
||||||
|
android:id="@+id/tv_text" |
||||||
|
android:layout_toLeftOf="@+id/iv" |
||||||
|
android:layout_height="wrap_content"/> |
||||||
|
<ImageView android:layout_width="100dp" |
||||||
|
android:layout_height="100dp" |
||||||
|
android:id="@+id/iv" |
||||||
|
android:scaleType="centerCrop" |
||||||
|
android:layout_alignParentRight="true"/> |
||||||
|
</RelativeLayout> |
Loading…
Reference in new issue