Merged in PhotonQyv/mastodon_etalab/ClickToTop (pull request #65)

ClickToTop: User can click on toolbarTitle to return to top of Timelines & Notifications.
This commit is contained in:
PhotonQyv 2017-08-20 05:53:26 +00:00 committed by tom79
commit fe024fa833
1 changed files with 33 additions and 1 deletions

View File

@ -235,11 +235,43 @@ public class MainActivity extends AppCompatActivity
}
}
});
if (Helper.THEME_MENU == sharedpreferences.getInt(Helper.SET_TABS, Helper.THEME_TABS)) {
toolbarTitle.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
int pos = tabLayout.getSelectedTabPosition();
Fragment fragment = (Fragment) viewPager.getAdapter().instantiateItem(viewPager, pos);
switch (pos) {
case 0:
case 2:
case 3:
DisplayStatusFragment displayStatusFragment = ((DisplayStatusFragment) fragment);
if (displayStatusFragment != null)
displayStatusFragment.scrollToTop();
break;
case 1:
DisplayNotificationsFragment displayNotificationsFragment = ((DisplayNotificationsFragment) fragment);
if (displayNotificationsFragment != null)
displayNotificationsFragment.scrollToTop();
break;
}
}
});
}
else {
toolbarTitle.setOnClickListener(null);
toolbar.setClickable(false);
}
for(int i = 0 ; i < 4 ; i++)
if( tabLayout.getTabAt(i) != null && tabLayout.getTabAt(i).getIcon() != null)
tabLayout.getTabAt(i).getIcon().setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
toolbar_search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {