Skip to content

Commit

Permalink
Improving scrolling marquee. Make an attempt to shrink down song titl…
Browse files Browse the repository at this point in the history
…e to fit without scrolling if possible

(cherry picked from commit 97e41f1)
  • Loading branch information
EthanArmbrust committed Jan 23, 2018
1 parent 2056a09 commit 504e254
Showing 2 changed files with 43 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -79,7 +80,7 @@ public class BaseNowplayingFragment extends Fragment implements MusicStateListen

private String ateKey;
private int overflowcounter = 0;
private TextView songtitle, songalbum, songartist, songduration, elapsedtime;
private TextView songtitle, songalbum, songartist, songduration, elapsedtime, scrollTest;
private SeekBar mProgress;
boolean fragmentPaused = false;

@@ -306,6 +307,10 @@ public void setSongDetails(View view) {

recyclerView = (RecyclerView) view.findViewById(R.id.queue_recyclerview);


songtitle.setSelected(true);


Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
if (toolbar != null) {
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
@@ -540,12 +545,37 @@ public void onLoadingFailed(String imageUri, View view, FailReason failReason) {

});
}
if (songtitle != null) {
if(!songtitle.getText().equals(MusicPlayer.getTrackName())) {
if (songtitle != null && MusicPlayer.getTrackName() != null) {
songtitle.setText(MusicPlayer.getTrackName());
songtitle.setSelected(true);
}
if(MusicPlayer.getTrackName().length() <= 23){
songtitle.setTextSize(25);
}
else if(MusicPlayer.getTrackName().length() >= 30){
songtitle.setTextSize(18);
}
else{
songtitle.setTextSize(18 + (MusicPlayer.getTrackName().length() - 24));
}
Log.v("BaseNowPlayingFrag", "Title Text Size: " + songtitle.getTextSize());

/*new Runnable() {
@Override
public void run() {
songtitle.setSelected(true);
}
};*/
}
if (songartist != null) {
songartist.setText(MusicPlayer.getArtistName());
songartist.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NavigationUtils.goToArtist(getContext(), MusicPlayer.getCurrentArtistId());
}
});
}
if (songalbum != null)
songalbum.setText(MusicPlayer.getAlbumName());

}
duetoplaypause = false;
@@ -559,18 +589,9 @@ public void onLoadingFailed(String imageUri, View view, FailReason failReason) {



if (songalbum != null)
songalbum.setText(MusicPlayer.getAlbumName());

/* if (songartist != null) {
songartist.setText(MusicPlayer.getArtistName());
songartist.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NavigationUtils.goToArtist(getContext(), MusicPlayer.getCurrentArtistId());
}
});
}*/



if (songduration != null && getActivity() != null)
songduration.setText(TimberUtils.makeShortTimeString(getActivity(), MusicPlayer.duration() / 1000));
8 changes: 6 additions & 2 deletions app/src/main/res/layout/fragment_timber3.xml
Original file line number Diff line number Diff line change
@@ -65,23 +65,27 @@
<TextView
android:id="@+id/song_title"
style="@style/TextAppearance.AppCompat.Body1"
android:layout_width="wrap_content"
android:layout_width="243dp"
android:layout_height="wrap_content"
android:layout_marginRight="130dp"
android:width="800dp"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textSize="25sp" />
android:text="It Aint Hard To Tell I Excel and Pre"
android:textSize="16sp" />

<TextView
android:id="@+id/song_artist"
style="@style/TextAppearance.AppCompat.Body1"
android:layout_width="wrap_content"
android:width="800dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="Song Artist"
android:paddingTop="3dp"

android:textSize="14sp" />

0 comments on commit 504e254

Please sign in to comment.