This commit is contained in:
stom79 2019-01-26 14:10:48 +01:00
parent 10326a0e65
commit b77f629949
2 changed files with 6 additions and 20 deletions

View File

@ -2620,6 +2620,8 @@ public abstract class BaseMainActivity extends BaseActivity
FragmentTransaction fragTransaction = getSupportFragmentManager().beginTransaction(); FragmentTransaction fragTransaction = getSupportFragmentManager().beginTransaction();
String tag; String tag;
tag = finalTagTimelines.get(0).getName(); tag = finalTagTimelines.get(0).getName();
if( tagFragment.get(tag) == null)
return;
fragTransaction.detach(tagFragment.get(tag)); fragTransaction.detach(tagFragment.get(tag));
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
if( mediaOnly[0]) if( mediaOnly[0])
@ -2798,26 +2800,10 @@ public abstract class BaseMainActivity extends BaseActivity
dialogBuilder.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() { dialogBuilder.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
new SearchDAO(BaseMainActivity.this, db).remove(tag);
String tag;
if( position > 0 && tabLayout.getTabAt(position - 1).getText() != null) {
tag = tabLayout.getTabAt(position - 1).getText().toString();
}else if( tabLayout.getTabCount() > 1 && tabLayout.getTabAt(1).getText() != null) {
tag = tabLayout.getTabAt(1).getText().toString();
}else //Last element
tag = "";
Helper.removeTab(tabLayout, adapter, position);
adapter = new BaseMainActivity.PagerAdapter
(getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(adapter);
for(int i = 0; i < tabLayout.getTabCount() ; i++ ){
if( tabLayout.getTabAt(i).getText() != null && tabLayout.getTabAt(i).getText().equals(tag.trim())){
tabLayout.getTabAt(i).select();
break;
}
} new SearchDAO(BaseMainActivity.this, db).remove(tag);
Helper.refreshSearchTag(BaseMainActivity.this, tabLayout, adapter);
dialog.dismiss();
} }
}); });
dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

View File

@ -3015,7 +3015,7 @@ public class Helper {
tableLayout.setTabTextColors(ContextCompat.getColor(context, R.color.dark_text), ContextCompat.getColor(context, R.color.mastodonC4)); tableLayout.setTabTextColors(ContextCompat.getColor(context, R.color.dark_text), ContextCompat.getColor(context, R.color.mastodonC4));
} }
public static void removeTab(TabLayout tableLayout, BaseMainActivity.PagerAdapter pagerAdapter, int position) { private static void removeTab(TabLayout tableLayout, BaseMainActivity.PagerAdapter pagerAdapter, int position) {
if (tableLayout.getTabCount() >= position ) { if (tableLayout.getTabCount() >= position ) {
try { try {
if(tableLayout.getTabCount() > 0) if(tableLayout.getTabCount() > 0)