本文整理汇总了Java中com.pokegoapi.api.PokemonGo类的典型用法代码示例。如果您正苦于以下问题:Java PokemonGo类的具体用法?Java PokemonGo怎么用?Java PokemonGo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PokemonGo类属于com.pokegoapi.api包,在下文中一共展示了PokemonGo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: calculateIntermediate
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
/**
* Calculates the desired intermediate point for this path, based on the current time
*
* @param api the current API
* @return the intermediate point for the given time
*/
public Point calculateIntermediate(PokemonGo api) {
if (totalTime <= 0) {
this.complete = true;
return this.destination;
}
long time = Math.min(api.currentTimeMillis(), endTime) - startTime;
if (time >= totalTime) {
this.complete = true;
}
double intermediate = (double) time / totalTime;
double latitude = source.getLatitude() + (destination.getLatitude() - source.getLatitude()) * intermediate;
double longitude = source.getLongitude() + (destination.getLongitude() - source.getLongitude()) * intermediate;
this.intermediate.setLatitude(latitude);
this.intermediate.setLongitude(longitude);
return this.intermediate;
}
开发者ID:slgphantom,项目名称:yearyearyear,代码行数:23,代码来源:Path2.java
示例2: use2captcha
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
private static void use2captcha(PokemonGo api) {
System.out.println(url);
String apiKey = <2captcha api key>;
String googleKey = "6LeeTScTAAAAADqvhqVMhPpr_vB9D364Ia-1dSgK";
String pageUrl = url;
TwoCaptchaService service = new TwoCaptchaService(apiKey, googleKey, pageUrl);
try {
String responseToken = service.solveCaptcha();
System.out.println("The response token is: " + responseToken);
if (api.verifyChallenge(responseToken)) {
System.out.println("Captcha was correctly solved!");
} else {
System.out.println("Captcha was incorrectly solved! Please try again.");
}
} catch (Exception e) {
System.out.println("ERROR case 1");
e.printStackTrace();
}
}
开发者ID:slgphantom,项目名称:yearyearyear,代码行数:20,代码来源:Example.java
示例3: loginComplete
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
@Override
public void loginComplete(PokemonGo go, Exception result) {
mAuthTask = null;
showProgress(false);
if (result == null) {
SharedPreferences.Editor editor = getSharedPreferences(MainActivity.preferencesKey, Context.MODE_PRIVATE).edit();
editor.putBoolean("login", true);
editor.putString("username", username);
editor.putString("password", password);
MainActivity.username = username;
MainActivity.password = password;
editor.apply();
MainActivity.go = go;
Intent i = new Intent(this, MapsActivity.class);
startActivity(i);
} else if (result instanceof LoginFailedException) {
mPasswordView.setError(getString(R.string.error_incorrect_password));
mPasswordView.requestFocus();
} else if (result instanceof RemoteServerException) {
mPasswordView.setError(getString(R.string.login_server_exception));
mPasswordView.requestFocus();
}
}
开发者ID:guipenedo,项目名称:PokeRadar,代码行数:26,代码来源:LoginActivity.java
示例4: setLoginInfo
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
/**
* Sets the google auth token for the auth info also invokes the onLogin callback.
*/
public void setLoginInfo(@NonNull final LoginInfo info) {
mHandler.post(new Runnable() {
@Override
public void run() {
try {
mAuthInfo = info.createAuthInfo();
mPokemonGo = new PokemonGo(mAuthInfo, mPoGoClient);
EventBus.getDefault().post(new LoginEventResult(true, mAuthInfo, mPokemonGo));
} catch (RemoteServerException | LoginFailedException | RuntimeException e) {
e.printStackTrace();
Log.e(TAG, "Setting google auth token failed. setGoogleAuthToken() raised: " + e.getMessage());
EventBus.getDefault().post(new LoginEventResult(false, null, null));
}
}
});
}
开发者ID:shivarajp,项目名称:LivePokemonFinder,代码行数:20,代码来源:NianticManager.java
示例5: SimplePokemonBot
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
public SimplePokemonBot(PokemonGo api, Options options) {
this.api = api;
this.setCurrentLocation(options.getStartingLocation());
CatchPokemonActivity catchPokemonActivity = new CatchPokemonActivity(this);
TransferPokemonActivity transferPokemonActivity =
new TransferPokemonActivity(this, options);
HeartBeatListener heartBeatListener = new SimpleHeartBeatListener(50, this);
heartBeatListener.addHeartBeatActivity(catchPokemonActivity);
LocationListener locationListener = new SimpleLocationListener(this);
if (options.isTransferPokemon()) {
heartBeatListener.addHeartBeatActivity(transferPokemonActivity);
}
BotWalker botWalker = new BotWalker(this, options.getStartingLocation(), locationListener, heartBeatListener, options);
botWalker.addPostStepActivity(catchPokemonActivity);
this.botWalker = botWalker;
this.state = State.NAN;
this.options = options;
}
开发者ID:mackenzieg,项目名称:PokemonGoBot,代码行数:23,代码来源:SimplePokemonBot.java
示例6: doInBackground
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
@Override
protected String[] doInBackground(String... params) {
String error = null;
String authToken = null;
OkHttpClient http = new OkHttpClient();
try {
// check readme for other example
PokemonGo go = new PokemonGo(new PtcCredentialProvider(http, params[0],
params[1]), http);
authToken = go.getAuthInfo().getToken().toString();
mPokemonGo = go;
// } catch (LoginFailedException | RemoteServerException e) {
} catch (Exception e) {
mPokemonGo = null;
error = e.getMessage();
e.printStackTrace();
}
return new String[]{authToken, error};
}
开发者ID:procks,项目名称:PokeTool,代码行数:20,代码来源:NianticManager.java
示例7: onOptionsItemSelected
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_refresh:
// startActivity(new Intent(this, LoginActivity.class));
try {
NianticManager nianticManager = NianticManager.getInstance();
PokemonGo go = nianticManager.getPokemonGo();
go.getInventories().updateInventories(true);
} catch (LoginFailedException | RemoteServerException e) {
e.printStackTrace();
}
for (int i = 0; i < mCollectionPagerAdapter.getCount(); i++) {
Updatable currentFragment = (Updatable) mCollectionPagerAdapter.getRegisteredFragment(i); //mViewPager.getCurrentItem());
currentFragment.update();
}
return true;
case R.id.action_logout:
logout();
return true;
case R.id.action_check_update:
new AppUpdateLoader(this, this).execute();
return true;
}
return super.onOptionsItemSelected(item);
}
开发者ID:procks,项目名称:PokeTool,代码行数:27,代码来源:MainActivity.java
示例8: start
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
/**
* Sets the start and end time for this Path, ready to begin moving
*
* @param api the current API
* @return the total time it will take for this path to complete
*/
public long start(PokemonGo api) {
startTime = api.currentTimeMillis();
endTime = startTime + totalTime;
complete = false;
return totalTime;
}
开发者ID:slgphantom,项目名称:yearyearyear,代码行数:13,代码来源:Path2.java
示例9: setSpeed
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
/**
* Changes the speed of this path
*
* @param api the current API
* @param speed the new speed to travel at
*/
public void setSpeed(PokemonGo api, double speed) {
double metersPerHour = speed * 1000;
this.speed = metersPerHour / 60 / 60 / 1000;
this.source = calculateIntermediate(api);
this.totalTime = (long) (MapUtil.distFrom(source, destination) / this.speed);
start(api);
}
开发者ID:slgphantom,项目名称:yearyearyear,代码行数:14,代码来源:Path2.java
示例10: onInfoWindowClick
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
@Override
public void onInfoWindowClick(Marker marker) {
if(checkWait()){
return;
}
try{
final PokeMapsActivity pma = (PokeMapsActivity) getActivity();
PokemonGo go = pma.getPokemonGo();
final WildPokemonOuterClass.WildPokemon pokemon = pokemons.get(marker);
if(pokemon != null){
new PokemonCatcher().tryCatchPokemon(this, go, pokemon, marker);
}
final Pokestop pokestop = pokestops.get(marker);
if(pokestop != null){
Duration d = new Duration(timeTilX(pokestop.getCooldownCompleteTimestampMs()));
if(d.getMillis() > 0){
make(mView,
MessageFormat.format(
getString(R.string.pokestop_info),
d.getStandardMinutes(),
d.getStandardSeconds() - 60*d.getStandardMinutes()
), Snackbar.LENGTH_LONG)
.show();
}else{
new PokemonCatcher().tryLootPokestop(this, go, pokestop, marker);
}
}
// MapPokemonOuterClass.MapPokemon cp = catchablePokemons.get(marker);
// if(cp != null){
// new PokemonCatcher().tryCatchPokemon(this, go, cp, marker);
// }
}catch (Exception e){
showError(e.getMessage());
}
}
开发者ID:kiideveloper,项目名称:pokiimap-human,代码行数:40,代码来源:MapWrapperFragment.java
示例11: run
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
@Override
public void run() {
try {
logger = Logger.getLogger(options.getName());
PokemonGo pokemonGo = Main.buildPokemonGo(this.options);
SimplePokemonBot simplePokemonBot = new SimplePokemonBot(pokemonGo, this.options);
Thread.sleep(500);
simplePokemonBot.wander();
} catch (Exception e) {
logger.debug("Error Starting " + this.getName(), e);
}
}
开发者ID:mackenzieg,项目名称:PokemonGoBot,代码行数:13,代码来源:BotRunner.java
示例12: buildPokemonGo
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
public static PokemonGo buildPokemonGo(Options option) throws LoginFailedException, RemoteServerException {
OkHttpClient client;
if (option.getProxy() != null) {
OkHttpClient.Builder builder = new OkHttpClient.Builder()
.connectTimeout(60, TimeUnit.SECONDS)
.writeTimeout(60, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS)
.proxy(new Proxy(Proxy.Type.HTTP, option.getProxy()));
if (!option.getProxyCredentials().isEmpty()) {
Authenticator proxyAuthenticator = (route, response) -> {
String credential = option.getProxyCredentials();
return response.request().newBuilder()
.header("Proxy-Authorization", credential)
.build();
};
builder.proxyAuthenticator(proxyAuthenticator);
}
client = builder.build();
} else {
client = new OkHttpClient();
}
CredentialProvider credentialProvider;
if (option.isGoogle()) {
credentialProvider = googleAuthentication(client, option.getUsername(), option.getPassword());
} else {
credentialProvider = ptcAuthentication(client, option.getUsername(), option.getPassword());
}
PokemonGo pokemonGo = new PokemonGo(credentialProvider, client);
DeviceInfo deviceInfo = DeviceInfo.DEFAULT;
pokemonGo.setDeviceInfo(deviceInfo);
return pokemonGo;
}
开发者ID:mackenzieg,项目名称:PokemonGoBot,代码行数:36,代码来源:Main.java
示例13: main
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
public static void main(String args[]){
/*
* ====================================================
* pokemon go ����~̖����
* -���rֻ�Æξ��̵��
* ====================================================
*/
go = new LinkedList<PokemonGo>();
for(int x=0;x < account.length;x++){
OkHttpClient http = new OkHttpClient();
go.add(new PokemonGo(http));
try{
System.out.println("check point 1");
go.get(x).login(new PtcCredentialProvider(http, account[x][0],account[x][1]));
System.out.println("check point 2");
}catch(Exception E1){
System.out.println("Login error 2 : " + E1);
return;
}
}
System.out.println("login done.");
/*
* ����һ���µ�telegramAPI �ڃȴ��e��
*/
TelegramBotsApi tgBot = new TelegramBotsApi();
/*
* ��ʼ��telegramAPI�����к���
*/
ApiContextInitializer.init();
/*
*try{}catch(Exception e) ��һ�M�l�� ����Lԇ ����г����e�` ����catch ��]�� catch�t��������
*/
try {
/*
* �������telegramAPI�c�C�����B��
*/
tgBot.registerBot(new TelegramBot());
} catch (TelegramApiException e) {
System.out.println("error" + e);
}
}
开发者ID:slgphantom,项目名称:yearyearyear,代码行数:45,代码来源:Example.java
示例14: main
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
public static void main(String args[]) throws Exception{
/*
* ====================================================
* pokemon go 登陸賬號部分
* -暫時只用單線程登陸
* ====================================================
*/
go = new LinkedList<PokemonGo>();
for(int x=0;x < account.length;x++){
OkHttpClient http = new OkHttpClient();
go.add(new PokemonGo(http));
try{
go.get(x).login(new PtcCredentialProvider(http, account[x][0],account[x][1]));
}catch(Exception E1){
System.out.println("Login error 2 : " + E1);
}
}
/*
* 創建一個新的telegramAPI 在內存裡面
*/
TelegramBotsApi tgBot = new TelegramBotsApi();
/*
* 初始化telegramAPI的所有函數
*/
ApiContextInitializer.init();
/*
*try{}catch(Exception e) 是一組條件 代表嘗試 如果有程序錯誤 執行catch 如沒有 catch則不會執行
*/
try {
/*
* 把創建出來的telegramAPI與機器人連接
*/
tgBot.registerBot(new TelegramBot());
} catch (TelegramApiException e) {
System.out.println("error" + e);
}
}
开发者ID:slgphantom,项目名称:yearyearyear,代码行数:43,代码来源:Example.java
示例15: main
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
public static void main(String args[]) throws Exception{
/*
* ====================================================
* pokemon go 登陸賬號部分
* -暫時只用單線程登陸
* ====================================================
*/
go = new LinkedList<PokemonGo>();
for(int x=0;x < account.length;x++){
OkHttpClient http = new OkHttpClient();
go.add(new PokemonGo(http));
try{
go.get(x).login(new PtcCredentialProvider(http, account[x][0],account[x][1]));
}catch(Exception E1){
System.out.println("Login error 2 : " + E1);
}
}
/*
* 創建一個新的telegramAPI 在內存裡面
*/
TelegramBotsApi tgBot = new TelegramBotsApi();
/*
* 初始化telegramAPI的所有函數
*/
ApiContextInitializer.init();
/*
*try{}catch(Exception e) 是一組條件 代表嘗試 如果有程序錯誤 執行catch 如沒有 catch則不會執行
*/
try {
/*
* 把創建出來的telegramAPI與機器人連接
*/
tgBot.registerBot(new TelegramBot());
} catch (TelegramApiException e) {
System.out.println("error" + e);
}
}
开发者ID:slgphantom,项目名称:yearyearyear,代码行数:43,代码来源:Example.java
示例16: main
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
public static void main(String args[]){
/*
* ====================================================
* pokemon go ����~̖����
* -���rֻ�Æξ��̵��
* ====================================================
*/
go = new LinkedList<PokemonGo>();
for(int x=0;x < account.length;x++){
OkHttpClient http = new OkHttpClient();
go.add(new PokemonGo(http));
try{
System.out.println("check point 1");
go.get(x).login(new PtcCredentialProvider(http, account[x][0],account[x][1]), new LegacyHashProvider());
System.out.println("check point 2");
}catch(Exception E1){
System.out.println("Login error 2 : " + E1);
}
}
System.out.println("login done.");
/*
* ����һ���µ�telegramAPI �ڃȴ��e��
*/
TelegramBotsApi tgBot = new TelegramBotsApi();
/*
* ��ʼ��telegramAPI�����к���
*/
ApiContextInitializer.init();
/*
*try{}catch(Exception e) ��һ�M�l�� ����Lԇ ����г����e�` ����catch ��]�� catch�t��������
*/
try {
/*
* �������telegramAPI�c�C�����B��
*/
tgBot.registerBot(new TelegramBot());
} catch (TelegramApiException e) {
System.out.println("error" + e);
}
}
开发者ID:slgphantom,项目名称:yearyearyear,代码行数:44,代码来源:Example.java
示例17: doInBackground
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
@Override
protected Void doInBackground(Void... voids) {
PokemonGo go = MainActivity.go;
if (go == null)
return null;
long time = System.currentTimeMillis();
while (pos < settings.locations.size()) {
if (isCancelled()) return null;
go.setLatitude(settings.locations.get(pos).latitude);
go.setLongitude(settings.locations.get(pos).longitude);
pos++;
try {
Map map = new Map(go);
MapObjects objects = map.getMapObjects(9);
MapWrapper mapWrapper = new MapWrapper();
if (settings.pokemon)
mapWrapper.getPokemon().addAll(map.getCatchablePokemon());
if (settings.pokestops)
mapWrapper.getPokestops().addAll(objects.getPokestops());
if (settings.spawnpoints) {
mapWrapper.getSpawnpoints().addAll(map.getDecimatedSpawnPoints());
mapWrapper.getSpawnpoints().addAll(map.getSpawnPoints());
}
if (settings.gyms)
for (FortDataOuterClass.FortData fortdata : objects.getGyms()) {
if (!ids.contains(fortdata.getId())) {
Thread.sleep(350);
mapWrapper.getGyms().add(new PGym(new Gym(go, fortdata)));
ids.add(fortdata.getId());
}
}
publishProgress(mapWrapper);
if (objects.getPokestops().size() > 0) {
System.out.println("SUCCESSFUL REQUEST! TIME: " + (System.currentTimeMillis() - time) / 1000);
time = System.currentTimeMillis();
}
System.out.println("POKESTOP COUNT: " + objects.getPokestops().size());
System.out.println("SLEEPING " + ((long) go.getSettings().getMapSettings().getMinRefresh()));
//Thread.sleep((long) go.getSettings().getMapSettings().getMinRefresh());
Thread.sleep(6200);
//Thread.sleep(10000);
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
开发者ID:guipenedo,项目名称:PokeRadar,代码行数:50,代码来源:ScanTask.java
示例18: getPokemonGo
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
public PokemonGo getPokemonGo() {
return pokemonGo;
}
开发者ID:kiideveloper,项目名称:pokiimap-human,代码行数:4,代码来源:PokeMapsActivity.java
示例19: initPokemonGOApi
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
private void initPokemonGOApi(final Function<Object, Object> callback){
final String authJson = pref.getString("auth", "");
if(TextUtils.isEmpty(authJson)){
askLogin();
return;
}
AsyncTask at = new AsyncTask() {
@Override
protected void onPreExecute() {
super.onPreExecute();
// mSignin.setEnabled(false);
mSignin.setText(R.string.loading_);
}
@Override
protected Object doInBackground(Object[] objects) {
try {
if(!TextUtils.isEmpty(authJson)){
Gson gson = new Gson();
final RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo auth =
gson.fromJson(authJson, RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo.class);
pokemonGo = new PokemonGo(new CredentialProviderAdapter(auth), http);
PlayerProfile profile = pokemonGo.getPlayerProfile();
return profile;
}
}catch (Exception e){
e.printStackTrace();
// final String error = e.getMessage();
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
// showMessage(error);
// }
// });
}
return null;
}
@Override
protected void onPostExecute(Object o) {
super.onPostExecute(o);
// mSignin.setEnabled(false);
mSignin.setText(R.string.sign_in);
if(o instanceof PlayerProfile){
PlayerProfile playerProfile = (PlayerProfile)o;
renderProfile(playerProfile);
}else{
setProfile("", "", Collections.<String, String>emptyMap());
}
if(callback != null){
callback.apply(o);
}
}
};
at.execute();
}
开发者ID:kiideveloper,项目名称:pokiimap-human,代码行数:64,代码来源:PokeMapsActivity.java
示例20: tryLootPokestop
import com.pokegoapi.api.PokemonGo; //导入依赖的package包/类
public void tryLootPokestop(MapWrapperFragment mapWrapperFragment, PokemonGo go, Pokestop pokestop, Marker marker) {
}
开发者ID:kiideveloper,项目名称:pokiimap-human,代码行数:3,代码来源:PokemonCatcher.java
注:本文中的com.pokegoapi.api.PokemonGo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论