removed unused code

This commit is contained in:
Mariotaku Lee 2017-09-22 15:00:12 +08:00
parent 557d2842d5
commit d28b99149b
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
6 changed files with 29 additions and 60 deletions

View File

@ -127,9 +127,11 @@ android {
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/maven/**'
exclude 'META-INF/*.kotlin_module'
exclude 'kotlin/*.kotlin_builtins'
exclude 'kotlin/**.kotlin_builtins'
exclude 'org/osmdroid/**.png'
exclude 'javax/annotation/**.java'
exclude 'generated-sources/**'
exclude 'jsr305_annotations/**'
exclude 'sdk-version.txt'
exclude 'build-data.properties'
}
@ -155,7 +157,6 @@ dependencies {
// START Non-FOSS component
googleImplementation "com.google.android.gms:play-services-maps:${libVersions['PlayServices']}"
googleImplementation "com.google.android.gms:play-services-auth:${libVersions['PlayServices']}"
googleImplementation "com.google.android.gms:play-services-ads:${libVersions['PlayServices']}"
googleImplementation "com.google.maps.android:android-maps-utils:${libVersions['MapsUtils']}"
googleImplementation "com.anjlab.android.iab.v3:library:${libVersions['IABv3']}"
googleImplementation "com.dropbox.core:dropbox-core-sdk:${libVersions['DropboxCoreSdk']}"

View File

@ -27,6 +27,8 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import kotlin.ranges.RangesKt;
/**
* Created by mariotaku on 15/1/8.
*/
@ -94,9 +96,9 @@ public class TwidereColorUtils {
public static int YIQToColor(int alpha, int[] yiq) {
final int r = TwidereMathUtils.clamp((yiq[0] * 1000 + yiq[1] * 956 + yiq[2] * 620) / 1000, 0, 255);
final int g = TwidereMathUtils.clamp((yiq[0] * 1000 - yiq[1] * 272 - yiq[2] * 647) / 1000, 0, 255);
final int b = TwidereMathUtils.clamp((yiq[0] * 1000 - yiq[1] * 1108 + yiq[2] * 1705) / 1000, 0, 255);
final int r = RangesKt.coerceIn((yiq[0] * 1000 + yiq[1] * 956 + yiq[2] * 620) / 1000, 0, 255);
final int g = RangesKt.coerceIn((yiq[0] * 1000 - yiq[1] * 272 - yiq[2] * 647) / 1000, 0, 255);
final int b = RangesKt.coerceIn((yiq[0] * 1000 - yiq[1] * 1108 + yiq[2] * 1705) / 1000, 0, 255);
return Color.argb(alpha, r, g, b);
}

View File

@ -1,47 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program 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 program 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.util;
public class TwidereMathUtils {
private TwidereMathUtils() {
}
public static int clamp(final int num, final int bound1, final int bound2) {
final int max = Math.max(bound1, bound2), min = Math.min(bound1, bound2);
return Math.max(Math.min(num, max), min);
}
// Returns the next power of two.
// Returns the input if it is already power of 2.
// Throws IllegalArgumentException if the input is <= 0 or
// the answer overflows.
public static int nextPowerOf2(int n) {
if (n <= 0 || n > 1 << 30) throw new IllegalArgumentException("n is invalid: " + n);
n -= 1;
n |= n >> 16;
n |= n >> 8;
n |= n >> 4;
n |= n >> 2;
n |= n >> 1;
return n + 1;
}
}

View File

@ -36,7 +36,8 @@ import android.view.ViewGroup;
import android.widget.OverScroller;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.util.TwidereMathUtils;
import kotlin.ranges.RangesKt;
/**
* Custom ViewGroup for user profile page like Google+ but with tab swipe
@ -284,7 +285,7 @@ public class HeaderDrawerLayout extends ViewGroup {
private void offsetHeaderBy(int dy) {
final int prevTop = mContainer.getTop();
final int clampedDy = TwidereMathUtils.clamp(prevTop + dy, getHeaderTopMinimum(), getHeaderTopMaximum()) - prevTop;
final int clampedDy = RangesKt.coerceIn(prevTop + dy, getHeaderTopMinimum(), getHeaderTopMaximum()) - prevTop;
mContainer.offsetTopAndBottom(clampedDy);
}
@ -421,7 +422,7 @@ public class HeaderDrawerLayout extends ViewGroup {
mDrawer.scrollByCallback(-dy);
}
mScrollingHeaderByHelper = true;
return TwidereMathUtils.clamp(top, min, max);
return RangesKt.coerceIn(top, min, max);
}
private boolean isScrollingHeaderByHelper() {

View File

@ -43,4 +43,17 @@ operator fun Long.contains(i: Long): Boolean = (this and i) == i
fun Number.toLocalizedString(locale: Locale = Locale.getDefault()): String {
val nf = NumberFormat.getInstance(locale)
return nf.format(this)
}
}
val Int.nextPowerOf2: Int
get() {
var n = this
if (n <= 0 || n > 1 shl 30) throw IllegalArgumentException("n is invalid: " + n)
n -= 1
n = n or (n shr 16)
n = n or (n shr 8)
n = n or (n shr 4)
n = n or (n shr 2)
n = n or (n shr 1)
return n + 1
}

View File

@ -28,13 +28,13 @@ import android.os.Bundle
import com.davemorrissey.labs.subscaleview.ImageSource
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
import com.davemorrissey.labs.subscaleview.decoder.SkiaImageDecoder
import org.mariotaku.ktextension.nextPowerOf2
import org.mariotaku.mediaviewer.library.CacheDownloadLoader
import org.mariotaku.mediaviewer.library.subsampleimageview.SubsampleImageViewerFragment
import org.mariotaku.twidere.TwidereConstants.*
import org.mariotaku.twidere.activity.MediaViewerActivity
import org.mariotaku.twidere.model.ParcelableMedia
import org.mariotaku.twidere.model.UserKey
import org.mariotaku.twidere.util.TwidereMathUtils
import org.mariotaku.twidere.util.UriUtils
import org.mariotaku.twidere.util.media.MediaExtra
import java.io.IOException
@ -156,10 +156,9 @@ class ImagePageFragment : SubsampleImageViewerFragment() {
val dm = context.resources.displayMetrics
val targetSize = Math.min(1024, Math.max(dm.widthPixels, dm.heightPixels))
val sizeRatio = Math.ceil(Math.max(o.outHeight, o.outWidth) / targetSize.toDouble())
o.inSampleSize = TwidereMathUtils.nextPowerOf2(Math.max(1.0, sizeRatio).toInt())
o.inSampleSize = Math.max(1.0, sizeRatio).toInt().nextPowerOf2
o.inJustDecodeBounds = false
val bitmap = decodeBitmap(cr, uri, o) ?: throw IOException()
return bitmap
return decodeBitmap(cr, uri, o) ?: throw IOException()
}
return super.decode(context, uri)
}