1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00

Replace call to method only available with API 9 and higher

This commit is contained in:
cketti 2012-10-27 05:09:58 +02:00
parent 65b3a57340
commit 889e2502be
2 changed files with 18 additions and 2 deletions

View File

@ -2,7 +2,6 @@ package com.fsck.k9.fragment;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
@ -74,6 +73,7 @@ import com.fsck.k9.fragment.ConfirmationDialogFragment.ConfirmationDialogFragmen
import com.fsck.k9.helper.MessageHelper;
import com.fsck.k9.helper.MergeCursorWithUniqueId;
import com.fsck.k9.helper.StringUtils;
import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Folder;
@ -133,7 +133,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
private static final int ACCOUNT_UUID_COLUMN = 14;
private static final int THREAD_COUNT_COLUMN = 15;
private static final String[] PROJECTION = Arrays.copyOf(THREADED_PROJECTION,
private static final String[] PROJECTION = Utility.copyOf(THREADED_PROJECTION,
THREAD_COUNT_COLUMN);

View File

@ -1,11 +1,13 @@
package com.fsck.k9.helper;
import android.annotation.SuppressLint;
import android.app.Application;
import android.content.Context;
import android.database.Cursor;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.text.Editable;
import android.util.Log;
import android.widget.EditText;
@ -19,6 +21,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
@ -708,4 +711,17 @@ public class Utility {
return null;
}
@SuppressLint("NewApi")
public static String[] copyOf(String[] original, int newLength) {
if (Build.VERSION.SDK_INT >= 9) {
return Arrays.copyOf(original, newLength);
}
String[] newArray = new String[newLength];
int copyLength = (original.length >= newLength) ? newLength : original.length;
System.arraycopy(original, 0, newArray, 0, copyLength);
return newArray;
}
}