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
fun View.showKeyboard(context: Context) { | |
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | |
imm.showSoftInput(this, InputMethodManager.SHOW_FORCED) | |
} | |
fun View.hideKeyboard(context: Context) { | |
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | |
imm.hideSoftInputFromWindow(this.windowToken, 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
fun String.Companion.emptyString(): String { | |
return "" | |
} | |
fun String.Companion.formatDate(dateFormat: String, date: String): Date { | |
val simpleDateFormat = SimpleDateFormat(dateFormat) | |
return simpleDateFormat.parse(date) | |
} |
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
fun Fragment.slideNextFragment(fragment: Fragment, | |
@IdRes fragmentContentId: Int, | |
@AnimRes enter: Int? = null, | |
@AnimRes exit: Int? = null, | |
@AnimRes popEnter: Int? = null, | |
@AnimRes popExit: Int? = null, | |
vararg sharedElements: Pair<View, String>) { | |
if (isAdded) { | |
val fragmentTransaction = fragmentManager.beginTransaction() | |
enter?.let { exit?.let { it1 -> popEnter?.let { it2 -> popExit?.let { it3 -> fragmentTransaction.setCustomAnimations(it, it1, it2, it3) } } } } |
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
fun FragmentActivity.initialFragment(fragment: Fragment, | |
@IdRes fragmentContentId: Int) { | |
val fragmentManager = supportFragmentManager | |
val fragmentTransaction = fragmentManager.beginTransaction() | |
fragmentTransaction.add(fragmentContentId, fragment).commit() | |
} |
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
@ColorInt | |
fun Context.getColor(@ColorRes colorRes: Int): Int { | |
val color: Int | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
color = resources.getColor(colorRes, theme) | |
} else { | |
color = resources.getColor(colorRes) | |
} | |
return color | |
} |
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 BaseProjectApplication : Application() { | |
override fun onCreate() { | |
super.onCreate() | |
Fresco.initialize(this); | |
Injector.initializeApplicationComponent(this) | |
} | |
} |
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
abstract class BaseFragment : Fragment() { | |
private var unbinder: Unbinder? = null | |
@get:LayoutRes protected abstract val layout: Int | |
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
return inflater?.inflate(layout, container, false) | |
} | |
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) { |
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
abstract class BaseFragmentActivity : AppCompatActivity() { | |
private var unbinder: Unbinder? = null | |
@get:LayoutRes protected abstract val contentView: Int | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(contentView) | |
unbinder = ButterKnife.bind(this) |
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
object Injector { | |
var serviceComponent: ServiceComponent? = null | |
fun initializeApplicationComponent(application: BaseProjectApplication) { | |
serviceComponent = DaggerServiceComponent.builder() | |
.appModule(AppModule(application)) | |
.netModule(NetModule()) | |
.build() |
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
object Injector { | |
var serviceComponent: ServiceComponent? = null | |
fun initializeApplicationComponent(application: BaseProjectApplication) { | |
serviceComponent = DaggerServiceComponent.builder() | |
.appModule(AppModule(application)) | |
.preferencesModule(PreferencesModule()) | |
.netModule(NetModule()) | |
.build() |
NewerOlder