-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from CSE-110-Winter-2023/US-12b
Us 12b
- Loading branch information
Showing
4 changed files
with
141 additions
and
58 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.example.demo5; | ||
|
||
import android.util.Log; | ||
|
||
import java.util.UUID; | ||
|
||
import androidx.core.util.Pair; | ||
import androidx.lifecycle.LiveData; | ||
import androidx.lifecycle.MutableLiveData; | ||
|
||
import static java.util.UUID.randomUUID; | ||
|
||
public class BestFriend { | ||
MutableLiveData<Pair<Double, Double>> loc = new MutableLiveData<>(); | ||
UUID uid; | ||
|
||
BestFriend() { | ||
loc.setValue(new Pair<Double, Double>(0.0, 0.0)); | ||
this.uid = new UUID(1, 0); | ||
uid = randomUUID(); | ||
//testMove(); | ||
} | ||
|
||
|
||
public Double getLatitude() { | ||
return getLocation().getValue().first; | ||
} | ||
|
||
public Double getLongitude() { | ||
return getLocation().getValue().second; | ||
} | ||
|
||
public UUID getUid() { | ||
return uid; | ||
} | ||
|
||
public String getUidString() { | ||
return getUid().toString(); | ||
} | ||
|
||
public LiveData<Pair<Double, Double>> getLocation() { | ||
return loc; | ||
} | ||
|
||
public void testMove() { | ||
for (int i = 0; i < 100; ++i) { | ||
|
||
switch (i % 4) { | ||
case 0: | ||
loc.postValue(new Pair<Double, Double>(1.0, 1.0)); | ||
break; | ||
case 1: | ||
loc.postValue(new Pair<Double, Double>(1.0, -1.0)); | ||
break; | ||
case 2: | ||
loc.postValue(new Pair<Double, Double>(-1.0, -1.0)); | ||
break; | ||
case 3: | ||
loc.postValue(new Pair<Double, Double>(-1.0, 1.0)); | ||
break; | ||
default: | ||
Log.i("ERROR", "yeah, this isn't working"); | ||
break; | ||
} | ||
|
||
try { | ||
Thread.sleep(1000); | ||
Log.i("SLEEP", String.valueOf(i)); | ||
} catch (InterruptedException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
} | ||
} | ||
|
||
public void testMove2() { | ||
loc.postValue(new Pair<Double, Double>(0.0, -1.0)); | ||
try { | ||
Thread.sleep(5000); | ||
} catch (InterruptedException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
//loc.postValue(new Pair<Double, Double>(-1.0, -1.0)); | ||
} | ||
} | ||
|
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
This file was deleted.
Oops, something went wrong.
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