This file contains hidden or 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
| object MyService { | |
| private val TIMEOUTOFSECOND = 12 | |
| private val _instanceOfService: Service by lazy { setupHttpClient() } | |
| fun on(): Service { | |
| return _instanceOfService | |
| } |
This file contains hidden or 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
| interface Service { | |
| @FormUrlEncoded | |
| @POST("info/getInfoDetail") | |
| fun GetInfoDetail(@FieldMap params: HashMap<String, Any>): Call<InfoDetailObject> | |
| @GET("search/{search_word}") | |
| fun getSuggestSearchWords(@Path("search_word") search_word: String): Call<SearchWorObject> |
This file contains hidden or 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 MyApplication : Application() { | |
| //sample usage : MyApplication.context | |
| override fun onCreate() { | |
| super.onCreate() | |
| instance = this | |
| } | |
| companion object { |
This file contains hidden or 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
| package com.samclarke.android.util | |
| import java.security.MessageDigest | |
| /** | |
| * Hashing Utils | |
| * @author Sam Clarke <www.samclarke.com> | |
| * @license MIT | |
| */ | |
| object HashUtils { |
This file contains hidden or 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
| if (supportFragmentManager.findFragmentByTag("searchfragment") != null) { // to kill a specific Fragment | |
| supportFragmentManager().popBackStack(); | |
| } else { | |
| //Do Something | |
| } | |
| private fun closeFragments() { | |
| repeat(supportFragmentManager.backStackEntryCount) { | |
| supportFragmentManager.popBackStack() |
This file contains hidden or 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
| inline fun <reified T : kotlin.Enum<T>> safeEnumValueOf(type: String?,defaultEnum:T): T { | |
| return try { | |
| java.lang.Enum.valueOf(T::class.java, type) | |
| } catch (e: Exception) { | |
| defaultEnum | |
| } | |
| } |
This file contains hidden or 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
| fun sureChildViewVisibleOnScreen(childView: View, parenView: View): Boolean { | |
| val scrollBounds = Rect() | |
| parenView.getHitRect(scrollBounds) | |
| return childView.getLocalVisibleRect(scrollBounds) // if childView visible return true else false | |
| } |
This file contains hidden or 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 = [MyModelClass]() | |
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| let cell = tableView.dequeueReusableCell(withIdentifier: "TableCell") as! TableCell | |
| let position = indexPath.row | |
| let item = items?[position] | |
| //click event for label | |
| let labelRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.tableViewLabelClick)) | |
| cell.Label?.isUserInteractionEnabled = true |
OlderNewer