Skip to content

Instantly share code, notes, and snippets.

View malikkurosaki's full-sized avatar
💭
NextJs On Fire

malik kurosaki malikkurosaki

💭
NextJs On Fire
View GitHub Profile
@malikkurosaki
malikkurosaki / upload_firebase.java
Last active October 8, 2018 05:09
malikkurosaki firebase storage upload file
if (ImagePicker.shouldHandle(requestCode, resultCode, data)) {
Image image = ImagePicker.getFirstImageOrNull(data);
Uri uri = Uri.fromFile(new File(image.getPath()));
StorageReference tempat = storageReference.child("user").child(auth.getUid()).child("profil.jpg");
UploadTask uploadTask = tempat.putFile(uri);
uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Log.d("BERHASIL","adalah:"+taskSnapshot);
@malikkurosaki
malikkurosaki / imagePicker.java
Created September 21, 2018 12:20
android studio image picker
Intent ambilGambar = new Intent(Intent.ACTION_PICK);
ambilGambar.setType("image/*");
startActivityForResult(ambilGambar,PILIH_PHOTO);
//
@malikkurosaki
malikkurosaki / model.js
Created September 21, 2018 12:21
contoh model object javascrip
// object model
var objectModel = {
nama:"paijo",
satu:function(){
this.nama += "gunawan";
},
get namaNya(){
return this.nama;
@malikkurosaki
malikkurosaki / callback.java
Created September 22, 2018 13:38
android studio callback simple function
This is a classic issue with asynchronous web APIs. You cannot return something now that hasn't been loaded yet. With other words, you cannot simply create a global variable and use it outside onDataChange() method because it will always be null. This is happening because onDataChange() method is called asynchronous. Depending on your connection speed and the state, it may take from a few hundred milliseconds to a few seconds before that data is available.
But not only Firebase Realtime Database loads data asynchronously, almost all of modern other web APIs do, since it may take some time. So instead of waiting for the data (which can lead to unresponsive application dialogs for your users), your main application code continues while the data is loaded on a secondary thread. Then when the data is available, your onDataChange() method is called and can use the data. With other words, by the time onDataChange() method is called your data is not loaded yet.
Let's take an example, by placing a few log statemen
@malikkurosaki
malikkurosaki / gradient.xml
Created September 23, 2018 07:42
android studio gradient color
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="@color/colorBiru" android:centerColor="@color/colorTransparant" android:endColor="@color/colorTransparant" android:angle="270"/>
</shape>
@malikkurosaki
malikkurosaki / border.xml
Created September 23, 2018 07:43
android studio create border
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="@color/colorTransparant">
</solid>
<corners android:radius="10dp">
</corners>
<stroke android:width="1dp" android:color="@color/colorBiru" >
</stroke>
</shape>
@malikkurosaki
malikkurosaki / MainActivity_backup1.java
Created September 23, 2018 08:31
backup for ignore eror
package com.malik.rajapickup;
import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
@malikkurosaki
malikkurosaki / onclick.java
Created September 24, 2018 02:56
custome onclik listener
private OnClickListener btnClick = new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
};
//passing listener object to button
make_move.setOnClickListener(btnClick);
@malikkurosaki
malikkurosaki / manifest.xml
Created September 24, 2018 03:42
ignore edit text covered by keyboard android
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<application ...>
<activity
android:name=".TestInputActivity"
android:label="@string/title_activity_test_input"
android:windowSoftInputMode="adjustResize"
android:theme="@style/AppTheme.NoActionBar">
</activity>
</application>
@malikkurosaki
malikkurosaki / errorMessage.java
Created September 24, 2018 05:29
check edit text is empty and thank push error message
if (TextUtils.isEmpty(updateEditNamaProfile.getText().toString().trim())){
updateEditNamaProfile.setError("Gak Bole Kosong");
return;
}