use of android.net.Uri in project MaterialDrawer by mikepenz.
the class CustomApplication method onCreate.
@Override
public void onCreate() {
super.onCreate();
LeakCanary.install(this);
/*
//initialize and create the image loader logic
DrawerImageLoader.init(new AbstractDrawerImageLoader() {
@Override
public void set(ImageView imageView, Uri uri, Drawable placeholder) {
Picasso.with(imageView.getContext()).load(uri).placeholder(placeholder).into(imageView);
}
@Override
public void cancel(ImageView imageView) {
Picasso.with(imageView.getContext()).cancelRequest(imageView);
}
});
*/
//initialize and create the image loader logic
DrawerImageLoader.init(new AbstractDrawerImageLoader() {
@Override
public void set(ImageView imageView, Uri uri, Drawable placeholder, String tag) {
Glide.with(imageView.getContext()).load(uri).placeholder(placeholder).into(imageView);
}
@Override
public void cancel(ImageView imageView) {
Glide.clear(imageView);
}
@Override
public Drawable placeholder(Context ctx, String tag) {
//custom ones can be checked via string. see the CustomUrlBasePrimaryDrawerItem LINE 111
if (DrawerImageLoader.Tags.PROFILE.name().equals(tag)) {
return DrawerUIUtils.getPlaceHolder(ctx);
} else if (DrawerImageLoader.Tags.ACCOUNT_HEADER.name().equals(tag)) {
return new IconicsDrawable(ctx).iconText(" ").backgroundColorRes(com.mikepenz.materialdrawer.R.color.primary).sizeDp(56);
} else if ("customUrlItem".equals(tag)) {
return new IconicsDrawable(ctx).iconText(" ").backgroundColorRes(R.color.md_red_500).sizeDp(56);
}
return super.placeholder(ctx, tag);
}
});
}
use of android.net.Uri in project qksms by moezbhatti.
the class MessageUtils method lockMessage.
public static void lockMessage(Context context, MessageItem msgItem, boolean locked) {
Uri uri;
if ("sms".equals(msgItem.mType)) {
uri = Sms.CONTENT_URI;
} else {
uri = Mms.CONTENT_URI;
}
final Uri lockUri = ContentUris.withAppendedId(uri, msgItem.mMsgId);
final ContentValues values = new ContentValues(1);
values.put("locked", locked ? 1 : 0);
new Thread(() -> {
context.getContentResolver().update(lockUri, values, null, null);
}, "MainActivity.lockMessage").start();
}
use of android.net.Uri in project qksms by moezbhatti.
the class AddressUtils method getFrom.
public static String getFrom(Context context, Uri uri) {
String msgId = uri.getLastPathSegment();
Uri.Builder builder = Mms.CONTENT_URI.buildUpon();
builder.appendPath(msgId).appendPath("addr");
Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(), builder.build(), new String[] { Addr.ADDRESS, Addr.CHARSET }, Addr.TYPE + "=" + PduHeaders.FROM, null, null);
if (cursor != null) {
try {
if (cursor.moveToFirst()) {
String from = cursor.getString(0);
if (!TextUtils.isEmpty(from)) {
byte[] bytes = PduPersister.getBytes(from);
int charset = cursor.getInt(1);
return new EncodedStringValue(charset, bytes).getString();
}
}
} finally {
cursor.close();
}
}
return context.getString(R.string.hidden_sender_address);
}
use of android.net.Uri in project qksms by moezbhatti.
the class BackgroundLoaderManager method cancelCallback.
public void cancelCallback(ItemLoadedCallback callback) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Cancelling image callback " + callback);
}
for (final Uri uri : mCallbacks.keySet()) {
final Set<ItemLoadedCallback> callbacks = mCallbacks.get(uri);
callbacks.remove(callback);
}
}
use of android.net.Uri in project qksms by moezbhatti.
the class MessageUtils method handleReadReport.
public static void handleReadReport(final Context context, final Collection<Long> threadIds, final int status, final Runnable callback) {
StringBuilder selectionBuilder = new StringBuilder(Mms.MESSAGE_TYPE + " = " + PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF + " AND " + Mms.READ + " = 0" + " AND " + Mms.READ_REPORT + " = " + PduHeaders.VALUE_YES);
String[] selectionArgs = null;
if (threadIds != null) {
String threadIdSelection = null;
StringBuilder buf = new StringBuilder();
selectionArgs = new String[threadIds.size()];
int i = 0;
for (long threadId : threadIds) {
if (i > 0) {
buf.append(" OR ");
}
buf.append(Mms.THREAD_ID).append("=?");
selectionArgs[i++] = Long.toString(threadId);
}
threadIdSelection = buf.toString();
selectionBuilder.append(" AND (" + threadIdSelection + ")");
}
final Cursor c = SqliteWrapper.query(context, context.getContentResolver(), Mms.Inbox.CONTENT_URI, new String[] { Mms._ID, Mms.MESSAGE_ID }, selectionBuilder.toString(), selectionArgs, null);
if (c == null) {
return;
}
final Map<String, String> map = new HashMap<>();
try {
if (c.getCount() == 0) {
if (callback != null) {
callback.run();
}
return;
}
while (c.moveToNext()) {
Uri uri = ContentUris.withAppendedId(Mms.CONTENT_URI, c.getLong(0));
map.put(c.getString(1), AddressUtils.getFrom(context, uri));
}
} finally {
c.close();
}
OnClickListener positiveListener = new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
for (final Map.Entry<String, String> entry : map.entrySet()) {
MmsMessageSender.sendReadRec(context, entry.getValue(), entry.getKey(), status);
}
if (callback != null) {
callback.run();
}
dialog.dismiss();
}
};
OnClickListener negativeListener = new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (callback != null) {
callback.run();
}
dialog.dismiss();
}
};
OnCancelListener cancelListener = new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
if (callback != null) {
callback.run();
}
dialog.dismiss();
}
};
confirmReadReportDialog(context, positiveListener, negativeListener, cancelListener);
}
Aggregations