Fixes a bug with conversations

This commit is contained in:
tom79 2017-07-08 11:32:38 +02:00
parent 00f8f314b7
commit c8562ef118
8 changed files with 13 additions and 7 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 144 KiB

View File

@ -57,7 +57,7 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
public static int position;
private SwipeRefreshLayout swipeRefreshLayout;
private ListView lv_status;
private boolean isRefreshed;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -79,6 +79,7 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
statusId = b.getString("statusId", null);
if( statusId == null)
finish();
isRefreshed = false;
setTitle(R.string.conversation);
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeContainer);
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ONESTATUS, statusId,null, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
@ -95,6 +96,7 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
isRefreshed = true;
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ONESTATUS, statusId,null, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
@ -111,6 +113,7 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
( new Handler()).postDelayed(new Runnable() {
@Override
public void run() {
isRefreshed = true;
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ONESTATUS, statusId,null, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}, 1000);
@ -174,7 +177,6 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
if( context.getDescendants() != null && context.getDescendants().size() > 0){
for(Status status: context.getDescendants()){
statuses.add(status);
statusId = status.getId();
}
}
RelativeLayout loader = (RelativeLayout) findViewById(R.id.loader);
@ -183,6 +185,12 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
statusListAdapter.notifyDataSetChanged();
loader.setVisibility(View.GONE);
lv_status.setVisibility(View.VISIBLE);
lv_status.smoothScrollToPosition(position);
if( isRefreshed){
position = statuses.size()-1;
lv_status.setSelection(position);
}else {
lv_status.smoothScrollToPosition(position);
}
}
}

View File

@ -654,9 +654,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
public void onTranslatedTextview(int position, String translatedResult, Boolean error) {
if( error){
Toast.makeText(context, R.string.toast_error_translate, Toast.LENGTH_LONG).show();
return;
}
if( statuses.size() > position) {
}else if( statuses.size() > position) {
try {
JSONObject translationJson = new JSONObject(translatedResult);
JSONArray aJsonArray = translationJson.getJSONArray("text");
@ -666,7 +664,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
statuses.get(position).setTranslationShown(true);
statuses.get(position).setContent_translated(aJsonString);
statusListAdapter.notifyDataSetChanged();
} catch (JSONException | UnsupportedEncodingException e) {
} catch (JSONException | UnsupportedEncodingException | IllegalArgumentException e) {
Toast.makeText(context, R.string.toast_error_translate, Toast.LENGTH_LONG).show();
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 37 KiB