/
ProductSearchActivity.kt
585 lines (517 loc) 路 25.2 KB
/
ProductSearchActivity.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
package openfoodfacts.github.scrachx.openfood.features.search
import android.Manifest
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.PackageManager
import android.os.Bundle
import android.util.Log
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.SearchView
import android.widget.Toast
import androidx.annotation.StringRes
import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.net.toUri
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.afollestad.materialdialogs.MaterialDialog
import com.squareup.picasso.Picasso
import dagger.hilt.android.AndroidEntryPoint
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.rxkotlin.addTo
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.rx2.awaitSingleOrNull
import kotlinx.coroutines.withContext
import openfoodfacts.github.scrachx.openfood.R
import openfoodfacts.github.scrachx.openfood.customtabs.CustomTabActivityHelper
import openfoodfacts.github.scrachx.openfood.databinding.ActivityProductBrowsingListBinding
import openfoodfacts.github.scrachx.openfood.features.adapters.ProductSearchAdapter
import openfoodfacts.github.scrachx.openfood.features.listeners.CommonBottomListenerInstaller.installBottomNavigation
import openfoodfacts.github.scrachx.openfood.features.listeners.CommonBottomListenerInstaller.selectNavigationItem
import openfoodfacts.github.scrachx.openfood.features.listeners.EndlessRecyclerViewScrollListener
import openfoodfacts.github.scrachx.openfood.features.listeners.RecyclerItemClickListener
import openfoodfacts.github.scrachx.openfood.features.scan.ContinuousScanActivity
import openfoodfacts.github.scrachx.openfood.features.shared.BaseActivity
import openfoodfacts.github.scrachx.openfood.models.Search
import openfoodfacts.github.scrachx.openfood.models.SearchInfo
import openfoodfacts.github.scrachx.openfood.models.SearchProduct
import openfoodfacts.github.scrachx.openfood.network.OpenFoodAPIClient
import openfoodfacts.github.scrachx.openfood.repositories.ProductRepository
import openfoodfacts.github.scrachx.openfood.utils.*
import openfoodfacts.github.scrachx.openfood.utils.SearchType.*
import java.text.NumberFormat
import java.util.*
import javax.inject.Inject
@AndroidEntryPoint
class ProductSearchActivity : BaseActivity() {
private var _binding: ActivityProductBrowsingListBinding? = null
private val binding get() = _binding!!
@Inject
lateinit var client: OpenFoodAPIClient
@Inject
lateinit var productRepository: ProductRepository
@Inject
lateinit var picasso: Picasso
@Inject
lateinit var sharedPreferences: SharedPreferences
@Inject
lateinit var localeManager: LocaleManager
private lateinit var mSearchInfo: SearchInfo
private lateinit var adapter: ProductSearchAdapter
private var contributionType = 0
private var disp = CompositeDisposable()
private val lowBatteryMode by lazy { isDisableImageLoad() && isBatteryLevelLow() }
/**
* boolean to determine if image should be loaded or not
*/
private var setupDone = false
private var mCountProducts = 0
private var pageAddress = 1
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
_binding = ActivityProductBrowsingListBinding.inflate(layoutInflater)
setContentView(binding.root)
setSupportActionBar(binding.toolbarInclude.toolbar)
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
// OnClick
binding.buttonTryAgain.setOnClickListener { reloadSearch() }
binding.addProduct.setOnClickListener { addProduct() }
binding.textCountProduct.visibility = View.INVISIBLE
// Get the search information (query, title, type) that we will use in this activity
val extras = intent.extras
if (extras != null) {
mSearchInfo = extras.getParcelable(SEARCH_INFO) ?: SearchInfo.emptySearchInfo()
} else if (Intent.ACTION_VIEW == intent.action) {
// the user has entered the activity via a url
val data = intent.data
if (data != null) {
// TODO: If we open advanced search from app it redirects here
val paths = data.toString().split("/")
mSearchInfo = SearchInfo.emptySearchInfo()
if (paths[3] == "cgi" && paths[4].contains("search.pl")) {
mSearchInfo.searchTitle = data.getQueryParameter("search_terms") ?: ""
mSearchInfo.searchQuery = data.getQueryParameter("search_terms") ?: ""
mSearchInfo.searchType = SEARCH
} else {
mSearchInfo.searchTitle = paths[4]
mSearchInfo.searchQuery = paths[4]
mSearchInfo.searchType = SearchType.fromUrl(paths[3]) ?: SEARCH
}
} else {
Log.i(LOG_TAG, "No data was passed in with URL. Exiting.")
finish()
}
} else {
Log.e(LOG_TAG, "No data passed to the activity. Exiting.")
finish()
}
newSearchQuery()
binding.navigationBottom.bottomNavigation.selectNavigationItem(0)
binding.navigationBottom.bottomNavigation.installBottomNavigation(this)
}
override fun onDestroy() {
disp.dispose()
_binding = null
super.onDestroy()
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_main, menu)
val searchMenuItem = menu.findItem(R.id.action_search)
val searchView = searchMenuItem.actionView as SearchView
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String): Boolean {
mSearchInfo.searchQuery = query
mSearchInfo.searchType = SEARCH
newSearchQuery()
return true
}
override fun onQueryTextChange(newText: String) = true
})
searchMenuItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
override fun onMenuItemActionExpand(item: MenuItem) = true
override fun onMenuItemActionCollapse(item: MenuItem): Boolean {
supportActionBar?.title = ""
finish()
return true
}
})
if (CONTRIBUTOR == mSearchInfo.searchType) {
menu.findItem(R.id.action_set_type).isVisible = true
}
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
android.R.id.home -> {
finish()
true
}
R.id.action_set_type -> {
val contributionTypes = arrayOf(
getString(R.string.products_added),
getString(R.string.products_incomplete),
getString(R.string.product_pictures_contributed),
getString(R.string.picture_contributed_incomplete),
getString(R.string.product_info_added),
getString(R.string.product_info_tocomplete)
)
MaterialDialog.Builder(this).apply {
title(R.string.show_by)
items(*contributionTypes)
itemsCallback { _, _, position, _ ->
contributionType = when (position) {
1, 2, 3, 4, 5 -> position
else -> 0
}
newSearchQuery()
}
}.show()
true
}
else -> super.onOptionsItemSelected(item)
}
}
private fun setupHungerGames() {
val actualCountryTag = sharedPreferences.getString(getString(R.string.pref_country_key), "")
if (actualCountryTag.isNullOrBlank()) {
lifecycleScope.launch {
val url = productRepository.getCountryByCC2OrWorld(localeManager.getLocale().country).awaitSingleOrNull()?.tag ?: "en:world"
withContext(Dispatchers.Main) { setupUrlHungerGames(url) }
}
} else {
setupUrlHungerGames(actualCountryTag)
}
}
private fun setupUrlHungerGames(countryTag: String?) {
val url =
"https://hunger.openfoodfacts.org/questions?type=${mSearchInfo.searchType.url}&value_tag=${mSearchInfo.searchQuery}&country=$countryTag".toUri()
val builder = CustomTabsIntent.Builder()
val customTabsIntent = builder.build()
binding.btnHungerGames.visibility = View.VISIBLE
binding.btnHungerGames.text = resources.getString(R.string.hunger_game_call_to_action, mSearchInfo.searchTitle)
binding.btnHungerGames.setOnClickListener {
CustomTabActivityHelper.openCustomTab(this, customTabsIntent, url, null)
}
}
private fun newSearchQuery() {
supportActionBar?.title = mSearchInfo.searchTitle
when (mSearchInfo.searchType) {
BRAND -> {
supportActionBar!!.setSubtitle(R.string.brand_string)
setupHungerGames()
}
LABEL -> {
supportActionBar!!.subtitle = getString(R.string.label_string)
setupHungerGames()
}
CATEGORY -> {
supportActionBar!!.subtitle = getString(R.string.category_string)
setupHungerGames()
}
COUNTRY -> supportActionBar!!.setSubtitle(R.string.country_string)
ORIGIN -> supportActionBar!!.setSubtitle(R.string.origin_of_ingredients)
MANUFACTURING_PLACE -> supportActionBar!!.setSubtitle(R.string.manufacturing_place)
ADDITIVE -> supportActionBar!!.setSubtitle(R.string.additive_string)
SEARCH -> supportActionBar!!.setSubtitle(R.string.search_string)
STORE -> supportActionBar!!.setSubtitle(R.string.store_subtitle)
PACKAGING -> supportActionBar!!.setSubtitle(R.string.packaging_subtitle)
CONTRIBUTOR -> supportActionBar!!.subtitle = getString(R.string.contributor_string)
ALLERGEN -> supportActionBar!!.subtitle = getString(R.string.allergen_string)
INCOMPLETE_PRODUCT -> supportActionBar!!.title = getString(R.string.products_to_be_completed)
STATE -> {
// TODO: 26/07/2020 use resources
supportActionBar!!.subtitle = "State"
}
TRACE -> supportActionBar!!.setSubtitle(R.string.traces)
else -> error("No match case found for ${mSearchInfo.searchType}")
}
binding.progressBar.visibility = View.VISIBLE
reloadSearch()
}
private fun reloadSearch() {
binding.offlineCloudLinearLayout.visibility = View.INVISIBLE
binding.textCountProduct.visibility = View.INVISIBLE
binding.noResultsLayout.visibility = View.INVISIBLE
pageAddress = 1
loadDataFromAPI()
}
/**
* When no matching products are found in the database then noResultsLayout is displayed.
* This method is called when the user clicks on the add photo button in the noResultsLayout.
*/
private fun addProduct() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
MaterialDialog.Builder(this)
.title(R.string.action_about)
.content(R.string.permission_camera)
.neutralText(android.R.string.ok)
.onNeutral { _, _ -> ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.CAMERA), MY_PERMISSIONS_REQUEST_CAMERA) }
.show()
} else {
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.CAMERA), MY_PERMISSIONS_REQUEST_CAMERA)
}
} else {
val intent = Intent(this, ContinuousScanActivity::class.java)
startActivity(intent)
}
}
fun loadDataFromAPI() {
val searchQuery = mSearchInfo.searchQuery
when (mSearchInfo.searchType) {
BRAND -> client.getProductsByBrand(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_brand_products)
COUNTRY -> client.getProductsByCountry(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_country_products)
ORIGIN -> client.getProductsByOrigin(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_country_products)
MANUFACTURING_PLACE -> client.getProductsByManufacturingPlace(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_country_products)
ADDITIVE -> client.getProductsByAdditive(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_additive_products)
STORE -> client.getProductsByStore(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_store_products)
PACKAGING -> client.getProductsByPackaging(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_packaging_products)
SEARCH -> {
if (isBarcodeValid(searchQuery)) {
client.openProduct(searchQuery, this)
} else {
client.searchProductsByName(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_products, R.string.txt_broaden_search)
}
}
LABEL -> client.getProductsByLabel(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_label_products)
CATEGORY -> client.getProductsByCategory(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching__category_products)
ALLERGEN -> client.getProductsByAllergen(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_allergen_products)
CONTRIBUTOR -> loadDataForContributor(searchQuery)
STATE -> client.getProductsByStates(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_allergen_products)
// Get Products to be completed data and input it to loadData function
INCOMPLETE_PRODUCT -> client.getIncompleteProducts(pageAddress)
.startSearch(R.string.txt_no_matching_incomplete_products)
else -> Log.e("Products Browsing", "No match case found for " + mSearchInfo.searchType)
}
}
private fun Single<Search>.startSearch(@StringRes noMatchMsg: Int, @StringRes extendedMsg: Int = -1) {
observeOn(AndroidSchedulers.mainThread()).subscribe { search, throwable ->
displaySearch(throwable == null, search, noMatchMsg, extendedMsg)
}.addTo(disp)
}
private fun loadDataForContributor(searchQuery: String) {
when (contributionType) {
1 -> client.getToBeCompletedProductsByContributor(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_contributor_products)
2 -> client.getPicturesContributedProducts(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_contributor_products)
3 -> client.getPicturesContributedIncompleteProducts(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_contributor_products)
4 -> client.getInfoAddedProducts(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_contributor_products)
5 -> client.getInfoAddedIncompleteProductsSingle(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_contributor_products)
else -> client.getProductsByContributor(searchQuery, pageAddress)
.startSearch(R.string.txt_no_matching_contributor_products)
}
}
private fun showResponse(isResponseOk: Boolean, response: Search?) {
if (isResponseOk && response != null) {
showSuccessfulResponse(response)
} else {
showOfflineCloud()
}
}
private fun showSuccessfulResponse(response: Search) {
mCountProducts = response.count.toInt()
if (pageAddress == 1) {
val number = NumberFormat.getInstance(Locale.getDefault()).format(response.count.toLong())
binding.textCountProduct.text = "${resources.getString(R.string.number_of_results)} $number"
val products: MutableList<SearchProduct?> = response.products.toMutableList()
if (products.size < mCountProducts) {
products += null
}
if (setupDone) {
adapter = ProductSearchAdapter(products, lowBatteryMode, this, picasso, client, localeManager)
binding.productsRecyclerView.adapter = adapter
}
setUpRecyclerView(products)
} else if (adapter.products.size - 1 < mCountProducts + 1) {
val posStart = adapter.itemCount
adapter.products.removeAt(adapter.itemCount - 1)
adapter.products += response.products
if (adapter.products.size < mCountProducts) {
adapter.products += null
}
adapter.notifyItemRangeChanged(posStart - 1, adapter.products.size - 1)
}
}
private fun showOfflineCloud() {
binding.swipeRefresh.isRefreshing = false
binding.textCountProduct.visibility = View.GONE
binding.productsRecyclerView.visibility = View.INVISIBLE
binding.progressBar.visibility = View.INVISIBLE
binding.offlineCloudLinearLayout.visibility = View.VISIBLE
}
/**
* Shows UI indicating that no matching products were found.
*
* Called by [displaySearch].
*
* @param message message to display when there are no results for given search
* @param extendedMessage additional message to display, -1 if no message is displayed
*/
private fun showEmptyResponse(@StringRes message: Int, @StringRes extendedMessage: Int) {
binding.swipeRefresh.isRefreshing = false
binding.productsRecyclerView.visibility = View.INVISIBLE
binding.progressBar.visibility = View.INVISIBLE
binding.offlineCloudLinearLayout.visibility = View.INVISIBLE
binding.textCountProduct.visibility = View.GONE
binding.textNoResults.setText(message)
if (extendedMessage != -1) binding.textExtendSearch.setText(extendedMessage)
binding.noResultsLayout.bringToFront()
binding.noResultsLayout.visibility = View.VISIBLE
}
/**
* Loads the search results into the UI, otherwise shows UI indicating that no matching
* products were found.
*
* @param isResponseSuccessful true if the search response was successful
* @param response the search results
* @param emptyMessage message to display if there are no results
* @param extendedMessage extended message to display if there are no results
*/
private fun displaySearch(
isResponseSuccessful: Boolean,
response: Search?,
@StringRes emptyMessage: Int,
@StringRes extendedMessage: Int = -1
) = if (response == null) {
showResponse(isResponseSuccessful, null)
} else {
val count = try {
response.count.toInt()
} catch (e: NumberFormatException) {
throw NumberFormatException("Cannot parse ${response.count}.")
}
if (!isResponseSuccessful || count != 0) {
showResponse(isResponseSuccessful, response)
} else {
showEmptyResponse(emptyMessage, extendedMessage)
}
}
private fun setUpRecyclerView(mProducts: MutableList<SearchProduct?>) {
binding.swipeRefresh.isRefreshing = false
binding.progressBar.visibility = View.INVISIBLE
binding.offlineCloudLinearLayout.visibility = View.INVISIBLE
binding.textCountProduct.visibility = View.VISIBLE
binding.productsRecyclerView.visibility = View.VISIBLE
if (!setupDone) {
binding.productsRecyclerView.setHasFixedSize(true)
val mLayoutManager = LinearLayoutManager(this@ProductSearchActivity, LinearLayoutManager.VERTICAL, false)
binding.productsRecyclerView.layoutManager = mLayoutManager
adapter = ProductSearchAdapter(mProducts, lowBatteryMode, this, picasso, client, localeManager)
binding.productsRecyclerView.adapter = adapter
val dividerItemDecoration = DividerItemDecoration(binding.productsRecyclerView.context, DividerItemDecoration.VERTICAL)
binding.productsRecyclerView.addItemDecoration(dividerItemDecoration)
// Retain an instance so that you can call `resetState()` for fresh searches
// Adds the scroll listener to RecyclerView
binding.productsRecyclerView.addOnScrollListener(object : EndlessRecyclerViewScrollListener(mLayoutManager) {
override fun onLoadMore(page: Int, totalItemsCount: Int, view: RecyclerView) {
if (mProducts.size < mCountProducts) {
pageAddress = page
loadDataFromAPI()
}
}
})
binding.productsRecyclerView.addOnItemTouchListener(RecyclerItemClickListener(this) { _, position ->
val product = adapter.getProduct(position) ?: return@RecyclerItemClickListener
val barcode = product.code
if (Utils.isNetworkConnected(this)) {
client.openProduct(barcode, this)
try {
val viewWithFocus = currentFocus
if (viewWithFocus != null) {
val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(viewWithFocus.windowToken, 0)
}
} catch (e: NullPointerException) {
Log.e(LOG_TAG, "addOnItemTouchListener", e)
}
} else {
MaterialDialog.Builder(this@ProductSearchActivity).apply {
title(R.string.device_offline_dialog_title)
content(R.string.connectivity_check)
positiveText(R.string.txt_try_again)
onPositive { _, _ ->
if (Utils.isNetworkConnected(this@ProductSearchActivity)) {
client.openProduct(barcode, this@ProductSearchActivity)
} else {
Toast.makeText(this@ProductSearchActivity, R.string.device_offline_dialog_title, Toast.LENGTH_SHORT).show()
}
}
negativeText(R.string.dismiss)
onNegative { dialog, _ -> dialog.dismiss() }
}.show()
}
return@RecyclerItemClickListener
})
binding.swipeRefresh.setOnRefreshListener {
mProducts.clear()
adapter.notifyDataSetChanged()
binding.textCountProduct.text = resources.getString(R.string.number_of_results)
pageAddress = 1
reloadSearch()
if (binding.swipeRefresh.isRefreshing) {
binding.swipeRefresh.isRefreshing = false
}
}
}
setupDone = true
binding.swipeRefresh.setOnRefreshListener {
binding.swipeRefresh.isRefreshing = true
pageAddress = 1
reloadSearch()
}
}
companion object {
/**
* Must be public to be visible by TakeScreenshotIncompleteProductsTest class.
*/
const val SEARCH_INFO = "search_info"
/**
* Start a new [ProductSearchActivity] given a search information
*
* @param context the context to use to start this activity
* @param searchQuery the search query
* @param searchTitle the title used in the activity for this search query
* @param type the type of search
*/
@JvmStatic
fun start(context: Context, type: SearchType, searchQuery: String, searchTitle: String = searchQuery) {
start(context, SearchInfo(type, searchQuery, searchTitle))
}
/**
* @see [start]
*/
@JvmStatic
private fun start(context: Context, searchInfo: SearchInfo) {
context.startActivity(Intent(context, ProductSearchActivity::class.java).apply {
putExtra(SEARCH_INFO, searchInfo)
})
}
private val LOG_TAG: String = this::class.simpleName!!
}
}