Guest User

Untitled

a guest
May 23rd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. public class BaseFragment extends Fragment {
  2.  
  3. protected SwipeRefreshLayout swipeContainer;
  4. protected ContentLoadingProgressBar progressBar;
  5. protected TextView emptyListMsg;
  6. protected RecyclerView recyclerView;
  7.  
  8.  
  9. @Override
  10. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  11.  
  12. View view = inflater.inflate(R.layout.list_layout_default, container, false);
  13. Log.d("check_meg", "BaseFragment");
  14. swipeContainer = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);
  15. swipeContainer.setColorSchemeResources(android.R.color.holo_red_light);
  16.  
  17. recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
  18. LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
  19. layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
  20. recyclerView.setLayoutManager(layoutManager);
  21. recyclerView.setHasFixedSize(true);
  22. recyclerView.setNestedScrollingEnabled(false);
  23.  
  24. emptyListMsg = (TextView) view.findViewById(R.id.empty_list_msg);
  25. progressBar = (ContentLoadingProgressBar) view.findViewById(R.id.pb_wait);
  26.  
  27. return view;
  28. }
  29.  
  30. <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
  31. android:layout_width="match_parent"
  32. android:id="@+id/swipe_container"
  33. android:layout_height="match_parent">
  34.  
  35. <RelativeLayout
  36. android:layout_width="match_parent"
  37. android:layout_height="match_parent">
  38.  
  39. <android.support.v4.widget.ContentLoadingProgressBar
  40. android:id="@+id/pb_wait"
  41. style="?android:attr/progressBarStyleLarge"
  42. android:layout_width="32dp"
  43. android:layout_height="32dp"
  44. android:layout_centerInParent="true"
  45. android:indeterminate="true"
  46. android:indeterminateDrawable="@drawable/progress"
  47. android:visibility="gone"/>
  48.  
  49. <TextView
  50. android:id="@+id/empty_list_msg"
  51. android:layout_width="wrap_content"
  52. android:layout_height="wrap_content"
  53. android:layout_centerInParent="true"
  54. android:textSize="@dimen/title_text_size"
  55. android:text="first text"
  56. />
  57.  
  58. <android.support.v4.widget.NestedScrollView
  59. android:layout_width="match_parent"
  60. android:layout_height="match_parent"
  61. android:scrollbarFadeDuration="2"
  62. android:scrollbars="vertical">
  63.  
  64. <android.support.v7.widget.RecyclerView
  65. android:id="@+id/recycler_view"
  66. android:layout_width="match_parent"
  67. android:layout_height="match_parent" />
  68.  
  69. </android.support.v4.widget.NestedScrollView>
  70.  
  71. </RelativeLayout>
  72.  
  73. public class TalkFragment extends BaseFragment {
  74.  
  75.  
  76. public TalkFragment() {
  77. // Required empty public constructor
  78. }
  79.  
  80.  
  81. @Override
  82. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  83. super.onCreateView(inflater, container, savedInstanceState);
  84. View view = inflater.inflate(R.layout.fragment_talk, container, false);
  85.  
  86. ((Button) view.findViewById(R.id.button)).setText("updated button");
  87. Log.d("check_meg", "TalkFragment");
  88. emptyListMsg.setText("updated text");
  89. emptyListMsg.setVisibility(View.VISIBLE);
  90. Toast.makeText(getContext(), emptyListMsg.getText().toString(), Toast.LENGTH_SHORT).show();
  91. return view;
  92. }
  93.  
  94. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  95. xmlns:tools="http://schemas.android.com/tools"
  96. android:layout_width="match_parent"
  97. android:layout_height="match_parent"
  98. android:orientation="vertical"
  99. tools:context=".fragment.TalkFragment">
  100.  
  101. <include
  102. android:layout_width="match_parent"
  103. android:layout_height="0dp"
  104. android:layout_weight="1"
  105. android:id="@+id/initial_layout"
  106. layout="@layout/list_layout_default" />
Add Comment
Please, Sign In to add comment