Search in sources :

Example 1 with ImagePickerUtil

use of in.testpress.testpress.util.ImagePickerUtil in project android by testpress.

the class PostActivity method displayComments.

void displayComments() {
    commentsAdapter = new CommentsListAdapter(this);
    listView.setNestedScrollingEnabled(false);
    listView.setLayoutManager(new LinearLayoutManager(this));
    listView.setAdapter(commentsAdapter);
    loadPreviousCommentsLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            loadPreviousCommentsLayout.setVisibility(View.GONE);
            getSupportLoaderManager().restartLoader(PREVIOUS_COMMENTS_LOADER_ID, null, PostActivity.this);
        }
    });
    loadNewCommentsLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            loadNewCommentsLayout.setVisibility(View.GONE);
            getSupportLoaderManager().restartLoader(NEW_COMMENTS_LOADER_ID, null, PostActivity.this);
        }
    });
    newCommentsAvailableLabel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            newCommentsAvailableLabel.setVisibility(View.GONE);
            scrollView.post(new Runnable() {

                @Override
                public void run() {
                    scrollView.fullScroll(View.FOCUS_DOWN);
                }
            });
        }
    });
    scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {

        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            int scrollViewHeight = scrollView.getHeight();
            int totalScrollViewChildHeight = scrollView.getChildAt(0).getHeight();
            // Let's assume end has reached at 50 pixels before itself(on partial visible of last item)
            boolean endHasBeenReached = (scrollY + scrollViewHeight + 50) >= totalScrollViewChildHeight;
            if (endHasBeenReached) {
                newCommentsAvailableLabel.setVisibility(View.GONE);
            }
        }
    });
    imagePickerUtil = new ImagePickerUtil(activityRootLayout, this);
    commentsLayout.setVisibility(View.VISIBLE);
    getSupportLoaderManager().initLoader(PREVIOUS_COMMENTS_LOADER_ID, null, PostActivity.this);
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) NestedScrollView(android.support.v4.widget.NestedScrollView) InjectView(butterknife.InjectView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) NestedScrollView(android.support.v4.widget.NestedScrollView) RecyclerView(android.support.v7.widget.RecyclerView) SuppressLint(android.annotation.SuppressLint) ImagePickerUtil(in.testpress.testpress.util.ImagePickerUtil)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 NestedScrollView (android.support.v4.widget.NestedScrollView)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 WebView (android.webkit.WebView)1 TextView (android.widget.TextView)1 InjectView (butterknife.InjectView)1 ImagePickerUtil (in.testpress.testpress.util.ImagePickerUtil)1