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
import React, { useState } from 'react'; | |
import { StyleSheet, Text, View, Button, Dimensions, TouchableWithoutFeedback } from 'react-native'; | |
import Modal from "react-native-modalbox"; | |
import {verticalScale} from './Utils/ScreenUtils'; | |
const {width, height } = Dimensions.get("window"); | |
export default function App() { | |
const [modalVisible, setModalVisible] = useState(false); | |
const getModal = () =>{ | |
return ( | |
<Modal |
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 MainActivity : AppCompatActivity() { | |
lateinit var arFragment: CloudAnchorFragment | |
var cloudAnchor: Anchor? = null | |
enum class AppAnchorState { | |
NONE, | |
HOSTING, | |
HOSTED, | |
RESOLVING, | |
RESOLVED | |
} |
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 onResolveOkPressed(dialogVal: String) { | |
val shortCode = dialogVal.toInt() | |
val cloudAnchorId = storageManager.getCloudAnchorID(this, shortCode) | |
val resolvedAnchor = arFragment.arSceneView.session?.resolveCloudAnchor(cloudAnchorId) | |
cloudAnchor(resolvedAnchor) | |
placeObject(arFragment, cloudAnchor!!, Uri.parse("model.sfb")) | |
snackbarHelper.showMessage(this, "Now resolving anchor...") | |
appAnchorState = AppAnchorState.RESOLVING | |
} |
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
btn_resolve.setOnClickListener { | |
if (cloudAnchor != null) { | |
snackbarHelper.showMessageWithDismiss(this, "Please clear the anchor") | |
return@setOnClickListener | |
} | |
val dialog = ResolveDialogFragment() | |
dialog.setOkListener(this::onResolveOkPressed) | |
dialog.show(supportFragmentManager, "Resolve") | |
} |
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 ResolveDialogFragment extends DialogFragment { | |
interface OkListener { | |
void onOkPressed(String dialogValue); | |
} | |
private OkListener okListener; | |
private EditText shortCodeField; | |
/** Sets a listener that is invoked when the OK button on this dialog is pressed. */ | |
void setOkListener(OkListener okListener) { | |
this.okListener = okListener; | |
} |
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
btn_clear.setOnClickListener { | |
cloudAnchor(null) | |
} |
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
/** Helper class for managing on-device storage of cloud anchor IDs. */ | |
public class StorageManager { | |
private static final String NEXT_SHORT_CODE = "next_short_code"; | |
private static final String KEY_PREFIX = "anchor;"; | |
private static final int INITIAL_SHORT_CODE = 142; | |
/** Gets a new short code that can be used to store the anchor ID. */ | |
int nextShortCode(Activity activity) { | |
SharedPreferences sharedPrefs = activity.getPreferences(Context.MODE_PRIVATE); | |
int shortCode = sharedPrefs.getInt(NEXT_SHORT_CODE, INITIAL_SHORT_CODE); | |
// Increment and update the value in sharedPrefs, so the next code retrieved will be unused. |
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 onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
arFragment = supportFragmentManager.findFragmentById(R.id.ar_fragment) as CloudAnchorFragment | |
arFragment.arSceneView.scene.addOnUpdateListener(this::onUpdateFrame) | |
.... | |
} | |
fun onUpdateFrame(frameTime: FrameTime) { | |
checkUpdatedAnchor() |
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 onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
arFragment.setOnTapArPlaneListener { hitResult, plane, _ -> | |
if (plane.type != Plane.Type.HORIZONTAL_UPWARD_FACING || appAnchorState != AppAnchorState.NONE) { | |
return@setOnTapArPlaneListener | |
} | |
val anchor = arFragment.arSceneView.session?.hostCloudAnchor(hitResult.createAnchor()) | |
cloudAnchor(anchor) | |
appAnchorState = AppAnchorState.HOSTING |
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 MainActivity : AppCompatActivity() { | |
lateinit var arFragment: CloudAnchorFragment | |
var cloudAnchor: Anchor? = null | |
enum class AppAnchorState { | |
NONE, | |
HOSTING, | |
HOSTED, | |
RESOLVING, | |
RESOLVED | |
} |
NewerOlder