package com.yutou.jianr_mg.Adapters;

import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.fragment.app.FragmentActivity;

import com.yutou.jianr_mg.R;
import com.yutou.jianr_mg.views.MapTopActivity;

import cn.lemon.view.adapter.BaseViewHolder;
import cn.lemon.view.adapter.RecyclerAdapter;

public class MapRecyclierAdapter extends RecyclerAdapter<String> {

    public MapRecyclierAdapter(Context context) {
        super(context);
    }

    @Override
    public BaseViewHolder<String> onCreateBaseViewHolder(ViewGroup parent, int viewType) {

        return new ItemViewHolder(parent,R.layout.item_maptop);
    }
    class ItemViewHolder extends BaseViewHolder<String>{
        private LinearLayout listLayout,titleLayout;
        private TextView name;

        public ItemViewHolder(ViewGroup parent, int layoutId) {
            super(parent, layoutId);
            listLayout=findViewById(R.id.listLayout);
            titleLayout=findViewById(R.id.titleLayout);
            name=findViewById(R.id.title);
            listLayout.setVisibility(View.GONE);
        }

        @Override
        public void setData(String data) {
            super.setData(data);
            name.setText(data);
        }

        @Override
        public void onItemViewClick(String data) {
            super.onItemViewClick(data);
            Intent intent=new Intent(getContext(), MapTopActivity.class);
            intent.putExtra("level_name", data);
            getContext().startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(((FragmentActivity)getContext()),name,"transitionTitle").toBundle());
        }
    }
}
