title: What is the best practice around inheriting a custom fragment
body: <p>I'm making an Reddit app for my android exam and I have a question about inheritence.</p>
  
  <p>I have a Fragment who has a RecyclerView. That recyclerview contains a list of redditposts. My app consists of multiple subreddits (funny, gaming, news, etc..). Every subreddit has his own Fragment. I have some methods that every Fragment has to have. (a showProgressBar, hideProgressBar, populateResult, etc...) I think it would be simple if i just make an Fragment class where all the subreddit Fragments can inheritance from. I could put all the methods in that fragment class because the methods are the same for every subreddit fragment. But my lecturer said that is a bad use of inheritance. So does anybody have a best practice around this problem? </p>
  
  <p>This is the fragment i'm talking about:
  package com.example.thomas.redditapp;</p>
  
  <pre><code>public class FunnyFragment extends Fragment {
  
      private OnListFragmentInteractionListener mListener;
  
      @Bind(R.id.funny_recyclerview)
      RecyclerView mRecyclerView;
  
      @Bind(R.id.progressBarFetch)
      ProgressBar progress;
  
      private RedditHelper helper;
  
      private RedditPostRecyclerViewAdapter mAdapter;
  
      List&lt;RedditPost&gt; redditPosts;
  
      public FunnyFragment() {
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          helper = null;
          helper = new RedditHelper(SubRedditEnum.funny, this);
          redditPosts = new ArrayList&lt;&gt;();
          startLoad();
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.fragment_funny_list, container, false);
          ButterKnife.bind(this, view);
          showProgressBar();
  
          mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
  
          mAdapter = new RedditPostRecyclerViewAdapter(redditPosts, mListener, mRecyclerView);
  
          mAdapter.setOnLoadMoreListener(new OnLoadMoreListener() {
              @Override
              public void onLoadMore() {
                  redditPosts.add(null);
                  helper.loadListFromUrl();
              }
          });
  
          mRecyclerView.setAdapter(mAdapter);
  
  
  
          return view;
      }
  
      protected void startLoad() {
          if (helper != null) {
              helper.loadListFromDb();
          }
      }
  
      @Override
      public void onActivityCreated(Bundle savedInstanceState) {
          if (isTaskRunning()) {
              showProgressBar();
          } else {
              hideProgressBar();
          }
          super.onActivityCreated(savedInstanceState);
  
      }
  
      public void hideProgressBar() {
          progress.setVisibility(View.GONE);
  
      }
  
      public void showProgressBar() {
          progress.setVisibility(View.VISIBLE);
          progress.setIndeterminate(true);
  
      }
  
      @Override
      public void onAttach(Context context) {
          super.onAttach(context);
          if (context instanceof OnListFragmentInteractionListener) {
              mListener = (OnListFragmentInteractionListener) context;
          } else {
              throw new RuntimeException(context.toString()
                      + " must implement OnListFragmentInteractionListener");
          }
      }
  
      @Override
      public void onDetach() {
          super.onDetach();
          mListener = null;
      }
  
      public void populateResult(List&lt;RedditPost&gt; result) {
          if(!redditPosts.isEmpty()){
              redditPosts.remove(redditPosts.size() - 1);
          }
          redditPosts.addAll(result);
          mAdapter.setLoaded();
          mAdapter.notifyDataSetChanged();
      }
  
      protected boolean isTaskRunning() {
          if (helper == null) {
              return false;
          } else if (helper.getStatus() == 0) {
              return false;
          } else {
              return true;
          }
      }
  }
  </code></pre>
  
  <p>I call the hideProgressBar(), showProgressBar() and populateResult() in my helper class. </p>