use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class PerformanceTest method init.
/**
* Set up environment for testing.
*/
private void init() throws Exception {
final String APP_NAME = "com.fireappbuilder.android.calypso";
// TODO: handle situations in which clearing logs takes an arbitrary amount of time
// not needed for later versions of Android as Logcat supports time-based filtering
Runtime.getRuntime().exec("logcat -c");
// use ActivityManager to measure memory usage
mActivityManager = (ActivityManager) mSplashActivity.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager.RunningAppProcessInfo calypsoProcess = null;
// find the process for Calypso
for (ActivityManager.RunningAppProcessInfo p : mActivityManager.getRunningAppProcesses()) {
if (p.processName.equals(APP_NAME)) {
calypsoProcess = p;
break;
}
}
assertNotNull("Calypso process not found.", calypsoProcess);
calypsoPID = new int[] { calypsoProcess.pid };
long startTime = System.currentTimeMillis();
solo.waitForView(R.id.full_content_browse_fragment, 0, TestConfig.LONG_TIMEOUT);
loadTime = (int) (System.currentTimeMillis() - startTime);
// get item count
count = 0;
ContentContainer mContentContainer = ContentBrowser.getInstance(mSplashActivity).getRootContentContainer();
List<Content> contentFound = new ArrayList<>();
for (Content c : mContentContainer) {
if (!contentFound.contains(c)) {
contentFound.add(c);
count++;
}
}
// check if we are using sample feed
Content firstItem = contentFound.get(0);
boolean hasSampleVideo = firstItem.getTitle().contains("Sample item");
boolean isValidSize = false;
for (int s : SAMPLE_SIZES) {
if (count == s) {
isValidSize = true;
break;
}
}
isSampleFeed = hasSampleVideo && isValidSize;
}
use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class ContentLoader method getLoadContentsObservable.
/*
* Zype, Evgeny Cherkasov
*/
public Observable<Object> getLoadContentsObservable(Observable<Object> observable, Recipe recipeDynamicParser) {
return observable.map(contentContainerAsObject -> {
ContentContainer contentContainer = (ContentContainer) contentContainerAsObject;
if (contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.MY_LIBRARY_PLAYLIST_ID)) {
ContentContainer rootMyLibrary = getRootContentContainer().findContentContainerByName(ZypeSettings.ROOT_MY_LIBRARY_PLAYLIST_ID);
if (rootMyLibrary.getExtraValueAsInt(ExtraKeys.NEXT_PAGE) == 1) {
contentContainer.getContents().clear();
}
} else {
if (contentContainer.getExtraValueAsInt(ExtraKeys.NEXT_PAGE) == 1) {
contentContainer.getContents().clear();
}
}
return contentContainerAsObject;
}).concatMap(contentContainerAsObject -> {
ContentContainer contentContainer = (ContentContainer) contentContainerAsObject;
if (DEBUG_RECIPE_CHAIN) {
Log.d(TAG, "getLoadContentsObservable:" + contentContainer.getName());
}
if (contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.MY_LIBRARY_PLAYLIST_ID)) {
// Loading My Library videos
return getMyLibraryVideosObservable(contentContainerAsObject);
} else if (contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.FAVORITES_PLAYLIST_ID)) {
// Load favorites videos
return getFavoriteVideosFeedObservable(contentContainerAsObject);
} else {
LocalBroadcastManager.getInstance(mContext).sendBroadcast(new Intent(BROADCAST_VIDEO_DETAIL_DATA_LOADED));
// Loading playlist videos
return getPlaylistVideosFeedObservable(contentContainerAsObject);
}
}).concatMap(objectPair -> {
ContentContainer contentContainer = (ContentContainer) objectPair.first;
String feed = (String) objectPair.second;
String[] params = new String[] { contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG) };
if (TextUtils.isEmpty(feed)) {
return Observable.just(Pair.create(contentContainer, null));
} else {
return mDynamicParser.cookRecipeObservable(recipeDynamicParser, feed, null, params).map(contentAsObject -> {
if (DEBUG_RECIPE_CHAIN) {
Log.d(TAG, "Parser got an content");
}
Content content = (Content) contentAsObject;
if (content != null) {
contentContainer.addContent(content);
if (ZypeConfiguration.displayWatchedBarOnVideoThumbnails()) {
content.setExtraValue(Content.EXTRA_PLAYBACK_POSITION_PERCENTAGE, getContentPlaybackPositionPercentage(content));
}
}
return Pair.create(contentContainer, contentAsObject);
});
}
});
}
use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class ContentLoader method getContentsObservable.
/**
* Get contents observable.
*
* @param observable Rx Observable chain to continue on.
* @param dataLoaderRecipeForContents Data loader recipe for getting contents.
* @param dynamicParserRecipeForContents Dynamic parser recipe for getting contents.
* @return RX Observable.
*/
private Observable<Object> getContentsObservable(Observable<Object> observable, Recipe dataLoaderRecipeForContents, Recipe dynamicParserRecipeForContents) {
Map<String, Content> parsedContent = new HashMap();
return observable.concatMap(contentContainerAsObject -> {
ContentContainer contentContainer = (ContentContainer) contentContainerAsObject;
if (DEBUG_RECIPE_CHAIN) {
Log.d(TAG, "ContentContainer:" + contentContainer.getName());
}
return mDataLoadManager.cookRecipeObservable(dataLoaderRecipeForContents, null, null, null).map(feedDataForContent -> {
if (DEBUG_RECIPE_CHAIN) {
Log.d(TAG, "Feed for container complete");
}
return Pair.create(contentContainerAsObject, feedDataForContent);
});
}).concatMap(objectPair -> {
ContentContainer contentContainer = (ContentContainer) objectPair.first;
/* Zype, Evgeny Cherkasov */
// Clear content list to avoid duplicate contents for nested playlist (subcategory)
contentContainer.getContents().clear();
String feed = (String) objectPair.second;
String[] params = new String[] { (String) contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG) };
return mDynamicParser.cookRecipeObservable(dynamicParserRecipeForContents, feed, null, params).map(contentAsObject -> {
if (DEBUG_RECIPE_CHAIN) {
Log.d(TAG, "Parser got an content");
}
Content content = (Content) contentAsObject;
if (content != null) {
// Add information of free content available with container
if (contentContainer.getExtraStringValue(Recipe.CONTENT_TYPE_TAG) != null) {
content.setExtraValue(Recipe.CONTENT_TYPE_TAG, contentContainer.getExtraStringValue(Recipe.CONTENT_TYPE_TAG));
}
/* Zype, Evgeny Cherkasov */
if (ZypeConfiguration.displayWatchedBarOnVideoThumbnails()) {
content.setExtraValue(Content.EXTRA_PLAYBACK_POSITION_PERCENTAGE, getContentPlaybackPositionPercentage(content));
}
contentContainer.addContent(content);
}
return Pair.create(contentContainer, contentAsObject);
});
});
}
use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class FavoritesManager method addVideoToFavoritesContentContainer.
// //////////
//
//
public void addVideoToFavoritesContentContainer(Content content) {
ContentContainer favoritesContainer = contentLoader.getRootContentContainer().findContentContainerById(ZypeSettings.FAVORITES_PLAYLIST_ID);
if (favoritesContainer != null) {
Gson gson = new Gson();
String jsonFavoriteVideo = gson.toJson(content);
Content favoriteVideo = gson.fromJson(jsonFavoriteVideo, content.getClass());
favoriteVideo.setExtraValue(Content.EXTRA_PLAYLIST_ID, ZypeSettings.FAVORITES_PLAYLIST_ID);
favoritesContainer.getContents().add(0, favoriteVideo);
}
}
use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class FavoritesManager method removeVideoFromFavoritesContentContainer.
public void removeVideoFromFavoritesContentContainer(Content content) {
ContentContainer favoritesContainer = contentLoader.getRootContentContainer().findContentContainerById(ZypeSettings.FAVORITES_PLAYLIST_ID);
if (favoritesContainer != null) {
Content favoriteVideo = favoritesContainer.findContentById(content.getId());
if (favoriteVideo == null) {
return;
}
favoritesContainer.getContents().remove(favoriteVideo);
}
}
Aggregations