Skip to content

Instantly share code, notes, and snippets.

View senneco's full-sized avatar

Yuri Shmakov senneco

View GitHub Profile
RestAdapter restAdapter = RestApi.init(this, sCurrentUrl);
final ServiceApi serverApi = restAdapter.create(ServiceApi.class);
mServiceApi = (ServiceApi) Proxy.newProxyInstance(ServiceApi.class.getClassLoader(), new Class<?>[]{ServiceApi.class},
new InvocationHandler()
{
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
final Method serviceApiMethod = serviceApi.getClass().getMethod(method.getName(), method.getParameterTypes());
private static class InlineConverter extends GsonConverter
{
private static String sGuid = null;
private static final String CHARSET = "UTF-8";
private final RequestHeader mRequestHeader;
private final DeviceGuid mDeviceGuid;
private final Gson mGson;
public InlineConverter(Gson gson, String appVersion)
package com.altaine.wagamama.ui.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.arellomobile.mvp.MvpDelegate;
@senneco
senneco / FixedMvpDelegate.java
Last active June 9, 2016 17:27
Fix bug of mvp delegate
package com.arellomobile.mvp;
import java.util.ArrayList;
import java.util.List;
import android.os.Bundle;
import com.arellomobile.mvp.presenter.PresenterType;
/**
package net.senneco.weatherapp.mvp.presenter;
import com.arellomobile.mvp.InjectViewState;
import com.arellomobile.mvp.MvpPresenter;
import net.senneco.weatherapp.app.WeatherApp;
import net.senneco.weatherapp.mvp.common.WeatherAppSchedulers;
import net.senneco.weatherapp.mvp.model.data.City;
import net.senneco.weatherapp.mvp.model.repository.Repository;
import net.senneco.weatherapp.mvp.view.CitiesView;
@senneco
senneco / HelloActivity.java
Created October 25, 2016 14:06
Extra-minimal Moxy sample
package net.senneco.devfest;
import android.os.Bundle;
import android.support.annotation.StringRes;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.arellomobile.mvp.MvpAppCompatActivity;
import com.arellomobile.mvp.presenter.InjectPresenter;
public class PlayerActivity extends MvpAppCompatActivity implements PlayerView {
@InjectPresenter
PlayerPresenter mPlayerPresenter;
Player mPlayer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@senneco
senneco / MoneyWatcher.java
Last active November 8, 2016 06:47
This watchers format entered value as # ###,##. Backspace working right every time
public class Watcher implements TextWatcher {
private static final char THOUSANDS_SEPARATOR = ' ';
private static final char FRACTION_SEPARATOR = ',';
private boolean mIsSpaceRemoved;
private int mRemovedSpacePosition;
private EditText mValueEditText;
private InputFilter[] mFilters;
public Watcher(EditText valueEditText) {
public class DefaultStateStrategy implements StateStrategy {
@Override
public <View extends MvpView> void beforeApply(List<ViewCommand<View>> currentState, ViewCommand<View> incomingCommand) {
MvpFacade.getDefaultStrategy().beforeApply(currentState, incomingCommand);
}
@Override
public <View extends MvpView> void afterApply(List<ViewCommand<View>> currentState, ViewCommand<View> incomingCommand) {
MvpFacade.getDefaultStrategy().afterApply(currentState, incomingCommand);
public abstract class ViewCommand<View extends MvpView> {
private final String mTag;
private final Class<? extends StateStrategy> mStateStrategyType;
protected ViewCommand(String tag) {
this(tag, MvpFacade.getDefaultStrategyClass());
}
protected ViewCommand(String tag, Class<? extends StateStrategy> stateStrategyType) {
mTag = tag;