DownloadAuditionFragment.java
6.32 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
package com.sunvote.xpadapp.fragments;
import android.annotation.SuppressLint;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.sunvote.xpadapp.R;
import com.sunvote.xpadapp.audition.DownloadType;
import com.sunvote.xpadapp.audition.EvaluationRuleInfo;
import com.sunvote.xpadapp.audition.ScoreNameInfo;
import com.sunvote.xpadapp.audition.ScoreRuleDao;
import com.sunvote.xpadapp.audition.ScoreRuleExplainInfo;
import com.sunvote.xpadapp.audition.ScoreRuleInfo;
import com.sunvote.xpadapp.audition.dao.EvaluationRuleDao;
import com.sunvote.xpadapp.audition.dao.EvaluationRuleDaoImpl;
import com.sunvote.xpadapp.audition.dao.ScoreNameDao;
import com.sunvote.xpadapp.audition.dao.ScoreNameDaoImpl;
import com.sunvote.xpadapp.audition.dao.ScoreNameRuleDao;
import com.sunvote.xpadapp.audition.dao.ScoreNameRuleDaoImpl;
import com.sunvote.xpadapp.audition.dao.ScoreNameRuleInfo;
import com.sunvote.xpadapp.audition.dao.ScoreRuleDaoImpl;
import com.sunvote.xpadapp.audition.dao.ScoreRuleExplainDao;
import com.sunvote.xpadapp.audition.dao.ScoreRuleExplainDaoImpl;
import com.sunvote.xpadapp.base.BaseFragment;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Administrator on 2017/11/13 0013.
*/
@SuppressLint("ValidFragment")
public class DownloadAuditionFragment extends BaseFragment {
//界面
private View view;
private TextView tvDownloadTitle,tvName,tvProgress;
private Object object;
private int downloadType;
public DownloadAuditionFragment(Object obj, int mDownloadType){
object=obj;
downloadType=mDownloadType;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view=inflater.inflate(R.layout.fragment_audition_fragment,container,false);
initView();
initData();
return view;
}
private void initView(){
tvDownloadTitle=view.findViewById(R.id.tv_download_title);
tvName=view.findViewById(R.id.tv_name);
tvProgress=view.findViewById(R.id.tv_progress);
//tvProgress.setText(String.format("%s%s", "进度: ", "下载中"));
tvDownloadTitle.setText(getString(R.string.download));
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
;
}
});
}
private void initData(){
DownloadType type = DownloadType.getDownloadType(downloadType);
tvName.setText(String.format("%s%s", "表名: ", type.toString()));
if(object==null){
return;
}
switch (type){
case MultipleAssessItem:
ScoreNameDao scoreNameDao=new ScoreNameDaoImpl();
scoreNameDao.delScoreNameInfo();
List<ScoreNameInfo> scoreNameInfoLs= (ArrayList<ScoreNameInfo>) object;
for(ScoreNameInfo scoreNameInfo:scoreNameInfoLs){
scoreNameDao.addScoreNameInfo(scoreNameInfo);
}
break;
case MultipleAssessRule:
ScoreNameRuleDao scoreNameRuleDao=new ScoreNameRuleDaoImpl();
scoreNameRuleDao.delScoreNameRuleInfo();
List<ScoreNameRuleInfo> scoreNameRuleInfoLs= (ArrayList<ScoreNameRuleInfo>) object;
for(ScoreNameRuleInfo scoreNameRuleInfo:scoreNameRuleInfoLs){
scoreNameRuleDao.addScoreNameRuleInfo(scoreNameRuleInfo);
}
break;
case ScoreRule:
ScoreRuleDao scoreRuleDao=new ScoreRuleDaoImpl();
scoreRuleDao.delScoreRuleInfo();
List<ScoreRuleInfo> scoreRuleInfoLs= (ArrayList<ScoreRuleInfo>) object;
for(ScoreRuleInfo scoreRuleInfo:scoreRuleInfoLs){
scoreRuleDao.addScoreRuleInfo(scoreRuleInfo);
}
scoreRuleDao.addDefalutScoreRuleInfo();
break;
case EvaluationRule:
EvaluationRuleDao evaluationRuleDao=new EvaluationRuleDaoImpl();
evaluationRuleDao.delEvaluationRuleInfo();
List<EvaluationRuleInfo> evaluationRuleInfoLs= (ArrayList<EvaluationRuleInfo>) object;
for(EvaluationRuleInfo evaluationRuleInfo:evaluationRuleInfoLs){
evaluationRuleDao.addEvaluationRuleInfo(evaluationRuleInfo);
}
break;
case ScoreRuleExplain:
ScoreRuleExplainDao scoreRuleExplainDao=new ScoreRuleExplainDaoImpl();
scoreRuleExplainDao.delScoreRuleExplainInfo();
List<ScoreRuleExplainInfo> scoreRuleExplainInfoLs= (ArrayList<ScoreRuleExplainInfo>) object;
for(ScoreRuleExplainInfo scoreRuleExplainInfo:scoreRuleExplainInfoLs){
scoreRuleExplainDao.addScoreRuleExplainInfo(scoreRuleExplainInfo);
}
break;
default:
break;
}
//tvProgress.setText(String.format("%s%s", "进度: ", "下载完成"));
tvDownloadTitle.setText("下载完成");
Message message = new Message();
myHandler.sendMessage(message);
}
public void onSubmitData(int type, Object obj) {
object=obj;
downloadType=type;
initData();
}
/**
* 消息处理
*/
Handler myHandler = new Handler()
{
@Override
public void handleMessage(Message msg) {
new Handler().postDelayed(new Runnable(){
public void run() {
goBack();
}
}, 500);
}
};
@SuppressLint("NewApi")
private void goBack() {
FragmentManager fm = getChildFragmentManager();
FragmentTransaction tx = fm.beginTransaction();
tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
tx.remove(this);
tx.commit();
mMainActivity.addCurrFragment=null;
if(mMainActivity.currFragment != null){
mMainActivity.currFragment.onDownUpdate();
}
}
}