Merge branch 'master' of github.com:highfidelity/hifi into infinite-scroll

This commit is contained in:
howard-stearns 2018-06-08 12:12:21 -07:00
commit dd0f3c64ec
18 changed files with 155 additions and 128 deletions

View file

@ -1,10 +1,11 @@
package io.highfidelity.hifiinterface.provider;
import android.util.Log;
import android.util.MutableInt;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import io.highfidelity.hifiinterface.HifiUtils;
import io.highfidelity.hifiinterface.view.DomainAdapter;
@ -47,24 +48,42 @@ public class UserStoryDomainProvider implements DomainProvider {
suggestions = new ArrayList<>();
}
@Override
public synchronized void retrieve(String filterText, DomainCallback domainCallback) {
if (!startedToGetFromAPI) {
startedToGetFromAPI = true;
fillDestinations(filterText, domainCallback);
} else {
filterChoicesByText(filterText, domainCallback);
}
}
private void fillDestinations(String filterText, DomainCallback domainCallback) {
StoriesFilter filter = new StoriesFilter(filterText);
final MutableInt counter = new MutableInt(0);
allStories.clear();
getUserStoryPage(1,
List<UserStory> taggedStories = new ArrayList<>();
Set<String> taggedStoriesIds = new HashSet<>();
getUserStoryPage(1, taggedStories, TAGS_TO_SEARCH,
e -> {
allStories.subList(counter.value, allStories.size()).forEach(userStory -> {
filter.filterOrAdd(userStory);
});
if (domainCallback != null) {
domainCallback.retrieveOk(suggestions); //ended
}
},
a -> {
allStories.forEach(userStory -> {
counter.value++;
filter.filterOrAdd(userStory);
taggedStories.forEach(userStory -> {
taggedStoriesIds.add(userStory.id);
});
allStories.clear();
getUserStoryPage(1, allStories, null,
ex -> {
allStories.forEach(userStory -> {
if (taggedStoriesIds.contains(userStory.id)) {
userStory.tagFound = true;
}
filter.filterOrAdd(userStory);
});
if (domainCallback != null) {
domainCallback.retrieveOk(suggestions); //ended
}
}
);
}
);
}
@ -73,25 +92,22 @@ public class UserStoryDomainProvider implements DomainProvider {
restOfPagesCallback.callback(new Exception("Error accessing url [" + url + "]", t));
}
private void getUserStoryPage(int pageNumber, Callback<Exception> restOfPagesCallback, Callback<Void> firstPageCallback) {
private void getUserStoryPage(int pageNumber, List<UserStory> userStoriesList, String tagsFilter, Callback<Exception> restOfPagesCallback) {
Call<UserStories> userStories = mUserStoryDomainProviderService.getUserStories(
INCLUDE_ACTIONS_FOR_PLACES,
"open",
true,
mProtocol,
TAGS_TO_SEARCH,
tagsFilter,
pageNumber);
Log.d("API-USER-STORY-DOMAINS", "Protocol [" + mProtocol + "] include_actions [" + INCLUDE_ACTIONS_FOR_PLACES + "]");
userStories.enqueue(new retrofit2.Callback<UserStories>() {
@Override
public void onResponse(Call<UserStories> call, Response<UserStories> response) {
UserStories data = response.body();
allStories.addAll(data.user_stories);
userStoriesList.addAll(data.user_stories);
if (data.current_page < data.total_pages && data.current_page <= MAX_PAGES_TO_GET) {
if (pageNumber == 1 && firstPageCallback != null) {
firstPageCallback.callback(null);
}
getUserStoryPage(pageNumber + 1, restOfPagesCallback, null);
getUserStoryPage(pageNumber + 1, userStoriesList, tagsFilter, restOfPagesCallback);
return;
}
restOfPagesCallback.callback(null);
@ -107,12 +123,16 @@ public class UserStoryDomainProvider implements DomainProvider {
private class StoriesFilter {
String[] mWords = new String[]{};
public StoriesFilter(String filterText) {
mWords = filterText.toUpperCase().split("\\s+");
mWords = filterText.trim().toUpperCase().split("\\s+");
if (mWords.length == 1 && (mWords[0] == null || mWords[0].length() <= 0 ) ) {
mWords = null;
}
}
private boolean matches(UserStory story) {
if (mWords.length <= 0) {
return true;
if (mWords == null || mWords.length <= 0) {
// No text filter? So filter by tag
return story.tagFound;
}
for (String word : mWords) {
@ -128,6 +148,9 @@ public class UserStoryDomainProvider implements DomainProvider {
suggestions.add(story.toDomain());
}
/**
* if the story matches this filter criteria it's added into suggestions
* */
public void filterOrAdd(UserStory story) {
if (matches(story)) {
addToSuggestions(story);
@ -144,16 +167,6 @@ public class UserStoryDomainProvider implements DomainProvider {
domainCallback.retrieveOk(suggestions);
}
@Override
public synchronized void retrieve(String filterText, DomainCallback domainCallback) {
if (!startedToGetFromAPI) {
startedToGetFromAPI = true;
fillDestinations(filterText, domainCallback);
} else {
filterChoicesByText(filterText, domainCallback);
}
}
public interface UserStoryDomainProviderService {
@GET("api/v1/user_stories")
Call<UserStories> getUserStories(@Query("include_actions") String includeActions,
@ -166,12 +179,14 @@ public class UserStoryDomainProvider implements DomainProvider {
class UserStory {
public UserStory() {}
String id;
String place_name;
String path;
String thumbnail_url;
String place_id;
String domain_id;
private String searchText;
private boolean tagFound; // Locally used
// New fields? tags, description

View file

@ -54,27 +54,10 @@ public class DomainAdapter extends RecyclerView.Adapter<DomainAdapter.ViewHolder
@Override
public void retrieveOk(List<Domain> domain) {
if (filterText.length() == 0) {
Domain lastVisitedDomain = new Domain(mContext.getString(R.string.your_last_location), mLastLocation, DEFAULT_THUMBNAIL_PLACE);
if (!mLastLocation.isEmpty() && mLastLocation.contains("://")) {
int startIndex = mLastLocation.indexOf("://");
int endIndex = mLastLocation.indexOf("/", startIndex + 3);
String toSearch = mLastLocation.substring(0, endIndex + 1).toLowerCase();
for (Domain d : domain) {
if (d.url.toLowerCase().startsWith(toSearch)) {
lastVisitedDomain.thumbnail = d.thumbnail;
}
}
}
domain.add(0, lastVisitedDomain);
addLastLocation(domain);
}
for (Domain d : domain) {
// we override the default picture added in the server by an android specific version
if (d.thumbnail != null &&
d.thumbnail.endsWith("assets/places/thumbnail-default-place-e5a3f33e773ab699495774990a562f9f7693dc48ef90d8be6985c645a0280f75.png")) {
d.thumbnail = DEFAULT_THUMBNAIL_PLACE;
}
}
overrideDefaultThumbnails(domain);
mDomains = new Domain[domain.size()];
mDomains = domain.toArray(mDomains);
@ -96,6 +79,31 @@ public class DomainAdapter extends RecyclerView.Adapter<DomainAdapter.ViewHolder
});
}
private void overrideDefaultThumbnails(List<Domain> domain) {
for (Domain d : domain) {
// we override the default picture added in the server by an android specific version
if (d.thumbnail != null &&
d.thumbnail.endsWith("assets/places/thumbnail-default-place-e5a3f33e773ab699495774990a562f9f7693dc48ef90d8be6985c645a0280f75.png")) {
d.thumbnail = DEFAULT_THUMBNAIL_PLACE;
}
}
}
private void addLastLocation(List<Domain> domain) {
Domain lastVisitedDomain = new Domain(mContext.getString(R.string.your_last_location), mLastLocation, DEFAULT_THUMBNAIL_PLACE);
if (!mLastLocation.isEmpty() && mLastLocation.contains("://")) {
int startIndex = mLastLocation.indexOf("://");
int endIndex = mLastLocation.indexOf("/", startIndex + 3);
String toSearch = mLastLocation.substring(0, endIndex + 1).toLowerCase();
for (Domain d : domain) {
if (d.url.toLowerCase().startsWith(toSearch)) {
lastVisitedDomain.thumbnail = d.thumbnail;
}
}
}
domain.add(0, lastVisitedDomain);
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = mInflater.inflate(R.layout.domain_view, parent, false);

View file

@ -2,88 +2,88 @@ name = mannequin
type = body+head
scale = 1
filename = mannequin/mannequin.baked.fbx
joint = jointRoot = Hips
joint = jointNeck = Neck
joint = jointLean = Spine
joint = jointLeftHand = LeftHand
joint = jointHead = Head
joint = jointEyeLeft = LeftEye
joint = jointEyeRight = RightEye
joint = jointRoot = Hips
joint = jointLeftHand = LeftHand
joint = jointRightHand = RightHand
joint = jointNeck = Neck
joint = jointHead = Head
freeJoint = LeftArm
freeJoint = LeftForeArm
freeJoint = RightArm
freeJoint = RightForeArm
bs = EyeBlink_L = blink = 1
bs = JawOpen = mouth_Open = 1
bs = LipsFunnel = Oo = 1
bs = BrowsU_L = brow_Up = 1
jointIndex = RightHandPinky2 = 19
jointIndex = LeftHandMiddle4 = 61
jointIndex = LeftHand = 41
jointIndex = LeftHandRing4 = 49
jointIndex = RightHandMiddle3 = 36
jointIndex = LeftHandThumb4 = 57
jointIndex = RightToe_End = 10
jointIndex = LeftHandRing1 = 46
jointIndex = LeftForeArm = 40
jointIndex = RightHandIndex4 = 29
jointIndex = LeftShoulder = 38
jointIndex = RightHandMiddle4 = 37
jointIndex = RightShoulder = 14
jointIndex = LeftLeg = 2
jointIndex = LeftToe_End = 5
jointIndex = Hips = 0
jointIndex = RightFoot = 8
jointIndex = RightHandThumb2 = 31
jointIndex = LeftHandMiddle3 = 60
jointIndex = RightHandThumb1 = 30
jointIndex = Neck = 62
jointIndex = Spine = 11
jointIndex = RightHandThumb4 = 33
jointIndex = RightHandMiddle1 = 34
jointIndex = LeftHandIndex4 = 53
jointIndex = face = 68
jointIndex = RightHandRing3 = 24
jointIndex = LeftHandPinky4 = 45
jointIndex = LeftHandMiddle2 = 59
jointIndex = RightHandThumb3 = 32
bs = EyeBlink_L = blink = 1
jointIndex = LeftHandPinky3 = 44
jointIndex = HeadTop_End = 66
jointIndex = Spine1 = 12
jointIndex = LeftHandRing3 = 48
jointIndex = mannequin1 = 67
jointIndex = RightEye = 65
jointIndex = RightHandRing4 = 25
jointIndex = RightHandPinky4 = 21
jointIndex = LeftHandRing2 = 47
jointIndex = RightHandIndex3 = 28
jointIndex = RightUpLeg = 6
jointIndex = LeftArm = 39
jointIndex = LeftHandThumb3 = 56
jointIndex = RightHandIndex2 = 27
jointIndex = RightForeArm = 16
jointIndex = RightArm = 15
jointIndex = RightHandRing2 = 23
jointIndex = LeftHandMiddle1 = 58
jointIndex = Spine2 = 13
jointIndex = LeftHandThumb2 = 55
jointIndex = RightHandMiddle2 = 35
jointIndex = RightHandPinky1 = 18
jointIndex = LeftUpLeg = 1
jointIndex = RightLeg = 7
jointIndex = LeftHandIndex2 = 51
jointIndex = LeftHand = 41
jointIndex = RightHandMiddle1 = 34
jointIndex = LeftHandPinky4 = 45
jointIndex = RightHand = 17
jointIndex = LeftHandIndex3 = 52
jointIndex = LeftFoot = 3
jointIndex = RightHandPinky3 = 20
jointIndex = RightHandIndex1 = 26
jointIndex = LeftHandPinky1 = 42
jointIndex = RightToeBase = 9
jointIndex = LeftHandIndex1 = 50
jointIndex = LeftToeBase = 4
jointIndex = LeftHandPinky2 = 43
jointIndex = RightHandRing1 = 22
jointIndex = LeftHandThumb1 = 54
jointIndex = LeftEye = 64
jointIndex = LeftFoot = 3
jointIndex = Head = 63
jointIndex = Spine1 = 12
jointIndex = RightHandRing4 = 25
jointIndex = RightHandPinky1 = 18
jointIndex = LeftHandIndex1 = 50
jointIndex = RightHandIndex3 = 28
jointIndex = LeftHandIndex3 = 52
jointIndex = LeftToe_End = 5
jointIndex = RightArm = 15
jointIndex = RightHandRing3 = 24
jointIndex = RightHandThumb2 = 31
jointIndex = Spine2 = 13
jointIndex = HeadTop_End = 66
jointIndex = LeftToeBase = 4
jointIndex = RightUpLeg = 6
jointIndex = RightForeArm = 16
jointIndex = LeftHandMiddle1 = 58
jointIndex = LeftHandRing3 = 48
jointIndex = RightHandPinky4 = 21
jointIndex = RightHandIndex1 = 26
jointIndex = Hips = 0
jointIndex = RightEye = 65
jointIndex = RightHandPinky2 = 19
jointIndex = LeftHandMiddle2 = 59
jointIndex = LeftHandPinky1 = 42
jointIndex = LeftHandRing4 = 49
jointIndex = RightFoot = 8
jointIndex = RightHandIndex2 = 27
jointIndex = RightToe_End = 10
jointIndex = RightHandThumb3 = 32
jointIndex = LeftHandMiddle3 = 60
jointIndex = LeftHandThumb4 = 57
jointIndex = LeftHandMiddle4 = 61
jointIndex = LeftHandThumb1 = 54
jointIndex = LeftHandThumb3 = 56
jointIndex = body = 67
jointIndex = LeftArm = 39
jointIndex = RightToeBase = 9
jointIndex = LeftEye = 64
jointIndex = RightLeg = 7
jointIndex = face = 68
jointIndex = LeftForeArm = 40
jointIndex = RightHandThumb4 = 33
jointIndex = RightHandRing1 = 22
jointIndex = LeftUpLeg = 1
jointIndex = LeftHandPinky2 = 43
jointIndex = LeftLeg = 2
jointIndex = LeftHandIndex4 = 53
jointIndex = RightHandThumb1 = 30
jointIndex = LeftHandRing2 = 47
jointIndex = RightHandMiddle2 = 35
jointIndex = RightHandMiddle3 = 36
jointIndex = Spine = 11
jointIndex = RightHandMiddle4 = 37
jointIndex = LeftHandIndex2 = 51
jointIndex = RightHandRing2 = 23
jointIndex = LeftHandThumb2 = 55
jointIndex = LeftShoulder = 38
jointIndex = Neck = 62
jointIndex = RightHandIndex4 = 29
jointIndex = LeftHandRing1 = 46
jointIndex = RightShoulder = 14

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,002 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 KiB

View file

@ -206,7 +206,7 @@ private:
render::ItemKey _itemKey { render::ItemKey::Builder().withTypeMeta() };
bool _didLastVisualGeometryRequestSucceed { false };
bool _didLastVisualGeometryRequestSucceed { true };
void processMaterials();
};

View file

@ -636,7 +636,10 @@ void Resource::attemptRequest() {
<< "- retrying asset load - attempt" << _attempts << " of " << MAX_ATTEMPTS;
}
ResourceCache::attemptRequest(_self);
auto self = _self.lock();
if (self) {
ResourceCache::attemptRequest(self);
}
}
void Resource::finishedLoading(bool success) {

View file

@ -40,7 +40,7 @@ PacketVersion versionForPacketType(PacketType packetType) {
case PacketType::AvatarData:
case PacketType::BulkAvatarData:
case PacketType::KillAvatar:
return static_cast<PacketVersion>(AvatarMixerPacketVersion::FBXReaderNodeReparenting);
return static_cast<PacketVersion>(AvatarMixerPacketVersion::FixMannequinDefaultAvatarFeet);
case PacketType::MessagesData:
return static_cast<PacketVersion>(MessageDataVersion::TextOrBinaryData);
// ICE packets

View file

@ -282,7 +282,8 @@ enum class AvatarMixerPacketVersion : PacketVersion {
AvatarIdentityLookAtSnapping,
UpdatedMannequinDefaultAvatar,
AvatarJointDefaultPoseFlags,
FBXReaderNodeReparenting
FBXReaderNodeReparenting,
FixMannequinDefaultAvatarFeet
};
enum class DomainConnectRequestVersion : PacketVersion {