This commit is contained in:
stom79 2018-12-06 19:05:29 +01:00
parent fa1bc9f545
commit a27ffa3dfa
2 changed files with 33 additions and 1 deletions

View File

@ -206,6 +206,8 @@ public abstract class BaseMainActivity extends BaseActivity
private int style;
private Activity activity;
private HashMap<String, Integer> tabPosition = new HashMap<>();
private FloatingActionButton federatedTimelines;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -339,7 +341,7 @@ public abstract class BaseMainActivity extends BaseActivity
}else {
style = R.style.Dialog;
}
FloatingActionButton federatedTimelines = findViewById(R.id.federated_timeline);
federatedTimelines = findViewById(R.id.federated_timeline);
delete_instance.setOnClickListener(new View.OnClickListener() {
@Override
@ -2727,6 +2729,24 @@ public abstract class BaseMainActivity extends BaseActivity
}
public void manageFloatingButton(boolean display){
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
boolean displayFollowInstance = sharedpreferences.getBoolean(Helper.SET_DISPLAY_FOLLOW_INSTANCE, true);
if(display){
toot.show();
if( !displayFollowInstance)
federatedTimelines.hide();
else
federatedTimelines.show();
}else{
toot.hide();
federatedTimelines.hide();
}
}
public boolean getFloatingVisibility(){
return toot.getVisibility() == View.VISIBLE;
}
public void refreshButton(){
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
FloatingActionButton federatedTimelines = findViewById(R.id.federated_timeline);

View File

@ -178,6 +178,12 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
lv_status.addOnScrollListener(new RecyclerView.OnScrollListener() {
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy)
{
if (context instanceof BaseMainActivity ) {
if( dy < 0 && !((BaseMainActivity)context).getFloatingVisibility() )
((BaseMainActivity) context).manageFloatingButton(true);
if( dy > 0 && ((BaseMainActivity)context).getFloatingVisibility() )
((BaseMainActivity) context).manageFloatingButton(false);
}
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
if(dy > 0){
int visibleItemCount = mLayoutManager.getChildCount();
@ -219,6 +225,12 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
editor.apply();
}
}
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
}
});