Fixes issues
This commit is contained in:
parent
e7da61bdd3
commit
3874c3495a
|
@ -79,7 +79,7 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
|
|||
private ListView lv_status;
|
||||
private boolean isRefreshed;
|
||||
private ImageView pp_actionBar;
|
||||
|
||||
public static int position;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -224,7 +224,7 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onRetrieveFeeds(Context context, Error error) {
|
||||
public void onRetrieveContext(Context context, Status statusFirst, Error error) {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
if( error != null){
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
|
@ -237,25 +237,32 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
|
|||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
|
||||
int positionSpinnerTrans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
|
||||
int position = 0;
|
||||
position = 0;
|
||||
boolean positionFound = false;
|
||||
List<Status> statuses = new ArrayList<>();
|
||||
if( statusFirst != null)
|
||||
statuses.add(0, statusFirst);
|
||||
if( context.getAncestors() != null && context.getAncestors().size() > 0){
|
||||
for(Status status: context.getAncestors()){
|
||||
statuses.add(status);
|
||||
if( status.getId().equals(initialStatus.getId()))
|
||||
positionFound =true;
|
||||
if( !positionFound)
|
||||
position++;
|
||||
if( status.getId().equals(initialStatus.getId()))
|
||||
positionFound = true;
|
||||
|
||||
}
|
||||
}else if( statusFirst == null){
|
||||
statuses.add(0, initialStatus);
|
||||
positionFound = true;
|
||||
}
|
||||
if( context.getDescendants() != null && context.getDescendants().size() > 0){
|
||||
for(Status status: context.getDescendants()){
|
||||
statuses.add(status);
|
||||
if( status.getId().equals(initialStatus.getId()))
|
||||
positionFound =true;
|
||||
if( !positionFound)
|
||||
position++;
|
||||
if( status.getId().equals(initialStatus.getId()))
|
||||
positionFound = true;
|
||||
|
||||
}
|
||||
}
|
||||
RelativeLayout loader = findViewById(R.id.loader);
|
||||
|
|
|
@ -16,8 +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.Status;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveContextInterface;
|
||||
|
||||
|
||||
|
@ -30,6 +33,7 @@ public class RetrieveContextAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
private Context context;
|
||||
private String statusId;
|
||||
private fr.gouv.etalab.mastodon.client.Entities.Status statusFirst;
|
||||
private fr.gouv.etalab.mastodon.client.Entities.Context statusContext;
|
||||
private OnRetrieveContextInterface listener;
|
||||
private API api;
|
||||
|
@ -46,6 +50,7 @@ public class RetrieveContextAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
statusContext = api.getStatusContext(statusId);
|
||||
//Retrieves the first toot
|
||||
if( statusContext.getAncestors().size() > 0 ) {
|
||||
statusFirst = statusContext.getAncestors().get(0);
|
||||
statusContext = api.getStatusContext(statusContext.getAncestors().get(0).getId());
|
||||
}
|
||||
return null;
|
||||
|
@ -53,7 +58,7 @@ public class RetrieveContextAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
listener.onRetrieveFeeds(statusContext, api.getError());
|
||||
listener.onRetrieveContext(statusContext, statusFirst, api.getError());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,11 +17,12 @@ package fr.gouv.etalab.mastodon.interfaces;
|
|||
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Context;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||
|
||||
/**
|
||||
* Created by Thomas on 04/05/2017.
|
||||
* Interface when a context for a status has been retrieved
|
||||
*/
|
||||
public interface OnRetrieveContextInterface {
|
||||
void onRetrieveFeeds(Context context, Error error);
|
||||
void onRetrieveContext(Context context, Status statusFirst, Error error);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue