0

I have two packages with one that is the primary package with the MainActivity. The other package gets imported into the MainActivity. The other package deals with drawing on a canvas. However, any changes that I am making to the imported package are not showing up on the actual app. For example, when i change the size of the rectangle being drawn, nothing is actually changing. Does anyone know why this is?

Sorry if this is a trivial question, I just started learning android dev. Also, I got the code off of github, and i'm trying to learn from it. If there is any information that I left out that is crucial please ask. Thank

The code is from: https://github.com/husaynhakeem/android-face-detector

The specific part that I had tried to change is the ANCHOR_RADIUS, ID_OFFSET, as well as the xOffset, yOffset values in the FaceBoundsOverlay. Each variable affects some boundary that is supposed to be used to draw the rectangle and center dot. I pasted the drawAnchor method down below. In that method, when I changed the ANCHOR_RADIUS to 50f, I expected the dot to become larger but nothing was changed.

The FaceBoundsOverlay is in the package called facedetector while the MainActivity is in the package called facedetectorapp

class FaceBoundsOverlay @JvmOverloads constructor(
        ctx: Context,
        attrs: AttributeSet? = null,
        defStyleAttr: Int = 0) : View(ctx, attrs, defStyleAttr) {
      .....
    private fun drawAnchor(canvas: Canvas, centerX: Float, centerY: 
Float) {    private fun drawAnchor(canvas: Canvas, centerX: Float, 
centerY: Float) {
        canvas.drawCircle(
                centerX,
                centerY,
                ANCHOR_RADIUS,
                anchorPaint)
    }
    companion object {
        private const val ANCHOR_RADIUS = 10f
//        private const val ANCHOR_RADIUS = 50f
        private const val ID_OFFSET = 50f
    }
}
5
  • I'm not getting your question! I believe you saying, there is a package and you have a module? Also, I would like to know, you just cloned the github project you shared? Jan 2, 2019 at 9:56
  • Hi, yes I downloaded the project as a zip and then imported it into Android Studio. When I opened it, there were two packages. One package (called facedetectorapp) contains the MainActivity which is what is first run when the project is run. There is another package (called facedetector) which contains files that draw the overlay on the camera preview. In the MainActivity, there is one part that imports a few classes from facedetector and also uses the classes but when running the app, it doesn't seem like it ever goes into the facedetector package.
    – appljuice
    Jan 2, 2019 at 10:46
  • So here is the thing! First of all you don't mention it as two packages. Instead you should mention as module. In the face-detector-app, facedetector is a module. And you just cloned the working project, which means you need to understand the whole project how it works before starting to change something and expect it to work! Kindly go though that library, that will help you what to do make your changes further. Jan 2, 2019 at 11:03
  • Thank you for your suggestions. I have spent quite a while trying to understand the project except I still have a few conceptual questions. (1) How do you find the documentation/source code of the imported classes? For example, in the mainActivity, it imports husaynhakeem.io.facedetector.models.Size. Where can i find the code for this class? (2) How are modules different from packages in terms of their use and being imported into a file? Thanks!
    – appljuice
    Jan 4, 2019 at 0:18
  • As this project is using Kotlin, the author has used the data classes. As you mentioned, husaynhakeem.io.facedetector.models.Size can be found inside a package husaynhakeem.io.facedetector.models you have models.kt file. Kindly open that you'll find the Size data class. To answer your question on difference between modules and packages take a look at it stackoverflow.com/a/40552837/3475831. Always ask yourself or take Google's help to understand these kinda things. Jan 4, 2019 at 7:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.