public override void onCreate(Bundle savedInstanceState) { base.onCreate(savedInstanceState); ContentView = R.layout.activity_custom_capturer; localMedia = LocalMedia.create(this); capturedView = (LinearLayout)findViewById(R.id.captured_view); videoView = (VideoView)findViewById(R.id.video_view); timerView = (Chronometer)findViewById(R.id.timer_view); timerView.start(); // Once added we should see our linear layout rendered live below localVideoTrack = localMedia.addVideoTrack(true, new ViewCapturer(capturedView)); localVideoTrack.addRenderer(videoView); }
public override void onCreate(Bundle savedInstanceState) { base.onCreate(savedInstanceState); ContentView = R.layout.activity_custom_capturer; localMedia = LocalMedia.create(this); capturedView = (LinearLayout) findViewById(R.id.captured_view); videoView = (VideoView) findViewById(R.id.video_view); timerView = (Chronometer) findViewById(R.id.timer_view); timerView.start(); // Once added we should see our linear layout rendered live below localVideoTrack = localMedia.addVideoTrack(true, new ViewCapturer(capturedView)); localVideoTrack.addRenderer(videoView); }
public override void addView(android.view.View child, int index, android.view.ViewGroup .LayoutParams @params) { base.addView(child, index, @params); int childId = child.getId(); if (childId == CHRONOMETER_ID && child is android.widget.Chronometer) { mChronometer = (android.widget.Chronometer)child; mChronometer.setOnChronometerTickListener(this); // Check if Chronometer should move with with ProgressBar mChronometerFollow = (@params.width == android.view.ViewGroup.LayoutParams.WRAP_CONTENT ); mChronometerGravity = (mChronometer.getGravity() & android.view.Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK ); } else { if (childId == PROGRESSBAR_ID && child is android.widget.ProgressBar) { mProgressBar = (android.widget.ProgressBar)child; } } }
public virtual void onChronometerTick(android.widget.Chronometer chronometer) { if (mProgressBar == null) { throw new java.lang.RuntimeException("Expecting child ProgressBar with id 'android.R.id.progress'" ); } // Stop Chronometer if we're past duration long now = android.os.SystemClock.elapsedRealtime(); if (now >= mDurationBase) { mChronometer.stop(); } // Update the ProgressBar status int remaining = (int)(mDurationBase - now); mProgressBar.setProgress(mDuration - remaining); // Move the Chronometer if gravity is set correctly if (mChronometerFollow) { android.widget.RelativeLayout.LayoutParams @params; // Calculate estimate of ProgressBar leading edge position @params = (android.widget.RelativeLayout.LayoutParams)mProgressBar.getLayoutParams (); int contentWidth = mProgressBar.getWidth() - (@params.leftMargin + @params.rightMargin ); int leadingEdge = ((contentWidth * mProgressBar.getProgress()) / mProgressBar.getMax ()) + @params.leftMargin; // Calculate any adjustment based on gravity int adjustLeft = 0; int textWidth = mChronometer.getWidth(); if (mChronometerGravity == android.view.Gravity.RIGHT) { adjustLeft = -textWidth; } else { if (mChronometerGravity == android.view.Gravity.CENTER_HORIZONTAL) { adjustLeft = -(textWidth / 2); } } // Limit margin to keep text inside ProgressBar bounds leadingEdge += adjustLeft; int rightLimit = contentWidth - @params.rightMargin - textWidth; if (leadingEdge < @params.leftMargin) { leadingEdge = @params.leftMargin; } else { if (leadingEdge > rightLimit) { leadingEdge = rightLimit; } } @params = (android.widget.RelativeLayout.LayoutParams)mChronometer.getLayoutParams (); @params.leftMargin = leadingEdge; // Request layout to move Chronometer mChronometer.requestLayout(); } }
void android.widget.Chronometer.OnChronometerTickListener.onChronometerTick(android.widget.Chronometer arg0) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.widget.Chronometer.OnChronometerTickListener_._onChronometerTick11074, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.widget.Chronometer.OnChronometerTickListener_.staticClass, global::android.widget.Chronometer.OnChronometerTickListener_._onChronometerTick11074, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } }