Skip to content

Instantly share code, notes, and snippets.

View DanishAmjad12's full-sized avatar
🎯
Focusing

Danish Amjad DanishAmjad12

🎯
Focusing
View GitHub Profile
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))
}
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)
}
}
tflite.run(inputVal,output);
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){
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);
}
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/*"
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 ->
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 =
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
entityExtractor
.downloadModelIfNeeded()
.addOnSuccessListener { _ ->
//step3
val params =
EntityExtractionParams.Builder("My flight is LX373")
.build()
entityExtractor
.annotate(params)
.addOnSuccessListener {