Derive from Adapter and only override what you need

pull/20/head
Skalaw 8 years ago
parent 30914b09a9
commit c94265669b
  1. 16
      app/src/main/java/com/github/florent37/camerafragment/sample/MainActivity.java
  2. 33
      camerafragment/src/main/java/com/github/florent37/camerafragment/listeners/CameraFragmentControlsAdapter.java
  3. 18
      camerafragment/src/main/java/com/github/florent37/camerafragment/listeners/CameraFragmentResultAdapter.java
  4. 75
      camerafragment/src/main/java/com/github/florent37/camerafragment/listeners/CameraFragmentStateAdapter.java
  5. 28
      camerafragment/src/main/java/com/github/florent37/camerafragment/listeners/CameraFragmentVideoRecordTextAdapter.java

@ -16,10 +16,10 @@ import android.widget.Toast;
import com.github.florent37.camerafragment.CameraFragment;
import com.github.florent37.camerafragment.CameraFragmentApi;
import com.github.florent37.camerafragment.configuration.Configuration;
import com.github.florent37.camerafragment.listeners.CameraFragmentControlsListener;
import com.github.florent37.camerafragment.listeners.CameraFragmentResultListener;
import com.github.florent37.camerafragment.listeners.CameraFragmentStateListener;
import com.github.florent37.camerafragment.listeners.CameraFragmentVideoRecordTextListener;
import com.github.florent37.camerafragment.listeners.CameraFragmentControlsAdapter;
import com.github.florent37.camerafragment.listeners.CameraFragmentResultAdapter;
import com.github.florent37.camerafragment.listeners.CameraFragmentStateAdapter;
import com.github.florent37.camerafragment.listeners.CameraFragmentVideoRecordTextAdapter;
import com.github.florent37.camerafragment.widgets.CameraSettingsView;
import com.github.florent37.camerafragment.widgets.CameraSwitchView;
import com.github.florent37.camerafragment.widgets.FlashSwitchView;
@ -87,7 +87,7 @@ public class MainActivity extends AppCompatActivity {
public void onRecordButtonClicked() {
final CameraFragmentApi cameraFragment = getCameraFragment();
if (cameraFragment != null) {
cameraFragment.takePhotoOrCaptureVideo(new CameraFragmentResultListener() {
cameraFragment.takePhotoOrCaptureVideo(new CameraFragmentResultAdapter() {
@Override
public void onVideoRecorded(String filePath) {
Toast.makeText(getBaseContext(), "onVideoRecorded " + filePath, Toast.LENGTH_SHORT).show();
@ -176,7 +176,7 @@ public class MainActivity extends AppCompatActivity {
// }
//});
cameraFragment.setStateListener(new CameraFragmentStateListener() {
cameraFragment.setStateListener(new CameraFragmentStateAdapter() {
@Override
public void onCurrentCameraBack() {
@ -255,7 +255,7 @@ public class MainActivity extends AppCompatActivity {
}
});
cameraFragment.setControlsListener(new CameraFragmentControlsListener() {
cameraFragment.setControlsListener(new CameraFragmentControlsAdapter() {
@Override
public void lockControls() {
cameraSwitchView.setEnabled(false);
@ -288,7 +288,7 @@ public class MainActivity extends AppCompatActivity {
}
});
cameraFragment.setTextListener(new CameraFragmentVideoRecordTextListener() {
cameraFragment.setTextListener(new CameraFragmentVideoRecordTextAdapter() {
@Override
public void setRecordSizeText(long size, String text) {
recordSizeText.setText(text);

@ -0,0 +1,33 @@
package com.github.florent37.camerafragment.listeners;
/**
* Convenience implementation of {@link CameraFragmentControlsListener}. Derive from this and only override what you need.
* @author Skala
*/
public class CameraFragmentControlsAdapter implements CameraFragmentControlsListener {
@Override
public void lockControls() {
}
@Override
public void unLockControls() {
}
@Override
public void allowCameraSwitching(boolean allow) {
}
@Override
public void allowRecord(boolean allow) {
}
@Override
public void setMediaActionSwitchVisible(boolean visible) {
}
}

@ -0,0 +1,18 @@
package com.github.florent37.camerafragment.listeners;
/**
* Convenience implementation of {@link CameraFragmentResultListener}. Derive from this and only override what you need.
* @author Skala
*/
public class CameraFragmentResultAdapter implements CameraFragmentResultListener {
@Override
public void onVideoRecorded(String filePath) {
}
@Override
public void onPhotoTaken(byte[] bytes, String filePath) {
}
}

@ -0,0 +1,75 @@
package com.github.florent37.camerafragment.listeners;
import java.io.File;
/**
* Convenience implementation of {@link CameraFragmentStateListener}. Derive from this and only override what you need.
* @author Skala
*/
public class CameraFragmentStateAdapter implements CameraFragmentStateListener {
@Override
public void onCurrentCameraBack() {
}
@Override
public void onCurrentCameraFront() {
}
@Override
public void onFlashAuto() {
}
@Override
public void onFlashOn() {
}
@Override
public void onFlashOff() {
}
@Override
public void onCameraSetupForPhoto() {
}
@Override
public void onCameraSetupForVideo() {
}
@Override
public void onRecordStateVideoReadyForRecord() {
}
@Override
public void onRecordStateVideoInProgress() {
}
@Override
public void onRecordStatePhoto() {
}
@Override
public void shouldRotateControls(int degrees) {
}
@Override
public void onStartVideoRecord(File outputFile) {
}
@Override
public void onStopVideoRecord() {
}
}

@ -0,0 +1,28 @@
package com.github.florent37.camerafragment.listeners;
/**
* Convenience implementation of {@link CameraFragmentVideoRecordTextListener}. Derive from this and only override what you need.
* @author Skala
*/
public class CameraFragmentVideoRecordTextAdapter implements CameraFragmentVideoRecordTextListener {
@Override
public void setRecordSizeText(long size, String text) {
}
@Override
public void setRecordSizeTextVisible(boolean visible) {
}
@Override
public void setRecordDurationText(String text) {
}
@Override
public void setRecordDurationTextVisible(boolean visible) {
}
}
Loading…
Cancel
Save