If you think the Android project bitfynd-wallet-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright 2014 the original author or authors.
*//www.java2s.com
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/package de.schildbach.wallet.service;
import java.util.Date;
import java.util.EnumSet;
import java.util.Set;
import android.content.Intent;
/**
* @author Andreas Schildbach
*/publicclass BlockchainState
{
privatestaticfinal String EXTRA_BEST_CHAIN_DATE = "best_chain_date";
privatestaticfinal String EXTRA_BEST_CHAIN_HEIGHT = "best_chain_height";
privatestaticfinal String EXTRA_REPLAYING = "replaying";
privatestaticfinal String EXTRA_IMPEDIMENTS = "impediment";
publicenum Impediment
{
STORAGE, NETWORK
}
publicfinal Date bestChainDate;
publicfinalint bestChainHeight;
publicfinalboolean replaying;
publicfinal EnumSet<Impediment> impediments;
public BlockchainState(final Date bestChainDate, finalint bestChainHeight, finalboolean replaying, final Set<Impediment> impediments)
{
this.bestChainDate = bestChainDate;
this.bestChainHeight = bestChainHeight;
this.replaying = replaying;
this.impediments = EnumSet.copyOf(impediments);
}
publicstatic BlockchainState fromIntent(final Intent intent)
{
final Date bestChainDate = (Date) intent.getSerializableExtra(EXTRA_BEST_CHAIN_DATE);
finalint bestChainHeight = intent.getIntExtra(EXTRA_BEST_CHAIN_HEIGHT, -1);
finalboolean replaying = intent.getBooleanExtra(EXTRA_REPLAYING, false);
final Set<Impediment> impediments = (Set<Impediment>) intent.getSerializableExtra(EXTRA_IMPEDIMENTS);
returnnew BlockchainState(bestChainDate, bestChainHeight, replaying, impediments);
}
publicvoid putExtras(final Intent intent)
{
intent.putExtra(EXTRA_BEST_CHAIN_DATE, bestChainDate);
intent.putExtra(EXTRA_BEST_CHAIN_HEIGHT, bestChainHeight);
intent.putExtra(EXTRA_REPLAYING, replaying);
intent.putExtra(EXTRA_IMPEDIMENTS, impediments);
}
}