コード例 #1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().setWindowAnimations(0); // Do not animate the view when it gets pushed on the screen
    setContentView(R.layout.videoview);

    CustomApp appState = ((CustomApp) getApplicationContext());
    unzippedDir = appState.getUnzippedDir();
    // videoView =  (VideoView) findViewById(R.id.surface_view); //new VideoView(VideoViewer.this);

    // Get the extras (video filename) out of the new intent
    Intent intent = getIntent();
    if (intent != null) videoFile = intent.getStringExtra("video");
    if (intent != null) packagePath = intent.getStringExtra("path");

    File clip = new File(/*unzippedDir + */ packagePath + File.separator + videoFile);
    System.out.println("Complete video path === " + packagePath + File.separator + videoFile);

    try {
      if (clip.exists()) {

        videoView = new VideoView(VideoViewer.this);
        videoView.setVideoPath(clip.getAbsolutePath());

        videoView.setLayoutParams(
            new Gallery.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

        ctlr = new MediaController(VideoViewer.this);
        ctlr.setMediaPlayer(videoView);
        videoView.setMediaController(ctlr);
        videoView.requestFocus();
        videoView.start();
        setContentView(videoView);

      } else {
        TextView tv = new TextView(this);
        tv.setText("File does not exist");
        setContentView(tv);
      }
    } catch (OutOfMemoryError E) {
      // Release some (all) of the above objects
      System.out.println("Out of Memory Exception");
      TextView txtView = new TextView(VideoViewer.this);
      txtView.setText("Error: Out of Memory - video file is too big to load!");
      setContentView(txtView);
    }
  }
コード例 #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // setContentView(R.layout.splash);
    getWindow()
        .setWindowAnimations(
            0); // Do not animate the view when it gets pushed on the screen
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

    // MyStateSaver data = (MyStateSaver) getLastNonConfigurationInstance();

    CustomApp appState = ((CustomApp) getApplicationContext());
    unzippedDir = appState.getUnzippedDir();
    authenticationUrl = appState.getAuthenticationUrl();
    unzippedRoot = appState.getUnzippedRoot();

    languageSelected = appState.getLanguage();
    Locale locale = new Locale(languageSelected);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    getBaseContext()
        .getResources()
        .updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());

    oc = new OnlineCheck(); // check online connection

    // Check if an SDCard exists. If it does then check if the PlaceBooks dir exists.
    // If it does not exist then create it. If there is no SDCard then alert user they need one.
    SDCardCheck sdcardcheck = new SDCardCheck();
    if (sdcardcheck.isSdPresent()) {
      // SDCard IS mounted. Now check if PlaceBooks root dir exists. Create it when app first starts
      // up.
      File directory = new File(unzippedDir);

      if (!directory.exists()) {
        // Create the placebooks root directory on the SDCard
        directory = new File(unzippedDir);
        directory.mkdirs();
      } else {
        // Directory exists so do nothing
      }
    } else {
      // SDCard is not mounted. Alert user.
      Log.d("Placebooks", getResources().getString(R.string.no_sdcard));

      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder.setTitle(getResources().getString(R.string.no_sdcard));
      builder.setMessage(getResources().getString(R.string.sdcard_needed));
      builder.setPositiveButton(getResources().getString(R.string.ok), null);
      builder.show();
    }

    /*
    //Get the app's shared preferences - check if a user connected their account to the app
    SharedPreferences loginAppPreferences = this.getSharedPreferences("LOGIN_DETAILS", MODE_PRIVATE);
    strUserName = loginAppPreferences.getString("username", "");
    strPassword = loginAppPreferences.getString("password", "");

    if (data != null) {
         // Show splash screen if still loading
         if (data.showSplashScreen) {
             showSplashScreen();
         }
         if (strUserName != ""){

     Intent intent = new Intent();
     //intent.setClassName("org.placebooks.www", "org.placebooks.www.Shelf");
     intent.setClassName("org.placebooks.www", "org.placebooks.www.TabLayoutActivity");
     intent.putExtra("username", strUserName);  //pass the username variable along as an extra in the Intent object, and then retrieve it from the newly launched Activity in the Shelf class
     //intent.putExtra("password", password);
     startActivity(intent);
     mSplashDialog.dismiss();
     endThisActivity();	//kill the placebooks activity

      }

      else{
       //First time using the app on the phone so let user log in..

      presentLogin();

      } //end of else

         // Rebuild your UI with your saved state here
    } else {
        showSplashScreen();
         if (strUserName != ""){

     Intent intent = new Intent();
     //intent.setClassName("org.placebooks.www", "org.placebooks.www.Shelf");
     intent.setClassName("org.placebooks.www", "org.placebooks.www.TabLayoutActivity");
     intent.putExtra("username", strUserName);  //pass the username variable along as an extra in the Intent object, and then retrieve it from the newly launched Activity in the Shelf class
     //intent.putExtra("password", password);
     startActivity(intent);
     mSplashDialog.dismiss();
     endThisActivity();	//kill the placebooks activity

      }

      else{
       //First time using the app on the phone so let user log in..

      presentLogin();

      } //end of else
         // Do your heavy loading here on a background thread
    }
    */

    // User isn't logged in so let them log in
    presentLogin();
  } // end of onCreate()