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
apply plugin: 'com.android.application' | |
apply plugin: 'kotlin-android' | |
apply plugin: 'kotlin-android-extensions' | |
apply plugin: 'kotlin-kapt' | |
kotlin { | |
experimental { | |
coroutines "enable" | |
} | |
} |
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 HomeViewModel: ViewModel(){ | |
// Initialize LiveData and MutableLiveData | |
private val actor = actor<Action>(UI, Channel.CONFLATED) { | |
for (action in this) when (action) { | |
is Loadjadwal -> { | |
mutableLoading.value = true | |
try { |
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 HomeViewModel: ViewModel(){ | |
private var mutableJadwal = MutableLiveData<Jadwal>().apply{ value = null } | |
private var mutableLoading = MutableLiveData<Boolean>().apply{ value = false } | |
private var mutableMessage = MutableLiveData<String>().apply{ value = "" } | |
var jadwal :LiveData<Jadwal> = mutableJadwal | |
var loading :LiveData<Boolean> = mutableLoading | |
var message :LiveData<String> = mutableMessage |
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 HomeActivity : AppCompatActivity(), LifecycleOwner{ | |
private var viewModel = HomeViewModel() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_home) | |
viewModel = ViewModelProviders.of(this).get(HomeViewModel::class.java) | |
viewModel.loading.observe(this, Observer { displayLoading(it ?: false) }) |
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 JadwalSholatRepository{ | |
suspend fun getAllCity(): List<City> | |
= JadwalSholatApi.service.getAllCity().await() | |
suspend fun getJadwalByCityId(cityId: String) | |
= JadwalSholatApi.service.getJadwalByCityId(cityId).await() | |
suspend fun getJadwalDefault() |
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
import android.os.Bundle | |
import android.support.design.widget.FloatingActionButton | |
import android.support.v7.app.AppCompatActivity | |
import android.support.v7.widget.Toolbar | |
import android.view.Menu | |
import android.view.MenuItem | |
import com.github.ksoichiro.android.observablescrollview.ObservableListView | |
import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks | |
import com.github.ksoichiro.android.observablescrollview.ScrollState |
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
var timeFrame = 500 | |
this.timer = setInterval(() => { | |
if (this.state.progress == 1) { | |
clearInterval(this.timer); | |
setTimeout(() => { | |
//When delay is finish do something | |
}, timeFrame) | |
} else { | |
let random = Math.random() * 0.5; | |
let progress = this.state.progress + random; |
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
<?php | |
namespace TikiOngkir; | |
use Symfony\Component\DomCrawler\Crawler; | |
/** | |
* Tiki Provider | |
*/ | |
class Tiki { |
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
<?php | |
/** | |
* @author Ammar F. <[email protected]> | |
*/ | |
$_p['value(user_id)'] = ""; // username | |
$_p['value(pswd)'] = ""; // password | |
$_p['value(Submit)'] = "LOGIN"; | |
$a=curl("https://m.klikbca.com/login.jsp"); | |
$a = explode('type="hidden"', $a); | |
for ($i=1;$i<count($a);$i++) { |
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
/* | |
* Return user short name | |
* */ | |
public static String getShortName(String name) { | |
String[] strings = name.split(" ");//no i18n | |
String shortName; | |
if (strings.length == 1) { | |
shortName = strings[0].substring(0, 2); | |
} else { | |
shortName = strings[0].substring(0, 1) + strings[1].substring(0, 1); |