Skip to content

Instantly share code, notes, and snippets.

Pierfrancesco Soffritti PierfrancescoSoffritti

Block or report user

Report or block PierfrancescoSoffritti

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@PierfrancescoSoffritti
PierfrancescoSoffritti / MainActivity.kt
Last active Feb 14, 2019
How to build sample apps for Android libraries with just a few lines of code.
View MainActivity.kt
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val intent = Intent(this, SampleAppTemplateActivity::class.java)
intent.putExtra(Constants.TITLE.name, getString(R.string.title))
intent.putExtra(Constants.GITHUB_URL.name, "https://github.com/username/repo")
intent.putExtra(Constants.HOMEPAGE_URL.name(), "https://github.com/username/repo/README.md");
intent.putExtra(Constants.PLAYSTORE_PACKAGE_NAME.name(), "com.name.appname");
@PierfrancescoSoffritti
PierfrancescoSoffritti / theme.xml
Created Feb 14, 2019
How to build sample apps for Android libraries with just a few lines of code.
View theme.xml
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
@PierfrancescoSoffritti
PierfrancescoSoffritti / manifest.xml
Last active Feb 14, 2019
How to build sample apps for Android libraries with just a few lines of code
View manifest.xml
<application
android:theme="@style/AppTheme">
<activity android:name="com.psoffritti.librarysampleapptemplate.core.SampleAppTemplateActivity" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
@PierfrancescoSoffritti
PierfrancescoSoffritti / build.gradle
Created Feb 14, 2019
How to build sample apps for Android libraries with just a few lines of code
View build.gradle
dependencies {
implementation "com.psoffritti.librarysampleapptemplate:core:$latest_version"
}
View layout_web_ui.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
android:id="@+id/youtube_player_view"
android:layout_width="match_parent"
View AddAYouTubePlayerListener.java
YouTubePlayerView youTubePlayerView = findViewById(R.id.youtube_player_view);
getLifecycle().addObserver(youTubePlayerView);
youTubePlayerView.addYouTubePlayerListener(new AbstractYouTubePlayerListener() {
@Override
public void onReady(@NonNull YouTubePlayer youTubePlayer) {
String videoId = "S0Q4gqBUs7c";
youTubePlayer.loadVideo(videoId, 0f);
}
});
View Activity.java
YouTubePlayerView youTubePlayerView = findViewById(R.id.youtube_player_view);
getLifecycle().addObserver(youTubePlayerView);
View layout.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
android:id="@+id/youtube_player_view"
android:layout_width="match_parent"
View build.gradle
dependencies {
implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:core:last_version'
}
View CustomUiController.java
class CustomUiController {
private boolean isPlaying = false;
CustomUiController(View customPlayerUI, YouTubePlayer youTubePlayer) {
playPauseButton = customPlayerUI.findViewById(R.id.play_pause_button);
playPauseButton.setOnClickListener( view -> {
if(isPlaying) youTubePlayer.pause();
else youTubePlayer.play();
You can’t perform that action at this time.