[英]How to implement proper MVP architecture whilst using images in Android?
I'm making my first Android app from scratch and I'm trying to stick to the MVP architecture. 我正在从头开始创建我的第一个Android应用程序,我正在努力坚持MVP架构。 If I understand correctly, the Model should be independent of the platform (ie: not use any android package components).
如果我理解正确,模型应该独立于平台(即:不使用任何android包组件)。
However, in dealing with images, I'm facing issues with this because Bitmap (an Android class) seems to be the only way to implement images. 但是,在处理图像时,我遇到了这个问题,因为Bitmap(一个Android类)似乎是实现图像的唯一方法。 I'm unable to use java.awt for some reason, and many questions I've searched have answers suggesting it is not supported in Android.
我出于某种原因无法使用java.awt,我搜索过的许多问题都有答案表明它在Android中不受支持。
So my question is: How do I maintain my MVP architecture if I'm forced to use an android class in my Model to deal with images? 所以我的问题是: 如果我被迫在我的模型中使用Android类来处理图像,我如何维护我的MVP架构?
Here is a screenshot of my issue with importing java.awt.image.BufferedImage (it's in my JDK but cannot be imported): BufferedImage is in my JDK but cannot be imported 这是我导入java.awt.image.BufferedImage的问题的截图 (它在我的JDK中,但无法导入): BufferedImage在我的JDK中,但无法导入
Here is one of many questions saying java.awt cannot be used: How can I import java.awt.image.BufferedImage in Android Studio 以下是无法使用java.awt的众多问题之一: 如何在Android Studio中导入java.awt.image.BufferedImage
If you want to maintain your architecture, you should not store images as Bitmap
in your model. 如果要维护体系结构,则不应将图像作为
Bitmap
存储在模型中。 Keep them under the simpler form byte[]
or something similar. 将它们保持在更简单的形式
byte[]
或类似的东西下。 Then, once in the higher levels where you can access your Android classes, transform them into a Bitmap
. 然后,在更高级别中,您可以访问Android类,将它们转换为
Bitmap
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.