This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
@RequestMapping("/api/v1/products") | |
public class ProductsController { | |
@Autowired | |
ProductsRepository productsRepository; | |
@Autowired | |
AuditService auditService; | |
@PostMapping("") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.javers</groupId> | |
<artifactId>javers-spring-boot-starter-sql</artifactId> | |
<version>${javers.version}</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
public class AuditService { | |
@Autowired | |
private final Javers javers; | |
public AuditService(Javers javers) { | |
this.javers = javers; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void onDestroy(){ | |
mVideoPlayer.stop(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void onResume(){ | |
mVideoPlayer.play(); | |
} | |
public void onPause(){ | |
mVideoPlayer.pause(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void onCreate(…){ | |
//some UI setup | |
mVideoPlayer = new VideoPlayer(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void onCreate(…){ | |
//some UI setup | |
mVideoPlayer = new VideoPlayer(); | |
getLifecycle().addObserver(mVideoPlayer); | |
} | |
public void onDestroy(){ | |
getLifecycle().removeObserver(mVideoPlayer); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class VideoPlayer implements LifecycleObserver{ | |
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME) | |
public void play(){ | |
//play logic | |
} | |
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE) | |
public void pause(){ | |
//pause logic | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
// Lifecycles only (no ViewModel or LiveData) | |
implementation "android.arch.lifecycle:runtime:1.1.0" | |
annotationProcessor "android.arch.lifecycle:compiler:1.1.0" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void onCreate(…){ | |
//some UI setup | |
mVideoPlayer = new VideoPlayer(); | |
} | |
public void onResume(){ | |
mVideoPlayer.play(); | |
} | |
public void onPause(){ |