public static void recall() { ContactsHandler contactsHandler = new ContactsHandler(activity); List<ContactsHolder> holder = contactsHandler.getAllContacts(getDepartmentName(usn.substring(5, 7))); mAdapter = new RecyclerViewMaterialAdapter(new ContactsAdapter(holder)); mRecyclerView.setAdapter(mAdapter); hideNoPost(); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); activity = getActivity(); hideNoPost(); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(activity); mRecyclerView.setLayoutManager(layoutManager); mRecyclerView.setHasFixedSize(true); animator = new DefaultItemAnimator(); animator.setAddDuration(1000); /*View v = mRecyclerView.getChildAt(0); load_post= (RelativeLayout) v.findViewById(R.id.load_contact_layout); no_internet= (RelativeLayout) v.findViewById(R.id.connect_internet_layout); post_list= (RelativeLayout) v.findViewById(R.id.list_contact_items);*/ // Call to load posts from internet MaterialViewPagerHelper.registerRecyclerView(activity, mRecyclerView, null); mLayoutManager = new LinearLayoutManager(activity); mRecyclerView.setLayoutManager(mLayoutManager); final ContactsHandler contactsHandler = new ContactsHandler(activity); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext()); usn = preferences.getString("USN", "4MC13EC011"); if (contactsHandler.getAllPostsCount() > 150) { List<ContactsHolder> holder = contactsHandler.getAllContacts(getDepartmentName(usn.substring(5, 7))); mAdapter = new RecyclerViewMaterialAdapter(new ContactsAdapter(holder)); mRecyclerView.setAdapter(mAdapter); fab.setVisibility(View.VISIBLE); } else { showNoPost(true); fab.setVisibility(View.INVISIBLE); } fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Dialog.Builder builder = new SimpleDialog.Builder(R.style.SimpleDialogLight) { @Override public void onPositiveActionClicked(DialogFragment fragment) { List<ContactsHolder> holder = contactsHandler.getAllContacts( getDepartmentNameForBuilder(getSelectedValue().toString())); mAdapter = new RecyclerViewMaterialAdapter(new ContactsAdapter(holder)); mRecyclerView.setAdapter(mAdapter); super.onPositiveActionClicked(fragment); } @Override public void onNegativeActionClicked(DialogFragment fragment) { super.onNegativeActionClicked(fragment); } }; ((SimpleDialog.Builder) builder) .items( new String[] { "Electronics", "Computer Science", "Civil", "Mechanical", "Information Science", "Electrical", "Industrial Production", "Automobile", "E&I" }, 0) .title("Department") .positiveAction("OK") .negativeAction("CANCEL"); DialogFragment fragment = DialogFragment.newInstance(builder); fragment.setCancelable(true); fragment.show(getChildFragmentManager(), null); } }); contactsHandler.closeDB(); }