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.bd.network | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
val response = fetchData() | |
when (response) { |
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
Add base fragment : backStackManager?.addBaseFragment(showcaseFragment, R.id.home) | |
Add subFragment : backStackManager?.loadFragmentAndAddToBackStack(fragment = event.fragment) | |
backStackManager?.loadFragmentAndAddToBackStack(fragment = event.fragment,menuId = event.menuId) | |
Pop Backstack : backStackManager?.popFragmentBackStack(activeMenuId) | |
Switch Menu : private fun switchMenu(activeMenuId: Int,targetMenuId: Int) { //Should invoke in navigationViewSelectedListener. |
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
public class CountryFlags { | |
private static String A = getEmojiByUnicode(0x1F1E6); | |
private static String B = getEmojiByUnicode(0x1F1E7); | |
private static String C = getEmojiByUnicode(0x1F1E8); | |
private static String D = getEmojiByUnicode(0x1F1E9); | |
private static String E = getEmojiByUnicode(0x1F1EA); | |
private static String F = getEmojiByUnicode(0x1F1EB); | |
private static String G = getEmojiByUnicode(0x1F1EC); | |
private static String H = getEmojiByUnicode(0x1F1ED); | |
private static String I = getEmojiByUnicode(0x1F1EE); |
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
data class User(var name:String,var list:List<User>) : Serializable | |
fun <T:Serializable?>T.deepCopy(): T? { | |
if (this == null) return null | |
val baos = ByteArrayOutputStream() | |
val oos = ObjectOutputStream(baos) | |
oos.writeObject(this) | |
oos.close() | |
val bais = ByteArrayInputStream(baos.toByteArray()) |
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 String.isValidTcNo(): Boolean { | |
val tcNo = this.trim() | |
if (tcNo.length != 11) | |
return false | |
if (tcNo.startsWith("0")) | |
return false | |
if (!tcNo.matches("[0-9]+".toRegex())) | |
return false | |
val tcNoArray = tcNo.map { it.toString().toInt() } | |
if (tcNoArray[9] != (((7 * (tcNoArray[0] + tcNoArray[2] + tcNoArray[4] + tcNoArray[6]+ tcNoArray[8])) - (tcNoArray[1] + tcNoArray[3]+ tcNoArray[5] + tcNoArray[7])) % 10)) |
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
// | |
// CurrencyEditField.swift | |
// TSoftShopper | |
// | |
// Created by Burak Dizlek on 12.06.2019. | |
// Copyright © 2019 Burak Dizlek. All rights reserved. | |
// | |
import Foundation |
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 |
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
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
if (supportFragmentManager.findFragmentByTag("searchfragment") != null) { // to kill a specific Fragment | |
supportFragmentManager().popBackStack(); | |
} else { | |
//Do Something | |
} | |
private fun closeFragments() { | |
repeat(supportFragmentManager.backStackEntryCount) { | |
supportFragmentManager.popBackStack() |
NewerOlder