This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | |
<gradient android:startColor="#34000000" | |
android:endColor="#00000000" | |
android:angle="-90" | |
android:useLevel="false" | |
android:type="linear"/> | |
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun setDialogGravity(gravity: Int) { | |
val window = dialog?.window | |
val wlp = window?.attributes | |
wlp?.gravity = gravity | |
wlp?.y = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 56f, resources.displayMetrics).toInt() | |
window?.attributes = wlp | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bottomNavigationView.menu.removeItem(R.id.itemId) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.os.Handler | |
import android.util.TypedValue | |
import android.widget.TextView | |
import androidx.core.widget.TextViewCompat | |
import kotlinx.android.synthetic.main.activity_main.* | |
class MainActivity : AppCompatActivity() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//in manifest | |
apply plugin: 'kotlin-kapt' | |
... | |
dataBinding { enabled = true } | |
//------------------- | |
//Binding adapter example in kotlin | |
@BindingAdapter("app:backgroundTintAdapt") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BindingAdapters { | |
@BindingAdapter({"app:setFlags"}) | |
public static void setFlags(CollapsingToolbarLayout view, int flag) { | |
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) view.getLayoutParams(); | |
params.setScrollFlags(flag); | |
view.setLayoutParams(params); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@BindingAdapter("list", "layout") | |
fun <T> chips(view: ChipGroup, items: List<T>, layoutId: Int) { | |
view.removeAllViews() | |
val inflater = view.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater | |
items.forEachIndexed { index, model -> | |
val binding = DataBindingUtil.inflate<ViewDataBinding>(inflater, layoutId, view, false) | |
binding.setVariable(BR.model, model) | |
(binding.root as Chip).id = index | |
view.addView(binding.root) | |
binding.executePendingBindings() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Root(name="Node") | |
class Node ( | |
@field:Element(name = "title", required = false) | |
var title: String? = null | |
) | |
val n = Node("sad") | |
val serializer: Serializer = Persister() | |
val writer = StringWriter() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var items = [ | |
'567', | |
'2346' | |
]; | |
var i = 0; | |
function myLoop() { | |
setTimeout(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script works by using the Get-ChildItem cmdlet to recursively search for all files and folders in the target directory. For each item, it checks whether its name contains the search string. If it does, it constructs the new name by replacing the search string with the replace string, and then renames the item using the Rename-Item cmdlet. | |
# Note that we're using the ToLower() method to convert the item name to lowercase before checking for the search string. This ensures that we catch variations of the search string that are spelled with different capitalization. | |
# Again, you should use this script with caution, especially when renaming directories that contain files, as it can cause issues with file paths and dependencies. | |
# To run this PowerShell script, save it with a .ps1 extension (e.g., rename_comments.ps1) and execute it from a PowerShell prompt by entering the file path, e.g.: .\rename_comments.ps1. You will then be prompted to enter the target directory path. | |
$searchString = "string1" |