Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
57 kB
4
Indexable
Never
public class BerandaManifest extends Fragment {
    private final String TAG = "FRAGMENT Manifest Passenger";
    ProgressBar mProgressBar;
    FragmentManager manager;
    TinyDB tinydb;
    String mTOKEN_LOGIN, mFCMTOKEN, mNIP, mNAMA, mTGLDepart, mTGLArrive, mNOKA, mNAMAKA, mSessDEVICEID, urlWEBService;
    String mPOSISI, mNO_CUSTOMER, mSINGKATAN, mPERSONAL_AREA, mSUB_PERSONAL_AREA,mUNIT, mIDUNIT;
//    String nomorWagon, KodeWagon;
//    private int mStatusCode=0;
    Spinner spinWagon, spinBerangkat, spinTujuan;
    private RecyclerView mRecylerView;
    ArrayList<String> arrKodeWagon                                      = new ArrayList<>();
    ArrayList<String> arrStOri                                          = new ArrayList<>();
    ArrayList<String> arrStDestination                                  = new ArrayList<>();

    ArrayList<item_relation> dataRelasiKereta                           = new ArrayList<>();
    ArrayList<item_passenger> dataPassengerSatuKereta                   = new ArrayList<>();
    ArrayList<item_wagon> dataWagonDanPassengerSatuKereta               = new ArrayList<item_wagon>();
    int JmlPenumpangSatuKereta= 0;
    int JmlPenumpangSatuWagon= 0;
    int JmlPenumpangSatuWagonDptTuslah= 0;
    int JmlPenumpangSatuWagonDptSelimut= 0;
    int JmlPenumpangSatuWagonVIP= 0;
    String strTxtInfoSatuWagon  ="";
    String strTxtInfoRelasi     = "";

//    int Baris, Kolom, KursiKolom1, KursiKolom2, KursiKolom3, Kapasitas;
//    private ArrayList<item_relation> mItemDataRelation = new ArrayList<item_relation>();
//    //private ArrayList<item_wagon> mItemDataWagon = new ArrayList<item_wagon>();
//    private ArrayList<String> strWagonName = new ArrayList<String>();
//    private ArrayList<String> strStamformdetcode = new ArrayList<>();
//    private ArrayList<String> strBerangkat  = new ArrayList<String>();
//    private ArrayList<String> strTujuan     = new ArrayList<String>();

//    ArrayList<String> arrKodeWagon                                      = new ArrayList<>();
//    ArrayList<String> arrStOri                                          = new ArrayList<>();
//    ArrayList<String> arrStDestination                                  = new ArrayList<>();
//
//    ArrayList<item_relation> dataRelasiKereta                           = new ArrayList<>();
//    ArrayList<item_passenger> dataPassengerSatuKereta                   = new ArrayList<>();
//    ArrayList<item_wagon> dataWagonDanPassengerSatuKereta               = new ArrayList<item_wagon>();

    TextView txtInfoKereta, txtRelasi, txtInfoJumlahPenumpang;
    //private ArrayList<ArrayList<item_tempatduduk>> peta_tempatduduk = new ArrayList<>();
    Button mBtnTampilkan;
    ImageView btnManifest, btnTuslah, btnSelimut, btnRekon;

    adapter_wagon mAdapter;
    private Context contextNullSafe;
    String abj_col1x2[] = {"A", "X", "C", "D"};
    String abj_col2x1[] = {"A", "B", "X", "D"};
    String abj_col2x2[] = {"A", "B", "X", "C", "D"};
    String abj_col2x3[] = {"A", "B", "X", "C", "D","E"};
    String abj_col3x2[] = {"A", "B", "C", "X", "D","E"};

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        final View rootView = inflater.inflate(R.layout.fragment_beranda_manifest, container, false);
        //mContext            = getActivity();
        EventBus.getDefault().register(this);
        Bundle bundle = getArguments();
        arrKodeWagon                    = bundle.getStringArrayList("DATA_KODEWAGON");
        arrStOri                        = bundle.getStringArrayList("DATA_STORI");
        arrStDestination                = bundle.getStringArrayList("DATA_STDESTINATION");
        dataRelasiKereta                = bundle.getParcelableArrayList("DATA_RELASIKERETA");
        dataPassengerSatuKereta         = bundle.getParcelableArrayList("DATA_PENUMPANGSATUKERETA");
        dataWagonDanPassengerSatuKereta = bundle.getParcelableArrayList("DATAWAGON_DAN_PENUMPANGSATUKERETA");

        strTxtInfoSatuWagon = "Jml Pnp Kereta: "+String.valueOf(dataPassengerSatuKereta.size());

        //dbLokal = AppDatabase.getDatabase(getContextNullSafety());
        tinydb = new TinyDB(getContextNullSafety());
        urlWEBService       = getString(R.string.api_trainmart);
        mSessDEVICEID       = tinydb.getString("SESS_DEVICE_ID");
        mNIP                = tinydb.getString("SESS_NIP");
        mNAMA               = tinydb.getString("SESS_NAMA");
        mNOKA               = tinydb.getString("SESS_NOKA");
        mNAMAKA             = tinydb.getString("SESS_NAMAKA");
        mTOKEN_LOGIN        = tinydb.getString("SESS_TOKEN_LOGIN");
        mFCMTOKEN           = tinydb.getString("SESS_TOKEN_FIREBASE");
        mPOSISI             = tinydb.getString("SESS_POSISI");
        mSINGKATAN          = tinydb.getString("SESS_SINGKATAN");
        mPERSONAL_AREA      = tinydb.getString("SESS_PERSONAL_AREA");
        mSUB_PERSONAL_AREA  = tinydb.getString("SESS_SUB_PERSONAL_AREA");
        mUNIT               = tinydb.getString("SESS_UNIT");
        mIDUNIT             = tinydb.getString("SESS_ID_UNIT");
        mTGLDepart          = tinydb.getString("SESS_TGLTRIP");
        mTGLArrive          = tinydb.getString("SESS_TGLARRIVE");
        mNO_CUSTOMER        = tinydb.getString("SESS_NO_CUSTOMER");

        mProgressBar            = rootView.findViewById(R.id.objProgressBarManifest);
        mProgressBar.setVisibility(View.INVISIBLE);
        txtInfoKereta           = rootView.findViewById(R.id.nomor_kereta);
        txtRelasi               = rootView.findViewById(R.id.relasi);
        txtInfoJumlahPenumpang  = rootView.findViewById(R.id.infoPenumpang);

        spinWagon           = rootView.findViewById(R.id.spinner_wagon);
        if (arrKodeWagon.size()>0){
            ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(getContextNullSafety(), simple_spinner_item, arrKodeWagon);
            spinnerArrayAdapter.setDropDownViewResource(R.layout.template_spinner); // The drop down view
            spinWagon.setAdapter(spinnerArrayAdapter);
        }
        spinBerangkat       = rootView.findViewById(R.id.spinner_berangkat);
        if (arrStOri.size()>0){
            ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(getContextNullSafety(), simple_spinner_item, arrStOri);
            spinnerArrayAdapter.setDropDownViewResource(R.layout.template_spinner); // The drop down view
            spinBerangkat.setAdapter(spinnerArrayAdapter);
        }
        spinTujuan          = rootView.findViewById(R.id.spinner_tujuan);
        if (arrStDestination.size()>0){
            ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(getContextNullSafety(), simple_spinner_item, arrStDestination);
            spinnerArrayAdapter.setDropDownViewResource(R.layout.template_spinner); // The drop down view
            spinTujuan.setAdapter(spinnerArrayAdapter);
        }

        mBtnTampilkan       = rootView.findViewById(R.id.btncari);
        btnManifest         = rootView.findViewById(R.id.fragManifest);
        //btnManifest FREEZE
        btnTuslah           = rootView.findViewById(R.id.fragtuslah);
        btnTuslah.setVisibility(GONE);
        btnTuslah.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                GetManiFestPenumpang("TUSLAH");
//                if (dataWagonDanPassengerSatuKereta.size()>0){
//                    bundle.putStringArrayList("DATA_STORI",arrStOri);
//                    bundle.putStringArrayList("DATA_STDESTINATION",arrStDestination);
//                    bundle.putStringArrayList("DATA_KODEWAGON",arrKodeWagon);
//
//                    bundle.putParcelableArrayList("DATA_RELASIKERETA", dataRelasiKereta);
//                    bundle.putParcelableArrayList("DATA_PENUMPANGSATUKERETA", dataPassengerSatuKereta);
//                    bundle.putParcelableArrayList("DATAWAGON_DAN_PENUMPANGSATUKERETA", dataWagonDanPassengerSatuKereta);
//                    Fragment gantiFragment = new PembagianTuslah();
//                    getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_utama, gantiFragment).commit();
//                }else{
//                    Toasty.error(getContextNullSafety(), "Data Wagon dan Passenger tidak ditemukan!, Coba klik kembali!", Toast.LENGTH_SHORT, true).show();
//                }
            }
        });
        btnSelimut          = rootView.findViewById(R.id.fragSelimut);
        btnSelimut.setVisibility(GONE);
        btnSelimut.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                GetManiFestPenumpang("SELIMUT");
//                if (dataWagonDanPassengerSatuKereta.size()>0){
//                    bundle.putStringArrayList("DATA_STORI",arrStOri);
//                    bundle.putStringArrayList("DATA_STDESTINATION",arrStDestination);
//                    bundle.putStringArrayList("DATA_KODEWAGON",arrKodeWagon);
//
//                    bundle.putParcelableArrayList("DATA_RELASIKERETA", dataRelasiKereta);
//                    bundle.putParcelableArrayList("DATA_PENUMPANGSATUKERETA", dataPassengerSatuKereta);
//                    bundle.putParcelableArrayList("DATAWAGON_DAN_PENUMPANGSATUKERETA", dataWagonDanPassengerSatuKereta);
//                    Fragment gantiFragment = new PembagianSelimut();
//                    getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_utama, gantiFragment).commit();
//                }else{
//                    Toasty.error(getContextNullSafety(), "Data Wagon dan Passenger tidak ditemukan!, Coba klik kembali!", Toast.LENGTH_SHORT, true).show();
//                }
            }
        });
        btnRekon            = rootView.findViewById(R.id.fragRekon);
        btnRekon.setVisibility(GONE);
        btnRekon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Fragment gantiFragment = new RekonTuslahFragment();
                getActivityNullSafety().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_utama, gantiFragment).commit();
            }
        });
        mRecylerView        = rootView.findViewById(R.id.recycleInfoWagon);
        mRecylerView.setHasFixedSize(true);
        mRecylerView.setLayoutManager(new LinearLayoutManager(getContextNullSafety()));

        txtInfoKereta.setText("KA: "+mNAMAKA+" ("+mNOKA+")");
        strTxtInfoRelasi = "Depart: "+mTGLDepart;
        txtRelasi.setText(strTxtInfoRelasi);
        txtInfoJumlahPenumpang.setText(strTxtInfoSatuWagon);

        mBtnTampilkan.setOnClickListener(new View.OnClickListener() {
            @RequiresApi(api = Build.VERSION_CODES.N)
            @Override
            public void onClick(View v) {
                int dipilihNoWagon          = spinWagon.getSelectedItemPosition();
                String stBerangkat          = arrStOri.get(spinBerangkat.getSelectedItemPosition());
                String stTujuan             = arrStDestination.get(spinTujuan.getSelectedItemPosition());
                String stamformdetcode      = arrKodeWagon.get(dipilihNoWagon);
                ArrayList<item_passenger> arrPassengerSatuWagon    = dataWagonDanPassengerSatuKereta.get(dipilihNoWagon).getDataPassengerSatuWagon();
                String infotambahanRelasi   = ", Naik: "+stBerangkat+", Turun: "+stTujuan;
                /FILTER DATA PENUMPANG/
                List<item_passenger> dataPnpYgHrsDptTuslah = arrPassengerSatuWagon.stream()
                        .filter(b -> b.getTuslah() == true)
                        .collect(Collectors.toList());
                List<item_passenger> dataPnpYgHrsDptSelimut = arrPassengerSatuWagon.stream()
                        .filter(b -> b.getSelimut() == true)
                        .collect(Collectors.toList());
                List<item_passenger> dataPnpVIP = arrPassengerSatuWagon.stream()
                        .filter(b -> b.getPenumpangVIP() == true)
                        .collect(Collectors.toList());
                List<item_passenger> dataDobelSeat = arrPassengerSatuWagon.stream()
                        .filter(b -> b.getDoubleseat() == true)
                        .collect(Collectors.toList());
                List<item_passenger> dataPnpNaikTurun = new ArrayList<>();
                if (stBerangkat.equals("-any-") && stTujuan.equals("-any-") ){
                    //Jika Brgkt Terserah dan Tujuan Terserah
                    dataPnpNaikTurun = arrPassengerSatuWagon.stream()
                            .filter(b -> (!b.getStationOri().equals(stBerangkat) && !b.getStationDes().equals(stTujuan)))
                            .collect(Collectors.toList());
                }else if ((stBerangkat.equals("-any-")) && !stTujuan.equals("-any-")){
                    //Jika Brgkt Terserah dan Tujuan sesuai yg dipilih
                    dataPnpNaikTurun = arrPassengerSatuWagon.stream()
                            .filter(b -> (!b.getStationOri().equals(stBerangkat) && b.getStationDes().equals(stTujuan)))
                            .collect(Collectors.toList());
                }else if (!(stBerangkat.equals("-any-")) && stTujuan.equals("-any-")){
                    //Jika Brgkt sesuai yg dipilih dan Tujuan Terserah
                    dataPnpNaikTurun = arrPassengerSatuWagon.stream()
                            .filter(b -> (b.getStationOri().equals(stBerangkat) && !b.getStationDes().equals(stTujuan)))
                            .collect(Collectors.toList());
                }else{
                    //Jika Brgkt dan Tujuan harus sama 2-2nya dgn yg dipilih
                    dataPnpNaikTurun = arrPassengerSatuWagon.stream()
                            .filter(b -> (b.getStationOri().equals(stBerangkat) && b.getStationDes().equals(stTujuan)))
                            .collect(Collectors.toList());
                }

                int jmlPnpSatuWagon         = arrPassengerSatuWagon.size();
                int jmlPnpHrsDptTuslah      = dataPnpYgHrsDptTuslah.size();
                int jmlPnpHrsDptSelimut     = dataPnpYgHrsDptSelimut.size();
                int jmlPnpVIP               = dataPnpVIP.size();;
                int jmlPnpNaikTurun         = dataPnpNaikTurun.size();
                int jmlSeatDobelSeat        = dataDobelSeat.size();

                String infotambahanSatuWagon = "";
                String infotambahanTuslahSatuWagon = "";
                String infotambahanNaikTurunSatuWagon = "";
                String infotambahanDobelSeatSatuWagon = "";
                String infotambahanSelimutSatuWagon = "";
                String infotambahanVIPSatuWagon = "";

                txtRelasi.setText(strTxtInfoRelasi+infotambahanRelasi);

                //Tampilkan Ulang Perhitungan Penumpang dlm 1 WAGON
                if (jmlPnpSatuWagon!=0){
                    infotambahanSatuWagon  = "\nPnp Wagon ["+stamformdetcode+"]: "+String.valueOf(jmlPnpSatuWagon);
                }
                if (jmlPnpNaikTurun!=0){
                    infotambahanNaikTurunSatuWagon  = "\nPnp Naik "+stBerangkat+"/Turun "+stTujuan+": "+String.valueOf(jmlPnpNaikTurun);
                }
                if (jmlSeatDobelSeat!=0){
                    infotambahanDobelSeatSatuWagon  = "\nDobelSeat: "+String.valueOf(jmlSeatDobelSeat);
                }
                //if (jmlPnpHrsDptTuslah!=0){
                //    infotambahanTuslahSatuWagon  = "\nPnp hrs dpt Tuslah: "+String.valueOf(jmlPnpHrsDptTuslah);
                //}
                //if (jmlPnpHrsDptSelimut!=0){
                //    infotambahanSelimutSatuWagon  = "\nPnp hrs Selimut: "+String.valueOf(jmlPnpHrsDptSelimut);
                //}
                if (jmlPnpVIP!=0){
                    infotambahanVIPSatuWagon  = "\nPnp VIP: "+String.valueOf(jmlPnpVIP);
                }
                txtInfoJumlahPenumpang.setText(strTxtInfoSatuWagon+infotambahanSatuWagon+infotambahanNaikTurunSatuWagon+infotambahanDobelSeatSatuWagon+infotambahanTuslahSatuWagon+infotambahanSelimutSatuWagon+infotambahanVIPSatuWagon);

                /2. PENYUSUNAN GAMBARAN SUSUNAN TEMPAT DUDUK KERETA/
                int col1seats           = dataWagonDanPassengerSatuKereta.get(dipilihNoWagon).getCol1seats();
                int col2seats           = dataWagonDanPassengerSatuKereta.get(dipilihNoWagon).getCol2seats();
                int col3seats           = dataWagonDanPassengerSatuKereta.get(dipilihNoWagon).getCol3seats();
                int jmlCol              = dataWagonDanPassengerSatuKereta.get(dipilihNoWagon).getCols();
                int rows                = dataWagonDanPassengerSatuKereta.get(dipilihNoWagon).getRows();

                if ( (col1seats==1) && (col2seats==2) ){
                    jmlCol = 4; //Spasi 1
                    //abj_col1x2
                } else if ( (col1seats==2) && (col2seats==1) ) {
                    jmlCol = 4; //Spasi 1
                    //abj_col2x1
                } else if ( (col1seats==2) && (col2seats==2) ) {
                    jmlCol = 5; //Spasi 1
                    //abj_col2x2
                } else if ( (col1seats==2) && (col2seats==3) ) {
                    jmlCol = 6;
                    //abj_col2x3
                } else if ( (col1seats==3) && (col2seats==2) ) {
                    jmlCol = 6;
                    //abj_col3x2
                } else {
                    jmlCol = 6;
                    //abj_col3x2
                }

                /ISI DULU TEMPAT DUDUK YG SUDAH TERISI UTK DICOMPARE/
                List<String> tempatygterisi = new ArrayList<>();
                for (int booking = 0; booking < arrPassengerSatuWagon.size(); booking++) {
                    String noseat = arrPassengerSatuWagon.get(booking).getSeat();
                    tempatygterisi.add(noseat);
                }

                ArrayList<ArrayList<item_tempatduduk>> tmp_seat_satuwagon = new ArrayList<>();
                for (int r = 0; r < rows; r++) {
                    ArrayList<item_tempatduduk> tmp_seat_satubaris = new ArrayList<>();
                    String kodetempatduduk  = "";
                    Boolean lorong          = false;
                    Boolean ada_penumpang   = false;
                    Boolean penumpang_vip   = false;
                    Boolean tuslah          = false;
                    Boolean sudah_dpttuslah = false;
                    Boolean selimut         = false;
                    Boolean sudah_dptselimut= false;

                    String warna = "grey";
                    for (int c = 0; c < jmlCol; c++) {
                        item_passenger datapenumpang = null;
                        String abjad = "";
                        if ( (col1seats==1) && (col2seats==2) ){
                            abjad    = abj_col1x2[c];
                        } else if ( (col1seats==2) && (col2seats==1) ) {
                            abjad    = abj_col2x1[c];
                        } else if ( (col1seats==2) && (col2seats==2) ) {
                            abjad    = abj_col2x2[c];
                        } else if ( (col1seats==2) && (col2seats==3) ) {
                            abjad    = abj_col2x3[c];
                        } else {
                            abjad    = abj_col3x2[c];
                        }
                        String urutan   = String.valueOf(r+1);
                        kodetempatduduk = urutan+abjad;
                        //Log.d("pesan", "pesan kodetempatduduk: "+kodetempatduduk);
                        if (abjad.equals("X")){
                            kodetempatduduk = "LORONG";
                            lorong = true;
                            ada_penumpang   = false;
                        }else{
                            if (tempatygterisi.contains(kodetempatduduk)) {
                                int posisiCursor = tempatygterisi.lastIndexOf(kodetempatduduk);
                                //Log.d("pesan", "pesan kodetempatduduk: "+kodetempatduduk+" ditempati, position: "+String.valueOf(index));
                                lorong          = false;
                                ada_penumpang   = true;
                                penumpang_vip   = false;
                                selimut         = false;
                                sudah_dptselimut= false;
                                String newwagonno           = arrPassengerSatuWagon.get(posisiCursor).getWagonNo();
                                String newstationOri        = arrPassengerSatuWagon.get(posisiCursor).getStationOri();
                                String newstationDes        = arrPassengerSatuWagon.get(posisiCursor).getStationDes();
                                String newseat              = arrPassengerSatuWagon.get(posisiCursor).getSeat();
                                String newboarding          = arrPassengerSatuWagon.get(posisiCursor).getBoarding();
                                String newstamformdetcode   = arrPassengerSatuWagon.get(posisiCursor).getStamformdetcode();

                                Boolean newtuslah           = arrPassengerSatuWagon.get(posisiCursor).getTuslah();
                                Boolean newsdhdpt_tuslah    = arrPassengerSatuWagon.get(posisiCursor).getSdhdpt_tuslah();
                                Boolean newselimut          = arrPassengerSatuWagon.get(posisiCursor).getSelimut();
                                Boolean newsdhdpt_selimut   = arrPassengerSatuWagon.get(posisiCursor).getSdhdpt_selimut();
                                Boolean newpenumpangVIP     = arrPassengerSatuWagon.get(posisiCursor).getPenumpangVIP();
                                Boolean newdoubleseat       = arrPassengerSatuWagon.get(posisiCursor).getDoubleseat();
                                datapenumpang = new item_passenger(newwagonno,newstamformdetcode, newstationOri, newstationDes, newseat, newboarding, newstamformdetcode, newtuslah, newsdhdpt_tuslah, newselimut, newsdhdpt_selimut, newpenumpangVIP, newdoubleseat);
                            } else {
                                lorong          = false;
                                ada_penumpang   = false;
                                penumpang_vip   = false;
                                selimut         = false;
                                sudah_dptselimut= false;
                                tuslah          = false;
                                sudah_dpttuslah = false;
                            }
                        }
                        tmp_seat_satubaris.add(new item_tempatduduk(kodetempatduduk,lorong,ada_penumpang,penumpang_vip,selimut,sudah_dptselimut,tuslah,sudah_dpttuslah,datapenumpang));
                    }
                    tmp_seat_satuwagon.add(tmp_seat_satubaris);
                    //Log.d("pesan","pesan Size peta_tempatduduk "+String.valueOf(tmp_seat_satuwagon.size()));
                }
                if (tmp_seat_satuwagon.size()>0){
                    mAdapter = new adapter_wagon(getContextNullSafety(),tmp_seat_satuwagon,stBerangkat,stTujuan,dataDobelSeat, getActivityNullSafety().getSupportFragmentManager());
                    mRecylerView.setAdapter(mAdapter);
                }
            }
        });
        //GetManiFestPenumpang();
        /*
        spinWagon.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
                int dipilih = spinWagon.getSelectedItemPosition();
                //ArrayList<item_passenger> mParaPenumpang = new ArrayList<>();
                int dipilihBerangkat    = spinBerangkat.getSelectedItemPosition();
                String stBerangkat      = strBerangkat.get(dipilihBerangkat);
                int dipilihTujuan       = spinTujuan.getSelectedItemPosition();
                String stTujuan         = strTujuan.get(dipilihTujuan);
                Log.d("pesan", "pesan dipilihNoWagon : "+String.valueOf(dipilih));
                Log.d("pesan", "pesan dipilihBerangkat : "+stBerangkat);
                Log.d("pesan", "pesan dipilihTujuan : "+stTujuan);

                nomorWagon      = mItemDataWagon.get(dipilih).getWagonNo();
                KodeWagon       = mItemDataWagon.get(dipilih).getWagonCode();
                txtInfoKereta.setText("KA: "+mNAMAKA+" ("+mNOKA+")");
                txtRelasi.setText("Depart: "+mTGLDepart);

                Baris           = mItemDataWagon.get(dipilih).getRows();
                Kolom           = mItemDataWagon.get(dipilih).getCols();
                KursiKolom1     = mItemDataWagon.get(dipilih).getCol1seats();
                KursiKolom2     = mItemDataWagon.get(dipilih).getCol2seats();
                KursiKolom3     = mItemDataWagon.get(dipilih).getCol3seats();
                Kapasitas       = mItemDataWagon.get(dipilih).getCapacity();

                ArrayList<ArrayList<item_tempatduduk>> dataTempatDudukWagon = mItemDataWagon.get(dipilih).getPeta_tempatduduk();
                //Log.d("pesan", "pesan NomorWagon: "+nomorWagon+", CodeWagon: "+mItemDataWagon.get(dipilih).getWagonCode());
                //Log.d("pesan", "pesan Baris : "+String.valueOf(Baris)+", Kolom: "+String.valueOf(Kolom));
                //Log.d("pesan", "pesan Col1 : "+String.valueOf(KursiKolom1)+", Col2: "+String.valueOf(KursiKolom2)+", Col3: "+String.valueOf(KursiKolom3));
                //HashMap<String, Object> datajson = new HashMap<String, Object>();
                //Gson gson=new Gson();
                //datajson.put("dataTempatDudukWagon",dataTempatDudukWagon);
                //String strPayLoad=gson.toJson(datajson);
                //Log.d("pesan","strPayLoad datawagondipilih: "+strPayLoad);
                if (dataTempatDudukWagon.size()>0){
                    //Log.d("pesan", "pesan Ukuran dataTempatDudukWagon : "+String.valueOf(dataTempatDudukWagon.size()));
                    //,Baris,Kolom,KursiKolom1,KursiKolom2,KursiKolom3,Kapasitas,nomorWagon,KodeWagon
                    mAdapter = new adapter_wagon(getContextNullSafety(),dataTempatDudukWagon,stBerangkat,stTujuan);
                    mRecylerView.setAdapter(mAdapter);
                }
            }
            @Override
            public void onNothingSelected(AdapterView<?> parentView) {
                // your code here
            }
        });
         */
        // Inflate the layout for this fragment
        return rootView;
    }


//    private void GetManiFestPenumpang() {
//        String strPayLoad = "";
//        //String vStrAPIGetManifest = urlWEBService + "/v1/rts/manifest/map-penumpang?trainNo="+trainNo+"&route_date="+route_date;
//        String vStrAPIGetManifest = urlWEBService + "/v2/trainmart/trainattendant/map-penumpang/"+mTOKEN_LOGIN;
//        Log.d("pesan","pesan urlGET ManifestKA "+vStrAPIGetManifest);
//        mProgressBar.setVisibility(View.VISIBLE);
//        mProgressBar.bringToFront();
//        StringRequest vResultFromServer = new StringRequest(Request.Method.GET, vStrAPIGetManifest, new Response.Listener<String>() {
//            @Override
//            public void onResponse(String response) {
//                //Log.wtf("pesan","pesan response "+response);
//                try {
//                    JSONObject jObj = new JSONObject(response);
//                    mProgressBar.setVisibility(View.INVISIBLE);
//                    if (mStatusCode==200){
//                        mProgressBar.setVisibility(View.INVISIBLE);
//                        if (mItemDataWagon.size()>0){
//                            mItemDataWagon.clear();
//                        }
//                        JSONArray objRelation = jObj.getJSONArray("relation");
//                        strBerangkat.clear();
//                        strTujuan.clear();
//
//                        strBerangkat.add("-any-");
//                        strTujuan.add("-any-");
//
//                        for (int r = 0; r < objRelation.length(); r++) {
//                            JSONObject jObj_Relation = objRelation.getJSONObject(r);
//                            String code     = jObj_Relation.getString("code");
//                            String depart   = jObj_Relation.getString("depart");;
//                            mItemDataRelation.add(new item_relation(code,depart));
//                            strBerangkat.add(code);
//                            //Log.d("pesan","pesan code "+code);
//                        }
//                        ArrayAdapter<String> spinnerArrayAdapterBerangkat = new ArrayAdapter<String>(getContextNullSafety(), simple_spinner_item, strBerangkat);
//                        spinnerArrayAdapterBerangkat.setDropDownViewResource(R.layout.template_spinner); // The drop down view
//                        spinBerangkat.setAdapter(spinnerArrayAdapterBerangkat);
//
//                        for (int r = mItemDataRelation.size()-1; r !=0; r--) {
//                            strTujuan.add(mItemDataRelation.get(r).getCode());
//                        }
//                        ArrayAdapter<String> spinnerArrayAdapterTujuan = new ArrayAdapter<String>(getContextNullSafety(), simple_spinner_item, strTujuan);
//                        spinnerArrayAdapterTujuan.setDropDownViewResource(R.layout.template_spinner); // The drop down view
//                        spinTujuan.setAdapter(spinnerArrayAdapterTujuan);
//
//                        String abj_col1x2[] = {"A", "X", "C", "D"};
//                        String abj_col2x1[] = {"A", "B", "X", "D"};
//                        String abj_col2x2[] = {"A", "B", "X", "C", "D"};
//                        String abj_col2x3[] = {"A", "B", "X", "C", "D","E"};
//                        String abj_col3x2[] = {"A", "B", "C", "X", "D","E"};
//
//                        JSONArray objWagon = jObj.getJSONArray("wagon");
//                        //mItemDataWagon.add(new item_wagon("","","",0,0,0,0,0,0,null));
//                        //strWagonName.add("Pilih Nomor Wagon Kereta");
//                        for (int i = 0; i < objWagon.length(); i++) {
//                            JSONObject jObj_Wagon   = objWagon.getJSONObject(i);
//                            String wagonNo          = jObj_Wagon.getString("wagonNo");
//                            String wagonCode        = jObj_Wagon.getString("wagonCode");
//                            String stamformdetcode  = jObj_Wagon.getString("stamformdetcode");
//                            int cols                = jObj_Wagon.getInt("cols");
///1. AMBIL DATA PASSENGER UTK DI MATCHING DGN SUSUNAN TEMPAT DUDUK KERETA/
//                            ArrayList<String> penumpangygduduk = new ArrayList<>();
//
//                            int capacity            = jObj_Wagon.getInt("capacity");
//                            ArrayList<item_passenger> passenger = new ArrayList<>();
//                            JSONArray obj_psgr = jObj_Wagon.getJSONArray("passenger");
//                            for (int p = 0; p < obj_psgr.length(); p++) {
//                                JSONObject jObj_Passenger = obj_psgr.getJSONObject(p);
//                                String stationOri   = jObj_Passenger.getString("stationOri");
//                                String stationDes   = jObj_Passenger.getString("stationDes");
//                                String seat         = jObj_Passenger.getString("seat");
//                                String boarding     = "";
//                                String stamform_psg     = jObj_Passenger.getString("stamformdetcode");
//                                Boolean tuslah          = jObj_Passenger.getBoolean("tuslah");
//                                Boolean sdhdpt_tuslah   = jObj_Passenger.getBoolean("tuslah_delivered"); //Ganti nanti  yaaaa kalo API dah dirubah
//                                Boolean selimut         = jObj_Passenger.getBoolean("selimut");; //Ganti nanti  yaaaa kalo API dah dirubah
//                                Boolean sdhdpt_selimut  = jObj_Passenger.getBoolean("selimut_delivered");; //Ganti nanti  yaaaa kalo API dah dirubah
//                                Boolean penumpangVIP    = jObj_Passenger.getBoolean("vip");
//                                Boolean doubleseat      = jObj_Passenger.getBoolean("vip");
//
//                                penumpangygduduk.add(seat);
//                                //Log.d("pesan","Ada Penumpang: "+String.valueOf(seat));
//                                passenger.add(new item_passenger(wagonNo,wagonCode,stationOri,stationDes,seat,boarding,stamform_psg,tuslah,sdhdpt_tuslah,selimut,sdhdpt_selimut,penumpangVIP,doubleseat));
//                            }
//
///2. PENYUSUNAN GAMBARAN SUSUNAN TEMPAT DUDUK KERETA/
//                            int col1seats           = jObj_Wagon.getInt("col1seats");
//                            int col2seats           = jObj_Wagon.getInt("col2seats");
//                            int col3seats           = jObj_Wagon.getInt("col3seats");
//                            int jmlCol              = 0;
//                            if ( (col1seats==1) && (col2seats==2) ){
//                                jmlCol = 4; //Spasi 1
//                                //abj_col1x2
//                            } else if ( (col1seats==2) && (col2seats==1) ) {
//                                jmlCol = 4; //Spasi 1
//                                //abj_col2x1
//                            } else if ( (col1seats==2) && (col2seats==2) ) {
//                                jmlCol = 5; //Spasi 1
//                                //abj_col2x2
//                            } else if ( (col1seats==2) && (col2seats==3) ) {
//                                jmlCol = 6;
//                                //abj_col2x3
//                            } else if ( (col1seats==3) && (col2seats==2) ) {
//                                jmlCol = 6;
//                                //abj_col3x2
//                            } else {
//                                jmlCol = 6;
//                                //abj_col3x2
//                            }
//                            int rows = jObj_Wagon.getInt("rows");
//                            //Log.d("pesan","wagonNo: "+String.valueOf(wagonNo));
//
//                            ArrayList<ArrayList<item_tempatduduk>> peta_tempatduduk = new ArrayList<>();
//                            for (int r = 0; r < rows; r++) {
//                                ArrayList<item_tempatduduk> tempatduduk_satu_baris = new ArrayList<>();
//                                String kodetempatduduk  = "";
//                                Boolean lorong          = false;
//                                Boolean ada_penumpang   = false;
//                                Boolean penumpang_vip   = false;
//                                Boolean dpt_tuslah      = false;
//                                Boolean sudah_dpttuslah = false;
//                                Boolean selimut         = false;
//                                Boolean sudah_dptselimut= false;
//
//                                String warna = "grey";
//                                for (int c = 0; c < jmlCol; c++) {
//                                    item_passenger datapenumpang = null;
//                                    String abjad = "";
//                                    if ( (col1seats==1) && (col2seats==2) ){
//                                        abjad    = abj_col1x2[c];
//                                    } else if ( (col1seats==2) && (col2seats==1) ) {
//                                        abjad    = abj_col2x1[c];
//                                    } else if ( (col1seats==2) && (col2seats==2) ) {
//                                        abjad    = abj_col2x2[c];
//                                    } else if ( (col1seats==2) && (col2seats==3) ) {
//                                        abjad    = abj_col2x3[c];
//                                    } else {
//                                        abjad    = abj_col3x2[c];
//                                    }
//                                    String urutan   = String.valueOf(r+1);
//                                    kodetempatduduk = urutan+abjad;
//                                    //Log.d("pesan", "pesan kodetempatduduk: "+kodetempatduduk);
//                                    if (abjad.equals("X")){
//                                        kodetempatduduk = " LORONG ";
//                                        lorong = true;
//                                        ada_penumpang   = false;
//                                    }else{
//                                        if (penumpangygduduk.contains(kodetempatduduk)) {
//                                            int index = penumpangygduduk.lastIndexOf(kodetempatduduk);
//                                            //Log.d("pesan", "pesan kodetempatduduk: "+kodetempatduduk+" ditempati, position: "+String.valueOf(index));
//                                            lorong          = false;
//                                            ada_penumpang   = true;
//                                            penumpang_vip   = false;
//                                            selimut         = false;
//                                            sudah_dptselimut= false;
//                                            warna           = "blue";
//                                            String newstationOri      = passenger.get(index).getStationOri();
//                                            String newstationDes      = passenger.get(index).getStationDes();
//                                            String newseat            = passenger.get(index).getSeat();
//                                            String newboarding        = passenger.get(index).getBoarding();
//                                            String newstamformdetcode = passenger.get(index).getStamformdetcode();
//
//                                            Boolean tuslah          = passenger.get(index).getTuslah();
//                                            Boolean sdhdpt_tuslah   = passenger.get(index).getSdhdpt_tuslah();
//                                            Boolean selimut_flag    = passenger.get(index).getSelimut();
//                                            Boolean sdhdpt_selimut  = passenger.get(index).getSdhdpt_selimut();
//                                            Boolean penumpangVIP    = passenger.get(index).getPenumpangVIP();
//                                            Boolean doubleseat      = passenger.get(index).getDoubleseat();
//
//                                            datapenumpang = new item_passenger(wagonNo,wagonCode, newstationOri, newstationDes, newseat, newboarding, newstamformdetcode, tuslah, sdhdpt_tuslah, selimut_flag, sdhdpt_selimut, penumpangVIP, doubleseat);
//                                        } else {
//                                            lorong          = false;
//                                            ada_penumpang   = false;
//                                            penumpang_vip   = false;
//                                            selimut         = false;
//                                            sudah_dptselimut= false;
//                                            warna = "red";
//                                            //Log.d("pesan", "pesan kodetempatduduk: "+kodetempatduduk+" gak ditempati");
//                                        }
//                                    }
//                                    tempatduduk_satu_baris.add(new item_tempatduduk(kodetempatduduk,lorong,ada_penumpang,penumpang_vip,selimut,sudah_dptselimut,warna,datapenumpang));
//                                }
//                                //mKondisiTempatDudukWagon.add(new item_tempatduduk());
//                                peta_tempatduduk.add(tempatduduk_satu_baris);
//                                //Log.d("pesan","pesan Size peta_tempatduduk "+String.valueOf(peta_tempatduduk.size()));
//                            }
//                            mItemDataWagon.add(new item_wagon(wagonNo,wagonCode,stamformdetcode,cols,col1seats,col2seats,col3seats,rows,capacity,peta_tempatduduk));
///END PENYUSUNAN GAMBARAN SUSUNAN TEMPAT DUDUK KERETA/
////                            HashMap<String, Object> datajson = new HashMap<String, Object>();
////                            Gson gson=new Gson();
////                            datajson.put("peta_tempatduduk",peta_tempatduduk);
////                            String strPayLoad=gson.toJson(datajson);
//                            //Log.d("pesan","Ukuran peta_tempatduduk: "+String.valueOf(peta_tempatduduk.size()));
////                            mItemDataWagon.add(new item_wagon(wagonNo,wagonCode,stamformdetcode,cols,col1seats,col2seats,col3seats,rows,capacity,peta_tempatduduk));
//                            strWagonName.add("Wagon "+wagonNo+" - "+wagonCode);
//                            //Log.d("pesan","pesan Wagon "+wagonNo+" - "+wagonCode);
//                        }
//                        if (!(strWagonName ==null)){
//                            if (strWagonName.size()>0){
//                                ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(getContextNullSafety(), simple_spinner_item, strWagonName);
//                                spinnerArrayAdapter.setDropDownViewResource(R.layout.template_spinner); // The drop down view
//                                spinWagon.setAdapter(spinnerArrayAdapter);
//                            }
//                        }
//                    }else{
//                        mProgressBar.setVisibility(View.INVISIBLE);
//                    }
//                } catch (JSONException e) {
//                    // JSON error
//                    mProgressBar.setVisibility(View.GONE);
//                    e.printStackTrace();
//                }
//            }
//        }, new Response.ErrorListener() {
//            @Override
//            public void onErrorResponse(VolleyError error) {
//                mProgressBar.setVisibility(View.INVISIBLE);
//                TanganiVolleyError TVE = new TanganiVolleyError(getActivityNullSafety(),error);
//                TVE.proses_error();
//                error.printStackTrace();
//            }
//        }) {
//            @Override
//            public Map<String, String> getHeaders() throws AuthFailureError {
//                HashMap<String, String> headerMap = new HashMap<String, String>();
//                headerMap.put("Content-Type", "application/json; charset=utf-8");
//                headerMap.put("Authorization", "Bearer " + mTOKEN_LOGIN);
//                return headerMap;
//            }
//
//            @Override
//            public String getBodyContentType() {
//                return "application/json; charset=utf-8";
//            }
//            @RequiresApi(api = Build.VERSION_CODES.KITKAT)
//            @Override
//            public byte[] getBody() throws AuthFailureError {
//                return strPayLoad == null ? null : strPayLoad.getBytes(StandardCharsets.UTF_8);
//            }
//            @Override
//            protected Response<String> parseNetworkResponse(NetworkResponse response) {
//                mStatusCode = response.statusCode;
//                return super.parseNetworkResponse(response);
//            }
//        };
//        int MY_SOCKET_TIMEOUT_MS=50000;
//        vResultFromServer.setRetryPolicy(new DefaultRetryPolicy(
//                MY_SOCKET_TIMEOUT_MS,
//                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
//                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
//        MySingleton.getPrvInstance(getContextNullSafety()).addToRequestque(vResultFromServer);
//    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(item_broadcastmanifest mItemBroadCastManifest) {
        String perintah         = mItemBroadCastManifest.getPerintah();
        int jmlPenumpangWagon   = mItemBroadCastManifest.getJmlPenumpangWagon();
        int jmlPenumpangFilter  = mItemBroadCastManifest.getJmlPenumpangFilter();
        int jmlPenumpangTuslah  = mItemBroadCastManifest.getJmlPenumpangTuslah();
        int jmlPenumpangVIP     = mItemBroadCastManifest.getJmlPenumpangVIP();
        if (perintah.equals("tampilkanhistorywagon")){
            int dipilihBerangkat    = spinBerangkat.getSelectedItemPosition();
            String stBerangkat      = arrStOri.get(dipilihBerangkat);
            int dipilihTujuan       = spinTujuan.getSelectedItemPosition();
            String stTujuan         = arrStDestination.get(dipilihTujuan);
            //"\nTuslah: "+jmlPenumpangTuslah+
            txtInfoJumlahPenumpang.setText("Total Pnp: "+jmlPenumpangWagon+"\nPnp dr: "+stBerangkat+" to "+stTujuan+": "+jmlPenumpangFilter);
        }
    }

    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        contextNullSafe = context;
    }
    /*CALL THIS IF YOU NEED CONTEXT/
    public Context getContextNullSafety() {
        if (getContext() != null) return getContext();
        if (getActivity() != null) return getActivity();
        if (contextNullSafe != null) return contextNullSafe;
        if (getView() != null && getView().getContext() != null) return getView().getContext();
        if (requireContext() != null) return requireContext();
        if (requireActivity() != null) return requireActivity();
        if (requireView() != null && requireView().getContext() != null)
            return requireView().getContext();

        return null;

    }
    /*CALL THIS IF YOU NEED ACTIVITY/
    public FragmentActivity getActivityNullSafety() {
        if (getContextNullSafety() != null && getContextNullSafety() instanceof FragmentActivity) {
            /*It is observed that if context it not null then it will be
             * the related host/container activity always*/
            return (FragmentActivity) getContextNullSafety();
        }
        return null;
    }

    private void GetManiFestPenumpang(String namaModul) {
        int mStatusCode = 0;
        String strPayLoad = "";
        String vStrAPIGetManifest = urlWEBService + "/v2/trainmart/trainattendant/map-penumpang/"+mTOKEN_LOGIN;
        String abj_col1x2[] = {"A", "X", "C", "D"};
        String abj_col2x1[] = {"A", "B", "X", "D"};
        String abj_col2x2[] = {"A", "B", "X", "C", "D"};
        String abj_col2x3[] = {"A", "B", "X", "C", "D","E"};
        String abj_col3x2[] = {"A", "B", "C", "X", "D","E"};

        Log.d("pesan","pesan urlGET ManifestKA "+vStrAPIGetManifest);
        mProgressBar.setVisibility(View.VISIBLE);
        mProgressBar.bringToFront();
        StringRequest vResultFromServer = new StringRequest(Request.Method.GET, vStrAPIGetManifest, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                //Log.d("pesan","pesan response "+response);
                try {
                    JSONObject jObj = new JSONObject(response);
                    Log.d("pesan","pesan namaModul: "+namaModul);
                    int objStatus = jObj.getInt("status");
                    if (objStatus==200){
                        mProgressBar.setVisibility(View.INVISIBLE);
                        Fragment gantiFragment = null;
                        Bundle bundle = new Bundle();

                        ArrayList<String> arrKodeWagon                                      = new ArrayList<>();
                        ArrayList<String> arrStOri                                          = new ArrayList<>();
                        ArrayList<String> arrStDestination                                  = new ArrayList<>();

                        ArrayList<item_relation> dataRelasiKereta                           = new ArrayList<>();
                        ArrayList<item_passenger> dataPassengerSatuKereta                   = new ArrayList<>();
                        ArrayList<item_wagon> dataWagonDanPassengerSatuKereta               = new ArrayList<item_wagon>();

                        /ADD RELASI DULU KE ARRAY/
                        JSONArray objRelation   = jObj.getJSONArray("relation");
                        arrStOri.clear();
                        arrStDestination.clear();
                        arrStOri.add("-any-");
                        arrStDestination.add("-any-");
                        for (int r = 0; r < objRelation.length(); r++) {
                            JSONObject jObj_Relation = objRelation.getJSONObject(r);
                            String code     = jObj_Relation.getString("code");
                            String depart   = jObj_Relation.getString("depart");;
                            dataRelasiKereta.add(new item_relation(code,depart));
                            arrStOri.add(code);
                        }
                        for (int r = objRelation.length()-1; r>=0; r--) {
                            arrStDestination.add(dataRelasiKereta.get(r).getCode());
                        }

                        JSONArray objWagon      = jObj.getJSONArray("wagon");
                        /ADD DATA WAGON KE ARRAY/
                        for (int w = 0; w < objWagon.length(); w++) {
                            JSONObject jItemObj_Wagon   = objWagon.getJSONObject(w);
                            String wagonNo          = jItemObj_Wagon.getString("wagonNo");
                            String wagonCode        = jItemObj_Wagon.getString("wagonCode");
                            String stamformdetcode  = jItemObj_Wagon.getString("stamformdetcode");
                            if (!stamformdetcode.equals("-")){
                                int cols                = jItemObj_Wagon.getInt("cols");
                                int rows                = jItemObj_Wagon.getInt("rows");
                                int capacity            = jItemObj_Wagon.getInt("capacity");
                                int col1seats           = jItemObj_Wagon.getInt("col1seats");
                                int col2seats           = jItemObj_Wagon.getInt("col2seats");
                                int col3seats           = jItemObj_Wagon.getInt("col3seats");

                                /1. AMBIL DATA PASSENGER UTK DI MATCHING DGN SUSUNAN TEMPAT DUDUK KERETA/
                                JSONArray obj_psgr = jItemObj_Wagon.getJSONArray("passenger");
                                ArrayList<item_passenger> dataPassengerSatuWagon = new ArrayList<>();
                                for (int p = 0; p < obj_psgr.length(); p++) {
                                    JSONObject jObjItemPassenger = obj_psgr.getJSONObject(p);
                                    String stationOri       = jObjItemPassenger.getString("stationOri");
                                    String stationDes       = jObjItemPassenger.getString("stationDes");
                                    String seat             = jObjItemPassenger.getString("seat");
                                    String boarding         = "";
                                    Boolean tuslah          = jObjItemPassenger.getBoolean("tuslah");
                                    Boolean sdhdpt_tuslah   = jObjItemPassenger.getBoolean("tuslah_delivered"); //Ganti nanti  yaaaa kalo API dah dirubah
                                    Boolean selimut         = jObjItemPassenger.getBoolean("selimut");; //Ganti nanti  yaaaa kalo API dah dirubah
                                    Boolean sdhdpt_selimut  = jObjItemPassenger.getBoolean("selimut_delivered");; //Ganti nanti  yaaaa kalo API dah dirubah
                                    Boolean penumpangVIP    = jObjItemPassenger.getBoolean("vip");
                                    Boolean doubleseat      = jObjItemPassenger.getBoolean("double_seat");

                                    dataPassengerSatuWagon.add(new item_passenger(wagonNo,wagonCode,stationOri,stationDes,seat,boarding,stamformdetcode,tuslah,sdhdpt_tuslah,selimut,sdhdpt_selimut,penumpangVIP,doubleseat));
                                    dataPassengerSatuKereta.add(new item_passenger(wagonNo,wagonCode,stationOri,stationDes,seat,boarding,stamformdetcode,tuslah,sdhdpt_tuslah,selimut,sdhdpt_selimut,penumpangVIP,doubleseat));
                                }
                                dataWagonDanPassengerSatuKereta.add(new item_wagon(wagonNo,wagonCode,stamformdetcode,cols,col1seats,col2seats,col3seats,rows,capacity,dataPassengerSatuWagon));
                                //Jika Wagon bukan yg "-" maka insert semua data ke array
                                arrKodeWagon.add(stamformdetcode);
                            }
                        }
                        //Toasty.error(getContextNullSafety(), "NANTI! line 2025 ganti DoubleSeat key", Toast.LENGTH_SHORT, true).show();

                        switch (namaModul){
                            case "MANIFEST":
                                gantiFragment = new BerandaManifest();
                                break;
                            case "TUSLAH":
                                gantiFragment = new PembagianTuslah();
                                break;
                            case "SELIMUT":
                                gantiFragment = new PembagianTuslah();
                                break;
                        }
                        if (!(gantiFragment ==null)){
                            if (dataWagonDanPassengerSatuKereta.size()>0){
                                bundle.putStringArrayList("DATA_STORI",arrStOri);
                                bundle.putStringArrayList("DATA_STDESTINATION",arrStDestination);
                                bundle.putStringArrayList("DATA_KODEWAGON",arrKodeWagon);

                                bundle.putParcelableArrayList("DATA_RELASIKERETA", dataRelasiKereta);
                                bundle.putParcelableArrayList("DATA_PENUMPANGSATUKERETA", dataPassengerSatuKereta);
                                bundle.putParcelableArrayList("DATAWAGON_DAN_PENUMPANGSATUKERETA", dataWagonDanPassengerSatuKereta);
                                gantiFragment.setArguments(bundle);
                                getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_utama, gantiFragment).commit();
                            }else{
                                Toasty.error(getContextNullSafety(), "Data Wagon dan Passenger tidak ditemukan!, Coba klik kembali!", Toast.LENGTH_SHORT, true).show();
                            }
                        }
                    }
                    mProgressBar.setVisibility(View.INVISIBLE);
                } catch (JSONException e) {
                    // JSON error
                    mProgressBar.setVisibility(View.INVISIBLE);
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                mProgressBar.setVisibility(View.INVISIBLE);
                TanganiVolleyError TVE = new TanganiVolleyError(getActivityNullSafety(),error);
                TVE.proses_error();
                error.printStackTrace();
            }
        }) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                HashMap<String, String> headerMap = new HashMap<String, String>();
                headerMap.put("Content-Type", "application/json; charset=utf-8");
                headerMap.put("Authorization", "Bearer " + mTOKEN_LOGIN);
                return headerMap;
            }

            @Override
            public String getBodyContentType() {
                return "application/json; charset=utf-8";
            }
            @RequiresApi(api = Build.VERSION_CODES.KITKAT)
            @Override
            public byte[] getBody() throws AuthFailureError {
                return strPayLoad == null ? null : strPayLoad.getBytes(StandardCharsets.UTF_8);
            }
            @Override
            protected Response<String> parseNetworkResponse(NetworkResponse response) {
                return super.parseNetworkResponse(response);
            }
        };
        int MY_SOCKET_TIMEOUT_MS=50000;
        vResultFromServer.setRetryPolicy(new DefaultRetryPolicy(
                MY_SOCKET_TIMEOUT_MS,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
        MySingleton.getPrvInstance(getContextNullSafety()).addToRequestque(vResultFromServer);
    }
}
Leave a Comment