Caching the status translation for easier use
This commit is contained in:
@@ -50,6 +50,7 @@ public class Status extends BaseModel implements DisplayItemsParent{
|
|||||||
public Card card;
|
public Card card;
|
||||||
public String language;
|
public String language;
|
||||||
public String text;
|
public String text;
|
||||||
|
public String translation;
|
||||||
|
|
||||||
public boolean favourited;
|
public boolean favourited;
|
||||||
public boolean reblogged;
|
public boolean reblogged;
|
||||||
|
|||||||
@@ -97,23 +97,28 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBind(TextStatusDisplayItem item){
|
public void onBind(TextStatusDisplayItem item){
|
||||||
if(item.status.wantsTranslation){
|
if(item.status.wantsTranslation && item.status.translation == null){
|
||||||
new GetStatusTranslation(item.status.id)
|
new GetStatusTranslation(item.status.id)
|
||||||
.setCallback(new Callback<StatusTranslation>(){
|
.setCallback(new Callback<StatusTranslation>(){
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(StatusTranslation status){
|
public void onSuccess(StatusTranslation statusTranslation){
|
||||||
text.setText(status.getStrippedText());
|
item.status.translation = statusTranslation.getStrippedText();
|
||||||
|
text.setText(item.status.translation);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onError(ErrorResponse error){
|
public void onError(ErrorResponse error){
|
||||||
item.status.wantsTranslation=false;
|
item.status.wantsTranslation=false;
|
||||||
text.setText(item.text);
|
|
||||||
error.showToast(item.parentFragment.getActivity());
|
error.showToast(item.parentFragment.getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.wrapProgress(item.parentFragment.getActivity(), R.string.loading, true)
|
.wrapProgress(item.parentFragment.getActivity(), R.string.loading, true)
|
||||||
.exec(item.parentFragment.getAccountID());
|
.exec(item.parentFragment.getAccountID());
|
||||||
|
}
|
||||||
|
if(item.status.wantsTranslation){
|
||||||
|
if(item.status.translation != null)
|
||||||
|
{
|
||||||
|
text.setText(item.status.translation);
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
text.setText(item.text);
|
text.setText(item.text);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user