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:BaseContactor<*>, reified Y:BasePresenter<*>>RecyclerView.loadData(contactor:Class<T>, presenter:Class<Y>) { | |
| val pres = presenter.asSubclass(presenter).getConstructor(Context::class.java, this::class.java).newInstance(this.context, this) | |
| contactor.asSubclass(contactor).getConstructor(presenter).newInstance(pres).execute() | |
| } |
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 ListJiwaPresenter (context: Context, val recyclerView: RecyclerView?):BasePresenter<MutableList<Jiwa>>(context) { | |
| override fun onSuccess(data: MutableList<Jiwa>?) { | |
| recyclerView?.layoutManager = LinearLayoutManager(recyclerView?.context, LinearLayoutManager.VERTICAL, false) | |
| recyclerView?.adapter = ListJiwaAdapter(data) | |
| } | |
| override fun onError(message: String?) { | |
| Terpaksa error "Gagal mengambil data Jiwa" | |
| } |
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
| abstract class BasePresenter<T>(val context: Context?) { | |
| val progress:ProgressDialog | |
| init { | |
| progress = ProgressDialog(context) | |
| } | |
| fun showProgress(show: Boolean = false) { | |
| if (show) progress.show() | |
| else progress.dismiss() | |
| } | |
| abstract fun onSuccess(data:T?) |
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 ListJiwaContactorImpl(handler: ListJiwaPresenter) : BaseContactor<MutableList<Jiwa>>(handler){ | |
| override fun prepareCaller(): Call<MutableList<Jiwa>> { | |
| return api.getJiwa() | |
| } | |
| } |
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
| abstract class BaseContactor<T>(val handler:BasePresenter<T>?) { | |
| private val interceptor = HttpLoggingInterceptor() | |
| private val retrofit: Retrofit | |
| private val client: OkHttpClient | |
| protected val api: Api | |
| init { | |
| interceptor.level = HttpLoggingInterceptor.Level.BODY | |
| client = OkHttpClient.Builder().addInterceptor(interceptor).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
| class SalesAPI(Resource): | |
| def get(self): | |
| auth, message, code, user = authenticated(request.headers.get('Authorization')) | |
| if not auth: | |
| return message, code | |
| if not user: | |
| return {'status': 'INTERNAL SERVER ERROR', 'message': 'Failed to get user information'} | |
| # items = [] |
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 DoSomethingInJava { | |
| public double sumAllNumberInString(String text) { | |
| /* #TODO | |
| * Implementasikan kode untuk menjumlahkan semua angka yang ditemukan pada parameter 'text' | |
| * Misalkan, text berisi string = "12 bisa didapatkan dari perkalian 3 dengan 4" | |
| * maka, hasil yang seharusnya didapatkan adalah 19 dimana 19 = 12 + 3 + 4 | |
| * pastikan hasilnya dilewatkan sebagai return value methode ini. | |
| */ | |
| // implementasikan di sini | |
| } |
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
| <?php | |
| if (isset($_POST['submit'])) { | |
| $Fname = $_POST['fname']; | |
| $Lname = $_POST['lname']; | |
| $fp = fopen("input.txt","a");// Open data.txt for writing | |
| if(!$fp) { | |
| echo 'Error, the file could not be opened or there was an error creating it.'; | |
| exit; | |
| } | |
| if(@fwrite($fp, $Fname.'|'.$Lname."\n")){ |
NewerOlder