Skip to content

Commit

Permalink
fix lint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
REBOOTERS committed Apr 11, 2024
1 parent 4a803e4 commit b00988d
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import com.alibaba.android.arouter.facade.annotation.Route
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.SimpleTarget
import com.bumptech.glide.request.transition.Transition
import com.didichuxing.doraemonkit.util.ScreenUtils
import com.engineer.imitate.R
import com.engineer.imitate.databinding.FragmentFrescoBinding
import com.engineer.imitate.util.ScreenUtils
import com.engineer.imitate.util.dp
import com.facebook.common.executors.CallerThreadExecutor
import com.facebook.common.references.CloseableReference
Expand Down Expand Up @@ -69,17 +69,21 @@ class FrescoFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)

val listener = object : BaseControllerListener<ImageInfo>() {
override fun onFinalImageSet(id: String?, imageInfo: ImageInfo?, animatable: Animatable?) {
override fun onFinalImageSet(
id: String?, imageInfo: ImageInfo?, animatable: Animatable?
) {
super.onFinalImageSet(id, imageInfo, animatable)
imageInfo?.let {
val w1 = it.width
val h1 = it.height
val width = ScreenUtils.getScreenWidth() - 16.dp
val height = ScreenUtils.getScreenHeight()
val width = ScreenUtils.getScreenWidth(context) - 16.dp
val height = ScreenUtils.getScreenHeight(context)
Log.d("Fresco", "onFinalImageSet() called w1=$w1,h1=$h1")
Log.d("Fresco", "onFinalImageSet() called w=$width,h=$height")
Log.d("Fresco", "onFinalImageSet() called ${it.qualityInfo.isOfFullQuality}")
Log.d("Fresco", "onFinalImageSet() called ${it.qualityInfo.isOfGoodEnoughQuality}")
Log.d(
"Fresco", "onFinalImageSet() called ${it.qualityInfo.isOfGoodEnoughQuality}"
)
Log.d("Fresco", "onFinalImageSet() called ${it.extras}")
viewBinding.s0.layoutParams.width = width
// viewBinding.s0.layoutParams.height = h1
Expand Down Expand Up @@ -109,7 +113,8 @@ class FrescoFragment : Fragment() {
viewBinding.s2.hierarchy = hierarchy
viewBinding.s2.setActualImageResource(R.drawable.totoro)

val url = "http://h.hiphotos.baidu.com/image/pic/item/960a304e251f95ca060674a0c7177f3e67095231.jpg"
val url =
"http://h.hiphotos.baidu.com/image/pic/item/960a304e251f95ca060674a0c7177f3e67095231.jpg"


val t = System.currentTimeMillis()
Expand Down Expand Up @@ -188,26 +193,28 @@ class FrescoFragment : Fragment() {
private fun bitmapMagic() {
viewBinding.shimmerLayout.startShimmerAnimation()

c.add(Observable.create(ObservableOnSubscribe<Bitmap> { emitter ->
val bitmap = BitmapFactory.decodeResource(resources, R.drawable.star)
val width = bitmap.width
val height = bitmap.height
val colorArray = Array(width) { IntArray(height) }
for (i in 0 until width) {
for (j in 0 until height) {
c.add(
Observable.create(ObservableOnSubscribe<Bitmap> { emitter ->
val bitmap = BitmapFactory.decodeResource(resources, R.drawable.star)
val width = bitmap.width
val height = bitmap.height
val colorArray = Array(width) { IntArray(height) }
for (i in 0 until width) {
for (j in 0 until height) {
// Log.e("zyq", "i==$i j==$j")
// Log.e("zyq", "live=${emitter.isDisposed}")
if (emitter.isDisposed) {
break
if (emitter.isDisposed) {
break
}
colorArray[i][j] = bitmap.getPixel(i, j)
}
colorArray[i][j] = bitmap.getPixel(i, j)
}
}
Log.e("bitmapMagic", "colorArray==$colorArray")
emitter.onNext(bitmap)
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe({ bitmap ->
setupBitmap(bitmap)
}, { t -> t.printStackTrace() })
Log.e("bitmapMagic", "colorArray==$colorArray")
emitter.onNext(bitmap)
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe({ bitmap ->
setupBitmap(bitmap)
}, { t -> t.printStackTrace() })
)

}
Expand Down
43 changes: 43 additions & 0 deletions imitate/src/main/java/com/engineer/imitate/util/ScreenUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.engineer.imitate.util;

import android.content.Context;
import android.graphics.Point;
import android.view.WindowManager;

public final class ScreenUtils {

private ScreenUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}

/**
* Return the width of screen, in pixel.
*
* @return the width of screen, in pixel
*/
public static int getScreenWidth(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
if (wm == null) {
return -1;
}
Point point = new Point();
wm.getDefaultDisplay().getRealSize(point);
return point.x;
}

/**
* Return the height of screen, in pixel.
*
* @return the height of screen, in pixel
*/
public static int getScreenHeight(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
if (wm == null) {
return -1;
}
Point point = new Point();
wm.getDefaultDisplay().getRealSize(point);
return point.y;
}

}
8 changes: 4 additions & 4 deletions subs/ai/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ android {

// Sanity check if you have trained and downloaded TF Lite model.
preBuild.doFirst {
assert file("./src/main/assets/mnist.tflite").exists() :
"mnist.tflite not found. Make sure you have trained and " +
"downloaded your TensorFlow Lite model to assets/ folder"
assert file("./src/main/assets/mnist.tflite").exists(): "mnist.tflite not found. Make sure you have trained and " + "downloaded your TensorFlow Lite model to assets/ folder"
}

compileOptions {
Expand All @@ -53,6 +51,8 @@ dependencies {

// AndroidDraw Library
implementation 'com.github.divyanshub024:AndroidDraw:v0.1'
implementation 'org.tensorflow:tensorflow-lite:2.15.0'
implementation('org.tensorflow:tensorflow-lite:2.15.0') {
exclude group: "com.google.inject", module: "guice"
}
implementation 'com.google.android.gms:play-services-tasks:18.1.0'
}

0 comments on commit b00988d

Please sign in to comment.