@Override public void onCreate(Bundle savedInstanceState) { StrictMode.setThreadPolicy( new StrictMode.ThreadPolicy.Builder() .detectDiskReads() .detectDiskWrites() .detectNetwork() .penaltyLog() .build()); // allowing the main thread to do http request StrictMode.setVmPolicy( new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects() .detectLeakedClosableObjects() .penaltyLog() .penaltyDeath() .build()); // allowing the main thread to do http request super.onCreate(savedInstanceState); // creates the view requestWindowFeature(Window.FEATURE_NO_TITLE); // requests for no title window getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // sets the fullscreen setContentView( R.layout .viewer); // sets the content of the View to be the layout on the manuscript xml file identifier = getIntent().getIntExtra("identifier", -1); config = getIntent().getStringExtra("config"); ic = new ImageCache(); table = (TableLayout) findViewById(R.id.manuslay); // getting the Table Layout element with id manuslay Display display = getWindowManager().getDefaultDisplay(); // getting the display as an object Point size = new Point(); // creating a Point object display.getSize( size); // getting the size of the screen as a Point object and storing it on the Point // object named size width = size.x; // setting a variable for the width of the screen height = size.y; // setting a variable for the height of the screen page = getIntent().getIntExtra("page", -1); System.out.println(config); par = new Parser(); ic.setCache(page); b = ic.getCurrent(); par.setStr(config); manuscripts = par.FillStructures(); // ************* Upper Menu *************// upper = (LinearLayout) findViewById(R.id.upper); params = new LayoutParams(); params.height = height / 12; params.width = LayoutParams.MATCH_PARENT; upper.setLayoutParams(params); upper.setBackgroundResource(R.raw.navigation); Button tmp; String menu[] = {"Hi-Res", "Multispectral", "3D", "Legacy", "Translation", "Extras"}; params = new LayoutParams(); for (int i = 0; i < 6; i++) { params.width = (width / 9) + 10; params.height = LayoutParams.MATCH_PARENT; tmp = new Button(this); tmp.setBackgroundResource(R.raw.button); tmp.setTextColor(Color.BLUE); tmp.setText(menu[i]); tmp.setOnClickListener(this); tmp.setOnTouchListener(this); tmp.setId(i); tmp.setLayoutParams(params); upper.addView(tmp); } params = new LayoutParams(); SearchView search = new SearchView(this); params.width = width - (6 * (width / 10) + 10); params.height = 60; params.gravity = Gravity.CENTER_VERTICAL; search.setLayoutParams(params); upper.addView(search); // *************** Upper Menu ****************// // **************** Main **************// main = (LinearLayout) findViewById(R.id.main); params = new LayoutParams(); params.height = height - (height / 6); params.width = LayoutParams.MATCH_PARENT; main.setLayoutParams(params); // ************** Main ******************// // ************* Lower Menu *************// lower = (LinearLayout) findViewById(R.id.lower); params = new LayoutParams(); params.height = height / 12; params.width = width; lower.setLayoutParams(params); Button home = (Button) findViewById(R.id.home); home.setBackgroundResource(R.raw.home_button); home.setOnClickListener(this); home.setId(7); params = new LayoutParams(); params.gravity = Gravity.CENTER_VERTICAL; params.width = LayoutParams.WRAP_CONTENT; params.height = (height / 12) - 10; home.setLayoutParams(params); home.setPadding(40, 0, 40, 0); Button toc = (Button) findViewById(R.id.toc); toc.setBackgroundResource(R.raw.table_of_contents); toc.setOnClickListener(this); toc.setId(9); params = new LayoutParams(); params.width = LayoutParams.WRAP_CONTENT; params.height = (height / 12) - 10; params.gravity = Gravity.CENTER_VERTICAL; toc.setLayoutParams(params); toc.setPadding(40, 0, 40, 0); SeekBar seekbar = (SeekBar) findViewById(R.id.seekbar); seekbar.setKeyProgressIncrement(1); seekbar.setMax(200); seekbar.setOnSeekBarChangeListener(this); params = new LayoutParams(); params.height = LayoutParams.MATCH_PARENT; params.width = width - 400; params.height = (height / 12) - 10; params.gravity = Gravity.CENTER_VERTICAL; seekbar.setLayoutParams(params); seekbar.setPadding(40, 0, 40, 0); pageNumber = (TextView) findViewById(R.id.pageNum); pageNumber.setText("Page: " + page); params = new LayoutParams(); params.width = LayoutParams.WRAP_CONTENT; params.height = -50; params.gravity = Gravity.CENTER_VERTICAL; pageNumber.setPadding(0, 0, 20, 0); pageNumber.setLayoutParams(params); Button info = (Button) findViewById(R.id.info); info.setBackgroundResource(R.raw.info); info.setId(8); info.setOnClickListener(this); params = new LayoutParams(); params.width = LayoutParams.WRAP_CONTENT; params.height = (height / 12) - 10; params.gravity = Gravity.RIGHT; info.setLayoutParams(params); lower.setBackgroundResource(R.raw.navigation); // **************** Lower Menu ************// }
@Override public boolean onTouchEvent(MotionEvent arg1) { switch (arg1.getAction()) { case (MotionEvent.ACTION_DOWN): x1 = arg1.getRawX(); System.out.println("Down: " + x1); break; case (MotionEvent.ACTION_UP): { x2 = arg1.getRawX(); System.out.println("Up: " + x2); dx = x2 - x1; if (x1 == x2) { if (vis == 0) { upper.setVisibility(View.GONE); lower.setVisibility(View.GONE); params = new LayoutParams(); params.height = height; main.setLayoutParams(params); vis = 1; } else { upper.setVisibility(View.VISIBLE); lower.setVisibility(View.VISIBLE); LayoutParams lp = new LayoutParams(); lp.height = height - (height / 6); main.setLayoutParams(lp); vis = 0; } } if (dx < 0) { page += 1; b = ic.getNext(); highRes.setImageBitmap(b); highRes.setId(page); pageNumber.setText("Page: " + Integer.toString(page)); Thread thread = new Thread() { public void run() { synchronized (this) { ic.cacheForward(page); } } }; thread.start(); } if (dx > 0 && page != 1) { page -= 1; b = ic.getPrev(); highRes.setImageBitmap(b); highRes.setId(page); pageNumber.setText("Page: " + Integer.toString(page)); ic.cacheRewind(page); } } } return super.onTouchEvent(arg1); }