Skip to content

Instantly share code, notes, and snippets.

View senneco's full-sized avatar

Yuri Shmakov senneco

View GitHub Profile
public class Temp {
public View showFloatingView(View contentView)
{
final View floatingView = ((LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE)).inflate(R.layout.view_floating, null);
final WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
final WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
import java.util.Iterator;
import java.util.List;
import com.arellomobile.mvp.MvpView;
import com.arellomobile.mvp.viewstate.ViewCommand;
import com.arellomobile.mvp.viewstate.strategy.StateStrategy;
public class AddToEndSingleByTagStateStrategy implements StateStrategy {
@Override
class AccountHolder extends MvpViewHolder implements AccountView {
@InjectPresenter
AccountPresenter mAccountPresenter;
/**
@BindView(R.id.item_account_check_box)
CheckBox mCheckBox;
...
**/
public class ScanInteractor {
private final DevicesManager devicesManager;
public ScanInteractor() {
devicesManager = DevicesManager.getInstance();
}
public Observable<ScanResultData> getDevices() {
return devicesManager
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;
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);
@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 PlayerActivity extends MvpAppCompatActivity implements PlayerView {
@InjectPresenter
PlayerPresenter mPlayerPresenter;
Player mPlayer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@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;
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;