@Override
  protected void onDestroy() {
    super.onDestroy();

    articleFeed.stopLoad();
    ThumbnailCache.getInstance().stopLoad();
  }
  @Override
  protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    articleFeed.setRssListener(null);
    currentPosition = findViewById(R.id.article_scroll_view).getScrollY();
  }
  @Override
  protected void onResume() {
    super.onResume();
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor editor = settings.edit();

    if (settings.getBoolean("CLEAN_UP", false)) {
      editor.putBoolean("CLEAN_UP", false);
      editor.commit();
      setContentView(R.layout.articles_list);

      rubricsList = (LinearLayout) findViewById(R.id.articles_list);
      //			emptMessage = (TextView) findViewById(R.id.empty);

      articleFeed.loadCache();

      generateRubricsList();
    }

    //		final ScrollView scrollView = (ScrollView)findViewById(R.id.article_scroll_view);
    //		scrollView.post(new Runnable() {
    //
    //			@Override
    //			public void run() {
    //				scrollView.scrollTo(0, currentPosition);
    //			}
    //		});

    if (articleFeed.getNonemptyRubrics().size() == 0) {
      emptyMessage.setVisibility(View.INVISIBLE);
    } else {
      emptyMessage.setVisibility(View.INVISIBLE);
    }

    articleFeed.setRssListener(
        new Loader.RssListener() {

          @Override
          public void finish() {
            Application.hideProgressBar();
          }

          @Override
          public void addArticle(RssArticle article) {
            insertArticleView(article);
          }
        });
  }
  @Override
  protected void onPostResume() {
    super.onPostResume();
    articleFeed.resume();

    if (!isUpdatedToday()) {
      reloadFeed();
    }

    SharedPreferences.Editor settings = PreferenceManager.getDefaultSharedPreferences(this).edit();
    Date lastUpdateDate = new Date();
    settings.putLong(LAST_UPDATE_DATE, lastUpdateDate.getTime());
    settings.commit();

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

    articleFeed = new ArticleFeed(this.getBaseContext());
    setFeed(articleFeed);

    articleFeed.loadCache();

    ThumbnailCache.getInstance().setContext(getBaseContext());

    setContentView(R.layout.articles_list);
    rubricsList = (LinearLayout) findViewById(R.id.articles_list);
    emptyMessage = (TextView) findViewById(R.id.empty);

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    String fontSize = preferences.getString("font_list_size", "medium");

    float imageSize = 12;
    if (fontSize.equalsIgnoreCase("small")) {
      imageSize = getResources().getDimension(R.dimen.image_size_small);
    } else if (fontSize.equalsIgnoreCase("medium")) {
      imageSize = getResources().getDimension(R.dimen.image_size_medium);
    } else if (fontSize.equalsIgnoreCase("large")) {
      imageSize = getResources().getDimension(R.dimen.image_size_large);
    }

    Display display =
        ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    int width = display.getWidth();

    int maxImageCount = (int) (width / imageSize + 1);
    Rubric.setDefaultViewCount(maxImageCount);
    System.gc();

    listArticlesViews = new LinkedList<View>();
    generateRubricsList();
  }
  @Override
  protected void onPause() {
    super.onPause();

    articleFeed.pauseLoad();
  }