removed apache commons dependencies
This commit is contained in:
parent
64bd85ae6c
commit
f13f8e46be
|
@ -218,7 +218,6 @@ dependencies {
|
|||
implementation "pl.droidsonroids.gif:android-gif-drawable:${libVersions['AndroidGIFDrawable']}"
|
||||
implementation 'com.sprylab.android.texturevideoview:texturevideoview:1.2.1'
|
||||
implementation 'com.squareup:pollexor:2.0.4'
|
||||
implementation 'commons-primitives:commons-primitives:1.0'
|
||||
implementation "org.apache.james:apache-mime4j-core:${libVersions['Mime4J']}"
|
||||
implementation "org.apache.james:apache-mime4j-storage:${libVersions['Mime4J']}"
|
||||
implementation "com.bluelinelabs:logansquare:${libVersions['LoganSquare']}"
|
||||
|
|
|
@ -1,291 +0,0 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Created on Nov 21, 2005
|
||||
*/
|
||||
package jopt.csp.util;
|
||||
|
||||
import org.apache.commons.collections.primitives.ArrayIntList;
|
||||
import org.apache.commons.collections.primitives.IntCollection;
|
||||
import org.apache.commons.collections.primitives.IntList;
|
||||
import org.apache.commons.collections.primitives.RandomAccessIntList;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
/**
|
||||
* A flexible, sortable list of int primitives. Borrows much
|
||||
* of its functionality from the ArrayIntList implementation
|
||||
* given in the Commons Primitives project
|
||||
* (http://jakarta.apache.org/commons/primitives/index.html)
|
||||
*
|
||||
* @author Chris Johnson
|
||||
*/
|
||||
public class SortableIntList extends RandomAccessIntList implements IntList, Serializable {
|
||||
|
||||
private transient int[] data = null;
|
||||
private int size = 0;
|
||||
|
||||
/**
|
||||
* Construct an empty list with the default
|
||||
* initial capacity.
|
||||
*/
|
||||
public SortableIntList() {
|
||||
this(8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an empty list with the given
|
||||
* initial capacity.
|
||||
*
|
||||
* @throws IllegalArgumentException when <i>initialCapacity</i> is negative
|
||||
*/
|
||||
public SortableIntList(int initialCapacity) {
|
||||
if (initialCapacity < 0) {
|
||||
throw new IllegalArgumentException("capacity " + initialCapacity + " cannot be negative");
|
||||
}
|
||||
data = new int[initialCapacity];
|
||||
size = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a list containing the elements of the given collection,
|
||||
* in the order they are returned by that collection's iterator.
|
||||
*
|
||||
* @param that the non-<code>null</code> collection of <code>int</code>s
|
||||
* to add
|
||||
* @throws NullPointerException if <i>that</i> is <code>null</code>
|
||||
* @see ArrayIntList#addAll(org.apache.commons.collections.primitives.IntCollection)
|
||||
*/
|
||||
public SortableIntList(IntCollection that) {
|
||||
this(that.size());
|
||||
addAll(that);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int get(int index) {
|
||||
checkRange(index);
|
||||
return data[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the element at the specified position in
|
||||
* (optional operation). Any subsequent elements
|
||||
* are shifted to the left, subtracting one from their
|
||||
* indices. Returns the element that was removed.
|
||||
*
|
||||
* @param index the index of the element to remove
|
||||
* @return the value of the element that was removed
|
||||
* @throws UnsupportedOperationException when this operation is not
|
||||
* supported
|
||||
* @throws IndexOutOfBoundsException if the specified index is out of range
|
||||
*/
|
||||
@Override
|
||||
public int removeElementAt(int index) {
|
||||
checkRange(index);
|
||||
incrModCount();
|
||||
int oldval = data[index];
|
||||
int numtomove = size - index - 1;
|
||||
if (numtomove > 0) {
|
||||
System.arraycopy(data, index + 1, data, index, numtomove);
|
||||
}
|
||||
size--;
|
||||
return oldval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the element at the specified
|
||||
* position in me with the specified element
|
||||
* (optional operation). If specified index is
|
||||
* beyond the current size, the list grows
|
||||
* to accommodate it. No IndexOutOfBoundsException
|
||||
* will occur during the set operation.
|
||||
*
|
||||
* @param index the index of the element to change
|
||||
* @param element the value to be stored at the specified position
|
||||
* @return the value previously stored at the specified position
|
||||
* @throws UnsupportedOperationException when this operation is not
|
||||
* supported
|
||||
*/
|
||||
@Override
|
||||
public int set(int index, int element) {
|
||||
ensureCapacity(index + 1);
|
||||
ensureSize(index + 1);
|
||||
incrModCount();
|
||||
int oldval = data[index];
|
||||
data[index] = element;
|
||||
return oldval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts the specified element at the specified position
|
||||
* (optional operation). Shifts the element currently
|
||||
* at that position (if any) and any subsequent elements to the
|
||||
* right, increasing their indices. If the specified index is
|
||||
* beyond the current size, this method behaves like a call
|
||||
* to {@link #set(int, int)}.
|
||||
*
|
||||
* @param index the index at which to insert the element
|
||||
* @param element the value to insert
|
||||
* @throws UnsupportedOperationException when this operation is not
|
||||
* supported
|
||||
* @throws IllegalArgumentException if some aspect of the specified element
|
||||
* prevents it from being added to me
|
||||
*/
|
||||
@Override
|
||||
public void add(int index, int element) {
|
||||
if (index >= size) {
|
||||
set(index, element);
|
||||
} else {
|
||||
incrModCount();
|
||||
ensureCapacity(size + 1);
|
||||
int numtomove = size - index;
|
||||
System.arraycopy(data, index, data, index + 1, numtomove);
|
||||
data[index] = element;
|
||||
size++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases my capacity, if necessary, to ensure that I can hold at
|
||||
* least the number of elements specified by the minimum capacity
|
||||
* argument without growing.
|
||||
*/
|
||||
public void ensureCapacity(int mincap) {
|
||||
incrModCount();
|
||||
if (mincap > data.length) {
|
||||
int newcap = (data.length * 3) / 2 + 1;
|
||||
int[] olddata = data;
|
||||
data = new int[newcap < mincap ? mincap : newcap];
|
||||
System.arraycopy(olddata, 0, data, 0, size);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce my capacity, if necessary, to match my
|
||||
* current {@link #size size}.
|
||||
*/
|
||||
public void trimToSize() {
|
||||
incrModCount();
|
||||
if (size < data.length) {
|
||||
int[] olddata = data;
|
||||
data = new int[size];
|
||||
System.arraycopy(olddata, 0, data, 0, size);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the list into ascending numerical order via {@link java.util.Arrays#sort(int[])}
|
||||
* <p/>
|
||||
* Sorts the list of ints into ascending numerical order. The sorting algorithm
|
||||
* is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering
|
||||
* a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November
|
||||
* 1993). This algorithm offers n*log(n) performance on many data sets that cause other
|
||||
* quicksorts to degrade to quadratic performance.
|
||||
*/
|
||||
public void sort() {
|
||||
trimToSize();
|
||||
Arrays.sort(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverses the order of the elements
|
||||
*/
|
||||
public void reverse() {
|
||||
for (int i = 0, mid = size >> 1, j = size - 1; i < mid; i++, j--)
|
||||
swap(i, j);
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps the two specified elements.
|
||||
* (If the specified positions are equal, invoking this method leaves
|
||||
* the list unchanged.)
|
||||
*/
|
||||
public void swap(int i, int j) {
|
||||
int tmp = data[i];
|
||||
data[i] = data[j];
|
||||
data[j] = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the list for the specified key via {@link java.util.Arrays#binarySearch(int[], int)}
|
||||
* <p/>
|
||||
* The array must be sorted (as by the sort method, above) prior to making this call.
|
||||
* If it is not sorted, the results are undefined. If the list contains multiple elements
|
||||
* with the specified value, there is no guarantee which one will be found.
|
||||
*
|
||||
* @param key the value to be searched for
|
||||
* @return index of the search key, if it is contained in the list; otherwise, (-(insertion point) - 1)
|
||||
*/
|
||||
public int binarySearch(int key) {
|
||||
trimToSize();
|
||||
return Arrays.binarySearch(data, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the specified range of the list into ascending numerical order
|
||||
* via {@link java.util.Arrays#sort(int[], int, int)}
|
||||
*
|
||||
* @param fromIndex the index of the first element (inclusive) to be sorted
|
||||
* @param toIndex the index of the last element (exclusive) to be sorted
|
||||
*/
|
||||
public void sort(int fromIndex, int toIndex) {
|
||||
trimToSize();
|
||||
Arrays.sort(data, fromIndex, toIndex);
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream out) throws IOException {
|
||||
out.defaultWriteObject();
|
||||
out.writeInt(data.length);
|
||||
for (int i = 0; i < size; i++) {
|
||||
out.writeInt(data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
data = new int[in.readInt()];
|
||||
for (int i = 0; i < size; i++) {
|
||||
data[i] = in.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureSize(int potentialSize) {
|
||||
if (potentialSize > size) {
|
||||
size = potentialSize;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkRange(int index) {
|
||||
if (index < 0 || index >= size) {
|
||||
throw new IndexOutOfBoundsException("Should be at least 0 and less than " + size + ", found " + index);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -43,7 +43,6 @@ import android.view.inputmethod.InputMethodManager
|
|||
import android.widget.*
|
||||
import android.widget.AdapterView.OnItemClickListener
|
||||
import android.widget.AdapterView.OnItemSelectedListener
|
||||
import jopt.csp.util.SortableIntList
|
||||
import kotlinx.android.synthetic.main.activity_quick_search_bar.*
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.ktextension.empty
|
||||
|
@ -369,7 +368,7 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
|
|||
private val requestManager = activity.requestManager
|
||||
private val inflater = LayoutInflater.from(activity)
|
||||
private val userColorNameManager = activity.userColorNameManager
|
||||
private val removedPositions = SortableIntList()
|
||||
private val removedPositions = ArrayList<Int>()
|
||||
|
||||
private var indices: SuggestionItem.Indices? = null
|
||||
|
||||
|
@ -483,7 +482,7 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
|
|||
}
|
||||
|
||||
override fun getCount(): Int {
|
||||
return super.getCount() - removedPositions.size()
|
||||
return super.getCount() - removedPositions.size
|
||||
}
|
||||
|
||||
override fun getItem(position: Int): Any? {
|
||||
|
@ -504,7 +503,7 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
|
|||
|
||||
private fun getActualPosition(position: Int): Int {
|
||||
var skipped = 0
|
||||
for (i in 0 until removedPositions.size()) {
|
||||
for (i in 0 until removedPositions.size) {
|
||||
if (position + skipped >= removedPositions.get(i)) {
|
||||
skipped++
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.mariotaku.twidere.task
|
|||
|
||||
import android.content.Context
|
||||
import android.widget.Toast
|
||||
import org.apache.commons.collections.primitives.ArrayIntList
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
|
@ -76,7 +75,7 @@ class CreateFavoriteTask(context: Context, accountKey: UserKey, private val stat
|
|||
}
|
||||
|
||||
override fun afterExecute(callback: Any?, result: ParcelableStatus?, exception: MicroBlogException?) {
|
||||
creatingFavoriteIds.removeElement(calculateHashCode(accountKey, statusId))
|
||||
creatingFavoriteIds.remove(calculateHashCode(accountKey, statusId))
|
||||
val taskEvent = FavoriteTaskEvent(FavoriteTaskEvent.Action.CREATE, accountKey, statusId)
|
||||
taskEvent.isFinished = true
|
||||
if (result != null) {
|
||||
|
@ -123,7 +122,7 @@ class CreateFavoriteTask(context: Context, accountKey: UserKey, private val stat
|
|||
|
||||
companion object {
|
||||
|
||||
private val creatingFavoriteIds = ArrayIntList()
|
||||
private val creatingFavoriteIds = ArrayList<Int>()
|
||||
|
||||
fun isCreatingFavorite(accountKey: UserKey?, statusId: String?): Boolean {
|
||||
return creatingFavoriteIds.contains(calculateHashCode(accountKey, statusId))
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.mariotaku.twidere.task
|
|||
|
||||
import android.content.Context
|
||||
import android.widget.Toast
|
||||
import org.apache.commons.collections.primitives.ArrayIntList
|
||||
import org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
import org.mariotaku.microblog.library.mastodon.Mastodon
|
||||
|
@ -69,7 +68,7 @@ class DestroyFavoriteTask(
|
|||
}
|
||||
|
||||
override fun afterExecute(callback: Any?, result: ParcelableStatus?, exception: MicroBlogException?) {
|
||||
destroyingFavoriteIds.removeElement(AsyncTwitterWrapper.calculateHashCode(accountKey, statusId))
|
||||
destroyingFavoriteIds.remove(AsyncTwitterWrapper.calculateHashCode(accountKey, statusId))
|
||||
val taskEvent = FavoriteTaskEvent(FavoriteTaskEvent.Action.DESTROY, accountKey, statusId)
|
||||
taskEvent.isFinished = true
|
||||
if (result != null) {
|
||||
|
@ -86,7 +85,7 @@ class DestroyFavoriteTask(
|
|||
}
|
||||
|
||||
companion object {
|
||||
private val destroyingFavoriteIds = ArrayIntList()
|
||||
private val destroyingFavoriteIds = ArrayList<Int>()
|
||||
|
||||
fun isDestroyingFavorite(accountKey: UserKey?, statusId: String?): Boolean {
|
||||
return destroyingFavoriteIds.contains(calculateHashCode(accountKey, statusId))
|
||||
|
|
|
@ -60,7 +60,7 @@ class DestroyStatusTask(
|
|||
}
|
||||
|
||||
override fun afterExecute(callback: Any?, result: ParcelableStatus?, exception: MicroBlogException?) {
|
||||
microBlogWrapper.destroyingStatusIds.removeElement(AsyncTwitterWrapper.calculateHashCode(accountKey, statusId))
|
||||
microBlogWrapper.destroyingStatusIds.remove(AsyncTwitterWrapper.calculateHashCode(accountKey, statusId))
|
||||
if (result != null) {
|
||||
if (result.retweet_id != null) {
|
||||
Toast.makeText(context, R.string.message_toast_retweet_cancelled, Toast.LENGTH_SHORT).show()
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.mariotaku.twidere.task
|
|||
|
||||
import android.content.Context
|
||||
import android.widget.Toast
|
||||
import org.apache.commons.collections.primitives.ArrayIntList
|
||||
import org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
import org.mariotaku.microblog.library.mastodon.Mastodon
|
||||
|
@ -82,7 +81,7 @@ class RetweetStatusTask(
|
|||
}
|
||||
|
||||
override fun afterExecute(callback: Any?, result: ParcelableStatus?, exception: MicroBlogException?) {
|
||||
creatingRetweetIds.removeElement(AsyncTwitterWrapper.calculateHashCode(accountKey, statusId))
|
||||
creatingRetweetIds.remove(AsyncTwitterWrapper.calculateHashCode(accountKey, statusId))
|
||||
if (result != null) {
|
||||
bus.post(StatusRetweetedEvent(result))
|
||||
Toast.makeText(context, R.string.message_toast_status_retweeted, Toast.LENGTH_SHORT).show()
|
||||
|
@ -116,7 +115,7 @@ class RetweetStatusTask(
|
|||
|
||||
companion object {
|
||||
|
||||
private val creatingRetweetIds = ArrayIntList()
|
||||
private val creatingRetweetIds = ArrayList<Int>()
|
||||
|
||||
fun isCreatingRetweet(accountKey: UserKey?, statusId: String?): Boolean {
|
||||
return creatingRetweetIds.contains(AsyncTwitterWrapper.calculateHashCode(accountKey, statusId))
|
||||
|
|
|
@ -23,7 +23,6 @@ package org.mariotaku.twidere.util
|
|||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.os.Bundle
|
||||
import org.apache.commons.collections.primitives.ArrayIntList
|
||||
import org.mariotaku.twidere.activity.HomeActivity
|
||||
|
||||
/**
|
||||
|
@ -31,7 +30,7 @@ import org.mariotaku.twidere.activity.HomeActivity
|
|||
*/
|
||||
class ActivityTracker : Application.ActivityLifecycleCallbacks {
|
||||
|
||||
private val internalStack = ArrayIntList()
|
||||
private val internalStack = ArrayList<Int>()
|
||||
|
||||
var isHomeActivityStarted: Boolean = false
|
||||
private set
|
||||
|
@ -39,15 +38,15 @@ class ActivityTracker : Application.ActivityLifecycleCallbacks {
|
|||
private set
|
||||
|
||||
private fun isSwitchingInSameTask(hashCode: Int): Boolean {
|
||||
return internalStack.lastIndexOf(hashCode) < internalStack.size() - 1
|
||||
return internalStack.lastIndexOf(hashCode) < internalStack.size - 1
|
||||
}
|
||||
|
||||
fun size(): Int {
|
||||
return internalStack.size()
|
||||
return internalStack.size
|
||||
}
|
||||
|
||||
val isEmpty: Boolean
|
||||
get() = internalStack.isEmpty
|
||||
get() = internalStack.isEmpty()
|
||||
|
||||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
|
||||
if (activity is HomeActivity) {
|
||||
|
@ -76,7 +75,7 @@ class ActivityTracker : Application.ActivityLifecycleCallbacks {
|
|||
isHomeActivityStarted = false
|
||||
}
|
||||
|
||||
internalStack.removeElement(hashCode)
|
||||
internalStack.remove(hashCode)
|
||||
}
|
||||
|
||||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
|
||||
|
|
|
@ -25,9 +25,6 @@ import android.net.Uri
|
|||
import android.widget.Toast
|
||||
import com.squareup.otto.Bus
|
||||
import com.squareup.otto.Subscribe
|
||||
import org.apache.commons.collections.primitives.ArrayIntList
|
||||
import org.apache.commons.collections.primitives.ArrayLongList
|
||||
import org.apache.commons.collections.primitives.IntList
|
||||
import org.mariotaku.abstask.library.TaskStarter
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.ktextension.mapToArray
|
||||
|
@ -70,10 +67,10 @@ class AsyncTwitterWrapper(
|
|||
private val resolver = context.contentResolver
|
||||
|
||||
|
||||
var destroyingStatusIds: IntList = ArrayIntList()
|
||||
private val updatingRelationshipIds = ArrayIntList()
|
||||
var destroyingStatusIds = ArrayList<Int>()
|
||||
private val updatingRelationshipIds = ArrayList<Int>()
|
||||
|
||||
private val sendingDraftIds = ArrayLongList()
|
||||
private val sendingDraftIds = ArrayList<Long>()
|
||||
|
||||
private val getMessageTasks = CompactHashSet<Uri>()
|
||||
private val getStatusTasks = CompactHashSet<Uri>()
|
||||
|
@ -256,7 +253,7 @@ class AsyncTwitterWrapper(
|
|||
}
|
||||
|
||||
fun getSendingDraftIds(): LongArray {
|
||||
return sendingDraftIds.toArray()
|
||||
return sendingDraftIds.toLongArray()
|
||||
}
|
||||
|
||||
fun isDestroyingStatus(accountKey: UserKey?, statusId: String?): Boolean {
|
||||
|
@ -313,7 +310,7 @@ class AsyncTwitterWrapper(
|
|||
|
||||
fun removeSendingDraftId(id: Long) {
|
||||
synchronized(sendingDraftIds) {
|
||||
sendingDraftIds.removeElement(id)
|
||||
sendingDraftIds.remove(id)
|
||||
resolver.notifyChange(Drafts.CONTENT_URI_UNSENT, null)
|
||||
}
|
||||
}
|
||||
|
@ -399,7 +396,7 @@ class AsyncTwitterWrapper(
|
|||
}
|
||||
|
||||
fun removeUpdatingRelationshipId(accountKey: UserKey, userKey: UserKey) {
|
||||
updatingRelationshipIds.removeElement(ParcelableUser.calculateHashCode(accountKey, userKey))
|
||||
updatingRelationshipIds.remove(ParcelableUser.calculateHashCode(accountKey, userKey))
|
||||
}
|
||||
|
||||
fun isUpdatingRelationship(accountKey: UserKey, userKey: UserKey): Boolean {
|
||||
|
|
Loading…
Reference in New Issue