Fixes an issue when following devs
This commit is contained in:
parent
74e1fd4640
commit
f930023578
|
@ -23,9 +23,7 @@ import android.os.AsyncTask;
|
|||
import android.os.Bundle;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
@ -189,6 +187,7 @@ public class AboutActivity extends AppCompatActivity implements OnRetrieveRemote
|
|||
boolean tschneider = false;
|
||||
boolean PhotonQyv = false;
|
||||
boolean angrytux = false;
|
||||
|
||||
for(Account account: accounts){
|
||||
if( account.getUsername().equals("tschneider")){
|
||||
account.setFollowing(false);
|
||||
|
@ -223,6 +222,20 @@ public class AboutActivity extends AppCompatActivity implements OnRetrieveRemote
|
|||
new RetrieveRemoteAccountsAsyncTask("angrytux", "social.tchncs.de", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(){
|
||||
super.onResume();
|
||||
if( developers != null && developers.size() > 0){
|
||||
for(Account account: developers){
|
||||
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(),AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
if( contributors != null && contributors.size() > 0){
|
||||
for(Account account: contributors){
|
||||
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(),AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onRetrieveRelationship(Relationship relationship, Error error) {
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
|
@ -231,15 +244,17 @@ public class AboutActivity extends AppCompatActivity implements OnRetrieveRemote
|
|||
return;
|
||||
}
|
||||
for( int i = 0 ; i < developers.size() ; i++){
|
||||
if( developers.get(i).getId().equals(relationship.getId()) && relationship.isFollowing() || userId.trim().equals(relationship.getId())){
|
||||
developers.get(i).setFollowing(true);
|
||||
if( developers.get(i).getId().equals(relationship.getId())){
|
||||
developers.get(i).setFollowing(relationship.isFollowing() || userId.trim().equals(relationship.getId()));
|
||||
accountSearchWebAdapterDeveloper.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
for( int i = 0 ; i < contributors.size() ; i++){
|
||||
if( contributors.get(i).getId().equals(relationship.getId()) && relationship.isFollowing() || userId.trim().equals(relationship.getId())){
|
||||
contributors.get(i).setFollowing(true);
|
||||
if( contributors.get(i).getId().equals(relationship.getId())){
|
||||
contributors.get(i).setFollowing(relationship.isFollowing() || userId.trim().equals(relationship.getId()));
|
||||
accountSearchWebAdapterContributors.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,11 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Relationship;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRelationshipInterface;
|
||||
|
||||
/**
|
||||
|
@ -38,11 +40,12 @@ public class RetrieveRelationshipAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
this.context = context;
|
||||
this.listener = onRetrieveRelationshipInterface;
|
||||
this.accountId = accountId;
|
||||
Log.v(Helper.TAG,"RetrieveRelationshipAsyncTask");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
Log.v(Helper.TAG,"doInBackground");
|
||||
api = new API(context);
|
||||
relationship = api.getRelationship(accountId);
|
||||
return null;
|
||||
|
|
|
@ -190,6 +190,13 @@ public class AccountSearchDevAdapter extends BaseAdapter implements OnPostAction
|
|||
holder.account_follow.setEnabled(true);
|
||||
return;
|
||||
}
|
||||
for( Account account: accounts){
|
||||
if(account.getId().equals(userId)) {
|
||||
account.setFollowing(true);
|
||||
notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
holder.account_follow.setVisibility(View.GONE);
|
||||
Toast.makeText(context, R.string.toast_follow, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue