Search in sources :

Example 1 with StudentsListNoteAdapter

use of dz.easy.androidclient.Adapters.StudentsListNoteAdapter in project easy by MehdiBenmesa.

the class StudentsFragmentNote method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    mReceiver = new DataReceiver(new Handler());
    mReceiver.setReceiver(this);
    addItemsOnSpinner();
    if (GRID_LAYOUT) {
        mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
    } else {
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    }
    mRecyclerView.setHasFixedSize(true);
    try {
        studentsListNoteAdapter = new StudentsListNoteAdapter(students, module.getString("_id"), (StudentsListNoteAdapter.AdapterInterface) StudentsFragmentNote.this);
    } catch (JSONException e1) {
        e1.printStackTrace();
    }
    mRecyclerView.setAdapter(studentsListNoteAdapter);
    /*
            mRecyclerView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    System.out.println("VALIER /// 2 ");
                    StudentsListNoteAdapter.MyViewHolder child;
                    ArrayList<StudentsListNoteAdapter.MyViewHolder> myList = studentsListNoteAdapter.getMyList();
                    Toast.makeText(getContext() , "Hello From Module Fragment "+ myList.size() +" hihi " , Toast.LENGTH_LONG).show();
                    for (int i = 0; i < myList.size(); i++) {
                        child = myList.get(i);
                        Toast.makeText(getContext() , child.title.getText() , Toast.LENGTH_LONG).show();
                    }
                }
            });*/
    valider = (Button) view.findViewById(R.id.valider);
    valider.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            System.out.println("VALIER /// ");
            try {
                studentsListNoteAdapter.updateNotes(getActivity(), module.getString("_id"));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    });
//mRecyclerView.
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) StudentsListNoteAdapter(dz.easy.androidclient.Adapters.StudentsListNoteAdapter) Handler(android.os.Handler) JSONException(org.json.JSONException) DataReceiver(dz.easy.androidclient.Services.DataReceiver) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Aggregations

Handler (android.os.Handler)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 StudentsListNoteAdapter (dz.easy.androidclient.Adapters.StudentsListNoteAdapter)1 DataReceiver (dz.easy.androidclient.Services.DataReceiver)1 JSONException (org.json.JSONException)1