mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2023-12-13 20:50:18 +01:00
6a84e4d897
Extend CI workflows (-> https://codeberg.org/gitnex/GitNex/issues/1099) 1. pull translations and push them again on every pull @mmarif this needs the secrets and `BOT_TOKEN` the code for this comes from tea4j-autodeploy 2. add a **template** for a check workflow which only does some static checks right now. It is disabled because it requires some investigation and discussion on how we should deal with these issues. The checks are currently (if we would enable it): 1. check code style and formatting according to the project file in `.idea/` 2. make sure every Java file has an `@author` annotation I would wait until you reviewed with enabling them because we have to reformat all the files which results in changes with a few thousand changed lines (tried this once). Closes https://codeberg.org/gitnex/GitNex/issues/141 Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1155 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
99 lines
2.9 KiB
Java
99 lines
2.9 KiB
Java
package org.mian.gitnex.fragments;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Typeface;
|
|
import android.os.Bundle;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.TextView;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
|
import androidx.viewpager2.widget.ViewPager2;
|
|
import com.google.android.material.tabs.TabLayout;
|
|
import com.google.android.material.tabs.TabLayoutMediator;
|
|
import org.mian.gitnex.R;
|
|
import org.mian.gitnex.activities.MainActivity;
|
|
import org.mian.gitnex.helpers.AppUtil;
|
|
import org.mian.gitnex.helpers.TinyDB;
|
|
|
|
/**
|
|
* @author M M Arif
|
|
*/
|
|
|
|
public class ExploreFragment extends Fragment {
|
|
|
|
@Nullable
|
|
@Override
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
|
View view = inflater.inflate(R.layout.fragment_explore, container, false);
|
|
|
|
Context ctx = getContext();
|
|
TinyDB tinyDB = TinyDB.getInstance(ctx);
|
|
|
|
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.pageTitleExplore));
|
|
|
|
ViewPager2 viewPager = view.findViewById(R.id.containerExplore);
|
|
viewPager.setOffscreenPageLimit(1);
|
|
TabLayout tabLayout = view.findViewById(R.id.tabsExplore);
|
|
|
|
ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
|
|
|
|
Typeface myTypeface = AppUtil.getTypeface(requireContext());
|
|
viewPager.setAdapter(new ViewPagerAdapter(this));
|
|
|
|
String[] tabTitles = {getResources().getString(R.string.navRepos), getResources().getString(R.string.pageTitleIssues), getResources().getString(R.string.navOrg), getResources().getString(R.string.pageTitleUsers)};
|
|
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> tab.setText(tabTitles[position])).attach();
|
|
|
|
for (int j = 0; j < tabTitles.length; j++) {
|
|
|
|
ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
|
|
int tabChildCount = vgTab.getChildCount();
|
|
|
|
for (int i = 0; i < tabChildCount; i++) {
|
|
View tabViewChild = vgTab.getChildAt(i);
|
|
if (tabViewChild instanceof TextView) {
|
|
((TextView) tabViewChild).setTypeface(myTypeface);
|
|
}
|
|
}
|
|
}
|
|
|
|
return view;
|
|
}
|
|
|
|
public static class ViewPagerAdapter extends FragmentStateAdapter {
|
|
|
|
public ViewPagerAdapter(@NonNull ExploreFragment fa) { super(fa); }
|
|
|
|
@NonNull
|
|
@Override
|
|
public Fragment createFragment(int position) {
|
|
Fragment fragment = null;
|
|
switch(position) {
|
|
case 0: // Repositories
|
|
fragment = new ExploreRepositoriesFragment();
|
|
break;
|
|
case 1: // Issues
|
|
fragment = new ExploreIssuesFragment();
|
|
break;
|
|
case 2: // Organizations
|
|
fragment = new ExplorePublicOrganizationsFragment();
|
|
break;
|
|
case 3: // Users
|
|
fragment = new ExploreUsersFragment();
|
|
break;
|
|
}
|
|
assert fragment != null;
|
|
return fragment;
|
|
}
|
|
|
|
@Override
|
|
public int getItemCount() {
|
|
return 4;
|
|
}
|
|
}
|
|
}
|