Pergunta de entrevista da empresa HungerStation

The following block of code assumes RxJava2 usage.Please, describe which scheduler will [map] execute on, [filter] execute on. fun theTest() { val io = Schedulers.io() Observable .just("long", "longer", "longest") .subscribeOn(Schedulers.io()) .map { println("map ${Thread.currentThread().name}") it.length } .observeOn(Schedulers.computation()) .filter { println("filter ${Thread.currentThread().name}") it > 6 } .blockingSubscribeBy { length -> println( "item length $length under " + Thread.currentThread().name ) } }

Resposta da entrevista

Sigiloso

21 de dez. de 2023

We have a food delivery app that connects between a customer,arestaurant, When user select the restaurant, so the restaurant menu will appear, and the user can add/remove the menu item from his cart. Additionat info: 1. Each restaurant have their own categories of menus 2. Each restaurant have multiple menu items 3. Each itew have (Itew name, price, image, id, - etc) 4. Cart supports multiple restaurants at the same time- 5. Users can place an order with the menu Items of only one restaurant. 6. Once the user places an order, the cart will be reset. Extended Case : 1. Implement a Cart management system. 2. Architectural design pattern: - Android: Move the "RestaurantsFragment. kt" from MVC to MVV Bonus points: 1. Add unit test of view model layer Technicel Consideration : 1. Try to follow SOLID principles. 2. Try to use value type protocol oriented programming. 3. Thread safety should be considered, Example : Restaurant: KFC - Categories: Drinks and Desert Menu Items: Pepsi, 7up package com.hungerstation.intervienquestionone import android.service.controls.actions.FloatAction import com.google.android.material.floatingactionbutton.FloatingactionButton import com.google.android.material.snackbar.Snackbar import androidx.appcompat.app.AppCompatictivity import android.view.Menu import android.view.MenuItem import android.widget.ListAdapter import androidx.appcompat.app.AppCompatActivity import androidx.compose.material3.Snackbar import androidx.fragment.app.Fragment import androidx.navigation.fragment.navargs import kotlinx.android.synthetic.main.fragment_second.* import java.io.InputStream import androidx.navigation.fragment.findNavcontroller import kotlinx.android.synthetic.main.row_menu.view.* import android.os.Parcelable import com.google.gson.annotations.SerializedName import kotlinx.android.parcel.Parcelize import android.os.Bundle import androidx.recyclerview.widget.DividerItemDecoration import com.google.gson.Gson import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.fragment_first.* import java.io.IOException import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.databinding.DataBindingutil import androidx.databinding.ViewDataBinding import android.fragment.app.Fraginent import android.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import java.lo.Inputstream import java.lang.reflect.Type import android.widget.ImageView import android.databinding.BindingAdapter import com.bumptech.glide.Glide import com.bumptech.glide.Load.DecodeFormat import com.bumptech.glide.Load.resourcedrawable.DrawableTransitionOptions import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.transition.DrawableCrossFadeFactory class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) setSupportActionBar(findViewById(R.id.toolbar)) findViewById(R.id.fab).setOnClickListener { view -> Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show() } } override fun onCreateOptionsMenu(menu: Menu?): Boolean { menuInflater.inflate(R.menu.menu_main, menu) return true } override fun onOptionsItemSelected(item: MenuItem): Boolean { return when (item.itemId) { R.id.action_settings -> true else -> super.onOptionsItemSelected(item) } } } class MenuFragment : Fragment() { val args: MenuFragmentArgs by navArgs() lateinit var menuListAdapter: MenuListAdapter override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { return inflater.inflate(R.layout.fragment_second, container, false) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) menuListAdapter = MenuListAdapter() menuRecycler.adapter = menuListAdapter val itemDecorator = DividerItemDecoration(context, DividerItemDecoration.VERTICAL) menuRecycler.addItemDecoration(itemDecorator) menuListAdapter.submitList(args!!.menuCategory.asList()) } } class MenuListAdapter : ListAdapter(MenuListItemDiffCallback()) { override fun onCreateviewHolder (parent: ViewGroup, viewType: Int): MenuListViewHolder { val layoutInflater = LayoutInflater.from(parent.context) val binding = DataBindingUtil.inflate(layoutInflater, viewType, parent, false) return MenuListViewHolder(binding) } override fun onBindViewHolder(vh: MenuListViewHolder, position: Int) = vh.bind(g