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 java.text.Normalizer | |
enum class State(val stateName: String) { | |
AK("Alaska"), | |
AL("Alabama"), | |
AR("Arkansas"), | |
AZ("Arizona"), | |
CA("California"), | |
CO("Colorado"), | |
CT("Connecticut"), |
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.fragment.app.Fragment | |
import androidx.lifecycle.DefaultLifecycleObserver | |
import androidx.lifecycle.LifecycleOwner | |
import kotlin.properties.ReadOnlyProperty | |
import kotlin.reflect.KProperty | |
fun <T> Fragment.viewLifecycleAware(initialise: () -> T): ReadOnlyProperty<Fragment, T> = | |
object : ReadOnlyProperty<Fragment, T>, DefaultLifecycleObserver { | |
private var binding: T? = null |
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
override fun onCreate(savedInstanceState: Bundle?) { | |
... | |
btnContinue.setOnClickListener { | |
if (pager.currentItem < pager.adapter?.itemCount!! - 1) { | |
handler.removeMessages(0) | |
pager.currentItem = ++pager.currentItem | |
} | |
} | |
// I expect the back button to be hidden when ViewPager2 is at position 0 |
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
... | |
pager.registerOnPageChangeCallback(object : OnPageChangeCallback() { | |
override fun onPageSelected(position: Int) { | |
super.onPageSelected(position) | |
// Clear the messages so that every time an item has changed | |
// we reset our handler. | |
handler.removeMessages(0) | |
if (position == 0) btnBack.visibility = View.GONE |
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
companion object { | |
private const val timerDelay: Long = 10 * 1000 // 10 seconds in milliseconds | |
} | |
override fun onCreate(savedInstanceState: Bundle?) { | |
... | |
pager.adapter = ViewPagerAdapter(updates) | |
... | |
pager.registerOnPageChangeCallback(object : OnPageChangeCallback() { | |
override fun onPageSelected(position: Int) { |
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
class LauncherActivity : AppCompatActivity(){ | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
val handler = Handler() | |
setContentView(R.layout.activity_launcher) | |
val updates = listOf( | |
UpdatesSeriesModel( |
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 OkHttpFactory { | |
private static final int DEFAULT_CONNECTION_TIMEOUT = 30; // seconds | |
private OkHttpClient mOkHttpClient; | |
public void OkHttpFactory() { | |
mOkHttpClient = new OkHttpClient(); | |
} | |
/** | |
* To get default OkHttpClient with out any interceptor or log level. To add OkHttpClient with its properties use {@link Builder} class |
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
class ChildItemsViewHolder(inflater: LayoutInflater, parent: ViewGroup, itemListener: ItemListener) : | |
RecyclerView.ViewHolder(inflater.inflate(R.layout.card_child_item, parent, false)), View.OnClickListener { | |
private var itemListener: ItemListener? = null | |
private var cardTitle: TextView? = null | |
private var cardDesc: TextView? = null | |
private var remove: ConstraintLayout? = null | |
init { | |
cardTitle = itemView.findViewById(R.id.card_title) |
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
class ChildItemsAdapter(private val data: ArrayList<ChildItemModel>, | |
private var itemListener: ItemListener | |
) : RecyclerView.Adapter<ChildItemsViewHolder>(), ItemListener { | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ChildItemsViewHolder { | |
val inflater = LayoutInflater.from(parent.context) | |
return ChildItemsViewHolder(inflater, parent, this) | |
} | |
override fun onBindViewHolder(holder: ChildItemsViewHolder, position: Int) { |
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
class ParentItemsViewHolder(inflater: LayoutInflater, parent: ViewGroup, itemListener: ItemListener) : | |
RecyclerView.ViewHolder(inflater.inflate(R.layout.card_parent_item, parent, false)) { | |
private var itemListener: ItemListener? = null | |
private var cardTitle: TextView? = null | |
private var recyclerItem: RecyclerView? = null | |
init { | |
cardTitle = itemView.findViewById(R.id.app_title) | |
recyclerItem = itemView.findViewById(R.id.id_card_child_items) |
NewerOlder