Search in sources :

Example 26 with SuppressLint

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;
}
Also used : Uri(android.net.Uri) File(java.io.File) SuppressLint(android.annotation.SuppressLint)

Example 27 with SuppressLint

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);
}
Also used : SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 28 with SuppressLint

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);
}
Also used : ReaderCallback(android.nfc.NfcAdapter.ReaderCallback) Bundle(android.os.Bundle) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Tag(android.nfc.Tag) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 29 with SuppressLint

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());
}
Also used : Tweet(com.pushtorefresh.storio.sample.db.entities.Tweet) SuppressLint(android.annotation.SuppressLint)

Example 30 with SuppressLint

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;
}
Also used : SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)739 View (android.view.View)168 TextView (android.widget.TextView)106 Intent (android.content.Intent)86 Paint (android.graphics.Paint)63 ImageView (android.widget.ImageView)44 File (java.io.File)42 LayoutInflater (android.view.LayoutInflater)37 WebView (android.webkit.WebView)37 Uri (android.net.Uri)35 ArrayList (java.util.ArrayList)34 Context (android.content.Context)33 Bitmap (android.graphics.Bitmap)31 ViewGroup (android.view.ViewGroup)30 ListView (android.widget.ListView)30 Bundle (android.os.Bundle)27 IOException (java.io.IOException)26 AlertDialog (android.app.AlertDialog)25 DialogInterface (android.content.DialogInterface)25 AdapterView (android.widget.AdapterView)25