SHARE
TWEET

TvShow Fregment

a guest May 19th, 2019 96 in 144 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.dicoding.picodiploma.moviecatalogueuiux.ui.main;
  2.  
  3. import android.content.Context;
  4. import android.content.res.TypedArray;
  5. import android.net.Uri;
  6. import android.os.Bundle;
  7. import android.support.annotation.NonNull;
  8. import android.support.annotation.Nullable;
  9. import android.support.v4.app.Fragment;
  10. import android.support.v7.widget.LinearLayoutManager;
  11. import android.support.v7.widget.RecyclerView;
  12. import android.view.LayoutInflater;
  13. import android.view.View;
  14. import android.view.ViewGroup;
  15.  
  16. import com.dicoding.picodiploma.moviecatalogueuiux.R;
  17.  
  18. import java.util.ArrayList;
  19.  
  20. public class TvShowFragment extends Fragment {
  21.  
  22.     private RecyclerView rvCategory1;
  23.     private ArrayList<TvShow> list1 = new ArrayList<>();
  24.     private static String[] dataJudulTv;
  25.     private static String[] dataReleaseTv;
  26.     private static String[] dataRuntimeTv;
  27.     private static String[] dataOverviewTv;
  28.     private static TypedArray dataPhotoTv;
  29.  
  30.     public TvShowFragment() {
  31.         // Required empty public constructor
  32.     }
  33.  
  34.     @Override
  35.     public View onCreateView(LayoutInflater inflater, ViewGroup container,
  36.                              Bundle savedInstanceState) {
  37.         return inflater.inflate(R.layout.fragment_tv_show, container, false);
  38.     }
  39.  
  40.  
  41.     @Override
  42.     public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState){
  43.         super.onViewCreated(view, savedInstanceState);
  44.  
  45.         rvCategory1 = view.findViewById(R.id.rv_category1);
  46.         rvCategory1.setHasFixedSize(true);
  47.  
  48.         dataJudulTv= getResources().getStringArray(R.array.judul_tv);
  49.         dataReleaseTv = getResources().getStringArray(R.array.release_tv);
  50.         dataRuntimeTv = getResources().getStringArray(R.array.runtime_tv);
  51.         dataOverviewTv = getResources().getStringArray(R.array.overview_tv);
  52.         dataPhotoTv = getResources().obtainTypedArray(R.array.photo_tv);
  53.  
  54.  
  55.         for (int i = 0; i< dataJudulTv.length; i++){
  56.             TvShow tvShow = new TvShow();
  57.             tvShow.setJudulTv(dataJudulTv[i]);
  58.             tvShow.setReleaseTv(dataReleaseTv[i]);
  59.             tvShow.setRuntimeTv(dataRuntimeTv[i]);
  60.             tvShow.setOverviewTv(dataOverviewTv[i]);
  61.             tvShow.setPhotoTv(dataPhotoTv.getResourceId(i, -1));
  62.             list1.add(tvShow);
  63.         }
  64.         showRecyclerCardView();
  65.  
  66.     }
  67.  
  68.     private void showRecyclerCardView(){
  69.         rvCategory1.setLayoutManager(new LinearLayoutManager(getActivity()));
  70.         CardViewTvAdapter cardViewTvAdapter = new CardViewTvAdapter(getContext());
  71.         cardViewTvAdapter.setListTvShow(list1);
  72.         rvCategory1.setAdapter(cardViewTvAdapter);
  73.     }
  74.  
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top