如何在同一时间停止多次预订?

时间:2018-07-15 13:40:21

标签: java android

  

我从firebase firestore获取预订详细信息,并通过bean(DTO)类设置到Recyclerview中,我具有整数形式的时间和日期值,我想在同一时间或近30分钟内停止多次预订,有人告诉我如何停下来..??

主要Recyclerview Fragement,我在Firestore那里获得了价值

RecyclerView listView=(RecyclerView)view.findViewById(R.id.listview);

    lbean = new ArrayList<>();
    sheduleAdapter= new SheduleAdapter(getActivity(),lbean);

    listView.setHasFixedSize(true);
    listView.setLayoutManager(new LinearLayoutManager(getActivity()));
    listView.setAdapter(sheduleAdapter);




    db.collection("users").addSnapshotListener(new EventListener<QuerySnapshot>() {
        @Override
        public void onEvent(@Nullable QuerySnapshot queryDocumentSnapshots, @Nullable FirebaseFirestoreException e) {
            if (e != null) {
                Log.d(TAG, "Error:" + e.getMessage());
            }
            for (DocumentChange doc : queryDocumentSnapshots.getDocumentChanges()) {
                switch (doc.getType()) {
                    case ADDED:
                        bean = doc.getDocument().toObject(bean.class);
                        lbean.add(bean);
                        sheduleAdapter.notifyDataSetChanged();
                        break;
                    case MODIFIED:
                        bean = doc.getDocument().toObject(bean.class);
                        lbean.add(bean);
                        sheduleAdapter.notifyDataSetChanged();
                        break;
                    case REMOVED:
                        lbean.remove(bean);
                        sheduleAdapter.notifyDataSetChanged();
                        break;
                }

            }
        }
    });

Recyclerview适配器在那里我设置了bean类的值

        holder.mint.setText(String.valueOf(bean.get(position).getMint()));
    holder.hour.setText(String.valueOf(bean.get(position).getHour()));
    holder.day.setText(String.valueOf(bean.get(position).getDay()));
    holder.month.setText(String.valueOf(bean.get(position).getMonth()));
    holder.year.setText(String.valueOf(bean.get(position).getYear()));


    holder.btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {



            Calendar c=Calendar.getInstance();

            iHour = c.get(Calendar.HOUR_OF_DAY);
            iMin = c.get(Calendar.MINUTE );
            iYear = c.get(Calendar.YEAR);
            iMonth = c.get(Calendar.MONTH);
            iDay = c.get(Calendar.DAY_OF_MONTH);


            iMin=bean.get(position).getMint();
            iHour=bean.get(position).getHour();
            iDay=bean.get(position).getDay();
            iMonth=bean.get(position).getMonth();
            iYear=bean.get(position).getYear();

            c.set(iYear,iMonth,iDay,iHour,iMin);

                    String mm = String.valueOf(iMin);
                    String h = String.valueOf(iHour);
                    String d = String.valueOf(iDay);
                    String m = String.valueOf(iMonth);
                    String y = String.valueOf(iYear);


                    Toast.makeText(context, mm + "==" + h + "==" + d + "==" + m + "==" + y, Toast.LENGTH_SHORT).show();


                    FirebaseFirestore db = FirebaseFirestore.getInstance();


                    DocumentReference ref = db.collection("users").document();
                    final String myId = ref.getId();
                    Toast.makeText(context, myId, Toast.LENGTH_SHORT).show();


               }
    });

}

0 个答案:

没有答案