예제 #1
0
  public void reload() {
    currentPageIndex = -1;
    PagingStrategy pagingStrategy = null;
    if (accountType.equals(Constants.TYPE_SINA_WEIBO)
        || accountType.equals(Constants.TYPE_MY_SINA_WEIBO)) {
      //// System.out.println("accountType" + accountType);
      if (isWeiboMode()) pagingStrategy = new WeiboPagingStrategy(this);
      else pagingStrategy = new FixedPagingStrategy(this, 2);

      pagingStrategy.setNoMoreArticleListener(
          new NoMoreArticleListener() {
            public void onNoMoreArticle() throws NoMoreStatusException {
              // Log.d("cache system", "no more articles, refreshing repo");
              repo.refresh(repo.getRefreshingToken());
            }
          });

      repo = new ContentRepo(pagingStrategy, refreshingSemaphore);

      sinaToken = SinaAccountUtil.getToken(PageActivity.this);
      ArticleFilter filter;
      if (isWeiboMode()) filter = new NullArticleFilter();
      else filter = new ContainsLinkFilter(new NullArticleFilter());

      source =
          new SinaArticleSource(
              true, sinaToken.getToken(), sinaToken.getTokenSecret(), sourceId, filter);

    } else if (accountType.equals(Constants.TYPE_RSS)
        || accountType.equals(Constants.TYPE_BAIDUSEARCH)) {
      pagingStrategy = new FixedPagingStrategy(this, 2);
      pagingStrategy.setNoMoreArticleListener(
          new NoMoreArticleListener() {
            public void onNoMoreArticle() throws NoMoreStatusException {
              throw new NoMoreStatusException();
            }
          });

      repo = new ContentRepo(pagingStrategy, refreshingSemaphore);
      cachedArticleSource =
          new CachedArticleSource(
              new FeaturedArticleSource(this, contentUrl, sourceName, sourceImageURL),
              this,
              this,
              SourceCache.getInstance(this));
      cachedArticleSource.loadSourceFromCache();
      source = cachedArticleSource;
    } else if (accountType.equals(Constants.TYPE_GOOGLE_READER)) {

      String sid = preferences.getString(GoogleAccountActivity.GOOGLE_ACCOUNT_SID, "");
      String auth = preferences.getString(GoogleAccountActivity.GOOGLE_ACCOUNT_AUTH, "");

      pagingStrategy = new FixedPagingStrategy(this, 2);
      pagingStrategy.setNoMoreArticleListener(
          new NoMoreArticleListener() {
            public void onNoMoreArticle() throws NoMoreStatusException {
              throw new NoMoreStatusException();
            }
          });
      repo = new ContentRepo(pagingStrategy, refreshingSemaphore);
      source = new GoogleReaderArticleSource(sid, auth);
    } else if (accountType.equals(Constants.TYPE_TAOBAO)) {

      pagingStrategy = new FixedPagingStrategy(this, 2);
      pagingStrategy.setNoMoreArticleListener(
          new NoMoreArticleListener() {
            public void onNoMoreArticle() throws NoMoreStatusException {
              throw new NoMoreStatusException();
            }
          });

      repo = new ContentRepo(pagingStrategy, refreshingSemaphore);
      source = new TaobaoArticleSource(sourceName, this.getApplicationContext());
    }

    repo.setArticleSource(source);

    headerText.setText(sourceName);
    if (sourceImageURL != null && sourceImageURL.length() != 0) {
      headerImageView.setImageUrl(sourceImageURL);
      headerImageView.loadImage();
    } else {
      int maxTitle = 7;

      if (sourceName != null && sourceName.length() >= maxTitle)
        headerImageView.setVisibility(View.GONE);
      else headerImageView.setVisibility(View.INVISIBLE);
    }

    slidingWindows = new PageViewSlidingWindows(10, repo, pageViewFactory, 3);
    current = pageViewFactory.createFirstPage();

    shadow = new LinearLayout(PageActivity.this);
    shadow.setBackgroundColor(Color.parseColor("#10999999"));

    shadow2 = new LinearLayout(PageActivity.this);
    shadow2.setBackgroundColor(Color.parseColor("#FFDDDDDD"));

    shadowParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
    pageViewLayoutParamsFront =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT);
    pageViewLayoutParamsBack = pageViewLayoutParamsFront;
    flipPage(true);
  }
예제 #2
0
  private void showAnimation() {

    enlargedMode = false;
    renderNextPageIfNotRendered();
    // Log.d("ANI", "start animation");
    container.removeAllViews();
    if (current.isFirstPage()) {
      next.setVisibility(View.VISIBLE);
      currentPageIndex++;
      container.addView(current, pageViewLayoutParamsBack);
      container.addView(next, pageViewLayoutParamsFront);
      current.startAnimation(fadeInPageView);
    } else if (isWeiboMode()
        || next.isLastPage()
        || next.getWrapperViews().size() < 2
        || lastFlipDirection == ACTION_HORIZONTAL) {

      Animation rotation = buildFlipHorizonalAnimation(forward);
      if (forward) next.setVisibility(View.VISIBLE);
      else previous.setVisibility(View.VISIBLE);
      if (forward) {
        currentPageIndex++;

        container.addView(current, pageViewLayoutParamsBack);
        container.addView(next, pageViewLayoutParamsFront);
        current.startAnimation(rotation);
      } else {

        container.addView(current, pageViewLayoutParamsFront);
        container.addView(previous, pageViewLayoutParamsBack);
        previous.startAnimation(rotation);
      }
    } else {
      if (forward) {
        currentPageIndex++;
        container.addView(next, pageViewLayoutParamsFront);
      } else {
        container.addView(previous, pageViewLayoutParamsFront);
      }
      container.addView(current, pageViewLayoutParamsBack);

      if (forward) {
        currentUpper = current.getWrapperViews().get(0);
        currentBottom = current.getWrapperViews().get(1);
        nextUpper = next.getWrapperViews().get(0);
        nextBottom = next.getWrapperViews().get(1);
        final Animation flipToNext =
            buildFlipAnimation(currentUpper, currentBottom, nextUpper, nextBottom, true);
        currentBottom.startAnimation(flipToNext);
      } else {
        currentUpper = current.getWrapperViews().get(0);
        currentBottom = current.getWrapperViews().get(1);
        nextUpper = previous.getWrapperViews().get(0);
        nextBottom = previous.getWrapperViews().get(1);

        final Animation flipToPrevious =
            buildFlipAnimation(currentUpper, currentBottom, nextUpper, nextBottom, false);
        currentUpper.startAnimation(flipToPrevious);
      }
    }
  }