Added now playing queue shett
This commit is contained in:
parent
24f78d9738
commit
2af26548ee
16 changed files with 432 additions and 112 deletions
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
|
||||
public class CustomBottomSheetBehavior<V extends View> extends BottomSheetBehavior<V> {
|
||||
|
||||
private static final String TAG = "CustomBottomSheetBehavi";
|
||||
|
||||
private boolean allowDragging = true;
|
||||
|
||||
public CustomBottomSheetBehavior() {
|
||||
}
|
||||
|
||||
public CustomBottomSheetBehavior(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
|
||||
if (!allowDragging) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.onInterceptTouchEvent(parent, child, event);
|
||||
}
|
||||
|
||||
public void setAllowDragging(boolean allowDragging) {
|
||||
this.allowDragging = allowDragging;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,184 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
|
||||
public class MultiSheetView extends CoordinatorLayout {
|
||||
|
||||
@interface Sheet {
|
||||
|
||||
int NONE = 0;
|
||||
int FIRST = 1;
|
||||
int SECOND = 2;
|
||||
}
|
||||
|
||||
private static final String TAG = "MultiSheetView";
|
||||
|
||||
private CustomBottomSheetBehavior bottomSheetBehavior1;
|
||||
|
||||
private CustomBottomSheetBehavior bottomSheetBehavior2;
|
||||
|
||||
public MultiSheetView(@NonNull Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public MultiSheetView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public MultiSheetView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public boolean consumeBackPress() {
|
||||
switch (getCurrentSheet()) {
|
||||
case Sheet.SECOND:
|
||||
showSheet(Sheet.FIRST);
|
||||
return true;
|
||||
case Sheet.FIRST:
|
||||
showSheet(Sheet.NONE);
|
||||
return true;
|
||||
case Sheet.NONE:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Sheet
|
||||
public int getCurrentSheet() {
|
||||
if (bottomSheetBehavior2.getState() == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
return Sheet.SECOND;
|
||||
} else if (bottomSheetBehavior1.getState() == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
return Sheet.FIRST;
|
||||
} else {
|
||||
return Sheet.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@IdRes
|
||||
public int getMainContainerResId() {
|
||||
return R.id.mainContentFrame;
|
||||
}
|
||||
|
||||
@IdRes
|
||||
public int getSheet1ContainerResId() {
|
||||
return R.id.playerFragmentContainer;
|
||||
}
|
||||
|
||||
@IdRes
|
||||
public int getSheet1PeekViewResId() {
|
||||
return R.id.miniPlayerFragment;
|
||||
}
|
||||
|
||||
@IdRes
|
||||
public int getSheet2ContainerResId() {
|
||||
return R.id.sheet2Container;
|
||||
}
|
||||
|
||||
@IdRes
|
||||
public int getSheet2PeekViewResId() {
|
||||
return R.id.sheet2PeekView;
|
||||
}
|
||||
|
||||
public void showSheet(@Sheet int sheet) {
|
||||
|
||||
// if we are already at our target panel, then don't do anything
|
||||
if (sheet == getCurrentSheet()) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (sheet) {
|
||||
case Sheet.NONE:
|
||||
bottomSheetBehavior2.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
bottomSheetBehavior1.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
break;
|
||||
case Sheet.FIRST:
|
||||
bottomSheetBehavior2.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
bottomSheetBehavior1.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
break;
|
||||
case Sheet.SECOND:
|
||||
bottomSheetBehavior2.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
bottomSheetBehavior1.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
View sheet1 = findViewById(R.id.slidingPanel);
|
||||
bottomSheetBehavior1 = (CustomBottomSheetBehavior) BottomSheetBehavior.from(sheet1);
|
||||
|
||||
View sheet2 = findViewById(R.id.sheet2);
|
||||
View thump = findViewById(R.id.thumb);
|
||||
View extendedToolbar = findViewById(R.id.extendedToolbar);
|
||||
bottomSheetBehavior2 = (CustomBottomSheetBehavior) BottomSheetBehavior.from(sheet2);
|
||||
bottomSheetBehavior2.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
|
||||
@Override
|
||||
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
|
||||
bottomSheetBehavior1.setAllowDragging(false);
|
||||
thump.setRotation(slideOffset * 180);
|
||||
extendedToolbar.setAlpha(slideOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChanged(@NonNull View bottomSheet, int newState) {
|
||||
if (newState == BottomSheetBehavior.STATE_EXPANDED
|
||||
|| newState == BottomSheetBehavior.STATE_DRAGGING) {
|
||||
bottomSheetBehavior1.setAllowDragging(false);
|
||||
} else {
|
||||
bottomSheetBehavior1.setAllowDragging(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//First sheet view click listener
|
||||
findViewById(getSheet1PeekViewResId())
|
||||
.setOnClickListener(v -> bottomSheetBehavior1.setState(BottomSheetBehavior.STATE_EXPANDED));
|
||||
|
||||
// FIXME:
|
||||
// This click listener (combined with a nested RecyclerView in Sheet 2's container), causes
|
||||
// the second peek view to stop responding to drag events.
|
||||
// See `Sheet2Controller`. Remove this ClickListener here to see things working as they should.
|
||||
|
||||
//Second sheet view click listener
|
||||
findViewById(getSheet2PeekViewResId())
|
||||
.setOnClickListener(v -> bottomSheetBehavior2.setState(BottomSheetBehavior.STATE_EXPANDED));
|
||||
|
||||
// FIXED:
|
||||
// issue was bottomSheetBehavior1 is taking drag event when getSheet2PeekView is dragging
|
||||
// so detect touch event getSheet2PeekView set bottomSheetBehavior1 dragging false and bottomSheetBehavior2 true
|
||||
findViewById(getSheet2PeekViewResId()).setOnTouchListener(new OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
Log.e(TAG, "onTouch: ");
|
||||
bottomSheetBehavior1.setAllowDragging(false);
|
||||
bottomSheetBehavior2.setAllowDragging(true);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -6,11 +6,14 @@ import android.os.Bundle
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewTreeObserver
|
||||
import android.widget.FrameLayout
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter
|
||||
import code.name.monkey.retromusic.extensions.hide
|
||||
import code.name.monkey.retromusic.extensions.show
|
||||
import code.name.monkey.retromusic.fragments.MiniPlayerFragment
|
||||
|
@ -52,9 +55,10 @@ import code.name.monkey.retromusic.util.DensityUtil
|
|||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.views.BottomNavigationBarTinted
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import kotlinx.android.synthetic.main.sliding_music_panel_layout.bottomNavigationView
|
||||
import kotlinx.android.synthetic.main.sliding_music_panel_layout.dimBackground
|
||||
import kotlinx.android.synthetic.main.sliding_music_panel_layout.mainContent
|
||||
import kotlinx.android.synthetic.main.sliding_music_panel_layout.sheet2Container
|
||||
import kotlinx.android.synthetic.main.sliding_music_panel_layout.slidingPanel
|
||||
|
||||
abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlayerFragment.Callbacks {
|
||||
|
@ -62,7 +66,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
|
|||
val TAG: String = AbsSlidingMusicPanelActivity::class.java.simpleName
|
||||
}
|
||||
|
||||
private lateinit var bottomSheetBehavior: BottomSheetBehavior<MaterialCardView>
|
||||
private lateinit var bottomSheetBehavior: BottomSheetBehavior<FrameLayout>
|
||||
private var miniPlayerFragment: MiniPlayerFragment? = null
|
||||
private var playerFragment: AbsPlayerFragment? = null
|
||||
private var currentNowPlayingScreen: NowPlayingScreen? = null
|
||||
|
@ -71,6 +75,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
|
|||
private var lightStatusBar: Boolean = false
|
||||
private var lightNavigationBar: Boolean = false
|
||||
private var navigationBarColorAnimator: ValueAnimator? = null
|
||||
private lateinit var queueAdapter: PlayingQueueAdapter
|
||||
protected abstract fun createContentView(): View
|
||||
private val panelState: Int
|
||||
get() = bottomSheetBehavior.state
|
||||
|
@ -112,6 +117,10 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
|
|||
|
||||
val themeColor = ATHUtil.resolveColor(this, android.R.attr.windowBackground, Color.GRAY)
|
||||
dimBackground.setBackgroundColor(ColorUtil.withAlpha(themeColor, 0.5f))
|
||||
|
||||
queueAdapter = PlayingQueueAdapter(this, ArrayList(), MusicPlayerRemote.position, R.layout.item_queue)
|
||||
sheet2Container.adapter = queueAdapter
|
||||
sheet2Container.layoutManager = LinearLayoutManager(this)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -270,6 +279,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
|
|||
override fun onGlobalLayout() {
|
||||
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||
hideBottomBar(false)
|
||||
queueAdapter.swapDataSet(MusicPlayerRemote.playingQueue, MusicPlayerRemote.position)
|
||||
}
|
||||
})
|
||||
} // don't call hideBottomBar(true) here as it causes a bug with the SlidingUpPanelLayout
|
||||
|
@ -278,6 +288,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
|
|||
override fun onQueueChanged() {
|
||||
super.onQueueChanged()
|
||||
hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty())
|
||||
queueAdapter.swapDataSet(MusicPlayerRemote.playingQueue, MusicPlayerRemote.position)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
@ -285,11 +296,14 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
|
|||
}
|
||||
|
||||
open fun handleBackPress(): Boolean {
|
||||
if (bottomSheetBehavior.peekHeight != 0 && playerFragment!!.onBackPressed()) return true
|
||||
/*if (bottomSheetBehavior.peekHeight != 0 && playerFragment!!.onBackPressed()) return true
|
||||
if (panelState == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
collapsePanel()
|
||||
return true
|
||||
}
|
||||
}*/
|
||||
|
||||
if (mainContent.consumeBackPress())
|
||||
return true
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@ import com.bumptech.glide.Glide
|
|||
import java.util.ArrayList
|
||||
|
||||
class AlbumCoverPagerAdapter(
|
||||
fm: FragmentManager,
|
||||
fragmentManager: FragmentManager,
|
||||
private val dataSet: ArrayList<Song>
|
||||
) : CustomFragmentStatePagerAdapter(fm) {
|
||||
) : CustomFragmentStatePagerAdapter(fragmentManager) {
|
||||
|
||||
private var currentColorReceiver: AlbumCoverFragment.ColorReceiver? = null
|
||||
private var currentColorReceiverPosition = -1
|
||||
|
|
|
@ -16,10 +16,7 @@ import code.name.monkey.retromusic.transform.ParallaxPagerTransformer
|
|||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import kotlinx.android.synthetic.main.fragment_player_album_cover.viewPager
|
||||
|
||||
|
||||
class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChangeListener {
|
||||
|
||||
|
||||
private var callbacks: Callbacks? = null
|
||||
private var currentPosition: Int = 0
|
||||
private val colorReceiver = object : AlbumCoverFragment.ColorReceiver {
|
||||
|
@ -34,22 +31,24 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
|
|||
val transformer = ParallaxPagerTransformer(R.id.player_image)
|
||||
transformer.setSpeed(0.3f)
|
||||
viewPager.setPageTransformer(true, transformer)
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_player_album_cover, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
viewPager.addOnPageChangeListener(this)
|
||||
//noinspection ConstantConditions
|
||||
val nowPlayingScreen = PreferenceUtil.getInstance(requireContext()).nowPlayingScreen
|
||||
|
||||
if (PreferenceUtil.getInstance(requireContext()).carouselEffect() &&
|
||||
!((PreferenceUtil.getInstance(requireContext()).nowPlayingScreen == NowPlayingScreen.FULL) ||
|
||||
(PreferenceUtil.getInstance(requireContext()).nowPlayingScreen == NowPlayingScreen.ADAPTIVE)
|
||||
|| (PreferenceUtil.getInstance(requireContext()).nowPlayingScreen == NowPlayingScreen.FIT))) {
|
||||
!((nowPlayingScreen == NowPlayingScreen.FULL) || (nowPlayingScreen == NowPlayingScreen.ADAPTIVE)
|
||||
|| (nowPlayingScreen == NowPlayingScreen.FIT))
|
||||
) {
|
||||
viewPager.clipToPadding = false
|
||||
viewPager.setPadding(40, 40, 40, 0)
|
||||
viewPager.pageMargin = 0
|
||||
|
@ -79,7 +78,7 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
|
|||
|
||||
private fun updatePlayingQueue() {
|
||||
viewPager.apply {
|
||||
adapter = AlbumCoverPagerAdapter(fragmentManager!!, MusicPlayerRemote.playingQueue)
|
||||
adapter = AlbumCoverPagerAdapter(childFragmentManager, MusicPlayerRemote.playingQueue)
|
||||
viewPager.adapter!!.notifyDataSetChanged()
|
||||
viewPager.currentItem = MusicPlayerRemote.position
|
||||
onPageSelected(MusicPlayerRemote.position)
|
||||
|
@ -87,7 +86,6 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
|
|||
}
|
||||
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
|
@ -101,14 +99,10 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
|
|||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun notifyColorChange(color: Int) {
|
||||
if (callbacks != null) {
|
||||
callbacks!!.onColorChanged(color)
|
||||
}
|
||||
callbacks?.onColorChanged(color)
|
||||
}
|
||||
|
||||
fun setCallbacks(listener: Callbacks) {
|
||||
|
@ -119,16 +113,13 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
|
|||
viewPager.setPageTransformer(false, null)
|
||||
}
|
||||
|
||||
|
||||
interface Callbacks {
|
||||
|
||||
fun onColorChanged(color: Int)
|
||||
|
||||
fun onFavoriteToggled()
|
||||
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
val TAG: String = PlayerAlbumCoverFragment::class.java.simpleName
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
|||
}
|
||||
|
||||
override fun setDark(color: Int) {
|
||||
val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground)
|
||||
val colorBg = ATHUtil.resolveColor(requireContext(), R.attr.colorSurface)
|
||||
if (ColorUtil.isColorLight(colorBg)) {
|
||||
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
|
||||
lastDisabledPlaybackControlsColor =
|
||||
|
|
|
@ -28,10 +28,10 @@ import com.bumptech.glide.request.animation.GlideAnimation
|
|||
abstract class RetroMusicColoredTarget(view: ImageView) : BitmapPaletteTarget(view) {
|
||||
|
||||
protected val defaultFooterColor: Int
|
||||
get() = ATHUtil.resolveColor(getView().context, R.attr.colorSurface)
|
||||
get() = ATHUtil.resolveColor(getView().context, R.attr.colorControlNormal)
|
||||
|
||||
protected val albumArtistFooterColor: Int
|
||||
get() = ATHUtil.resolveColor(getView().context, R.attr.colorSurface)
|
||||
get() = ATHUtil.resolveColor(getView().context, R.attr.colorControlNormal)
|
||||
|
||||
abstract fun onColorReady(color: Int)
|
||||
|
||||
|
|
|
@ -14,40 +14,35 @@
|
|||
|
||||
package code.name.monkey.retromusic.views;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class WidthFitSquareLayout extends FrameLayout {
|
||||
private boolean forceSquare = true;
|
||||
|
||||
public WidthFitSquareLayout(Context context) {
|
||||
public WidthFitSquareLayout(@NonNull final Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public WidthFitSquareLayout(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
public WidthFitSquareLayout(@NonNull final Context context, @Nullable final AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public WidthFitSquareLayout(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i);
|
||||
public WidthFitSquareLayout(@NonNull final Context context, @Nullable final AttributeSet attrs,
|
||||
final int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
public WidthFitSquareLayout(Context context, AttributeSet attributeSet, int i, int i2) {
|
||||
super(context, attributeSet, i, i2);
|
||||
public WidthFitSquareLayout(@NonNull final Context context, @Nullable final AttributeSet attrs,
|
||||
final int defStyleAttr,
|
||||
final int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public void forceSquare(boolean z) {
|
||||
this.forceSquare = z;
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
protected void onMeasure(int i, int i2) {
|
||||
if (this.forceSquare) {
|
||||
i2 = i;
|
||||
}
|
||||
super.onMeasure(i, i2);
|
||||
@Override
|
||||
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue