Beispiel #1
0
  private void initSinaWeibo() {
    weibo = new WeiboExt();
    weibo.setHttpConnectionTimeout(5000);
    if (sinaToken == null) sinaToken = SinaAccountUtil.getToken(PageActivity.this);

    weibo.setToken(sinaToken.getToken(), sinaToken.getTokenSecret());
  }
Beispiel #2
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);
  }