package com.example.cmknowledgegraph;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;

import com.example.ChatContentPkg.RecyclerViewFragment;
import com.github.florent37.materialviewpager.MaterialViewPager;
import com.github.florent37.materialviewpager.header.HeaderDesign;

public class tt extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chat);
//        Toolbar toolbar = findViewById(R.id.toolbar);
//        setSupportActionBar(toolbar);
//
//        FloatingActionButton fab = findViewById(R.id.fab);
//        fab.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
//                        .setAction("Action", null).show();
//            }
//        });
//        BoomMenuButton bmb = findViewById(R.id.bmb);
//        for (int i=0;i<bmb.getPiecePlaceEnum().pieceNumber();i++){
//            SimpleCircleButton.Builder builder = new SimpleCircleButton.Builder()
//                    .normalImageRes(R.drawable.draw1)//设置点开的图片
//                    //              设置阴影
////                    .shadowEffect(true)
////                    .shadowOffsetX(20).shadowOffsetY(0)
////                    .shadowRadius(Util.dp2px(20))
////                    .shadowCornerRadius(Util.dp2px(20))
////                    .shadowColor(Color.parseColor("#ee000000"))
////                    设置图片
//
//                    .highlightedImageRes(R.drawable.draw3)//点开某个按钮后突变的图片
//                    .unableImageRes(R.drawable.draw3)//unable时候的图片
//                    .imageRect(new Rect(Util.dp2px(10), Util.dp2px(10), Util.dp2px(70), Util.dp2px(70)))
//                    .imagePadding(new Rect(0, 0, 0, 0))
//                    .buttonCornerRadius(Util.dp2px(20))
////                    .unable(true),默认是假的
////                    设置按钮样式
//                    ;
//            bmb.addBuilder(builder);
//        }
//        final NavigationTabBar navigationTabBar = (NavigationTabBar) findViewById(R.id.ntb);
//        final ArrayList<NavigationTabBar.Model> models =  new ArrayList<>();
//        models.add(
//                new NavigationTabBar.Model.Builder(
//                        getResources().getDrawable(R.drawable.draw3),
//                        Color.parseColor("red")
//                ).title("论坛").badgeTitle("NTB").build());
//        models.add(
//                new NavigationTabBar.Model.Builder(
//                        getResources().getDrawable(R.drawable.draw1),
//                        Color.parseColor("blue")
//                ).title("drug").badgeTitle("drug").build()
//        );
//        navigationTabBar.setModels(models);
//        ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
//        viewPager.setAdapter(new PagerAdapter() {
//            @Override
//            public int getCount() {
//                return 0;
//            }
//
//            @Override
//            public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
//                return false;
//            }
//        });
//        navigationTabBar.setViewPager(viewPager,2);
//        navigationTabBar.setTitleMode(NavigationTabBar.TitleMode.ACTIVE);
//        navigationTabBar.setBadgeGravity(NavigationTabBar.BadgeGravity.BOTTOM);
//        navigationTabBar.setBadgePosition(NavigationTabBar.BadgePosition.CENTER);
//
//        navigationTabBar.setIsBadged(true);
//        navigationTabBar.setIsTitled(true);
//        navigationTabBar.setIsTinted(true);
//        navigationTabBar.setIsBadgeUseTypeface(true);
//        navigationTabBar.setBadgeBgColor(Color.RED);
//        navigationTabBar.setBadgeTitleColor(Color.WHITE);
//        navigationTabBar.setIsSwiped(true);
//        navigationTabBar.setBgColor(Color.BLACK);
//        navigationTabBar.setBadgeSize(10);
//        navigationTabBar.setTitleSize(10);
//        navigationTabBar.setIconSizeFraction((float) 0.5);
        //得到MaterviewPager实例
        MaterialViewPager materialViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager);
        //为MaterialViewPager添加监听
        materialViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {
            @Override
            public HeaderDesign getHeaderDesign(int page) {
                switch (page){
                    case 0:
                        return HeaderDesign.fromColorResAndUrl(
                                R.color.blue,
                                getResources().getDrawable(R.drawable.draw1).toString()
                        );
                    case 1:
                        return HeaderDesign.fromColorResAndUrl(
                                R.color.green,
                                getResources().getDrawable(R.drawable.draw2).toString()
                        );
                    case 2:
                        return HeaderDesign.fromColorResAndUrl(
                                R.color.cyan,
                                getResources().getDrawable(R.drawable.draw3).toString()
                        );

                }
                return null;
            }
        });
        //设置Toolbar
        Toolbar toolbar = materialViewPager.getToolbar();
        if(toolbar!=null){
            setSupportActionBar(toolbar);
            ActionBar actionBar = getSupportActionBar();
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayShowHomeEnabled(true);
            actionBar.setDisplayShowTitleEnabled(true);
            actionBar.setDisplayUseLogoEnabled(false);
            actionBar.setHomeButtonEnabled(true);
        }
        //为Viewpager设置适配器
        ViewPager viewPager = materialViewPager.getViewPager();
        viewPager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {
            @NonNull
            @Override
            public Fragment getItem(int position) {
                switch (position % 3){
                    case 0:
                        return RecyclerViewFragment.newInstance();
                    default:
                        return RecyclerViewFragment.newInstance();

                }
            }

            @Override
            public int getCount() {
                return 3;
            }

            @Nullable
            @Override
            public CharSequence getPageTitle(int position) {
                switch (position % 3){
                    case 0:
                        return "TAP1";
                    default:
                        return "TAPN";
                }
            }
        });
        materialViewPager.getViewPager().setOffscreenPageLimit(materialViewPager
                .getViewPager().getAdapter().getCount());
        materialViewPager.getPagerTitleStrip().setViewPager(materialViewPager.getViewPager());
    }




}
