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
lateinit var link : String | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
link = "https://firebasestorage.googleapis.com/v0/b/modelviewerapp.appspot.com/o/models%2Fout.glb?alt=media&token=442d2d08-9b61-49e1-a059-e7f89a83155c" | |
//making a transformation system so we can interact with the 3d model | |
transformationSystem = TransformationSystem(resources.displayMetrics, FootprintSelectionVisualizer()) | |
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 renderObject() { | |
ModelRenderable.builder() | |
.setSource( | |
requireContext(), builder().setSource( | |
requireContext(), | |
Uri.parse(link), | |
SourceType.GLB | |
) | |
.setRecenterMode(RecenterMode.ROOT) |
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 onRenderableLoaded(modelRenderable: ModelRenderable) { | |
modelNode = TransformableNode(transformationSystem).apply { | |
setParent(binding.SceneView.scene) | |
translationController.isEnabled = true | |
scaleController.isEnabled = true | |
scaleController.minScale=0.01f |
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 getPermission() { | |
Dexter.withContext(this) | |
.withPermission( | |
Manifest.permission.CAMERA | |
).withListener(object : MultiplePermissionsListener { | |
override fun onPermissionsChecked(report: MultiplePermissionsReport) { | |
report.let { | |
if (report.areAllPermissionsGranted()) { | |
Toast.makeText(this@MainActivity, "Permission Granted", Toast.LENGTH_SHORT).show() |
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 getPermission() { | |
Dexter.withContext(this) | |
.withPermissions( | |
Manifest.permission.CAMERA, | |
Manifest.permission.WRITE_EXTERNAL_STORAGE | |
).withListener(object : MultiplePermissionsListener { | |
override fun onPermissionsChecked(report: MultiplePermissionsReport) { | |
report.let { | |
if (report.areAllPermissionsGranted()) { |
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 onPermissionRationaleShouldBeShown(permissions: List<PermissionRequest?>?, token: PermissionToken?) { | |
token?.continuePermissionRequest() | |
} |
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 val itemTouchHelper by lazy { | |
val simpleItemTouchCallback = object : ItemTouchHelper.SimpleCallback(UP or DOWN or START or END, 0) { | |
override fun onMove(recyclerView: RecyclerView, | |
viewHolder: RecyclerView.ViewHolder, | |
target: RecyclerView.ViewHolder): Boolean { | |
//on move lets you check if an item has been moved from its position either up or down | |
return true | |
} |
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 val itemTouchHelper by lazy { | |
val simpleItemTouchCallback = object : ItemTouchHelper.SimpleCallback(UP or DOWN or START or END, 0) { | |
override fun onMove(recyclerView: RecyclerView, | |
viewHolder: RecyclerView.ViewHolder, | |
target: RecyclerView.ViewHolder): Boolean { | |
//getting the adapter | |
val adapter = recyclerView.adapter as MoviesAdapter | |
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 onMove(recyclerView: RecyclerView, | |
viewHolder: RecyclerView.ViewHolder, | |
target: RecyclerView.ViewHolder): Boolean { | |
val adapter = recyclerView.adapter as MoviesAdapter | |
val from = viewHolder.adapterPosition | |
val to = target.adapterPosition | |
adapter.moveItemInRecyclerViewList(from, to) | |
adapter.notifyItemMoved(from, to) | |
return true |
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
val entityExtractor = | |
EntityExtraction.getClient( | |
EntityExtractorOptions.Builder(EntityExtractorOptions.ENGLISH) | |
.build() | |
) |
OlderNewer