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 MainActivity : Activity() { | |
fun onCreate() { | |
val tv : TextView = findViewById(R.id.tv) | |
// ViewModel 정의 | |
val viewModel = MainViewModel() | |
// ViewModel 옵저빙 후 갱신 | |
viewModel.name.observe { | |
tv.text = it | |
} | |
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 FlowableForLifecycle { | |
fun <T> flowableForLifecycle(lifecycleOwner: LifecycleOwner, data: Flowable<T>, atLeast:Lifecycle.State = Lifecycle.State.RESUMED): Flowable<T> { | |
return Flowable.combineLatest(Flowable.create<Lifecycle.State>({ e -> | |
val observer: GenericLifecycleObserver = object : GenericLifecycleObserver { | |
override fun getReceiver(): Any = lifecycleOwner | |
override fun onStateChanged(owner: LifecycleOwner, event: Lifecycle.Event) { | |
e.takeIf { !e.isCancelled }?.onNext(owner.lifecycle.currentState) | |
if (event == Lifecycle.Event.ON_DESTROY) { | |
lifecycleOwner.lifecycle.removeObserver(this) |
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.pluu.support.tstore | |
import android.content.Context | |
import com.pluu.support.impl.AbstractWeekApi | |
import com.pluu.support.impl.NAV_ITEM | |
import com.pluu.support.impl.NetworkSupportApi | |
import com.pluu.webtoon.item.Status | |
import com.pluu.webtoon.item.WebToonInfo | |
import org.jsoup.Jsoup | |
import java.util.* |
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
apply plugin: 'me.tatarka.retrolambda' | |
android { | |
compileOptions { | |
sourceCompatibility JavaVersion.VERSION_1_8 | |
targetCompatibility JavaVersion.VERSION_1_8 | |
} | |
} | |
dependnecies { |
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 DataRepository extends RealmRepository { | |
private static DataRepository instance; | |
synchronized public static DataRepository getInstance() { | |
if (instance == null) { | |
instance = new BotRepository(); | |
} | |
return instance; | |
} |
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
// delete realm of default config | |
Realm.deleteRealm(new RealmConfiguration.Builder().build()); |
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 static void init(Context context) { | |
ActivityManager activityManager = | |
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); | |
for (ActivityManager.RunningAppProcessInfo processInfo : activityManager.getRunningAppProcesses()) { | |
if (Process.myPid() == processInfo.pid) { | |
if (TextUtils.equals(processInfo.processName, BuildConfig.APPLICATION_ID)) { | |
// initiate olny on default process of app | |
Realm.init(context); | |
Realm.setDefaultConfiguration(realmConfiguration()); | |
} |
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 MyApplication extends Application { | |
@Override | |
public void onCreate() { | |
// problem point | |
Realm.init(this); | |
} | |
} |
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
List list = Arrays.asList(A, B, C, D); | |
list.stream() |
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
// dependencies-app.gradle | |
rootProject.allprojects { project -> | |
if (project.name == 'app') { | |
project.afterEvaluate { | |
repositories { | |
jcenter() | |
} | |
dependencies { |