Fixes some issues

This commit is contained in:
stom79 2017-10-24 11:44:07 +02:00
parent f809094efa
commit f6ad7d74e2
2 changed files with 35 additions and 30 deletions

View File

@ -28,6 +28,7 @@ import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
@ -40,7 +41,6 @@ import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
@ -98,7 +98,7 @@ public class RemoteFollowActivity extends AppCompatActivity implements OnRetriev
private EditText rf_username;
private TextView rf_no_result;
private Button rf_search;
private ListView lv_account;
private RecyclerView lv_account;
private RelativeLayout loader;
private boolean isLoadingInstance;
private String instance_name, screen_name;
@ -115,12 +115,12 @@ public class RemoteFollowActivity extends AppCompatActivity implements OnRetriev
}
setContentView(R.layout.activity_remote_follow);
rf_instance = (AutoCompleteTextView) findViewById(R.id.rf_instance);
rf_username = (EditText) findViewById(R.id.rf_username);
rf_search = (Button) findViewById(R.id.rf_search);
loader = (RelativeLayout) findViewById(R.id.loader);
lv_account = (ListView) findViewById(R.id.lv_account);
rf_no_result = (TextView) findViewById(R.id.rf_no_result);
rf_instance = findViewById(R.id.rf_instance);
rf_username = findViewById(R.id.rf_username);
rf_search = findViewById(R.id.rf_search);
loader = findViewById(R.id.loader);
lv_account = findViewById(R.id.lv_account);
rf_no_result = findViewById(R.id.rf_no_result);
if( theme == Helper.THEME_LIGHT) {
rf_search.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.white));
}
@ -131,10 +131,10 @@ public class RemoteFollowActivity extends AppCompatActivity implements OnRetriev
@SuppressLint("InflateParams") View view = inflater.inflate(R.layout.conversation_action_bar, null);
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
TextView title = (TextView) actionBar.getCustomView().findViewById(R.id.toolbar_title);
pp_actionBar = (ImageView) actionBar.getCustomView().findViewById(R.id.pp_actionBar);
TextView title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
pp_actionBar = actionBar.getCustomView().findViewById(R.id.pp_actionBar);
title.setText(R.string.remote_follow_menu);
ImageView close_conversation = (ImageView) actionBar.getCustomView().findViewById(R.id.close_conversation);
ImageView close_conversation = actionBar.getCustomView().findViewById(R.id.close_conversation);
if( close_conversation != null){
close_conversation.setOnClickListener(new View.OnClickListener() {
@Override

View File

@ -22,11 +22,11 @@ import android.os.Parcelable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Toast;
@ -63,7 +63,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
private SwipeRefreshLayout swipeRefreshLayout;
private String targetedId;
private boolean swiped;
private ListView lv_accounts;
private RecyclerView lv_accounts;
boolean hideHeader;
@Override
@ -109,23 +109,28 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
//Hide account header when scrolling for ShowAccountActivity
if (hideHeader && Build.VERSION.SDK_INT >= 21)
ViewCompat.setNestedScrollingEnabled(lv_accounts, true);
lv_accounts.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (firstVisibleItem + visibleItemCount == totalItemCount) {
if (!flag_loading) {
flag_loading = true;
if (type != RetrieveAccountsAsyncTask.Type.FOLLOWERS && type != RetrieveAccountsAsyncTask.Type.FOLLOWING)
asyncTask = new RetrieveAccountsAsyncTask(context, type, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else
asyncTask = new RetrieveAccountsAsyncTask(context, type, targetedId, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
nextElementLoader.setVisibility(View.VISIBLE);
final LinearLayoutManager mLayoutManager;
mLayoutManager = new LinearLayoutManager(context);
lv_accounts.setLayoutManager(mLayoutManager);
lv_accounts.addOnScrollListener(new RecyclerView.OnScrollListener() {
public void onScrolled(RecyclerView recyclerView, int dx, int dy)
{
if(dy > 0) {
int visibleItemCount = mLayoutManager.getChildCount();
int totalItemCount = mLayoutManager.getItemCount();
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
if (firstVisibleItem + visibleItemCount == totalItemCount) {
if (!flag_loading) {
flag_loading = true;
if (type != RetrieveAccountsAsyncTask.Type.FOLLOWERS && type != RetrieveAccountsAsyncTask.Type.FOLLOWING)
asyncTask = new RetrieveAccountsAsyncTask(context, type, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else
asyncTask = new RetrieveAccountsAsyncTask(context, type, targetedId, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
nextElementLoader.setVisibility(View.VISIBLE);
}
} else {
nextElementLoader.setVisibility(View.GONE);
}
} else {
nextElementLoader.setVisibility(View.GONE);
}
}
});