zoukankan      html  css  js  c++  java
  • 第二阶段冲刺3

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    package com.example.shazidouhuiapp.activity;
     
     
     
    import android.content.Intent;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.ImageView;
    import android.widget.TextView;
    import android.widget.Toast;
     
    import androidx.annotation.Nullable;
    import androidx.appcompat.app.AppCompatActivity;
    import androidx.recyclerview.widget.LinearLayoutManager;
     
    import com.example.shazidouhuiapp.Adapter.receiveAdapter;
    import com.example.shazidouhuiapp.Bean.homework;
    import com.example.shazidouhuiapp.Bean.homeworkContent;
    import com.example.shazidouhuiapp.R;
     
    import java.util.List;
     
    import cn.bmob.v3.BmobQuery;
    import cn.bmob.v3.datatype.BmobPointer;
    import cn.bmob.v3.exception.BmobException;
    import cn.bmob.v3.listener.FindListener;
    import cn.bmob.v3.listener.QueryListener;
    import cn.bmob.v3.listener.UpdateListener;
     
     
    public class student_unfinished_receive_question extends AppCompatActivity {
        private TextView question,score,status;
        private EditText myanswer;
        private Button submit;
        private ImageView returnview;
        private String id,parent;
        private  homeworkContent hom;
        private homework homework;
     
        @Override
        protected void onCreate(@Nullable Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.student_unfinished_recieve);
            initview();
            initdata();
            returnview.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    finish();
                }
            });
     
        }
     
        private void initdata() {
            //另外一种
            Intent a=getIntent();
            id=a.getStringExtra("id");
            parent=a.getStringExtra("parentid");
            hom=new homeworkContent();
            homework=new homework();
            hom.setObjectId(id+"");
            homework.setObjectId(parent+"");
            String mquestion=a.getStringExtra("question");
            String mscore=a.getStringExtra("score");
            String mstatus=a.getStringExtra("status");
            if(mstatus.equals("true")){
                status.setText("已完成");
            }
            else if(mstatus.equals("false")){
                status.setText("未完成");
            }
            question.setText(mquestion);
            score.setText(mscore);
     
            submit.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    final String answer=myanswer.getText().toString().trim();
                    if(answer.isEmpty()){
                        Toast.makeText(student_unfinished_receive_question.this"请输入你的答案", Toast.LENGTH_SHORT).show();
                    }
                    else {
                        hom.setMyAnswer(answer);
                        hom.setStatus(true);
                        hom.update(new UpdateListener() {
                            @Override
                            public void done(BmobException e) {
                                if(e==null){
     
                                    BmobQuery<homeworkContent> query=new BmobQuery();
                                    query.addWhereRelatedTo("homeworkContent",new BmobPointer(homework));
     
                                    query.findObjects(new FindListener<homeworkContent>() {
                                        @Override
                                        public void done(List<homeworkContent> list, BmobException e) {
                                            if(e==null){
                                                int flag=0;
                                                for (homeworkContent homew:list
                                                     ) {
                                                    if(homew.isStatus()==true){
                                                        flag++;
                                                    }
                                                }
                                                Toast.makeText(student_unfinished_receive_question.this"本小题提交成功", Toast.LENGTH_SHORT).show();
                                                if(flag>=(list.size()-1)){
                                                    homework.setStatus(true);
                                                    homework.update(new UpdateListener() {
                                                        @Override
                                                        public void done(BmobException e) {
                                                            if(e==null){
                                                                Toast.makeText(student_unfinished_receive_question.this"您已完成本次作业所有题目", Toast.LENGTH_SHORT).show();
                                                            }
                                                            else {
                                                                Toast.makeText(student_unfinished_receive_question.this"本次作业更新失败"+e.getMessage(), Toast.LENGTH_SHORT).show();
                                                            }
                                                        }
                                                    });
     
                                                }
                                            }
                                            else {
                                                Toast.makeText(student_unfinished_receive_question.this"获取题目数据失败", Toast.LENGTH_SHORT).show();
                                            }
                                        }
                                    });
     
                                }
                                else{
                                    Log.d("提交失败", e.getMessage()+"");
                                    Toast.makeText(student_unfinished_receive_question.this"提交失败"+e.getMessage(), Toast.LENGTH_LONG).show();
                                }
                            }
                        });
                    }
                }
            });
     
     
        }
     
        private void initview() {
            question=findViewById(R.id.receive_question_question);
            score=findViewById(R.id.receive_question_score);
            status=findViewById(R.id.receive_question_status);
            myanswer=findViewById(R.id.receive_myanswer);
            returnview=findViewById(R.id.receiveback);
            submit=findViewById(R.id.receive_submit);
        }
     
    }
      
  • 相关阅读:
    rman备份,恢复
    异步事件回调机制原理探索 (转)
    stock
    将知识变成你的技能点
    Tomcat的URL中文乱码解决以及传输优化
    李洪强iOS开发之-入门指南
    WebSocket 和 Socket 的区别
    李洪强iOS开发之-修改状态栏的字体的颜色
    关于UDID和UUID的区别
    李洪强iOS开发之
  • 原文地址:https://www.cnblogs.com/wwbzuiku/p/13090370.html
Copyright © 2011-2022 走看看