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

View File

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