use of com.bumptech.glide.request.RequestOptions in project glide by bumptech.
the class RequestBuilder method into.
/**
* Sets the {@link ImageView} the resource will be loaded into, cancels any existing loads into
* the view, and frees any resources Glide may have previously loaded into the view so they may be
* reused.
*
* @see RequestManager#clear(Target)
*
* @param view The view to cancel previous loads for and load the new resource into.
* @return The
* {@link com.bumptech.glide.request.target.Target} used to wrap the given {@link ImageView}.
*/
@NonNull
public ViewTarget<ImageView, TranscodeType> into(@NonNull ImageView view) {
Util.assertMainThread();
Preconditions.checkNotNull(view);
RequestOptions requestOptions = this.requestOptions;
if (!requestOptions.isTransformationSet() && requestOptions.isTransformationAllowed() && view.getScaleType() != null) {
// View's scale type.
switch(view.getScaleType()) {
case CENTER_CROP:
requestOptions = requestOptions.clone().optionalCenterCrop();
break;
case CENTER_INSIDE:
requestOptions = requestOptions.clone().optionalCenterInside();
break;
case FIT_CENTER:
case FIT_START:
case FIT_END:
requestOptions = requestOptions.clone().optionalFitCenter();
break;
case FIT_XY:
requestOptions = requestOptions.clone().optionalCenterInside();
break;
case CENTER:
case MATRIX:
default:
}
}
return into(glideContext.buildImageViewTarget(view, transcodeClass), /*targetListener=*/
null, requestOptions);
}
use of com.bumptech.glide.request.RequestOptions in project glide by bumptech.
the class GlideTest method testLoadColorDrawable_withNonUnitBitmapTransformation_returnsBitmapDrawable.
@Test
public void testLoadColorDrawable_withNonUnitBitmapTransformation_returnsBitmapDrawable() {
ColorDrawable colorDrawable = new ColorDrawable(Color.RED);
requestManager.load(colorDrawable).apply(new RequestOptions().override(100, 100).circleCrop()).into(target);
ArgumentCaptor<Object> argumentCaptor = ArgumentCaptor.forClass(Object.class);
verify(target).onResourceReady(argumentCaptor.capture(), isA(Transition.class));
Object result = argumentCaptor.getValue();
assertThat(result).isInstanceOf(BitmapDrawable.class);
Bitmap bitmap = ((BitmapDrawable) result).getBitmap();
assertThat(bitmap.getWidth()).isEqualTo(100);
assertThat(bitmap.getHeight()).isEqualTo(100);
}
use of com.bumptech.glide.request.RequestOptions in project glide by bumptech.
the class GlideTest method testLoadColorDrawable_withUnitBitmapTransformation_returnsColorDrawable.
@Test
public void testLoadColorDrawable_withUnitBitmapTransformation_returnsColorDrawable() {
ColorDrawable colorDrawable = new ColorDrawable(Color.RED);
requestManager.load(colorDrawable).apply(new RequestOptions().override(100, 100).centerCrop()).into(target);
ArgumentCaptor<Object> argumentCaptor = ArgumentCaptor.forClass(Object.class);
verify(target).onResourceReady(argumentCaptor.capture(), isA(Transition.class));
Object result = argumentCaptor.getValue();
assertThat(result).isInstanceOf(ColorDrawable.class);
assertThat(((ColorDrawable) result).getColor()).isEqualTo(Color.RED);
}
use of com.bumptech.glide.request.RequestOptions in project NetGuard by M66B.
the class AdapterRule method onBindViewHolder.
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
final Context context = holder.itemView.getContext();
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
// Get rule
final Rule rule = listFiltered.get(position);
// Handle expanding/collapsing
holder.llApplication.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
rule.expanded = !rule.expanded;
notifyItemChanged(holder.getAdapterPosition());
}
});
// Show if non default rules
holder.itemView.setBackgroundColor(rule.changed ? colorChanged : Color.TRANSPARENT);
// Show expand/collapse indicator
holder.ivExpander.setImageLevel(rule.expanded ? 1 : 0);
// Show application icon
if (rule.icon <= 0)
holder.ivIcon.setImageResource(android.R.drawable.sym_def_app_icon);
else {
Uri uri = Uri.parse("android.resource://" + rule.packageName + "/" + rule.icon);
GlideApp.with(holder.itemView.getContext()).applyDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_RGB_565)).load(uri).override(iconSize, iconSize).into(holder.ivIcon);
}
// Show application label
holder.tvName.setText(rule.name);
// Show application state
int color = rule.system ? colorOff : colorText;
if (!rule.internet || !rule.enabled)
color = Color.argb(128, Color.red(color), Color.green(color), Color.blue(color));
holder.tvName.setTextColor(color);
holder.tvHosts.setVisibility(rule.hosts > 0 ? View.VISIBLE : View.GONE);
holder.tvHosts.setText(Long.toString(rule.hosts));
// Lockdown settings
boolean lockdown = prefs.getBoolean("lockdown", false);
boolean lockdown_wifi = prefs.getBoolean("lockdown_wifi", true);
boolean lockdown_other = prefs.getBoolean("lockdown_other", true);
if ((otherActive && !lockdown_other) || (wifiActive && !lockdown_wifi))
lockdown = false;
holder.rlLockdown.setVisibility(lockdown && !rule.lockdown ? View.VISIBLE : View.GONE);
holder.ivLockdown.setEnabled(rule.apply);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
Drawable wrap = DrawableCompat.wrap(holder.ivLockdown.getDrawable());
DrawableCompat.setTint(wrap, rule.apply ? colorOff : colorGrayed);
}
boolean screen_on = prefs.getBoolean("screen_on", true);
// Wi-Fi settings
holder.cbWifi.setEnabled(rule.apply);
holder.cbWifi.setAlpha(wifiActive ? 1 : 0.5f);
holder.cbWifi.setOnCheckedChangeListener(null);
holder.cbWifi.setChecked(rule.wifi_blocked);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
Drawable wrap = DrawableCompat.wrap(CompoundButtonCompat.getButtonDrawable(holder.cbWifi));
DrawableCompat.setTint(wrap, rule.apply ? (rule.wifi_blocked ? colorOff : colorOn) : colorGrayed);
}
holder.cbWifi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
rule.wifi_blocked = isChecked;
updateRule(context, rule, true, listAll);
}
});
holder.ivScreenWifi.setEnabled(rule.apply);
holder.ivScreenWifi.setAlpha(wifiActive ? 1 : 0.5f);
holder.ivScreenWifi.setVisibility(rule.screen_wifi && rule.wifi_blocked ? View.VISIBLE : View.INVISIBLE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
Drawable wrap = DrawableCompat.wrap(holder.ivScreenWifi.getDrawable());
DrawableCompat.setTint(wrap, rule.apply ? colorOn : colorGrayed);
}
// Mobile settings
holder.cbOther.setEnabled(rule.apply);
holder.cbOther.setAlpha(otherActive ? 1 : 0.5f);
holder.cbOther.setOnCheckedChangeListener(null);
holder.cbOther.setChecked(rule.other_blocked);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
Drawable wrap = DrawableCompat.wrap(CompoundButtonCompat.getButtonDrawable(holder.cbOther));
DrawableCompat.setTint(wrap, rule.apply ? (rule.other_blocked ? colorOff : colorOn) : colorGrayed);
}
holder.cbOther.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
rule.other_blocked = isChecked;
updateRule(context, rule, true, listAll);
}
});
holder.ivScreenOther.setEnabled(rule.apply);
holder.ivScreenOther.setAlpha(otherActive ? 1 : 0.5f);
holder.ivScreenOther.setVisibility(rule.screen_other && rule.other_blocked ? View.VISIBLE : View.INVISIBLE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
Drawable wrap = DrawableCompat.wrap(holder.ivScreenOther.getDrawable());
DrawableCompat.setTint(wrap, rule.apply ? colorOn : colorGrayed);
}
holder.tvRoaming.setTextColor(rule.apply ? colorOff : colorGrayed);
holder.tvRoaming.setAlpha(otherActive ? 1 : 0.5f);
holder.tvRoaming.setVisibility(rule.roaming && (!rule.other_blocked || rule.screen_other) ? View.VISIBLE : View.INVISIBLE);
// Expanded configuration section
holder.llConfiguration.setVisibility(rule.expanded ? View.VISIBLE : View.GONE);
// Show application details
holder.tvUid.setText(Integer.toString(rule.uid));
holder.tvPackage.setText(rule.packageName);
holder.tvVersion.setText(rule.version);
// Show application state
holder.tvInternet.setVisibility(rule.internet ? View.GONE : View.VISIBLE);
holder.tvDisabled.setVisibility(rule.enabled ? View.GONE : View.VISIBLE);
// Show related
holder.btnRelated.setVisibility(rule.relateduids ? View.VISIBLE : View.GONE);
holder.btnRelated.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent main = new Intent(context, ActivityMain.class);
main.putExtra(ActivityMain.EXTRA_SEARCH, Integer.toString(rule.uid));
main.putExtra(ActivityMain.EXTRA_RELATED, true);
context.startActivity(main);
}
});
// Launch application settings
if (rule.expanded) {
Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + rule.packageName));
final Intent settings = (intent.resolveActivity(context.getPackageManager()) == null ? null : intent);
holder.ibSettings.setVisibility(settings == null ? View.GONE : View.VISIBLE);
holder.ibSettings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
context.startActivity(settings);
}
});
} else
holder.ibSettings.setVisibility(View.GONE);
// Launch application
if (rule.expanded) {
Intent intent = context.getPackageManager().getLaunchIntentForPackage(rule.packageName);
final Intent launch = (intent == null || intent.resolveActivity(context.getPackageManager()) == null ? null : intent);
holder.ibLaunch.setVisibility(launch == null ? View.GONE : View.VISIBLE);
holder.ibLaunch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
context.startActivity(launch);
}
});
} else
holder.ibLaunch.setVisibility(View.GONE);
// Apply
holder.cbApply.setEnabled(rule.pkg);
holder.cbApply.setOnCheckedChangeListener(null);
holder.cbApply.setChecked(rule.apply);
holder.cbApply.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
rule.apply = isChecked;
updateRule(context, rule, true, listAll);
}
});
// Show Wi-Fi screen on condition
holder.llScreenWifi.setVisibility(screen_on ? View.VISIBLE : View.GONE);
holder.cbScreenWifi.setEnabled(rule.wifi_blocked && rule.apply);
holder.cbScreenWifi.setOnCheckedChangeListener(null);
holder.cbScreenWifi.setChecked(rule.screen_wifi);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
Drawable wrap = DrawableCompat.wrap(holder.ivWifiLegend.getDrawable());
DrawableCompat.setTint(wrap, colorOn);
}
holder.cbScreenWifi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
rule.screen_wifi = isChecked;
updateRule(context, rule, true, listAll);
}
});
// Show mobile screen on condition
holder.llScreenOther.setVisibility(screen_on ? View.VISIBLE : View.GONE);
holder.cbScreenOther.setEnabled(rule.other_blocked && rule.apply);
holder.cbScreenOther.setOnCheckedChangeListener(null);
holder.cbScreenOther.setChecked(rule.screen_other);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
Drawable wrap = DrawableCompat.wrap(holder.ivOtherLegend.getDrawable());
DrawableCompat.setTint(wrap, colorOn);
}
holder.cbScreenOther.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
rule.screen_other = isChecked;
updateRule(context, rule, true, listAll);
}
});
// Show roaming condition
holder.cbRoaming.setEnabled((!rule.other_blocked || rule.screen_other) && rule.apply);
holder.cbRoaming.setOnCheckedChangeListener(null);
holder.cbRoaming.setChecked(rule.roaming);
holder.cbRoaming.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@TargetApi(Build.VERSION_CODES.M)
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
rule.roaming = isChecked;
updateRule(context, rule, true, listAll);
}
});
// Show lockdown
holder.cbLockdown.setEnabled(rule.apply);
holder.cbLockdown.setOnCheckedChangeListener(null);
holder.cbLockdown.setChecked(rule.lockdown);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
Drawable wrap = DrawableCompat.wrap(holder.ivLockdownLegend.getDrawable());
DrawableCompat.setTint(wrap, colorOn);
}
holder.cbLockdown.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@TargetApi(Build.VERSION_CODES.M)
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
rule.lockdown = isChecked;
updateRule(context, rule, true, listAll);
}
});
// Reset rule
holder.btnClear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Util.areYouSure(view.getContext(), R.string.msg_clear_rules, new Util.DoubtListener() {
@Override
public void onSure() {
holder.cbApply.setChecked(true);
holder.cbWifi.setChecked(rule.wifi_default);
holder.cbOther.setChecked(rule.other_default);
holder.cbScreenWifi.setChecked(rule.screen_wifi_default);
holder.cbScreenOther.setChecked(rule.screen_other_default);
holder.cbRoaming.setChecked(rule.roaming_default);
holder.cbLockdown.setChecked(false);
}
});
}
});
holder.llFilter.setVisibility(Util.canFilter(context) ? View.VISIBLE : View.GONE);
// Live
holder.ivLive.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
live = !live;
TypedValue tv = new TypedValue();
view.getContext().getTheme().resolveAttribute(live ? R.attr.iconPause : R.attr.iconPlay, tv, true);
holder.ivLive.setImageResource(tv.resourceId);
if (live)
AdapterRule.this.notifyDataSetChanged();
}
});
// Show logging/filtering is disabled
final boolean log_app = prefs.getBoolean("log_app", false);
final boolean filter = prefs.getBoolean("filter", false);
final boolean notify_access = prefs.getBoolean("notify_access", false);
holder.tvLogging.setText(log_app && filter ? R.string.title_logging_enabled : R.string.title_logging_disabled);
holder.btnLogging.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.enable, null, false);
final CheckBox cbLogging = view.findViewById(R.id.cbLogging);
final CheckBox cbFiltering = view.findViewById(R.id.cbFiltering);
final CheckBox cbNotify = view.findViewById(R.id.cbNotify);
TextView tvFilter4 = view.findViewById(R.id.tvFilter4);
cbLogging.setChecked(log_app);
cbFiltering.setChecked(filter);
cbFiltering.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);
tvFilter4.setVisibility(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? View.GONE : View.VISIBLE);
cbNotify.setChecked(notify_access);
cbNotify.setEnabled(log_app);
cbLogging.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("log_app", checked).apply();
cbNotify.setEnabled(checked);
if (!checked) {
cbNotify.setChecked(false);
prefs.edit().putBoolean("notify_access", false).apply();
ServiceSinkhole.reload("changed notify", context, false);
}
AdapterRule.this.notifyDataSetChanged();
}
});
cbFiltering.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
if (checked)
cbLogging.setChecked(true);
prefs.edit().putBoolean("filter", checked).apply();
ServiceSinkhole.reload("changed filter", context, false);
AdapterRule.this.notifyDataSetChanged();
}
});
cbNotify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("notify_access", checked).apply();
ServiceSinkhole.reload("changed notify", context, false);
AdapterRule.this.notifyDataSetChanged();
}
});
AlertDialog dialog = new AlertDialog.Builder(context).setView(view).setCancelable(true).create();
dialog.show();
}
});
// Show access rules
if (rule.expanded) {
// Access the database when expanded only
final AdapterAccess badapter = new AdapterAccess(context, DatabaseHelper.getInstance(context).getAccess(rule.uid));
holder.lvAccess.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, final int bposition, long bid) {
PackageManager pm = context.getPackageManager();
Cursor cursor = (Cursor) badapter.getItem(bposition);
final long id = cursor.getLong(cursor.getColumnIndex("ID"));
final int version = cursor.getInt(cursor.getColumnIndex("version"));
final int protocol = cursor.getInt(cursor.getColumnIndex("protocol"));
final String daddr = cursor.getString(cursor.getColumnIndex("daddr"));
final int dport = cursor.getInt(cursor.getColumnIndex("dport"));
long time = cursor.getLong(cursor.getColumnIndex("time"));
int block = cursor.getInt(cursor.getColumnIndex("block"));
PopupMenu popup = new PopupMenu(context, anchor);
popup.inflate(R.menu.access);
popup.getMenu().findItem(R.id.menu_host).setTitle(Util.getProtocolName(protocol, version, false) + " " + daddr + (dport > 0 ? "/" + dport : ""));
SubMenu sub = popup.getMenu().findItem(R.id.menu_host).getSubMenu();
boolean multiple = false;
Cursor alt = null;
try {
alt = DatabaseHelper.getInstance(context).getAlternateQNames(daddr);
while (alt.moveToNext()) {
multiple = true;
sub.add(Menu.NONE, Menu.NONE, 0, alt.getString(0)).setEnabled(false);
}
} finally {
if (alt != null)
alt.close();
}
popup.getMenu().findItem(R.id.menu_host).setEnabled(multiple);
markPro(context, popup.getMenu().findItem(R.id.menu_allow), ActivityPro.SKU_FILTER);
markPro(context, popup.getMenu().findItem(R.id.menu_block), ActivityPro.SKU_FILTER);
// Whois
final Intent lookupIP = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.tcpiputils.com/whois-lookup/" + daddr));
if (pm.resolveActivity(lookupIP, 0) == null)
popup.getMenu().removeItem(R.id.menu_whois);
else
popup.getMenu().findItem(R.id.menu_whois).setTitle(context.getString(R.string.title_log_whois, daddr));
// Lookup port
final Intent lookupPort = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.speedguide.net/port.php?port=" + dport));
if (dport <= 0 || pm.resolveActivity(lookupPort, 0) == null)
popup.getMenu().removeItem(R.id.menu_port);
else
popup.getMenu().findItem(R.id.menu_port).setTitle(context.getString(R.string.title_log_port, dport));
popup.getMenu().findItem(R.id.menu_time).setTitle(SimpleDateFormat.getDateTimeInstance().format(time));
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
int menu = menuItem.getItemId();
boolean result = false;
switch(menu) {
case R.id.menu_whois:
context.startActivity(lookupIP);
result = true;
break;
case R.id.menu_port:
context.startActivity(lookupPort);
result = true;
break;
case R.id.menu_allow:
if (IAB.isPurchased(ActivityPro.SKU_FILTER, context)) {
DatabaseHelper.getInstance(context).setAccess(id, 0);
ServiceSinkhole.reload("allow host", context, false);
} else
context.startActivity(new Intent(context, ActivityPro.class));
result = true;
break;
case R.id.menu_block:
if (IAB.isPurchased(ActivityPro.SKU_FILTER, context)) {
DatabaseHelper.getInstance(context).setAccess(id, 1);
ServiceSinkhole.reload("block host", context, false);
} else
context.startActivity(new Intent(context, ActivityPro.class));
result = true;
break;
case R.id.menu_reset:
DatabaseHelper.getInstance(context).setAccess(id, -1);
ServiceSinkhole.reload("reset host", context, false);
result = true;
break;
case R.id.menu_copy:
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("netguard", daddr);
clipboard.setPrimaryClip(clip);
return true;
}
if (menu == R.id.menu_allow || menu == R.id.menu_block || menu == R.id.menu_reset)
new AsyncTask<Object, Object, Long>() {
@Override
protected Long doInBackground(Object... objects) {
return DatabaseHelper.getInstance(context).getHostCount(rule.uid, false);
}
@Override
protected void onPostExecute(Long hosts) {
rule.hosts = hosts;
notifyDataSetChanged();
}
}.execute();
return result;
}
});
if (block == 0)
popup.getMenu().removeItem(R.id.menu_allow);
else if (block == 1)
popup.getMenu().removeItem(R.id.menu_block);
popup.show();
}
});
holder.lvAccess.setAdapter(badapter);
} else {
holder.lvAccess.setAdapter(null);
holder.lvAccess.setOnItemClickListener(null);
}
// Clear access log
holder.btnClearAccess.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Util.areYouSure(view.getContext(), R.string.msg_reset_access, new Util.DoubtListener() {
@Override
public void onSure() {
DatabaseHelper.getInstance(context).clearAccess(rule.uid, true);
if (!live)
notifyDataSetChanged();
if (rv != null)
rv.scrollToPosition(holder.getAdapterPosition());
}
});
}
});
// Notify on access
holder.cbNotify.setEnabled(prefs.getBoolean("notify_access", false) && rule.apply);
holder.cbNotify.setOnCheckedChangeListener(null);
holder.cbNotify.setChecked(rule.notify);
holder.cbNotify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
rule.notify = isChecked;
updateRule(context, rule, true, listAll);
}
});
}
use of com.bumptech.glide.request.RequestOptions in project MaterialFBook by ZeeRooo.
the class Photo method shareImg.
private void shareImg() {
ShareTarget = new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap bitmap, Transition<? super Bitmap> transition) {
String path = MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, Uri.parse(url).getLastPathSegment(), null);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(path));
startActivity(Intent.createChooser(shareIntent, getString(R.string.context_share_image)));
CookingAToast.cooking(Photo.this, getString(R.string.context_share_image_progress), Color.WHITE, Color.parseColor("#00C851"), R.drawable.ic_share, false).show();
}
};
Glide.with(Photo.this).asBitmap().load(url).apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE)).into(ShareTarget);
share = 2;
}
Aggregations