我正在开发一个投票应用程序,其中SomeOne上传两个或更多图像,而另一个用户对任何特定图像进行投票。
现在一切正常,但是我必须添加一项功能,当有人单击图像时,圆形进度条应一个接一个地显示进度。
当前发生的情况是,如果有人单击图像,我会计算当前的投票百分比并添加新的百分比,然后致电notifyitemchange(Position)
我想要的是,如果分数是30%,那么进度条应将其显示为0到30%
else if (PO.getFeed_type().equalsIgnoreCase("vertical")){
view.card_parent.setVisibility(View.GONE);
view.card_parentS.setVisibility(View.GONE);
view.card_parentV3.setVisibility(View.GONE);
view.card_parentV4.setVisibility(View.GONE);
view.card_parenttext.setVisibility(View.GONE);
view.card_parentpost.setVisibility(View.GONE);
// System.out.println("jdixkdicxk+++3"+PO.getTitle());
view.titleH.setText(PO.getTitle());
view.usernameH.setText(PO.getUsername());
view.vote_countH.setText(String.valueOf(PO.getAnswered_poll()) + "");
view.created_timeH.setText(PO.getCreated_time());
view.comment_countH.setText(PO.getComments_count());
Picasso.with(getActivity())
.load(Constant.imagepath + PO.getChoice1())
.error(R.drawable.no_image)
.into(view.choice1H);
Picasso.with(getActivity())
.load(Constant.imagepath + PO.getChoice2())
.error(R.drawable.no_image)
.into(view.choice2H);
if (PO.getProfile_pic().length() > 0)
Picasso.with(getActivity())
.load(Constant.user_imagepath + PO.getProfile_pic())
.error(R.drawable.dummy_user)
.into(view.profile_picH);
else {
Picasso.with(getActivity())
.load(R.drawable.dummy_user)
.error(R.drawable.dummy_user)
.into(view.profile_picH);
}
if (PO.getSelected_choice() == 1) {
// holder.choice1_selected.setVisibility(View.VISIBLE);
// holder.choice2_selected.setVisibility(View.GONE);
//
// holder.choice1_percentage.setVisibility(View.VISIBLE);
// holder.choice2_percentage.setVisibility(View.VISIBLE);
int percentage1 = PO.getChoice1_percentage();
int percentage2 = PO.getChoice2_percentage();
view.donut_progress1H.setProgress(percentage1);
view.donut_progress2H.setProgress(percentage2);
view.donut_progress1H.setText(String.valueOf(percentage1) + "%");
view.donut_progress2H.setText(String.valueOf(percentage2) + "%");
view.white_layer1H.setVisibility(View.VISIBLE);
view.white_layer2H.setVisibility(View.VISIBLE);
view.myvote1H.setVisibility(View.VISIBLE);
view.myvote2H.setVisibility(View.GONE);
//view.choicebar1.setVisibility(View.VISIBLE);
//view.choicebar2.setVisibility(View.VISIBLE);
} else if (PO.getSelected_choice() == 2) {
// view.choice1_selected.setVisibility(View.GONE);
// view.choice2_selected.setVisibility(View.VISIBLE);
//
view.white_layer1H.setVisibility(View.VISIBLE);
view.white_layer2H.setVisibility(View.VISIBLE);
int percentage1 = PO.getChoice1_percentage();
int percentage2 = PO.getChoice2_percentage();
view.donut_progress1H.setProgress(percentage1);
view.donut_progress2H.setProgress(percentage2);
view.donut_progress1H.setText(String.valueOf(percentage1) + "%");
view.donut_progress2H.setText(String.valueOf(percentage2) + "%");
//
view.choice1_percentage.setText(String.valueOf(percentage1));
//
view.choice2_percentage.setText(String.valueOf(percentage2));
view.myvote1H.setVisibility(View.GONE);
view.myvote2H.setVisibility(View.VISIBLE);
} else {
view.choicebar1H.setVisibility(View.GONE);
view.choicebar2H.setVisibility(View.GONE);
view.white_layer1H.setVisibility(View.GONE);
view.white_layer2H.setVisibility(View.GONE);
}
if
(myuserobj.getUser_pk().equalsIgnoreCase(PO.getUser_fk()))
view.follow_btnH.setVisibility(View.GONE);
else
view.follow_btnH.setVisibility(View.VISIBLE);
view.choice1H.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view) {
if (PO.getSelected_choice() == 0) {
PO.setSelected_choice(1);
PO.setChoice1_count(PO.getChoice1_count() + 1);
PO.setAnswered_poll(PO.getAnswered_poll() + 1);
float choice1_percentage = ((float)
PO.getChoice1_count() / (float) PO.getAnswered_poll()) * 100;
float choice2_percentage = ((float)
PO.getChoice2_count() / (float) PO.getAnswered_poll()) * 100;
PO.setChoice1_percentage((int)
choice1_percentage);
PO.setChoice2_percentage((int)
choice2_percentage);
// getAllPollsFollowing();
// feedlistview.smoothScrollToPosition(position+1);
PO.setSelected_choice(1);
notifyItemChanged(position,PO);
vote_poll(myuserobj.getUser_pk(),
String.valueOf(items.get(position).getPoll_pk()), "1");
} else {
Intent in = new Intent(getActivity(),
PollDetailActivity.class);
in.putExtra("poll_pk",
String.valueOf(PO.getPoll_pk()));
startActivity(in);
}
// Toast.makeText(getActivity(), "Already voted",
Toast.LENGTH_SHORT).show();
}
});
view.choice2H.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (PO.getSelected_choice() == 0) {
PO.setSelected_choice(2);
PO.setChoice2_count(PO.getChoice2_count() + 1);
PO.setAnswered_poll(PO.getAnswered_poll() + 1);
float choice1_percentage = ((float) PO.getChoice1_count() / (float) PO.getAnswered_poll()) * 100;
float choice2_percentage = ((float) PO.getChoice2_count() / (float) PO.getAnswered_poll()) * 100;
PO.setChoice1_percentage((int) choice1_percentage);
PO.setChoice2_percentage((int) choice2_percentage);
items.get(position).setSelected_choice(2);
notifyItemChanged(position,PO);
vote_poll(myuserobj.getUser_pk(), String.valueOf(items.get(position).getPoll_pk()), "2");
} else {
Intent in = new Intent(getActivity(), PollDetailActivity.class);
in.putExtra("poll_pk", String.valueOf(PO.getPoll_pk()));
startActivity(in);
}
}
});