use of ingage.ingage20.adapters.ThreadListAdapter in project iNGAGE by davis123123.
the class FrontPageFragment 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();
postThreadButton = (FloatingActionButton) rootView.findViewById(R.id.fab);
postThreadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (v == postThreadButton) {
// goInsertThread();
session.updatePage("date");
/* initilize FrontPage Fragment*/
final FragmentManager fragmentManager = getFragmentManager();
final Class fragmentClass = FrontPageFragment.class;
final Fragment fragment = Fragment.instantiate(getContext(), fragmentClass.getName());
fragmentManager.beginTransaction().replace(R.id.main_fragment_container, fragment, fragmentClass.getSimpleName()).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit();
Toast.makeText(getActivity(), "Page refreshed!", Toast.LENGTH_LONG).show();
}
}
});
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
}
}
}
});
}
use of ingage.ingage20.adapters.ThreadListAdapter in project iNGAGE by davis123123.
the class FrontPageFragment 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());
getThreadsJSON(rowCount);
rootView = inflater.inflate(R.layout.fragment_front_page, container, false);
rootView.setTag(TAG);
return rootView;
}
use of ingage.ingage20.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());
getThreadsJSON(rowCount);
rootView = inflater.inflate(R.layout.fragment_front_page, container, false);
rootView.setTag(TAG);
return rootView;
}
use of ingage.ingage20.adapters.ThreadListAdapter in project iNGAGE by davis123123.
the class CategoriesPageFragment method onViewCreated.
@Override
public void onViewCreated(final View view, final Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// TODO fix threadlistadapter for dynamic threads
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();
postThreadButton = (FloatingActionButton) rootView.findViewById(R.id.fab);
postThreadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (v == postThreadButton) {
// goInsertThread();
session.updatePage("date");
/* initilize FrontPage Fragment*/
final FragmentManager fragmentManager = getFragmentManager();
final Class fragmentClass = FrontPageFragment.class;
final Fragment fragment = Fragment.instantiate(getContext(), fragmentClass.getName());
fragmentManager.beginTransaction().replace(R.id.main_fragment_container, fragment, fragmentClass.getSimpleName()).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit();
Toast.makeText(getActivity(), "Filters have been removed, returned to lobby!", Toast.LENGTH_LONG).show();
}
}
});
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();
}
}
});
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
}
}
}
});
}
use of ingage.ingage20.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);
threadListAdapter = new ThreadListAdapter(this, getActivity());
getThreadsJSON(rowCount, searchString);
rootView = inflater.inflate(R.layout.fragment_front_page, container, false);
rootView.setTag(TAG);
return rootView;
}
Aggregations