use of forpdateam.ru.forpda.ui.views.ContentController in project ForPDA by RadiationX.
the class TabFragment method onCreateView.
@CallSuper
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_base, container, false);
// Осторожно! Чувствительно к структуре разметки! (по идеи так должно работать чуть быстрее)
fragmentContainer = (RelativeLayout) findViewById(R.id.fragment_container);
coordinatorLayout = (CoordinatorLayout) fragmentContainer.findViewById(R.id.coordinator_layout);
appBarLayout = (AppBarLayout) coordinatorLayout.findViewById(R.id.appbar_layout);
toolbarLayout = (CollapsingToolbarLayout) appBarLayout.findViewById(R.id.toolbar_layout);
toolbarBackground = (ImageView) toolbarLayout.findViewById(R.id.toolbar_image_background);
toolbar = (Toolbar) toolbarLayout.findViewById(R.id.toolbar);
toolbarImageView = (ImageView) toolbar.findViewById(R.id.toolbar_image_icon);
toolbarTitleView = (TextView) toolbar.findViewById(R.id.toolbar_title);
toolbarSubtitleView = (TextView) toolbar.findViewById(R.id.toolbar_subtitle);
toolbarProgress = (ProgressBar) toolbar.findViewById(R.id.toolbar_progress);
titlesWrapper = (LinearLayout) toolbar.findViewById(R.id.toolbar_titles_wrapper);
toolbarSpinner = (Spinner) toolbar.findViewById(R.id.toolbar_spinner);
notifyDot = findViewById(R.id.notify_dot);
fragmentContent = (ViewGroup) coordinatorLayout.findViewById(R.id.fragment_content);
additionalContent = (ViewGroup) coordinatorLayout.findViewById(R.id.additional_content);
contentProgress = (ProgressBar) additionalContent.findViewById(R.id.content_progress);
noNetwork = (LinearLayout) coordinatorLayout.findViewById(R.id.no_network);
// // TODO: 20.03.17 удалить и юзать только там, где нужно
fab = (FloatingActionButton) coordinatorLayout.findViewById(R.id.fab);
contentController = new ContentController(contentProgress, additionalContent, fragmentContent);
return view;
}
use of forpdateam.ru.forpda.ui.views.ContentController in project ForPDA by RadiationX.
the class ArticleCommentsFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.article_comments, container, false);
refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_list);
recyclerView = (RecyclerView) view.findViewById(R.id.base_list);
writePanel = (RelativeLayout) view.findViewById(R.id.comment_write_panel);
messageField = (EditText) view.findViewById(R.id.message_field);
sendContainer = (FrameLayout) view.findViewById(R.id.send_container);
buttonSend = (AppCompatImageButton) view.findViewById(R.id.button_send);
progressBarSend = (ProgressBar) view.findViewById(R.id.send_progress);
additionalContent = (ViewGroup) view.findViewById(R.id.additional_content);
refreshLayout.setProgressBackgroundColorSchemeColor(App.getColorFromAttr(getContext(), R.attr.colorPrimary));
refreshLayout.setColorSchemeColors(App.getColorFromAttr(getContext(), R.attr.colorAccent));
refreshLayout.setOnRefreshListener(() -> {
refreshLayout.setRefreshing(true);
RxApi.NewsList().getDetails(article.getId()).map(page -> {
Comment commentTree = Api.NewsApi().updateComments(article, page);
article.setCommentTree(commentTree);
return Api.NewsApi().commentsToList(article.getCommentTree());
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(comments -> {
refreshLayout.setRefreshing(false);
createFunny(comments);
adapter.addAll(comments);
});
});
recyclerView.setBackgroundColor(App.getColorFromAttr(getContext(), R.attr.background_for_lists));
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setHasFixedSize(true);
recyclerView.addItemDecoration(new BrandFragment.SpacingItemDecoration(App.px12, false));
adapter = new ArticleCommentsAdapter();
adapter.setClickListener(this);
Observable.fromCallable(() -> {
if (article.getCommentTree() == null) {
Comment commentTree = Api.NewsApi().parseComments(article.getKarmaMap(), article.getCommentsSource());
article.setCommentTree(commentTree);
}
return Api.NewsApi().commentsToList(article.getCommentTree());
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(comments -> {
createFunny(comments);
adapter.addAll(comments);
if (article.getCommentId() > 0) {
for (int i = 0; i < comments.size(); i++) {
if (comments.get(i).getId() == article.getCommentId()) {
recyclerView.scrollToPosition(i);
break;
}
}
}
});
recyclerView.setAdapter(adapter);
messageField.addTextChangedListener(new SimpleTextWatcher() {
@Override
public void afterTextChanged(Editable s) {
if (s.length() == 0) {
currentReplyComment = null;
}
buttonSend.setClickable(s.length() > 0);
}
});
buttonSend.setOnClickListener(v -> sendComment());
if (ClientHelper.getAuthState()) {
writePanel.setVisibility(View.VISIBLE);
} else {
writePanel.setVisibility(View.GONE);
}
ClientHelper.get().addLoginObserver(loginObserver);
contentController = new ContentController(null, additionalContent, refreshLayout);
return view;
}
Aggregations