use of io.plaidapp.data.api.designernews.model.StoriesResponse in project sbt-android by scala-android.
the class HomeActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(requestCode) {
case RC_SEARCH:
// reset the search icon which we hid
View searchMenuView = toolbar.findViewById(R.id.menu_search);
if (searchMenuView != null) {
searchMenuView.setAlpha(1f);
}
if (resultCode == SearchActivity.RESULT_CODE_SAVE) {
String query = data.getStringExtra(SearchActivity.EXTRA_QUERY);
if (TextUtils.isEmpty(query))
return;
Source dribbbleSearch = null;
Source designerNewsSearch = null;
boolean newSource = false;
if (data.getBooleanExtra(SearchActivity.EXTRA_SAVE_DRIBBBLE, false)) {
dribbbleSearch = new Source.DribbbleSearchSource(query, true);
newSource |= filtersAdapter.addFilter(dribbbleSearch);
}
if (data.getBooleanExtra(SearchActivity.EXTRA_SAVE_DESIGNER_NEWS, false)) {
designerNewsSearch = new Source.DesignerNewsSearchSource(query, true);
newSource |= filtersAdapter.addFilter(designerNewsSearch);
}
if (newSource && (dribbbleSearch != null || designerNewsSearch != null)) {
highlightNewSources(dribbbleSearch, designerNewsSearch);
}
}
break;
case RC_NEW_DESIGNER_NEWS_STORY:
if (resultCode == PostNewDesignerNewsStory.RESULT_DRAG_DISMISSED) {
// need to reshow the FAB as there's no shared element transition
showFab();
} else if (resultCode == PostNewDesignerNewsStory.RESULT_POST) {
String title = data.getStringExtra(PostNewDesignerNewsStory.EXTRA_STORY_TITLE);
String url = data.getStringExtra(PostNewDesignerNewsStory.EXTRA_STORY_URL);
String comment = data.getStringExtra(PostNewDesignerNewsStory.EXTRA_STORY_COMMENT);
if (!TextUtils.isEmpty(title)) {
NewStoryRequest storyToPost = null;
if (!TextUtils.isEmpty(url)) {
storyToPost = NewStoryRequest.createWithUrl(title, url);
} else if (!TextUtils.isEmpty(comment)) {
storyToPost = NewStoryRequest.createWithComment(title, comment);
}
if (storyToPost != null) {
// TODO: move this to a service in follow up CL?
DesignerNewsService designerNewsApi = new RestAdapter.Builder().setEndpoint(DesignerNewsService.ENDPOINT).setRequestInterceptor(new ClientAuthInterceptor(designerNewsPrefs.getAccessToken(), BuildConfig.DESIGNER_NEWS_CLIENT_ID)).build().create(DesignerNewsService.class);
designerNewsApi.postStory(storyToPost, new Callback<StoriesResponse>() {
@Override
public void success(StoriesResponse story, Response response) {
if (story != null && story.stories != null && story.stories.size() > 0) {
long id = story.stories.get(0).id;
}
}
@Override
public void failure(RetrofitError error) {
Log.e("HomeActivity", "Failed posting story", error);
}
});
}
}
}
break;
case RC_NEW_DESIGNER_NEWS_LOGIN:
if (resultCode == RESULT_OK) {
showFab();
}
break;
case RC_AUTH_DRIBBBLE_FOLLOWING:
if (resultCode == RESULT_OK) {
filtersAdapter.enableFilterByKey(SourceManager.SOURCE_DRIBBBLE_FOLLOWING, this);
}
break;
case RC_AUTH_DRIBBBLE_USER_LIKES:
if (resultCode == RESULT_OK) {
filtersAdapter.enableFilterByKey(SourceManager.SOURCE_DRIBBBLE_USER_LIKES, this);
}
break;
case RC_AUTH_DRIBBBLE_USER_SHOTS:
if (resultCode == RESULT_OK) {
filtersAdapter.enableFilterByKey(SourceManager.SOURCE_DRIBBBLE_USER_SHOTS, this);
}
break;
}
}
Aggregations