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
fun updateLikeIcon(movie: Moview) | |
{ | |
if(movie.like?.isLiked==true) | |
bind.likeIcon.setImageDrawable(ContextCompat.getDrawable(context,R.drawable.ic_thumb_like)) | |
else | |
bind.likeIcon.setImageDrawable(ContextCompat.getDrawable(context,R.drawable.ic_thumb_unlike)) | |
} |
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
override fun onBindViewHolder(h: RecyclerView.ViewHolder, position: Int, payloads: List<Any>) { | |
if (payloads.isNotEmpty()) { | |
val item = data[position] | |
for (payload in payloads) { | |
if (payload == payloadName) { | |
// in this case only like icon will be updated | |
(h as CardMovie).updateLikeIcon(movie) | |
} | |
} | |
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
tflite.run(inputVal,output); |
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
public class MainActivity extends AppCompatActivity { | |
Interpreter tflite; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
try { | |
tflite = new Interpreter(loadFile()); | |
}catch (Exception ex){ |
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
private MappedByteBuffer loadFile() throws IOException { | |
AssetFileDescriptor fileDescriptor=this.getAssets().openFd("degree.tflite"); | |
FileInputStream inputStream=new FileInputStream(fileDescriptor.getFileDescriptor()); | |
FileChannel fileChannel=inputStream.getChannel(); | |
long startOffset=fileDescriptor.getStartOffset(); | |
long declareLength=fileDescriptor.getDeclaredLength(); | |
return fileChannel.map(FileChannel.MapMode.READ_ONLY,startOffset,declareLength); | |
} |
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
private fun galleryIntent() { | |
val galleryIntent:Intent | |
if (Build.VERSION.SDK_INT >= Versions.ANDROID_10) | |
galleryIntent = Intent(Intent.ACTION_PICK,MediaStore.Images.Media.EXTERNAL_CONTENT_URI) | |
else | |
galleryIntent = Intent() | |
galleryFile = FileUtils.createTempFileInStorage(this, FileUtil.getProfileName()) | |
galleryIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) | |
galleryIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION) | |
galleryIntent.type = "image/*" |
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
fun recognize(context: Context) { | |
val ink = inkBuilder.build() | |
recognizer.recognize(ink) | |
.addOnSuccessListener { result: RecognitionResult -> | |
Toast.makeText(context, "This is ${result.candidates[0].text}", Toast.LENGTH_LONG) | |
.show() | |
} | |
.addOnFailureListener { e: Exception -> |
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
fun download() { | |
var modelIdentifier: DigitalInkRecognitionModelIdentifier? = null | |
try { | |
modelIdentifier = | |
DigitalInkRecognitionModelIdentifier.fromLanguageTag("zxx-Zsym-x-autodraw") | |
} catch (e: MlKitException) { | |
// language tag failed to parse, handle error. | |
} | |
model = |
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
class Drawing @JvmOverloads constructor( | |
context: Context?, | |
attributeSet: AttributeSet? = null | |
) : | |
View(context, attributeSet) { | |
private val currentStrokePaint: Paint = Paint() | |
private val canvasPaint: Paint | |
private val currentStroke: Path | |
private lateinit var drawCanvas: Canvas | |
private lateinit var canvasBitmap: 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
entityExtractor | |
.downloadModelIfNeeded() | |
.addOnSuccessListener { _ -> | |
//step3 | |
val params = | |
EntityExtractionParams.Builder("My flight is LX373") | |
.build() | |
entityExtractor | |
.annotate(params) | |
.addOnSuccessListener { |
NewerOlder