Search in sources :

Example 1 with ThreadListAdapter

use of ingage.ingage.adapters.ThreadListAdapter in project iNGAGE by davis123123.

the class CategoriesPageFragment method create.

public View create(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    Log.d("ROWCOUNT", "num" + rowCount);
    threadListAdapter = new ThreadListAdapter(this, getActivity(), true);
    rowCount = 0;
    getThreadsJSON(rowCount);
    rootView = inflater.inflate(R.layout.fragment_archived, container, false);
    rootView.setTag(TAG);
    return rootView;
}
Also used : ThreadListAdapter(ingage.ingage.adapters.ThreadListAdapter)

Example 2 with ThreadListAdapter

use of ingage.ingage.adapters.ThreadListAdapter in project iNGAGE by davis123123.

the class SearchResultFragment method create.

public View create(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    session = new SessionManager(getContext());
    HashMap<String, String> user = session.getUserDetails();
    searchString = user.get(SessionManager.SEARCH_STRING);
    Log.d("STATE", "searchstring " + searchString);
    rowCount = 0;
    threadListAdapter = new ThreadListAdapter(this, getActivity(), true);
    getThreadsJSON(rowCount, searchString);
    rootView = inflater.inflate(R.layout.fragment_archived, container, false);
    rootView.setTag(TAG);
    return rootView;
}
Also used : SessionManager(ingage.ingage.managers.SessionManager) ThreadListAdapter(ingage.ingage.adapters.ThreadListAdapter)

Example 3 with ThreadListAdapter

use of ingage.ingage.adapters.ThreadListAdapter in project iNGAGE by davis123123.

the class ArchivedFragment method onViewCreated.

@Override
public void onViewCreated(final View view, final Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    threadListRecyclerView = (RecyclerView) rootView.findViewById(R.id.rv_posts);
    final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    threadListRecyclerView.setLayoutManager(layoutManager);
    threadListRecyclerView.setAdapter(threadListAdapter);
    Log.d("STATE", "serverstring" + json_string);
    inflateThreads();
    threadListAdapter.setOnLoadMoreListener(new ThreadListAdapter.OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
            Log.d("haint", "Load More");
            // threadListAdapter.list.add(null);
            // threadListAdapter.notifyItemInserted(threadListAdapter.list.size() - 1);
            rowCount += 10;
            Thread getJSON = new Thread(new Runnable() {

                @Override
                public void run() {
                    getThreadsJSON(rowCount);
                    while (true) {
                        if (!threadListAdapter.getLoadStat()) {
                            Log.d("haint", "Load More222");
                            break;
                        }
                    // no longer loading
                    }
                }
            });
            getJSON.start();
            try {
                getJSON.join();
                // threadListAdapter.list.remove(threadListAdapter.list.size() - 1);
                // threadListAdapter.notifyItemRemoved(threadListAdapter.list.size());
                inflateThreads();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        // getThreadsJSON(rowCount);
        // inflateThreads();
        /*new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        Log.e("haint", "Load More 2");
                        threadListAdapter.list.remove(threadListAdapter.list.size() - 1);
                        threadListAdapter.notifyItemRemoved(threadListAdapter.list.size());
                        rowCount += 10;
                        getThreadsJSON(rowCount);
                        inflateThreads();
                        threadListAdapter.setLoaded();
                    }
                }, 10000);*/
        }
    });
    threadListRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            Log.d("...", "Lastnot Item Wow !");
            if (// check for scroll down
            dy > 0) {
                visibleItemCount = layoutManager.getChildCount();
                totalItemCount = layoutManager.getItemCount();
                pastVisiblesItems = layoutManager.findFirstVisibleItemPosition();
                if (!threadListAdapter.isLoading && (visibleItemCount + pastVisiblesItems) >= totalItemCount) {
                    // if(mOnLoadMoreListener != null){
                    Log.d("...", "Last Item Wow !");
                    threadListAdapter.isLoading = true;
                    // threadListAdapter.list.add(null);
                    threadListAdapter.mOnLoadMoreListener.onLoadMore();
                // }
                // loading = false;
                // rowCount += 10;
                // getThreadsJSON(rowCount);
                // inflateThreads();
                // Do pagination.. i.e. fetch new data
                }
            }
        }
    });
}
Also used : ThreadListAdapter(ingage.ingage.adapters.ThreadListAdapter) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 4 with ThreadListAdapter

use of ingage.ingage.adapters.ThreadListAdapter in project iNGAGE by davis123123.

the class ArchivedFragment method create.

public View create(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    threadListAdapter = new ThreadListAdapter(this, getActivity(), false);
    rowCount = 0;
    getThreadsJSON(rowCount);
    rootView = inflater.inflate(R.layout.fragment_archived, container, false);
    rootView.setTag(TAG);
    return rootView;
}
Also used : ThreadListAdapter(ingage.ingage.adapters.ThreadListAdapter)

Example 5 with ThreadListAdapter

use of ingage.ingage.adapters.ThreadListAdapter in project iNGAGE by davis123123.

the class SearchResultArchivedFragment method create.

public View create(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    session = new SessionManager(getContext());
    HashMap<String, String> user = session.getUserDetails();
    searchString = user.get(SessionManager.SEARCH_STRING);
    Log.d("STATE", "searchstring " + searchString);
    rowCount = 0;
    threadListAdapter = new ThreadListAdapter(this, getActivity(), false);
    getThreadsJSON(rowCount, searchString);
    rootView = inflater.inflate(R.layout.fragment_archived, container, false);
    rootView.setTag(TAG);
    return rootView;
}
Also used : SessionManager(ingage.ingage.managers.SessionManager) ThreadListAdapter(ingage.ingage.adapters.ThreadListAdapter)

Aggregations

ThreadListAdapter (ingage.ingage.adapters.ThreadListAdapter)8 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 RecyclerView (android.support.v7.widget.RecyclerView)4 SessionManager (ingage.ingage.managers.SessionManager)2