|
|
@@ -34,15 +34,14 @@ public class FAQListFragment extends Fragment {
|
|
|
private RecyclerView expandableListViewFaq;
|
|
|
|
|
|
private List<FAQBean> faqBeans;
|
|
|
- private IFAQListFragmentListener listener;
|
|
|
+ private IFAQListFragmentDelegate delegate;
|
|
|
private int index;
|
|
|
|
|
|
- public void setListener(IFAQListFragmentListener listener) {
|
|
|
- this.listener = listener;
|
|
|
+ public void setDelegate(IFAQListFragmentDelegate delegate) {
|
|
|
+ this.delegate = delegate;
|
|
|
}
|
|
|
|
|
|
public static FAQListFragment newInstance(int index) {
|
|
|
-
|
|
|
FAQListFragment fragment = new FAQListFragment();
|
|
|
Bundle args = new Bundle();
|
|
|
args.putInt(PARAM_INDEX, index);
|
|
|
@@ -67,22 +66,30 @@ public class FAQListFragment extends Fragment {
|
|
|
@Override
|
|
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
|
|
super.onViewCreated(view, savedInstanceState);
|
|
|
+
|
|
|
+ expandableListViewFaq = view.findViewById(R.id.expandable_list_view_faq);
|
|
|
+ expandableListViewFaq.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
|
|
+ expandableListViewFaq.addItemDecoration(new RecyclerView.ItemDecoration() {
|
|
|
+ @Override
|
|
|
+ public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
|
|
+ super.getItemOffsets(outRect, view, parent, state);
|
|
|
+ outRect.bottom = ResourceUtil.dpToPx(12);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onStart() {
|
|
|
super.onStart();
|
|
|
|
|
|
- listener.onInit(this, this.index);
|
|
|
+ delegate.onInit(this, this.index);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void setUserVisibleHint(boolean isVisibleToUser) {
|
|
|
super.setUserVisibleHint(isVisibleToUser);
|
|
|
|
|
|
- if (isVisibleToUser) {
|
|
|
- }
|
|
|
- else {
|
|
|
+ if (isVisibleToUser == false) {
|
|
|
if (null != expandableListViewFaq) {
|
|
|
expandableListViewFaq.scrollToPosition(0);
|
|
|
}
|
|
|
@@ -95,23 +102,13 @@ public class FAQListFragment extends Fragment {
|
|
|
* @param beans
|
|
|
*/
|
|
|
public void init(List<FAQBean> beans) {
|
|
|
- View view = getView();
|
|
|
- expandableListViewFaq = view.findViewById(R.id.expandable_list_view_faq);
|
|
|
- expandableListViewFaq.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
|
|
faqBeans = beans;
|
|
|
|
|
|
FAQExpandableListViewAdapter adapter = new FAQExpandableListViewAdapter(faqBeans);
|
|
|
expandableListViewFaq.setAdapter(adapter);
|
|
|
- expandableListViewFaq.addItemDecoration(new RecyclerView.ItemDecoration() {
|
|
|
- @Override
|
|
|
- public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
|
|
- super.getItemOffsets(outRect, view, parent, state);
|
|
|
- outRect.bottom = ResourceUtil.dpToPx(12);
|
|
|
- }
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
- interface IFAQListFragmentListener {
|
|
|
+ interface IFAQListFragmentDelegate {
|
|
|
void onInit(FAQListFragment faqListFragment, int category);
|
|
|
}
|
|
|
}
|