Skip to content

Instantly share code, notes, and snippets.

View damianpetla's full-sized avatar
🐢
Mastering Compose

Damian Petla damianpetla

🐢
Mastering Compose
View GitHub Profile
@damianpetla
damianpetla / card_background.xml
Last active April 6, 2023 19:05
Android drawable used as background with shadows. Support elevation on API 21+
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<layer-list>
<!-- Drop Shadow Stack -->
<item>
<shape>
<padding
android:bottom="1dp"
public class MySwipeLayout : SwipeRefreshLayout {
public constructor(context: Context) : super(context)
public constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
var appBarLayout: AppBarLayout? = null
override fun onAttachedToWindow() {
super<SwipeRefreshLayout>.onAttachedToWindow()
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
SwipeRefreshLayout rv = (SwipeRefreshLayout) inflater.inflate(
R.layout.fragment_cheese_list, container, false);
rv.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
}
@damianpetla
damianpetla / someClass.kt
Created May 21, 2015 08:45
Coloring text with HTML tags
val color = getResources().getString(R.color.some_color).replace("#ff", "#")
val terms = getString(R.string.register_terms, color)
termsText.setText(Html.fromHtml(terms))
@damianpetla
damianpetla / GmailAuthenticator.kt
Last active August 29, 2015 14:18
Trait's restricted class example
trait GmailAuthenticator : ActionBarActivity {
companion object {
val TAG = javaClass<GmailAuthenticator>().getName()
val PLAY_SERVICES_RESOLUTION_REQUEST = 9000
val REQUEST_CODE_PICK_ACCOUNT = 1000
val REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR = 1001
val AUDIENCE = "audience:...."
}
@damianpetla
damianpetla / DateUtils.kt
Last active August 29, 2015 14:10
Simple way to convert ISO8601 date/time to localised date/time
import java.util.TimeZone
import android.text.format.Time
import java.text.SimpleDateFormat
import java.text.DateFormat
/**
* Created by loop on 24/11/14.
*/
/**