public class DrawerListAdapter extends ArrayAdapter<NavigationSelect> {

    private Context context = null;
    private int resource;
    private ArrayList<NavigationSelect> navigationSelects;


    public DrawerListAdapter(Context context, int resource, NavigationSelect[] objects) {
        super(context, resource, objects);
        this.context = context;
        this.resource = resource;

    }

    public DrawerListAdapter(Context context, int resource, ArrayList<NavigationSelect> objects) {
        super(context, resource, objects);
        this.context = context;
        this.resource = resource;
        this.navigationSelects = objects;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View view = null;
        if(position == 0)
        {
            view = inflater.inflate(R.layout.drawer_text_item, parent, false);
        }
        else if(position == 1)
        {
            view = inflater.inflate(R.layout.drawer_item_logo, parent, false);

        }else
        {
            view = inflater.inflate(R.layout.drawer_item, parent, false);
            TextView textTitle = (TextView) view.findViewById(R.id.drawer_text);
            textTitle.setText(navigationSelects.get(position).getTitle());
            ImageView imageLogo = (ImageView) view.findViewById(R.id.drawer_image);
            imageLogo.setBackgroundResource(navigationSelects.get(position).getDrawableId());
        }
        return view;
    }
} public class NavigationBarAdapter extends ArrayAdapter<ColorSelect> {

    private Context context = null;
    private int resource;
    private List<ColorSelect> colorSelect;


    public NavigationBarAdapter(Context context, int resource, ColorSelect[] objects) {
        super(context, resource, objects);
        this.context = context;
        this.resource = resource;

    }

    public NavigationBarAdapter(Context context, int resource, List<ColorSelect> objects) {
        super(context, resource, objects);
        this.context = context;
        this.resource = resource;
        this.colorSelect = objects;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.navigation_row, parent, false);
        TextView textColorName = (TextView) view.findViewById(R.id.colorName);
        textColorName.setText(colorSelect.get(position).getTitle());
        return view;
    }
} public class SaveListAdapter extends RecyclerView.Adapter<SaveListAdapter.ViewHolder>{

    private List<Model> mDataset;
    private Context context;

    public static class ViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.color_layout)
        RelativeLayout mColorLayout;

        @BindView(R.id.color_text_view)
        TextView mColorTextView;

        @BindView(R.id.delete_saved_list)
        ImageView mDeleteImageView;



        public ViewHolder(View v) {
            super(v);
            ButterKnife.bind(this, v);
        }
    }

    public void add(int position, Model item) {
        mDataset.add(position, item);
        notifyItemInserted(position);
    }

    public void remove(String item) {
        int position = mDataset.indexOf(item);
        mDataset.remove(position);
        notifyItemRemoved(position);
    }

    public SaveListAdapter(List<Model> myDataset){
        this.mDataset = myDataset;
    }

    @Override
    public SaveListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        int layout = R.layout.saved_list_item;
        View v = LayoutInflater.from(parent.getContext()).inflate(layout, parent, false);
        context = parent.getContext();
        ViewHolder vh = new ViewHolder(v);
        return vh;
    }

    @Override
    public void onBindViewHolder(SaveListAdapter.ViewHolder holder, final int position) {
        holder.mColorTextView.setText(this.mDataset.get(position).getColorCode());
        holder.mColorLayout.setBackgroundColor(Color.parseColor(this.mDataset.get(position).getColorCode()));
        holder.mDeleteImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    mDataset.remove(position);
                    notifyDataSetChanged();
                }catch (Exception e){}
            }
        });

    }

    @Override
    public int getItemViewType(int position) {
        return 0;
    }

    @Override
    public int getItemCount() {
        return mDataset.size();
    }
} public class ViewPagerAdapter extends FragmentPagerAdapter {

    private final List<Fragment> fragmentList = new ArrayList<>();
    private final List<String> fragmentTitleList = new ArrayList<>();


    public ViewPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }

    @Override
    public int getCount() {
        return fragmentList.size();
    }

    public void addFragment(Fragment fragment,String title)
    {
        fragmentList.add(fragment);
        fragmentTitleList.add(title);
    }

    @Override
    public CharSequence getPageTitle(int position)
    {
        return fragmentTitleList.get(position);
    }

} public class YourColorAdapter extends RecyclerView.Adapter<YourColorAdapter.ViewHolder>{

    private int sayac = 0;
    private List<SavedObject> mDataset;
    private Context context;
    private boolean isDeleted = false;

    private OnItemDelete mListener = null;

    public interface OnItemDelete{
        void onItemDelete(String name);
        void onItemDelete(String name,int position);
        void onClickedPosition(int position);
        void onDeleteAlert(String name,int position);
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.dynamic_linear_layout)
        LinearLayout mLayout;

        @BindView(R.id.color_palette_name)
        TextView mPaletteName;

        @BindView(R.id.delete_saved_query)
        ImageButton mDeleteButton;

        @BindView(R.id.palette_share)
        ImageButton mShareButton;


        public ViewHolder(View v) {
            super(v);
            ButterKnife.bind(this, v);
        }
    }

    public void add(int position, SavedObject item) {
        mDataset.add(position, item);
        notifyItemInserted(position);
    }

    public void remove(String item) {
        int position = mDataset.indexOf(item);
        mDataset.remove(position);
        notifyItemRemoved(position);
    }

    public YourColorAdapter(List<SavedObject> myDataset){
        this.mDataset = myDataset;
    }

    public YourColorAdapter(List<SavedObject> myDataset, OnItemDelete listener){
        this.mDataset = myDataset;
        this.mListener = listener;
    }

    @Override
    public YourColorAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        int layout = R.layout.your_color_item;
        View v = LayoutInflater.from(parent.getContext()).inflate(layout, parent, false);
        context = parent.getContext();
        ViewHolder vh = new ViewHolder(v);
        return vh;
    }

    @Override
    public void onBindViewHolder(YourColorAdapter.ViewHolder holder, final int position) {
        if(context != null){
            if(!isDeleted){
                final SavedObject object = this.mDataset.get(position);
                holder.mPaletteName.setText(object.getName());
                holder.mLayout.removeAllViews();
                for (Model m: object.getList()) {
                    LinearLayout l1 = new LinearLayout(context);
                    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
                    params.weight = 1.0f;
                    l1.setLayoutParams(params);
                    l1.setBackgroundColor(Color.parseColor(m.getColorCode()));
                    holder.mLayout.addView(l1);
                }

                holder.mLayout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        if(mListener != null)
                            mListener.onClickedPosition(position);
                    }
                });

                holder.mDeleteButton.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        Log.e("TAG", "onClick: Deleted" );
                        if(mListener != null){
                            //isDeleted = true;
                            mListener.onDeleteAlert(object.getName(), position);
                            //mListener.onItemDelete(object.getName(), position);
                            //notifyDataSetChanged();
                        }
                    }
                });

                holder.mShareButton.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                    }
                });
            }


        }
    }

    @Override
    public int getItemViewType(int position) {
        return position == 10 ? 1 : 0;
    }

    @Override
    public int getItemCount() {
        return mDataset.size();
    }
} public class AdsUtils {

    public static boolean TEST = true;
    private Context context = null;
    private static InterstitialAd mInterstitialAd = null;
    private int mInteractionValue = 0;
    private static int INTERACT_THRESHOLD = 12;


    private static AdsUtils instance = null;

    public static AdsUtils getInstance(){
        if(instance == null)
            instance = new AdsUtils();
        return instance;
    }

    public boolean showAds(){
        if(mInterstitialAd.isLoaded()){
            mInterstitialAd.show();
            return true;
        }else{
            requestNewInterstitial();
            return false;
        }
    }


    private void load(){
        if(mInterstitialAd == null){
            mInterstitialAd = new InterstitialAd(context);
            mInterstitialAd.setAdUnitId(context.getString(R.string.admob_inter_app_pub));
            mInterstitialAd.setAdListener(new AdListener() {
                @Override
                public void onAdClosed() {
                    Log.e("TAG","onAdClosed and new Request Interstitial");
                    requestNewInterstitial();
                }
            });
            requestNewInterstitial();
        }
    }

    public Context getContext() {
        return context;
    }

    public void setContext(Context context) {
        this.context = context;
        load();
    }

    private void requestNewInterstitial() {
        AdRequest ret = null;
        TEST = BuildConfig.DEBUG;
        if (TEST) {
            ret = new AdRequest.Builder()
                    .addTestDevice("0A02E72208689385EF8EE5F0CCCFE947")
                    .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                    .addTestDevice("9552A433781FF6F1766BC1BDF72022E5")
                    .build();
        } else {
            ret = new AdRequest.Builder().build();
        }
        mInterstitialAd.loadAd(ret);
    }

    public void increaseInteraction(){
        mInteractionValue++;
        controlInteraction();
    }

    private void controlInteraction() {
        if(mInteractionValue % INTERACT_THRESHOLD == 0) //  if removed ads, ads will not show on screen
            showAds();
    }

} public class ColorArrayController {
    private List<ColorInfo> materialList = null;
    private List<ColorInfo> flatList = null;
    private List<ColorInfo> socialList = null;
    private List<ColorInfo> metroList = null;
    private List<ColorInfo> htmlList = null;
    private String[] headerColorList = null;

    private List<MaterialColorInfo> materialColorInfoList = null;

    private Resources resources = null;

    private static ColorArrayController ourInstance = null;

    public static ColorArrayController getInstance()
    {
        if(ourInstance == null)
            ourInstance = new ColorArrayController();
        return ourInstance;
    }

    private ColorArrayController() {
        materialList = new ArrayList<ColorInfo>();
        flatList = new ArrayList<ColorInfo>();
        socialList = new ArrayList<ColorInfo>();
        metroList = new ArrayList<ColorInfo>();
        htmlList = new ArrayList<ColorInfo>();
        materialColorInfoList = new ArrayList<MaterialColorInfo>();
    }

    public void init()
    {
        initMaterial();
        initFlat();
        initMetro();
        initSocial();
        initHtml();
    }

    public void setResource(Resources resource)
    {
        this.resources = resource;
    }

    public void initMaterial()
    {
        if(resources == null)
            return;
        materialColorInfoList.clear();

        int[] arrayId = new int[]{
                R.array.MaterialColorCodeRed,R.array.MaterialColorCodePink ,R.array.MaterialColorCodePurple ,
                R.array.MaterialColorCodeDeepPurple ,R.array.MaterialColorCodeIndigo ,R.array.MaterialColorCodeBlue ,
                R.array.MaterialColorCodeLightBlue ,R.array.MaterialColorCodeCyan ,R.array.MaterialColorCodeTeal ,
                R.array.MaterialColorCodeGreen ,R.array.MaterialColorCodeLightGreen ,R.array.MaterialColorCodeLime ,
                R.array.MaterialColorCodeYellow ,R.array.MaterialColorCodeAmber ,R.array.MaterialColorCodeOrange ,
                R.array.MaterialColorCodeDeepOrange ,R.array.MaterialColorCodeBrown ,R.array.MaterialColorCodeGrey ,
                R.array.MaterialColorCodeBlueGrey
        };

        String[] colorNames = resources.getStringArray(R.array.MaterialColorCodeName);

        for(int i = 0; i < arrayId.length; i++)
        {
            String[] colorCodes = resources.getStringArray(arrayId[i]);
            List<ColorInfo> list  = new ArrayList<ColorInfo>();
            for(int j = 0; j< colorCodes.length;j++)
                list.add(new ColorInfo(colorNames[j],colorCodes[j].toUpperCase()));
            materialColorInfoList.add(new MaterialColorInfo(list));
            list.clear();
        }
    }

    public List<MaterialColorInfo> getMaterialColorInfoList()
    {
        return this.materialColorInfoList;
    }

    public void initFlat()
    {
        if(resources == null)
            return;
        flatList.clear();
        String[] colorCodes = resources.getStringArray(R.array.FlatColorCode);
        String[] colorNames = resources.getStringArray(R.array.FlatColorName);
        for(int i = 0; i< colorCodes.length;i++)
            flatList.add(new ColorInfo(colorNames[i],colorCodes[i].toUpperCase()));
    }
    public void initSocial()
    {
        if(resources == null)
            return;
        socialList.clear();
        String[] colorCodes = resources.getStringArray(R.array.SocialColorCode);
        String[] colorNames = resources.getStringArray(R.array.SocialColorName);
        for(int i = 0; i< colorCodes.length;i++)
            socialList.add(new ColorInfo(colorNames[i],colorCodes[i].toUpperCase()));
    }
    public void initMetro()
    {
        if(resources == null)
            return;
        metroList.clear();
        String[] colorCodes = resources.getStringArray(R.array.MetroColorCode);
        String[] colorNames = resources.getStringArray(R.array.MetroColorName);
        for(int i = 0; i< colorCodes.length;i++)
            metroList.add(new ColorInfo(colorNames[i],colorCodes[i].toUpperCase()));
    }

    public List<String> getMaterialNameList()
    {
        List<String> list = new ArrayList<String>();
        String[] colorNames = resources.getStringArray(R.array.MaterialColorNames);
        list = Arrays.asList(colorNames);
//        for(int i = 0; i< colorNames.length;i++)
//            list.add(colorNames[i]);
        return list;
    }

    public void initHtml()
    {
        if(resources == null)
            return;
        htmlList.clear();
        String[] colorCodes = resources.getStringArray(R.array.HtmlColorCode);
        String[] colorNames = resources.getStringArray(R.array.HtmlColorName);
        //htmlList.addAll()
        for(int i = 0; i< colorCodes.length;i++)
            htmlList.add(new ColorInfo(colorNames[i],colorCodes[i].toUpperCase()));
    }



    public List<ColorSelect> getMaterialNameColorSelectList()
    {
        List<ColorSelect> list = new ArrayList<ColorSelect>();
        String[] colorNames = resources.getStringArray(R.array.MaterialColorNames);
        for(int i = 0; i< colorNames.length;i++)
            list.add(new ColorSelect(colorNames[i]));
        return list;
    }

    public void setMaterialList(ArrayList<ColorInfo> list)
    {
        this.materialList = list;
    }
    public List<ColorInfo> getMaterialList()
    {
        return this.materialList;
    }

    public void setFlatList(ArrayList<ColorInfo> list)
    {
        this.flatList = list;
    }
    public List<ColorInfo> getFlatList()
    {
        return this.flatList;
    }
    public void setSocialList(List<ColorInfo> list)
    {
        this.socialList = list;
    }
    public List<ColorInfo> getSocialList()
    {
        return this.socialList;
    }
    public void setMetroList(List<ColorInfo> list)
    {
        this.metroList = list;
    }
    public List<ColorInfo> getMetroList()
    {
        return this.metroList;
    }
    public void setHtmlList(List<ColorInfo> list)
    {
        this.htmlList = list;
    }
    public List<ColorInfo> getHtmlList()
    {
        return this.htmlList;
    }

    public String getHeaderColorName(int index)
    {
        if(resources == null)
            return null;
        if(headerColorList == null)
            headerColorList =  resources.getStringArray(R.array.HeaderColorName);

        if(index > headerColorList.length)
            return null;

        return  headerColorList[index];
    }





} public class DrawerListController {
    private static DrawerListController ourInstance = null;

    private String[] nameList = new String[]{
            null,
            null,
            "Your Colors",
            "Color Picker",
            "Rate This App",
            "Share This App",
            "About Us"
    };
    private int[] idList = new int[]{
            -1,
            -1,
            R.drawable.ic_action_favorites,
            R.drawable.ic_action_color_palette,
            R.drawable.ic_action_rate2,
            R.drawable.ic_action_share,
            R.drawable.ic_action_about_us
    };

    private ArrayList<NavigationSelect> navList = null;
    public static DrawerListController getInstance()
    {
        if(ourInstance == null)
            ourInstance = new DrawerListController();
        return ourInstance;
    }

    private DrawerListController() {
        if(navList == null)
            navList = new ArrayList<NavigationSelect>();
        else
            navList.clear();
        for(int i = 0;i<idList.length; i++)
        {
            navList.add(new NavigationSelect(nameList[i],idList[i]));
        }
    }
    public ArrayList<NavigationSelect> getNavList()
    {
        return this.navList;
    }

} public class ToolBarController {
    private Toolbar toolbar = null;
    private TabLayout tabLayout = null;
    private static ToolBarController ourInstance = new ToolBarController();

    public static ToolBarController getInstance() {
        return ourInstance;
    }

    private ToolBarController() {
    }

    public void setToolBar(Toolbar toolBar)
    {
        this.toolbar = toolBar;
    }
    public void setTabLayout(TabLayout tabLayout)
    {
        this.tabLayout = tabLayout;
    }
    public Toolbar getToolbar()
    {
        return this.toolbar;
    }

    public void setColor(int color)
    {
        this.tabLayout.setBackgroundColor(color);
        this.toolbar.setBackgroundColor(color);
    }
    public void setTextColor(int color)
    {
        this.tabLayout.setTabTextColors(color,color);
        toolbar.setTitleTextColor(color);
    }



} public class RealmX {

    private static Realm realm;

    private static void getRealm(){
        try {
            realm = Realm.getDefaultInstance();
        }catch (Exception e){
            Log.e("TAG","Exception Exception " + e.getMessage());
//            RealmConfiguration config = new RealmConfiguration.Builder().deleteRealmIfMigrationNeeded().build();
//            realm = Realm.getInstance(config);
        }
    }

    public static Realm realm(){
        if(realm == null)
            getRealm();
        return realm;
    }


    public static void closeRealm(){
        if(realm != null){
            if(!realm.isClosed()){
                realm.close();
            }
        }
    }


    public static void save(final SavedObject object) {
        getRealm();
        realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                realm.copyToRealm(object);
                //closeRealm();
            }
        });
    }

    public static void list(){
        getRealm();
        RealmResults<SavedObject> res = realm.where(SavedObject.class)
                .findAll();

        for (SavedObject s : res ) {
            Log.e("TAG", "list: " + s.getName() );
            for (Model m : s.getList() ) {
                Log.e("TAG", "list::: " +  m.getColorCode() );
            }
            Log.e("TAG", "---------------------" );
        }

        //closeRealm();
    }

    public static RealmResults<SavedObject> getObject(){
        RealmResults<SavedObject> res = realm.where(SavedObject.class).findAll();
        return res;
    }

    public static SavedObject getObject(String name){
        SavedObject res = realm.where(SavedObject.class)
                .equalTo("name",name)
                .findFirst();
        return res;
    }

    public static void setList(final String name, List<Model> list){
        final RealmList<Model> realmList = new RealmList<>();
        realmList.addAll(list);
        realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                SavedObject res = realm.where(SavedObject.class)
                        .equalTo("name",name)
                        .findFirst();
                res.setList(realmList);
                Log.e("TAG", "execute: execute" );
            }
        });
    }

    public static void deleteObject(final String name) {

        realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                RealmResults<SavedObject> list = realm.where(SavedObject.class).equalTo("name",name).findAll();
                list.deleteAllFromRealm();
            }
        });
    }
} public class SavedObject extends RealmObject {

    private String name;
    private RealmList<Model> list;

    public SavedObject(){}

    public SavedObject(String name, RealmList<Model> list){
        setName(name);
        setList(list);
    }
    public SavedObject(RealmList<Model> list){
        setList(list);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Model> getList() {
        return list;
    }

    public void addList(List<Model> lists){
        RealmX.realm().beginTransaction();
        this.list.clear();
        this.list.addAll(lists);
        RealmX.realm().commitTransaction();
    }

    public void setList(RealmList<Model> list) {
        this.list = list;
    }

    public void setNameQuery(String name){
        RealmX.realm().beginTransaction();
        this.name = name;
        RealmX.realm().commitTransaction();
    }

} public class YourColorActivity extends AppCompatActivity implements YourColorAdapter.OnItemDelete{


    @BindView(R.id.recyclerview)
    RecyclerView mRecyclerView;

    private YourColorAdapter mAdapter;

    private List<SavedObject> modelList = new ArrayList<>();


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_your_color);
        ButterKnife.bind(this);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        toolbar.setNavigationIcon(R.drawable.ic_action_back_button);
        getSupportActionBar().setTitle("Your Colors");
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onBackPressed();
            }
        });
        loadAdapters();
    }


    @Override
    protected void onResume() {
        if(mAdapter != null){
            RealmResults<SavedObject> list = RealmX.getObject();
            modelList.clear();
            modelList.addAll(list);
            mAdapter.notifyDataSetChanged();
        }
        super.onResume();
    }

    private void loadAdapters() {
        RealmResults<SavedObject> list = RealmX.getObject();
        modelList.addAll(list);

        LinearLayoutManager manager = new LinearLayoutManager(this);
        mRecyclerView.setLayoutManager(manager);
        mRecyclerView.setHasFixedSize(true);

        mAdapter = new YourColorAdapter(modelList,this);
        mRecyclerView.setAdapter(mAdapter);

//        mRecyclerView.addOnItemTouchListener(new RecyclerItemClickListener(getApplicationContext(), new RecyclerItemClickListener.OnItemClickListener() {
//            @Override
//            public void onItemClick(View view, int position) {
//                Log.e("TAG","Clicked item position " + position);
//                ColorBus.getInstance().setSavedObject(modelList.get(position));
//                startActivity(new Intent(YourColorActivity.this, ColorActivity.class));
//            }
//        }));
    }

    @Override
    public void onItemDelete(String name) {
    }

    @Override
    public void onItemDelete(String name, int position) {
        try {
            RealmX.deleteObject(name);
            RealmResults<SavedObject> list = RealmX.getObject();
            modelList.clear();
            modelList.addAll(list);
            mAdapter = new YourColorAdapter(modelList,this);
            mRecyclerView.setAdapter(mAdapter);
        }catch (IllegalStateException ex){
            ex.printStackTrace();
        }
        AdsUtils.getInstance().increaseInteraction();
    }

    @Override
    public void onClickedPosition(int position) {
        ColorBus.getInstance().setSavedObject(modelList.get(position));
        startActivity(new Intent(YourColorActivity.this, ColorActivity.class));
    }

    @Override
    public void onDeleteAlert(final String name, final int position) {

        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(YourColorActivity.this);

        // set title
        alertDialogBuilder.setTitle(getString(R.string.delete_saved_object));
        alertDialogBuilder
                .setMessage(getString(R.string.delete_file_ask))
                .setCancelable(false)
                .setPositiveButton(getString(R.string.answer_yes),new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog,int id) {
                        onItemDelete(name,position);
                        dialog.dismiss();
                    }
                })
                .setNegativeButton(getString(R.string.answer_no),new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });

        // create alert dialog
        AlertDialog alertDialog = alertDialogBuilder.create();

        // show it
        alertDialog.show();
    }
} public class ColorPicker1 extends Fragment implements IOnFocusListenable {


    RelativeLayout colorViewLayout = null;
    TextView textViewColor = null;
    SeekBar redSeekBar, greenSeekBar, blueSeekBar,opacitySeekBar;
    TextView redToolTip, greenToolTip, blueToolTip,opacityToolTip;
    ClipboardManager clipBoard;
    ClipData clip;
    Window window;
    Display display;
    int red, green, blue, seekBarLeft,opacity;
    Rect thumbRect;

    public interface OnColorListener{
        void onAddColor(String color);
    }

    private OnColorListener mListener;

    public ColorPicker1() {
    }

    public OnColorListener getListener() {
        return mListener;
    }

    public void setListener(OnColorListener mListener) {
        this.mListener = mListener;
    }

    public static ColorPicker1 newInstance(OnColorListener listener) {
        ColorPicker1 fragment = new ColorPicker1();
        fragment.setListener(listener);
        return fragment;
    }

    public static ColorPicker1 newInstance(String param1, String param2) {
        ColorPicker1 fragment = new ColorPicker1();
        return fragment;
    }

    @OnClick(R.id.add_color_button) void addColorClick(){
        String color = textViewColor.getText().toString();
        this.mListener.onAddColor(color);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_color_picker1, container, false);
        view.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                return true;
            }
        });
        ButterKnife.bind(this,view);
        return view;
    }
    @Override
    public void onActivityCreated(Bundle savedInstanceState)
    {
        super.onActivityCreated(savedInstanceState);
        display = ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();

        red = green = blue = 120;
        opacity = 255;

        clipBoard = (ClipboardManager)getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
        window = getActivity().getWindow();

        redSeekBar = (SeekBar)getView().findViewById(R.id.redSeekBar);
        greenSeekBar = (SeekBar)getView().findViewById(R.id.greenSeekBar);
        blueSeekBar = (SeekBar)getView().findViewById(R.id.blueSeekBar);

        opacitySeekBar = (SeekBar)getView().findViewById(R.id.opacitySeekBar);

        seekBarLeft = redSeekBar.getPaddingLeft();

        redToolTip = (TextView)getView().findViewById(R.id.redToolTip);
        greenToolTip = (TextView)getView().findViewById(R.id.greenToolTip);
        blueToolTip = (TextView)getView().findViewById(R.id.blueToolTip);

        opacityToolTip = (TextView)getView().findViewById(R.id.opacityToolTip);

        textViewColor = (TextView) getView().findViewById(R.id.textViewColor);
        textViewColor.setTextColor(Color.parseColor(inverseColor(red,green,blue)));


        redSeekBar.setProgress(red);
        greenSeekBar.setProgress(green);
        blueSeekBar.setProgress(blue);
        opacitySeekBar.setProgress(opacity);

        colorViewLayout = (RelativeLayout) getView().findViewById(R.id.colorView2);
        colorViewLayout.setBackgroundColor(Color.argb(opacity,red, green, blue));

        textViewColor.setText(String.format("#%02x%02x%02x%02x", opacity, red, green, blue));
        textViewColor.setTextColor(Color.parseColor(inverseColor(red,green,blue)));


        textViewColor.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                BoardEditor.getInstance().copyToClipBoard(textViewColor.getText().toString());
                Toast.makeText(BoardEditor.getInstance().getContext(), "Color " + textViewColor.getText().toString() +
                        " copied to clipboard...", Toast.LENGTH_SHORT).show();
            }
        });


        redSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                red = progress;
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    thumbRect = seekBar.getThumb().getBounds();
                }

                redToolTip.setX(seekBarLeft + thumbRect.left);

                if (progress<10)
                    redToolTip.setText("  " + red);
                else if (progress<100)
                    redToolTip.setText(" "+red);
                else
                    redToolTip.setText(red+"");

                colorViewLayout.setBackgroundColor(Color.argb(opacity,red, green, blue));
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

                    if (display.getRotation() == Surface.ROTATION_0)
                        window.setStatusBarColor(Color.argb(opacity,red, green, blue));
                }
                textViewColor.setText(String.format("#%02x%02x%02x%02x", opacity,red, green, blue));
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });
        greenSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                green = progress;
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    thumbRect = seekBar.getThumb().getBounds();
                }

                greenToolTip.setX(seekBar.getPaddingLeft()+thumbRect.left);
                if (progress<10)
                    greenToolTip.setText("  "+green);
                else if (progress<100)
                    greenToolTip.setText(" "+green);
                else
                    greenToolTip.setText(green+"");

                colorViewLayout.setBackgroundColor(Color.argb(opacity,red, green, blue));

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

                    if (display.getRotation() == Surface.ROTATION_0)
                        window.setStatusBarColor(Color.argb(opacity,red, green, blue));
                }
                textViewColor.setText(String.format("#%02x%02x%02x%02x", opacity,red, green, blue));
                textViewColor.setTextColor(Color.parseColor(inverseColor(red,green,blue)));
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });
        blueSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                blue = progress;
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    thumbRect = seekBar.getThumb().getBounds();
                }

                blueToolTip.setX(seekBarLeft + thumbRect.left);
                if (progress<10)
                    blueToolTip.setText("  "+blue);
                else if (progress<100)
                    blueToolTip.setText(" "+blue);
                else
                    blueToolTip.setText(blue+"");

                colorViewLayout.setBackgroundColor(Color.argb(opacity,red, green, blue));

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

                    if (display.getRotation() == Surface.ROTATION_0)
                        window.setStatusBarColor(Color.argb(opacity,red, green, blue));
                }
                textViewColor.setText(String.format("#%02x%02x%02x%02x", opacity,red, green, blue));
                textViewColor.setTextColor(Color.parseColor(inverseColor(red,green,blue)));
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });
        opacitySeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                opacity = progress;

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    thumbRect = seekBar.getThumb().getBounds();
                }
                opacityToolTip.setX(seekBarLeft + thumbRect.left);
                if (progress<10)
                    opacityToolTip.setText("  "+opacity);
                else if (progress<100)
                    opacityToolTip.setText(" "+opacity);
                else
                    opacityToolTip.setText(opacity+"");

                colorViewLayout.setBackgroundColor(Color.argb(opacity,red, green, blue));
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

                    if (display.getRotation() == Surface.ROTATION_0)
                        window.setStatusBarColor(Color.argb(opacity,red, green, blue));
                }
                textViewColor.setText(String.format("#%02x%02x%02x%02x", opacity,red, green, blue));
                textViewColor.setTextColor(Color.parseColor(inverseColor(red,green,blue)));
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });

    }

    private boolean setValue(int viewValue)
    {
        setProgressBar(red,green,blue,opacity);
        onWindowFocusChanged(true);
        return false;
    }

    private String inverseColor(int red, int green, int blue)
    {
        String ff = "FF";
        String r = String.format("%02x", red);
        String g = String.format("%02x", green);
        String b = String.format("%02x", blue);

        BigInteger ri = new BigInteger(r,16);
        BigInteger gi = new BigInteger(g,16);
        BigInteger bi = new BigInteger(b,16);

        BigInteger fi = new BigInteger(ff,16);

        BigInteger rs = ri.xor(fi);
        BigInteger gs = gi.xor(fi);
        BigInteger bs = bi.xor(fi);


        String res = String.format("#%02x%02x%02x",rs,gs,bs);
        return res;
    }


    private void setProgressBar(int r,int g,int b,int o)
    {

        redSeekBar.setProgress(r);
        greenSeekBar.setProgress(g);
        blueSeekBar.setProgress(b);
        opacitySeekBar.setProgress(o);
    }
    @Override
    public void onWindowFocusChanged(boolean hasFocus)
    {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            thumbRect = redSeekBar.getThumb().getBounds();
        }

        redToolTip.setX(seekBarLeft + thumbRect.left);
        if (red<10)
            redToolTip.setText("  "+red);
        else if (red<100)
            redToolTip.setText(" "+red);
        else
            redToolTip.setText(red+"");

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            thumbRect = greenSeekBar.getThumb().getBounds();
        }

        greenToolTip.setX(seekBarLeft + thumbRect.left);
        if (green<10)
            greenToolTip.setText("  "+green);
        else if (red<100)
            greenToolTip.setText(" "+green);
        else
            greenToolTip.setText(green+"");

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            thumbRect = blueSeekBar.getThumb().getBounds();
        }

        blueToolTip.setX(seekBarLeft + thumbRect.left);
        if (blue<10)
            blueToolTip.setText("  "+blue);
        else if (blue<100)
            blueToolTip.setText(" "+blue);
        else
            blueToolTip.setText(blue+"");

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            thumbRect = opacitySeekBar.getThumb().getBounds();
        }

        opacityToolTip.setX(seekBarLeft + thumbRect.left);
        if (opacity<10)
            opacityToolTip.setText("  "+opacity);
        else if (opacity<100)
            opacityToolTip.setText(" "+opacity);
        else
            opacityToolTip.setText(opacity+"");
    }

} public class ColorPicker3 extends Fragment implements ColorPickerView.OnColorChangedListener {


    @BindView(R.id.colorView)
    View colorView;

    @BindView(R.id.color)
    TextView colorTextView;

    private int colorText = 0;
    @BindView(R.id.colorpickerview__color_picker_view1)
    ColorPickerView mColorPickerView;

    private ColorPicker1.OnColorListener mListener = null;

    public ColorPicker3() {
    }

    public static ColorPicker3 newInstance(String param1, String param2) {
        ColorPicker3 fragment = new ColorPicker3();
        return fragment;
    }

    public static ColorPicker3 newInstance(ColorPicker1.OnColorListener listener) {
        ColorPicker3 fragment = new ColorPicker3();
        fragment.setListener(listener);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_color_picker3, container, false);
        ButterKnife.bind(this,view);
        return view;
    }

    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        final int initialColor = 0xFFE12109;;
        mColorPickerView.setOnColorChangedListener(this);
        mColorPickerView.setColor(initialColor, true);
        colorView.setBackgroundColor(initialColor);

        colorTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                BoardEditor.getInstance().copyToClipBoard(colorTextView.getText().toString());
                Toast.makeText(BoardEditor.getInstance().getContext(), "Color " + colorTextView.getText().toString() +
                        " copied to clipboard...", Toast.LENGTH_SHORT).show();
            }
        });
    }

    @OnClick(R.id.add_button) void addColorButtonClick(){
        String color = colorTextView.getText().toString();
        if(mListener != null)
            this.mListener.onAddColor(color);
    }

    private String inverseColor(String hexColor)
    {
        String ff = "FF";
        String r = hexColor.substring(2,4);
        String g = hexColor.substring(4,6);
        String b = hexColor.substring(6,8);


        BigInteger ri = new BigInteger(r,16);
        BigInteger gi = new BigInteger(g,16);
        BigInteger bi = new BigInteger(b,16);


        BigInteger fi = new BigInteger(ff,16);

        BigInteger rs = ri.xor(fi);
        BigInteger gs = gi.xor(fi);
        BigInteger bs = bi.xor(fi);

        String res = String.format("#%02x%02x%02x",rs,gs,bs);
        return res;
    }

    @Override
    public void onColorChanged(int newColor) {

        colorText = newColor;
        colorTextView.setText("#" + Integer.toHexString(newColor));
        colorTextView.setTextColor(Color.parseColor(inverseColor(Integer.toHexString(newColor))));
        colorView.setBackgroundColor(colorText);
    }

    public void setListener(ColorPicker1.OnColorListener listener) {
        this.mListener = listener;
    }
} public class FlatColorFragment extends Fragment implements AdapterView.OnItemLongClickListener  {

    private ColorPicker1.OnColorListener mListener = null;
    public FlatColorFragment() {

    }

    public static FlatColorFragment newInstance(ColorPicker1.OnColorListener listener) {
        FlatColorFragment fragment = new FlatColorFragment();
        fragment.setListener(listener);
        return fragment;
    }

    public void setListener(ColorPicker1.OnColorListener listener) {
        this.mListener = listener;
    }

    public ColorPicker1.OnColorListener getListener() {
        return this.mListener;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_flat_color, container, false);
        ButterKnife.bind(this,view);
        return view;
    }
    @Override
    public void onActivityCreated(Bundle savedInstanceState)
    {
        super.onActivityCreated(savedInstanceState);

        ColorArrayController controller  = ColorArrayController.getInstance();
        GridView gridView = (GridView) getView().findViewById(R.id.gridviewflat);
        GridViewArrayAdapter adapter = new GridViewArrayAdapter(getContext(),R.layout.grid_list,controller.getFlatList(),this.mListener);
        gridView.setAdapter(adapter);
    }

    @Override
    public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
        return false;
    }
} public class HtmlColorFragment extends Fragment {

    private ColorPicker1.OnColorListener mListener = null;
    private List<ColorInfo> colorInfoArrayList = null;

    public HtmlColorFragment() {
    }

    public static HtmlColorFragment newInstance(ColorPicker1.OnColorListener listener) {
        HtmlColorFragment fragment = new HtmlColorFragment();
        fragment.setListener(listener);
        return fragment;
    }

    public ColorPicker1.OnColorListener getListener() {
        return mListener;
    }

    public void setListener(ColorPicker1.OnColorListener mListener) {
        this.mListener = mListener;
    }

    public static HtmlColorFragment newInstance(String param1, String param2) {
        HtmlColorFragment fragment = new HtmlColorFragment();
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_html_color, container, false);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState)
    {
        super.onActivityCreated(savedInstanceState);
        if(colorInfoArrayList == null)
            colorInfoArrayList = new ArrayList<ColorInfo>();
        GridView gridView = (GridView) getView().findViewById(R.id.gridview);
        ColorArrayController controller  = ColorArrayController.getInstance();
        colorInfoArrayList = controller.getHtmlList();
        GridViewArrayAdapter adapter = new GridViewArrayAdapter(getContext(),R.layout.grid_list,colorInfoArrayList,this.mListener);
        gridView.setAdapter(adapter);
    }
} public class MaterialColorFragment extends Fragment implements AdapterView.OnItemLongClickListener , ListenerModel.OnModelStateListener {

    private GridView gridView = null;
    private List<ColorInfo> colorInfoArrayList = null;
    private ColorPicker1.OnColorListener mListener = null;
    private MaterialGridViewAdapter mAdapter = null;
    public MaterialColorFragment() {
    }

    public static MaterialColorFragment newInstance(ColorPicker1.OnColorListener listener){
        MaterialColorFragment fragment = new MaterialColorFragment();
        fragment.setListener(listener);
        return fragment;
    }

    public void setListener(ColorPicker1.OnColorListener listener) {
        this.mListener = listener;
    }

    public ColorPicker1.OnColorListener getListener() {
        return this.mListener;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_material_color, container, false);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState)
    {
        super.onActivityCreated(savedInstanceState);
        if(colorInfoArrayList == null)
            colorInfoArrayList = new ArrayList<ColorInfo>();

        ListenerModel.getInstance().setListener(this);

        ColorArrayController controller  = ColorArrayController.getInstance();
        colorInfoArrayList = controller.getMaterialColorInfoList().get(0).getColorInfoList();
        gridView = (GridView) getView().findViewById(R.id.gridviewmaterial);
        mAdapter = new MaterialGridViewAdapter(getContext(),R.layout.grid_list,colorInfoArrayList,this.mListener);
        gridView.setAdapter(mAdapter);
    }

    @Override
    public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
        return false;
    }

    @Override
    public void onSelectedColorIndex(int index) {
        int fi = MaterialGridViewAdapter.HeaderIndex;
        MaterialGridViewAdapter.HeaderIndex = index;
        ColorArrayController controller  = ColorArrayController.getInstance();
        colorInfoArrayList = controller.getMaterialColorInfoList().get(index).getColorInfoList();
        mAdapter = new MaterialGridViewAdapter(getContext(),R.layout.grid_list,colorInfoArrayList,this.mListener);
        gridView.setAdapter(mAdapter);
    }
} public class MetroColorFragment extends Fragment implements AdapterView.OnItemLongClickListener  {


    private ColorPicker1.OnColorListener mListener = null;

    public MetroColorFragment() {
        // Required empty public constructor
    }

    public static MetroColorFragment newInstance(ColorPicker1.OnColorListener listener){
        MetroColorFragment fragment = new MetroColorFragment();
        fragment.setListener(listener);
        return fragment;
    }

    public ColorPicker1.OnColorListener getListener() {
        return mListener;
    }

    public void setListener(ColorPicker1.OnColorListener mListener) {
        this.mListener = mListener;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_metro_color, container, false);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState)
    {
        super.onActivityCreated(savedInstanceState);
        GridView gridView = (GridView) getView().findViewById(R.id.gridviewmetro);
        ColorArrayController controller  = ColorArrayController.getInstance();
        GridViewArrayAdapter adapter = new GridViewArrayAdapter(getContext(),R.layout.grid_list,controller.getMetroList(),this.mListener);
        gridView.setAdapter(adapter);
    }

    @Override
    public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
        return false;
    }
} public class SocialColorFragment extends Fragment implements AdapterView.OnItemLongClickListener   {


    private ColorPicker1.OnColorListener mListener = null;

    public SocialColorFragment() {
        // Required empty public constructor
    }

    public static SocialColorFragment newInstance(ColorPicker1.OnColorListener listener){
        SocialColorFragment fragment = new SocialColorFragment();
        fragment.setListener(listener);
        return fragment;
    }

    public ColorPicker1.OnColorListener getListener() {
        return this.mListener;
    }

    public void setListener(ColorPicker1.OnColorListener mListener) {
        this.mListener = mListener;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_social_color, container, false);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState)
    {
        super.onActivityCreated(savedInstanceState);
        /*ColorArrayController controller  = ColorArrayController.getInstance();
        setListAdapter(new ColorArrayListAdapter(getContext(),R.layout.list_layout,controller.getSocialList()));
        getListView().setOnItemLongClickListener(this);
        */

        GridView gridView = (GridView) getView().findViewById(R.id.gridviewsocial);
        ColorArrayController controller  = ColorArrayController.getInstance();
        //GridViewArrayAdapter adapter = new GridViewArrayAdapter(getContext(),R.layout.grid_list,controller.getSocialList());
        GridViewArrayAdapter adapter = new GridViewArrayAdapter(getContext(),R.layout.grid_list,controller.getSocialList(),this.mListener);
        gridView.setAdapter(adapter);

    }


    @Override
    public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
        return false;
    }
}
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TabLayout;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.AndroidException;
import android.util.Log;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cheetatech.com.colorhub.adapters.DrawerListAdapter;
import cheetatech.com.colorhub.adapters.NavigationBarAdapter;
import cheetatech.com.colorhub.adapters.SaveListAdapter;
import cheetatech.com.colorhub.adapters.ViewPagerAdapter;
import cheetatech.com.colorhub.adapters.YourColorAdapter;
import cheetatech.com.colorhub.ads.AdsUtils;
import cheetatech.com.colorhub.controller.ColorArrayController;
import cheetatech.com.colorhub.controller.DrawerListController;
import cheetatech.com.colorhub.controller.ToolBarController;
import cheetatech.com.colorhub.defines.BoardEditor;
import cheetatech.com.colorhub.dialog.SaveDialog;
import cheetatech.com.colorhub.drawer.ColorSelect;
import cheetatech.com.colorhub.listeners.ListenerModel;
import cheetatech.com.colorhub.models.Model;
import cheetatech.com.colorhub.realm.RealmX;
import cheetatech.com.colorhub.realm.SavedObject;
import cheetatech.com.colorhub.yourcolors.YourColorActivity;
import es.dmoral.toasty.Toasty;
import hotchemi.android.rate.AppRate;
import hotchemi.android.rate.OnClickButtonListener;
import io.realm.RealmList;
import layout.ColorPicker1;
import layout.ColorPicker3;
import layout.FlatColorFragment;
import layout.HtmlColorFragment;
import layout.MaterialColorFragment;
import layout.MetroColorFragment;
import layout.SocialColorFragment;
package cheetatech.com.colorhub;




public class MainActivity extends AppCompatActivity implements ListView.OnItemClickListener, TabLayout.OnTabSelectedListener, ColorPicker1.OnColorListener , SaveDialog.OnSaveListener{

    private Toolbar toolbar = null;
    List<ColorSelect> cselect = null;

    private DrawerListAdapter drawerListAdapter = null;