forked from devzwy/open_nsfw_android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
156 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
app/src/main/java/com/example/open_nsfw_android/MainAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/example/open_nsfw_android/MyNsfwBean.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,49 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:gravity="center" | ||
android:layout_width="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"/> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:orientation="vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" | ||
android:layout_below="@+id/bt_" | ||
android:id="@+id/tv_" | ||
android:textSize="18sp" | ||
android:id="@+id/tv_start" | ||
android:gravity="center" | ||
android:layout_gravity="center" | ||
android:padding="20dp" | ||
android:text="sfw:适宜在公共场所浏览,nsfw:不适宜在公共场所浏览,两者都是0-1中间的浮点型值,nsfw数值越大表示色情程度越高,sfw反之"/> | ||
<TextView | ||
android:id="@+id/tvv" | ||
android:layout_below="@+id/tv_" android:layout_width="match_parent" android:layout_height="match_parent"/> | ||
android:text="点击开始识别Assets下的测试图片"/> | ||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" | ||
android:text="sfw:适宜在公共场所浏览,nsfw:不适宜在公共场所浏览,两者都是0-1中间的浮点型值,nsfw数值越大表示色情程度越高,sfw反之" | ||
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters