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
public interface TaskQueue<T> { | |
void add(Task<T> task); | |
public interface TaskCallback { | |
void onSuccess(List<T> result); | |
void onError(List<T> result, Exception e); | |
} | |
void execute(TaskCallback callback); | |
void notifyResult(T result); | |
void notifyError(Exception e); |
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 MyItemDAO { | |
public interface UploadAllListener { | |
void onSuccess(int count); | |
void onError(int count, Exception e); | |
} | |
private final KiiVolleyAPI mAPI; | |
void uploadAll(List<MyItem> list, UploadAllListener callback) { | |
uploadAll(list, 0, callback); | |
} |
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 java.util.List; | |
import java.util.ArrayList; | |
public class ListApp { | |
public static void main(String[] args) { | |
// Stringが入ってるリストを作る | |
List<String> nameList = new ArrayList<String>(); | |
nameList.add("fkm"); | |
nameList.add("mhidaka"); | |
nameList.add("vvakame"); |
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
// CoinType.java | |
public enum CoinType { | |
YEN1(1), | |
YEN5(5), | |
YEN10(10), | |
YEN50(50), | |
YEN100(100), | |
YEN500(500), | |
; | |
// この硬貨の価格 |
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
// service/user.go | |
type UserService interface { | |
Create(email, password string) Result | |
} | |
// model/user.go | |
type UserDAO interface { | |
Create(email, password string) (*User, error) | |
} |
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
func newCreateUserHandler(service func(email, password string) Result) func(xxxx) { | |
return func(xxx) { | |
email := // read from request | |
password := // read from request | |
r := service(email, password) | |
// write to response | |
} | |
} | |
func newCreateUserService(dao UserDAO) func(email, password string) Result { |
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
int result; | |
void someFunc(int arg) { | |
// 何か処理 | |
result = 結果; | |
} | |
int main() { | |
someFunc(); | |
// 結果はグローバル変数に入ってる |
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
// クラスの定義をこんな感じにする | |
package jp.fkmsoft.demo; | |
public class MyClass { | |
public static class Inner { | |
} | |
} | |
// case 1 |
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
public void set(User value) { | |
KVS<User> kvs = new KVSImpl(getContext()); | |
kvs.put("key", value); | |
kvs.commit(); | |
kvs.close(); | |
} | |
public User get(String key) { | |
KVS<User> kvs = new KVSImpl(getContext()); | |
User user = kvs.get(key); |
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
public class MyDialogFragment extends DialogFragment { | |
public statci MyDialogFragment newInstance(Fragment target, int requestCode) { | |
MyDialogFragment fragment = new MyDialogFragment(); | |
fragment.setTargetFragment(target, requestCode); | |
return fragment; | |
} | |
@Override | |
public Dialog onCreateDialog(Bundle savedInstanceState) { | |
Dialog dialog = new Dialog(getActivity()); |
NewerOlder