Skip to content

Instantly share code, notes, and snippets.

View AsynctaskCoffee's full-sized avatar
:octocat:
It's time to move on!

Egemen ÖZOGUL AsynctaskCoffee

:octocat:
It's time to move on!
View GitHub Profile
@AsynctaskCoffee
AsynctaskCoffee / BaseFragment.kt
Created December 16, 2022 14:28
BaseFragment Example
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
typealias Inflate<T> = (LayoutInflater, ViewGroup?, Boolean) -> T
abstract class BaseFragment<VB : ViewBinding>(
frameLayout = findViewById(R.id.frameLayout)
videoLayout = VideoLayout(this)
videoLayout.setGravity(VideoLayout.VGravity.centerCrop)
videoLayout.setIsLoop(true)
videoLayout.setPathOrUrl("loginvideotype3.mp4") // could be any video url
frameLayout.addView(videoLayout)
<?xml version="1.0" encoding="utf-8"?>
<egolabsapps.basicodemine.videolayout.VideoLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/videoLayout"
app:path_or_url="walking.mp4"
app:video_gravity="centerCrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.github.AsynctaskCoffee:VideoLayout:1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/videoLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:focusable="true"
android:focusableInTouchMode="true"
tools:context=".MainActivity">
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<egolabsapps.basicodemine.offlinemap.Views.OfflineMapView
android:id="@+id/map"
android:layout_width="match_parent"
public class MainActivity extends AppCompatActivity implements MapListener{
OfflineMapView offlineMapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
offlineMapView = findViewById(R.id.map);
offlineMapView.init(this, this);
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.github.AsynctaskCoffee:AndroidOfflineMapLibrary:v1'
implementation 'com.github.MKergall:osmbonuspack:6.6.0'
implementation 'org.osmdroid:osmdroid-android:6.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'