Fixes a bug with conversations
Before Width: | Height: | Size: 148 KiB After Width: | Height: | Size: 144 KiB |
|
@ -57,7 +57,7 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
|
||||||
public static int position;
|
public static int position;
|
||||||
private SwipeRefreshLayout swipeRefreshLayout;
|
private SwipeRefreshLayout swipeRefreshLayout;
|
||||||
private ListView lv_status;
|
private ListView lv_status;
|
||||||
|
private boolean isRefreshed;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -79,6 +79,7 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
|
||||||
statusId = b.getString("statusId", null);
|
statusId = b.getString("statusId", null);
|
||||||
if( statusId == null)
|
if( statusId == null)
|
||||||
finish();
|
finish();
|
||||||
|
isRefreshed = false;
|
||||||
setTitle(R.string.conversation);
|
setTitle(R.string.conversation);
|
||||||
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeContainer);
|
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeContainer);
|
||||||
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ONESTATUS, statusId,null, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
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() {
|
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onRefresh() {
|
public void onRefresh() {
|
||||||
|
isRefreshed = true;
|
||||||
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ONESTATUS, statusId,null, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
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() {
|
( new Handler()).postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
isRefreshed = true;
|
||||||
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ONESTATUS, statusId,null, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ONESTATUS, statusId,null, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
@ -174,7 +177,6 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
|
||||||
if( context.getDescendants() != null && context.getDescendants().size() > 0){
|
if( context.getDescendants() != null && context.getDescendants().size() > 0){
|
||||||
for(Status status: context.getDescendants()){
|
for(Status status: context.getDescendants()){
|
||||||
statuses.add(status);
|
statuses.add(status);
|
||||||
statusId = status.getId();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RelativeLayout loader = (RelativeLayout) findViewById(R.id.loader);
|
RelativeLayout loader = (RelativeLayout) findViewById(R.id.loader);
|
||||||
|
@ -183,6 +185,12 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
|
||||||
statusListAdapter.notifyDataSetChanged();
|
statusListAdapter.notifyDataSetChanged();
|
||||||
loader.setVisibility(View.GONE);
|
loader.setVisibility(View.GONE);
|
||||||
lv_status.setVisibility(View.VISIBLE);
|
lv_status.setVisibility(View.VISIBLE);
|
||||||
lv_status.smoothScrollToPosition(position);
|
if( isRefreshed){
|
||||||
|
position = statuses.size()-1;
|
||||||
|
lv_status.setSelection(position);
|
||||||
|
}else {
|
||||||
|
lv_status.smoothScrollToPosition(position);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -654,9 +654,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
||||||
public void onTranslatedTextview(int position, String translatedResult, Boolean error) {
|
public void onTranslatedTextview(int position, String translatedResult, Boolean error) {
|
||||||
if( error){
|
if( error){
|
||||||
Toast.makeText(context, R.string.toast_error_translate, Toast.LENGTH_LONG).show();
|
Toast.makeText(context, R.string.toast_error_translate, Toast.LENGTH_LONG).show();
|
||||||
return;
|
}else if( statuses.size() > position) {
|
||||||
}
|
|
||||||
if( statuses.size() > position) {
|
|
||||||
try {
|
try {
|
||||||
JSONObject translationJson = new JSONObject(translatedResult);
|
JSONObject translationJson = new JSONObject(translatedResult);
|
||||||
JSONArray aJsonArray = translationJson.getJSONArray("text");
|
JSONArray aJsonArray = translationJson.getJSONArray("text");
|
||||||
|
@ -666,7 +664,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
||||||
statuses.get(position).setTranslationShown(true);
|
statuses.get(position).setTranslationShown(true);
|
||||||
statuses.get(position).setContent_translated(aJsonString);
|
statuses.get(position).setContent_translated(aJsonString);
|
||||||
statusListAdapter.notifyDataSetChanged();
|
statusListAdapter.notifyDataSetChanged();
|
||||||
} catch (JSONException | UnsupportedEncodingException e) {
|
} catch (JSONException | UnsupportedEncodingException | IllegalArgumentException e) {
|
||||||
Toast.makeText(context, R.string.toast_error_translate, Toast.LENGTH_LONG).show();
|
Toast.makeText(context, R.string.toast_error_translate, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 37 KiB |