private void init() {
    mSwipeBackLayout = getSwipeBackLayout();
    mSwipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT);

    nav_title = (TextView) findViewById(R.id.nav_title);
    nav_title.setText("ÑéÖ¤");
    nav_left_item = (ImageView) findViewById(R.id.nav_left_item);
    nav_left_item.setVisibility(View.VISIBLE);
    nav_left_item.setOnClickListener(
        new ImageView.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
          }
        });

    verificationresultwait_back = (TextView) findViewById(R.id.verificationresultwait_back);
    verificationresultwait_back.setOnClickListener(
        new TextView.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent =
                new Intent(VerificationResultWaitActivity.this, VerificationActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
          }
        });
  }
 @Override
 public View findViewById(int id) {
   View v = super.findViewById(id);
   if (v == null && mSwipeBackLayout != null) {
     v = mSwipeBackLayout.findViewById(id);
   }
   return v;
 }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   ButterKnife.bind(this);
   setTitle(getString(R.string.title_settings));
   getFragmentManager()
       .beginTransaction()
       .replace(R.id.fragment_frame, new PrefsFragment())
       .commit();
   mSwipeBackLayout = getSwipeBackLayout();
   mSwipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT);
 }
  @SuppressWarnings("deprecation")
  public void onActivityCreate() {
    mActivity.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    mActivity.getWindow().getDecorView().setBackgroundDrawable(null);
    mSwipeBackLayout =
        (SwipeBackLayout) LayoutInflater.from(mActivity).inflate(R.layout.swipeback_layout, null);
    mSwipeBackLayout.addSwipeListener(
        new SwipeBackLayout.SwipeListener() {
          @Override
          public void onScrollStateChange(int state, float scrollPercent) {}

          @Override
          public void onEdgeTouch(int edgeFlag) {
            Utils.convertActivityToTranslucent(mActivity);
          }

          @Override
          public void onScrollOverThreshold() {}
        });
  }
 /** Scroll out contentView and finish the activity */
 public void scrollToFinishActivity() {
   mSwipeBackLayout.scrollToFinishActivity();
 }
 public void setSwipeBackEnable(boolean enable) {
   mSwipeBackLayout.setEnableGesture(enable);
 }
 @Override
 protected void onPostCreate(Bundle savedInstanceState) {
   super.onPostCreate(savedInstanceState);
   mSwipeBackLayout.attachToActivity(this);
 }
  @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
  }
Пример #9
0
  @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();
  }
 public View findViewById(int id) {
   if (mSwipeBackLayout != null) {
     return mSwipeBackLayout.findViewById(id);
   }
   return null;
 }
 public void onPostCreate() {
   mSwipeBackLayout.attachToActivity(mActivity);
 }