Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ebb83f61 authored by Alexander Martinz's avatar Alexander Martinz Committed by Michael Bestas
Browse files

Correct some lint warnings



Correcting lint issues such as:
 - if -> switch
 - unnecessary (un)boxing
 - for / while -> foreach where appropriate
 - remove unused imports
 - remove obsolete SDK_INT checks

Change-Id: Icb7170b0564b9c1cf191a0a102d1babab61e2ec2
Signed-off-by: Alexander Martinz's avatarAlexander Martinz <amartinz@shiftphones.com>
parent 5b70dfcd
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 Andrew Neal
     Copyright (C) 2014 The CyanogenMod Project
     Copyright (C) 2019 The LineageOS Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
@@ -15,9 +16,11 @@
     limitations under the License.
 -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="org.lineageos.eleven"
    android:versionCode="3"
    android:versionName="3.0">
    android:versionName="3.0"
    tools:ignore="GradleOverrides">

    <uses-sdk
        android:minSdkVersion="26"
@@ -87,7 +90,7 @@
                <category android:name="android.intent.category.APP_MUSIC" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
            <intent-filter tools:ignore="AppLinkUrlError">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
+0 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res/org.lineageos.eleven"
    android:id="@+id/bottom_action_bar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/bottom_action_bar_height"
+1 −1
Original line number Diff line number Diff line
@@ -205,7 +205,7 @@
    partial scaled up values for different resolutions -->
    <dimen name="divider_height">1px</dimen>

    <item name="letter_to_tile_ratio" type="dimen">53%</item>
    <item name="letter_to_tile_ratio" type="fraction">53%</item>

    <!-- Audio preview -->
    <dimen name="preview_layout_height">125dp</dimen>
+39 −43
Original line number Diff line number Diff line
@@ -496,7 +496,7 @@ public class MusicPlaybackService extends Service {

    private String mLyrics;

    private ArrayList<MusicPlaybackTrack> mPlaylist = new ArrayList<MusicPlaybackTrack>(100);
    private ArrayList<MusicPlaybackTrack> mPlaylist = new ArrayList<>(100);

    private long[] mAutoShuffleList = null;

@@ -914,7 +914,7 @@ public class MusicPlaybackService extends Service {
        // Make sure we don't indefinitely hold the wake lock under any circumstances
        mHeadsetHookWakeLock.acquire(10000);

        Message msg = mPlayerHandler.obtainMessage(HEADSET_HOOK_EVENT, Long.valueOf(timestamp));
        Message msg = mPlayerHandler.obtainMessage(HEADSET_HOOK_EVENT, timestamp);
        msg.sendToTarget();
    }

@@ -1153,7 +1153,7 @@ public class MusicPlaybackService extends Service {
            position = mPlaylist.size();
        }

        final ArrayList<MusicPlaybackTrack> arrayList = new ArrayList<MusicPlaybackTrack>(addlen);
        final ArrayList<MusicPlaybackTrack> arrayList = new ArrayList<>(addlen);
        for (int i = 0; i < list.length; i++) {
            arrayList.add(new MusicPlaybackTrack(list[i], sourceId, sourceType, i));
        }
@@ -1330,7 +1330,7 @@ public class MusicPlaybackService extends Service {
            // has been played
            final int numHistory = mHistory.size();
            for (int i = 0; i < numHistory; i++) {
                final int idx = mHistory.get(i).intValue();
                final int idx = mHistory.get(i);
                if (idx >= 0 && idx < numTracks) {
                    trackNumPlays[idx]++;
                }
@@ -1345,12 +1345,12 @@ public class MusicPlaybackService extends Service {
            // how many tracks share that count
            int minNumPlays = Integer.MAX_VALUE;
            int numTracksWithMinNumPlays = 0;
            for (int i = 0; i < trackNumPlays.length; i++) {
            for (final int trackNumPlay : trackNumPlays) {
                // if we found a new track that has less number of plays, reset the counters
                if (trackNumPlays[i] < minNumPlays) {
                    minNumPlays = trackNumPlays[i];
                if (trackNumPlay < minNumPlays) {
                    minNumPlays = trackNumPlay;
                    numTracksWithMinNumPlays = 1;
                } else if (trackNumPlays[i] == minNumPlays) {
                } else if (trackNumPlay == minNumPlays) {
                    // increment this track shares the # of tracks
                    numTracksWithMinNumPlays++;
                }
@@ -1530,12 +1530,14 @@ public class MusicPlaybackService extends Service {
        musicIntent.setAction(what.replace(ELEVEN_PACKAGE_NAME, MUSIC_PACKAGE_NAME));
        sendStickyBroadcast(musicIntent);

        if (what.equals(META_CHANGED)) {
        switch (what) {
            case META_CHANGED:
                // Add the track to the recently played list.
                mRecentsCache.addSongId(getAudioId());

                mSongPlayCountCache.bumpSongCount(getAudioId());
        } else if (what.equals(QUEUE_CHANGED)) {
                break;
            case QUEUE_CHANGED:
                saveQueue(true);
                if (isPlaying()) {
                    // if we are in shuffle mode and our next track is still valid,
@@ -1548,8 +1550,10 @@ public class MusicPlaybackService extends Service {
                        setNextTrack();
                    }
                }
        } else {
                break;
            default:
                saveQueue(false);
                break;
        }

        if (what.equals(PLAYSTATE_CHANGED)) {
@@ -1928,20 +1932,13 @@ public class MusicPlaybackService extends Service {
     */
    private String getValueForDownloadedFile(Context context, Uri uri, String column) {

        Cursor cursor = null;
        final String[] projection = {
                column
        };

        try {
            cursor = context.getContentResolver().query(uri, projection, null, null, null);
        try (Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null)) {
            if (cursor != null && cursor.moveToFirst()) {
                return cursor.getString(0);
            }
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
        return null;
    }
@@ -2652,7 +2649,7 @@ public class MusicPlaybackService extends Service {
                if (removeFromHistory) {
                    mHistory.remove(histsize - 1);
                }
                return pos.intValue();
                return pos;
            } else {
                if (mPlayPos > 0) {
                    return mPlayPos - 1;
@@ -3009,7 +3006,7 @@ public class MusicPlaybackService extends Service {
         */
        public MusicPlayerHandler(final MusicPlaybackService service, final Looper looper) {
            super(looper);
            mService = new WeakReference<MusicPlaybackService>(service);
            mService = new WeakReference<>(service);
        }

        /**
@@ -3141,9 +3138,9 @@ public class MusicPlaybackService extends Service {

    private static final class Shuffler {

        private final LinkedList<Integer> mHistoryOfNumbers = new LinkedList<Integer>();
        private final LinkedList<Integer> mHistoryOfNumbers = new LinkedList<>();

        private final TreeSet<Integer> mPreviousNumbers = new TreeSet<Integer>();
        private final TreeSet<Integer> mPreviousNumbers = new TreeSet<>();

        private final Random mRandom = new Random();

@@ -3164,8 +3161,7 @@ public class MusicPlaybackService extends Service {
            int next;
            do {
                next = mRandom.nextInt(interval);
            } while (next == mPrevious && interval > 1
                    && !mPreviousNumbers.contains(Integer.valueOf(next)));
            } while (next == mPrevious && interval > 1 && !mPreviousNumbers.contains(next));
            mPrevious = next;
            mHistoryOfNumbers.add(mPrevious);
            mPreviousNumbers.add(mPrevious);
@@ -3217,7 +3213,7 @@ public class MusicPlaybackService extends Service {
         * Constructor of <code>MultiPlayer</code>
         */
        public MultiPlayer(final MusicPlaybackService service) {
            mService = new WeakReference<MusicPlaybackService>(service);
            mService = new WeakReference<>(service);
            mSrtManager = new SrtManager() {
                @Override
                public void onTimedText(String text) {
@@ -3499,7 +3495,7 @@ public class MusicPlaybackService extends Service {
        private final WeakReference<MusicPlaybackService> mService;

        private ServiceStub(final MusicPlaybackService service) {
            mService = new WeakReference<MusicPlaybackService>(service);
            mService = new WeakReference<>(service);
        }

        /**
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ public class AlbumArtPagerAdapter extends FragmentStatePagerAdapter {
    private static final int MAX_ALBUM_ARTIST_SIZE = 10;

    // This helps with flickering and jumping and reloading the same tracks
    private final static LinkedList<AlbumArtistDetails> sCacheAlbumArtistDetails = new LinkedList<AlbumArtistDetails>();
    private final static LinkedList<AlbumArtistDetails> sCacheAlbumArtistDetails = new LinkedList<>();

    /**
     * Adds the album artist details to the cache
Loading