package name.wanghwx.ehomework.presenter;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import androidx.fragment.app.Fragment;
import com.onyx.android.sdk.pen.RawInputCallback;
import com.onyx.android.sdk.pen.TouchHelper;
import com.onyx.android.sdk.pen.data.TouchPoint;
import com.onyx.android.sdk.pen.data.TouchPointList;
import com.onyx.android.sdk.utils.CollectionUtils;
import com.onyx.android.sdk.utils.StringUtils;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;
import name.wanghwx.ehomework.common.constant.Category;
import name.wanghwx.ehomework.common.constant.MapKey;
import name.wanghwx.ehomework.common.constant.PreSuf;
import name.wanghwx.ehomework.common.pojo.DisplayItem;
import name.wanghwx.ehomework.common.pojo.DisplayOption;
import name.wanghwx.ehomework.common.pojo.DisplayQuestion;
import name.wanghwx.ehomework.common.pojo.EraserSetting;
import name.wanghwx.ehomework.common.pojo.HttpCallback;
import name.wanghwx.ehomework.common.pojo.PenSetting;
import name.wanghwx.ehomework.common.pojo.Result;
import name.wanghwx.ehomework.common.pojo.Step;
import name.wanghwx.ehomework.common.pojo.Stroke;
import name.wanghwx.ehomework.common.pojo.StrokeBoard;
import name.wanghwx.ehomework.common.util.GsonUtils;
import name.wanghwx.ehomework.model.HomeworkModel;
import name.wanghwx.ehomework.model.MistakeBookModel;
import name.wanghwx.ehomework.model.imodel.IHomeworkModel;
import name.wanghwx.ehomework.model.imodel.IMistakeBookModel;
import name.wanghwx.ehomework.pojo.Answer;
import name.wanghwx.ehomework.pojo.Choice;
import name.wanghwx.ehomework.pojo.Homework;
import name.wanghwx.ehomework.pojo.Item;
import name.wanghwx.ehomework.pojo.MistakeBook;
import name.wanghwx.ehomework.pojo.Option;
import name.wanghwx.ehomework.pojo.Question;
import name.wanghwx.ehomework.pojo.Review;
import name.wanghwx.ehomework.presenter.ipresenter.IHomeworkActivityPresenter;
import name.wanghwx.ehomework.view.fragment.AudioFragment;
import name.wanghwx.ehomework.view.fragment.CommentFragment;
import name.wanghwx.ehomework.view.fragment.EraserFragment;
import name.wanghwx.ehomework.view.fragment.ItemFragment;
import name.wanghwx.ehomework.view.fragment.PenFragment;
import name.wanghwx.ehomework.view.iactivity.IHomeworkActivity;
import okhttp3.MediaType;
import okhttp3.RequestBody;
public class HomeworkActivityPresenter extends IHomeworkActivityPresenter implements Serializable {
private static final Bundle bundles = new Bundle();
private Stack<Step<Stroke>> undoStack = new Stack<>();
private Stack<Step<Stroke>> redoStack = new Stack<>();
// 作业id
private int homeworkId;
// 查询得到的单次作业
private Homework homework;
// 题目序号
private int number;
private Handler handler = new Handler(message->{
if(message.what == number){
if(isViewAttached()) getView().renderDraw(true,false);
return true;
}else{
return false;
}
});
// 工具栏是否显示
private boolean showTool;
// 工具栏工具码
private int tool;
// 笔触设置
private PenSetting penSetting = new PenSetting();
// 橡皮设置
private EraserSetting eraserSetting = new EraserSetting();
private PenFragment penFragment = PenFragment.getInstance(penSetting);
private EraserFragment eraserFragment = EraserFragment.getInstance(eraserSetting);
// 指导栏是否显示
private boolean showGuidance;
// 指导栏指导码
private int guidance;
// 是否全屏显示
private boolean fullscreen;
// 是否显示草稿
private boolean showDraft;
// 是否显示答案
private boolean showReference;
// 手写范围定宽
private int fixedWidth;
// 当前滚动高度
private int scroll;
// 最大滚动高度
private int maxScroll;
private TouchHelper touchHelper;
// 当前笔画
private Stroke currentStroke;
// 滑动是否开启
private boolean slide;
// 滑动初始高度
private int initialY;
// 当前画布
private Canvas canvas;
// 当前位图
private Bitmap bitmap;
// 重绘线程
private Thread redraw;
// 题目展示数据
private List<DisplayItem> displayItems = new ArrayList<>();
// 答题区手写板
private List<StrokeBoard> answerBoards = new ArrayList<>();
// 草稿区手写板
private List<StrokeBoard> draftBoards = new ArrayList<>();
// 题目展示控件
private List<ItemFragment> itemFragments = new ArrayList<>();
// 评语展示控件
private List<CommentFragment> commentFragments = new ArrayList<>();
// 留言展示控件
private List<AudioFragment> audioFragments = new ArrayList<>();
private IHomeworkModel homeworkModel = HomeworkModel.getInstance();
private IMistakeBookModel mistakeBookModel = MistakeBookModel.getInstance();
public HomeworkActivityPresenter(IHomeworkActivity homeworkActivity){
attachView(homeworkActivity);
penFragment.setOnDecreaseClickListener(this::decreasePenWeight);
penFragment.setOnProgressChangeListener(this::setPenWeight);
penFragment.setOnIncreaseClickListener(this::increasePenWeight);
eraserFragment.setOnClearClickListener(this::emptyBoard);
}
private void decreasePenWeight(){
penSetting.weight--;
validatePenWeight();
}
private void setPenWeight(int progress){
penSetting.weight = (float)progress;
validatePenWeight();
}
private void increasePenWeight(){
penSetting.weight++;
validatePenWeight();
}
// 清空,支持撤销功能
private void emptyBoard(){
StrokeBoard strokeBoard = getStrokeBoard();
if(strokeBoard != null){
Step<Stroke> step = strokeBoard.clearBoard();
if(step != null){
redoStack.clear();
undoStack.push(step);
validateUndoRedo();
}
redraw();
}
}
private void validatePenWeight(){
if(penSetting.weight <= PenSetting.MIN_WEIGHT){
penSetting.weight = PenSetting.MIN_WEIGHT;
penFragment.disableDecrease();
}else{
penFragment.enableDecrease();
}
if(penSetting.weight >= PenSetting.MAX_WEIGHT){
penSetting.weight = PenSetting.MAX_WEIGHT;
penFragment.disableIncrease();
}else{
penFragment.enableIncrease();
}
if(touchHelper != null){
touchHelper.setStrokeWidth(penSetting.weight);
}
penFragment.renderPenSetting(penSetting);
}
@Override
public void getHomework(int homeworkId){
this.homeworkId = homeworkId;
homeworkModel.getHomework(new HttpCallback<Homework>(getView()){
@Override
public void success(Result<Homework> result){
Homework data = result.data();
if(data == null){
if(isViewAttached()) getView().nullData();
}else{
homework = data;
load();
}
}
},this.homeworkId);
}
private void load(){
Bundle bundle = bundles.getBundle(PreSuf.HOMEWORK_PREFIX + homeworkId);
List<Item> items = homework.getTask().getItems();
for(int i=0,il=items.size();i<il;i++){
int itemId = items.get(i).getItemId();
displayItems.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
该项目是一款针对Eink App的K12机构课后作业系统设计源码,总文件量为523个。其中,Java源代码文件222个,XML配置文件95个,类文件93个,PNG图片文件43个,Python脚本文件13个,Python字节码文件10个,HTML文件7个,JAR包文件5个,CSS文件5个,Git忽略文件4个。该系统名为“小象作业”,专为K12机构定制,全面兼容语数外史地生等所有学科及各种题型,支持主观客观题的录入,并包含语文写作功能。系统能够完整记录学生的做题过程,包括学生进入和退出的时间,以及每一步的时间记录。此外,系统支持在App内打草稿,从而记录学生的思考过程和草稿过程,为学生提供全面的学习跟踪服务。
资源推荐
资源详情
资源评论
收起资源包目录
基于Eink App的K12机构课后作业系统设计源码 (523个子文件)
gradlew.bat 2KB
oleObject1.bin 4KB
oleObject1.bin 4KB
TeacherController.class 10KB
AdminController.class 10KB
StudentController.class 9KB
UploadUtils.class 9KB
AuthFilter.class 9KB
Task.class 8KB
StudentServiceImpl.class 7KB
HomeworkServiceImpl.class 7KB
Question.class 6KB
Homework.class 6KB
Item.class 6KB
ItemServiceImpl.class 6KB
AnswerMapper.class 5KB
MavenWrapperDownloader.class 5KB
MaterialServiceImpl.class 5KB
Task$Form.class 5KB
TaskServiceImpl.class 5KB
Course.class 5KB
AnswerServiceImpl.class 5KB
CourseServiceImpl.class 5KB
MistakeBookServiceImpl.class 5KB
RedisServiceImpl.class 5KB
AuthRealm.class 4KB
TaskMapper.class 4KB
TeacherServiceImpl.class 4KB
Material.class 4KB
Result.class 4KB
CourseMapper.class 4KB
Unit.class 4KB
Question$Type.class 4KB
Homework$Status.class 4KB
Answer.class 4KB
Subject.class 4KB
ShiroConfig.class 4KB
StudentMapper.class 4KB
HomeworkMapper.class 4KB
MaterialCarrierTypeHandler.class 4KB
Review.class 4KB
SubjectTypeHandler.class 4KB
Teacher.class 4KB
HomeworkStatusHandler.class 4KB
TaskFormTypeHandler.class 4KB
QuestionTypeHandler.class 4KB
AdminServiceImpl.class 4KB
ItemMapper.class 3KB
FileUtils.class 3KB
ReviewServiceImpl.class 3KB
Choice.class 3KB
Material$Carrier.class 3KB
MistakeBookMapper.class 3KB
UnitMapper.class 3KB
PropertiesConfig.class 3KB
AnalyseServiceImpl.class 3KB
UnitServiceImpl.class 3KB
MistakeBook.class 3KB
StudentService.class 3KB
Admin.class 3KB
Student.class 3KB
MaterialMapper.class 3KB
RedisConfig.class 2KB
OSSProperties.class 2KB
AuthToken.class 2KB
PreSuf.class 2KB
Default.class 2KB
Option.class 2KB
ItemService.class 2KB
AnswerService.class 2KB
MapKey.class 2KB
QuestionMapper.class 2KB
EhomeworkApplicationTests.class 2KB
MapperName.class 2KB
TeacherMapper.class 2KB
ShiroProperties.class 2KB
MistakeBookService.class 2KB
TeacherService.class 2KB
ChoiceMapper.class 2KB
AdminMapper.class 2KB
TaskService.class 2KB
HomeworkService.class 2KB
CourseService.class 2KB
EhomeworkApplication.class 1KB
MD5Utils.class 1KB
RedisService.class 1KB
AnalyseMapper.class 1KB
MaterialService.class 1KB
AdminService.class 1KB
OptionMapper.class 1KB
UUIDUtils.class 1KB
ReviewMapper.class 1KB
AnalyseService.class 1KB
UnitService.class 1KB
ReviewService.class 902B
FailException.class 865B
index.css 6KB
index.css 6KB
login.css 1KB
login.css 1KB
共 523 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
lsx202406
- 粉丝: 2469
- 资源: 5593
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 小米AX1800WIFI6路由器刷集客包
- 0148电容充放电产生方波再经积分器转成三角波再经微分器转成方波proteus仿真资料.zip
- API网关 vs IDAAS网关 vs WAF,以及API网关在微服务中的应用
- 360T7路由集客AP固件
- meltdown/spectre处理器漏洞知识点整理
- AWDAWDWADWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
- 15000个英文单词, SQLite3数据库,字段为 单词, 翻译,各种时态,复数形式,例句
- Replicate 的 Python 客户端.zip
- Raven 是 Sentry 的旧版 Python 客户端(getsentry.com),已被 sentry-python 取代.zip
- python打包创造-pycache-文件
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功