Search in sources :

Example 11 with CourseV2

use of com.mnnyang.gzuclassschedule.data.beanv2.CourseV2 in project GzuClassSchedule by mnnyang.

the class HomePresenter method writeShare.

/**
 * 分享写入本地
 */
private long writeShare(List<DownCourseWrapper.DownCourse> data) {
    CourseV2Dao courseV2Dao = Cache.instance().getCourseV2Dao();
    CourseGroup group = new CourseGroup();
    group.setCgName("来自热心网友分享" + AppUtils.createUUID().substring(0, 8));
    long newGroupId = Cache.instance().getCourseGroupDao().insert(group);
    for (DownCourseWrapper.DownCourse downCourse : data) {
        CourseV2 courseV2 = new CourseV2().setCouOnlyId(// new only_id
        AppUtils.createUUID()).setCouCgId(// new group
        newGroupId).setCouName(downCourse.getName()).setCouTeacher(downCourse.getTeacher()).setCouLocation(downCourse.getLocation()).setCouColor(downCourse.getColor()).setCouWeek(downCourse.getWeek()).setCouStartNode(downCourse.getStart_node()).setCouNodeCount(downCourse.getNode_count()).setCouAllWeek(downCourse.getAll_week());
        courseV2Dao.insert(courseV2);
    }
    return newGroupId;
}
Also used : CourseV2Dao(com.mnnyang.gzuclassschedule.data.greendao.CourseV2Dao) CourseV2(com.mnnyang.gzuclassschedule.data.beanv2.CourseV2) CourseGroup(com.mnnyang.gzuclassschedule.data.beanv2.CourseGroup) DownCourseWrapper(com.mnnyang.gzuclassschedule.data.beanv2.DownCourseWrapper)

Example 12 with CourseV2

use of com.mnnyang.gzuclassschedule.data.beanv2.CourseV2 in project GzuClassSchedule by mnnyang.

the class HomePresenter method addCourse.

/**
 * 添加
 */
private void addCourse(DownCourseWrapper.DownCourse downCourse, Long groupId) {
    CourseV2Dao courseDao = Cache.instance().getCourseV2Dao();
    CourseV2 oldCourse = new CourseV2().setCouOnlyId(downCourse.getOnly_id()).setCouCgId(groupId).setCouName(downCourse.getName()).setCouTeacher(downCourse.getTeacher()).setCouLocation(downCourse.getLocation()).setCouColor(downCourse.getColor()).setCouWeek(downCourse.getWeek()).setCouStartNode(downCourse.getStart_node()).setCouNodeCount(downCourse.getNode_count()).setCouAllWeek(downCourse.getAll_week());
    courseDao.insert(oldCourse);
}
Also used : CourseV2Dao(com.mnnyang.gzuclassschedule.data.greendao.CourseV2Dao) CourseV2(com.mnnyang.gzuclassschedule.data.beanv2.CourseV2)

Example 13 with CourseV2

use of com.mnnyang.gzuclassschedule.data.beanv2.CourseV2 in project GzuClassSchedule by mnnyang.

the class AddActivity method initEmptyLocation.

private void initEmptyLocation(LinearLayout locationItem) {
    CourseV2 defaultCourse = new CourseV2().setCouOnlyId(AppUtils.createUUID()).setCouAllWeek(Constant.DEFAULT_ALL_WEEK).setCouWeek(1).setCouStartNode(1).setCouNodeCount(1);
    initNodeInfo(locationItem, defaultCourse);
}
Also used : CourseV2(com.mnnyang.gzuclassschedule.data.beanv2.CourseV2)

Example 14 with CourseV2

use of com.mnnyang.gzuclassschedule.data.beanv2.CourseV2 in project GzuClassSchedule by mnnyang.

the class AddActivity method addLocation.

private void addLocation(boolean closeable) {
    final LinearLayout locationItem = (LinearLayout) View.inflate(this, R.layout.layout_location_item, null);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.topMargin = ScreenUtils.dp2px(8);
    if (closeable) {
        locationItem.findViewById(R.id.iv_clear).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mLayoutLocationContainer.removeView(locationItem);
            }
        });
        initEmptyLocation(locationItem);
    } else {
        // 建立默认的上课时间和上课地点
        locationItem.findViewById(R.id.iv_clear).setVisibility(View.INVISIBLE);
        if (mAncestor != null) {
            // 屏幕点击过来
            CourseV2 defaultCourse = new CourseV2().setCouOnlyId(AppUtils.createUUID()).setCouAllWeek(Constant.DEFAULT_ALL_WEEK).setCouWeek(mAncestor.getRow()).setCouStartNode(mAncestor.getCol()).setCouNodeCount(mAncestor.getRowNum()).init();
            initNodeInfo(locationItem, defaultCourse);
        } else if (mIntentCourseV2 != null) {
            // 编辑过来
            initNodeInfo(locationItem, mIntentCourseV2);
            mEtlName.setText(mIntentCourseV2.getCouName());
            mEtlTeacher.setText(mIntentCourseV2.getCouTeacher());
        } else {
            // 
            LogUtil.e(this, "initEmptyLocation");
            initEmptyLocation(locationItem);
        }
    }
    locationItem.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            clickLocationItem(locationItem);
        }
    });
    mLayoutLocationContainer.addView(locationItem, params);
}
Also used : CourseV2(com.mnnyang.gzuclassschedule.data.beanv2.CourseV2) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 15 with CourseV2

use of com.mnnyang.gzuclassschedule.data.beanv2.CourseV2 in project GzuClassSchedule by mnnyang.

the class CourseActivity method setCourseData.

@Override
public void setCourseData(List<CourseV2> courses) {
    mCourseViewV2.clear();
    CourseV2Dao courseV2Dao = Cache.instance().getCourseV2Dao();
    LogUtil.d(this, "当前课程数:" + courses.size());
    for (CourseV2 course : courses) {
        if (course.getCouColor() == null || course.getCouColor() == -1) {
            course.setCouColor(Utils.getRandomColor());
            courseV2Dao.update(course);
        }
        course.init();
        LogUtil.e(this, "即将显示:" + course.toString());
        mCourseViewV2.addCourse(course);
    }
    // 没有课程才显示叶子logo
    if (courses.isEmpty()) {
        mLayoutCourse.setBackgroundResource(R.drawable.svg_bg);
    } else {
        mLayoutCourse.setBackgroundResource(0);
    }
}
Also used : CourseV2Dao(com.mnnyang.gzuclassschedule.data.greendao.CourseV2Dao) CourseV2(com.mnnyang.gzuclassschedule.data.beanv2.CourseV2)

Aggregations

CourseV2 (com.mnnyang.gzuclassschedule.data.beanv2.CourseV2)19 CourseV2Dao (com.mnnyang.gzuclassschedule.data.greendao.CourseV2Dao)8 CourseGroup (com.mnnyang.gzuclassschedule.data.beanv2.CourseGroup)4 View (android.view.View)3 TextView (android.widget.TextView)3 ArrayList (java.util.ArrayList)3 JSONException (org.json.JSONException)3 ImageView (android.widget.ImageView)2 DownCourseWrapper (com.mnnyang.gzuclassschedule.data.beanv2.DownCourseWrapper)2 Disposable (io.reactivex.disposables.Disposable)2 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 NonNull (android.support.annotation.NonNull)1 RecyclerView (android.support.v7.widget.RecyclerView)1 LinearLayout (android.widget.LinearLayout)1 CourseAncestor (com.mnnyang.gzuclassschedule.custom.course.CourseAncestor)1 CourseView (com.mnnyang.gzuclassschedule.custom.course.CourseView)1