Commit Graph

4352 Commits

Author SHA1 Message Date
Tobias Groza 31c4ed7d0e
Update app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java
Co-Authored-By: Redirion <redirion@web.de>
2019-03-05 20:57:05 +01:00
Redirion 111ad14ad3
Merge branch 'dev' into patch-1 2019-03-05 17:57:52 +01:00
Tobias Groza aec3f19d23
Merge pull request #2179 from Redirion/patch-2
Improve performance of getTimeString
2019-03-04 19:16:43 +01:00
Redirion d8b80f961a
Improved performance of getTimeString
This pull requests complements pull request  #2178 by reducing general computational time for the method getTimeString.

On my local machine (Desktop PC with Java) my tests with a sample size of 10000 calls to the method with param 86400001 showed a performance improvement of about 50%.

See sample code below to reproduce:

    private static final StringBuilder stringBuilder = new StringBuilder();
    private static final Formatter stringFormatter = new Formatter(stringBuilder, Locale.getDefault());
    
    public static String getTimeString(int milliSeconds) {
        int seconds = (milliSeconds % 60000) / 1000;
        int minutes = (milliSeconds % 3600000) / 60000;
        int hours = (milliSeconds % 86400000) / 3600000;
        int days = (milliSeconds % (86400000 * 7)) / 86400000;

        stringBuilder.setLength(0);
        return days > 0 ? stringFormatter.format("%d:%02d:%02d:%02d", days, hours, minutes, seconds).toString()
                : hours > 0 ? stringFormatter.format("%d:%02d:%02d", hours, minutes, seconds).toString()
                : stringFormatter.format("%02d:%02d", minutes, seconds).toString();
    }
    
    public static String getTimeStringL(int milliSeconds) {
        long seconds = (milliSeconds % 60000L) / 1000L;
        long minutes = (milliSeconds % 3600000L) / 60000L;
        long hours = (milliSeconds % 86400000L) / 3600000L;
        long days = (milliSeconds % (86400000L * 7L)) / 86400000L;

        stringBuilder.setLength(0);
        return days > 0 ? stringFormatter.format("%d:%02d:%02d:%02d", days, hours, minutes, seconds).toString()
                : hours > 0 ? stringFormatter.format("%d:%02d:%02d", hours, minutes, seconds).toString()
                : stringFormatter.format("%02d:%02d", minutes, seconds).toString();
    }
    
	public static void main(String[] args) throws Exception {
		final int SAMPLE_SIZE = 25000;
		long[] results = new long[SAMPLE_SIZE];
		for(int i = 0; i < SAMPLE_SIZE; i++) {
			long now = System.nanoTime();
			getTimeString(86400001);
			results[i] = System.nanoTime() - now;
		}
		long sum = 0;
		for(int i = 0; i < SAMPLE_SIZE; i++) {
			sum += results[i];
		}
		System.out.println("Average execution time: " + (sum/SAMPLE_SIZE));
		results = new long[SAMPLE_SIZE];
		for(int i = 0; i < SAMPLE_SIZE; i++) {
			long now = System.nanoTime();
			getTimeStringL(86400001);
			results[i] = System.nanoTime() - now;
		}
		sum = 0;
		for(int i = 0; i < SAMPLE_SIZE; i++) {
			sum += results[i];
		}
		System.out.println("Average execution time: " + (sum/SAMPLE_SIZE));
2019-03-04 15:45:59 +01:00
Redirion 6aebbc3109
Cache duration String to improve performance
In VideoPlayer the Duration String is cached effectively by setting it to the playbackSeekBar. As the playbackSeekBar doesn't exist in BackgroundPlayer, using two addition variables will reduce performance impact of notification updates by almost 50% and thus perform similar to VideoPlayer.

This addresses issue #2170
2019-03-04 10:24:08 +01:00
Christian Schabesberger 15eb7f3186
Merge pull request #2023 from dotvirus/enqueue-playlist
Add playlist to queue when long clicking on 'Background'
2019-03-03 20:59:15 +01:00
Christian Schabesberger fb4cd98014
Merge branch 'dev' into enqueue-playlist 2019-03-03 20:53:17 +01:00
Christian Schabesberger eb692dea59
Merge pull request #2168 from yausername/commentSizeAndLinks
make links in comments clickable, increase text size
2019-03-03 20:52:11 +01:00
Christian Schabesberger d8039fb542
Merge branch 'dev' into enqueue-playlist 2019-03-03 20:50:00 +01:00
Christian Schabesberger 5e06d19d77
Merge branch 'dev' into commentSizeAndLinks 2019-03-03 20:46:03 +01:00
Christian Schabesberger 963f390336
Merge pull request #2176 from yausername/fixScrollOnBlank
fixed scroll w/ comments and related streams disabled
2019-03-03 20:41:07 +01:00
Ritvik Saraf 2309e15261 fixed scroll w/ comments and related streams disabled 2019-03-03 18:20:15 +05:30
Ritvik Saraf 8491035b2f updated extractor 2019-03-03 04:34:50 +05:30
Ritvik Saraf 4d4107aefc Merge remote-tracking branch 'upstream/dev' into commentSizeAndLinks 2019-03-03 04:32:19 +05:30
Ritvik Saraf 67d2b9131e handling timestamp links in comments 2019-03-02 05:12:06 +05:30
Christian Schabesberger da8644168c Merge branch 'master' into dev 2019-03-01 09:53:43 +01:00
Ritvik Saraf c0004e988a make links in comments clickable, increase text size 2019-03-01 13:28:32 +05:30
Christian Schabesberger 554ebf7ab9
Merge pull request #2161 from Redirion/patch-1
Fixed CheckForNewAppVersionTask being executed when it shouldn't
2019-02-27 22:14:53 +01:00
Redirion 3e54cd7284
Update CheckForNewAppVersionTask.java 2019-02-26 19:33:01 +01:00
Redirion a7afc23a9a
Fixed Asynctask being executed when it shouldn't
#1 check if cancel was called in onPrepare
#2 if we currently don't have a Connection, don't show crash report dialogue to user
2019-02-26 19:23:54 +01:00
Christian Schabesberger f24fab0fa2 fix brake when selecting a mediaccc channel form subscription page 2019-02-25 12:24:48 +01:00
Christian Schabesberger 261620fd13
Merge branch 'master' into release_v0.16.0 2019-02-24 23:06:06 +01:00
Christian Schabesberger 9af6effad9 move on to version 0.16.0 2019-02-24 22:52:07 +01:00
Christian Schabesberger 92602916dd merge weblate 2019-02-24 22:51:08 +01:00
Christian Schabesberger f4d215664e
Merge pull request #2117 from nv95/patch1_ui
Small ux improve
2019-02-24 22:34:12 +01:00
Christian Schabesberger 84894a557a
Merge branch 'dev' into patch1_ui 2019-02-24 22:27:06 +01:00
Christian Schabesberger ffad6e4c61
Merge pull request #2148 from yausername/commentsAndRelatedUx
added top padding for comments and related videos
2019-02-24 22:26:46 +01:00
Christian Schabesberger 93b266e6be
Merge branch 'dev' into commentsAndRelatedUx 2019-02-24 22:19:47 +01:00
Christian Schabesberger f92ea28581
Merge pull request #2151 from nv95/fix_leak
Fix AudioManager memory leak
2019-02-24 22:19:27 +01:00
Christian Schabesberger 85213e4b6c
Merge branch 'dev' into patch1_ui 2019-02-24 22:18:06 +01:00
Christian Schabesberger 4e46119e18
Merge branch 'dev' into commentsAndRelatedUx 2019-02-24 22:17:24 +01:00
Christian Schabesberger fdc6e9f1c3
Merge branch 'dev' into fix_leak 2019-02-24 22:12:46 +01:00
Christian Schabesberger cb20f1e212
Merge pull request #2153 from TeamNewPipe/fix_url
fix invalid channel url for commends
2019-02-24 22:10:40 +01:00
Christian Schabesberger e3fccd7125 fix invalid channel url for commends 2019-02-24 22:10:16 +01:00
Vasiliy 15142c1ec3
Fix AudioManager memory leak 2019-02-24 10:51:30 +02:00
Nathan Follens 6c7b90e1c3
Translated using Weblate (Flemish)
Currently translated at 100.0% (443 of 443 strings)
2019-02-24 06:18:27 +01:00
Nathan Follens d8e57144f7
Translated using Weblate (Dutch)
Currently translated at 100.0% (443 of 443 strings)
2019-02-24 06:18:27 +01:00
Ritvik Saraf 49fe8a427a added top padding for comments and related videos 2019-02-24 02:21:11 +05:30
Vasiliy 5318e77035
Merge branch 'dev' into patch1_ui 2019-02-23 13:18:14 +02:00
Christian Schabesberger e69c45a246
Merge pull request #1650 from yausername/dev
comments support
2019-02-21 15:50:21 +01:00
Ritvik Saraf 3f87a6d714 Merge remote-tracking branch 'origin/dev' into dev 2019-02-20 05:29:34 +05:30
Ritvik Saraf 841124b1f3 updated extractor, fixed settings padding 2019-02-20 05:24:33 +05:30
Hosted Weblate 257a878ef4
Merge branch 'origin/dev' into Weblate. 2019-02-19 19:18:29 +01:00
84436 07d3f82912
Translated using Weblate (Vietnamese)
Currently translated at 99.3% (440 of 443 strings)
2019-02-19 19:18:26 +01:00
Ali Demirtas 7d3eb4f5a6
Translated using Weblate (Turkish)
Currently translated at 100.0% (443 of 443 strings)
2019-02-19 19:18:12 +01:00
srkrishna 0efcc55373
Translated using Weblate (Tamil)
Currently translated at 34.5% (153 of 443 strings)
2019-02-19 19:18:12 +01:00
Christian Schabesberger eafceb8a6c
Merge branch 'dev' into dev 2019-02-19 17:35:49 +01:00
Christian Schabesberger 5ac8318e71
Merge pull request #2136 from TeamNewPipe/db_doc
add database doc in dia
2019-02-19 16:06:11 +01:00
Christian Schabesberger 7981f9dc91 add database doc in dia 2019-02-19 16:03:10 +01:00
Christian Schabesberger a9bf04cbc6
Merge pull request #2135 from TeamNewPipe/firetv
add support for search in amazon firetv
2019-02-19 15:00:22 +01:00