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

    saveRecord();
    return;
  }
Example #2
0
 @Override
 public void onContentChanged() {
   super.onContentChanged();
   mImageView = (ImageViewTouch) findViewById(R.id.image_viewer);
   mRefreshStopSaveButton = (ImageButton) findViewById(R.id.refresh_stop_save);
   mProgress = (ProgressBar) findViewById(R.id.progress);
 }
 @Override
 protected void onPause() {
   super.onPause();
   if (mLoadingArticle.getVisibility() == View.VISIBLE) {
     mLoadingArticle.endAnimation();
   }
 }
  @Override
  protected void onDestroy() {
    super.onDestroy();

    if (pDialog != null) pDialog.dismiss();
    pDialog = null;
    return;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_verificationresultwait);

    init();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);

    if (savedInstanceState == null) {
      getSupportFragmentManager()
          .beginTransaction()
          .replace(R.id.container, AdminLoginFragment.newInstance())
          .commit();
    }
  }
Example #7
0
 @Override
 protected void onNewIntent(final Intent intent) {
   super.onNewIntent(intent);
   setIntent(intent);
   loadImage();
 }
Example #8
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   stopLoading();
 }
Example #9
0
 @Override
 protected void onCreate(final Bundle icicle) {
   super.onCreate(icicle);
   setContentView(R.layout.image_viewer);
   loadImage();
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_novel_content);

    mSwipeBackLayout = getSwipeBackLayout();
    mSwipeBackLayout.setScrimColor(Color.TRANSPARENT);
    mSwipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT);

    // fetch vars
    parentActivity = this;
    currentAid = getIntent().getIntExtra("aid", 1);
    currentVid = getIntent().getIntExtra("vid", 1);
    currentCid = getIntent().getIntExtra("cid", 1);
    from = getIntent().getStringExtra("from");
    if (from == null) from = "";
    vl = (List<XMLParser.VolumeList>) getIntent().getSerializableExtra("volumes");
    if (vl == null) Log.v("MewX", "vl is null from getIntentExtra");

    // menu
    ((LinearLayout) parentActivity.findViewById(R.id.novel_content_layout))
        .setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                // TODO Auto-generated method stub
                ((RelativeLayout) parentActivity.findViewById(R.id.floating_frame))
                    .setVisibility(View.VISIBLE);
              }
            });
    ((RelativeLayout) parentActivity.findViewById(R.id.floating_frame))
        .setOnTouchListener(
            new OnTouchListener() {
              @Override
              public boolean onTouch(View v, MotionEvent event) {
                // TODO Auto-generated method stub
                ((RelativeLayout) parentActivity.findViewById(R.id.floating_frame))
                    .setVisibility(View.GONE);
                return true;
              }
            });

    // previous and next chapter button event
    ((Button) parentActivity.findViewById(R.id.previous_chapter))
        .setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                Log.v("MewX", "[P0]currentCid: " + currentCid);

                // save read record
                saveRecord();

                // goto previous chapter
                int pre = 0, next = 0, current = 0; // by default
                outer:
                for (XMLParser.VolumeList tempVl : vl) {
                  for (XMLParser.ChapterInfo tempCi : tempVl.chapterList) {
                    if (tempCi.cid == currentCid && current != 0) {
                      pre = current; // get previous
                      currentCid = pre;
                      currentVid = tempVl.vid;
                      break outer;
                    }
                    current = tempCi.cid;
                  }
                }

                Log.v(
                    "MewX",
                    "[P1]currentCid: " + currentCid + "; pre: " + pre + "; current: " + current);
                if (pre == 0) Toast.makeText(parentActivity, "No more", Toast.LENGTH_SHORT).show();
                else {
                  // refresh view
                  ((LinearLayout) parentActivity.findViewById(R.id.novel_content_layout))
                      .removeAllViews();
                  getNC();
                }

                return;
              }
            });
    ((Button) parentActivity.findViewById(R.id.next_chapter))
        .setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                // save read record
                saveRecord();
                Log.v("MewX", "[N0]currentCid: " + currentCid);

                // goto previous chapter
                int pre = 0, next = 0, current = 0; // by default
                outer:
                for (XMLParser.VolumeList tempVl : vl) {
                  for (XMLParser.ChapterInfo tempCi : tempVl.chapterList) {
                    if (tempCi.cid == currentCid) {
                      pre = current; // get previous
                    } else if (pre != 0 || pre == 0 && current == currentCid) {
                      next = tempCi.cid; // get next
                      currentCid = next;
                      currentVid = tempVl.vid;
                      break outer;
                    }
                    current = tempCi.cid;
                  }
                }

                Log.v(
                    "MewX",
                    "[N1]currentCid: " + currentCid + "; pre: " + pre + "; current: " + current);
                if (next == 0) Toast.makeText(parentActivity, "No more", Toast.LENGTH_SHORT).show();
                else {
                  // refresh view
                  ((LinearLayout) parentActivity.findViewById(R.id.novel_content_layout))
                      .removeAllViews();
                  getNC();
                }
                return;
              }
            });

    // fill text
    getNC(); // get novel content
  }
 @Override
 public void onPause() {
   // TODO Auto-generated method stub
   super.onPause();
   StatService.onPause(this);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_article);

    this.handler = new Handler();

    Intent intent = getIntent();
    mUrl = intent.getStringExtra("url");
    //    mTitle = intent.getStringExtra("title");
    //    mSummary = intent.getStringExtra("summary");
    //    mAuthor = intent.getStringExtra("author");
    mLoadingArticle = (LoadingTextView) findViewById(R.id.loading_article);
    mWebView = (ObservableWebView) findViewById(R.id.web);
    mWebView.setOnScrollChangedCallback(this);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.addJavascriptInterface(this, "article");
    mRetryButton = (Button) findViewById(R.id.retry);
    this.scanLight = (View) findViewById(R.id.scan_light);

    final ArticleActivity that = this;

    this.fadeIn = AnimationUtils.loadAnimation(this, R.anim.fade_in);
    this.fadeOut = AnimationUtils.loadAnimation(this, R.anim.fade_out);
    this.fadeOut.setAnimationListener(
        new Animation.AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            ArticleActivity.this.mLikeView.setVisibility(View.GONE);
          }

          @Override
          public void onAnimationRepeat(Animation animation) {}
        });

    this.scanAnim = AnimationUtils.loadAnimation(this, R.anim.scan);
    this.scanAnim.setAnimationListener(
        new Animation.AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {
            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            that.scanFinishedDialogFragment = ScanFinishedDialogFragment.newInstance();
            that.scanFinishedDialogFragment.show(ft, "scan");
          }

          @Override
          public void onAnimationEnd(Animation animation) {
            ArticleActivity.this.scanLight.setVisibility(View.GONE);
          }

          @Override
          public void onAnimationRepeat(Animation animation) {}
        });

    mLikeProgress = (ProgressBar) findViewById(R.id.like_progress);
    this.likingAnim =
        ObjectAnimator.ofInt(this.mLikeProgress, "progress", 2, mLikeProgress.getMax() - 1);
    this.likingAnim.setDuration(2000);
    this.unlikingAnim =
        ObjectAnimator.ofInt(this.mLikeProgress, "progress", mLikeProgress.getMax() - 1, 2);
    this.unlikingAnim.setDuration(2000);

    mLikeView = findViewById(R.id.like);
    mLikeTextView = (TextView) findViewById(R.id.like_text);
    mLikeView.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            final ArticleActivity that = ArticleActivity.this;
            final int max = mLikeProgress.getMax();
            if (that.isLikingProgressing) {
              return;
            }
            that.isLikingProgressing = true;

            that.currentAnim = that.isLiking ? that.unlikingAnim : that.likingAnim;
            that.currentAnim.start();

            (new AsyncTask<Void, Void, Boolean>() {

                  @Override
                  protected Boolean doInBackground(Void... params) {
                    Object httpResult = JianshuSession.getsInstance().postSync(that.likeUrl, false);
                    if (httpResult instanceof String) {
                      String str = (String) httpResult;
                      if (str.startsWith("$")) {
                        if (str.contains("addClass('note-liked')")) {
                          that.isLiking = true;
                        } else if (str.contains("removeClass('note-liked')")) {
                          that.isLiking = false;
                        }
                        Matcher matcher = LIKE_COUNT_PATTERN.matcher(str);
                        if (matcher.find()) {
                          that.likingCount = Integer.parseInt(matcher.group(1));
                        }
                        return true;
                      }
                    }
                    return false;
                  }

                  @Override
                  protected void onPostExecute(Boolean succeed) {
                    that.isLikingProgressing = false;
                    // 即使是网络问题失败了,也要重置进度条状态
                    updateLike();
                    if (!succeed) {
                      Toast.makeText(that, "网络似乎不给力", Toast.LENGTH_LONG).show();
                    }
                  }
                })
                .execute();
          }
        });

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    // 滑动返回
    mSwipeBackLayout = getSwipeBackLayout();
    mSwipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT);

    mRetryButton.setOnClickListener(
        new Button.OnClickListener() {

          @Override
          public void onClick(View v) {
            mRetryButton.setVisibility(View.INVISIBLE);
            mLoadingArticle.setVisibility(View.VISIBLE);
            loadArticle();
          }
        });

    mDownloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);

    mFinalHttp = new FinalHttp();

    Object[] state = StatePool.getInstance().getState("article");
    if (state != null) {
      String url = (String) state[0];
      if (mUrl.equals(url)) {
        this.mTitle = (String) state[1];
        this.mAuthor = (String) state[2];
        this.content = (String) state[3];
        mWebView.setVisibility(View.VISIBLE);
        mWebView.loadData(this.content, "text/html; charset=UTF-8", null);
        return;
      }
    }
    loadArticle();
  }