@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 }