Пример #1
0
  @SuppressLint("NewApi")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.avideo);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      if (!BuildVars.debug) {
        getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);
      }
    }
    NotificationManager mNotificationManager =
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancelAll();
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    title = (TextView) findViewById(R.id.tvVtitle);
    reports = new Reports(getApplicationContext(), "Training");
    mtitle = (TextView) findViewById(R.id.mtitle);
    icon = (ImageView) findViewById(R.id.miconimage);
    detail = (TextView) findViewById(R.id.tvVDetail);
    from = (TextView) findViewById(R.id.tvVFrom);
    summary = (TextView) findViewById(R.id.tvVsummary);
    vfullscreenplay = (ImageView) findViewById(R.id.vfullscreenplay);

    vid = (com.sanofi.in.mobcast.CustomVideoView) findViewById(R.id.vvType);

    mtitle.setText("Training");

    icon.setImageResource(R.drawable.training);

    // share = (Button) findViewById(R.id.bVshare);
    vid.setOnPreparedListener(this);
    btn = (ImageView) findViewById(R.id.vbackground);
    play = (ImageView) findViewById(R.id.vbackgroundplay);
    play.setOnClickListener(BackgroundclkListener);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      play.setAlpha(0.7f);
    }

    btn.setOnClickListener(BackgroundclkListener);

    share = (Button) findViewById(R.id.iv6);

    onNewIntent(getIntent());
    share.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            if (event.getAction() == android.view.MotionEvent.ACTION_DOWN) {
              if (android.os.Build.VERSION.SDK_INT >= 11) {
                v.setAlpha(0.5f);
              }
              // v.getBackground().setAlpha(45);
            } else if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
              if (android.os.Build.VERSION.SDK_INT >= 11) {
                v.setAlpha(1);
              }
              // v.getBackground().setAlpha(255);
            }
            return false;
          }
        });
    vfullscreenplay.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            // isToRate = true;
            vid.pause();
            time = vid.getCurrentPosition();
            Log.d("Paused at ", "" + time);
            Intent i = new Intent(TrainingVideo.this, VideoFullscreen.class);
            i.putExtra("name", name);
            Log.d("name", name);
            i.putExtra("StartAt", (int) time);
            onDestroy();
            startActivity(i);
          }
        });

    detail.setText(DateUtils.formatDate(Ddetail));
    share.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            reports.updateShare(aid);
            final Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
            shareIntent.setType("video/mp4");
            String shareBody =
                title.getText()
                    + "\n"
                    + from.getText()
                    + "\n ON: "
                    + detail.getText()
                    + "\n"
                    + summary.getText();
            shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, title.getText());
            prefs.edit().putInt("StartAt", vid.getCurrentPosition()).commit();
            shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
            shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.fromFile(file));
            startActivity(Intent.createChooser(shareIntent, "Share video"));
          }
        });

    String roo1t =
        Environment.getExternalStorageDirectory().toString() + Constants.APP_FOLDER_VIDEO + name;
    Bitmap thumbnail =
        ThumbnailUtils.createVideoThumbnail(roo1t, MediaStore.Images.Thumbnails.MINI_KIND);
    BitmapDrawable bitmapDrawable = new BitmapDrawable(thumbnail);
    vid.setBackgroundDrawable(bitmapDrawable);
    // btn.setBackgroundDrawable(bitmapDrawable);

    btn.setImageDrawable(bitmapDrawable);
    vid.setVideoPath(roo1t);

    mc = new MediaController(this);
    mc.show(500000);
    mc.setAnchorView(vid);
    vid.setMediaController(mc);
    vid.requestFocus();
    // vid.setPlayPauseListener(ppl);

  }
Пример #2
0
  @Override
  public void onNewIntent(Intent intent) {

    Dtitle = intent.getStringExtra("title");
    Ddetail = intent.getStringExtra("detail");
    Dfrom = intent.getStringExtra("from");
    _id = intent.getStringExtra("_id");
    Dsummary = intent.getStringExtra("summary");
    String sharekey = intent.getStringExtra("shareKey");
    if (sharekey.contains("off")) share.setVisibility(Button.GONE);
    name = intent.getStringExtra("name");
    aid = intent.getStringExtra("id");
    // String shareflag = intent.getStringExtra("shareKey");
    // if(shareflag.trim().contentEquals("off"))
    // share.setVisibility(Button.INVISIBLE);

    // url = intent.getStringExtra("");
    title.setText(Dtitle);
    detail.setText(Ddetail);
    from.setText(Dfrom);
    summary.setText(Dsummary);

    String root = Environment.getExternalStorageDirectory().toString();
    File myDir = new File(root + Constants.APP_FOLDER_VIDEO);
    // myDir.mkdirs();
    String fname = name;
    file = new File(myDir, fname);
    if (file.exists()) {

      String roo1t =
          Environment.getExternalStorageDirectory().toString() + Constants.APP_FOLDER_VIDEO + name;
      vid.setVideoPath(roo1t);
      vid.setZOrderOnTop(false);
      vid.setMediaController(new MediaController(this) {});
      vid.requestFocus();
    } else {
      if (Utilities.isInternetConnected()) {
        Download d = new Download(TrainingVideo.this, AnnounceDBAdapter.SQLITE_TRAINING, _id + "");
        d.execute("");
        d.setOnPostExecuteListener(
            new OnPostExecuteListener() {

              public void onPostExecute(String result) {
                String roo1t =
                    Environment.getExternalStorageDirectory().toString()
                        + Constants.APP_FOLDER_VIDEO
                        + name;
                detail.setText(DateUtils.formatDate(Ddetail));
                Bitmap thumbnail =
                    ThumbnailUtils.createVideoThumbnail(
                        roo1t, MediaStore.Images.Thumbnails.MINI_KIND);
                BitmapDrawable bitmapDrawable = new BitmapDrawable(thumbnail);
                // vid.setBackgroundDrawable(bitmapDrawable);
                btn.setImageDrawable(bitmapDrawable);
                vid.setVideoPath(roo1t);

                vid.setVideoPath(roo1t);
                vid.setZOrderOnTop(false);
                vid.setMediaController(new MediaController(TrainingVideo.this) {});
                vid.requestFocus();
              }
            });
      } else {
        Toast.makeText(
                TrainingVideo.this, "Please check your internet connection", Toast.LENGTH_SHORT)
            .show();
      }
    }

    // vid.start();
    AnnounceDBAdapter announce = new AnnounceDBAdapter(getApplicationContext());
    announce.open();
    announce.readrow(_id + "", "Training");
    announce.close();
    reports.updateRead(aid);

    //		SA VIKALP ADDED CANCEL LOLLIPOP NOTIFICATION
    try {
      Utilities.cancelLolliPopNotification(ApplicationLoader.getApplication());
    } catch (Exception e) {
      Log.i(TAG, e.toString());
    }
    //		EA VIKALP ADDED CANCEL LOLLIPOP NOTIFICATION
  }