Some changes
This commit is contained in:
parent
a85ca83386
commit
d6ef3e4382
|
@ -53,10 +53,16 @@ public class ManagePollAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
if( status.getPoll().getId() == null)
|
Poll _poll;
|
||||||
|
if( status.getReblog() != null)
|
||||||
|
_poll = status.getReblog().getPoll();
|
||||||
|
else
|
||||||
|
_poll = status.getPoll();
|
||||||
|
|
||||||
|
if( _poll.getId() == null)
|
||||||
return null;
|
return null;
|
||||||
if (type == type_s.SUBMIT){
|
if (type == type_s.SUBMIT){
|
||||||
poll = new API(contextReference.get()).submiteVote(status.getPoll().getId(),choices);
|
poll = new API(contextReference.get()).submiteVote(_poll.getId(),choices);
|
||||||
}else if( type == type_s.REFRESH){
|
}else if( type == type_s.REFRESH){
|
||||||
poll = new API(contextReference.get()).getPoll(status);
|
poll = new API(contextReference.get()).getPoll(status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2223,8 +2223,9 @@ public class API {
|
||||||
*/
|
*/
|
||||||
public Poll getPoll(Status status){
|
public Poll getPoll(Status status){
|
||||||
try {
|
try {
|
||||||
|
Poll _p = (status.getReblog() != null)?status.getReblog().getPoll():status.getPoll();
|
||||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||||
String response = httpsConnection.get(getAbsoluteUrl(String.format("/polls/%s", status.getPoll().getId())), 60, null, prefKeyOauthTokenT);
|
String response = httpsConnection.get(getAbsoluteUrl(String.format("/polls/%s", _p.getId())), 60, null, prefKeyOauthTokenT);
|
||||||
Poll poll = parsePoll(context, new JSONObject(response));
|
Poll poll = parsePoll(context, new JSONObject(response));
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
status.setPoll(poll);
|
status.setPoll(poll);
|
||||||
|
|
|
@ -557,18 +557,28 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
holder.multiple_choice.setVisibility(View.GONE);
|
holder.multiple_choice.setVisibility(View.GONE);
|
||||||
holder.single_choice.setVisibility(View.GONE);
|
holder.single_choice.setVisibility(View.GONE);
|
||||||
holder.submit_vote.setVisibility(View.GONE);
|
holder.submit_vote.setVisibility(View.GONE);
|
||||||
if( status.getPoll() != null && status.getPoll().getOptionsList() != null ){
|
if( (status.getPoll() != null && status.getPoll().getOptionsList() != null)
|
||||||
Poll poll = status.getPoll();
|
|| (status.getReblog() != null && status.getReblog().getPoll() != null && status.getReblog().getPoll().getOptionsList() != null)
|
||||||
int choiceCount = status.getPoll().getOptionsList().size();
|
){
|
||||||
|
Poll poll;
|
||||||
|
int choiceCount;
|
||||||
|
if( status.getReblog() != null) {
|
||||||
|
poll = status.getReblog().getPoll();
|
||||||
|
choiceCount = status.getReblog().getPoll().getOptionsList().size();
|
||||||
|
}else {
|
||||||
|
poll = status.getPoll();
|
||||||
|
choiceCount = status.getPoll().getOptionsList().size();
|
||||||
|
}
|
||||||
|
|
||||||
if( poll.isVoted() || poll.isExpired()){
|
if( poll.isVoted() || poll.isExpired()){
|
||||||
holder.rated.setVisibility(View.VISIBLE);
|
holder.rated.setVisibility(View.VISIBLE);
|
||||||
List<BarItem> items = new ArrayList<>();
|
List<BarItem> items = new ArrayList<>();
|
||||||
int greaterValue = 0;
|
int greaterValue = 0;
|
||||||
for(PollOptions pollOption: status.getPoll().getOptionsList()){
|
for(PollOptions pollOption: poll.getOptionsList()){
|
||||||
if( pollOption.getVotes_count() > greaterValue)
|
if( pollOption.getVotes_count() > greaterValue)
|
||||||
greaterValue = pollOption.getVotes_count();
|
greaterValue = pollOption.getVotes_count();
|
||||||
}
|
}
|
||||||
for(PollOptions pollOption: status.getPoll().getOptionsList()){
|
for(PollOptions pollOption: poll.getOptionsList()){
|
||||||
double value = ((double)(pollOption.getVotes_count()* 100) / (double)poll.getVotes_count()) ;
|
double value = ((double)(pollOption.getVotes_count()* 100) / (double)poll.getVotes_count()) ;
|
||||||
if( pollOption.getVotes_count() == greaterValue) {
|
if( pollOption.getVotes_count() == greaterValue) {
|
||||||
BarItem bar = new BarItem(pollOption.getTitle(), value, "%", ContextCompat.getColor(context, R.color.mastodonC4), Color.WHITE);
|
BarItem bar = new BarItem(pollOption.getTitle(), value, "%", ContextCompat.getColor(context, R.color.mastodonC4), Color.WHITE);
|
||||||
|
@ -598,7 +608,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
if( choiceCount > 3)
|
if( choiceCount > 3)
|
||||||
holder.c_choice_4.setVisibility(View.VISIBLE);
|
holder.c_choice_4.setVisibility(View.VISIBLE);
|
||||||
int j = 1;
|
int j = 1;
|
||||||
for(PollOptions pollOption: status.getPoll().getOptionsList()){
|
for(PollOptions pollOption: poll.getOptionsList()){
|
||||||
if( j == 1 )
|
if( j == 1 )
|
||||||
holder.c_choice_1.setText(pollOption.getTitle());
|
holder.c_choice_1.setText(pollOption.getTitle());
|
||||||
else if( j == 2 )
|
else if( j == 2 )
|
||||||
|
@ -619,7 +629,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
if( choiceCount > 3)
|
if( choiceCount > 3)
|
||||||
holder.r_choice_4.setVisibility(View.VISIBLE);
|
holder.r_choice_4.setVisibility(View.VISIBLE);
|
||||||
int j = 1;
|
int j = 1;
|
||||||
for(PollOptions pollOption: status.getPoll().getOptionsList()){
|
for(PollOptions pollOption: poll.getOptionsList()){
|
||||||
if( j == 1 )
|
if( j == 1 )
|
||||||
holder.r_choice_1.setText(pollOption.getTitle());
|
holder.r_choice_1.setText(pollOption.getTitle());
|
||||||
else if( j == 2 )
|
else if( j == 2 )
|
||||||
|
@ -675,7 +685,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
holder.poll_container.setVisibility(View.VISIBLE);
|
holder.poll_container.setVisibility(View.VISIBLE);
|
||||||
holder.number_votes.setText(context.getResources().getQuantityString(R.plurals.number_of_vote,status.getPoll().getVotes_count(),status.getPoll().getVotes_count()));
|
holder.number_votes.setText(context.getResources().getQuantityString(R.plurals.number_of_vote,poll.getVotes_count(),poll.getVotes_count()));
|
||||||
holder.remaining_time.setText(context.getString(R.string.poll_finish_at, Helper.dateToStringPoll(poll.getExpires_at())));
|
holder.remaining_time.setText(context.getString(R.string.poll_finish_at, Helper.dateToStringPoll(poll.getExpires_at())));
|
||||||
}else {
|
}else {
|
||||||
holder.poll_container.setVisibility(View.GONE);
|
holder.poll_container.setVisibility(View.GONE);
|
||||||
|
@ -2536,6 +2546,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
toot.setVisibility(status.getVisibility());
|
toot.setVisibility(status.getVisibility());
|
||||||
if( status.getPoll() != null){
|
if( status.getPoll() != null){
|
||||||
toot.setPoll(status.getPoll());
|
toot.setPoll(status.getPoll());
|
||||||
|
}else if(status.getReblog() != null && status.getReblog().getPoll() != null ) {
|
||||||
|
toot.setPoll(status.getPoll());
|
||||||
}
|
}
|
||||||
new RetrieveFeedsAsyncTask(context, RetrieveFeedsAsyncTask.Type.ONESTATUS, status.getIn_reply_to_id(), null, false, false, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
new RetrieveFeedsAsyncTask(context, RetrieveFeedsAsyncTask.Type.ONESTATUS, status.getIn_reply_to_id(), null, false, false, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2548,6 +2560,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
toot.setContent(status.getContent());
|
toot.setContent(status.getContent());
|
||||||
if( status.getPoll() != null){
|
if( status.getPoll() != null){
|
||||||
toot.setPoll(status.getPoll());
|
toot.setPoll(status.getPoll());
|
||||||
|
}else if(status.getReblog() != null && status.getReblog().getPoll() != null ) {
|
||||||
|
toot.setPoll(status.getPoll());
|
||||||
}
|
}
|
||||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
long id = new StatusStoredDAO(context, db).insertStatus(toot, null);
|
long id = new StatusStoredDAO(context, db).insertStatus(toot, null);
|
||||||
|
|
|
@ -6,7 +6,7 @@ buildscript {
|
||||||
google()
|
google()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.3.2'
|
classpath 'com.android.tools.build:gradle:3.4.0'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#Thu Jan 17 11:18:18 CET 2019
|
#Thu Apr 18 13:00:25 CEST 2019
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
|
||||||
|
|
Loading…
Reference in New Issue