move current track bar into a standalone layout file

This commit is contained in:
tibbi 2020-10-17 11:42:13 +02:00
parent 09870f89d5
commit d1afa24e65
4 changed files with 48 additions and 42 deletions

View file

@ -10,7 +10,6 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.widget.SearchView
import androidx.core.content.ContextCompat
import androidx.core.view.MenuItemCompat
import androidx.viewpager.widget.ViewPager
import com.simplemobiletools.commons.dialogs.FilePickerDialog
@ -36,8 +35,8 @@ import com.simplemobiletools.musicplayer.models.Events
import com.simplemobiletools.musicplayer.models.Playlist
import com.simplemobiletools.musicplayer.services.MusicService
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.activity_main.view.*
import kotlinx.android.synthetic.main.fragment_songs.*
import kotlinx.android.synthetic.main.view_current_track_bar.*
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
@ -205,7 +204,7 @@ class MainActivity : SimpleActivity(), MainActivityInterface {
initFragments()
initializePlayer()
current_track_holder.setOnClickListener {
current_track_bar.setOnClickListener {
Intent(this, TrackActivity::class.java).apply {
startActivity(this)
}
@ -258,8 +257,8 @@ class MainActivity : SimpleActivity(), MainActivityInterface {
}
private fun updateCurrentTrackBar() {
current_track_holder.updateColors()
current_track_holder.updateCurrentTrack(MusicService.mCurrTrack)
current_track_bar.updateColors()
current_track_bar.updateCurrentTrack(MusicService.mCurrTrack)
}
private fun showSleepTimer() {
@ -482,7 +481,7 @@ class MainActivity : SimpleActivity(), MainActivityInterface {
getCurrentFragment()?.songChangedEvent(event.track)
}
current_track_holder.updateCurrentTrack(event.track)
current_track_bar.updateCurrentTrack(event.track)
}
@Subscribe(threadMode = ThreadMode.MAIN)

View file

@ -15,7 +15,7 @@ import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.extensions.config
import com.simplemobiletools.musicplayer.models.Track
import kotlinx.android.synthetic.main.activity_main.view.*
import kotlinx.android.synthetic.main.view_current_track_bar.view.*
class CurrentTrackBar(context: Context, attributeSet: AttributeSet) : RelativeLayout(context, attributeSet) {
fun updateColors() {

View file

@ -22,43 +22,11 @@
android:layout_height="match_parent"
android:layout_below="@+id/main_tabs_holder" />
<com.simplemobiletools.musicplayer.views.CurrentTrackBar
android:id="@+id/current_track_holder"
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<ImageView
android:id="@+id/current_track_divider"
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/divider_grey"
android:importantForAccessibility="no" />
<ImageView
android:id="@+id/current_track_image"
android:layout_width="@dimen/song_image_size"
android:layout_height="@dimen/song_image_size"
android:layout_marginStart="@dimen/normal_margin"
android:layout_marginTop="@dimen/normal_margin"
android:layout_marginEnd="@dimen/normal_margin"
android:layout_marginBottom="@dimen/normal_margin" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/current_track_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/current_track_image"
android:layout_alignBottom="@+id/current_track_image"
android:layout_toEndOf="@+id/current_track_image"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingEnd="@dimen/activity_margin"
android:textSize="@dimen/bigger_text_size"
tools:text="My Track" />
</com.simplemobiletools.musicplayer.views.CurrentTrackBar>
layout="@layout/view_current_track_bar"
android:layout_alignParentBottom="true" />
<RelativeLayout
android:id="@+id/sleep_timer_holder"

View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<com.simplemobiletools.musicplayer.views.CurrentTrackBar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/current_track_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<ImageView
android:id="@+id/current_track_divider"
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/divider_grey"
android:importantForAccessibility="no" />
<ImageView
android:id="@+id/current_track_image"
android:layout_width="@dimen/song_image_size"
android:layout_height="@dimen/song_image_size"
android:layout_marginStart="@dimen/normal_margin"
android:layout_marginTop="@dimen/normal_margin"
android:layout_marginEnd="@dimen/normal_margin"
android:layout_marginBottom="@dimen/normal_margin" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/current_track_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/current_track_image"
android:layout_alignBottom="@+id/current_track_image"
android:layout_toEndOf="@+id/current_track_image"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingEnd="@dimen/activity_margin"
android:textSize="@dimen/bigger_text_size"
tools:text="My Track" />
</com.simplemobiletools.musicplayer.views.CurrentTrackBar>