タイトルを表示できるように WIP

This commit is contained in:
r-ca 2024-01-28 14:07:23 +09:00
parent 3a13b8e4b7
commit 0210bcaeb6
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
2 changed files with 11 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import android.widget.Toast;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
@ -102,6 +103,10 @@ public class ViewerContainerFragment extends Fragment {
ViewerViewPagerAdapter viewerViewPagerAdapter = new ViewerViewPagerAdapter(requireActivity());
viewPager.setAdapter(viewerViewPagerAdapter);
// Init tab layout
TabLayout tabLayout = view.findViewById(R.id.tab_layout);
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> tab.setText(viewerViewPagerAdapter.getTabTitle(position))).attach();
// Init toolbar
Toolbar toolbar = view.findViewById(R.id.toolbar);
initToolbar(toolbar, true, documentName);
@ -119,7 +124,6 @@ public class ViewerContainerFragment extends Fragment {
});
} else {
logger.debug("ViewerContainerFragment", "hasCombined: " + hasCombined);
TabLayout tabLayout = view.findViewById(R.id.tab_layout);
tabLayout.setVisibility(View.GONE);
viewerViewPagerAdapter.addFragment(ViewerBodyFragment.newInstance(documentId, documentName), documentName);
}

View File

@ -1,6 +1,7 @@
package one.nem.lacerta.component.viewer;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
@ -35,4 +36,9 @@ public class ViewerViewPagerAdapter extends FragmentStateAdapter {
public int getItemCount() {
return fragmentArrayList == null ? 0 : fragmentArrayList.size();
}
@Nullable
public CharSequence getTabTitle(int position) {
return fragmentTitleList.get(position);
}
}