Search in sources :

Example 6 with CourseTeacher

use of com.shu.studentmanager.entity.CourseTeacher in project student-manager by SYYANI.

the class CourseAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull CourseAdapter.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
    if (coursesList != null && coursesList.size() > 0) {
        CourseTeacher course_entity = coursesList.get(position);
        holder.course_id_cid.setText(course_entity.getCid());
        holder.course_name_cname.setText(course_entity.getCname());
        holder.course_credit_ccredit.setText(course_entity.getCcredit());
        holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(View view) {
                new MaterialAlertDialogBuilder(context).setTitle("确认").setMessage("确定不开设该课程?").setNeutralButton("取消", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                }).setPositiveButton("确认", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Log.d(TAG, "onClick: " + which + " " + position);
                        enSureDelete(coursesList.get(position));
                    }
                }).show();
                return false;
            }
        });
    } else {
        return;
    }
}
Also used : DialogInterface(android.content.DialogInterface) CourseTeacher(com.shu.studentmanager.entity.CourseTeacher) TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) SuppressLint(android.annotation.SuppressLint)

Example 7 with CourseTeacher

use of com.shu.studentmanager.entity.CourseTeacher in project student-manager by SYYANI.

the class CourseManageAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull CourseManageAdapter.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
    if (courseManageList != null && courseManageList.size() > 0) {
        CourseTeacher courseEntity = courseManageList.get(position);
        holder.course_id_cid.setText(courseEntity.getCid());
        holder.course_name_cname.setText(courseEntity.getCname());
        holder.course_credit_ccredit.setText(courseEntity.getCcredit());
        holder.itemView.setOnClickListener(new View.OnClickListener() {

            @RequiresApi(api = Build.VERSION_CODES.P)
            @Override
            public void onClick(View view) {
                showAlertDialogMode(position, holder.course_name_cname);
            }
        });
        holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(View view) {
                new MaterialAlertDialogBuilder(context).setTitle("确认").setMessage("确定删除该课程?").setNeutralButton("取消", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                }).setPositiveButton("确认", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Log.d(TAG, "onClick: " + which + " " + position);
                        enSureDelete(courseManageList.get(position));
                    }
                }).show();
                return false;
            }
        });
    } else {
        return;
    }
}
Also used : DialogInterface(android.content.DialogInterface) RequiresApi(androidx.annotation.RequiresApi) CourseTeacher(com.shu.studentmanager.entity.CourseTeacher) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) SuppressLint(android.annotation.SuppressLint)

Example 8 with CourseTeacher

use of com.shu.studentmanager.entity.CourseTeacher in project student-manager by SYYANI.

the class TeacherFragment method setCoureListRecycleView.

private void setCoureListRecycleView() {
    course_list_recycleview.setHasFixedSize(true);
    course_list_recycleview.setLayoutManager(new LinearLayoutManager(getActivity()));
    courseAdapter = new CourseAdapter(getActivity());
    course_list_recycleview.setAdapter(courseAdapter);
    teacherViewModel.getMutableLiveData_course_list().observe(getActivity(), new Observer<ArrayList<CourseTeacher>>() {

        @Override
        public void onChanged(ArrayList<CourseTeacher> courseTeachers) {
            // Log.d(TAG, "onChanged: update");
            teacherFragmentBinding.teacherFragmentTeacherClassNumber.setText("本学期开设 " + String.valueOf(courseTeachers.size()) + " 门课");
            courseAdapter.updateCourseList(courseTeachers);
        }
    });
}
Also used : CourseAdapter(com.shu.studentmanager.adpater.CourseAdapter) ArrayList(java.util.ArrayList) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) CourseTeacher(com.shu.studentmanager.entity.CourseTeacher)

Aggregations

CourseTeacher (com.shu.studentmanager.entity.CourseTeacher)8 ArrayList (java.util.ArrayList)5 SuppressLint (android.annotation.SuppressLint)3 DialogInterface (android.content.DialogInterface)3 View (android.view.View)3 TextView (android.widget.TextView)3 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)3 RecyclerView (androidx.recyclerview.widget.RecyclerView)3 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)3 Gson (com.google.gson.Gson)2 TypeToken (com.google.gson.reflect.TypeToken)2 IOException (java.io.IOException)2 MediaType (okhttp3.MediaType)2 OkHttpClient (okhttp3.OkHttpClient)2 Request (okhttp3.Request)2 RequestBody (okhttp3.RequestBody)2 Response (okhttp3.Response)2 JSONObject (org.json.JSONObject)2 RequiresApi (androidx.annotation.RequiresApi)1 CourseAdapter (com.shu.studentmanager.adpater.CourseAdapter)1