标签:
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
|
/**
* 创建DialogueFragment视图
*
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
publicView onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
View v = inflater.inflate(R.layout.fragment_acg_dialogue, container,
false);
intid = (Integer) getArguments().getSerializable(EXTRA_ACG_ID);
mAcg = AcgLab.get(getActivity()).getAcg(id);
mDialogueTextView = (TextView) v.findViewById(R.id.dialogue_tv);
// 从以下标点符号处换行
String dialogue = mAcg.getDialogue().replace(",","\n");
dialogue = dialogue.replace("。","\n");
dialogue = dialogue.replace("?","\n");
dialogue = dialogue.replace("!","\n");
mDialogueTextView.setText(dialogue);
mPersonageTextView = (TextView) v.findViewById(R.id.personage_tv);
if(!mAcg.getPersonage().isEmpty()) {
mPersonageTextView.setText("--"+ mAcg.getPersonage());
}else{
mPersonageTextView.setText("");
}
mHeadImageView = (ImageView) v.findViewById(R.id.avatar_iv);
mRippleImageView = (ImageView) v.findViewById(R.id.ripple_iv);
// 将该应用程序自带的句子和用户添加的句子分开处理
if(mAcg.getId() < AcgListFragment.SYSTEM_DIALODUE_LENGHT) {
mHeadImageView.setImageResource(Integer.parseInt(mAcg.getHead()));
mHeadImageView.setOnClickListener(newView.OnClickListener() {
@Override
publicvoidonClick(View v) {
// TODO Auto-generated method stub
// 设置水波动画
Animation anim = AnimationUtils.loadAnimation(
getActivity(), R.anim.anim_ripple);
mRippleImageView.startAnimation(anim);
AcgDialogueFragment.getPlayer().play(getActivity(),
Integer.parseInt(mAcg.getSound()));
}
});
}else{
// 图片路径不存在或者未设置
File file =newFile(mAcg.getHead());
if(mAcg.getHead().isEmpty() || (!file.exists())) {
// 设置默认图片
mHeadImageView.setImageResource(R.drawable.saber);
}else{
Bitmap bmp = PictureUtils.getScaledBitmapFromPath(
getActivity(), mAcg.getHead());
bmp = PictureUtils.getRoundBitmap(bmp);
mHeadImageView.setImageBitmap(bmp);
}
mHeadImageView.setOnClickListener(newView.OnClickListener() {
@Override
publicvoidonClick(View v) {
// TODO Auto-generated method stub
// 设置水波动画
Animation anim = AnimationUtils.loadAnimation(
getActivity(), R.anim.anim_ripple);
mRippleImageView.startAnimation(anim);
if(mAcg.getId() < AcgListFragment.SYSTEM_DIALODUE_LENGHT) {
AcgDialogueFragment.getPlayer().play(getActivity(),
Integer.parseInt(mAcg.getSound()));
}else{
if(mAcg.getSound().isEmpty()) {
Toast.makeText(getActivity(),
R.string.tip_not_sound, Toast.LENGTH_SHORT)
.show();
}else{
AcgDialogueFragment.getPlayer().play(getActivity(),
mAcg.getSound());
}
}
}
});
}
returnv;
}
|
标签:
原文地址:http://my.oschina.net/yuanxulong/blog/386152