content: /*
   * Copyright (C) 2017 MINDORKS NEXTGEN PRIVATE LIMITED
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     https://mindorks.com/license/apache-v2
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License
   */
  
  package <%= appPackage %>.ui.feed.opensource;
  
  import android.os.Bundle;
  import android.support.annotation.Nullable;
  import android.support.v7.widget.DefaultItemAnimator;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  import <%= appPackage %>.R;
  import <%= appPackage %>.data.network.model.OpenSourceResponse;
  import <%= appPackage %>.di.component.ActivityComponent;
  import <%= appPackage %>.ui.base.BaseFragment;
  
  import java.util.List;
  
  import javax.inject.Inject;
  
  import butterknife.BindView;
  import butterknife.ButterKnife;
  
  /**
   * Created by janisharali on 25/05/17.
   */
  
  public class OpenSourceFragment extends BaseFragment implements
          OpenSourceMvpView, OpenSourceAdapter.Callback {
  
      private static final String TAG = "OpenSourceFragment";
  
      @Inject
      OpenSourceMvpPresenter<OpenSourceMvpView> mPresenter;
  
      @Inject
      OpenSourceAdapter mOpenSourceAdapter;
  
      @Inject
      LinearLayoutManager mLayoutManager;
  
      @BindView(R.id.repo_recycler_view)
      RecyclerView mRecyclerView;
  
      public static OpenSourceFragment newInstance() {
          Bundle args = new Bundle();
          OpenSourceFragment fragment = new OpenSourceFragment();
          fragment.setArguments(args);
          return fragment;
      }
  
      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                               @Nullable Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.fragment_open_source, container, false);
  
          ActivityComponent component = getActivityComponent();
          if (component != null) {
              component.inject(this);
              setUnBinder(ButterKnife.bind(this, view));
              mPresenter.onAttach(this);
              mOpenSourceAdapter.setCallback(this);
          }
          return view;
      }
  
      @Override
      protected void setUp(View view) {
          mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
          mRecyclerView.setLayoutManager(mLayoutManager);
          mRecyclerView.setItemAnimator(new DefaultItemAnimator());
          mRecyclerView.setAdapter(mOpenSourceAdapter);
  
          mPresenter.onViewPrepared();
      }
  
      @Override
      public void onRepoEmptyViewRetryClick() {
  
      }
  
      @Override
      public void updateRepo(List<OpenSourceResponse.Repo> repoList) {
          mOpenSourceAdapter.addItems(repoList);
      }
  
      @Override
      public void onDestroyView() {
          mPresenter.onDetach();
          super.onDestroyView();
      }
  }
  