Skip to content

Instantly share code, notes, and snippets.

View KucherenkoIhor's full-sized avatar

Ihor Kucherenko KucherenkoIhor

View GitHub Profile
extern "C" {
#include <libavutil/timestamp.h>
#include <libavformat/avformat.h>
#include <libavutil/display.h>
}
export default function loginReducer(state, action = {}) {
switch (action.type) {
case actions.ACTION_LIST_ERROR:
return state.withMutations(state => state.set('loginError', action.error));
case actions.ACTION_LIST_SUCCESS:
const data = action.page === 1 ? action.list : state.get('data').concat(action.list);
return state.withMutations(state => state.set('data', data));
default:
return state
}
function todoApp(state = initialState, action) {
switch (action.type) {
case SET_VISIBILITY_FILTER:
return { ...state, visibilityFilter: action.filter }
default:
return state
}
}
export function* loginFlow() {
while (true) {
const {username, password} = yield take(actions.LOGIN_ACTION);
yield put({type: actions.PROGRESS, progress: true});
yield call(authorize, username, password);
yield put({type: actions.PROGRESS, progress: false});
}
}
export default class RepositoryListItem extends React.PureComponent {
_onPress = () => {
const {navigate} = this.props.navigation;
navigate(consts.REPOSITORY_DETAILS_SCREEN, {repository: this.props.repository})
};
render() {
return (
<TouchableHighlight onPress={this._onPress}>
@Test
fun storeListener() {
val valueInt = 3
val keyInt = "integer"
val valueString = "value"
val keyString = "string"
store.listeners.add(object : StoreListener {
override fun onIntegerSet(key: String, value: Int) {
assertEquals(keyInt, key)
JNIEXPORT void JNICALL
Java_com_ihorkucherenko_storage_Store_setString(
JNIEnv* pEnv,
jobject pThis,
jstring pKey,
jstring pString) {
// Turns the Java string into a temporary C string.
StoreEntry* entry = allocateEntry(pEnv, &gStore, pKey);
if (entry != NULL) {
entry->mType = StoreType_String;
interface StoreListener {
fun onIntegerSet(key: String, value: Int)
fun onStringSet(key: String, value: String)
}
class Store : StoreListener {
val listeners = mutableListOf<StoreListener>()
jclass clazz = env->FindClass("com/ihorkucherenko/storage/Store");
jmethodID constructor = env->GetMethodID(clazz, "<init>", "()V");
jobject storeObject = env->NewObject(clazz, constructor);
jmethodID methodId = env->GetMethodID(clazz, "getSomething", "()I");
jint value = env->CallIntMethod(storeObject, methodId);
__android_log_print(ANDROID_LOG_INFO, __FUNCTION__, "value: %d ", value); //value: 3
jclass clazz = env->FindClass("com/ihorkucherenko/storage/Store");
jmethodID constructor = env->GetMethodID(clazz, "<init>", "()V");
jobject storeObject = env->NewObject(clazz, constructor);
jfieldID fieldId = env->GetFieldID(clazz, "property", "I");
jint value = env->GetIntField(storeObject, fieldId);
__android_log_print(ANDROID_LOG_INFO, __FUNCTION__, "Property value: %d ", value); //Property value: 3