Fix poll
This commit is contained in:
parent
5bdf24d581
commit
9b06787ba8
|
@ -628,7 +628,11 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
});
|
||||
holder.poll_container.setVisibility(View.VISIBLE);
|
||||
holder.number_votes.setText(context.getResources().getQuantityString(R.plurals.number_of_voters, status.getPoll().getVoters_count(), status.getPoll().getVoters_count()));
|
||||
holder.remaining_time.setText(context.getString(R.string.poll_finish_at, Helper.dateToStringPoll(poll.getExpires_at())));
|
||||
if( poll.isExpired()){
|
||||
holder.remaining_time.setText(context.getString(R.string.poll_finish_at, Helper.dateToStringPoll(poll.getExpires_at())));
|
||||
}else{
|
||||
holder.remaining_time.setText(context.getString(R.string.poll_finish_in, Helper.dateDiffPoll(context, poll.getExpires_at())));
|
||||
}
|
||||
} else {
|
||||
holder.poll_container.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
@ -895,7 +895,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
});
|
||||
holder.poll_container.setVisibility(View.VISIBLE);
|
||||
holder.number_votes.setText(context.getResources().getQuantityString(R.plurals.number_of_voters, poll.getVoters_count(), poll.getVoters_count()));
|
||||
holder.remaining_time.setText(context.getString(R.string.poll_finish_at, Helper.dateToStringPoll(poll.getExpires_at())));
|
||||
if( poll.isExpired()){
|
||||
holder.remaining_time.setText(context.getString(R.string.poll_finish_at, Helper.dateToStringPoll(poll.getExpires_at())));
|
||||
}else{
|
||||
holder.remaining_time.setText(context.getString(R.string.poll_finish_in, Helper.dateDiffPoll(context, poll.getExpires_at())));
|
||||
}
|
||||
} else {
|
||||
holder.poll_container.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
@ -1001,6 +1001,33 @@ public class Helper {
|
|||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Returns a String depending of the date
|
||||
* @param context Context
|
||||
* @param dateEndPoll Date
|
||||
* @return String
|
||||
*/
|
||||
public static String dateDiffPoll(Context context, Date dateEndPoll) {
|
||||
Date now = new Date();
|
||||
long diff = dateEndPoll.getTime() - now.getTime();
|
||||
long seconds = diff / 1000;
|
||||
long minutes = seconds / 60;
|
||||
long hours = minutes / 60;
|
||||
long days = hours / 24;
|
||||
|
||||
if (days > 0)
|
||||
return context.getResources().getQuantityString(R.plurals.date_day_polls, (int) days, (int) days);
|
||||
else if (hours > 0)
|
||||
return context.getResources().getQuantityString(R.plurals.date_hours_polls, (int) hours, (int) hours);
|
||||
else if (minutes > 0)
|
||||
return context.getResources().getQuantityString(R.plurals.date_minutes_polls, (int) minutes, (int) minutes);
|
||||
else {
|
||||
if (seconds < 0)
|
||||
seconds = 0;
|
||||
return context.getResources().getQuantityString(R.plurals.date_seconds_polls, (int) seconds, (int) seconds);
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Toast message depending of the status code and the initial action
|
||||
* @param context Context
|
||||
|
|
|
@ -45,14 +45,14 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"></LinearLayout>
|
||||
android:visibility="gone"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/rated"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"></LinearLayout>
|
||||
android:visibility="gone"/>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -137,6 +137,24 @@
|
|||
<string name="date_hours">%d h</string>
|
||||
<string name="date_day">%d d</string>
|
||||
|
||||
<plurals name="date_seconds_polls">
|
||||
<item quantity="one">%d second</item>
|
||||
<item quantity="other">%d seconds</item>
|
||||
</plurals>
|
||||
<plurals name="date_minutes_polls">
|
||||
<item quantity="one">%d minute</item>
|
||||
<item quantity="other">%d minutes</item>
|
||||
</plurals>
|
||||
<plurals name="date_hours_polls">
|
||||
<item quantity="one">%d hour</item>
|
||||
<item quantity="other">%d hours</item>
|
||||
</plurals>
|
||||
|
||||
<plurals name="date_day_polls">
|
||||
<item quantity="one">%d day</item>
|
||||
<item quantity="other">%d days</item>
|
||||
</plurals>
|
||||
|
||||
<!-- TOOT -->
|
||||
<string name="toot_cw_placeholder">Warning</string>
|
||||
<string name="toot_placeholder">What is on your mind?</string>
|
||||
|
@ -1154,4 +1172,5 @@
|
|||
<string name="status_count">Status count</string>
|
||||
<string name="instance_count">Instance count</string>
|
||||
<string name="blocked">Blocked</string>
|
||||
<string name="poll_finish_in">End in %s</string>
|
||||
</resources>
|
Loading…
Reference in New Issue