public abstract class BenihHeaderViewHolder extends BenihItemViewHolder
{
    protected Bundle bundle;

    public BenihHeaderViewHolder(View itemView, Bundle bundle)
    {
        super(itemView, null, null);
        this.bundle = bundle;
    }

    @Override
    public void bind(Object o)
    {

    }

    public abstract void show();

    public void saveState(Bundle bundle)
    {
        this.bundle = bundle;
    }
} public class BenihUtils
{
    public static int randInt(int min, int max)
    {
        Random rand = new Random();
        return rand.nextInt((max - min) + 1) + min;
    }

    public static boolean isMyServiceRunning(Context context, Class<?> serviceClass)
    {
        ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE))
        {
            if (serviceClass.getName().equals(service.service.getClassName()))
            {
                return true;
            }
        }
        return false;
    }

    public static boolean isMyAppRunning(Context context, String packageName)
    {
        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
        boolean run = false;
        for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses)
        {
            if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND)
            {
                if (appProcess.processName.equals(packageName))
                {
                    run = true;
                    break;
                }
            }
        }

        return run;
    }

    public static int getRandomColor()
    {
        Random rand = new Random();
        return Color.argb(100, rand.nextInt(256), rand.nextInt(256), rand.nextInt(256));
    }
} public class CodePolitanApplication extends BenihApplication
{
    private static CodePolitanApplication codePolitanApplication;

    @Override
    public void onCreate()
    {
        super.onCreate();
        codePolitanApplication = this;
        if (BuildConfig.DEBUG)
        {
            Timber.plant(new Timber.DebugTree());
        }
    }

    public static CodePolitanApplication pluck()
    {
        return codePolitanApplication;
    }
} public class BookmarkController extends BenihController<BookmarkController.Presenter>
{
    private List<Article> articles;
    private Article article;

    public BookmarkController(Presenter presenter)
    {
        super(presenter);
        BenihBus.pluck()
                .receive()
                .subscribe(o -> {
                    if (o instanceof BookmarkEvent)
                    {
                        onBookmarkEvent((BookmarkEvent) o);
                    }
                }, throwable -> Timber.e(throwable.getMessage()));
    }

    public void setArticle(Article article)
    {
        this.article = article;
    }

    private void onBookmarkEvent(BookmarkEvent bookmarkEvent)
    {
        if (article != null && article.getId() == bookmarkEvent.getArticle().getId())
        {
            if (bookmarkEvent.getArticle().isBookmarked() && !article.isBookmarked())
            {
                article.setBookmarked(true);
                presenter.onBookmark(article);
            } else if (!bookmarkEvent.getArticle().isBookmarked() && article.isBookmarked())
            {
                article.setBookmarked(false);
                presenter.onUnBookmark(article);
            }
        }
    }

    public void loadBookmarkedArticles()
    {
        presenter.showLoading();
        DataBaseHelper.pluck()
                .getBookmarkedArticles()
                .compose(BenihScheduler.pluck().applySchedulers(BenihScheduler.Type.IO))
                .subscribe(articles -> {
                    int size = articles.size();
                    for (int i = 0; i < size; i++)
                    {
                        articles.get(i).setBookmarked(DataBaseHelper.pluck().isBookmarked(articles.get(i).getId()));
                        articles.get(i).setReadLater(DataBaseHelper.pluck().isReadLater(articles.get(i).getId()));
                        articles.get(i).setBig(BenihUtils.randInt(0, 8) == 5);
                    }
                    this.articles = articles;
                    if (presenter != null)
                    {
                        presenter.showListBookmarkedArticles(articles);
                        presenter.dismissLoading();
                    }
                }, throwable -> {
                    if (presenter != null)
                    {
                        Timber.d(throwable.getMessage());
                        presenter.showError(new Throwable(ErrorEvent.LOAD_BOOKMARKED_ARTICLES));
                        presenter.dismissLoading();
                    }
                });
    }

    public void bookmark(Article article)
    {
        if (!article.isBookmarked())
        {
            article.setBookmarked(true);
            DataBaseHelper.pluck().bookmark(article);
            presenter.onBookmark(article);
        } else
        {
            article.setBookmarked(false);
            DataBaseHelper.pluck().unBookmark(article.getId());
            presenter.onUnBookmark(article);
        }

        BenihBus.pluck().send(new BookmarkEvent(article));
    }

    public void filter(String query)
    {
        if (articles != null)
        {
            Observable.from(articles)
                    .compose(BenihScheduler.pluck().applySchedulers(BenihScheduler.Type.NEW_THREAD))
                    .filter(article -> article.getTitle().toLowerCase().contains(query.toLowerCase()))
                    .map(article -> {
                        article.setBookmarked(DataBaseHelper.pluck().isBookmarked(article.getId()));
                        article.setReadLater(DataBaseHelper.pluck().isReadLater(article.getId()));
                        return article;
                    })
                    .toList()
                    .subscribe(presenter::showFilteredArticles, presenter::showError);
        } else
        {
            presenter.showFilteredArticles(new ArrayList<>());
        }
    }

    @Override
    public void saveState(Bundle bundle)
    {

    }

    @Override
    public void loadState(Bundle bundle)
    {

    }

    public interface Presenter extends BenihController.Presenter
    {
        void showListBookmarkedArticles(List<Article> listArticle);

        void onBookmark(Article article);

        void onUnBookmark(Article article);

        void showFilteredArticles(List<Article> articles);
    }
} public class RandomContentController extends BenihController<RandomContentController.Presenter>
{
    private List<Article> randomArticles;
    private Category category;
    private Tag tag;
    private boolean pageFlags[];
    private int count;

    public RandomContentController(Presenter presenter)
    {
        super(presenter);
        pageFlags = new boolean[26];
        reset();
    }

    public void reset()
    {
        count = 0;
        if (randomArticles != null)
        {
            randomArticles.clear();
        }

        for (int i = 0; i < 26; i++)
        {
            pageFlags[i] = false;
        }
    }

    private int getRandomPage()
    {
        int page = BenihUtils.randInt(1, 25);
        int rndCount = 0;

        while (pageFlags[page])
        {
            rndCount++;
            page = BenihUtils.randInt(1, 25);
            if (rndCount > 5 && pageFlags[page])
            {
                for (int i = 0; i < 26; i++)
                {
                    if (!pageFlags[i])
                    {
                        page = i;
                        break;
                    }
                }
            }
        }

        pageFlags[page] = true;

        return page;
    }

    public void loadRandomArticles()
    {
        presenter.showLoading();
        count++;
        if (count < 25)
        {
            CodePolitanApi.pluck()
                    .getApi()
                    .getLatestArticles(getRandomPage())
                    .compose(BenihScheduler.pluck().applySchedulers(BenihScheduler.Type.IO))
                    .flatMap(articleListResponse -> Observable.from(articleListResponse.getResult()))
                    .map(article -> {
                        article.setBookmarked(DataBaseHelper.pluck().isBookmarked(article.getId()));
                        article.setReadLater(DataBaseHelper.pluck().isReadLater(article.getId()));
                        article.setBig(BenihUtils.randInt(0, 8) == 5);
                        return article;
                    })
                    .toList()
                    .subscribe(articles -> {
                        if (count == 0 || randomArticles == null)
                        {
                            randomArticles = articles;
                        } else
                        {
                            randomArticles.addAll(articles);
                        }
                        if (presenter != null)
                        {
                            presenter.showRandomArticles(articles);
                            presenter.dismissLoading();
                        }
                    }, throwable -> {
                        if (presenter != null)
                        {
                            Timber.e(throwable.getMessage());
                            presenter.showError(new Throwable(ErrorEvent.LOAD_RANDOM_ARTICLES));
                            presenter.dismissLoading();
                        }
                    });
        } else
        {
            presenter.dismissLoading();
        }
    }

    public void loadRandomArticles(Category category)
    {
        presenter.showLoading();
        CodePolitanApi.pluck()
                .getApi()
                .getArticles(category, BenihUtils.randInt(1, 3))
                .compose(BenihScheduler.pluck().applySchedulers(BenihScheduler.Type.IO))
                .flatMap(articleListResponse -> Observable.from(articleListResponse.getResult()))
                .map(article -> {
                    article.setBookmarked(DataBaseHelper.pluck().isBookmarked(article.getId()));
                    article.setReadLater(DataBaseHelper.pluck().isReadLater(article.getId()));
                    article.setBig(BenihUtils.randInt(0, 8) == 5);
                    return article;
                })
                .toList()
                .subscribe(articles -> {
                    randomArticles = articles;
                    if (presenter != null)
                    {
                        presenter.showRandomArticles(articles);
                        presenter.dismissLoading();
                    }
                }, throwable -> {
                    if (presenter != null)
                    {
                        Timber.d(throwable.getMessage());
                        presenter.showError(new Throwable(ErrorEvent.LOAD_RANDOM_ARTICLES_BY_CATEGORY));
                        presenter.dismissLoading();
                    }
                });
    }

    public void loadRandomArticles(Tag tag)
    {
        presenter.showLoading();
        CodePolitanApi.pluck()
                .getApi()
                .getArticles(tag, BenihUtils.randInt(1, 3))
                .compose(BenihScheduler.pluck().applySchedulers(BenihScheduler.Type.IO))
                .flatMap(articleListResponse -> Observable.from(articleListResponse.getResult()))
                .map(article -> {
                    article.setBookmarked(DataBaseHelper.pluck().isBookmarked(article.getId()));
                    article.setReadLater(DataBaseHelper.pluck().isReadLater(article.getId()));
                    article.setBig(BenihUtils.randInt(0, 8) == 5);
                    return article;
                })
                .toList()
                .subscribe(articles -> {
                    randomArticles = articles;
                    if (presenter != null)
                    {
                        presenter.showRandomArticles(articles);
                        presenter.dismissLoading();
                    }
                }, throwable -> {
                    if (presenter != null)
                    {
                        Timber.d(throwable.getMessage());
                        presenter.showError(new Throwable(ErrorEvent.LOAD_RANDOM_ARTICLES_BY_TAG));
                        presenter.dismissLoading();
                    }
                });
    }

    public void loadRandomCategory()
    {
        presenter.showLoading();
        CodePolitanApi.pluck()
                .getApi()
                .getCategories(1)
                .compose(BenihScheduler.pluck().applySchedulers(BenihScheduler.Type.IO))
                .flatMap(categoryListResponse -> Observable.just(categoryListResponse.getResult()))
                .map(categories -> categories.get(BenihUtils.randInt(0, categories.size() - 1)))
                .subscribe(category -> {
                    this.category = category;
                    if (presenter != null)
                    {
                        presenter.showRandomCategory(category);
                        presenter.dismissLoading();
                    }
                }, throwable -> {
                    if (presenter != null)
                    {
                        Timber.d(throwable.getMessage());
                        presenter.showError(new Throwable(ErrorEvent.LOAD_RANDOM_CATEGORY));
                        presenter.dismissLoading();
                    }
                });
    }

    public void loadRandomTag()
    {
        presenter.showLoading();
        CodePolitanApi.pluck()
                .getApi()
                .getTags(BenihUtils.randInt(1, 5))
                .compose(BenihScheduler.pluck().applySchedulers(BenihScheduler.Type.IO))
                .flatMap(tagListResponse -> Observable.just(tagListResponse.getResult()))
                .map(tags -> tags.get(BenihUtils.randInt(0, tags.size() - 1)))
                .subscribe(tag -> {
                    this.tag = tag;
                    if (presenter != null)
                    {
                        presenter.showRandomTag(tag);
                        presenter.dismissLoading();
                    }
                }, throwable -> {
                    if (presenter != null)
                    {
                        Timber.d(throwable.getMessage());
                        presenter.showError(new Throwable(ErrorEvent.LOAD_RANDOM_TAG));
                        presenter.dismissLoading();
                    }
                });
    }

    public void filter(String query)
    {
        if (randomArticles != null)
        {
            Observable.from(randomArticles)
                    .compose(BenihScheduler.pluck().applySchedulers(BenihScheduler.Type.NEW_THREAD))
                    .filter(article -> article.getTitle().toLowerCase().contains(query.toLowerCase()))
                    .map(article -> {
                        article.setBookmarked(DataBaseHelper.pluck().isBookmarked(article.getId()));
                        article.setReadLater(DataBaseHelper.pluck().isReadLater(article.getId()));
                        return article;
                    })
                    .toList()
                    .subscribe(presenter::showFilteredArticles, presenter::showError);
        } else
        {
            presenter.showFilteredArticles(new ArrayList<>());
        }
    }

    @Override
    public void saveState(Bundle bundle)
    {
        bundle.putParcelableArrayList("random_articles", (ArrayList<Article>) randomArticles);
        bundle.putParcelable("random_category", category);
        bundle.putParcelable("random_tag", tag);
        bundle.putBooleanArray("pageFlags", pageFlags);
        bundle.putInt("count", count);
    }

    @Override
    public void loadState(Bundle bundle)
    {
        pageFlags = bundle.getBooleanArray("pageFlags");
        if (pageFlags == null)
        {
            pageFlags = new boolean[26];
        }

        count = bundle.getInt("count", 0);

        randomArticles = bundle.getParcelableArrayList("random_articles");
        if (randomArticles != null)
        {
            presenter.showRandomArticles(randomArticles);
        } else
        {
            presenter.showError(new Throwable(ErrorEvent.LOAD_STATE_RANDOM_ARTICLES));
        }

        category = bundle.getParcelable("random_category");
        if (category != null)
        {
            presenter.showRandomCategory(category);
        } else
        {
            presenter.showError(new Throwable(ErrorEvent.LOAD_STATE_RANDOM_CATEGORY));
        }

        tag = bundle.getParcelable("random_tag");
        if (tag != null)
        {
            presenter.showRandomTag(tag);
        } else
        {
            presenter.showError(new Throwable(ErrorEvent.LOAD_STATE_RANDOM_TAG));
        }
    }

    public interface Presenter extends BenihController.Presenter
    {
        void showRandomArticles(List<Article> articles);

        void showRandomCategory(Category category);

        void showRandomTag(Tag tag);

        void showFilteredArticles(List<Article> articles);
    }
} public class ReadLaterController extends BenihController<ReadLaterController.Presenter>
{
    private List<Article> articles;
    private Article article;

    public ReadLaterController(Presenter presenter)
    {
        super(presenter);
        BenihBus.pluck()
                .receive()
                .subscribe(o -> {
                    if (o instanceof ReadLaterEvent)
                    {
                        onReadLaterEvent((ReadLaterEvent) o);
                    }
                }, throwable -> Timber.e(throwable.getMessage()));
    }

    public void setArticle(Article article)
    {
        this.article = article;
    }

    private void onReadLaterEvent(ReadLaterEvent readLaterEvent)
    {
        if (article != null && article.getId() == readLaterEvent.getArticle().getId())
        {
            if (readLaterEvent.getArticle().isReadLater() && !article.isReadLater())
            {
                article.setReadLater(true);
                presenter.onReadLater(article);
            } else if (!readLaterEvent.getArticle().isReadLater() && article.isReadLater())
            {
                article.setReadLater(false);
                presenter.onUnReadLater(article);
            }
        }
    }

    public void loadReadLaterArticles()
    {
        presenter.showLoading();
        DataBaseHelper.pluck()
                .getReadLaterArticles()
                .compose(BenihScheduler.pluck().applySchedulers(BenihScheduler.Type.IO))
                .subscribe(articles -> {
                    int size = articles.size();
                    for (int i = 0; i < size; i++)
                    {
                        articles.get(i).setBookmarked(DataBaseHelper.pluck().isBookmarked(articles.get(i).getId()));
                        articles.get(i).setReadLater(DataBaseHelper.pluck().isReadLater(articles.get(i).getId()));
                        articles.get(i).setBig(BenihUtils.randInt(0, 8) == 5);
                    }
                    this.articles = articles;
                    if (presenter != null)
                    {
                        presenter.showListReadLaterArticles(articles);
                        presenter.dismissLoading();
                    }
                }, throwable -> {
                    if (presenter != null)
                    {
                        Timber.d(throwable.getMessage());
                        presenter.showError(new Throwable(ErrorEvent.LOAD_READ_LATER_ARTICLES));
                        presenter.dismissLoading();
                    }
                });
    }

    public void readLater(Article article)
    {
        if (!article.isReadLater())
        {
            if (article.getContent() == null)
            {
                CodePolitanApi.pluck()
                        .getApi()
                        .getDetailArticle(article.getId())
                        .compose(BenihScheduler.pluck().applySchedulers(BenihScheduler.Type.IO))
                        .subscribe(articleObjectResponse -> DataBaseHelper.pluck().readLater(articleObjectResponse.getResult()),
                                   throwable -> {
                                       if (presenter != null)
                                       {
                                           article.setReadLater(false);
                                           Timber.d(throwable.getMessage());
                                           presenter.showError(new Throwable(ErrorEvent.ON_READ_LATER));
                                           presenter.onUnReadLater(article);
                                           BenihBus.pluck().send(new ReadLaterEvent(article));
                                       }
                                   });
            } else
            {
                DataBaseHelper.pluck().readLater(article);
            }
            article.setReadLater(true);
            presenter.onReadLater(article);
        } else
        {
            article.setReadLater(false);
            DataBaseHelper.pluck().unReadLater(article.getId());
            presenter.onUnReadLater(article);
        }

        BenihBus.pluck().send(new ReadLaterEvent(article));
    }

    public void filter(String query)
    {
        if (articles != null)
        {
            Observable.from(articles)
                    .compose(BenihScheduler.pluck().applySchedulers(BenihScheduler.Type.NEW_THREAD))
                    .filter(article -> article.getTitle().toLowerCase().contains(query.toLowerCase()))
                    .map(article -> {
                        article.setBookmarked(DataBaseHelper.pluck().isBookmarked(article.getId()));
                        article.setReadLater(DataBaseHelper.pluck().isReadLater(article.getId()));
                        return article;
                    })
                    .toList()
                    .subscribe(presenter::showFilteredArticles, presenter::showError);
        } else
        {
            presenter.showFilteredArticles(new ArrayList<>());
        }
    }

    @Override
    public void saveState(Bundle bundle)
    {

    }

    @Override
    public void loadState(Bundle bundle)
    {

    }

    public interface Presenter extends BenihController.Presenter
    {
        void showListReadLaterArticles(List<Article> listArticle);

        void onReadLater(Article article);

        void onUnReadLater(Article article);

        void showFilteredArticles(List<Article> articles);
    }
} public interface ErrorEvent
{
    String LOAD_STATE_ARTICLE = "0";
    String LOAD_STATE_LIST_ARTICLE = "1";
    String LOAD_STATE_LIST_CATEGORY = "2";
    String LOAD_STATE_LIST_TAG = "3";
    String LOAD_STATE_RANDOM_ARTICLES = "4";
    String LOAD_ARTICLE = "5";
    String LOAD_LIST_ARTICLE_BY_PAGE = "6";
    String LOAD_LIST_ARTICLE_BY_POST_TYPE = "7";
    String LOAD_LIST_ARTICLE_BY_CATEGORY = "8";
    String LOAD_LIST_ARTICLE_BY_TAG = "9";
    String LOAD_BOOKMARKED_ARTICLES = "10";
    String LOAD_READ_LATER_ARTICLES = "11";
    String ON_READ_LATER = "12";
    String LOAD_RANDOM_ARTICLES = "13";
    String LOAD_RANDOM_ARTICLES_BY_CATEGORY = "14";
    String LOAD_RANDOM_ARTICLES_BY_TAG = "15";
    String LOAD_RANDOM_CATEGORY = "16";
    String LOAD_RANDOM_TAG = "17";
    String LOAD_STATE_RANDOM_CATEGORY = "18";
    String LOAD_STATE_RANDOM_TAG = "19";
    String LOAD_LIST_CATEGORY = "20";
    String LOAD_LIST_TAG = "21";
    String LOAD_POPULAR_TAGS = "22";
    String LOAD_STATE_POPULAR_TAGS = "23";
    String LOAD_FOLLOWED_CATEGORIES = "24";
    String LOAD_FOLLOWED_TAGS = "25";
    String LOAD_FOLLOWED_ARTICLES = "26";
    String LOAD_UNFOLLOWED_ARTICLES = "27";
    String SEARCH_ARTICLES = "28";
} public class MoreNewsHeaderEvent
{
} public class NewsHeaderEvent
{
    private List<Article> articles;

    public NewsHeaderEvent(List<Article> articles)
    {
        this.articles = articles;
    }

    public List<Article> getArticles()
    {
        return articles;
    }

    public void setArticles(List<Article> articles)
    {
        this.articles = articles;
    }
} public class Article implements Parcelable
{
    public final static String TYPE_NEWS = "news";
    public final static String TYPE_KOMIK = "nyankomik";
    public final static String TYPE_MEME = "meme";
    public final static String TYPE_QUOTE = "quotes";

    private int id;
    private String slug;
    private String title;
    private String excerpt;
    private String content;
    private String date;
    private String dateClear;
    private String link;
    private String thumbnailSmall;
    private String thumbnailMedium;
    private boolean bookmarked;
    private boolean readLater;
    private boolean big;
    private String postType;
    private List<Category> category;
    private List<Tag> tags;

    public Article()
    {
        postType = TYPE_NEWS;
    }

    protected Article(Parcel in)
    {
        id = in.readInt();
        slug = in.readString();
        title = in.readString();
        excerpt = in.readString();
        content = in.readString();
        date = in.readString();
        dateClear = in.readString();
        link = in.readString();
        thumbnailSmall = in.readString();
        thumbnailMedium = in.readString();
        bookmarked = in.readByte() != 0;
        readLater = in.readByte() != 0;
        big = in.readByte() != 0;
        postType = in.readString();
        category = in.createTypedArrayList(Category.CREATOR);
        tags = in.createTypedArrayList(Tag.CREATOR);
    }

    public static final Creator<Article> CREATOR = new Creator<Article>()
    {
        @Override
        public Article createFromParcel(Parcel in)
        {
            return new Article(in);
        }

        @Override
        public Article[] newArray(int size)
        {
            return new Article[size];
        }
    };

    public int getId()
    {
        return id;
    }

    public void setId(int id)
    {
        this.id = id;
    }

    public String getSlug()
    {
        return slug;
    }

    public void setSlug(String slug)
    {
        this.slug = slug;
    }

    public String getTitle()
    {
        return title;
    }

    public void setTitle(String title)
    {
        this.title = title;
    }

    public String getExcerpt()
    {
        return excerpt;
    }

    public void setExcerpt(String excerpt)
    {
        this.excerpt = excerpt;
    }

    public String getContent()
    {
        return content;
    }

    public void setContent(String content)
    {
        this.content = content;
    }

    public String getDate()
    {
        return date;
    }

    public void setDate(String date)
    {
        this.date = date;
    }

    public String getDateClear()
    {
        return dateClear;
    }

    public void setDateClear(String dateClear)
    {
        this.dateClear = dateClear;
    }

    public String getLink()
    {
        return link;
    }

    public void setLink(String link)
    {
        this.link = link;
    }

    public String getThumbnailSmall()
    {
        return thumbnailSmall;
    }

    public void setThumbnailSmall(String thumbnailSmall)
    {
        this.thumbnailSmall = thumbnailSmall;
    }

    public String getThumbnailMedium()
    {
        return thumbnailMedium;
    }

    public void setThumbnailMedium(String thumbnailMedium)
    {
        this.thumbnailMedium = thumbnailMedium;
    }

    public boolean isBookmarked()
    {
        return bookmarked;
    }

    public void setBookmarked(boolean bookmarked)
    {
        this.bookmarked = bookmarked;
    }

    public boolean isReadLater()
    {
        return readLater;
    }

    public void setReadLater(boolean readLater)
    {
        this.readLater = readLater;
    }

    public boolean isBig()
    {
        return big;
    }

    public void setBig(boolean big)
    {
        this.big = big;
    }

    public String getPostType()
    {
        return postType;
    }

    public void setPostType(String postType)
    {
        this.postType = postType;
    }

    public List<Category> getCategory()
    {
        return category;
    }

    public void setCategory(List<Category> category)
    {
        this.category = category;
    }

    public List<Tag> getTags()
    {
        return tags;
    }

    public void setTags(List<Tag> tags)
    {
        this.tags = tags;
    }

    @Override
    public int describeContents()
    {
        return hashCode();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags)
    {
        dest.writeInt(id);
        dest.writeString(slug);
        dest.writeString(title);
        dest.writeString(excerpt);
        dest.writeString(content);
        dest.writeString(date);
        dest.writeString(dateClear);
        dest.writeString(link);
        dest.writeString(thumbnailSmall);
        dest.writeString(thumbnailMedium);
        dest.writeByte((byte) (bookmarked ? 1 : 0));
        dest.writeByte((byte) (readLater ? 1 : 0));
        dest.writeByte((byte) (big ? 1 : 0));
        dest.writeString(postType);
        dest.writeTypedList(category);
        dest.writeTypedList(tags);
    }
} public class Category implements Parcelable
{
    private String name;
    private String slug;
    private int imageResource;
    private boolean followed;

    public Category()
    {

    }

    protected Category(Parcel in)
    {
        name = in.readString();
        slug = in.readString();
        imageResource = in.readInt();
        followed = in.readInt() == 1;
    }

    public static final Creator<Category> CREATOR = new Creator<Category>()
    {
        @Override
        public Category createFromParcel(Parcel in)
        {
            return new Category(in);
        }

        @Override
        public Category[] newArray(int size)
        {
            return new Category[size];
        }
    };

    public String getName()
    {
        return name;
    }

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

    public String getSlug()
    {
        return slug;
    }

    public void setSlug(String slug)
    {
        this.slug = slug;
    }

    public int getImageResource()
    {
        return imageResource;
    }

    public void setImageResource(int imageResource)
    {
        this.imageResource = imageResource;
    }

    public boolean isFollowed()
    {
        return followed;
    }

    public void setFollowed(boolean followed)
    {
        this.followed = followed;
    }

    @Override
    public String toString()
    {
        return slug;
    }

    @Override
    public int describeContents()
    {
        return hashCode();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags)
    {
        dest.writeString(name);
        dest.writeString(slug);
        dest.writeInt(imageResource);
        dest.writeInt(followed ? 1 : 0);
    }
} public class Tag implements Parcelable
{
    private String name;
    private String slug;
    private int count;
    private boolean followed;

    public Tag()
    {

    }

    protected Tag(Parcel in)
    {
        name = in.readString();
        slug = in.readString();
        count = in.readInt();
        followed = in.readInt() == 1;
    }

    public static final Creator<Tag> CREATOR = new Creator<Tag>()
    {
        @Override
        public Tag createFromParcel(Parcel in)
        {
            return new Tag(in);
        }

        @Override
        public Tag[] newArray(int size)
        {
            return new Tag[size];
        }
    };

    public String getName()
    {
        return name;
    }

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

    public String getSlug()
    {
        return slug;
    }

    public void setSlug(String slug)
    {
        this.slug = slug;
    }

    public int getCount()
    {
        return count;
    }

    public void setCount(int count)
    {
        this.count = count;
    }

    public boolean isFollowed()
    {
        return followed;
    }

    public void setFollowed(boolean followed)
    {
        this.followed = followed;
    }

    @Override
    public String toString()
    {
        return slug;
    }

    @Override
    public int describeContents()
    {
        return hashCode();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags)
    {
        dest.writeString(name);
        dest.writeString(slug);
        dest.writeInt(count);
        dest.writeInt(followed ? 1 : 0);
    }
} public class CodePolitanImageView extends BenihImageView
{
    public CodePolitanImageView(Context context)
    {
        super(context);
    }

    public CodePolitanImageView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
    }

    public CodePolitanImageView(Context context, AttributeSet attrs, int defStyleAttr)
    {
        super(context, attrs, defStyleAttr);
    }

    public void setImageUrl(String url, ImageView errorImageView)
    {
        Glide.with(getContext())
                .load(url)
                .listener(new RequestListener<String, GlideDrawable>()
                {
                    @Override
                    public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource)
                    {
                        errorImageView.setVisibility(VISIBLE);
                        setVisibility(INVISIBLE);
                        return false;
                    }

                    @Override
                    public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource)
                    {
                        setVisibility(VISIBLE);
                        errorImageView.setVisibility(GONE);
                        return false;
                    }
                })
                .into(this);
    }
}
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.CardView;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;
import butterknife.Bind;
import id.zelory.benih.adapter.viewholder.BenihHeaderViewHolder;
import id.zelory.benih.util.BenihBus;
import id.zelory.benih.util.BenihUtils;
import id.zelory.codepolitan.CodePolitanApplication;
import id.zelory.codepolitan.R;
import id.zelory.codepolitan.controller.BookmarkController;
import id.zelory.codepolitan.controller.RandomContentController;
import id.zelory.codepolitan.controller.ReadLaterController;
import id.zelory.codepolitan.controller.event.ErrorEvent;
import id.zelory.codepolitan.controller.event.MoreNewsHeaderEvent;
import id.zelory.codepolitan.controller.event.NewsHeaderEvent;
import id.zelory.codepolitan.data.model.Article;
import id.zelory.codepolitan.data.model.Category;
import id.zelory.codepolitan.data.model.Tag;
import id.zelory.codepolitan.ui.view.CodePolitanImageView;
/*
 * Copyright (c) 2015 Zelory.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package id.zelory.codepolitan.ui.adapter.viewholder;




/**
 * Created on : August 23, 2015
 * Author     : zetbaitsu
 * Name       : Zetra
 * Email      : zetra@mail.ugm.ac.id
 * GitHub     : https://github.com/zetbaitsu
 * LinkedIn   : https://id.linkedin.com/in/zetbaitsu
 */
public class NewsHeaderViewHolder extends BenihHeaderViewHolder implements
        RandomContentController.Presenter, BookmarkController.Presenter,
        ReadLaterController.Presenter