use of android.annotation.SuppressLint in project Conversations by siacs.
the class FileUtils method getPath.
/**
* Get a file path from a Uri. This will get the the path for Storage Access
* Framework Documents, as well as the _data field for the MediaStore and
* other file-based ContentProviders.
*
* @param context The context.
* @param uri The Uri to query.
* @author paulburke
*/
@SuppressLint("NewApi")
public static String getPath(final Context context, final Uri uri) {
if (uri == null) {
return null;
}
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
// DocumentProvider
if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
// ExternalStorageProvider
if (isExternalStorageDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
if ("primary".equalsIgnoreCase(type)) {
return Environment.getExternalStorageDirectory() + "/" + split[1];
}
// TODO handle non-primary volumes
} else // DownloadsProvider
if (isDownloadsDocument(uri)) {
final String id = DocumentsContract.getDocumentId(uri);
final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
return getDataColumn(context, contentUri, null, null);
} else // MediaProvider
if (isMediaDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
Uri contentUri = null;
if ("image".equals(type)) {
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(type)) {
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(type)) {
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
}
final String selection = "_id=?";
final String[] selectionArgs = new String[] { split[1] };
return getDataColumn(context, contentUri, selection, selectionArgs);
}
} else // MediaStore (and general)
if ("content".equalsIgnoreCase(uri.getScheme())) {
String path = getDataColumn(context, uri, null, null);
if (path != null) {
File file = new File(path);
if (!file.canRead()) {
return null;
}
}
return path;
} else // File
if ("file".equalsIgnoreCase(uri.getScheme())) {
return uri.getPath();
}
return null;
}
use of android.annotation.SuppressLint in project StylishMusicPlayer by ryanhoo.
the class TimeUtils method formatDuration.
/**
* Parse the time in milliseconds into String with the format: hh:mm:ss or mm:ss
*
* @param duration The time needs to be parsed.
*/
@SuppressLint("DefaultLocale")
public static String formatDuration(int duration) {
// milliseconds into seconds
duration /= 1000;
int minute = duration / 60;
int hour = minute / 60;
minute %= 60;
int second = duration % 60;
if (hour != 0)
return String.format("%2d:%02d:%02d", hour, minute, second);
else
return String.format("%02d:%02d", minute, second);
}
use of android.annotation.SuppressLint in project nfcspy by sinpolib.
the class NfcManager method setReaderMode.
@SuppressLint("NewApi")
private void setReaderMode(boolean enable, int delay) {
if (nfcAdapter == null || !hasHCE())
return;
if (!enable) {
nfcAdapter.disableReaderMode(activity);
return;
}
Bundle opts = new Bundle();
opts.putInt(NfcAdapter.EXTRA_READER_PRESENCE_CHECK_DELAY, 5000);
int flags = NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK;
flags |= NfcAdapter.FLAG_READER_NFC_A;
// For the 'READ BINARY' problem of Braodcom's NFC stack.
// Only works on Android 4.4+
nfcAdapter.enableReaderMode(activity, new ReaderCallback() {
@Override
public void onTagDiscovered(Tag tag) {
Intent i = new Intent().putExtra(EXTRA_TAG, tag);
tagListener.onNewTagIntent(i);
}
}, flags, opts);
}
use of android.annotation.SuppressLint in project storio by pushtorefresh.
the class TweetsAdapter method onBindViewHolder.
@SuppressLint("SetTextI18n")
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
final Tweet tweet = tweets.get(position);
holder.authorTextView.setText("@" + tweet.author());
holder.contentTextView.setText(tweet.content());
}
use of android.annotation.SuppressLint in project weiciyuan by qii.
the class SlidingMenu method fitSystemWindows.
/* (non-Javadoc)
* @see android.view.ViewGroup#fitSystemWindows(android.graphics.Rect)
*/
@SuppressLint("NewApi")
@Override
protected boolean fitSystemWindows(Rect insets) {
int leftPadding = insets.left;
int rightPadding = insets.right;
int topPadding = insets.top;
int bottomPadding = insets.bottom;
if (!mActionbarOverlay) {
Log.v(TAG, "setting padding!");
setPadding(leftPadding, topPadding, rightPadding, bottomPadding);
}
return true;
}
Aggregations