Skip to content

Instantly share code, notes, and snippets.

View Cutta's full-sized avatar
🏃‍♂️
null

Cüneyt Çarıkçi Cutta

🏃‍♂️
null
View GitHub Profile
fun String.toSpanned(): Spanned {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return Html.fromHtml(this, Html.FROM_HTML_MODE_LEGACY)
} else {
@Suppress("DEPRECATION")
return Html.fromHtml(this)
}
}
fun FragmentManager.show(containerId: Int, fragment: Fragment, backstack: String? = null) {
beginTransaction()
.replace(containerId, fragment)
.addToBackStack(backstack)
.commit()
}
public static void showKeyboard(final Activity activity, final View view) {
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(
view.getApplicationWindowToken(),
InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_NOT_ALWAYS);
}
@Cutta
Cutta / NavigationVisibility
Created December 20, 2016 13:32
Set visibility of Navigation bar
private void showHideChrome(boolean show) {
int flags = show ? 0 : View.SYSTEM_UI_FLAG_LOW_PROFILE;
flags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
if (!show) {
flags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE;
}
@Cutta
Cutta / ExtractSVGPath.ruby
Last active September 5, 2016 21:02
Extracts and displays SVG Path path from your .svg file
require 'nokogiri'
File.open("/your/file/path/test.svg", "r") do |f|
@doc = Nokogiri::XML(f)
puts "\n\n\n"
puts @doc.css("path").first.attr("d")
puts "\n\n\n"
end
@Cutta
Cutta / MakeBlurr.java
Last active August 10, 2016 11:56
Android ImageView Blurring
public void makeBlur(ImageView imageview) {
BitmapDrawable drawable = (BitmapDrawable) imageview.getDrawable();
Bitmap bitmap = drawable.getBitmap();
textView.setText("Radius: " + "" + radiusArr[position]);
Bitmap blurred = blurRenderScript(bitmap, 25); //second parametre is radius max:25
imageview.setImageBitmap(blurred); //radius decide blur amount
}
@SuppressLint("NewApi")
private Bitmap blurRenderScript(Bitmap smallBitmap, int radius) {