use of com.meisolsson.githubsdk.model.Content in project gh4a by slapperwan.
the class ContentListContainerFragment method loadModuleMap.
private void loadModuleMap() {
RepositoryContentService service = ServiceFactory.get(RepositoryContentService.class, false);
String repoOwner = mRepository.owner().login();
String repoName = mRepository.name();
service.getContents(repoOwner, repoName, ".gitmodules", mSelectedRef).map(ApiHelpers::throwOnFailure).map(Optional::of).compose(RxUtils.mapFailureToValue(HttpURLConnection.HTTP_NOT_FOUND, Optional.<Content>absent())).map(contentOpt -> contentOpt.map(content -> StringUtils.fromBase64(content.content()))).map(this::parseModuleMap).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).compose(mRxLoader.makeSingleTransformer(ID_LOADER_MODULEMAP, true)).subscribe(resultOpt -> {
mGitModuleMap = resultOpt.orNull();
if (mContentListFragment != null) {
mContentListFragment.onSubModuleNamesChanged(getSubModuleNames(mContentListFragment));
}
}, ((BaseActivity) getActivity())::handleLoadFailure);
}
use of com.meisolsson.githubsdk.model.Content in project gh4a by slapperwan.
the class ContentListContainerFragment method onContentsLoaded.
@Override
public void onContentsLoaded(ContentListFragment fragment, List<Content> contents) {
if (contents == null) {
return;
}
mContentCache.put(fragment.getPath(), new ArrayList<>(contents));
if (fragment.getPath() == null) {
for (Content content : contents) {
if (content.type() == ContentType.File && content.name().equals(".gitmodules")) {
loadModuleMap();
break;
}
}
}
if (mInitialPathToLoad != null && !mInitialPathToLoad.isEmpty() && !mStateSaved) {
String itemToLoad = mInitialPathToLoad.get(0);
boolean found = false;
for (Content content : contents) {
if (content.type() == ContentType.Directory) {
if (content.path().equals(itemToLoad)) {
onTreeSelected(content);
found = true;
break;
}
}
}
if (found) {
mInitialPathToLoad.remove(0);
} else {
mInitialPathToLoad = null;
}
}
}
Aggregations