Add count number on tabs - #549

This commit is contained in:
stom79 2018-11-07 07:55:39 +01:00
parent d53befdbf9
commit 1620bdc58f
2 changed files with 13 additions and 4 deletions

View File

@ -81,8 +81,12 @@ public class TootInfoActivity extends BaseActivity {
Bundle b = getIntent().getExtras(); Bundle b = getIntent().getExtras();
if( getSupportActionBar() != null) if( getSupportActionBar() != null)
getSupportActionBar().hide(); getSupportActionBar().hide();
int toot_reblogs_count = 0;
int toot_favorites_count = 0;
if( b != null){ if( b != null){
toot_id = b.getString("toot_id", null); toot_id = b.getString("toot_id", null);
toot_reblogs_count = b.getInt("toot_reblogs_count", 0);
toot_favorites_count = b.getInt("toot_favorites_count", 0);
} }
if( toot_id == null){ if( toot_id == null){
Toast.makeText(this, R.string.toast_error, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.toast_error, Toast.LENGTH_SHORT).show();
@ -91,8 +95,8 @@ public class TootInfoActivity extends BaseActivity {
userID = sharedpreferences.getString(Helper.PREF_KEY_ID, null); userID = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
tabLayout = findViewById(R.id.tabLayout); tabLayout = findViewById(R.id.tabLayout);
mPager = findViewById(R.id.viewpager); mPager = findViewById(R.id.viewpager);
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.reblog))); tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.reblog) + " ("+toot_reblogs_count+")"));
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.favourite))); tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.favourite) + " ("+toot_favorites_count+")"));
PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager()); PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
mPager.setAdapter(mPagerAdapter); mPager.setAdapter(mPagerAdapter);

View File

@ -1346,10 +1346,15 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
case R.id.action_info: case R.id.action_info:
Intent intent = new Intent(context, TootInfoActivity.class); Intent intent = new Intent(context, TootInfoActivity.class);
Bundle b = new Bundle(); Bundle b = new Bundle();
if( status.getReblog() != null) if( status.getReblog() != null) {
b.putString("toot_id", status.getReblog().getId()); b.putString("toot_id", status.getReblog().getId());
else b.putInt("toot_reblogs_count", status.getReblog().getReblogs_count());
b.putInt("toot_favorites_count", status.getReblog().getFavourites_count());
}else {
b.putString("toot_id", status.getId()); b.putString("toot_id", status.getId());
b.putInt("toot_reblogs_count", status.getReblogs_count());
b.putInt("toot_favorites_count", status.getFavourites_count());
}
intent.putExtras(b); intent.putExtras(b);
context.startActivity(intent); context.startActivity(intent);
return true; return true;