repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
samuil-yanovski/lol-api-library
src/yanovski/lol/api/callbacks/LeaguesCallback.java
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/League.java // public class League { // public long timestamp; // public String queue; // public String name; // public String tier; // public String participantId; // public List<LeagueItem> entries; // } // // Path: src/yanovski/lol/api/responses/LeaguesResponseNotification.java // public class LeaguesResponseNotification extends ResponseNotification<List<League>> { // // }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.League; import yanovski.lol.api.responses.LeaguesResponseNotification; import com.google.gson.Gson;
package yanovski.lol.api.callbacks; public class LeaguesCallback extends GenericCallback<Response> { public LeaguesCallback(String requestId) { super(requestId); } @Override public void success(Response r, Response response) {
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/League.java // public class League { // public long timestamp; // public String queue; // public String name; // public String tier; // public String participantId; // public List<LeagueItem> entries; // } // // Path: src/yanovski/lol/api/responses/LeaguesResponseNotification.java // public class LeaguesResponseNotification extends ResponseNotification<List<League>> { // // } // Path: src/yanovski/lol/api/callbacks/LeaguesCallback.java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.League; import yanovski.lol.api.responses.LeaguesResponseNotification; import com.google.gson.Gson; package yanovski.lol.api.callbacks; public class LeaguesCallback extends GenericCallback<Response> { public LeaguesCallback(String requestId) { super(requestId); } @Override public void success(Response r, Response response) {
ResponseNotification<List<League>> notification = new LeaguesResponseNotification();
samuil-yanovski/lol-api-library
src/yanovski/lol/api/callbacks/LeaguesCallback.java
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/League.java // public class League { // public long timestamp; // public String queue; // public String name; // public String tier; // public String participantId; // public List<LeagueItem> entries; // } // // Path: src/yanovski/lol/api/responses/LeaguesResponseNotification.java // public class LeaguesResponseNotification extends ResponseNotification<List<League>> { // // }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.League; import yanovski.lol.api.responses.LeaguesResponseNotification; import com.google.gson.Gson;
BufferedReader br = new BufferedReader(new InputStreamReader(in)); StringBuilder total = new StringBuilder(in.available()); String line; while ((line = br.readLine()) != null) { total.append(line); } JSONObject json = new JSONObject(total.toString()); JSONArray names = json.names(); int length = names.length(); GsonConverter converter = new GsonConverter(new Gson()); List<League> leagues = new ArrayList<League>(); for (int index = 0; index < length; ++index) { String name = names.getString(index); JSONObject current = json.optJSONObject(name); if (null != current) { League l = (League) converter.fromBody(new TypedString(current.toString()), League.class); leagues.add(l); } } notification.data = leagues; } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } catch (ConversionException e) { e.printStackTrace(); }
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/League.java // public class League { // public long timestamp; // public String queue; // public String name; // public String tier; // public String participantId; // public List<LeagueItem> entries; // } // // Path: src/yanovski/lol/api/responses/LeaguesResponseNotification.java // public class LeaguesResponseNotification extends ResponseNotification<List<League>> { // // } // Path: src/yanovski/lol/api/callbacks/LeaguesCallback.java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.League; import yanovski.lol.api.responses.LeaguesResponseNotification; import com.google.gson.Gson; BufferedReader br = new BufferedReader(new InputStreamReader(in)); StringBuilder total = new StringBuilder(in.available()); String line; while ((line = br.readLine()) != null) { total.append(line); } JSONObject json = new JSONObject(total.toString()); JSONArray names = json.names(); int length = names.length(); GsonConverter converter = new GsonConverter(new Gson()); List<League> leagues = new ArrayList<League>(); for (int index = 0; index < length; ++index) { String name = names.getString(index); JSONObject current = json.optJSONObject(name); if (null != current) { League l = (League) converter.fromBody(new TypedString(current.toString()), League.class); leagues.add(l); } } notification.data = leagues; } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } catch (ConversionException e) { e.printStackTrace(); }
EventBusManager.post(notification);
samuil-yanovski/lol-api-library
src/yanovski/lol/api/callbacks/TeamsCallback.java
// Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/Team.java // public class Team { // public String createDate; // public String lastGameDate; // public String lastJoinDate; // public String lastJoinedRankedTeamQueueDate; // public List<MatchHistorySummary> matchHistory; // public MessageOfDay messageOfDay; // public String modifyDate; // public String name; // public Roster roster; // public String secondLastJoinDate; // public String status; // public String tag; // public String fullId; // public TeamStatSummary teamStatSummary; // public String thirdLastJoinDate; // public long timestamp; // } // // Path: src/yanovski/lol/api/responses/TeamsResponseNotification.java // public class TeamsResponseNotification extends ResponseNotification<List<Team>> { // // }
import java.util.List; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.Team; import yanovski.lol.api.responses.TeamsResponseNotification;
package yanovski.lol.api.callbacks; public class TeamsCallback extends GenericCallback<List<Team>> { public TeamsCallback(String requestId) { super(requestId); } @Override
// Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/Team.java // public class Team { // public String createDate; // public String lastGameDate; // public String lastJoinDate; // public String lastJoinedRankedTeamQueueDate; // public List<MatchHistorySummary> matchHistory; // public MessageOfDay messageOfDay; // public String modifyDate; // public String name; // public Roster roster; // public String secondLastJoinDate; // public String status; // public String tag; // public String fullId; // public TeamStatSummary teamStatSummary; // public String thirdLastJoinDate; // public long timestamp; // } // // Path: src/yanovski/lol/api/responses/TeamsResponseNotification.java // public class TeamsResponseNotification extends ResponseNotification<List<Team>> { // // } // Path: src/yanovski/lol/api/callbacks/TeamsCallback.java import java.util.List; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.Team; import yanovski.lol.api.responses.TeamsResponseNotification; package yanovski.lol.api.callbacks; public class TeamsCallback extends GenericCallback<List<Team>> { public TeamsCallback(String requestId) { super(requestId); } @Override
protected ResponseNotification<List<Team>> createTypedResponse() {
samuil-yanovski/lol-api-library
src/yanovski/lol/api/callbacks/TeamsCallback.java
// Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/Team.java // public class Team { // public String createDate; // public String lastGameDate; // public String lastJoinDate; // public String lastJoinedRankedTeamQueueDate; // public List<MatchHistorySummary> matchHistory; // public MessageOfDay messageOfDay; // public String modifyDate; // public String name; // public Roster roster; // public String secondLastJoinDate; // public String status; // public String tag; // public String fullId; // public TeamStatSummary teamStatSummary; // public String thirdLastJoinDate; // public long timestamp; // } // // Path: src/yanovski/lol/api/responses/TeamsResponseNotification.java // public class TeamsResponseNotification extends ResponseNotification<List<Team>> { // // }
import java.util.List; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.Team; import yanovski.lol.api.responses.TeamsResponseNotification;
package yanovski.lol.api.callbacks; public class TeamsCallback extends GenericCallback<List<Team>> { public TeamsCallback(String requestId) { super(requestId); } @Override protected ResponseNotification<List<Team>> createTypedResponse() {
// Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/Team.java // public class Team { // public String createDate; // public String lastGameDate; // public String lastJoinDate; // public String lastJoinedRankedTeamQueueDate; // public List<MatchHistorySummary> matchHistory; // public MessageOfDay messageOfDay; // public String modifyDate; // public String name; // public Roster roster; // public String secondLastJoinDate; // public String status; // public String tag; // public String fullId; // public TeamStatSummary teamStatSummary; // public String thirdLastJoinDate; // public long timestamp; // } // // Path: src/yanovski/lol/api/responses/TeamsResponseNotification.java // public class TeamsResponseNotification extends ResponseNotification<List<Team>> { // // } // Path: src/yanovski/lol/api/callbacks/TeamsCallback.java import java.util.List; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.Team; import yanovski.lol.api.responses.TeamsResponseNotification; package yanovski.lol.api.callbacks; public class TeamsCallback extends GenericCallback<List<Team>> { public TeamsCallback(String requestId) { super(requestId); } @Override protected ResponseNotification<List<Team>> createTypedResponse() {
return new TeamsResponseNotification();
samuil-yanovski/lol-api-library
src/yanovski/lol/api/callbacks/RankedStatsCallback.java
// Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/RankedStats.java // public class RankedStats { // public long summonerId; // public long modifyDate; // public String modifyDateStr; // public List<ChampionStats> champions; // } // // Path: src/yanovski/lol/api/responses/RankedStatsResponseNotification.java // public class RankedStatsResponseNotification extends ResponseNotification<RankedStats> { // // }
import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.RankedStats; import yanovski.lol.api.responses.RankedStatsResponseNotification;
package yanovski.lol.api.callbacks; public class RankedStatsCallback extends GenericCallback<RankedStats> { public RankedStatsCallback(String requestId) { super(requestId); } @Override
// Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/RankedStats.java // public class RankedStats { // public long summonerId; // public long modifyDate; // public String modifyDateStr; // public List<ChampionStats> champions; // } // // Path: src/yanovski/lol/api/responses/RankedStatsResponseNotification.java // public class RankedStatsResponseNotification extends ResponseNotification<RankedStats> { // // } // Path: src/yanovski/lol/api/callbacks/RankedStatsCallback.java import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.RankedStats; import yanovski.lol.api.responses.RankedStatsResponseNotification; package yanovski.lol.api.callbacks; public class RankedStatsCallback extends GenericCallback<RankedStats> { public RankedStatsCallback(String requestId) { super(requestId); } @Override
protected ResponseNotification<RankedStats> createTypedResponse() {
samuil-yanovski/lol-api-library
src/yanovski/lol/api/callbacks/RankedStatsCallback.java
// Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/RankedStats.java // public class RankedStats { // public long summonerId; // public long modifyDate; // public String modifyDateStr; // public List<ChampionStats> champions; // } // // Path: src/yanovski/lol/api/responses/RankedStatsResponseNotification.java // public class RankedStatsResponseNotification extends ResponseNotification<RankedStats> { // // }
import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.RankedStats; import yanovski.lol.api.responses.RankedStatsResponseNotification;
package yanovski.lol.api.callbacks; public class RankedStatsCallback extends GenericCallback<RankedStats> { public RankedStatsCallback(String requestId) { super(requestId); } @Override protected ResponseNotification<RankedStats> createTypedResponse() {
// Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/RankedStats.java // public class RankedStats { // public long summonerId; // public long modifyDate; // public String modifyDateStr; // public List<ChampionStats> champions; // } // // Path: src/yanovski/lol/api/responses/RankedStatsResponseNotification.java // public class RankedStatsResponseNotification extends ResponseNotification<RankedStats> { // // } // Path: src/yanovski/lol/api/callbacks/RankedStatsCallback.java import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.RankedStats; import yanovski.lol.api.responses.RankedStatsResponseNotification; package yanovski.lol.api.callbacks; public class RankedStatsCallback extends GenericCallback<RankedStats> { public RankedStatsCallback(String requestId) { super(requestId); } @Override protected ResponseNotification<RankedStats> createTypedResponse() {
return new RankedStatsResponseNotification();
samuil-yanovski/lol-api-library
src/yanovski/lol/api/callbacks/MasteryPagesCallback.java
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/MasteryPages.java // public class MasteryPages { // public long summonerId; // public List<MasteryPage> pages; // } // // Path: src/yanovski/lol/api/responses/MasteryPagesResponseNotification.java // public class MasteryPagesResponseNotification extends ResponseNotification<List<MasteryPages>> { // // }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.MasteryPages; import yanovski.lol.api.responses.MasteryPagesResponseNotification; import com.google.gson.Gson;
package yanovski.lol.api.callbacks; public class MasteryPagesCallback extends GenericCallback<Response> { public MasteryPagesCallback(String requestId) { super(requestId); } @Override public void success(Response r, Response response) {
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/MasteryPages.java // public class MasteryPages { // public long summonerId; // public List<MasteryPage> pages; // } // // Path: src/yanovski/lol/api/responses/MasteryPagesResponseNotification.java // public class MasteryPagesResponseNotification extends ResponseNotification<List<MasteryPages>> { // // } // Path: src/yanovski/lol/api/callbacks/MasteryPagesCallback.java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.MasteryPages; import yanovski.lol.api.responses.MasteryPagesResponseNotification; import com.google.gson.Gson; package yanovski.lol.api.callbacks; public class MasteryPagesCallback extends GenericCallback<Response> { public MasteryPagesCallback(String requestId) { super(requestId); } @Override public void success(Response r, Response response) {
ResponseNotification<List<MasteryPages>> notification = new MasteryPagesResponseNotification();
samuil-yanovski/lol-api-library
src/yanovski/lol/api/callbacks/MasteryPagesCallback.java
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/MasteryPages.java // public class MasteryPages { // public long summonerId; // public List<MasteryPage> pages; // } // // Path: src/yanovski/lol/api/responses/MasteryPagesResponseNotification.java // public class MasteryPagesResponseNotification extends ResponseNotification<List<MasteryPages>> { // // }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.MasteryPages; import yanovski.lol.api.responses.MasteryPagesResponseNotification; import com.google.gson.Gson;
package yanovski.lol.api.callbacks; public class MasteryPagesCallback extends GenericCallback<Response> { public MasteryPagesCallback(String requestId) { super(requestId); } @Override public void success(Response r, Response response) {
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/MasteryPages.java // public class MasteryPages { // public long summonerId; // public List<MasteryPage> pages; // } // // Path: src/yanovski/lol/api/responses/MasteryPagesResponseNotification.java // public class MasteryPagesResponseNotification extends ResponseNotification<List<MasteryPages>> { // // } // Path: src/yanovski/lol/api/callbacks/MasteryPagesCallback.java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.MasteryPages; import yanovski.lol.api.responses.MasteryPagesResponseNotification; import com.google.gson.Gson; package yanovski.lol.api.callbacks; public class MasteryPagesCallback extends GenericCallback<Response> { public MasteryPagesCallback(String requestId) { super(requestId); } @Override public void success(Response r, Response response) {
ResponseNotification<List<MasteryPages>> notification = new MasteryPagesResponseNotification();
samuil-yanovski/lol-api-library
src/yanovski/lol/api/callbacks/MasteryPagesCallback.java
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/MasteryPages.java // public class MasteryPages { // public long summonerId; // public List<MasteryPage> pages; // } // // Path: src/yanovski/lol/api/responses/MasteryPagesResponseNotification.java // public class MasteryPagesResponseNotification extends ResponseNotification<List<MasteryPages>> { // // }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.MasteryPages; import yanovski.lol.api.responses.MasteryPagesResponseNotification; import com.google.gson.Gson;
package yanovski.lol.api.callbacks; public class MasteryPagesCallback extends GenericCallback<Response> { public MasteryPagesCallback(String requestId) { super(requestId); } @Override public void success(Response r, Response response) {
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/MasteryPages.java // public class MasteryPages { // public long summonerId; // public List<MasteryPage> pages; // } // // Path: src/yanovski/lol/api/responses/MasteryPagesResponseNotification.java // public class MasteryPagesResponseNotification extends ResponseNotification<List<MasteryPages>> { // // } // Path: src/yanovski/lol/api/callbacks/MasteryPagesCallback.java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.MasteryPages; import yanovski.lol.api.responses.MasteryPagesResponseNotification; import com.google.gson.Gson; package yanovski.lol.api.callbacks; public class MasteryPagesCallback extends GenericCallback<Response> { public MasteryPagesCallback(String requestId) { super(requestId); } @Override public void success(Response r, Response response) {
ResponseNotification<List<MasteryPages>> notification = new MasteryPagesResponseNotification();
samuil-yanovski/lol-api-library
src/yanovski/lol/api/callbacks/MasteryPagesCallback.java
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/MasteryPages.java // public class MasteryPages { // public long summonerId; // public List<MasteryPage> pages; // } // // Path: src/yanovski/lol/api/responses/MasteryPagesResponseNotification.java // public class MasteryPagesResponseNotification extends ResponseNotification<List<MasteryPages>> { // // }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.MasteryPages; import yanovski.lol.api.responses.MasteryPagesResponseNotification; import com.google.gson.Gson;
BufferedReader br = new BufferedReader(new InputStreamReader(in)); StringBuilder total = new StringBuilder(in.available()); String line; while ((line = br.readLine()) != null) { total.append(line); } JSONObject json = new JSONObject(total.toString()); JSONArray names = json.names(); int length = names.length(); GsonConverter converter = new GsonConverter(new Gson()); List<MasteryPages> pages = new ArrayList<MasteryPages>(); for (int index = 0; index < length; ++index) { String name = names.getString(index); JSONObject current = json.optJSONObject(name); if (null != current) { MasteryPages p = (MasteryPages) converter.fromBody(new TypedString(current.toString()), MasteryPages.class); pages.add(p); } } notification.data = pages; } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } catch (ConversionException e) { e.printStackTrace(); }
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/MasteryPages.java // public class MasteryPages { // public long summonerId; // public List<MasteryPage> pages; // } // // Path: src/yanovski/lol/api/responses/MasteryPagesResponseNotification.java // public class MasteryPagesResponseNotification extends ResponseNotification<List<MasteryPages>> { // // } // Path: src/yanovski/lol/api/callbacks/MasteryPagesCallback.java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.MasteryPages; import yanovski.lol.api.responses.MasteryPagesResponseNotification; import com.google.gson.Gson; BufferedReader br = new BufferedReader(new InputStreamReader(in)); StringBuilder total = new StringBuilder(in.available()); String line; while ((line = br.readLine()) != null) { total.append(line); } JSONObject json = new JSONObject(total.toString()); JSONArray names = json.names(); int length = names.length(); GsonConverter converter = new GsonConverter(new Gson()); List<MasteryPages> pages = new ArrayList<MasteryPages>(); for (int index = 0; index < length; ++index) { String name = names.getString(index); JSONObject current = json.optJSONObject(name); if (null != current) { MasteryPages p = (MasteryPages) converter.fromBody(new TypedString(current.toString()), MasteryPages.class); pages.add(p); } } notification.data = pages; } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } catch (ConversionException e) { e.printStackTrace(); }
EventBusManager.post(notification);
samuil-yanovski/lol-api-library
src/yanovski/lol/api/callbacks/RunePagesCallback.java
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/RunePages.java // public class RunePages { // public long summonerId; // public List<RunePage> pages; // } // // Path: src/yanovski/lol/api/responses/RunePagesResponseNotification.java // public class RunePagesResponseNotification extends ResponseNotification<List<RunePages>> { // // }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.RunePages; import yanovski.lol.api.responses.RunePagesResponseNotification; import com.google.gson.Gson;
package yanovski.lol.api.callbacks; public class RunePagesCallback extends GenericCallback<Response> { public RunePagesCallback(String requestId) { super(requestId); } @Override public void success(Response r, Response response) {
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/RunePages.java // public class RunePages { // public long summonerId; // public List<RunePage> pages; // } // // Path: src/yanovski/lol/api/responses/RunePagesResponseNotification.java // public class RunePagesResponseNotification extends ResponseNotification<List<RunePages>> { // // } // Path: src/yanovski/lol/api/callbacks/RunePagesCallback.java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.RunePages; import yanovski.lol.api.responses.RunePagesResponseNotification; import com.google.gson.Gson; package yanovski.lol.api.callbacks; public class RunePagesCallback extends GenericCallback<Response> { public RunePagesCallback(String requestId) { super(requestId); } @Override public void success(Response r, Response response) {
ResponseNotification<List<RunePages>> notification = new RunePagesResponseNotification();
samuil-yanovski/lol-api-library
src/yanovski/lol/api/callbacks/RunePagesCallback.java
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/RunePages.java // public class RunePages { // public long summonerId; // public List<RunePage> pages; // } // // Path: src/yanovski/lol/api/responses/RunePagesResponseNotification.java // public class RunePagesResponseNotification extends ResponseNotification<List<RunePages>> { // // }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.RunePages; import yanovski.lol.api.responses.RunePagesResponseNotification; import com.google.gson.Gson;
package yanovski.lol.api.callbacks; public class RunePagesCallback extends GenericCallback<Response> { public RunePagesCallback(String requestId) { super(requestId); } @Override public void success(Response r, Response response) {
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/RunePages.java // public class RunePages { // public long summonerId; // public List<RunePage> pages; // } // // Path: src/yanovski/lol/api/responses/RunePagesResponseNotification.java // public class RunePagesResponseNotification extends ResponseNotification<List<RunePages>> { // // } // Path: src/yanovski/lol/api/callbacks/RunePagesCallback.java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.RunePages; import yanovski.lol.api.responses.RunePagesResponseNotification; import com.google.gson.Gson; package yanovski.lol.api.callbacks; public class RunePagesCallback extends GenericCallback<Response> { public RunePagesCallback(String requestId) { super(requestId); } @Override public void success(Response r, Response response) {
ResponseNotification<List<RunePages>> notification = new RunePagesResponseNotification();
samuil-yanovski/lol-api-library
src/yanovski/lol/api/callbacks/RunePagesCallback.java
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/RunePages.java // public class RunePages { // public long summonerId; // public List<RunePage> pages; // } // // Path: src/yanovski/lol/api/responses/RunePagesResponseNotification.java // public class RunePagesResponseNotification extends ResponseNotification<List<RunePages>> { // // }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.RunePages; import yanovski.lol.api.responses.RunePagesResponseNotification; import com.google.gson.Gson;
package yanovski.lol.api.callbacks; public class RunePagesCallback extends GenericCallback<Response> { public RunePagesCallback(String requestId) { super(requestId); } @Override public void success(Response r, Response response) {
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/RunePages.java // public class RunePages { // public long summonerId; // public List<RunePage> pages; // } // // Path: src/yanovski/lol/api/responses/RunePagesResponseNotification.java // public class RunePagesResponseNotification extends ResponseNotification<List<RunePages>> { // // } // Path: src/yanovski/lol/api/callbacks/RunePagesCallback.java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.RunePages; import yanovski.lol.api.responses.RunePagesResponseNotification; import com.google.gson.Gson; package yanovski.lol.api.callbacks; public class RunePagesCallback extends GenericCallback<Response> { public RunePagesCallback(String requestId) { super(requestId); } @Override public void success(Response r, Response response) {
ResponseNotification<List<RunePages>> notification = new RunePagesResponseNotification();
samuil-yanovski/lol-api-library
src/yanovski/lol/api/callbacks/RunePagesCallback.java
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/RunePages.java // public class RunePages { // public long summonerId; // public List<RunePage> pages; // } // // Path: src/yanovski/lol/api/responses/RunePagesResponseNotification.java // public class RunePagesResponseNotification extends ResponseNotification<List<RunePages>> { // // }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.RunePages; import yanovski.lol.api.responses.RunePagesResponseNotification; import com.google.gson.Gson;
BufferedReader br = new BufferedReader(new InputStreamReader(in)); StringBuilder total = new StringBuilder(in.available()); String line; while ((line = br.readLine()) != null) { total.append(line); } JSONObject json = new JSONObject(total.toString()); JSONArray names = json.names(); int length = names.length(); GsonConverter converter = new GsonConverter(new Gson()); List<RunePages> runePages = new ArrayList<RunePages>(); for (int index = 0; index < length; ++index) { String name = names.getString(index); JSONObject current = json.optJSONObject(name); if (null != current) { RunePages rp = (RunePages) converter.fromBody(new TypedString(current.toString()), RunePages.class); runePages.add(rp); } } notification.data = runePages; } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } catch (ConversionException e) { e.printStackTrace(); }
// Path: src/yanovski/lol/api/messages/EventBusManager.java // public class EventBusManager { // private static Bus bus; // // public synchronized static Bus getInstance() { // if (null == bus) { // bus = new Bus(); // } // // return bus; // } // // public static void post(Object message) { // Bus instance = getInstance(); // instance.post(message); // } // // public static void register(Object listener) { // Bus instance = getInstance(); // instance.register(listener); // } // // public static void unregister(Object listener) { // Bus instance = getInstance(); // instance.unregister(listener); // } // } // // Path: src/yanovski/lol/api/messages/ResponseNotification.java // public class ResponseNotification<T> { // public String requestId; // public T data; // public Response origin; // public RetrofitError error; // } // // Path: src/yanovski/lol/api/models/RunePages.java // public class RunePages { // public long summonerId; // public List<RunePage> pages; // } // // Path: src/yanovski/lol/api/responses/RunePagesResponseNotification.java // public class RunePagesResponseNotification extends ResponseNotification<List<RunePages>> { // // } // Path: src/yanovski/lol/api/callbacks/RunePagesCallback.java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import retrofit.client.Response; import retrofit.converter.ConversionException; import retrofit.converter.GsonConverter; import retrofit.mime.TypedString; import yanovski.lol.api.messages.EventBusManager; import yanovski.lol.api.messages.ResponseNotification; import yanovski.lol.api.models.RunePages; import yanovski.lol.api.responses.RunePagesResponseNotification; import com.google.gson.Gson; BufferedReader br = new BufferedReader(new InputStreamReader(in)); StringBuilder total = new StringBuilder(in.available()); String line; while ((line = br.readLine()) != null) { total.append(line); } JSONObject json = new JSONObject(total.toString()); JSONArray names = json.names(); int length = names.length(); GsonConverter converter = new GsonConverter(new Gson()); List<RunePages> runePages = new ArrayList<RunePages>(); for (int index = 0; index < length; ++index) { String name = names.getString(index); JSONObject current = json.optJSONObject(name); if (null != current) { RunePages rp = (RunePages) converter.fromBody(new TypedString(current.toString()), RunePages.class); runePages.add(rp); } } notification.data = runePages; } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } catch (ConversionException e) { e.printStackTrace(); }
EventBusManager.post(notification);
samuil-yanovski/lol-api-library
src/yanovski/lol/api/services/LoLServicesClient.java
// Path: src/yanovski/lol/api/models/ChampionList.java // public class ChampionList { // public List<Champion> champions; // } // // Path: src/yanovski/lol/api/models/League.java // public class League { // public long timestamp; // public String queue; // public String name; // public String tier; // public String participantId; // public List<LeagueItem> entries; // } // // Path: src/yanovski/lol/api/models/LeagueItem.java // public class LeagueItem { // public boolean isFreshBlood; // public boolean isHotStreak; // public boolean isInactive; // public boolean isVeteran; // public long lastPlayed; // public String leagueName; // public int leaguePoints; // public int losses; // public MiniSeries miniSeries; // public String playerOrTeamId; // public String playerOrTeamName; // public String queueType; // public String rank; // public String tier; // public long timeUntilDecay; // public int wins; // } // // Path: src/yanovski/lol/api/models/PlayerStatsSummaryList.java // public class PlayerStatsSummaryList { // public long summonerId; // public List<PlayerStatsSummary> playerStatSummaries; // } // // Path: src/yanovski/lol/api/models/RankedStats.java // public class RankedStats { // public long summonerId; // public long modifyDate; // public String modifyDateStr; // public List<ChampionStats> champions; // } // // Path: src/yanovski/lol/api/models/RecentGames.java // public class RecentGames { // public long summonerId; // public List<Game> games; // } // // Path: src/yanovski/lol/api/models/Team.java // public class Team { // public String createDate; // public String lastGameDate; // public String lastJoinDate; // public String lastJoinedRankedTeamQueueDate; // public List<MatchHistorySummary> matchHistory; // public MessageOfDay messageOfDay; // public String modifyDate; // public String name; // public Roster roster; // public String secondLastJoinDate; // public String status; // public String tag; // public String fullId; // public TeamStatSummary teamStatSummary; // public String thirdLastJoinDate; // public long timestamp; // }
import java.util.List; import retrofit.Callback; import retrofit.client.Response; import retrofit.http.GET; import retrofit.http.Path; import retrofit.http.Query; import yanovski.lol.api.models.ChampionList; import yanovski.lol.api.models.League; import yanovski.lol.api.models.LeagueItem; import yanovski.lol.api.models.PlayerStatsSummaryList; import yanovski.lol.api.models.RankedStats; import yanovski.lol.api.models.RecentGames; import yanovski.lol.api.models.Team;
package yanovski.lol.api.services; /** * Created by Intuitiv-01 on 13-12-11. */ public interface LoLServicesClient { @GET("/api/lol/{region}/v1.3/summoner/by-name/{name}") void getSummonerByName(@Path("region") String region, @Path("name") String name, @Query("api_key") String apiKey, Callback<Response> callback); @GET("/api/lol/{region}/v2.3/league/challenger")
// Path: src/yanovski/lol/api/models/ChampionList.java // public class ChampionList { // public List<Champion> champions; // } // // Path: src/yanovski/lol/api/models/League.java // public class League { // public long timestamp; // public String queue; // public String name; // public String tier; // public String participantId; // public List<LeagueItem> entries; // } // // Path: src/yanovski/lol/api/models/LeagueItem.java // public class LeagueItem { // public boolean isFreshBlood; // public boolean isHotStreak; // public boolean isInactive; // public boolean isVeteran; // public long lastPlayed; // public String leagueName; // public int leaguePoints; // public int losses; // public MiniSeries miniSeries; // public String playerOrTeamId; // public String playerOrTeamName; // public String queueType; // public String rank; // public String tier; // public long timeUntilDecay; // public int wins; // } // // Path: src/yanovski/lol/api/models/PlayerStatsSummaryList.java // public class PlayerStatsSummaryList { // public long summonerId; // public List<PlayerStatsSummary> playerStatSummaries; // } // // Path: src/yanovski/lol/api/models/RankedStats.java // public class RankedStats { // public long summonerId; // public long modifyDate; // public String modifyDateStr; // public List<ChampionStats> champions; // } // // Path: src/yanovski/lol/api/models/RecentGames.java // public class RecentGames { // public long summonerId; // public List<Game> games; // } // // Path: src/yanovski/lol/api/models/Team.java // public class Team { // public String createDate; // public String lastGameDate; // public String lastJoinDate; // public String lastJoinedRankedTeamQueueDate; // public List<MatchHistorySummary> matchHistory; // public MessageOfDay messageOfDay; // public String modifyDate; // public String name; // public Roster roster; // public String secondLastJoinDate; // public String status; // public String tag; // public String fullId; // public TeamStatSummary teamStatSummary; // public String thirdLastJoinDate; // public long timestamp; // } // Path: src/yanovski/lol/api/services/LoLServicesClient.java import java.util.List; import retrofit.Callback; import retrofit.client.Response; import retrofit.http.GET; import retrofit.http.Path; import retrofit.http.Query; import yanovski.lol.api.models.ChampionList; import yanovski.lol.api.models.League; import yanovski.lol.api.models.LeagueItem; import yanovski.lol.api.models.PlayerStatsSummaryList; import yanovski.lol.api.models.RankedStats; import yanovski.lol.api.models.RecentGames; import yanovski.lol.api.models.Team; package yanovski.lol.api.services; /** * Created by Intuitiv-01 on 13-12-11. */ public interface LoLServicesClient { @GET("/api/lol/{region}/v1.3/summoner/by-name/{name}") void getSummonerByName(@Path("region") String region, @Path("name") String name, @Query("api_key") String apiKey, Callback<Response> callback); @GET("/api/lol/{region}/v2.3/league/challenger")
void getChallengerLeague(@Path("region") String region, @Query("type") String type, @Query("api_key") String apiKey, Callback<League> callback);
samuil-yanovski/lol-api-library
src/yanovski/lol/api/services/LoLServicesClient.java
// Path: src/yanovski/lol/api/models/ChampionList.java // public class ChampionList { // public List<Champion> champions; // } // // Path: src/yanovski/lol/api/models/League.java // public class League { // public long timestamp; // public String queue; // public String name; // public String tier; // public String participantId; // public List<LeagueItem> entries; // } // // Path: src/yanovski/lol/api/models/LeagueItem.java // public class LeagueItem { // public boolean isFreshBlood; // public boolean isHotStreak; // public boolean isInactive; // public boolean isVeteran; // public long lastPlayed; // public String leagueName; // public int leaguePoints; // public int losses; // public MiniSeries miniSeries; // public String playerOrTeamId; // public String playerOrTeamName; // public String queueType; // public String rank; // public String tier; // public long timeUntilDecay; // public int wins; // } // // Path: src/yanovski/lol/api/models/PlayerStatsSummaryList.java // public class PlayerStatsSummaryList { // public long summonerId; // public List<PlayerStatsSummary> playerStatSummaries; // } // // Path: src/yanovski/lol/api/models/RankedStats.java // public class RankedStats { // public long summonerId; // public long modifyDate; // public String modifyDateStr; // public List<ChampionStats> champions; // } // // Path: src/yanovski/lol/api/models/RecentGames.java // public class RecentGames { // public long summonerId; // public List<Game> games; // } // // Path: src/yanovski/lol/api/models/Team.java // public class Team { // public String createDate; // public String lastGameDate; // public String lastJoinDate; // public String lastJoinedRankedTeamQueueDate; // public List<MatchHistorySummary> matchHistory; // public MessageOfDay messageOfDay; // public String modifyDate; // public String name; // public Roster roster; // public String secondLastJoinDate; // public String status; // public String tag; // public String fullId; // public TeamStatSummary teamStatSummary; // public String thirdLastJoinDate; // public long timestamp; // }
import java.util.List; import retrofit.Callback; import retrofit.client.Response; import retrofit.http.GET; import retrofit.http.Path; import retrofit.http.Query; import yanovski.lol.api.models.ChampionList; import yanovski.lol.api.models.League; import yanovski.lol.api.models.LeagueItem; import yanovski.lol.api.models.PlayerStatsSummaryList; import yanovski.lol.api.models.RankedStats; import yanovski.lol.api.models.RecentGames; import yanovski.lol.api.models.Team;
package yanovski.lol.api.services; /** * Created by Intuitiv-01 on 13-12-11. */ public interface LoLServicesClient { @GET("/api/lol/{region}/v1.3/summoner/by-name/{name}") void getSummonerByName(@Path("region") String region, @Path("name") String name, @Query("api_key") String apiKey, Callback<Response> callback); @GET("/api/lol/{region}/v2.3/league/challenger") void getChallengerLeague(@Path("region") String region, @Query("type") String type, @Query("api_key") String apiKey, Callback<League> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}/entry")
// Path: src/yanovski/lol/api/models/ChampionList.java // public class ChampionList { // public List<Champion> champions; // } // // Path: src/yanovski/lol/api/models/League.java // public class League { // public long timestamp; // public String queue; // public String name; // public String tier; // public String participantId; // public List<LeagueItem> entries; // } // // Path: src/yanovski/lol/api/models/LeagueItem.java // public class LeagueItem { // public boolean isFreshBlood; // public boolean isHotStreak; // public boolean isInactive; // public boolean isVeteran; // public long lastPlayed; // public String leagueName; // public int leaguePoints; // public int losses; // public MiniSeries miniSeries; // public String playerOrTeamId; // public String playerOrTeamName; // public String queueType; // public String rank; // public String tier; // public long timeUntilDecay; // public int wins; // } // // Path: src/yanovski/lol/api/models/PlayerStatsSummaryList.java // public class PlayerStatsSummaryList { // public long summonerId; // public List<PlayerStatsSummary> playerStatSummaries; // } // // Path: src/yanovski/lol/api/models/RankedStats.java // public class RankedStats { // public long summonerId; // public long modifyDate; // public String modifyDateStr; // public List<ChampionStats> champions; // } // // Path: src/yanovski/lol/api/models/RecentGames.java // public class RecentGames { // public long summonerId; // public List<Game> games; // } // // Path: src/yanovski/lol/api/models/Team.java // public class Team { // public String createDate; // public String lastGameDate; // public String lastJoinDate; // public String lastJoinedRankedTeamQueueDate; // public List<MatchHistorySummary> matchHistory; // public MessageOfDay messageOfDay; // public String modifyDate; // public String name; // public Roster roster; // public String secondLastJoinDate; // public String status; // public String tag; // public String fullId; // public TeamStatSummary teamStatSummary; // public String thirdLastJoinDate; // public long timestamp; // } // Path: src/yanovski/lol/api/services/LoLServicesClient.java import java.util.List; import retrofit.Callback; import retrofit.client.Response; import retrofit.http.GET; import retrofit.http.Path; import retrofit.http.Query; import yanovski.lol.api.models.ChampionList; import yanovski.lol.api.models.League; import yanovski.lol.api.models.LeagueItem; import yanovski.lol.api.models.PlayerStatsSummaryList; import yanovski.lol.api.models.RankedStats; import yanovski.lol.api.models.RecentGames; import yanovski.lol.api.models.Team; package yanovski.lol.api.services; /** * Created by Intuitiv-01 on 13-12-11. */ public interface LoLServicesClient { @GET("/api/lol/{region}/v1.3/summoner/by-name/{name}") void getSummonerByName(@Path("region") String region, @Path("name") String name, @Query("api_key") String apiKey, Callback<Response> callback); @GET("/api/lol/{region}/v2.3/league/challenger") void getChallengerLeague(@Path("region") String region, @Query("type") String type, @Query("api_key") String apiKey, Callback<League> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}/entry")
void getLeagueEntriesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<LeagueItem>> callback);
samuil-yanovski/lol-api-library
src/yanovski/lol/api/services/LoLServicesClient.java
// Path: src/yanovski/lol/api/models/ChampionList.java // public class ChampionList { // public List<Champion> champions; // } // // Path: src/yanovski/lol/api/models/League.java // public class League { // public long timestamp; // public String queue; // public String name; // public String tier; // public String participantId; // public List<LeagueItem> entries; // } // // Path: src/yanovski/lol/api/models/LeagueItem.java // public class LeagueItem { // public boolean isFreshBlood; // public boolean isHotStreak; // public boolean isInactive; // public boolean isVeteran; // public long lastPlayed; // public String leagueName; // public int leaguePoints; // public int losses; // public MiniSeries miniSeries; // public String playerOrTeamId; // public String playerOrTeamName; // public String queueType; // public String rank; // public String tier; // public long timeUntilDecay; // public int wins; // } // // Path: src/yanovski/lol/api/models/PlayerStatsSummaryList.java // public class PlayerStatsSummaryList { // public long summonerId; // public List<PlayerStatsSummary> playerStatSummaries; // } // // Path: src/yanovski/lol/api/models/RankedStats.java // public class RankedStats { // public long summonerId; // public long modifyDate; // public String modifyDateStr; // public List<ChampionStats> champions; // } // // Path: src/yanovski/lol/api/models/RecentGames.java // public class RecentGames { // public long summonerId; // public List<Game> games; // } // // Path: src/yanovski/lol/api/models/Team.java // public class Team { // public String createDate; // public String lastGameDate; // public String lastJoinDate; // public String lastJoinedRankedTeamQueueDate; // public List<MatchHistorySummary> matchHistory; // public MessageOfDay messageOfDay; // public String modifyDate; // public String name; // public Roster roster; // public String secondLastJoinDate; // public String status; // public String tag; // public String fullId; // public TeamStatSummary teamStatSummary; // public String thirdLastJoinDate; // public long timestamp; // }
import java.util.List; import retrofit.Callback; import retrofit.client.Response; import retrofit.http.GET; import retrofit.http.Path; import retrofit.http.Query; import yanovski.lol.api.models.ChampionList; import yanovski.lol.api.models.League; import yanovski.lol.api.models.LeagueItem; import yanovski.lol.api.models.PlayerStatsSummaryList; import yanovski.lol.api.models.RankedStats; import yanovski.lol.api.models.RecentGames; import yanovski.lol.api.models.Team;
package yanovski.lol.api.services; /** * Created by Intuitiv-01 on 13-12-11. */ public interface LoLServicesClient { @GET("/api/lol/{region}/v1.3/summoner/by-name/{name}") void getSummonerByName(@Path("region") String region, @Path("name") String name, @Query("api_key") String apiKey, Callback<Response> callback); @GET("/api/lol/{region}/v2.3/league/challenger") void getChallengerLeague(@Path("region") String region, @Query("type") String type, @Query("api_key") String apiKey, Callback<League> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}/entry") void getLeagueEntriesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<LeagueItem>> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}") void getLeaguesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<League>> callback); @GET("/api/lol/{region}/v1.1/champion")
// Path: src/yanovski/lol/api/models/ChampionList.java // public class ChampionList { // public List<Champion> champions; // } // // Path: src/yanovski/lol/api/models/League.java // public class League { // public long timestamp; // public String queue; // public String name; // public String tier; // public String participantId; // public List<LeagueItem> entries; // } // // Path: src/yanovski/lol/api/models/LeagueItem.java // public class LeagueItem { // public boolean isFreshBlood; // public boolean isHotStreak; // public boolean isInactive; // public boolean isVeteran; // public long lastPlayed; // public String leagueName; // public int leaguePoints; // public int losses; // public MiniSeries miniSeries; // public String playerOrTeamId; // public String playerOrTeamName; // public String queueType; // public String rank; // public String tier; // public long timeUntilDecay; // public int wins; // } // // Path: src/yanovski/lol/api/models/PlayerStatsSummaryList.java // public class PlayerStatsSummaryList { // public long summonerId; // public List<PlayerStatsSummary> playerStatSummaries; // } // // Path: src/yanovski/lol/api/models/RankedStats.java // public class RankedStats { // public long summonerId; // public long modifyDate; // public String modifyDateStr; // public List<ChampionStats> champions; // } // // Path: src/yanovski/lol/api/models/RecentGames.java // public class RecentGames { // public long summonerId; // public List<Game> games; // } // // Path: src/yanovski/lol/api/models/Team.java // public class Team { // public String createDate; // public String lastGameDate; // public String lastJoinDate; // public String lastJoinedRankedTeamQueueDate; // public List<MatchHistorySummary> matchHistory; // public MessageOfDay messageOfDay; // public String modifyDate; // public String name; // public Roster roster; // public String secondLastJoinDate; // public String status; // public String tag; // public String fullId; // public TeamStatSummary teamStatSummary; // public String thirdLastJoinDate; // public long timestamp; // } // Path: src/yanovski/lol/api/services/LoLServicesClient.java import java.util.List; import retrofit.Callback; import retrofit.client.Response; import retrofit.http.GET; import retrofit.http.Path; import retrofit.http.Query; import yanovski.lol.api.models.ChampionList; import yanovski.lol.api.models.League; import yanovski.lol.api.models.LeagueItem; import yanovski.lol.api.models.PlayerStatsSummaryList; import yanovski.lol.api.models.RankedStats; import yanovski.lol.api.models.RecentGames; import yanovski.lol.api.models.Team; package yanovski.lol.api.services; /** * Created by Intuitiv-01 on 13-12-11. */ public interface LoLServicesClient { @GET("/api/lol/{region}/v1.3/summoner/by-name/{name}") void getSummonerByName(@Path("region") String region, @Path("name") String name, @Query("api_key") String apiKey, Callback<Response> callback); @GET("/api/lol/{region}/v2.3/league/challenger") void getChallengerLeague(@Path("region") String region, @Query("type") String type, @Query("api_key") String apiKey, Callback<League> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}/entry") void getLeagueEntriesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<LeagueItem>> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}") void getLeaguesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<League>> callback); @GET("/api/lol/{region}/v1.1/champion")
void getChampions(@Path("region") String region, @Query("freeToPlay") boolean freeToPlay, @Query("api_key") String apiKey, Callback<ChampionList> callback);
samuil-yanovski/lol-api-library
src/yanovski/lol/api/services/LoLServicesClient.java
// Path: src/yanovski/lol/api/models/ChampionList.java // public class ChampionList { // public List<Champion> champions; // } // // Path: src/yanovski/lol/api/models/League.java // public class League { // public long timestamp; // public String queue; // public String name; // public String tier; // public String participantId; // public List<LeagueItem> entries; // } // // Path: src/yanovski/lol/api/models/LeagueItem.java // public class LeagueItem { // public boolean isFreshBlood; // public boolean isHotStreak; // public boolean isInactive; // public boolean isVeteran; // public long lastPlayed; // public String leagueName; // public int leaguePoints; // public int losses; // public MiniSeries miniSeries; // public String playerOrTeamId; // public String playerOrTeamName; // public String queueType; // public String rank; // public String tier; // public long timeUntilDecay; // public int wins; // } // // Path: src/yanovski/lol/api/models/PlayerStatsSummaryList.java // public class PlayerStatsSummaryList { // public long summonerId; // public List<PlayerStatsSummary> playerStatSummaries; // } // // Path: src/yanovski/lol/api/models/RankedStats.java // public class RankedStats { // public long summonerId; // public long modifyDate; // public String modifyDateStr; // public List<ChampionStats> champions; // } // // Path: src/yanovski/lol/api/models/RecentGames.java // public class RecentGames { // public long summonerId; // public List<Game> games; // } // // Path: src/yanovski/lol/api/models/Team.java // public class Team { // public String createDate; // public String lastGameDate; // public String lastJoinDate; // public String lastJoinedRankedTeamQueueDate; // public List<MatchHistorySummary> matchHistory; // public MessageOfDay messageOfDay; // public String modifyDate; // public String name; // public Roster roster; // public String secondLastJoinDate; // public String status; // public String tag; // public String fullId; // public TeamStatSummary teamStatSummary; // public String thirdLastJoinDate; // public long timestamp; // }
import java.util.List; import retrofit.Callback; import retrofit.client.Response; import retrofit.http.GET; import retrofit.http.Path; import retrofit.http.Query; import yanovski.lol.api.models.ChampionList; import yanovski.lol.api.models.League; import yanovski.lol.api.models.LeagueItem; import yanovski.lol.api.models.PlayerStatsSummaryList; import yanovski.lol.api.models.RankedStats; import yanovski.lol.api.models.RecentGames; import yanovski.lol.api.models.Team;
package yanovski.lol.api.services; /** * Created by Intuitiv-01 on 13-12-11. */ public interface LoLServicesClient { @GET("/api/lol/{region}/v1.3/summoner/by-name/{name}") void getSummonerByName(@Path("region") String region, @Path("name") String name, @Query("api_key") String apiKey, Callback<Response> callback); @GET("/api/lol/{region}/v2.3/league/challenger") void getChallengerLeague(@Path("region") String region, @Query("type") String type, @Query("api_key") String apiKey, Callback<League> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}/entry") void getLeagueEntriesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<LeagueItem>> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}") void getLeaguesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<League>> callback); @GET("/api/lol/{region}/v1.1/champion") void getChampions(@Path("region") String region, @Query("freeToPlay") boolean freeToPlay, @Query("api_key") String apiKey, Callback<ChampionList> callback); @GET("/api/lol/{region}/v1.3/game/by-summoner/{summonerId}/recent")
// Path: src/yanovski/lol/api/models/ChampionList.java // public class ChampionList { // public List<Champion> champions; // } // // Path: src/yanovski/lol/api/models/League.java // public class League { // public long timestamp; // public String queue; // public String name; // public String tier; // public String participantId; // public List<LeagueItem> entries; // } // // Path: src/yanovski/lol/api/models/LeagueItem.java // public class LeagueItem { // public boolean isFreshBlood; // public boolean isHotStreak; // public boolean isInactive; // public boolean isVeteran; // public long lastPlayed; // public String leagueName; // public int leaguePoints; // public int losses; // public MiniSeries miniSeries; // public String playerOrTeamId; // public String playerOrTeamName; // public String queueType; // public String rank; // public String tier; // public long timeUntilDecay; // public int wins; // } // // Path: src/yanovski/lol/api/models/PlayerStatsSummaryList.java // public class PlayerStatsSummaryList { // public long summonerId; // public List<PlayerStatsSummary> playerStatSummaries; // } // // Path: src/yanovski/lol/api/models/RankedStats.java // public class RankedStats { // public long summonerId; // public long modifyDate; // public String modifyDateStr; // public List<ChampionStats> champions; // } // // Path: src/yanovski/lol/api/models/RecentGames.java // public class RecentGames { // public long summonerId; // public List<Game> games; // } // // Path: src/yanovski/lol/api/models/Team.java // public class Team { // public String createDate; // public String lastGameDate; // public String lastJoinDate; // public String lastJoinedRankedTeamQueueDate; // public List<MatchHistorySummary> matchHistory; // public MessageOfDay messageOfDay; // public String modifyDate; // public String name; // public Roster roster; // public String secondLastJoinDate; // public String status; // public String tag; // public String fullId; // public TeamStatSummary teamStatSummary; // public String thirdLastJoinDate; // public long timestamp; // } // Path: src/yanovski/lol/api/services/LoLServicesClient.java import java.util.List; import retrofit.Callback; import retrofit.client.Response; import retrofit.http.GET; import retrofit.http.Path; import retrofit.http.Query; import yanovski.lol.api.models.ChampionList; import yanovski.lol.api.models.League; import yanovski.lol.api.models.LeagueItem; import yanovski.lol.api.models.PlayerStatsSummaryList; import yanovski.lol.api.models.RankedStats; import yanovski.lol.api.models.RecentGames; import yanovski.lol.api.models.Team; package yanovski.lol.api.services; /** * Created by Intuitiv-01 on 13-12-11. */ public interface LoLServicesClient { @GET("/api/lol/{region}/v1.3/summoner/by-name/{name}") void getSummonerByName(@Path("region") String region, @Path("name") String name, @Query("api_key") String apiKey, Callback<Response> callback); @GET("/api/lol/{region}/v2.3/league/challenger") void getChallengerLeague(@Path("region") String region, @Query("type") String type, @Query("api_key") String apiKey, Callback<League> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}/entry") void getLeagueEntriesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<LeagueItem>> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}") void getLeaguesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<League>> callback); @GET("/api/lol/{region}/v1.1/champion") void getChampions(@Path("region") String region, @Query("freeToPlay") boolean freeToPlay, @Query("api_key") String apiKey, Callback<ChampionList> callback); @GET("/api/lol/{region}/v1.3/game/by-summoner/{summonerId}/recent")
void getRecentGamesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<RecentGames> callback);
samuil-yanovski/lol-api-library
src/yanovski/lol/api/services/LoLServicesClient.java
// Path: src/yanovski/lol/api/models/ChampionList.java // public class ChampionList { // public List<Champion> champions; // } // // Path: src/yanovski/lol/api/models/League.java // public class League { // public long timestamp; // public String queue; // public String name; // public String tier; // public String participantId; // public List<LeagueItem> entries; // } // // Path: src/yanovski/lol/api/models/LeagueItem.java // public class LeagueItem { // public boolean isFreshBlood; // public boolean isHotStreak; // public boolean isInactive; // public boolean isVeteran; // public long lastPlayed; // public String leagueName; // public int leaguePoints; // public int losses; // public MiniSeries miniSeries; // public String playerOrTeamId; // public String playerOrTeamName; // public String queueType; // public String rank; // public String tier; // public long timeUntilDecay; // public int wins; // } // // Path: src/yanovski/lol/api/models/PlayerStatsSummaryList.java // public class PlayerStatsSummaryList { // public long summonerId; // public List<PlayerStatsSummary> playerStatSummaries; // } // // Path: src/yanovski/lol/api/models/RankedStats.java // public class RankedStats { // public long summonerId; // public long modifyDate; // public String modifyDateStr; // public List<ChampionStats> champions; // } // // Path: src/yanovski/lol/api/models/RecentGames.java // public class RecentGames { // public long summonerId; // public List<Game> games; // } // // Path: src/yanovski/lol/api/models/Team.java // public class Team { // public String createDate; // public String lastGameDate; // public String lastJoinDate; // public String lastJoinedRankedTeamQueueDate; // public List<MatchHistorySummary> matchHistory; // public MessageOfDay messageOfDay; // public String modifyDate; // public String name; // public Roster roster; // public String secondLastJoinDate; // public String status; // public String tag; // public String fullId; // public TeamStatSummary teamStatSummary; // public String thirdLastJoinDate; // public long timestamp; // }
import java.util.List; import retrofit.Callback; import retrofit.client.Response; import retrofit.http.GET; import retrofit.http.Path; import retrofit.http.Query; import yanovski.lol.api.models.ChampionList; import yanovski.lol.api.models.League; import yanovski.lol.api.models.LeagueItem; import yanovski.lol.api.models.PlayerStatsSummaryList; import yanovski.lol.api.models.RankedStats; import yanovski.lol.api.models.RecentGames; import yanovski.lol.api.models.Team;
package yanovski.lol.api.services; /** * Created by Intuitiv-01 on 13-12-11. */ public interface LoLServicesClient { @GET("/api/lol/{region}/v1.3/summoner/by-name/{name}") void getSummonerByName(@Path("region") String region, @Path("name") String name, @Query("api_key") String apiKey, Callback<Response> callback); @GET("/api/lol/{region}/v2.3/league/challenger") void getChallengerLeague(@Path("region") String region, @Query("type") String type, @Query("api_key") String apiKey, Callback<League> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}/entry") void getLeagueEntriesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<LeagueItem>> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}") void getLeaguesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<League>> callback); @GET("/api/lol/{region}/v1.1/champion") void getChampions(@Path("region") String region, @Query("freeToPlay") boolean freeToPlay, @Query("api_key") String apiKey, Callback<ChampionList> callback); @GET("/api/lol/{region}/v1.3/game/by-summoner/{summonerId}/recent") void getRecentGamesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<RecentGames> callback); @GET("/api/lol/{region}/v1.2/stats/by-summoner/{summonerId}/summary")
// Path: src/yanovski/lol/api/models/ChampionList.java // public class ChampionList { // public List<Champion> champions; // } // // Path: src/yanovski/lol/api/models/League.java // public class League { // public long timestamp; // public String queue; // public String name; // public String tier; // public String participantId; // public List<LeagueItem> entries; // } // // Path: src/yanovski/lol/api/models/LeagueItem.java // public class LeagueItem { // public boolean isFreshBlood; // public boolean isHotStreak; // public boolean isInactive; // public boolean isVeteran; // public long lastPlayed; // public String leagueName; // public int leaguePoints; // public int losses; // public MiniSeries miniSeries; // public String playerOrTeamId; // public String playerOrTeamName; // public String queueType; // public String rank; // public String tier; // public long timeUntilDecay; // public int wins; // } // // Path: src/yanovski/lol/api/models/PlayerStatsSummaryList.java // public class PlayerStatsSummaryList { // public long summonerId; // public List<PlayerStatsSummary> playerStatSummaries; // } // // Path: src/yanovski/lol/api/models/RankedStats.java // public class RankedStats { // public long summonerId; // public long modifyDate; // public String modifyDateStr; // public List<ChampionStats> champions; // } // // Path: src/yanovski/lol/api/models/RecentGames.java // public class RecentGames { // public long summonerId; // public List<Game> games; // } // // Path: src/yanovski/lol/api/models/Team.java // public class Team { // public String createDate; // public String lastGameDate; // public String lastJoinDate; // public String lastJoinedRankedTeamQueueDate; // public List<MatchHistorySummary> matchHistory; // public MessageOfDay messageOfDay; // public String modifyDate; // public String name; // public Roster roster; // public String secondLastJoinDate; // public String status; // public String tag; // public String fullId; // public TeamStatSummary teamStatSummary; // public String thirdLastJoinDate; // public long timestamp; // } // Path: src/yanovski/lol/api/services/LoLServicesClient.java import java.util.List; import retrofit.Callback; import retrofit.client.Response; import retrofit.http.GET; import retrofit.http.Path; import retrofit.http.Query; import yanovski.lol.api.models.ChampionList; import yanovski.lol.api.models.League; import yanovski.lol.api.models.LeagueItem; import yanovski.lol.api.models.PlayerStatsSummaryList; import yanovski.lol.api.models.RankedStats; import yanovski.lol.api.models.RecentGames; import yanovski.lol.api.models.Team; package yanovski.lol.api.services; /** * Created by Intuitiv-01 on 13-12-11. */ public interface LoLServicesClient { @GET("/api/lol/{region}/v1.3/summoner/by-name/{name}") void getSummonerByName(@Path("region") String region, @Path("name") String name, @Query("api_key") String apiKey, Callback<Response> callback); @GET("/api/lol/{region}/v2.3/league/challenger") void getChallengerLeague(@Path("region") String region, @Query("type") String type, @Query("api_key") String apiKey, Callback<League> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}/entry") void getLeagueEntriesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<LeagueItem>> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}") void getLeaguesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<League>> callback); @GET("/api/lol/{region}/v1.1/champion") void getChampions(@Path("region") String region, @Query("freeToPlay") boolean freeToPlay, @Query("api_key") String apiKey, Callback<ChampionList> callback); @GET("/api/lol/{region}/v1.3/game/by-summoner/{summonerId}/recent") void getRecentGamesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<RecentGames> callback); @GET("/api/lol/{region}/v1.2/stats/by-summoner/{summonerId}/summary")
void getStatsBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("region") String season, @Query("api_key") String apiKey, Callback<PlayerStatsSummaryList> callback);
samuil-yanovski/lol-api-library
src/yanovski/lol/api/services/LoLServicesClient.java
// Path: src/yanovski/lol/api/models/ChampionList.java // public class ChampionList { // public List<Champion> champions; // } // // Path: src/yanovski/lol/api/models/League.java // public class League { // public long timestamp; // public String queue; // public String name; // public String tier; // public String participantId; // public List<LeagueItem> entries; // } // // Path: src/yanovski/lol/api/models/LeagueItem.java // public class LeagueItem { // public boolean isFreshBlood; // public boolean isHotStreak; // public boolean isInactive; // public boolean isVeteran; // public long lastPlayed; // public String leagueName; // public int leaguePoints; // public int losses; // public MiniSeries miniSeries; // public String playerOrTeamId; // public String playerOrTeamName; // public String queueType; // public String rank; // public String tier; // public long timeUntilDecay; // public int wins; // } // // Path: src/yanovski/lol/api/models/PlayerStatsSummaryList.java // public class PlayerStatsSummaryList { // public long summonerId; // public List<PlayerStatsSummary> playerStatSummaries; // } // // Path: src/yanovski/lol/api/models/RankedStats.java // public class RankedStats { // public long summonerId; // public long modifyDate; // public String modifyDateStr; // public List<ChampionStats> champions; // } // // Path: src/yanovski/lol/api/models/RecentGames.java // public class RecentGames { // public long summonerId; // public List<Game> games; // } // // Path: src/yanovski/lol/api/models/Team.java // public class Team { // public String createDate; // public String lastGameDate; // public String lastJoinDate; // public String lastJoinedRankedTeamQueueDate; // public List<MatchHistorySummary> matchHistory; // public MessageOfDay messageOfDay; // public String modifyDate; // public String name; // public Roster roster; // public String secondLastJoinDate; // public String status; // public String tag; // public String fullId; // public TeamStatSummary teamStatSummary; // public String thirdLastJoinDate; // public long timestamp; // }
import java.util.List; import retrofit.Callback; import retrofit.client.Response; import retrofit.http.GET; import retrofit.http.Path; import retrofit.http.Query; import yanovski.lol.api.models.ChampionList; import yanovski.lol.api.models.League; import yanovski.lol.api.models.LeagueItem; import yanovski.lol.api.models.PlayerStatsSummaryList; import yanovski.lol.api.models.RankedStats; import yanovski.lol.api.models.RecentGames; import yanovski.lol.api.models.Team;
package yanovski.lol.api.services; /** * Created by Intuitiv-01 on 13-12-11. */ public interface LoLServicesClient { @GET("/api/lol/{region}/v1.3/summoner/by-name/{name}") void getSummonerByName(@Path("region") String region, @Path("name") String name, @Query("api_key") String apiKey, Callback<Response> callback); @GET("/api/lol/{region}/v2.3/league/challenger") void getChallengerLeague(@Path("region") String region, @Query("type") String type, @Query("api_key") String apiKey, Callback<League> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}/entry") void getLeagueEntriesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<LeagueItem>> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}") void getLeaguesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<League>> callback); @GET("/api/lol/{region}/v1.1/champion") void getChampions(@Path("region") String region, @Query("freeToPlay") boolean freeToPlay, @Query("api_key") String apiKey, Callback<ChampionList> callback); @GET("/api/lol/{region}/v1.3/game/by-summoner/{summonerId}/recent") void getRecentGamesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<RecentGames> callback); @GET("/api/lol/{region}/v1.2/stats/by-summoner/{summonerId}/summary") void getStatsBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("region") String season, @Query("api_key") String apiKey, Callback<PlayerStatsSummaryList> callback); @GET("/api/lol/{region}/v1.2/stats/by-summoner/{summonerId}/ranked")
// Path: src/yanovski/lol/api/models/ChampionList.java // public class ChampionList { // public List<Champion> champions; // } // // Path: src/yanovski/lol/api/models/League.java // public class League { // public long timestamp; // public String queue; // public String name; // public String tier; // public String participantId; // public List<LeagueItem> entries; // } // // Path: src/yanovski/lol/api/models/LeagueItem.java // public class LeagueItem { // public boolean isFreshBlood; // public boolean isHotStreak; // public boolean isInactive; // public boolean isVeteran; // public long lastPlayed; // public String leagueName; // public int leaguePoints; // public int losses; // public MiniSeries miniSeries; // public String playerOrTeamId; // public String playerOrTeamName; // public String queueType; // public String rank; // public String tier; // public long timeUntilDecay; // public int wins; // } // // Path: src/yanovski/lol/api/models/PlayerStatsSummaryList.java // public class PlayerStatsSummaryList { // public long summonerId; // public List<PlayerStatsSummary> playerStatSummaries; // } // // Path: src/yanovski/lol/api/models/RankedStats.java // public class RankedStats { // public long summonerId; // public long modifyDate; // public String modifyDateStr; // public List<ChampionStats> champions; // } // // Path: src/yanovski/lol/api/models/RecentGames.java // public class RecentGames { // public long summonerId; // public List<Game> games; // } // // Path: src/yanovski/lol/api/models/Team.java // public class Team { // public String createDate; // public String lastGameDate; // public String lastJoinDate; // public String lastJoinedRankedTeamQueueDate; // public List<MatchHistorySummary> matchHistory; // public MessageOfDay messageOfDay; // public String modifyDate; // public String name; // public Roster roster; // public String secondLastJoinDate; // public String status; // public String tag; // public String fullId; // public TeamStatSummary teamStatSummary; // public String thirdLastJoinDate; // public long timestamp; // } // Path: src/yanovski/lol/api/services/LoLServicesClient.java import java.util.List; import retrofit.Callback; import retrofit.client.Response; import retrofit.http.GET; import retrofit.http.Path; import retrofit.http.Query; import yanovski.lol.api.models.ChampionList; import yanovski.lol.api.models.League; import yanovski.lol.api.models.LeagueItem; import yanovski.lol.api.models.PlayerStatsSummaryList; import yanovski.lol.api.models.RankedStats; import yanovski.lol.api.models.RecentGames; import yanovski.lol.api.models.Team; package yanovski.lol.api.services; /** * Created by Intuitiv-01 on 13-12-11. */ public interface LoLServicesClient { @GET("/api/lol/{region}/v1.3/summoner/by-name/{name}") void getSummonerByName(@Path("region") String region, @Path("name") String name, @Query("api_key") String apiKey, Callback<Response> callback); @GET("/api/lol/{region}/v2.3/league/challenger") void getChallengerLeague(@Path("region") String region, @Query("type") String type, @Query("api_key") String apiKey, Callback<League> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}/entry") void getLeagueEntriesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<LeagueItem>> callback); @GET("/api/lol/{region}/v2.3/league/by-summoner/{summonerId}") void getLeaguesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<List<League>> callback); @GET("/api/lol/{region}/v1.1/champion") void getChampions(@Path("region") String region, @Query("freeToPlay") boolean freeToPlay, @Query("api_key") String apiKey, Callback<ChampionList> callback); @GET("/api/lol/{region}/v1.3/game/by-summoner/{summonerId}/recent") void getRecentGamesBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<RecentGames> callback); @GET("/api/lol/{region}/v1.2/stats/by-summoner/{summonerId}/summary") void getStatsBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("region") String season, @Query("api_key") String apiKey, Callback<PlayerStatsSummaryList> callback); @GET("/api/lol/{region}/v1.2/stats/by-summoner/{summonerId}/ranked")
void getRandkedStatsBySummnerId(@Path("region") String region, @Path("summonerId") long summonerId, @Query("api_key") String apiKey, Callback<RankedStats> callback);
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/ContactPhoneAdapter.java
// Path: src/com/abewy/android/apps/contacts/adapter/holder/ContactPhoneHolder.java // public class ContactPhoneHolder // { // public final TextView primaryText; // public final TextView secondaryText; // public final ImageButton messageButton; // // public ContactPhoneHolder(TextView primaryText, TextView secondaryText, ImageButton messageButton) // { // this.primaryText = primaryText; // this.secondaryText = secondaryText; // this.messageButton = messageButton; // } // } // // Path: src/com/abewy/android/apps/contacts/model/ContactPhone.java // public class ContactPhone extends BaseContact // { // public final String phoneNumber; // public final int type; // public final String label; // // public ContactPhone(String phoneNumber, int type) // { // this(phoneNumber, type, ""); // } // // public ContactPhone(String phoneNumber, int type, String label) // { // this.phoneNumber = phoneNumber; // this.type = type; // this.label = label; // } // // @Override // public int getItemViewType() // { // return ObjectType.CONTACT_PHONE; // } // // @Override // public String getItemPrimaryLabel() // { // return phoneNumber; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/PhoneUtil.java // public class PhoneUtil // { // // public static void openDialActivity(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "openDialActivity: ", activityException); // } // } // // public static void callNumber(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_CALL); // intent.setData(Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "callNumber: ", activityException); // } // } // // public static void sendSMS(Context context, String phoneNumber) // { // try // { // Uri uri = Uri.parse("sms:" + phoneNumber); // Intent intent = new Intent(Intent.ACTION_VIEW, uri); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendSMS: ", activityException); // } // } // // public static void sendMail(Context context, String email) // { // Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null)); // // try // { // context.startActivity(Intent.createChooser(intent, "Send mail...")); // } // catch (android.content.ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendMail: ", activityException); // } // } // // public static void openURL(Context context, String url) // { // if (url.indexOf("http://") != 0) // { // if (url.indexOf("https://") != 0) // url = "http://" + url; // } // // Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); // context.startActivity(intent); // } // }
import android.provider.ContactsContract.CommonDataKinds.Phone; import android.telephony.PhoneNumberUtils; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.ContactPhoneHolder; import com.abewy.android.apps.contacts.model.ContactPhone; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.util.PhoneUtil; import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat; import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
package com.abewy.android.apps.contacts.adapter; public class ContactPhoneAdapter extends ContactBaseAdapter { public ContactPhoneAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_contact_phone; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text); TextView secondaryText = (TextView) view.findViewById(R.id.secondary_text); ImageButton button = (ImageButton) view.findViewById(R.id.message_button);
// Path: src/com/abewy/android/apps/contacts/adapter/holder/ContactPhoneHolder.java // public class ContactPhoneHolder // { // public final TextView primaryText; // public final TextView secondaryText; // public final ImageButton messageButton; // // public ContactPhoneHolder(TextView primaryText, TextView secondaryText, ImageButton messageButton) // { // this.primaryText = primaryText; // this.secondaryText = secondaryText; // this.messageButton = messageButton; // } // } // // Path: src/com/abewy/android/apps/contacts/model/ContactPhone.java // public class ContactPhone extends BaseContact // { // public final String phoneNumber; // public final int type; // public final String label; // // public ContactPhone(String phoneNumber, int type) // { // this(phoneNumber, type, ""); // } // // public ContactPhone(String phoneNumber, int type, String label) // { // this.phoneNumber = phoneNumber; // this.type = type; // this.label = label; // } // // @Override // public int getItemViewType() // { // return ObjectType.CONTACT_PHONE; // } // // @Override // public String getItemPrimaryLabel() // { // return phoneNumber; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/PhoneUtil.java // public class PhoneUtil // { // // public static void openDialActivity(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "openDialActivity: ", activityException); // } // } // // public static void callNumber(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_CALL); // intent.setData(Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "callNumber: ", activityException); // } // } // // public static void sendSMS(Context context, String phoneNumber) // { // try // { // Uri uri = Uri.parse("sms:" + phoneNumber); // Intent intent = new Intent(Intent.ACTION_VIEW, uri); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendSMS: ", activityException); // } // } // // public static void sendMail(Context context, String email) // { // Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null)); // // try // { // context.startActivity(Intent.createChooser(intent, "Send mail...")); // } // catch (android.content.ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendMail: ", activityException); // } // } // // public static void openURL(Context context, String url) // { // if (url.indexOf("http://") != 0) // { // if (url.indexOf("https://") != 0) // url = "http://" + url; // } // // Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); // context.startActivity(intent); // } // } // Path: src/com/abewy/android/apps/contacts/adapter/ContactPhoneAdapter.java import android.provider.ContactsContract.CommonDataKinds.Phone; import android.telephony.PhoneNumberUtils; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.ContactPhoneHolder; import com.abewy.android.apps.contacts.model.ContactPhone; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.util.PhoneUtil; import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat; import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber; package com.abewy.android.apps.contacts.adapter; public class ContactPhoneAdapter extends ContactBaseAdapter { public ContactPhoneAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_contact_phone; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text); TextView secondaryText = (TextView) view.findViewById(R.id.secondary_text); ImageButton button = (ImageButton) view.findViewById(R.id.message_button);
setHolder(view, new ContactPhoneHolder(primaryText, secondaryText, button));
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/ContactPhoneAdapter.java
// Path: src/com/abewy/android/apps/contacts/adapter/holder/ContactPhoneHolder.java // public class ContactPhoneHolder // { // public final TextView primaryText; // public final TextView secondaryText; // public final ImageButton messageButton; // // public ContactPhoneHolder(TextView primaryText, TextView secondaryText, ImageButton messageButton) // { // this.primaryText = primaryText; // this.secondaryText = secondaryText; // this.messageButton = messageButton; // } // } // // Path: src/com/abewy/android/apps/contacts/model/ContactPhone.java // public class ContactPhone extends BaseContact // { // public final String phoneNumber; // public final int type; // public final String label; // // public ContactPhone(String phoneNumber, int type) // { // this(phoneNumber, type, ""); // } // // public ContactPhone(String phoneNumber, int type, String label) // { // this.phoneNumber = phoneNumber; // this.type = type; // this.label = label; // } // // @Override // public int getItemViewType() // { // return ObjectType.CONTACT_PHONE; // } // // @Override // public String getItemPrimaryLabel() // { // return phoneNumber; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/PhoneUtil.java // public class PhoneUtil // { // // public static void openDialActivity(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "openDialActivity: ", activityException); // } // } // // public static void callNumber(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_CALL); // intent.setData(Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "callNumber: ", activityException); // } // } // // public static void sendSMS(Context context, String phoneNumber) // { // try // { // Uri uri = Uri.parse("sms:" + phoneNumber); // Intent intent = new Intent(Intent.ACTION_VIEW, uri); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendSMS: ", activityException); // } // } // // public static void sendMail(Context context, String email) // { // Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null)); // // try // { // context.startActivity(Intent.createChooser(intent, "Send mail...")); // } // catch (android.content.ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendMail: ", activityException); // } // } // // public static void openURL(Context context, String url) // { // if (url.indexOf("http://") != 0) // { // if (url.indexOf("https://") != 0) // url = "http://" + url; // } // // Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); // context.startActivity(intent); // } // }
import android.provider.ContactsContract.CommonDataKinds.Phone; import android.telephony.PhoneNumberUtils; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.ContactPhoneHolder; import com.abewy.android.apps.contacts.model.ContactPhone; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.util.PhoneUtil; import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat; import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
package com.abewy.android.apps.contacts.adapter; public class ContactPhoneAdapter extends ContactBaseAdapter { public ContactPhoneAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_contact_phone; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text); TextView secondaryText = (TextView) view.findViewById(R.id.secondary_text); ImageButton button = (ImageButton) view.findViewById(R.id.message_button); setHolder(view, new ContactPhoneHolder(primaryText, secondaryText, button)); } @Override
// Path: src/com/abewy/android/apps/contacts/adapter/holder/ContactPhoneHolder.java // public class ContactPhoneHolder // { // public final TextView primaryText; // public final TextView secondaryText; // public final ImageButton messageButton; // // public ContactPhoneHolder(TextView primaryText, TextView secondaryText, ImageButton messageButton) // { // this.primaryText = primaryText; // this.secondaryText = secondaryText; // this.messageButton = messageButton; // } // } // // Path: src/com/abewy/android/apps/contacts/model/ContactPhone.java // public class ContactPhone extends BaseContact // { // public final String phoneNumber; // public final int type; // public final String label; // // public ContactPhone(String phoneNumber, int type) // { // this(phoneNumber, type, ""); // } // // public ContactPhone(String phoneNumber, int type, String label) // { // this.phoneNumber = phoneNumber; // this.type = type; // this.label = label; // } // // @Override // public int getItemViewType() // { // return ObjectType.CONTACT_PHONE; // } // // @Override // public String getItemPrimaryLabel() // { // return phoneNumber; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/PhoneUtil.java // public class PhoneUtil // { // // public static void openDialActivity(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "openDialActivity: ", activityException); // } // } // // public static void callNumber(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_CALL); // intent.setData(Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "callNumber: ", activityException); // } // } // // public static void sendSMS(Context context, String phoneNumber) // { // try // { // Uri uri = Uri.parse("sms:" + phoneNumber); // Intent intent = new Intent(Intent.ACTION_VIEW, uri); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendSMS: ", activityException); // } // } // // public static void sendMail(Context context, String email) // { // Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null)); // // try // { // context.startActivity(Intent.createChooser(intent, "Send mail...")); // } // catch (android.content.ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendMail: ", activityException); // } // } // // public static void openURL(Context context, String url) // { // if (url.indexOf("http://") != 0) // { // if (url.indexOf("https://") != 0) // url = "http://" + url; // } // // Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); // context.startActivity(intent); // } // } // Path: src/com/abewy/android/apps/contacts/adapter/ContactPhoneAdapter.java import android.provider.ContactsContract.CommonDataKinds.Phone; import android.telephony.PhoneNumberUtils; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.ContactPhoneHolder; import com.abewy.android.apps.contacts.model.ContactPhone; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.util.PhoneUtil; import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat; import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber; package com.abewy.android.apps.contacts.adapter; public class ContactPhoneAdapter extends ContactBaseAdapter { public ContactPhoneAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_contact_phone; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text); TextView secondaryText = (TextView) view.findViewById(R.id.secondary_text); ImageButton button = (ImageButton) view.findViewById(R.id.message_button); setHolder(view, new ContactPhoneHolder(primaryText, secondaryText, button)); } @Override
public void bindData(View view, BaseType data, int position)
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/ContactPhoneAdapter.java
// Path: src/com/abewy/android/apps/contacts/adapter/holder/ContactPhoneHolder.java // public class ContactPhoneHolder // { // public final TextView primaryText; // public final TextView secondaryText; // public final ImageButton messageButton; // // public ContactPhoneHolder(TextView primaryText, TextView secondaryText, ImageButton messageButton) // { // this.primaryText = primaryText; // this.secondaryText = secondaryText; // this.messageButton = messageButton; // } // } // // Path: src/com/abewy/android/apps/contacts/model/ContactPhone.java // public class ContactPhone extends BaseContact // { // public final String phoneNumber; // public final int type; // public final String label; // // public ContactPhone(String phoneNumber, int type) // { // this(phoneNumber, type, ""); // } // // public ContactPhone(String phoneNumber, int type, String label) // { // this.phoneNumber = phoneNumber; // this.type = type; // this.label = label; // } // // @Override // public int getItemViewType() // { // return ObjectType.CONTACT_PHONE; // } // // @Override // public String getItemPrimaryLabel() // { // return phoneNumber; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/PhoneUtil.java // public class PhoneUtil // { // // public static void openDialActivity(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "openDialActivity: ", activityException); // } // } // // public static void callNumber(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_CALL); // intent.setData(Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "callNumber: ", activityException); // } // } // // public static void sendSMS(Context context, String phoneNumber) // { // try // { // Uri uri = Uri.parse("sms:" + phoneNumber); // Intent intent = new Intent(Intent.ACTION_VIEW, uri); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendSMS: ", activityException); // } // } // // public static void sendMail(Context context, String email) // { // Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null)); // // try // { // context.startActivity(Intent.createChooser(intent, "Send mail...")); // } // catch (android.content.ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendMail: ", activityException); // } // } // // public static void openURL(Context context, String url) // { // if (url.indexOf("http://") != 0) // { // if (url.indexOf("https://") != 0) // url = "http://" + url; // } // // Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); // context.startActivity(intent); // } // }
import android.provider.ContactsContract.CommonDataKinds.Phone; import android.telephony.PhoneNumberUtils; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.ContactPhoneHolder; import com.abewy.android.apps.contacts.model.ContactPhone; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.util.PhoneUtil; import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat; import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
package com.abewy.android.apps.contacts.adapter; public class ContactPhoneAdapter extends ContactBaseAdapter { public ContactPhoneAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_contact_phone; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text); TextView secondaryText = (TextView) view.findViewById(R.id.secondary_text); ImageButton button = (ImageButton) view.findViewById(R.id.message_button); setHolder(view, new ContactPhoneHolder(primaryText, secondaryText, button)); } @Override public void bindData(View view, BaseType data, int position) { final ContactPhoneHolder holder = (ContactPhoneHolder) getHolder(view);
// Path: src/com/abewy/android/apps/contacts/adapter/holder/ContactPhoneHolder.java // public class ContactPhoneHolder // { // public final TextView primaryText; // public final TextView secondaryText; // public final ImageButton messageButton; // // public ContactPhoneHolder(TextView primaryText, TextView secondaryText, ImageButton messageButton) // { // this.primaryText = primaryText; // this.secondaryText = secondaryText; // this.messageButton = messageButton; // } // } // // Path: src/com/abewy/android/apps/contacts/model/ContactPhone.java // public class ContactPhone extends BaseContact // { // public final String phoneNumber; // public final int type; // public final String label; // // public ContactPhone(String phoneNumber, int type) // { // this(phoneNumber, type, ""); // } // // public ContactPhone(String phoneNumber, int type, String label) // { // this.phoneNumber = phoneNumber; // this.type = type; // this.label = label; // } // // @Override // public int getItemViewType() // { // return ObjectType.CONTACT_PHONE; // } // // @Override // public String getItemPrimaryLabel() // { // return phoneNumber; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/PhoneUtil.java // public class PhoneUtil // { // // public static void openDialActivity(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "openDialActivity: ", activityException); // } // } // // public static void callNumber(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_CALL); // intent.setData(Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "callNumber: ", activityException); // } // } // // public static void sendSMS(Context context, String phoneNumber) // { // try // { // Uri uri = Uri.parse("sms:" + phoneNumber); // Intent intent = new Intent(Intent.ACTION_VIEW, uri); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendSMS: ", activityException); // } // } // // public static void sendMail(Context context, String email) // { // Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null)); // // try // { // context.startActivity(Intent.createChooser(intent, "Send mail...")); // } // catch (android.content.ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendMail: ", activityException); // } // } // // public static void openURL(Context context, String url) // { // if (url.indexOf("http://") != 0) // { // if (url.indexOf("https://") != 0) // url = "http://" + url; // } // // Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); // context.startActivity(intent); // } // } // Path: src/com/abewy/android/apps/contacts/adapter/ContactPhoneAdapter.java import android.provider.ContactsContract.CommonDataKinds.Phone; import android.telephony.PhoneNumberUtils; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.ContactPhoneHolder; import com.abewy.android.apps.contacts.model.ContactPhone; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.util.PhoneUtil; import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat; import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber; package com.abewy.android.apps.contacts.adapter; public class ContactPhoneAdapter extends ContactBaseAdapter { public ContactPhoneAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_contact_phone; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text); TextView secondaryText = (TextView) view.findViewById(R.id.secondary_text); ImageButton button = (ImageButton) view.findViewById(R.id.message_button); setHolder(view, new ContactPhoneHolder(primaryText, secondaryText, button)); } @Override public void bindData(View view, BaseType data, int position) { final ContactPhoneHolder holder = (ContactPhoneHolder) getHolder(view);
final ContactPhone phone = ((ContactPhone) data);
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/ContactPhoneAdapter.java
// Path: src/com/abewy/android/apps/contacts/adapter/holder/ContactPhoneHolder.java // public class ContactPhoneHolder // { // public final TextView primaryText; // public final TextView secondaryText; // public final ImageButton messageButton; // // public ContactPhoneHolder(TextView primaryText, TextView secondaryText, ImageButton messageButton) // { // this.primaryText = primaryText; // this.secondaryText = secondaryText; // this.messageButton = messageButton; // } // } // // Path: src/com/abewy/android/apps/contacts/model/ContactPhone.java // public class ContactPhone extends BaseContact // { // public final String phoneNumber; // public final int type; // public final String label; // // public ContactPhone(String phoneNumber, int type) // { // this(phoneNumber, type, ""); // } // // public ContactPhone(String phoneNumber, int type, String label) // { // this.phoneNumber = phoneNumber; // this.type = type; // this.label = label; // } // // @Override // public int getItemViewType() // { // return ObjectType.CONTACT_PHONE; // } // // @Override // public String getItemPrimaryLabel() // { // return phoneNumber; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/PhoneUtil.java // public class PhoneUtil // { // // public static void openDialActivity(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "openDialActivity: ", activityException); // } // } // // public static void callNumber(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_CALL); // intent.setData(Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "callNumber: ", activityException); // } // } // // public static void sendSMS(Context context, String phoneNumber) // { // try // { // Uri uri = Uri.parse("sms:" + phoneNumber); // Intent intent = new Intent(Intent.ACTION_VIEW, uri); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendSMS: ", activityException); // } // } // // public static void sendMail(Context context, String email) // { // Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null)); // // try // { // context.startActivity(Intent.createChooser(intent, "Send mail...")); // } // catch (android.content.ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendMail: ", activityException); // } // } // // public static void openURL(Context context, String url) // { // if (url.indexOf("http://") != 0) // { // if (url.indexOf("https://") != 0) // url = "http://" + url; // } // // Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); // context.startActivity(intent); // } // }
import android.provider.ContactsContract.CommonDataKinds.Phone; import android.telephony.PhoneNumberUtils; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.ContactPhoneHolder; import com.abewy.android.apps.contacts.model.ContactPhone; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.util.PhoneUtil; import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat; import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
setHolder(view, new ContactPhoneHolder(primaryText, secondaryText, button)); } @Override public void bindData(View view, BaseType data, int position) { final ContactPhoneHolder holder = (ContactPhoneHolder) getHolder(view); final ContactPhone phone = ((ContactPhone) data); PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); try { PhoneNumber numberProto = phoneUtil.parse(phone.phoneNumber, ""); holder.primaryText.setText(phoneUtil.format(numberProto, PhoneNumberFormat.NATIONAL)); } catch (NumberParseException e) { holder.primaryText.setText(phone.phoneNumber); } holder.secondaryText.setText(Phone.getTypeLabel(holder.secondaryText.getResources(), phone.type, phone.label)); holder.messageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
// Path: src/com/abewy/android/apps/contacts/adapter/holder/ContactPhoneHolder.java // public class ContactPhoneHolder // { // public final TextView primaryText; // public final TextView secondaryText; // public final ImageButton messageButton; // // public ContactPhoneHolder(TextView primaryText, TextView secondaryText, ImageButton messageButton) // { // this.primaryText = primaryText; // this.secondaryText = secondaryText; // this.messageButton = messageButton; // } // } // // Path: src/com/abewy/android/apps/contacts/model/ContactPhone.java // public class ContactPhone extends BaseContact // { // public final String phoneNumber; // public final int type; // public final String label; // // public ContactPhone(String phoneNumber, int type) // { // this(phoneNumber, type, ""); // } // // public ContactPhone(String phoneNumber, int type, String label) // { // this.phoneNumber = phoneNumber; // this.type = type; // this.label = label; // } // // @Override // public int getItemViewType() // { // return ObjectType.CONTACT_PHONE; // } // // @Override // public String getItemPrimaryLabel() // { // return phoneNumber; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/PhoneUtil.java // public class PhoneUtil // { // // public static void openDialActivity(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "openDialActivity: ", activityException); // } // } // // public static void callNumber(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_CALL); // intent.setData(Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "callNumber: ", activityException); // } // } // // public static void sendSMS(Context context, String phoneNumber) // { // try // { // Uri uri = Uri.parse("sms:" + phoneNumber); // Intent intent = new Intent(Intent.ACTION_VIEW, uri); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendSMS: ", activityException); // } // } // // public static void sendMail(Context context, String email) // { // Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null)); // // try // { // context.startActivity(Intent.createChooser(intent, "Send mail...")); // } // catch (android.content.ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendMail: ", activityException); // } // } // // public static void openURL(Context context, String url) // { // if (url.indexOf("http://") != 0) // { // if (url.indexOf("https://") != 0) // url = "http://" + url; // } // // Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); // context.startActivity(intent); // } // } // Path: src/com/abewy/android/apps/contacts/adapter/ContactPhoneAdapter.java import android.provider.ContactsContract.CommonDataKinds.Phone; import android.telephony.PhoneNumberUtils; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.ContactPhoneHolder; import com.abewy.android.apps.contacts.model.ContactPhone; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.util.PhoneUtil; import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat; import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber; setHolder(view, new ContactPhoneHolder(primaryText, secondaryText, button)); } @Override public void bindData(View view, BaseType data, int position) { final ContactPhoneHolder holder = (ContactPhoneHolder) getHolder(view); final ContactPhone phone = ((ContactPhone) data); PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); try { PhoneNumber numberProto = phoneUtil.parse(phone.phoneNumber, ""); holder.primaryText.setText(phoneUtil.format(numberProto, PhoneNumberFormat.NATIONAL)); } catch (NumberParseException e) { holder.primaryText.setText(phone.phoneNumber); } holder.secondaryText.setText(Phone.getTypeLabel(holder.secondaryText.getResources(), phone.type, phone.label)); holder.messageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
PhoneUtil.sendSMS(v.getContext(), phone.phoneNumber);
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/GroupAdapter.java
// Path: src/com/abewy/android/apps/contacts/adapter/holder/GroupHolder.java // public class GroupHolder // { // public final TextView title; // public final TextView size; // // public GroupHolder(TextView title, TextView size) // { // this.title = title; // this.size = size; // } // } // // Path: src/com/abewy/android/apps/contacts/model/Group.java // public class Group extends BaseType // { // private long id; // private String title; // private int size; // // public Group() // { // // } // // public Group(long id, String title, int size) // { // this.id = id; // this.title = title; // this.size = size; // } // // @Override // public int getItemViewType() // { // return ObjectType.GROUP; // } // // @Override // public String getItemPrimaryLabel() // { // return title; // } // // public long getId() // { // return id; // } // // public void setId(long id) // { // this.id = id; // } // // public String getTitle() // { // return title; // } // // public void setTitle(String title) // { // this.title = title; // } // // public int getSize() // { // return size; // } // // public void setSize(int size) // { // this.size = size; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // }
import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.GroupHolder; import com.abewy.android.apps.contacts.model.Group; import com.abewy.android.extended.items.BaseType;
package com.abewy.android.apps.contacts.adapter; public class GroupAdapter extends ContactBaseAdapter { public GroupAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_dropdown; } @Override protected void attachViewHolder(View view) {
// Path: src/com/abewy/android/apps/contacts/adapter/holder/GroupHolder.java // public class GroupHolder // { // public final TextView title; // public final TextView size; // // public GroupHolder(TextView title, TextView size) // { // this.title = title; // this.size = size; // } // } // // Path: src/com/abewy/android/apps/contacts/model/Group.java // public class Group extends BaseType // { // private long id; // private String title; // private int size; // // public Group() // { // // } // // public Group(long id, String title, int size) // { // this.id = id; // this.title = title; // this.size = size; // } // // @Override // public int getItemViewType() // { // return ObjectType.GROUP; // } // // @Override // public String getItemPrimaryLabel() // { // return title; // } // // public long getId() // { // return id; // } // // public void setId(long id) // { // this.id = id; // } // // public String getTitle() // { // return title; // } // // public void setTitle(String title) // { // this.title = title; // } // // public int getSize() // { // return size; // } // // public void setSize(int size) // { // this.size = size; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // Path: src/com/abewy/android/apps/contacts/adapter/GroupAdapter.java import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.GroupHolder; import com.abewy.android.apps.contacts.model.Group; import com.abewy.android.extended.items.BaseType; package com.abewy.android.apps.contacts.adapter; public class GroupAdapter extends ContactBaseAdapter { public GroupAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_dropdown; } @Override protected void attachViewHolder(View view) {
view.setTag(new GroupHolder((TextView) view.findViewById(R.id.title), (TextView) view.findViewById(R.id.size)));
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/GroupAdapter.java
// Path: src/com/abewy/android/apps/contacts/adapter/holder/GroupHolder.java // public class GroupHolder // { // public final TextView title; // public final TextView size; // // public GroupHolder(TextView title, TextView size) // { // this.title = title; // this.size = size; // } // } // // Path: src/com/abewy/android/apps/contacts/model/Group.java // public class Group extends BaseType // { // private long id; // private String title; // private int size; // // public Group() // { // // } // // public Group(long id, String title, int size) // { // this.id = id; // this.title = title; // this.size = size; // } // // @Override // public int getItemViewType() // { // return ObjectType.GROUP; // } // // @Override // public String getItemPrimaryLabel() // { // return title; // } // // public long getId() // { // return id; // } // // public void setId(long id) // { // this.id = id; // } // // public String getTitle() // { // return title; // } // // public void setTitle(String title) // { // this.title = title; // } // // public int getSize() // { // return size; // } // // public void setSize(int size) // { // this.size = size; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // }
import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.GroupHolder; import com.abewy.android.apps.contacts.model.Group; import com.abewy.android.extended.items.BaseType;
package com.abewy.android.apps.contacts.adapter; public class GroupAdapter extends ContactBaseAdapter { public GroupAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_dropdown; } @Override protected void attachViewHolder(View view) { view.setTag(new GroupHolder((TextView) view.findViewById(R.id.title), (TextView) view.findViewById(R.id.size))); } @Override
// Path: src/com/abewy/android/apps/contacts/adapter/holder/GroupHolder.java // public class GroupHolder // { // public final TextView title; // public final TextView size; // // public GroupHolder(TextView title, TextView size) // { // this.title = title; // this.size = size; // } // } // // Path: src/com/abewy/android/apps/contacts/model/Group.java // public class Group extends BaseType // { // private long id; // private String title; // private int size; // // public Group() // { // // } // // public Group(long id, String title, int size) // { // this.id = id; // this.title = title; // this.size = size; // } // // @Override // public int getItemViewType() // { // return ObjectType.GROUP; // } // // @Override // public String getItemPrimaryLabel() // { // return title; // } // // public long getId() // { // return id; // } // // public void setId(long id) // { // this.id = id; // } // // public String getTitle() // { // return title; // } // // public void setTitle(String title) // { // this.title = title; // } // // public int getSize() // { // return size; // } // // public void setSize(int size) // { // this.size = size; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // Path: src/com/abewy/android/apps/contacts/adapter/GroupAdapter.java import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.GroupHolder; import com.abewy.android.apps.contacts.model.Group; import com.abewy.android.extended.items.BaseType; package com.abewy.android.apps.contacts.adapter; public class GroupAdapter extends ContactBaseAdapter { public GroupAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_dropdown; } @Override protected void attachViewHolder(View view) { view.setTag(new GroupHolder((TextView) view.findViewById(R.id.title), (TextView) view.findViewById(R.id.size))); } @Override
public void bindData(View view, BaseType data, int position)
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/GroupAdapter.java
// Path: src/com/abewy/android/apps/contacts/adapter/holder/GroupHolder.java // public class GroupHolder // { // public final TextView title; // public final TextView size; // // public GroupHolder(TextView title, TextView size) // { // this.title = title; // this.size = size; // } // } // // Path: src/com/abewy/android/apps/contacts/model/Group.java // public class Group extends BaseType // { // private long id; // private String title; // private int size; // // public Group() // { // // } // // public Group(long id, String title, int size) // { // this.id = id; // this.title = title; // this.size = size; // } // // @Override // public int getItemViewType() // { // return ObjectType.GROUP; // } // // @Override // public String getItemPrimaryLabel() // { // return title; // } // // public long getId() // { // return id; // } // // public void setId(long id) // { // this.id = id; // } // // public String getTitle() // { // return title; // } // // public void setTitle(String title) // { // this.title = title; // } // // public int getSize() // { // return size; // } // // public void setSize(int size) // { // this.size = size; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // }
import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.GroupHolder; import com.abewy.android.apps.contacts.model.Group; import com.abewy.android.extended.items.BaseType;
package com.abewy.android.apps.contacts.adapter; public class GroupAdapter extends ContactBaseAdapter { public GroupAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_dropdown; } @Override protected void attachViewHolder(View view) { view.setTag(new GroupHolder((TextView) view.findViewById(R.id.title), (TextView) view.findViewById(R.id.size))); } @Override public void bindData(View view, BaseType data, int position) {
// Path: src/com/abewy/android/apps/contacts/adapter/holder/GroupHolder.java // public class GroupHolder // { // public final TextView title; // public final TextView size; // // public GroupHolder(TextView title, TextView size) // { // this.title = title; // this.size = size; // } // } // // Path: src/com/abewy/android/apps/contacts/model/Group.java // public class Group extends BaseType // { // private long id; // private String title; // private int size; // // public Group() // { // // } // // public Group(long id, String title, int size) // { // this.id = id; // this.title = title; // this.size = size; // } // // @Override // public int getItemViewType() // { // return ObjectType.GROUP; // } // // @Override // public String getItemPrimaryLabel() // { // return title; // } // // public long getId() // { // return id; // } // // public void setId(long id) // { // this.id = id; // } // // public String getTitle() // { // return title; // } // // public void setTitle(String title) // { // this.title = title; // } // // public int getSize() // { // return size; // } // // public void setSize(int size) // { // this.size = size; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // Path: src/com/abewy/android/apps/contacts/adapter/GroupAdapter.java import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.GroupHolder; import com.abewy.android.apps.contacts.model.Group; import com.abewy.android.extended.items.BaseType; package com.abewy.android.apps.contacts.adapter; public class GroupAdapter extends ContactBaseAdapter { public GroupAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_dropdown; } @Override protected void attachViewHolder(View view) { view.setTag(new GroupHolder((TextView) view.findViewById(R.id.title), (TextView) view.findViewById(R.id.size))); } @Override public void bindData(View view, BaseType data, int position) {
Group group = (Group) data;
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/TextItemAdapter.java
// Path: src/com/abewy/android/apps/contacts/adapter/holder/SimpleTextHolder.java // public class SimpleTextHolder // { // public final TextView primaryText; // // public SimpleTextHolder(TextView primaryText) // { // this.primaryText = primaryText; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/TextItem.java // public class TextItem extends BaseType // { // public final String text; // // public TextItem(String text) // { // this.text = text; // } // // public int getItemViewType() // { // return BaseType.TEXT; // } // // @Override // public String getItemPrimaryLabel() // { // return ""; // } // }
import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.SimpleTextHolder; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.items.TextItem;
package com.abewy.android.apps.contacts.adapter; public class TextItemAdapter extends ContactBaseAdapter { public TextItemAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_text; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text);
// Path: src/com/abewy/android/apps/contacts/adapter/holder/SimpleTextHolder.java // public class SimpleTextHolder // { // public final TextView primaryText; // // public SimpleTextHolder(TextView primaryText) // { // this.primaryText = primaryText; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/TextItem.java // public class TextItem extends BaseType // { // public final String text; // // public TextItem(String text) // { // this.text = text; // } // // public int getItemViewType() // { // return BaseType.TEXT; // } // // @Override // public String getItemPrimaryLabel() // { // return ""; // } // } // Path: src/com/abewy/android/apps/contacts/adapter/TextItemAdapter.java import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.SimpleTextHolder; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.items.TextItem; package com.abewy.android.apps.contacts.adapter; public class TextItemAdapter extends ContactBaseAdapter { public TextItemAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_text; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text);
setHolder(view, new SimpleTextHolder(primaryText));
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/TextItemAdapter.java
// Path: src/com/abewy/android/apps/contacts/adapter/holder/SimpleTextHolder.java // public class SimpleTextHolder // { // public final TextView primaryText; // // public SimpleTextHolder(TextView primaryText) // { // this.primaryText = primaryText; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/TextItem.java // public class TextItem extends BaseType // { // public final String text; // // public TextItem(String text) // { // this.text = text; // } // // public int getItemViewType() // { // return BaseType.TEXT; // } // // @Override // public String getItemPrimaryLabel() // { // return ""; // } // }
import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.SimpleTextHolder; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.items.TextItem;
package com.abewy.android.apps.contacts.adapter; public class TextItemAdapter extends ContactBaseAdapter { public TextItemAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_text; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text); setHolder(view, new SimpleTextHolder(primaryText)); } @Override
// Path: src/com/abewy/android/apps/contacts/adapter/holder/SimpleTextHolder.java // public class SimpleTextHolder // { // public final TextView primaryText; // // public SimpleTextHolder(TextView primaryText) // { // this.primaryText = primaryText; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/TextItem.java // public class TextItem extends BaseType // { // public final String text; // // public TextItem(String text) // { // this.text = text; // } // // public int getItemViewType() // { // return BaseType.TEXT; // } // // @Override // public String getItemPrimaryLabel() // { // return ""; // } // } // Path: src/com/abewy/android/apps/contacts/adapter/TextItemAdapter.java import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.SimpleTextHolder; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.items.TextItem; package com.abewy.android.apps.contacts.adapter; public class TextItemAdapter extends ContactBaseAdapter { public TextItemAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_text; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text); setHolder(view, new SimpleTextHolder(primaryText)); } @Override
public void bindData(View view, BaseType data, int position)
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/TextItemAdapter.java
// Path: src/com/abewy/android/apps/contacts/adapter/holder/SimpleTextHolder.java // public class SimpleTextHolder // { // public final TextView primaryText; // // public SimpleTextHolder(TextView primaryText) // { // this.primaryText = primaryText; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/TextItem.java // public class TextItem extends BaseType // { // public final String text; // // public TextItem(String text) // { // this.text = text; // } // // public int getItemViewType() // { // return BaseType.TEXT; // } // // @Override // public String getItemPrimaryLabel() // { // return ""; // } // }
import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.SimpleTextHolder; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.items.TextItem;
package com.abewy.android.apps.contacts.adapter; public class TextItemAdapter extends ContactBaseAdapter { public TextItemAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_text; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text); setHolder(view, new SimpleTextHolder(primaryText)); } @Override public void bindData(View view, BaseType data, int position) { final SimpleTextHolder holder = (SimpleTextHolder) getHolder(view);
// Path: src/com/abewy/android/apps/contacts/adapter/holder/SimpleTextHolder.java // public class SimpleTextHolder // { // public final TextView primaryText; // // public SimpleTextHolder(TextView primaryText) // { // this.primaryText = primaryText; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/TextItem.java // public class TextItem extends BaseType // { // public final String text; // // public TextItem(String text) // { // this.text = text; // } // // public int getItemViewType() // { // return BaseType.TEXT; // } // // @Override // public String getItemPrimaryLabel() // { // return ""; // } // } // Path: src/com/abewy/android/apps/contacts/adapter/TextItemAdapter.java import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.SimpleTextHolder; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.items.TextItem; package com.abewy.android.apps.contacts.adapter; public class TextItemAdapter extends ContactBaseAdapter { public TextItemAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_text; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text); setHolder(view, new SimpleTextHolder(primaryText)); } @Override public void bindData(View view, BaseType data, int position) { final SimpleTextHolder holder = (SimpleTextHolder) getHolder(view);
final TextItem item = ((TextItem) data);
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/AdapterSelector.java
// Path: src/com/abewy/android/apps/contacts/model/ObjectType.java // public class ObjectType // { // public static final int CONTACT = 101; // public static final int CONTACT_PHONE = 102; // public static final int CONTACT_EMAIL = 103; // public static final int GROUP = 104; // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/adapter/TypeAdapter.java // public abstract class TypeAdapter<T> // { // public TypeAdapter() // { // // } // // public View createView(ViewGroup parent) // { // LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); // View view = inflater.inflate(getLayoutRes(), parent, false); // // attachViewHolder(view); // // return view; // } // // public abstract void setLayoutParams(View view); // // public abstract void bindData(View view, T data, int position); // // public abstract boolean isEnabled(T object); // // protected abstract void attachViewHolder(View view); // // protected abstract int getLayoutRes(); // // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // }
import android.util.Log; import com.abewy.android.apps.contacts.model.ObjectType; import com.abewy.android.extended.adapter.TypeAdapter; import com.abewy.android.extended.items.BaseType;
package com.abewy.android.apps.contacts.adapter; public class AdapterSelector { public AdapterSelector() { }
// Path: src/com/abewy/android/apps/contacts/model/ObjectType.java // public class ObjectType // { // public static final int CONTACT = 101; // public static final int CONTACT_PHONE = 102; // public static final int CONTACT_EMAIL = 103; // public static final int GROUP = 104; // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/adapter/TypeAdapter.java // public abstract class TypeAdapter<T> // { // public TypeAdapter() // { // // } // // public View createView(ViewGroup parent) // { // LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); // View view = inflater.inflate(getLayoutRes(), parent, false); // // attachViewHolder(view); // // return view; // } // // public abstract void setLayoutParams(View view); // // public abstract void bindData(View view, T data, int position); // // public abstract boolean isEnabled(T object); // // protected abstract void attachViewHolder(View view); // // protected abstract int getLayoutRes(); // // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // Path: src/com/abewy/android/apps/contacts/adapter/AdapterSelector.java import android.util.Log; import com.abewy.android.apps.contacts.model.ObjectType; import com.abewy.android.extended.adapter.TypeAdapter; import com.abewy.android.extended.items.BaseType; package com.abewy.android.apps.contacts.adapter; public class AdapterSelector { public AdapterSelector() { }
static TypeAdapter<BaseType> getAdapter(BaseType object, int layoutType, MultiObjectAdapter parentAdapter)
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/AdapterSelector.java
// Path: src/com/abewy/android/apps/contacts/model/ObjectType.java // public class ObjectType // { // public static final int CONTACT = 101; // public static final int CONTACT_PHONE = 102; // public static final int CONTACT_EMAIL = 103; // public static final int GROUP = 104; // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/adapter/TypeAdapter.java // public abstract class TypeAdapter<T> // { // public TypeAdapter() // { // // } // // public View createView(ViewGroup parent) // { // LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); // View view = inflater.inflate(getLayoutRes(), parent, false); // // attachViewHolder(view); // // return view; // } // // public abstract void setLayoutParams(View view); // // public abstract void bindData(View view, T data, int position); // // public abstract boolean isEnabled(T object); // // protected abstract void attachViewHolder(View view); // // protected abstract int getLayoutRes(); // // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // }
import android.util.Log; import com.abewy.android.apps.contacts.model.ObjectType; import com.abewy.android.extended.adapter.TypeAdapter; import com.abewy.android.extended.items.BaseType;
package com.abewy.android.apps.contacts.adapter; public class AdapterSelector { public AdapterSelector() { }
// Path: src/com/abewy/android/apps/contacts/model/ObjectType.java // public class ObjectType // { // public static final int CONTACT = 101; // public static final int CONTACT_PHONE = 102; // public static final int CONTACT_EMAIL = 103; // public static final int GROUP = 104; // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/adapter/TypeAdapter.java // public abstract class TypeAdapter<T> // { // public TypeAdapter() // { // // } // // public View createView(ViewGroup parent) // { // LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); // View view = inflater.inflate(getLayoutRes(), parent, false); // // attachViewHolder(view); // // return view; // } // // public abstract void setLayoutParams(View view); // // public abstract void bindData(View view, T data, int position); // // public abstract boolean isEnabled(T object); // // protected abstract void attachViewHolder(View view); // // protected abstract int getLayoutRes(); // // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // Path: src/com/abewy/android/apps/contacts/adapter/AdapterSelector.java import android.util.Log; import com.abewy.android.apps.contacts.model.ObjectType; import com.abewy.android.extended.adapter.TypeAdapter; import com.abewy.android.extended.items.BaseType; package com.abewy.android.apps.contacts.adapter; public class AdapterSelector { public AdapterSelector() { }
static TypeAdapter<BaseType> getAdapter(BaseType object, int layoutType, MultiObjectAdapter parentAdapter)
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/AdapterSelector.java
// Path: src/com/abewy/android/apps/contacts/model/ObjectType.java // public class ObjectType // { // public static final int CONTACT = 101; // public static final int CONTACT_PHONE = 102; // public static final int CONTACT_EMAIL = 103; // public static final int GROUP = 104; // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/adapter/TypeAdapter.java // public abstract class TypeAdapter<T> // { // public TypeAdapter() // { // // } // // public View createView(ViewGroup parent) // { // LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); // View view = inflater.inflate(getLayoutRes(), parent, false); // // attachViewHolder(view); // // return view; // } // // public abstract void setLayoutParams(View view); // // public abstract void bindData(View view, T data, int position); // // public abstract boolean isEnabled(T object); // // protected abstract void attachViewHolder(View view); // // protected abstract int getLayoutRes(); // // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // }
import android.util.Log; import com.abewy.android.apps.contacts.model.ObjectType; import com.abewy.android.extended.adapter.TypeAdapter; import com.abewy.android.extended.items.BaseType;
package com.abewy.android.apps.contacts.adapter; public class AdapterSelector { public AdapterSelector() { } static TypeAdapter<BaseType> getAdapter(BaseType object, int layoutType, MultiObjectAdapter parentAdapter) { switch (object.getItemViewType()) {
// Path: src/com/abewy/android/apps/contacts/model/ObjectType.java // public class ObjectType // { // public static final int CONTACT = 101; // public static final int CONTACT_PHONE = 102; // public static final int CONTACT_EMAIL = 103; // public static final int GROUP = 104; // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/adapter/TypeAdapter.java // public abstract class TypeAdapter<T> // { // public TypeAdapter() // { // // } // // public View createView(ViewGroup parent) // { // LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); // View view = inflater.inflate(getLayoutRes(), parent, false); // // attachViewHolder(view); // // return view; // } // // public abstract void setLayoutParams(View view); // // public abstract void bindData(View view, T data, int position); // // public abstract boolean isEnabled(T object); // // protected abstract void attachViewHolder(View view); // // protected abstract int getLayoutRes(); // // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // Path: src/com/abewy/android/apps/contacts/adapter/AdapterSelector.java import android.util.Log; import com.abewy.android.apps.contacts.model.ObjectType; import com.abewy.android.extended.adapter.TypeAdapter; import com.abewy.android.extended.items.BaseType; package com.abewy.android.apps.contacts.adapter; public class AdapterSelector { public AdapterSelector() { } static TypeAdapter<BaseType> getAdapter(BaseType object, int layoutType, MultiObjectAdapter parentAdapter) { switch (object.getItemViewType()) {
case ObjectType.CONTACT:
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/app/AboutActivity.java
// Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/ApplicationUtil.java // public class ApplicationUtil { // // public static String getAppVersion(ContextWrapper cw) // { // PackageInfo pinfo = null; // // try { // pinfo = cw.getPackageManager().getPackageInfo(cw.getPackageName(), 0); // } // catch (NameNotFoundException e) // { // return ""; // } // // return pinfo.versionName; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/PhoneUtil.java // public class PhoneUtil // { // // public static void openDialActivity(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "openDialActivity: ", activityException); // } // } // // public static void callNumber(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_CALL); // intent.setData(Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "callNumber: ", activityException); // } // } // // public static void sendSMS(Context context, String phoneNumber) // { // try // { // Uri uri = Uri.parse("sms:" + phoneNumber); // Intent intent = new Intent(Intent.ACTION_VIEW, uri); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendSMS: ", activityException); // } // } // // public static void sendMail(Context context, String email) // { // Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null)); // // try // { // context.startActivity(Intent.createChooser(intent, "Send mail...")); // } // catch (android.content.ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendMail: ", activityException); // } // } // // public static void openURL(Context context, String url) // { // if (url.indexOf("http://") != 0) // { // if (url.indexOf("https://") != 0) // url = "http://" + url; // } // // Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); // context.startActivity(intent); // } // }
import java.util.Calendar; import java.util.GregorianCalendar; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.Window; import android.widget.ImageView; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.extended.util.ApplicationUtil; import com.abewy.android.extended.util.PhoneUtil;
package com.abewy.android.apps.contacts.app; public class AboutActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); setTitle(R.string.about_activity_title); getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_background_transparent_gradient)); getActionBar().setDisplayHomeAsUpEnabled(true); ImageView companyLogo = (ImageView) findViewById(R.id.company_logo); companyLogo.setClickable(true); companyLogo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
// Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/ApplicationUtil.java // public class ApplicationUtil { // // public static String getAppVersion(ContextWrapper cw) // { // PackageInfo pinfo = null; // // try { // pinfo = cw.getPackageManager().getPackageInfo(cw.getPackageName(), 0); // } // catch (NameNotFoundException e) // { // return ""; // } // // return pinfo.versionName; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/PhoneUtil.java // public class PhoneUtil // { // // public static void openDialActivity(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "openDialActivity: ", activityException); // } // } // // public static void callNumber(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_CALL); // intent.setData(Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "callNumber: ", activityException); // } // } // // public static void sendSMS(Context context, String phoneNumber) // { // try // { // Uri uri = Uri.parse("sms:" + phoneNumber); // Intent intent = new Intent(Intent.ACTION_VIEW, uri); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendSMS: ", activityException); // } // } // // public static void sendMail(Context context, String email) // { // Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null)); // // try // { // context.startActivity(Intent.createChooser(intent, "Send mail...")); // } // catch (android.content.ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendMail: ", activityException); // } // } // // public static void openURL(Context context, String url) // { // if (url.indexOf("http://") != 0) // { // if (url.indexOf("https://") != 0) // url = "http://" + url; // } // // Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); // context.startActivity(intent); // } // } // Path: src/com/abewy/android/apps/contacts/app/AboutActivity.java import java.util.Calendar; import java.util.GregorianCalendar; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.Window; import android.widget.ImageView; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.extended.util.ApplicationUtil; import com.abewy.android.extended.util.PhoneUtil; package com.abewy.android.apps.contacts.app; public class AboutActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); setTitle(R.string.about_activity_title); getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_background_transparent_gradient)); getActionBar().setDisplayHomeAsUpEnabled(true); ImageView companyLogo = (ImageView) findViewById(R.id.company_logo); companyLogo.setClickable(true); companyLogo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
PhoneUtil.openURL(AboutActivity.this, getString(R.string.company_url));
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/app/AboutActivity.java
// Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/ApplicationUtil.java // public class ApplicationUtil { // // public static String getAppVersion(ContextWrapper cw) // { // PackageInfo pinfo = null; // // try { // pinfo = cw.getPackageManager().getPackageInfo(cw.getPackageName(), 0); // } // catch (NameNotFoundException e) // { // return ""; // } // // return pinfo.versionName; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/PhoneUtil.java // public class PhoneUtil // { // // public static void openDialActivity(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "openDialActivity: ", activityException); // } // } // // public static void callNumber(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_CALL); // intent.setData(Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "callNumber: ", activityException); // } // } // // public static void sendSMS(Context context, String phoneNumber) // { // try // { // Uri uri = Uri.parse("sms:" + phoneNumber); // Intent intent = new Intent(Intent.ACTION_VIEW, uri); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendSMS: ", activityException); // } // } // // public static void sendMail(Context context, String email) // { // Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null)); // // try // { // context.startActivity(Intent.createChooser(intent, "Send mail...")); // } // catch (android.content.ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendMail: ", activityException); // } // } // // public static void openURL(Context context, String url) // { // if (url.indexOf("http://") != 0) // { // if (url.indexOf("https://") != 0) // url = "http://" + url; // } // // Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); // context.startActivity(intent); // } // }
import java.util.Calendar; import java.util.GregorianCalendar; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.Window; import android.widget.ImageView; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.extended.util.ApplicationUtil; import com.abewy.android.extended.util.PhoneUtil;
package com.abewy.android.apps.contacts.app; public class AboutActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); setTitle(R.string.about_activity_title); getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_background_transparent_gradient)); getActionBar().setDisplayHomeAsUpEnabled(true); ImageView companyLogo = (ImageView) findViewById(R.id.company_logo); companyLogo.setClickable(true); companyLogo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PhoneUtil.openURL(AboutActivity.this, getString(R.string.company_url)); } }); TextView version = (TextView) findViewById(R.id.version); TextView copyright = (TextView) findViewById(R.id.copyright);
// Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/ApplicationUtil.java // public class ApplicationUtil { // // public static String getAppVersion(ContextWrapper cw) // { // PackageInfo pinfo = null; // // try { // pinfo = cw.getPackageManager().getPackageInfo(cw.getPackageName(), 0); // } // catch (NameNotFoundException e) // { // return ""; // } // // return pinfo.versionName; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/PhoneUtil.java // public class PhoneUtil // { // // public static void openDialActivity(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "openDialActivity: ", activityException); // } // } // // public static void callNumber(Context context, String phoneNumber) // { // try // { // Intent intent = new Intent(Intent.ACTION_CALL); // intent.setData(Uri.parse("tel:" + phoneNumber)); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "callNumber: ", activityException); // } // } // // public static void sendSMS(Context context, String phoneNumber) // { // try // { // Uri uri = Uri.parse("sms:" + phoneNumber); // Intent intent = new Intent(Intent.ACTION_VIEW, uri); // context.startActivity(intent); // } // catch (ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendSMS: ", activityException); // } // } // // public static void sendMail(Context context, String email) // { // Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null)); // // try // { // context.startActivity(Intent.createChooser(intent, "Send mail...")); // } // catch (android.content.ActivityNotFoundException activityException) // { // Log.d("PhoneUtil", "sendMail: ", activityException); // } // } // // public static void openURL(Context context, String url) // { // if (url.indexOf("http://") != 0) // { // if (url.indexOf("https://") != 0) // url = "http://" + url; // } // // Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); // context.startActivity(intent); // } // } // Path: src/com/abewy/android/apps/contacts/app/AboutActivity.java import java.util.Calendar; import java.util.GregorianCalendar; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.Window; import android.widget.ImageView; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.extended.util.ApplicationUtil; import com.abewy.android.extended.util.PhoneUtil; package com.abewy.android.apps.contacts.app; public class AboutActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); setTitle(R.string.about_activity_title); getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_background_transparent_gradient)); getActionBar().setDisplayHomeAsUpEnabled(true); ImageView companyLogo = (ImageView) findViewById(R.id.company_logo); companyLogo.setClickable(true); companyLogo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PhoneUtil.openURL(AboutActivity.this, getString(R.string.company_url)); } }); TextView version = (TextView) findViewById(R.id.version); TextView copyright = (TextView) findViewById(R.id.copyright);
version.setText(getString(R.string.about_version, ApplicationUtil.getAppVersion(this)));
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/app/PeopleSmallGridFragment.java
// Path: src/com/abewy/android/apps/contacts/adapter/LayoutType.java // public class LayoutType // { // public static final int GRID_BIG = 1; // public static final int GRID_MEDIUM = 2; // public static final int GRID_SMALL = 3; // public static final int DROP_DOWN_ITEM = 4; // }
import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.LayoutType;
/** * @author Jonathan */ package com.abewy.android.apps.contacts.app; public class PeopleSmallGridFragment extends PeopleBigGridFragment { private static int mLastPosition = 0; private static int mLastFavPosition = 0; public PeopleSmallGridFragment() { } @Override protected int getNumColumn() { return getResources().getInteger(R.integer.small_grid_columns); } @Override protected int getCustomLayout() { return R.layout.grid_big; } protected int getAdapterLayoutType() {
// Path: src/com/abewy/android/apps/contacts/adapter/LayoutType.java // public class LayoutType // { // public static final int GRID_BIG = 1; // public static final int GRID_MEDIUM = 2; // public static final int GRID_SMALL = 3; // public static final int DROP_DOWN_ITEM = 4; // } // Path: src/com/abewy/android/apps/contacts/app/PeopleSmallGridFragment.java import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.LayoutType; /** * @author Jonathan */ package com.abewy.android.apps.contacts.app; public class PeopleSmallGridFragment extends PeopleBigGridFragment { private static int mLastPosition = 0; private static int mLastFavPosition = 0; public PeopleSmallGridFragment() { } @Override protected int getNumColumn() { return getResources().getInteger(R.integer.small_grid_columns); } @Override protected int getCustomLayout() { return R.layout.grid_big; } protected int getAdapterLayoutType() {
return LayoutType.GRID_SMALL;
jonathangerbaud/Contacts
libs_external/Abewy_Extended/src/com/abewy/android/extended/fragment/GridDialogFragment.java
// Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/fragment/GridFragment.java // public static interface IEmptyView // { // public void setText(String text); // // public void setText(int text); // }
import android.content.res.Configuration; import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.animation.AnimationUtils; import android.widget.AdapterView; import android.widget.GridView; import android.widget.ListAdapter; import com.abewy.android.extended.R; import com.abewy.android.extended.fragment.GridFragment.IEmptyView;
parent.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out)); } else { loadingView.clearAnimation(); parent.clearAnimation(); } loadingView.setVisibility(View.VISIBLE); if (parent != null) parent.setVisibility(View.GONE); } } protected void setEmptyText(int resId) { emptyText = resId; setText(emptyText); } protected void setErrorText(int resId) { errorText = resId; } private void setText(int resId) { if (resId != -1) { final View emptyView = getGridView().getEmptyView();
// Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/fragment/GridFragment.java // public static interface IEmptyView // { // public void setText(String text); // // public void setText(int text); // } // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/fragment/GridDialogFragment.java import android.content.res.Configuration; import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.animation.AnimationUtils; import android.widget.AdapterView; import android.widget.GridView; import android.widget.ListAdapter; import com.abewy.android.extended.R; import com.abewy.android.extended.fragment.GridFragment.IEmptyView; parent.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out)); } else { loadingView.clearAnimation(); parent.clearAnimation(); } loadingView.setVisibility(View.VISIBLE); if (parent != null) parent.setVisibility(View.GONE); } } protected void setEmptyText(int resId) { emptyText = resId; setText(emptyText); } protected void setErrorText(int resId) { errorText = resId; } private void setText(int resId) { if (resId != -1) { final View emptyView = getGridView().getEmptyView();
if (emptyView != null && emptyView instanceof IEmptyView)
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/app/PreferencesActivity.java
// Path: src/com/abewy/android/apps/contacts/core/CorePrefs.java // public class CorePrefs // { // public static final String ROUNDED_PICTURES = "contacts_rounded_pictures"; // public static final String PEOPLE_VIEW_TYPE = "people_view_type"; // public static final String FAVORITES_VIEW_TYPE = "favorites_view_type"; // public static final String VIEW_PAGER_EFFECT = "contacts_effects"; // public static final String SORT_BY_LAST_NAME = "contacts_sort_by_last_name"; // public static final String LIST_GRID_ANMIATION = "contacts_list_grid_animation"; // public static final String HAS_DONATED = "contacts_has_donated"; // public static final String FIRST_LAUNCH = "contacts_first_launch"; // // public static final int VIEW_TYPE_LIST = 0; // public static final int VIEW_TYPE_BIG_GRID = 1; // public static final int VIEW_TYPE_MEDIUM_GRID = 2; // public static final int VIEW_TYPE_SMALL_GRID = 3; // // private static boolean prefsHaveChanged; // // static SharedPreferences getPreferences() // { // return PreferenceManager.getDefaultSharedPreferences(CoreApplication.getInstance()); // } // // public static boolean isRoundedPictures() // { // return getPreferences().getBoolean(ROUNDED_PICTURES, true); // } // // public static boolean isSortingByLastName() // { // return getPreferences().getBoolean(SORT_BY_LAST_NAME, false); // } // // public static boolean isAnimatingListGridItems() // { // return getPreferences().getBoolean(LIST_GRID_ANMIATION, false); // } // // public static void setPeopleViewType(int viewType) // { // Editor editor = getPreferences().edit(); // editor.putInt(PEOPLE_VIEW_TYPE, viewType); // editor.commit(); // } // // public static int getPeopleViewType() // { // return getPreferences().getInt(PEOPLE_VIEW_TYPE, 0); // } // // public static void setFavoritesViewType(int viewType) // { // Editor editor = getPreferences().edit(); // editor.putInt(FAVORITES_VIEW_TYPE, viewType); // editor.commit(); // } // // public static int getFavoritesViewType() // { // return getPreferences().getInt(FAVORITES_VIEW_TYPE, 0); // } // // public static JazzyViewPager.TransitionEffect getViewPagerEffect() // { // int effect = Integer.parseInt(getPreferences().getString(VIEW_PAGER_EFFECT, "4")); // // switch (effect) // { // case 0: // return TransitionEffect.Standard; // case 1: // return TransitionEffect.Tablet; // case 2: // return TransitionEffect.CubeIn; // case 3: // return TransitionEffect.CubeOut; // case 4: // return TransitionEffect.FlipHorizontal; // case 5: // return TransitionEffect.FlipVertical; // case 6: // return TransitionEffect.Stack; // case 7: // return TransitionEffect.ZoomIn; // case 8: // return TransitionEffect.ZoomOut; // case 9: // return TransitionEffect.RotateUp; // case 10: // return TransitionEffect.RotateDown; // case 11: // return TransitionEffect.Accordion; // default: // return TransitionEffect.FlipHorizontal; // } // } // // public static void setPrefsHaveChanged(boolean changed) // { // prefsHaveChanged = changed; // } // // public static boolean getPrefsHaveChanged() // { // return prefsHaveChanged; // } // // public static void setHasDonated(boolean donated) // { // Editor editor = getPreferences().edit(); // editor.putBoolean(HAS_DONATED, donated); // editor.commit(); // } // // public static boolean hasDonated() // { // return getPreferences().getBoolean(HAS_DONATED, false); // } // // public static boolean isFirstLaunch() // { // return getPreferences().getBoolean(FIRST_LAUNCH, true); // } // // public static void setFirstLaunchDone() // { // Editor editor = getPreferences().edit(); // editor.putBoolean(FIRST_LAUNCH, false); // editor.commit(); // } // } // // Path: libs_external/JazzyViewPager/lib/src/com/jfeinstein/jazzyviewpager/JazzyViewPager.java // public enum TransitionEffect { // Standard, // Tablet, // CubeIn, // CubeOut, // FlipVertical, // FlipHorizontal, // Stack, // ZoomIn, // ZoomOut, // RotateUp, // RotateDown, // Accordion // }
import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceActivity; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.core.CorePrefs; import com.jfeinstein.jazzyviewpager.JazzyViewPager.TransitionEffect;
package com.abewy.android.apps.contacts.app; public class PreferencesActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener { private static final String ABOUT_KEY = "contacts_about"; private static final String CHANGELOG_KEY = "contacts_changelog"; private boolean mSortByLastName; private boolean mRoundedAvatars; private boolean mListAnimation;
// Path: src/com/abewy/android/apps/contacts/core/CorePrefs.java // public class CorePrefs // { // public static final String ROUNDED_PICTURES = "contacts_rounded_pictures"; // public static final String PEOPLE_VIEW_TYPE = "people_view_type"; // public static final String FAVORITES_VIEW_TYPE = "favorites_view_type"; // public static final String VIEW_PAGER_EFFECT = "contacts_effects"; // public static final String SORT_BY_LAST_NAME = "contacts_sort_by_last_name"; // public static final String LIST_GRID_ANMIATION = "contacts_list_grid_animation"; // public static final String HAS_DONATED = "contacts_has_donated"; // public static final String FIRST_LAUNCH = "contacts_first_launch"; // // public static final int VIEW_TYPE_LIST = 0; // public static final int VIEW_TYPE_BIG_GRID = 1; // public static final int VIEW_TYPE_MEDIUM_GRID = 2; // public static final int VIEW_TYPE_SMALL_GRID = 3; // // private static boolean prefsHaveChanged; // // static SharedPreferences getPreferences() // { // return PreferenceManager.getDefaultSharedPreferences(CoreApplication.getInstance()); // } // // public static boolean isRoundedPictures() // { // return getPreferences().getBoolean(ROUNDED_PICTURES, true); // } // // public static boolean isSortingByLastName() // { // return getPreferences().getBoolean(SORT_BY_LAST_NAME, false); // } // // public static boolean isAnimatingListGridItems() // { // return getPreferences().getBoolean(LIST_GRID_ANMIATION, false); // } // // public static void setPeopleViewType(int viewType) // { // Editor editor = getPreferences().edit(); // editor.putInt(PEOPLE_VIEW_TYPE, viewType); // editor.commit(); // } // // public static int getPeopleViewType() // { // return getPreferences().getInt(PEOPLE_VIEW_TYPE, 0); // } // // public static void setFavoritesViewType(int viewType) // { // Editor editor = getPreferences().edit(); // editor.putInt(FAVORITES_VIEW_TYPE, viewType); // editor.commit(); // } // // public static int getFavoritesViewType() // { // return getPreferences().getInt(FAVORITES_VIEW_TYPE, 0); // } // // public static JazzyViewPager.TransitionEffect getViewPagerEffect() // { // int effect = Integer.parseInt(getPreferences().getString(VIEW_PAGER_EFFECT, "4")); // // switch (effect) // { // case 0: // return TransitionEffect.Standard; // case 1: // return TransitionEffect.Tablet; // case 2: // return TransitionEffect.CubeIn; // case 3: // return TransitionEffect.CubeOut; // case 4: // return TransitionEffect.FlipHorizontal; // case 5: // return TransitionEffect.FlipVertical; // case 6: // return TransitionEffect.Stack; // case 7: // return TransitionEffect.ZoomIn; // case 8: // return TransitionEffect.ZoomOut; // case 9: // return TransitionEffect.RotateUp; // case 10: // return TransitionEffect.RotateDown; // case 11: // return TransitionEffect.Accordion; // default: // return TransitionEffect.FlipHorizontal; // } // } // // public static void setPrefsHaveChanged(boolean changed) // { // prefsHaveChanged = changed; // } // // public static boolean getPrefsHaveChanged() // { // return prefsHaveChanged; // } // // public static void setHasDonated(boolean donated) // { // Editor editor = getPreferences().edit(); // editor.putBoolean(HAS_DONATED, donated); // editor.commit(); // } // // public static boolean hasDonated() // { // return getPreferences().getBoolean(HAS_DONATED, false); // } // // public static boolean isFirstLaunch() // { // return getPreferences().getBoolean(FIRST_LAUNCH, true); // } // // public static void setFirstLaunchDone() // { // Editor editor = getPreferences().edit(); // editor.putBoolean(FIRST_LAUNCH, false); // editor.commit(); // } // } // // Path: libs_external/JazzyViewPager/lib/src/com/jfeinstein/jazzyviewpager/JazzyViewPager.java // public enum TransitionEffect { // Standard, // Tablet, // CubeIn, // CubeOut, // FlipVertical, // FlipHorizontal, // Stack, // ZoomIn, // ZoomOut, // RotateUp, // RotateDown, // Accordion // } // Path: src/com/abewy/android/apps/contacts/app/PreferencesActivity.java import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceActivity; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.core.CorePrefs; import com.jfeinstein.jazzyviewpager.JazzyViewPager.TransitionEffect; package com.abewy.android.apps.contacts.app; public class PreferencesActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener { private static final String ABOUT_KEY = "contacts_about"; private static final String CHANGELOG_KEY = "contacts_changelog"; private boolean mSortByLastName; private boolean mRoundedAvatars; private boolean mListAnimation;
private TransitionEffect mTransitionEffect;
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/app/IActionbarSpinner.java
// Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // }
import com.abewy.android.extended.items.BaseType; import java.util.List; import android.app.ActionBar.OnNavigationListener;
/** * @author Jonathan */ package com.abewy.android.apps.contacts.app; public interface IActionbarSpinner { public void displaySpinnerInActionBar(String[] array, int position, OnNavigationListener listener); public void displaySpinnerInActionBar(int array, int position, OnNavigationListener listener);
// Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // Path: src/com/abewy/android/apps/contacts/app/IActionbarSpinner.java import com.abewy.android.extended.items.BaseType; import java.util.List; import android.app.ActionBar.OnNavigationListener; /** * @author Jonathan */ package com.abewy.android.apps.contacts.app; public interface IActionbarSpinner { public void displaySpinnerInActionBar(String[] array, int position, OnNavigationListener listener); public void displaySpinnerInActionBar(int array, int position, OnNavigationListener listener);
public void displaySpinnerInActionBar(List<BaseType> data, int position, OnNavigationListener listener);
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/app/PeopleMediumGridFragment.java
// Path: src/com/abewy/android/apps/contacts/adapter/LayoutType.java // public class LayoutType // { // public static final int GRID_BIG = 1; // public static final int GRID_MEDIUM = 2; // public static final int GRID_SMALL = 3; // public static final int DROP_DOWN_ITEM = 4; // }
import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.LayoutType;
/** * @author Jonathan */ package com.abewy.android.apps.contacts.app; public class PeopleMediumGridFragment extends PeopleBigGridFragment { private static int mLastPosition = 0; private static int mLastFavPosition = 0; public PeopleMediumGridFragment() { } @Override protected int getNumColumn() { return getResources().getInteger(R.integer.medium_grid_columns); } @Override protected int getCustomLayout() { return R.layout.grid_big; } protected int getAdapterLayoutType() {
// Path: src/com/abewy/android/apps/contacts/adapter/LayoutType.java // public class LayoutType // { // public static final int GRID_BIG = 1; // public static final int GRID_MEDIUM = 2; // public static final int GRID_SMALL = 3; // public static final int DROP_DOWN_ITEM = 4; // } // Path: src/com/abewy/android/apps/contacts/app/PeopleMediumGridFragment.java import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.LayoutType; /** * @author Jonathan */ package com.abewy.android.apps.contacts.app; public class PeopleMediumGridFragment extends PeopleBigGridFragment { private static int mLastPosition = 0; private static int mLastFavPosition = 0; public PeopleMediumGridFragment() { } @Override protected int getNumColumn() { return getResources().getInteger(R.integer.medium_grid_columns); } @Override protected int getCustomLayout() { return R.layout.grid_big; } protected int getAdapterLayoutType() {
return LayoutType.GRID_MEDIUM;
jonathangerbaud/Contacts
libs_external/JazzyViewPager/lib/src/com/jfeinstein/jazzyviewpager/MainActivity.java
// Path: libs_external/JazzyViewPager/lib/src/com/jfeinstein/jazzyviewpager/JazzyViewPager.java // public enum TransitionEffect { // Standard, // Tablet, // CubeIn, // CubeOut, // FlipVertical, // FlipHorizontal, // Stack, // ZoomIn, // ZoomOut, // RotateUp, // RotateDown, // Accordion // }
import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.support.v4.view.PagerAdapter; import android.view.Gravity; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.widget.TextView; import com.jfeinstein.jazzyviewpager.JazzyViewPager.TransitionEffect;
package com.jfeinstein.jazzyviewpager; public class MainActivity extends Activity { private JazzyViewPager mJazzy; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
// Path: libs_external/JazzyViewPager/lib/src/com/jfeinstein/jazzyviewpager/JazzyViewPager.java // public enum TransitionEffect { // Standard, // Tablet, // CubeIn, // CubeOut, // FlipVertical, // FlipHorizontal, // Stack, // ZoomIn, // ZoomOut, // RotateUp, // RotateDown, // Accordion // } // Path: libs_external/JazzyViewPager/lib/src/com/jfeinstein/jazzyviewpager/MainActivity.java import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.support.v4.view.PagerAdapter; import android.view.Gravity; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.widget.TextView; import com.jfeinstein.jazzyviewpager.JazzyViewPager.TransitionEffect; package com.jfeinstein.jazzyviewpager; public class MainActivity extends Activity { private JazzyViewPager mJazzy; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
setupJazziness(TransitionEffect.Tablet);
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/HeaderAdapter.java
// Path: src/com/abewy/android/apps/contacts/adapter/holder/HeaderHolder.java // public class HeaderHolder // { // public final TextView headerTitle; // // public HeaderHolder(TextView headerTitle) // { // this.headerTitle = headerTitle; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/Header.java // public class Header extends BaseType // { // public final String name; // // public Header(String name) // { // this.name = name; // } // // public int getItemViewType() // { // return BaseType.HEADER; // } // // @Override // public String getItemPrimaryLabel() // { // return name; // } // }
import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.R.id; import com.abewy.android.apps.contacts.R.layout; import com.abewy.android.apps.contacts.adapter.holder.HeaderHolder; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.items.Header;
package com.abewy.android.apps.contacts.adapter; public class HeaderAdapter extends ContactBaseAdapter { public HeaderAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_header; } @Override protected void attachViewHolder(View view) {
// Path: src/com/abewy/android/apps/contacts/adapter/holder/HeaderHolder.java // public class HeaderHolder // { // public final TextView headerTitle; // // public HeaderHolder(TextView headerTitle) // { // this.headerTitle = headerTitle; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/Header.java // public class Header extends BaseType // { // public final String name; // // public Header(String name) // { // this.name = name; // } // // public int getItemViewType() // { // return BaseType.HEADER; // } // // @Override // public String getItemPrimaryLabel() // { // return name; // } // } // Path: src/com/abewy/android/apps/contacts/adapter/HeaderAdapter.java import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.R.id; import com.abewy.android.apps.contacts.R.layout; import com.abewy.android.apps.contacts.adapter.holder.HeaderHolder; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.items.Header; package com.abewy.android.apps.contacts.adapter; public class HeaderAdapter extends ContactBaseAdapter { public HeaderAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_header; } @Override protected void attachViewHolder(View view) {
view.setTag(new HeaderHolder((TextView) view.findViewById(R.id.header_title)));
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/HeaderAdapter.java
// Path: src/com/abewy/android/apps/contacts/adapter/holder/HeaderHolder.java // public class HeaderHolder // { // public final TextView headerTitle; // // public HeaderHolder(TextView headerTitle) // { // this.headerTitle = headerTitle; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/Header.java // public class Header extends BaseType // { // public final String name; // // public Header(String name) // { // this.name = name; // } // // public int getItemViewType() // { // return BaseType.HEADER; // } // // @Override // public String getItemPrimaryLabel() // { // return name; // } // }
import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.R.id; import com.abewy.android.apps.contacts.R.layout; import com.abewy.android.apps.contacts.adapter.holder.HeaderHolder; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.items.Header;
package com.abewy.android.apps.contacts.adapter; public class HeaderAdapter extends ContactBaseAdapter { public HeaderAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_header; } @Override protected void attachViewHolder(View view) { view.setTag(new HeaderHolder((TextView) view.findViewById(R.id.header_title))); } @Override
// Path: src/com/abewy/android/apps/contacts/adapter/holder/HeaderHolder.java // public class HeaderHolder // { // public final TextView headerTitle; // // public HeaderHolder(TextView headerTitle) // { // this.headerTitle = headerTitle; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/Header.java // public class Header extends BaseType // { // public final String name; // // public Header(String name) // { // this.name = name; // } // // public int getItemViewType() // { // return BaseType.HEADER; // } // // @Override // public String getItemPrimaryLabel() // { // return name; // } // } // Path: src/com/abewy/android/apps/contacts/adapter/HeaderAdapter.java import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.R.id; import com.abewy.android.apps.contacts.R.layout; import com.abewy.android.apps.contacts.adapter.holder.HeaderHolder; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.items.Header; package com.abewy.android.apps.contacts.adapter; public class HeaderAdapter extends ContactBaseAdapter { public HeaderAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_header; } @Override protected void attachViewHolder(View view) { view.setTag(new HeaderHolder((TextView) view.findViewById(R.id.header_title))); } @Override
public void bindData(View view, BaseType data, int position)
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/HeaderAdapter.java
// Path: src/com/abewy/android/apps/contacts/adapter/holder/HeaderHolder.java // public class HeaderHolder // { // public final TextView headerTitle; // // public HeaderHolder(TextView headerTitle) // { // this.headerTitle = headerTitle; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/Header.java // public class Header extends BaseType // { // public final String name; // // public Header(String name) // { // this.name = name; // } // // public int getItemViewType() // { // return BaseType.HEADER; // } // // @Override // public String getItemPrimaryLabel() // { // return name; // } // }
import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.R.id; import com.abewy.android.apps.contacts.R.layout; import com.abewy.android.apps.contacts.adapter.holder.HeaderHolder; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.items.Header;
package com.abewy.android.apps.contacts.adapter; public class HeaderAdapter extends ContactBaseAdapter { public HeaderAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_header; } @Override protected void attachViewHolder(View view) { view.setTag(new HeaderHolder((TextView) view.findViewById(R.id.header_title))); } @Override public void bindData(View view, BaseType data, int position) {
// Path: src/com/abewy/android/apps/contacts/adapter/holder/HeaderHolder.java // public class HeaderHolder // { // public final TextView headerTitle; // // public HeaderHolder(TextView headerTitle) // { // this.headerTitle = headerTitle; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/Header.java // public class Header extends BaseType // { // public final String name; // // public Header(String name) // { // this.name = name; // } // // public int getItemViewType() // { // return BaseType.HEADER; // } // // @Override // public String getItemPrimaryLabel() // { // return name; // } // } // Path: src/com/abewy/android/apps/contacts/adapter/HeaderAdapter.java import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.R.id; import com.abewy.android.apps.contacts.R.layout; import com.abewy.android.apps.contacts.adapter.holder.HeaderHolder; import com.abewy.android.extended.items.BaseType; import com.abewy.android.extended.items.Header; package com.abewy.android.apps.contacts.adapter; public class HeaderAdapter extends ContactBaseAdapter { public HeaderAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_header; } @Override protected void attachViewHolder(View view) { view.setTag(new HeaderHolder((TextView) view.findViewById(R.id.header_title))); } @Override public void bindData(View view, BaseType data, int position) {
Header header = (Header) data;
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/imageloader/ImageLoader.java
// Path: src/com/abewy/android/apps/contacts/core/CoreApplication.java // public abstract class CoreApplication extends Application // { // private static CoreApplication instance; // // @Override // public void onCreate() // { // instance = this; // // initGlobals(); // initBugReport(); // initPreferences(); // initOthers(); // // super.onCreate(); // } // // public static CoreApplication getInstance() // { // return instance; // } // // private void initBugReport() // { // if (CoreFlags.ENABLE_BUG_REPORT) // { // Log.d("CoreApplication", "initBugReport: "); // Crashlytics.start(this); // } // } // // protected abstract void initPreferences(); // // protected abstract void initGlobals(); // // protected abstract void initOthers(); // // @Override // public void onLowMemory() // { // super.onLowMemory(); // Log.i("BaseApplication", "onLowMemory"); // } // // @Override // @TargetApi(14) // public void onTrimMemory(int level) // { // super.onTrimMemory(level); // Log.i("BaseApplication", "onTrimMemory"); // } // // public static String generateIabKey() // { // return "[YOUR_KEY]"; // } // }
import android.content.Context; import android.net.Uri; import android.view.ViewGroup.LayoutParams; import android.widget.ImageView; import com.abewy.android.apps.contacts.core.CoreApplication; import com.squareup.picasso.Picasso; import com.squareup.picasso.RequestCreator;
requestCreator.inSampleSize(true); requestCreator.into(imageView, listener); } public static void displayNoScaling(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener) { if (uri == null || uri.length() == 0) uri = FAKE_URI; Picasso picasso = Picasso.with(imageView.getContext()); RequestCreator requestCreator = picasso.load(uri); if (stubImage != 0) { requestCreator.placeholder(stubImage); requestCreator.error(stubImage); } if (!(fadeIn && FADE_ENABLED)) requestCreator.noFade(); requestCreator.into(imageView, listener); } public static void loadImage(String uri, FakeImageLoaderListener listener) { if (uri == null || uri.length() == 0) uri = FAKE_URI;
// Path: src/com/abewy/android/apps/contacts/core/CoreApplication.java // public abstract class CoreApplication extends Application // { // private static CoreApplication instance; // // @Override // public void onCreate() // { // instance = this; // // initGlobals(); // initBugReport(); // initPreferences(); // initOthers(); // // super.onCreate(); // } // // public static CoreApplication getInstance() // { // return instance; // } // // private void initBugReport() // { // if (CoreFlags.ENABLE_BUG_REPORT) // { // Log.d("CoreApplication", "initBugReport: "); // Crashlytics.start(this); // } // } // // protected abstract void initPreferences(); // // protected abstract void initGlobals(); // // protected abstract void initOthers(); // // @Override // public void onLowMemory() // { // super.onLowMemory(); // Log.i("BaseApplication", "onLowMemory"); // } // // @Override // @TargetApi(14) // public void onTrimMemory(int level) // { // super.onTrimMemory(level); // Log.i("BaseApplication", "onTrimMemory"); // } // // public static String generateIabKey() // { // return "[YOUR_KEY]"; // } // } // Path: src/com/abewy/android/apps/contacts/imageloader/ImageLoader.java import android.content.Context; import android.net.Uri; import android.view.ViewGroup.LayoutParams; import android.widget.ImageView; import com.abewy.android.apps.contacts.core.CoreApplication; import com.squareup.picasso.Picasso; import com.squareup.picasso.RequestCreator; requestCreator.inSampleSize(true); requestCreator.into(imageView, listener); } public static void displayNoScaling(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener) { if (uri == null || uri.length() == 0) uri = FAKE_URI; Picasso picasso = Picasso.with(imageView.getContext()); RequestCreator requestCreator = picasso.load(uri); if (stubImage != 0) { requestCreator.placeholder(stubImage); requestCreator.error(stubImage); } if (!(fadeIn && FADE_ENABLED)) requestCreator.noFade(); requestCreator.into(imageView, listener); } public static void loadImage(String uri, FakeImageLoaderListener listener) { if (uri == null || uri.length() == 0) uri = FAKE_URI;
Picasso.with(CoreApplication.getInstance()).load(uri).into(listener);
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/ContactEmailAdapter.java
// Path: src/com/abewy/android/apps/contacts/adapter/holder/TitleTextHolder.java // public class TitleTextHolder // { // public final TextView primaryText; // public final TextView secondaryText; // // public TitleTextHolder(TextView primaryText, TextView secondaryText) // { // this.primaryText = primaryText; // this.secondaryText = secondaryText; // } // } // // Path: src/com/abewy/android/apps/contacts/model/ContactEmail.java // public class ContactEmail extends BaseContact // { // public final String email; // public final int type; // public final String label; // // public ContactEmail(String email, int type) // { // this(email, type, ""); // } // // public ContactEmail(String email, int type, String label) // { // this.email = email; // this.type = type; // this.label = label; // } // // @Override // public int getItemViewType() // { // return ObjectType.CONTACT_EMAIL; // } // // @Override // public String getItemPrimaryLabel() // { // return email; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // }
import android.provider.ContactsContract.CommonDataKinds.Email; import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.TitleTextHolder; import com.abewy.android.apps.contacts.model.ContactEmail; import com.abewy.android.extended.items.BaseType;
package com.abewy.android.apps.contacts.adapter; public class ContactEmailAdapter extends ContactBaseAdapter { public ContactEmailAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_title_text; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text); TextView secondaryText = (TextView) view.findViewById(R.id.secondary_text);
// Path: src/com/abewy/android/apps/contacts/adapter/holder/TitleTextHolder.java // public class TitleTextHolder // { // public final TextView primaryText; // public final TextView secondaryText; // // public TitleTextHolder(TextView primaryText, TextView secondaryText) // { // this.primaryText = primaryText; // this.secondaryText = secondaryText; // } // } // // Path: src/com/abewy/android/apps/contacts/model/ContactEmail.java // public class ContactEmail extends BaseContact // { // public final String email; // public final int type; // public final String label; // // public ContactEmail(String email, int type) // { // this(email, type, ""); // } // // public ContactEmail(String email, int type, String label) // { // this.email = email; // this.type = type; // this.label = label; // } // // @Override // public int getItemViewType() // { // return ObjectType.CONTACT_EMAIL; // } // // @Override // public String getItemPrimaryLabel() // { // return email; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // Path: src/com/abewy/android/apps/contacts/adapter/ContactEmailAdapter.java import android.provider.ContactsContract.CommonDataKinds.Email; import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.TitleTextHolder; import com.abewy.android.apps.contacts.model.ContactEmail; import com.abewy.android.extended.items.BaseType; package com.abewy.android.apps.contacts.adapter; public class ContactEmailAdapter extends ContactBaseAdapter { public ContactEmailAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_title_text; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text); TextView secondaryText = (TextView) view.findViewById(R.id.secondary_text);
setHolder(view, new TitleTextHolder(primaryText, secondaryText));
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/ContactEmailAdapter.java
// Path: src/com/abewy/android/apps/contacts/adapter/holder/TitleTextHolder.java // public class TitleTextHolder // { // public final TextView primaryText; // public final TextView secondaryText; // // public TitleTextHolder(TextView primaryText, TextView secondaryText) // { // this.primaryText = primaryText; // this.secondaryText = secondaryText; // } // } // // Path: src/com/abewy/android/apps/contacts/model/ContactEmail.java // public class ContactEmail extends BaseContact // { // public final String email; // public final int type; // public final String label; // // public ContactEmail(String email, int type) // { // this(email, type, ""); // } // // public ContactEmail(String email, int type, String label) // { // this.email = email; // this.type = type; // this.label = label; // } // // @Override // public int getItemViewType() // { // return ObjectType.CONTACT_EMAIL; // } // // @Override // public String getItemPrimaryLabel() // { // return email; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // }
import android.provider.ContactsContract.CommonDataKinds.Email; import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.TitleTextHolder; import com.abewy.android.apps.contacts.model.ContactEmail; import com.abewy.android.extended.items.BaseType;
package com.abewy.android.apps.contacts.adapter; public class ContactEmailAdapter extends ContactBaseAdapter { public ContactEmailAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_title_text; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text); TextView secondaryText = (TextView) view.findViewById(R.id.secondary_text); setHolder(view, new TitleTextHolder(primaryText, secondaryText)); } @Override
// Path: src/com/abewy/android/apps/contacts/adapter/holder/TitleTextHolder.java // public class TitleTextHolder // { // public final TextView primaryText; // public final TextView secondaryText; // // public TitleTextHolder(TextView primaryText, TextView secondaryText) // { // this.primaryText = primaryText; // this.secondaryText = secondaryText; // } // } // // Path: src/com/abewy/android/apps/contacts/model/ContactEmail.java // public class ContactEmail extends BaseContact // { // public final String email; // public final int type; // public final String label; // // public ContactEmail(String email, int type) // { // this(email, type, ""); // } // // public ContactEmail(String email, int type, String label) // { // this.email = email; // this.type = type; // this.label = label; // } // // @Override // public int getItemViewType() // { // return ObjectType.CONTACT_EMAIL; // } // // @Override // public String getItemPrimaryLabel() // { // return email; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // Path: src/com/abewy/android/apps/contacts/adapter/ContactEmailAdapter.java import android.provider.ContactsContract.CommonDataKinds.Email; import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.TitleTextHolder; import com.abewy.android.apps.contacts.model.ContactEmail; import com.abewy.android.extended.items.BaseType; package com.abewy.android.apps.contacts.adapter; public class ContactEmailAdapter extends ContactBaseAdapter { public ContactEmailAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_title_text; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text); TextView secondaryText = (TextView) view.findViewById(R.id.secondary_text); setHolder(view, new TitleTextHolder(primaryText, secondaryText)); } @Override
public void bindData(View view, BaseType data, int position)
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/ContactEmailAdapter.java
// Path: src/com/abewy/android/apps/contacts/adapter/holder/TitleTextHolder.java // public class TitleTextHolder // { // public final TextView primaryText; // public final TextView secondaryText; // // public TitleTextHolder(TextView primaryText, TextView secondaryText) // { // this.primaryText = primaryText; // this.secondaryText = secondaryText; // } // } // // Path: src/com/abewy/android/apps/contacts/model/ContactEmail.java // public class ContactEmail extends BaseContact // { // public final String email; // public final int type; // public final String label; // // public ContactEmail(String email, int type) // { // this(email, type, ""); // } // // public ContactEmail(String email, int type, String label) // { // this.email = email; // this.type = type; // this.label = label; // } // // @Override // public int getItemViewType() // { // return ObjectType.CONTACT_EMAIL; // } // // @Override // public String getItemPrimaryLabel() // { // return email; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // }
import android.provider.ContactsContract.CommonDataKinds.Email; import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.TitleTextHolder; import com.abewy.android.apps.contacts.model.ContactEmail; import com.abewy.android.extended.items.BaseType;
package com.abewy.android.apps.contacts.adapter; public class ContactEmailAdapter extends ContactBaseAdapter { public ContactEmailAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_title_text; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text); TextView secondaryText = (TextView) view.findViewById(R.id.secondary_text); setHolder(view, new TitleTextHolder(primaryText, secondaryText)); } @Override public void bindData(View view, BaseType data, int position) { final TitleTextHolder holder = (TitleTextHolder) getHolder(view);
// Path: src/com/abewy/android/apps/contacts/adapter/holder/TitleTextHolder.java // public class TitleTextHolder // { // public final TextView primaryText; // public final TextView secondaryText; // // public TitleTextHolder(TextView primaryText, TextView secondaryText) // { // this.primaryText = primaryText; // this.secondaryText = secondaryText; // } // } // // Path: src/com/abewy/android/apps/contacts/model/ContactEmail.java // public class ContactEmail extends BaseContact // { // public final String email; // public final int type; // public final String label; // // public ContactEmail(String email, int type) // { // this(email, type, ""); // } // // public ContactEmail(String email, int type, String label) // { // this.email = email; // this.type = type; // this.label = label; // } // // @Override // public int getItemViewType() // { // return ObjectType.CONTACT_EMAIL; // } // // @Override // public String getItemPrimaryLabel() // { // return email; // } // } // // Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // Path: src/com/abewy/android/apps/contacts/adapter/ContactEmailAdapter.java import android.provider.ContactsContract.CommonDataKinds.Email; import android.view.View; import android.widget.TextView; import com.abewy.android.apps.contacts.R; import com.abewy.android.apps.contacts.adapter.holder.TitleTextHolder; import com.abewy.android.apps.contacts.model.ContactEmail; import com.abewy.android.extended.items.BaseType; package com.abewy.android.apps.contacts.adapter; public class ContactEmailAdapter extends ContactBaseAdapter { public ContactEmailAdapter() { super(); } @Override protected int getLayoutRes() { return R.layout.item_title_text; } @Override protected void attachViewHolder(View view) { TextView primaryText = (TextView) view.findViewById(R.id.primary_text); TextView secondaryText = (TextView) view.findViewById(R.id.secondary_text); setHolder(view, new TitleTextHolder(primaryText, secondaryText)); } @Override public void bindData(View view, BaseType data, int position) { final TitleTextHolder holder = (TitleTextHolder) getHolder(view);
final ContactEmail email = ((ContactEmail) data);
jonathangerbaud/Contacts
src/com/abewy/android/apps/contacts/adapter/ContactListAdapter.java
// Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: src/com/hb/views/PinnedSectionListView.java // public static interface PinnedSectionListAdapter extends ListAdapter { // /** This method shall return 'true' if views of given type has to be pinned. */ // boolean isItemViewTypePinned(int viewType); // }
import java.util.List; import android.util.Log; import android.widget.AbsListView; import android.widget.SectionIndexer; import com.abewy.android.extended.items.BaseType; import com.hb.views.PinnedSectionListView.PinnedSectionListAdapter;
/** * @author Jonathan */ package com.abewy.android.apps.contacts.adapter; public class ContactListAdapter extends MultiObjectAdapter implements SectionIndexer, PinnedSectionListAdapter { private static String sections = "ABCDEFGHIJKLMNOPQRSTUVWXYZ#"; private static String[] sectionsArr; private int[] sectionMap; private int[] positionMap; public ContactListAdapter(AbsListView listView) { super(listView); sectionMap = new int[sections.length()]; positionMap = new int[1]; } public ContactListAdapter(AbsListView listView, int layoutType) { super(listView, layoutType); sectionMap = new int[sections.length()]; positionMap = new int[1]; } @Override
// Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java // public abstract class BaseType // { // public static final int HEADER = 1; // public static final int PROGRESS = 2; // public static final int TEXT_BUTTON = 3; // public static final int TEXT = 4; // public static final int TITLE = 5; // public static final int TITLE_TEXT = 6; // public static final int TITLE_TWO_ITEM = 7; // // /** // * Return an unique data type to associate with a list view item // */ // public abstract int getItemViewType(); // // public abstract String getItemPrimaryLabel(); // } // // Path: src/com/hb/views/PinnedSectionListView.java // public static interface PinnedSectionListAdapter extends ListAdapter { // /** This method shall return 'true' if views of given type has to be pinned. */ // boolean isItemViewTypePinned(int viewType); // } // Path: src/com/abewy/android/apps/contacts/adapter/ContactListAdapter.java import java.util.List; import android.util.Log; import android.widget.AbsListView; import android.widget.SectionIndexer; import com.abewy.android.extended.items.BaseType; import com.hb.views.PinnedSectionListView.PinnedSectionListAdapter; /** * @author Jonathan */ package com.abewy.android.apps.contacts.adapter; public class ContactListAdapter extends MultiObjectAdapter implements SectionIndexer, PinnedSectionListAdapter { private static String sections = "ABCDEFGHIJKLMNOPQRSTUVWXYZ#"; private static String[] sectionsArr; private int[] sectionMap; private int[] positionMap; public ContactListAdapter(AbsListView listView) { super(listView); sectionMap = new int[sections.length()]; positionMap = new int[1]; } public ContactListAdapter(AbsListView listView, int layoutType) { super(listView, layoutType); sectionMap = new int[sections.length()]; positionMap = new int[1]; } @Override
public void setData(List<BaseType> data)
jbehave/jbehave-web
web-runner/src/main/java/org/jbehave/web/runner/wicket/pages/RunStory.java
// Path: web-runner/src/main/java/org/jbehave/web/runner/context/StoryContext.java // @SuppressWarnings("serial") // public class StoryContext implements Serializable { // // private static final String EMPTY = ""; // private String input = EMPTY; // private String metaFilter = EMPTY; // private String output = EMPTY; // private List<String> messages = new ArrayList<String>(); // private Throwable cause = null; // // public StoryContext(){ // } // // public String getInput() { // return input; // } // // public void setInput(String input) { // this.input = input; // } // // public String getMetaFilter() { // return metaFilter; // } // // public void setMetaFilter(String metaFilter) { // this.metaFilter = metaFilter; // } // // public String getOutput() { // return output; // } // // public void setOutput(String output) { // this.output = output; // } // // public List<String> getFailureMessages() { // messages.clear(); // addFailureMessage(cause); // return messages; // } // // private void addFailureMessage(Throwable cause) { // if ( cause != null ){ // if ( cause.getMessage() != null ){ // messages.add(cause.getMessage()); // } // // recurse // addFailureMessage(cause.getCause()); // } // } // // public void clearFailureCause() { // this.cause = null; // } // // public void runFailedFor(Throwable cause) { // this.cause = cause; // } // // public String getFailureStackTrace() { // StringWriter writer = new StringWriter(); // if (cause != null) { // cause.printStackTrace(new PrintWriter(writer)); // } // return writer.getBuffer().toString(); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // // // }
import java.io.OutputStream; import java.io.PrintStream; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Properties; import org.apache.wicket.markup.html.basic.MultiLineLabel; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextArea; import org.apache.wicket.model.CompoundPropertyModel; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.util.value.ValueMap; import org.jbehave.core.configuration.Keywords; import org.jbehave.core.embedder.Embedder; import org.jbehave.core.embedder.PerformableTree; import org.jbehave.core.embedder.StoryManager; import org.jbehave.core.failures.BatchFailures; import org.jbehave.core.model.Story; import org.jbehave.core.reporters.StoryReporter; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.reporters.TxtOutput; import org.jbehave.web.runner.context.StoryContext; import org.jbehave.web.runner.context.StoryOutputStream; import com.google.inject.Inject; import static java.util.Arrays.asList; import static org.apache.commons.lang3.StringUtils.isNotBlank;
package org.jbehave.web.runner.wicket.pages; @SuppressWarnings("serial") public class RunStory extends Template { @Inject private Embedder embedder; private StoryManager storyManager; private StoryOutputStream outputStream = new StoryOutputStream();
// Path: web-runner/src/main/java/org/jbehave/web/runner/context/StoryContext.java // @SuppressWarnings("serial") // public class StoryContext implements Serializable { // // private static final String EMPTY = ""; // private String input = EMPTY; // private String metaFilter = EMPTY; // private String output = EMPTY; // private List<String> messages = new ArrayList<String>(); // private Throwable cause = null; // // public StoryContext(){ // } // // public String getInput() { // return input; // } // // public void setInput(String input) { // this.input = input; // } // // public String getMetaFilter() { // return metaFilter; // } // // public void setMetaFilter(String metaFilter) { // this.metaFilter = metaFilter; // } // // public String getOutput() { // return output; // } // // public void setOutput(String output) { // this.output = output; // } // // public List<String> getFailureMessages() { // messages.clear(); // addFailureMessage(cause); // return messages; // } // // private void addFailureMessage(Throwable cause) { // if ( cause != null ){ // if ( cause.getMessage() != null ){ // messages.add(cause.getMessage()); // } // // recurse // addFailureMessage(cause.getCause()); // } // } // // public void clearFailureCause() { // this.cause = null; // } // // public void runFailedFor(Throwable cause) { // this.cause = cause; // } // // public String getFailureStackTrace() { // StringWriter writer = new StringWriter(); // if (cause != null) { // cause.printStackTrace(new PrintWriter(writer)); // } // return writer.getBuffer().toString(); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // // // } // Path: web-runner/src/main/java/org/jbehave/web/runner/wicket/pages/RunStory.java import java.io.OutputStream; import java.io.PrintStream; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Properties; import org.apache.wicket.markup.html.basic.MultiLineLabel; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextArea; import org.apache.wicket.model.CompoundPropertyModel; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.util.value.ValueMap; import org.jbehave.core.configuration.Keywords; import org.jbehave.core.embedder.Embedder; import org.jbehave.core.embedder.PerformableTree; import org.jbehave.core.embedder.StoryManager; import org.jbehave.core.failures.BatchFailures; import org.jbehave.core.model.Story; import org.jbehave.core.reporters.StoryReporter; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.reporters.TxtOutput; import org.jbehave.web.runner.context.StoryContext; import org.jbehave.web.runner.context.StoryOutputStream; import com.google.inject.Inject; import static java.util.Arrays.asList; import static org.apache.commons.lang3.StringUtils.isNotBlank; package org.jbehave.web.runner.wicket.pages; @SuppressWarnings("serial") public class RunStory extends Template { @Inject private Embedder embedder; private StoryManager storyManager; private StoryOutputStream outputStream = new StoryOutputStream();
private StoryContext storyContext = new StoryContext();
jbehave/jbehave-web
web-runner/src/main/java/org/jbehave/web/runner/wicket/pages/FileContent.java
// Path: web-io/src/main/java/org/jbehave/web/io/ResourceFinder.java // public class ResourceFinder { // // public static final String DEFAULT_ROOT_DIRECTORY = ""; // public static final String DEFAULT_CLASSPATH_PREFIX = "classpath:"; // private final ClassLoader classLoader; // private final String classpathPrefix; // private String rootDirectory; // // public ResourceFinder() { // this(DEFAULT_ROOT_DIRECTORY); // } // // public ResourceFinder(String rootDirectory) { // this(Thread.currentThread().getContextClassLoader(), rootDirectory, // DEFAULT_CLASSPATH_PREFIX); // } // // public ResourceFinder(ClassLoader classLoader, String rootDirectory) { // this(classLoader, rootDirectory, DEFAULT_CLASSPATH_PREFIX); // } // // public ResourceFinder(ClassLoader classLoader, String rootDirectory, // String classpathPrefix) { // this.classLoader = classLoader; // this.classpathPrefix = classpathPrefix; // this.rootDirectory = rootDirectory; // } // // public String resourceAsString(String relativePath) { // String resourcePath = resolvePath(relativePath); // try { // try { // return classpathResource(resourcePath); // } catch (ResourceNotFoundException e) { // return filesystemResource(resourcePath); // } // } catch (IOException e) { // throw new ResourceRetrievalFailedException(resourcePath); // } // // } // // public void useRootDirectory(String rootDirectory) { // this.rootDirectory = rootDirectory; // } // // private String classpathResource(String resourcePath) throws IOException { // InputStream inputStream = classLoader.getResourceAsStream(resourcePath); // if (inputStream != null) { // return IOUtils.toString(inputStream, Charset.defaultCharset()); // } // throw new ResourceNotFoundException(resourcePath, classLoader); // } // // private String filesystemResource(String resourcePath) throws IOException { // File file = new File(resourcePath); // if (file.exists()) { // return FileUtils.readFileToString(file, Charset.defaultCharset()); // } // throw new ResourceNotFoundException(resourcePath); // } // // private String resolvePath(String relativePath) { // String resourcePath; // if (rootDirectory.startsWith(classpathPrefix)) { // resourcePath = resourcePath(stripPrefix(rootDirectory, // classpathPrefix), relativePath); // } else { // resourcePath = resourcePath(rootDirectory, relativePath); // // } // return resourcePath; // } // // private String resourcePath(String rootDirectory, String relativePath) { // if ( StringUtils.isBlank(rootDirectory) ){ // return relativePath; // } // return rootDirectory + "/" + relativePath; // } // // private String stripPrefix(String path, String prefix) { // return path.substring(prefix.length()); // } // // @SuppressWarnings("serial") // public static class ResourceNotFoundException extends RuntimeException { // // public ResourceNotFoundException(String resourcePath) { // super("Resource " + resourcePath + " not found"); // } // // public ResourceNotFoundException(String resourcePath, // ClassLoader classLoader) { // super("Resource " + resourcePath + " not found in classLoader " // + classLoader); // } // // } // // @SuppressWarnings("serial") // public static class ResourceRetrievalFailedException extends // RuntimeException { // // public ResourceRetrievalFailedException(String resourcePath) { // super("Failed to retrieve resource " + resourcePath); // } // // } // }
import java.io.File; import org.apache.commons.lang3.StringUtils; import org.jbehave.web.io.ResourceFinder;
package org.jbehave.web.runner.wicket.pages; @SuppressWarnings("serial") public class FileContent extends Template { public FileContent(File file) { String path = file.getPath(); String type = typeOf(path);
// Path: web-io/src/main/java/org/jbehave/web/io/ResourceFinder.java // public class ResourceFinder { // // public static final String DEFAULT_ROOT_DIRECTORY = ""; // public static final String DEFAULT_CLASSPATH_PREFIX = "classpath:"; // private final ClassLoader classLoader; // private final String classpathPrefix; // private String rootDirectory; // // public ResourceFinder() { // this(DEFAULT_ROOT_DIRECTORY); // } // // public ResourceFinder(String rootDirectory) { // this(Thread.currentThread().getContextClassLoader(), rootDirectory, // DEFAULT_CLASSPATH_PREFIX); // } // // public ResourceFinder(ClassLoader classLoader, String rootDirectory) { // this(classLoader, rootDirectory, DEFAULT_CLASSPATH_PREFIX); // } // // public ResourceFinder(ClassLoader classLoader, String rootDirectory, // String classpathPrefix) { // this.classLoader = classLoader; // this.classpathPrefix = classpathPrefix; // this.rootDirectory = rootDirectory; // } // // public String resourceAsString(String relativePath) { // String resourcePath = resolvePath(relativePath); // try { // try { // return classpathResource(resourcePath); // } catch (ResourceNotFoundException e) { // return filesystemResource(resourcePath); // } // } catch (IOException e) { // throw new ResourceRetrievalFailedException(resourcePath); // } // // } // // public void useRootDirectory(String rootDirectory) { // this.rootDirectory = rootDirectory; // } // // private String classpathResource(String resourcePath) throws IOException { // InputStream inputStream = classLoader.getResourceAsStream(resourcePath); // if (inputStream != null) { // return IOUtils.toString(inputStream, Charset.defaultCharset()); // } // throw new ResourceNotFoundException(resourcePath, classLoader); // } // // private String filesystemResource(String resourcePath) throws IOException { // File file = new File(resourcePath); // if (file.exists()) { // return FileUtils.readFileToString(file, Charset.defaultCharset()); // } // throw new ResourceNotFoundException(resourcePath); // } // // private String resolvePath(String relativePath) { // String resourcePath; // if (rootDirectory.startsWith(classpathPrefix)) { // resourcePath = resourcePath(stripPrefix(rootDirectory, // classpathPrefix), relativePath); // } else { // resourcePath = resourcePath(rootDirectory, relativePath); // // } // return resourcePath; // } // // private String resourcePath(String rootDirectory, String relativePath) { // if ( StringUtils.isBlank(rootDirectory) ){ // return relativePath; // } // return rootDirectory + "/" + relativePath; // } // // private String stripPrefix(String path, String prefix) { // return path.substring(prefix.length()); // } // // @SuppressWarnings("serial") // public static class ResourceNotFoundException extends RuntimeException { // // public ResourceNotFoundException(String resourcePath) { // super("Resource " + resourcePath + " not found"); // } // // public ResourceNotFoundException(String resourcePath, // ClassLoader classLoader) { // super("Resource " + resourcePath + " not found in classLoader " // + classLoader); // } // // } // // @SuppressWarnings("serial") // public static class ResourceRetrievalFailedException extends // RuntimeException { // // public ResourceRetrievalFailedException(String resourcePath) { // super("Failed to retrieve resource " + resourcePath); // } // // } // } // Path: web-runner/src/main/java/org/jbehave/web/runner/wicket/pages/FileContent.java import java.io.File; import org.apache.commons.lang3.StringUtils; import org.jbehave.web.io.ResourceFinder; package org.jbehave.web.runner.wicket.pages; @SuppressWarnings("serial") public class FileContent extends Template { public FileContent(File file) { String path = file.getPath(); String type = typeOf(path);
add(new NoMarkupMultiLineLabel("fileContent", new ResourceFinder().resourceAsString(path), "brush: "+type));
jbehave/jbehave-web
web-runner/src/main/java/org/jbehave/web/runner/wicket/pages/DataFiles.java
// Path: web-runner/src/main/java/org/jbehave/web/runner/context/FileContext.java // @SuppressWarnings("serial") // public class FileContext implements Serializable { // // private List<File> files = new ArrayList<File>(); // private Map<String, List<File>> contentFiles = new HashMap<String, List<File>>(); // private boolean contentVisible = false; // private List<String> errors = new ArrayList<String>(); // // public FileContext() { // } // // public List<File> getFiles() { // return files; // } // // public void setFiles(List<File> files) { // this.files = toViewables(files); // } // // public List<File> getContentFilesAsList() { // List<File> list = new ArrayList<File>(); // for ( String directoryPath : contentFiles.keySet() ){ // list.addAll(toViewables(contentFiles.get(directoryPath))); // } // return list; // } // // private List<File> toViewables(List<File> files) { // List<File> viewableFiles = new ArrayList<File>(); // for (File file : files) { // ViewableFile viewableFile = new ViewableFile(file); // if ( viewableFile.isViewable() ){ // viewableFiles.add(viewableFile); // } // } // return viewableFiles; // } // // public boolean getContentVisible() { // return contentVisible; // } // // public void setContentVisible(boolean contentVisible) { // this.contentVisible = contentVisible; // } // // public Map<String, List<File>> getContentFiles() { // return contentFiles; // } // // public void setContentFiles(Map<String, List<File>> contentFiles) { // this.contentFiles = contentFiles; // } // // public List<String> getErrors() { // return errors; // } // // public void setErrors(List<String> errors){ // this.errors = errors; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public static class ViewableFile extends File { // // public ViewableFile(File file) { // super(file.getPath()); // } // // public String getPath(){ // return unixPath(super.getPath()); // } // // private String unixPath(String path) { // return path.replace("\\","/"); // } // // public boolean isViewable() { // return getPath().matches(".*\\.[A-Za-z]+"); // } // // } // // // }
import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; import org.apache.commons.fileupload.FileItem; import org.apache.commons.lang3.NotImplementedException; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.CheckBoxMultipleChoice; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.upload.FileUpload; import org.apache.wicket.markup.html.form.upload.MultiFileUploadField; import org.apache.wicket.markup.html.link.Link; import org.apache.wicket.markup.html.list.ListItem; import org.apache.wicket.markup.html.list.ListView; import org.apache.wicket.model.CompoundPropertyModel; import org.apache.wicket.model.PropertyModel; import org.jbehave.web.io.FileManager; import org.jbehave.web.runner.context.FileContext; import com.google.inject.Inject;
package org.jbehave.web.runner.wicket.pages; @SuppressWarnings("serial") public class DataFiles extends Template { @Inject private FileManager manager;
// Path: web-runner/src/main/java/org/jbehave/web/runner/context/FileContext.java // @SuppressWarnings("serial") // public class FileContext implements Serializable { // // private List<File> files = new ArrayList<File>(); // private Map<String, List<File>> contentFiles = new HashMap<String, List<File>>(); // private boolean contentVisible = false; // private List<String> errors = new ArrayList<String>(); // // public FileContext() { // } // // public List<File> getFiles() { // return files; // } // // public void setFiles(List<File> files) { // this.files = toViewables(files); // } // // public List<File> getContentFilesAsList() { // List<File> list = new ArrayList<File>(); // for ( String directoryPath : contentFiles.keySet() ){ // list.addAll(toViewables(contentFiles.get(directoryPath))); // } // return list; // } // // private List<File> toViewables(List<File> files) { // List<File> viewableFiles = new ArrayList<File>(); // for (File file : files) { // ViewableFile viewableFile = new ViewableFile(file); // if ( viewableFile.isViewable() ){ // viewableFiles.add(viewableFile); // } // } // return viewableFiles; // } // // public boolean getContentVisible() { // return contentVisible; // } // // public void setContentVisible(boolean contentVisible) { // this.contentVisible = contentVisible; // } // // public Map<String, List<File>> getContentFiles() { // return contentFiles; // } // // public void setContentFiles(Map<String, List<File>> contentFiles) { // this.contentFiles = contentFiles; // } // // public List<String> getErrors() { // return errors; // } // // public void setErrors(List<String> errors){ // this.errors = errors; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public static class ViewableFile extends File { // // public ViewableFile(File file) { // super(file.getPath()); // } // // public String getPath(){ // return unixPath(super.getPath()); // } // // private String unixPath(String path) { // return path.replace("\\","/"); // } // // public boolean isViewable() { // return getPath().matches(".*\\.[A-Za-z]+"); // } // // } // // // } // Path: web-runner/src/main/java/org/jbehave/web/runner/wicket/pages/DataFiles.java import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; import org.apache.commons.fileupload.FileItem; import org.apache.commons.lang3.NotImplementedException; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.CheckBoxMultipleChoice; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.upload.FileUpload; import org.apache.wicket.markup.html.form.upload.MultiFileUploadField; import org.apache.wicket.markup.html.link.Link; import org.apache.wicket.markup.html.list.ListItem; import org.apache.wicket.markup.html.list.ListView; import org.apache.wicket.model.CompoundPropertyModel; import org.apache.wicket.model.PropertyModel; import org.jbehave.web.io.FileManager; import org.jbehave.web.runner.context.FileContext; import com.google.inject.Inject; package org.jbehave.web.runner.wicket.pages; @SuppressWarnings("serial") public class DataFiles extends Template { @Inject private FileManager manager;
private final FileContext fileContext = new FileContext();
jbehave/jbehave-web
web-io/src/test/java/org/jbehave/web/io/ResourceFinderTest.java
// Path: web-io/src/main/java/org/jbehave/web/io/ResourceFinder.java // @SuppressWarnings("serial") // public static class ResourceNotFoundException extends RuntimeException { // // public ResourceNotFoundException(String resourcePath) { // super("Resource " + resourcePath + " not found"); // } // // public ResourceNotFoundException(String resourcePath, // ClassLoader classLoader) { // super("Resource " + resourcePath + " not found in classLoader " // + classLoader); // } // // }
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.assertEquals; import java.io.IOException; import org.jbehave.web.io.ResourceFinder.ResourceNotFoundException; import org.junit.Test;
public void canFindResourceFromRootDirectoryInClasspath() throws IOException { ResourceFinder finder = new ResourceFinder("classpath:org/jbehave/web"); assertEquals("A test resource", finder.resourceAsString("io/resource.txt")); } @Test public void canChangeRootDirectory() throws IOException { ResourceFinder finder = new ResourceFinder(); finder.useRootDirectory("classpath:org/jbehave/web/io"); assertEquals("A test resource", finder.resourceAsString("resource.txt")); } @Test public void canFindResourceInFilesystem() throws IOException { ResourceFinder finder = new ResourceFinder(); assertEquals("A test resource", finder.resourceAsString("src/test/java/org/jbehave/web/io/resource.txt")); } @Test public void canFindResourceFromRootDirectoryInFilesystem() throws IOException { ResourceFinder finder = new ResourceFinder("src/test/java/org/jbehave/web"); assertEquals("A test resource", finder.resourceAsString("io/resource.txt")); } @Test public void canFindResourceInJarsInClasspath() { ResourceFinder finder = new ResourceFinder(); assertThat(finder.resourceAsString("ftl/jbehave-reports.ftl").length(), greaterThan(0)); }
// Path: web-io/src/main/java/org/jbehave/web/io/ResourceFinder.java // @SuppressWarnings("serial") // public static class ResourceNotFoundException extends RuntimeException { // // public ResourceNotFoundException(String resourcePath) { // super("Resource " + resourcePath + " not found"); // } // // public ResourceNotFoundException(String resourcePath, // ClassLoader classLoader) { // super("Resource " + resourcePath + " not found in classLoader " // + classLoader); // } // // } // Path: web-io/src/test/java/org/jbehave/web/io/ResourceFinderTest.java import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.assertEquals; import java.io.IOException; import org.jbehave.web.io.ResourceFinder.ResourceNotFoundException; import org.junit.Test; public void canFindResourceFromRootDirectoryInClasspath() throws IOException { ResourceFinder finder = new ResourceFinder("classpath:org/jbehave/web"); assertEquals("A test resource", finder.resourceAsString("io/resource.txt")); } @Test public void canChangeRootDirectory() throws IOException { ResourceFinder finder = new ResourceFinder(); finder.useRootDirectory("classpath:org/jbehave/web/io"); assertEquals("A test resource", finder.resourceAsString("resource.txt")); } @Test public void canFindResourceInFilesystem() throws IOException { ResourceFinder finder = new ResourceFinder(); assertEquals("A test resource", finder.resourceAsString("src/test/java/org/jbehave/web/io/resource.txt")); } @Test public void canFindResourceFromRootDirectoryInFilesystem() throws IOException { ResourceFinder finder = new ResourceFinder("src/test/java/org/jbehave/web"); assertEquals("A test resource", finder.resourceAsString("io/resource.txt")); } @Test public void canFindResourceInJarsInClasspath() { ResourceFinder finder = new ResourceFinder(); assertThat(finder.resourceAsString("ftl/jbehave-reports.ftl").length(), greaterThan(0)); }
@Test(expected = ResourceNotFoundException.class)
jbehave/jbehave-web
examples/flash-webdriver/src/main/java/org/jbehave/web/examples/flash/FlashStories.java
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashWebDriverProvider.java // public class FlashWebDriverProvider extends DelegatingWebDriverProvider { // // private String flashObjectId; // private WebDriver javascriptDriver; // // public FlashWebDriverProvider(String flashObjectId, WebDriver javascriptDriver) { // this.flashObjectId = flashObjectId; // this.javascriptDriver = javascriptDriver; // } // // public void initialize() { // delegate.set(new FlashDriver(javascriptDriver, flashObjectId)); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/PerStoryWebDriverSteps.java // public class PerStoryWebDriverSteps extends WebDriverSteps { // // public PerStoryWebDriverSteps(WebDriverProvider driverProvider) { // super(driverProvider); // } // // @BeforeStory // public void beforeStory() throws Exception { // driverProvider.initialize(); // } // // @AfterStory // public void afterStory() throws Exception { // driverProvider.end(); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SeleniumConfiguration.java // public class SeleniumConfiguration extends Configuration { // // private Selenium selenium; // private SeleniumContext seleniumContext; // private WebDriverProvider driverProvider; // // public SeleniumConfiguration() { // } // // public Selenium selenium() { // synchronized (this) { // if (selenium == null) { // selenium = defaultSelenium(); // } // } // return selenium; // } // // public SeleniumConfiguration useSelenium(Selenium selenium){ // this.selenium = selenium; // return this; // } // // public SeleniumContext seleniumContext() { // synchronized (this) { // if (seleniumContext == null) { // seleniumContext = new SeleniumContext(); // } // } // return seleniumContext; // } // // public SeleniumConfiguration useSeleniumContext(SeleniumContext seleniumContext) { // this.seleniumContext = seleniumContext; // return this; // } // // public WebDriverProvider webDriverProvider() { // return driverProvider; // } // // public SeleniumConfiguration useWebDriverProvider(WebDriverProvider webDriverProvider){ // this.driverProvider = webDriverProvider; // return this; // } // // /** // * Creates default Selenium instance: {@link DefaultSelenium("localhost", // * 4444, "*firefox", "http://localhost:8080")} // * // * @return A Selenium instance // */ // public static Selenium defaultSelenium() { // return new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080"); // } // // /** // * Creates default ConditionRunner: {@link JUnitConditionRunner(selenium, // * 10, 100, 1000)}. // * // * @param selenium // * the Selenium instance // * @return A ConditionRunner // */ // public static ConditionRunner defaultConditionRunner(Selenium selenium) { // return new JUnitConditionRunner(selenium, 10, 100, 1000); // } // // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // }
import java.util.List; import org.jbehave.core.Embeddable; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.io.LoadFromClasspath; import org.jbehave.core.io.StoryFinder; import org.jbehave.core.junit.JUnitStories; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.steps.InjectableStepsFactory; import org.jbehave.core.steps.InstanceStepsFactory; import org.jbehave.web.examples.flash.pages.Colors; import org.jbehave.web.examples.flash.steps.ColorSteps; import org.jbehave.web.selenium.FlashWebDriverProvider; import org.jbehave.web.selenium.PerStoryWebDriverSteps; import org.jbehave.web.selenium.SeleniumConfiguration; import org.jbehave.web.selenium.WebDriverProvider; import org.openqa.selenium.firefox.FirefoxDriver; import static java.util.Arrays.asList; import static org.jbehave.core.io.CodeLocations.codeLocationFromClass; import static org.jbehave.core.reporters.Format.CONSOLE; import static org.jbehave.core.reporters.Format.HTML; import static org.jbehave.core.reporters.Format.TXT; import static org.jbehave.core.reporters.Format.XML;
package org.jbehave.web.examples.flash; public class FlashStories extends JUnitStories { private WebDriverProvider driverProvider = new FlashWebDriverProvider("coloredSquare", new FirefoxDriver()); private Colors colorsPage = new Colors(driverProvider); @Override public Configuration configuration() { Class<? extends Embeddable> embeddableClass = this.getClass();
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashWebDriverProvider.java // public class FlashWebDriverProvider extends DelegatingWebDriverProvider { // // private String flashObjectId; // private WebDriver javascriptDriver; // // public FlashWebDriverProvider(String flashObjectId, WebDriver javascriptDriver) { // this.flashObjectId = flashObjectId; // this.javascriptDriver = javascriptDriver; // } // // public void initialize() { // delegate.set(new FlashDriver(javascriptDriver, flashObjectId)); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/PerStoryWebDriverSteps.java // public class PerStoryWebDriverSteps extends WebDriverSteps { // // public PerStoryWebDriverSteps(WebDriverProvider driverProvider) { // super(driverProvider); // } // // @BeforeStory // public void beforeStory() throws Exception { // driverProvider.initialize(); // } // // @AfterStory // public void afterStory() throws Exception { // driverProvider.end(); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SeleniumConfiguration.java // public class SeleniumConfiguration extends Configuration { // // private Selenium selenium; // private SeleniumContext seleniumContext; // private WebDriverProvider driverProvider; // // public SeleniumConfiguration() { // } // // public Selenium selenium() { // synchronized (this) { // if (selenium == null) { // selenium = defaultSelenium(); // } // } // return selenium; // } // // public SeleniumConfiguration useSelenium(Selenium selenium){ // this.selenium = selenium; // return this; // } // // public SeleniumContext seleniumContext() { // synchronized (this) { // if (seleniumContext == null) { // seleniumContext = new SeleniumContext(); // } // } // return seleniumContext; // } // // public SeleniumConfiguration useSeleniumContext(SeleniumContext seleniumContext) { // this.seleniumContext = seleniumContext; // return this; // } // // public WebDriverProvider webDriverProvider() { // return driverProvider; // } // // public SeleniumConfiguration useWebDriverProvider(WebDriverProvider webDriverProvider){ // this.driverProvider = webDriverProvider; // return this; // } // // /** // * Creates default Selenium instance: {@link DefaultSelenium("localhost", // * 4444, "*firefox", "http://localhost:8080")} // * // * @return A Selenium instance // */ // public static Selenium defaultSelenium() { // return new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080"); // } // // /** // * Creates default ConditionRunner: {@link JUnitConditionRunner(selenium, // * 10, 100, 1000)}. // * // * @param selenium // * the Selenium instance // * @return A ConditionRunner // */ // public static ConditionRunner defaultConditionRunner(Selenium selenium) { // return new JUnitConditionRunner(selenium, 10, 100, 1000); // } // // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // } // Path: examples/flash-webdriver/src/main/java/org/jbehave/web/examples/flash/FlashStories.java import java.util.List; import org.jbehave.core.Embeddable; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.io.LoadFromClasspath; import org.jbehave.core.io.StoryFinder; import org.jbehave.core.junit.JUnitStories; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.steps.InjectableStepsFactory; import org.jbehave.core.steps.InstanceStepsFactory; import org.jbehave.web.examples.flash.pages.Colors; import org.jbehave.web.examples.flash.steps.ColorSteps; import org.jbehave.web.selenium.FlashWebDriverProvider; import org.jbehave.web.selenium.PerStoryWebDriverSteps; import org.jbehave.web.selenium.SeleniumConfiguration; import org.jbehave.web.selenium.WebDriverProvider; import org.openqa.selenium.firefox.FirefoxDriver; import static java.util.Arrays.asList; import static org.jbehave.core.io.CodeLocations.codeLocationFromClass; import static org.jbehave.core.reporters.Format.CONSOLE; import static org.jbehave.core.reporters.Format.HTML; import static org.jbehave.core.reporters.Format.TXT; import static org.jbehave.core.reporters.Format.XML; package org.jbehave.web.examples.flash; public class FlashStories extends JUnitStories { private WebDriverProvider driverProvider = new FlashWebDriverProvider("coloredSquare", new FirefoxDriver()); private Colors colorsPage = new Colors(driverProvider); @Override public Configuration configuration() { Class<? extends Embeddable> embeddableClass = this.getClass();
return new SeleniumConfiguration()
jbehave/jbehave-web
examples/flash-webdriver/src/main/java/org/jbehave/web/examples/flash/FlashStories.java
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashWebDriverProvider.java // public class FlashWebDriverProvider extends DelegatingWebDriverProvider { // // private String flashObjectId; // private WebDriver javascriptDriver; // // public FlashWebDriverProvider(String flashObjectId, WebDriver javascriptDriver) { // this.flashObjectId = flashObjectId; // this.javascriptDriver = javascriptDriver; // } // // public void initialize() { // delegate.set(new FlashDriver(javascriptDriver, flashObjectId)); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/PerStoryWebDriverSteps.java // public class PerStoryWebDriverSteps extends WebDriverSteps { // // public PerStoryWebDriverSteps(WebDriverProvider driverProvider) { // super(driverProvider); // } // // @BeforeStory // public void beforeStory() throws Exception { // driverProvider.initialize(); // } // // @AfterStory // public void afterStory() throws Exception { // driverProvider.end(); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SeleniumConfiguration.java // public class SeleniumConfiguration extends Configuration { // // private Selenium selenium; // private SeleniumContext seleniumContext; // private WebDriverProvider driverProvider; // // public SeleniumConfiguration() { // } // // public Selenium selenium() { // synchronized (this) { // if (selenium == null) { // selenium = defaultSelenium(); // } // } // return selenium; // } // // public SeleniumConfiguration useSelenium(Selenium selenium){ // this.selenium = selenium; // return this; // } // // public SeleniumContext seleniumContext() { // synchronized (this) { // if (seleniumContext == null) { // seleniumContext = new SeleniumContext(); // } // } // return seleniumContext; // } // // public SeleniumConfiguration useSeleniumContext(SeleniumContext seleniumContext) { // this.seleniumContext = seleniumContext; // return this; // } // // public WebDriverProvider webDriverProvider() { // return driverProvider; // } // // public SeleniumConfiguration useWebDriverProvider(WebDriverProvider webDriverProvider){ // this.driverProvider = webDriverProvider; // return this; // } // // /** // * Creates default Selenium instance: {@link DefaultSelenium("localhost", // * 4444, "*firefox", "http://localhost:8080")} // * // * @return A Selenium instance // */ // public static Selenium defaultSelenium() { // return new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080"); // } // // /** // * Creates default ConditionRunner: {@link JUnitConditionRunner(selenium, // * 10, 100, 1000)}. // * // * @param selenium // * the Selenium instance // * @return A ConditionRunner // */ // public static ConditionRunner defaultConditionRunner(Selenium selenium) { // return new JUnitConditionRunner(selenium, 10, 100, 1000); // } // // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // }
import java.util.List; import org.jbehave.core.Embeddable; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.io.LoadFromClasspath; import org.jbehave.core.io.StoryFinder; import org.jbehave.core.junit.JUnitStories; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.steps.InjectableStepsFactory; import org.jbehave.core.steps.InstanceStepsFactory; import org.jbehave.web.examples.flash.pages.Colors; import org.jbehave.web.examples.flash.steps.ColorSteps; import org.jbehave.web.selenium.FlashWebDriverProvider; import org.jbehave.web.selenium.PerStoryWebDriverSteps; import org.jbehave.web.selenium.SeleniumConfiguration; import org.jbehave.web.selenium.WebDriverProvider; import org.openqa.selenium.firefox.FirefoxDriver; import static java.util.Arrays.asList; import static org.jbehave.core.io.CodeLocations.codeLocationFromClass; import static org.jbehave.core.reporters.Format.CONSOLE; import static org.jbehave.core.reporters.Format.HTML; import static org.jbehave.core.reporters.Format.TXT; import static org.jbehave.core.reporters.Format.XML;
package org.jbehave.web.examples.flash; public class FlashStories extends JUnitStories { private WebDriverProvider driverProvider = new FlashWebDriverProvider("coloredSquare", new FirefoxDriver()); private Colors colorsPage = new Colors(driverProvider); @Override public Configuration configuration() { Class<? extends Embeddable> embeddableClass = this.getClass(); return new SeleniumConfiguration() .useWebDriverProvider(driverProvider) .useStoryLoader(new LoadFromClasspath(embeddableClass)) .useStoryReporterBuilder( new StoryReporterBuilder().withCodeLocation(codeLocationFromClass(embeddableClass)) .withDefaultFormats().withFormats(CONSOLE, TXT, HTML, XML)); } @Override public InjectableStepsFactory stepsFactory() {
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashWebDriverProvider.java // public class FlashWebDriverProvider extends DelegatingWebDriverProvider { // // private String flashObjectId; // private WebDriver javascriptDriver; // // public FlashWebDriverProvider(String flashObjectId, WebDriver javascriptDriver) { // this.flashObjectId = flashObjectId; // this.javascriptDriver = javascriptDriver; // } // // public void initialize() { // delegate.set(new FlashDriver(javascriptDriver, flashObjectId)); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/PerStoryWebDriverSteps.java // public class PerStoryWebDriverSteps extends WebDriverSteps { // // public PerStoryWebDriverSteps(WebDriverProvider driverProvider) { // super(driverProvider); // } // // @BeforeStory // public void beforeStory() throws Exception { // driverProvider.initialize(); // } // // @AfterStory // public void afterStory() throws Exception { // driverProvider.end(); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SeleniumConfiguration.java // public class SeleniumConfiguration extends Configuration { // // private Selenium selenium; // private SeleniumContext seleniumContext; // private WebDriverProvider driverProvider; // // public SeleniumConfiguration() { // } // // public Selenium selenium() { // synchronized (this) { // if (selenium == null) { // selenium = defaultSelenium(); // } // } // return selenium; // } // // public SeleniumConfiguration useSelenium(Selenium selenium){ // this.selenium = selenium; // return this; // } // // public SeleniumContext seleniumContext() { // synchronized (this) { // if (seleniumContext == null) { // seleniumContext = new SeleniumContext(); // } // } // return seleniumContext; // } // // public SeleniumConfiguration useSeleniumContext(SeleniumContext seleniumContext) { // this.seleniumContext = seleniumContext; // return this; // } // // public WebDriverProvider webDriverProvider() { // return driverProvider; // } // // public SeleniumConfiguration useWebDriverProvider(WebDriverProvider webDriverProvider){ // this.driverProvider = webDriverProvider; // return this; // } // // /** // * Creates default Selenium instance: {@link DefaultSelenium("localhost", // * 4444, "*firefox", "http://localhost:8080")} // * // * @return A Selenium instance // */ // public static Selenium defaultSelenium() { // return new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080"); // } // // /** // * Creates default ConditionRunner: {@link JUnitConditionRunner(selenium, // * 10, 100, 1000)}. // * // * @param selenium // * the Selenium instance // * @return A ConditionRunner // */ // public static ConditionRunner defaultConditionRunner(Selenium selenium) { // return new JUnitConditionRunner(selenium, 10, 100, 1000); // } // // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // } // Path: examples/flash-webdriver/src/main/java/org/jbehave/web/examples/flash/FlashStories.java import java.util.List; import org.jbehave.core.Embeddable; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.io.LoadFromClasspath; import org.jbehave.core.io.StoryFinder; import org.jbehave.core.junit.JUnitStories; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.steps.InjectableStepsFactory; import org.jbehave.core.steps.InstanceStepsFactory; import org.jbehave.web.examples.flash.pages.Colors; import org.jbehave.web.examples.flash.steps.ColorSteps; import org.jbehave.web.selenium.FlashWebDriverProvider; import org.jbehave.web.selenium.PerStoryWebDriverSteps; import org.jbehave.web.selenium.SeleniumConfiguration; import org.jbehave.web.selenium.WebDriverProvider; import org.openqa.selenium.firefox.FirefoxDriver; import static java.util.Arrays.asList; import static org.jbehave.core.io.CodeLocations.codeLocationFromClass; import static org.jbehave.core.reporters.Format.CONSOLE; import static org.jbehave.core.reporters.Format.HTML; import static org.jbehave.core.reporters.Format.TXT; import static org.jbehave.core.reporters.Format.XML; package org.jbehave.web.examples.flash; public class FlashStories extends JUnitStories { private WebDriverProvider driverProvider = new FlashWebDriverProvider("coloredSquare", new FirefoxDriver()); private Colors colorsPage = new Colors(driverProvider); @Override public Configuration configuration() { Class<? extends Embeddable> embeddableClass = this.getClass(); return new SeleniumConfiguration() .useWebDriverProvider(driverProvider) .useStoryLoader(new LoadFromClasspath(embeddableClass)) .useStoryReporterBuilder( new StoryReporterBuilder().withCodeLocation(codeLocationFromClass(embeddableClass)) .withDefaultFormats().withFormats(CONSOLE, TXT, HTML, XML)); } @Override public InjectableStepsFactory stepsFactory() {
return new InstanceStepsFactory(configuration(), new ColorSteps(colorsPage), new PerStoryWebDriverSteps(
jbehave/jbehave-web
web-runner/src/main/java/org/jbehave/web/runner/wicket/pages/SubmitStory.java
// Path: web-runner/src/main/java/org/jbehave/web/runner/context/StoryContext.java // @SuppressWarnings("serial") // public class StoryContext implements Serializable { // // private static final String EMPTY = ""; // private String input = EMPTY; // private String metaFilter = EMPTY; // private String output = EMPTY; // private List<String> messages = new ArrayList<String>(); // private Throwable cause = null; // // public StoryContext(){ // } // // public String getInput() { // return input; // } // // public void setInput(String input) { // this.input = input; // } // // public String getMetaFilter() { // return metaFilter; // } // // public void setMetaFilter(String metaFilter) { // this.metaFilter = metaFilter; // } // // public String getOutput() { // return output; // } // // public void setOutput(String output) { // this.output = output; // } // // public List<String> getFailureMessages() { // messages.clear(); // addFailureMessage(cause); // return messages; // } // // private void addFailureMessage(Throwable cause) { // if ( cause != null ){ // if ( cause.getMessage() != null ){ // messages.add(cause.getMessage()); // } // // recurse // addFailureMessage(cause.getCause()); // } // } // // public void clearFailureCause() { // this.cause = null; // } // // public void runFailedFor(Throwable cause) { // this.cause = cause; // } // // public String getFailureStackTrace() { // StringWriter writer = new StringWriter(); // if (cause != null) { // cause.printStackTrace(new PrintWriter(writer)); // } // return writer.getBuffer().toString(); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // // // }
import java.text.SimpleDateFormat; import java.util.Date; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextArea; import org.apache.wicket.markup.html.link.BookmarkablePageLink; import org.apache.wicket.model.CompoundPropertyModel; import org.apache.wicket.model.Model; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.util.value.ValueMap; import org.jbehave.core.embedder.Embedder; import org.jbehave.core.embedder.PerformableTree; import org.jbehave.core.embedder.StoryManager; import org.jbehave.core.failures.BatchFailures; import org.jbehave.core.model.Story; import org.jbehave.core.reporters.CrossReference; import org.jbehave.web.runner.context.StoryContext; import com.google.inject.Inject; import static java.util.Arrays.asList; import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.jbehave.core.io.CodeLocations.codeLocationFromPath; import static org.jbehave.core.reporters.Format.HTML; import static org.jbehave.core.reporters.Format.TXT; import static org.jbehave.core.reporters.Format.XML;
package org.jbehave.web.runner.wicket.pages; @SuppressWarnings("serial") public class SubmitStory extends Template { @Inject private Embedder embedder; private StoryManager storyManager;
// Path: web-runner/src/main/java/org/jbehave/web/runner/context/StoryContext.java // @SuppressWarnings("serial") // public class StoryContext implements Serializable { // // private static final String EMPTY = ""; // private String input = EMPTY; // private String metaFilter = EMPTY; // private String output = EMPTY; // private List<String> messages = new ArrayList<String>(); // private Throwable cause = null; // // public StoryContext(){ // } // // public String getInput() { // return input; // } // // public void setInput(String input) { // this.input = input; // } // // public String getMetaFilter() { // return metaFilter; // } // // public void setMetaFilter(String metaFilter) { // this.metaFilter = metaFilter; // } // // public String getOutput() { // return output; // } // // public void setOutput(String output) { // this.output = output; // } // // public List<String> getFailureMessages() { // messages.clear(); // addFailureMessage(cause); // return messages; // } // // private void addFailureMessage(Throwable cause) { // if ( cause != null ){ // if ( cause.getMessage() != null ){ // messages.add(cause.getMessage()); // } // // recurse // addFailureMessage(cause.getCause()); // } // } // // public void clearFailureCause() { // this.cause = null; // } // // public void runFailedFor(Throwable cause) { // this.cause = cause; // } // // public String getFailureStackTrace() { // StringWriter writer = new StringWriter(); // if (cause != null) { // cause.printStackTrace(new PrintWriter(writer)); // } // return writer.getBuffer().toString(); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // // // } // Path: web-runner/src/main/java/org/jbehave/web/runner/wicket/pages/SubmitStory.java import java.text.SimpleDateFormat; import java.util.Date; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextArea; import org.apache.wicket.markup.html.link.BookmarkablePageLink; import org.apache.wicket.model.CompoundPropertyModel; import org.apache.wicket.model.Model; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.util.value.ValueMap; import org.jbehave.core.embedder.Embedder; import org.jbehave.core.embedder.PerformableTree; import org.jbehave.core.embedder.StoryManager; import org.jbehave.core.failures.BatchFailures; import org.jbehave.core.model.Story; import org.jbehave.core.reporters.CrossReference; import org.jbehave.web.runner.context.StoryContext; import com.google.inject.Inject; import static java.util.Arrays.asList; import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.jbehave.core.io.CodeLocations.codeLocationFromPath; import static org.jbehave.core.reporters.Format.HTML; import static org.jbehave.core.reporters.Format.TXT; import static org.jbehave.core.reporters.Format.XML; package org.jbehave.web.runner.wicket.pages; @SuppressWarnings("serial") public class SubmitStory extends Template { @Inject private Embedder embedder; private StoryManager storyManager;
private StoryContext storyContext = new StoryContext();
jbehave/jbehave-web
web-io/src/main/java/org/jbehave/web/io/ArchivingFileManager.java
// Path: web-io/src/main/java/org/jbehave/web/io/ZipFileArchiver.java // @SuppressWarnings("serial") // public static final class FileUnarchiveFailedException extends // RuntimeException { // // public FileUnarchiveFailedException(File archive, File directory, // Exception cause) { // super("Failed to unarchive " + archive + " to dir " + directory, // cause); // } // // }
import static java.util.Arrays.asList; import static org.apache.commons.lang3.StringUtils.isBlank; import java.io.File; import java.io.FileFilter; import java.util.ArrayList; import java.util.List; import org.apache.commons.fileupload.FileItem; import org.apache.commons.io.FilenameUtils; import org.jbehave.web.io.ZipFileArchiver.FileUnarchiveFailedException;
} public List<File> upload(List<FileItem> fileItems, List<String> errors) { List<File> files = new ArrayList<File>(); File directory = uploadDirectory(); for (FileItem item : fileItems) { try { File file = writeItemToFile(directory, item); monitor.fileUploaded(file); files.add(file); } catch (FileItemNameMissingException e) { // ignore and carry on } catch (FileWriteFailedException e) { errors.add(e.getMessage()); if (e.getCause() != null) { errors.add(e.getCause().getMessage()); } monitor.fileUploadFailed(item, e); } } return files; } public void unarchiveFiles(List<File> files, List<String> errors) { File directory = uploadDirectory(); for (File file : files) { if (archiver.isArchive(file)) { try { archiver.unarchive(file, directory); monitor.fileUnarchived(file, directory);
// Path: web-io/src/main/java/org/jbehave/web/io/ZipFileArchiver.java // @SuppressWarnings("serial") // public static final class FileUnarchiveFailedException extends // RuntimeException { // // public FileUnarchiveFailedException(File archive, File directory, // Exception cause) { // super("Failed to unarchive " + archive + " to dir " + directory, // cause); // } // // } // Path: web-io/src/main/java/org/jbehave/web/io/ArchivingFileManager.java import static java.util.Arrays.asList; import static org.apache.commons.lang3.StringUtils.isBlank; import java.io.File; import java.io.FileFilter; import java.util.ArrayList; import java.util.List; import org.apache.commons.fileupload.FileItem; import org.apache.commons.io.FilenameUtils; import org.jbehave.web.io.ZipFileArchiver.FileUnarchiveFailedException; } public List<File> upload(List<FileItem> fileItems, List<String> errors) { List<File> files = new ArrayList<File>(); File directory = uploadDirectory(); for (FileItem item : fileItems) { try { File file = writeItemToFile(directory, item); monitor.fileUploaded(file); files.add(file); } catch (FileItemNameMissingException e) { // ignore and carry on } catch (FileWriteFailedException e) { errors.add(e.getMessage()); if (e.getCause() != null) { errors.add(e.getCause().getMessage()); } monitor.fileUploadFailed(item, e); } } return files; } public void unarchiveFiles(List<File> files, List<String> errors) { File directory = uploadDirectory(); for (File file : files) { if (archiver.isArchive(file)) { try { archiver.unarchive(file, directory); monitor.fileUnarchived(file, directory);
} catch (FileUnarchiveFailedException e) {
jbehave/jbehave-web
web-selenium/src/main/java/org/jbehave/web/selenium/SauceContextStoryReporter.java
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/SauceWebDriverProvider.java // public static String getSauceAccessKey() { // String access_key = System.getProperty("SAUCE_ACCESS_KEY"); // if (access_key == null) { // throw new UnsupportedOperationException("SAUCE_ACCESS_KEY property name variable not specified"); // } // return access_key; // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SauceWebDriverProvider.java // public static String getSauceUser() { // String username = System.getProperty("SAUCE_USERNAME"); // if (username == null) { // throw new UnsupportedOperationException("SAUCE_USERNAME property name variable not specified"); // } // return username; // }
import org.jbehave.core.model.Story; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.remote.SessionId; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.Authenticator; import java.net.HttpURLConnection; import java.net.PasswordAuthentication; import java.net.URL; import java.util.HashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.Map; import static org.jbehave.web.selenium.SauceWebDriverProvider.getSauceAccessKey; import static org.jbehave.web.selenium.SauceWebDriverProvider.getSauceUser;
@Override public void afterStory(boolean givenStory) { String storyName = this.storyName.get(); if (storyName.equals("BeforeStories") || storyName.equals("AfterStories") || storyName.equals("BeforeStory") || storyName.equals("AfterStory") || storyName.equals("BeforeScenario") || storyName.equals("AfterScenario")) { return; } SessionId sessionId = sessionIds.get(); if (sessionId == null ) { // no executed scenarios, as (most likely) excluded return; } boolean pass = passed.get().equals(true); String payload = "{ \"passed\":" + pass + "}"; postJobUpdate(storyName, sessionId, payload); System.out.println("Saucelabs Job URL for " + (passed.get() ? "passing" : "failing") + " '" + storyName + "' : " + storyToJobIds.get(storyName)); } private void postJobUpdate(String storyName, SessionId sessionId, String payload) { try {
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/SauceWebDriverProvider.java // public static String getSauceAccessKey() { // String access_key = System.getProperty("SAUCE_ACCESS_KEY"); // if (access_key == null) { // throw new UnsupportedOperationException("SAUCE_ACCESS_KEY property name variable not specified"); // } // return access_key; // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SauceWebDriverProvider.java // public static String getSauceUser() { // String username = System.getProperty("SAUCE_USERNAME"); // if (username == null) { // throw new UnsupportedOperationException("SAUCE_USERNAME property name variable not specified"); // } // return username; // } // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SauceContextStoryReporter.java import org.jbehave.core.model.Story; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.remote.SessionId; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.Authenticator; import java.net.HttpURLConnection; import java.net.PasswordAuthentication; import java.net.URL; import java.util.HashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.Map; import static org.jbehave.web.selenium.SauceWebDriverProvider.getSauceAccessKey; import static org.jbehave.web.selenium.SauceWebDriverProvider.getSauceUser; @Override public void afterStory(boolean givenStory) { String storyName = this.storyName.get(); if (storyName.equals("BeforeStories") || storyName.equals("AfterStories") || storyName.equals("BeforeStory") || storyName.equals("AfterStory") || storyName.equals("BeforeScenario") || storyName.equals("AfterScenario")) { return; } SessionId sessionId = sessionIds.get(); if (sessionId == null ) { // no executed scenarios, as (most likely) excluded return; } boolean pass = passed.get().equals(true); String payload = "{ \"passed\":" + pass + "}"; postJobUpdate(storyName, sessionId, payload); System.out.println("Saucelabs Job URL for " + (passed.get() ? "passing" : "failing") + " '" + storyName + "' : " + storyToJobIds.get(storyName)); } private void postJobUpdate(String storyName, SessionId sessionId, String payload) { try {
URL url = new URL("http://saucelabs.com/rest/v1/" + getSauceUser() + "/jobs/" + sessionId.toString());
jbehave/jbehave-web
web-selenium/src/main/java/org/jbehave/web/selenium/SauceContextStoryReporter.java
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/SauceWebDriverProvider.java // public static String getSauceAccessKey() { // String access_key = System.getProperty("SAUCE_ACCESS_KEY"); // if (access_key == null) { // throw new UnsupportedOperationException("SAUCE_ACCESS_KEY property name variable not specified"); // } // return access_key; // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SauceWebDriverProvider.java // public static String getSauceUser() { // String username = System.getProperty("SAUCE_USERNAME"); // if (username == null) { // throw new UnsupportedOperationException("SAUCE_USERNAME property name variable not specified"); // } // return username; // }
import org.jbehave.core.model.Story; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.remote.SessionId; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.Authenticator; import java.net.HttpURLConnection; import java.net.PasswordAuthentication; import java.net.URL; import java.util.HashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.Map; import static org.jbehave.web.selenium.SauceWebDriverProvider.getSauceAccessKey; import static org.jbehave.web.selenium.SauceWebDriverProvider.getSauceUser;
if (storyName.equals("BeforeStories") || storyName.equals("AfterStories") || storyName.equals("BeforeStory") || storyName.equals("AfterStory") || storyName.equals("BeforeScenario") || storyName.equals("AfterScenario")) { return; } SessionId sessionId = sessionIds.get(); if (sessionId == null ) { // no executed scenarios, as (most likely) excluded return; } boolean pass = passed.get().equals(true); String payload = "{ \"passed\":" + pass + "}"; postJobUpdate(storyName, sessionId, payload); System.out.println("Saucelabs Job URL for " + (passed.get() ? "passing" : "failing") + " '" + storyName + "' : " + storyToJobIds.get(storyName)); } private void postJobUpdate(String storyName, SessionId sessionId, String payload) { try { URL url = new URL("http://saucelabs.com/rest/v1/" + getSauceUser() + "/jobs/" + sessionId.toString()); Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() {
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/SauceWebDriverProvider.java // public static String getSauceAccessKey() { // String access_key = System.getProperty("SAUCE_ACCESS_KEY"); // if (access_key == null) { // throw new UnsupportedOperationException("SAUCE_ACCESS_KEY property name variable not specified"); // } // return access_key; // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SauceWebDriverProvider.java // public static String getSauceUser() { // String username = System.getProperty("SAUCE_USERNAME"); // if (username == null) { // throw new UnsupportedOperationException("SAUCE_USERNAME property name variable not specified"); // } // return username; // } // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SauceContextStoryReporter.java import org.jbehave.core.model.Story; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.remote.SessionId; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.Authenticator; import java.net.HttpURLConnection; import java.net.PasswordAuthentication; import java.net.URL; import java.util.HashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.Map; import static org.jbehave.web.selenium.SauceWebDriverProvider.getSauceAccessKey; import static org.jbehave.web.selenium.SauceWebDriverProvider.getSauceUser; if (storyName.equals("BeforeStories") || storyName.equals("AfterStories") || storyName.equals("BeforeStory") || storyName.equals("AfterStory") || storyName.equals("BeforeScenario") || storyName.equals("AfterScenario")) { return; } SessionId sessionId = sessionIds.get(); if (sessionId == null ) { // no executed scenarios, as (most likely) excluded return; } boolean pass = passed.get().equals(true); String payload = "{ \"passed\":" + pass + "}"; postJobUpdate(storyName, sessionId, payload); System.out.println("Saucelabs Job URL for " + (passed.get() ? "passing" : "failing") + " '" + storyName + "' : " + storyToJobIds.get(storyName)); } private void postJobUpdate(String storyName, SessionId sessionId, String payload) { try { URL url = new URL("http://saucelabs.com/rest/v1/" + getSauceUser() + "/jobs/" + sessionId.toString()); Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(getSauceUser(), getSauceAccessKey().toCharArray());
jbehave/jbehave-web
archetypes/web-selenium-flash-archetype/src/main/resources/archetype-resources/src/main/java/pages/Colors.java
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashPage.java // public abstract class FlashPage extends WebDriverPage { // // public FlashPage(WebDriverProvider driverProvider) { // super(driverProvider); // } // // protected FlashDriver flashDriver() { // WebDriver driver = getDriverProvider().get(); // if ( driver instanceof FlashDriver ){ // return (FlashDriver)driver; // } // throw new FlashNotSupported(driver); // } // // @SuppressWarnings("serial") // public static class FlashNotSupported extends RuntimeException { // // public FlashNotSupported(WebDriver driver) { // super("Flash not supported by WebDriver "+driver); // } // // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // }
import org.jbehave.web.selenium.WebDriverProvider; import java.util.concurrent.TimeUnit; import org.jbehave.web.selenium.FlashPage;
#set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}.pages;
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashPage.java // public abstract class FlashPage extends WebDriverPage { // // public FlashPage(WebDriverProvider driverProvider) { // super(driverProvider); // } // // protected FlashDriver flashDriver() { // WebDriver driver = getDriverProvider().get(); // if ( driver instanceof FlashDriver ){ // return (FlashDriver)driver; // } // throw new FlashNotSupported(driver); // } // // @SuppressWarnings("serial") // public static class FlashNotSupported extends RuntimeException { // // public FlashNotSupported(WebDriver driver) { // super("Flash not supported by WebDriver "+driver); // } // // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // } // Path: archetypes/web-selenium-flash-archetype/src/main/resources/archetype-resources/src/main/java/pages/Colors.java import org.jbehave.web.selenium.WebDriverProvider; import java.util.concurrent.TimeUnit; import org.jbehave.web.selenium.FlashPage; #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}.pages;
public class Colors extends FlashPage {
jbehave/jbehave-web
archetypes/web-selenium-flash-archetype/src/main/resources/archetype-resources/src/main/java/pages/Colors.java
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashPage.java // public abstract class FlashPage extends WebDriverPage { // // public FlashPage(WebDriverProvider driverProvider) { // super(driverProvider); // } // // protected FlashDriver flashDriver() { // WebDriver driver = getDriverProvider().get(); // if ( driver instanceof FlashDriver ){ // return (FlashDriver)driver; // } // throw new FlashNotSupported(driver); // } // // @SuppressWarnings("serial") // public static class FlashNotSupported extends RuntimeException { // // public FlashNotSupported(WebDriver driver) { // super("Flash not supported by WebDriver "+driver); // } // // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // }
import org.jbehave.web.selenium.WebDriverProvider; import java.util.concurrent.TimeUnit; import org.jbehave.web.selenium.FlashPage;
#set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}.pages; public class Colors extends FlashPage {
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashPage.java // public abstract class FlashPage extends WebDriverPage { // // public FlashPage(WebDriverProvider driverProvider) { // super(driverProvider); // } // // protected FlashDriver flashDriver() { // WebDriver driver = getDriverProvider().get(); // if ( driver instanceof FlashDriver ){ // return (FlashDriver)driver; // } // throw new FlashNotSupported(driver); // } // // @SuppressWarnings("serial") // public static class FlashNotSupported extends RuntimeException { // // public FlashNotSupported(WebDriver driver) { // super("Flash not supported by WebDriver "+driver); // } // // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // } // Path: archetypes/web-selenium-flash-archetype/src/main/resources/archetype-resources/src/main/java/pages/Colors.java import org.jbehave.web.selenium.WebDriverProvider; import java.util.concurrent.TimeUnit; import org.jbehave.web.selenium.FlashPage; #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}.pages; public class Colors extends FlashPage {
public Colors(WebDriverProvider driverProvider) {
jbehave/jbehave-web
archetypes/web-selenium-flash-archetype/src/main/resources/archetype-resources/src/main/java/FlashStories.java
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashWebDriverProvider.java // public class FlashWebDriverProvider extends DelegatingWebDriverProvider { // // private String flashObjectId; // private WebDriver javascriptDriver; // // public FlashWebDriverProvider(String flashObjectId, WebDriver javascriptDriver) { // this.flashObjectId = flashObjectId; // this.javascriptDriver = javascriptDriver; // } // // public void initialize() { // delegate.set(new FlashDriver(javascriptDriver, flashObjectId)); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/PerStoryWebDriverSteps.java // public class PerStoryWebDriverSteps extends WebDriverSteps { // // public PerStoryWebDriverSteps(WebDriverProvider driverProvider) { // super(driverProvider); // } // // @BeforeStory // public void beforeStory() throws Exception { // driverProvider.initialize(); // } // // @AfterStory // public void afterStory() throws Exception { // driverProvider.end(); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SeleniumConfiguration.java // public class SeleniumConfiguration extends Configuration { // // private Selenium selenium; // private SeleniumContext seleniumContext; // private WebDriverProvider driverProvider; // // public SeleniumConfiguration() { // } // // public Selenium selenium() { // synchronized (this) { // if (selenium == null) { // selenium = defaultSelenium(); // } // } // return selenium; // } // // public SeleniumConfiguration useSelenium(Selenium selenium){ // this.selenium = selenium; // return this; // } // // public SeleniumContext seleniumContext() { // synchronized (this) { // if (seleniumContext == null) { // seleniumContext = new SeleniumContext(); // } // } // return seleniumContext; // } // // public SeleniumConfiguration useSeleniumContext(SeleniumContext seleniumContext) { // this.seleniumContext = seleniumContext; // return this; // } // // public WebDriverProvider webDriverProvider() { // return driverProvider; // } // // public SeleniumConfiguration useWebDriverProvider(WebDriverProvider webDriverProvider){ // this.driverProvider = webDriverProvider; // return this; // } // // /** // * Creates default Selenium instance: {@link DefaultSelenium("localhost", // * 4444, "*firefox", "http://localhost:8080")} // * // * @return A Selenium instance // */ // public static Selenium defaultSelenium() { // return new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080"); // } // // /** // * Creates default ConditionRunner: {@link JUnitConditionRunner(selenium, // * 10, 100, 1000)}. // * // * @param selenium // * the Selenium instance // * @return A ConditionRunner // */ // public static ConditionRunner defaultConditionRunner(Selenium selenium) { // return new JUnitConditionRunner(selenium, 10, 100, 1000); // } // // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // }
import java.util.List; import org.jbehave.core.Embeddable; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.io.LoadFromClasspath; import org.jbehave.core.io.StoryFinder; import org.jbehave.core.junit.JUnitStories; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.steps.InjectableStepsFactory; import org.jbehave.core.steps.InstanceStepsFactory; import ${package}.pages.Colors; import ${package}.steps.ColorSteps; import org.jbehave.web.selenium.FlashWebDriverProvider; import org.jbehave.web.selenium.PerStoryWebDriverSteps; import org.jbehave.web.selenium.SeleniumConfiguration; import org.jbehave.web.selenium.WebDriverProvider; import org.openqa.selenium.firefox.FirefoxDriver; import static java.util.Arrays.asList; import static org.jbehave.core.io.CodeLocations.codeLocationFromClass; import static org.jbehave.core.reporters.Format.CONSOLE; import static org.jbehave.core.reporters.Format.HTML; import static org.jbehave.core.reporters.Format.TXT; import static org.jbehave.core.reporters.Format.XML;
#set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}; public class FlashStories extends JUnitStories {
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashWebDriverProvider.java // public class FlashWebDriverProvider extends DelegatingWebDriverProvider { // // private String flashObjectId; // private WebDriver javascriptDriver; // // public FlashWebDriverProvider(String flashObjectId, WebDriver javascriptDriver) { // this.flashObjectId = flashObjectId; // this.javascriptDriver = javascriptDriver; // } // // public void initialize() { // delegate.set(new FlashDriver(javascriptDriver, flashObjectId)); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/PerStoryWebDriverSteps.java // public class PerStoryWebDriverSteps extends WebDriverSteps { // // public PerStoryWebDriverSteps(WebDriverProvider driverProvider) { // super(driverProvider); // } // // @BeforeStory // public void beforeStory() throws Exception { // driverProvider.initialize(); // } // // @AfterStory // public void afterStory() throws Exception { // driverProvider.end(); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SeleniumConfiguration.java // public class SeleniumConfiguration extends Configuration { // // private Selenium selenium; // private SeleniumContext seleniumContext; // private WebDriverProvider driverProvider; // // public SeleniumConfiguration() { // } // // public Selenium selenium() { // synchronized (this) { // if (selenium == null) { // selenium = defaultSelenium(); // } // } // return selenium; // } // // public SeleniumConfiguration useSelenium(Selenium selenium){ // this.selenium = selenium; // return this; // } // // public SeleniumContext seleniumContext() { // synchronized (this) { // if (seleniumContext == null) { // seleniumContext = new SeleniumContext(); // } // } // return seleniumContext; // } // // public SeleniumConfiguration useSeleniumContext(SeleniumContext seleniumContext) { // this.seleniumContext = seleniumContext; // return this; // } // // public WebDriverProvider webDriverProvider() { // return driverProvider; // } // // public SeleniumConfiguration useWebDriverProvider(WebDriverProvider webDriverProvider){ // this.driverProvider = webDriverProvider; // return this; // } // // /** // * Creates default Selenium instance: {@link DefaultSelenium("localhost", // * 4444, "*firefox", "http://localhost:8080")} // * // * @return A Selenium instance // */ // public static Selenium defaultSelenium() { // return new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080"); // } // // /** // * Creates default ConditionRunner: {@link JUnitConditionRunner(selenium, // * 10, 100, 1000)}. // * // * @param selenium // * the Selenium instance // * @return A ConditionRunner // */ // public static ConditionRunner defaultConditionRunner(Selenium selenium) { // return new JUnitConditionRunner(selenium, 10, 100, 1000); // } // // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // } // Path: archetypes/web-selenium-flash-archetype/src/main/resources/archetype-resources/src/main/java/FlashStories.java import java.util.List; import org.jbehave.core.Embeddable; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.io.LoadFromClasspath; import org.jbehave.core.io.StoryFinder; import org.jbehave.core.junit.JUnitStories; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.steps.InjectableStepsFactory; import org.jbehave.core.steps.InstanceStepsFactory; import ${package}.pages.Colors; import ${package}.steps.ColorSteps; import org.jbehave.web.selenium.FlashWebDriverProvider; import org.jbehave.web.selenium.PerStoryWebDriverSteps; import org.jbehave.web.selenium.SeleniumConfiguration; import org.jbehave.web.selenium.WebDriverProvider; import org.openqa.selenium.firefox.FirefoxDriver; import static java.util.Arrays.asList; import static org.jbehave.core.io.CodeLocations.codeLocationFromClass; import static org.jbehave.core.reporters.Format.CONSOLE; import static org.jbehave.core.reporters.Format.HTML; import static org.jbehave.core.reporters.Format.TXT; import static org.jbehave.core.reporters.Format.XML; #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}; public class FlashStories extends JUnitStories {
private WebDriverProvider driverProvider = new FlashWebDriverProvider("coloredSquare", new FirefoxDriver());
jbehave/jbehave-web
archetypes/web-selenium-flash-archetype/src/main/resources/archetype-resources/src/main/java/FlashStories.java
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashWebDriverProvider.java // public class FlashWebDriverProvider extends DelegatingWebDriverProvider { // // private String flashObjectId; // private WebDriver javascriptDriver; // // public FlashWebDriverProvider(String flashObjectId, WebDriver javascriptDriver) { // this.flashObjectId = flashObjectId; // this.javascriptDriver = javascriptDriver; // } // // public void initialize() { // delegate.set(new FlashDriver(javascriptDriver, flashObjectId)); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/PerStoryWebDriverSteps.java // public class PerStoryWebDriverSteps extends WebDriverSteps { // // public PerStoryWebDriverSteps(WebDriverProvider driverProvider) { // super(driverProvider); // } // // @BeforeStory // public void beforeStory() throws Exception { // driverProvider.initialize(); // } // // @AfterStory // public void afterStory() throws Exception { // driverProvider.end(); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SeleniumConfiguration.java // public class SeleniumConfiguration extends Configuration { // // private Selenium selenium; // private SeleniumContext seleniumContext; // private WebDriverProvider driverProvider; // // public SeleniumConfiguration() { // } // // public Selenium selenium() { // synchronized (this) { // if (selenium == null) { // selenium = defaultSelenium(); // } // } // return selenium; // } // // public SeleniumConfiguration useSelenium(Selenium selenium){ // this.selenium = selenium; // return this; // } // // public SeleniumContext seleniumContext() { // synchronized (this) { // if (seleniumContext == null) { // seleniumContext = new SeleniumContext(); // } // } // return seleniumContext; // } // // public SeleniumConfiguration useSeleniumContext(SeleniumContext seleniumContext) { // this.seleniumContext = seleniumContext; // return this; // } // // public WebDriverProvider webDriverProvider() { // return driverProvider; // } // // public SeleniumConfiguration useWebDriverProvider(WebDriverProvider webDriverProvider){ // this.driverProvider = webDriverProvider; // return this; // } // // /** // * Creates default Selenium instance: {@link DefaultSelenium("localhost", // * 4444, "*firefox", "http://localhost:8080")} // * // * @return A Selenium instance // */ // public static Selenium defaultSelenium() { // return new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080"); // } // // /** // * Creates default ConditionRunner: {@link JUnitConditionRunner(selenium, // * 10, 100, 1000)}. // * // * @param selenium // * the Selenium instance // * @return A ConditionRunner // */ // public static ConditionRunner defaultConditionRunner(Selenium selenium) { // return new JUnitConditionRunner(selenium, 10, 100, 1000); // } // // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // }
import java.util.List; import org.jbehave.core.Embeddable; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.io.LoadFromClasspath; import org.jbehave.core.io.StoryFinder; import org.jbehave.core.junit.JUnitStories; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.steps.InjectableStepsFactory; import org.jbehave.core.steps.InstanceStepsFactory; import ${package}.pages.Colors; import ${package}.steps.ColorSteps; import org.jbehave.web.selenium.FlashWebDriverProvider; import org.jbehave.web.selenium.PerStoryWebDriverSteps; import org.jbehave.web.selenium.SeleniumConfiguration; import org.jbehave.web.selenium.WebDriverProvider; import org.openqa.selenium.firefox.FirefoxDriver; import static java.util.Arrays.asList; import static org.jbehave.core.io.CodeLocations.codeLocationFromClass; import static org.jbehave.core.reporters.Format.CONSOLE; import static org.jbehave.core.reporters.Format.HTML; import static org.jbehave.core.reporters.Format.TXT; import static org.jbehave.core.reporters.Format.XML;
#set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}; public class FlashStories extends JUnitStories {
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashWebDriverProvider.java // public class FlashWebDriverProvider extends DelegatingWebDriverProvider { // // private String flashObjectId; // private WebDriver javascriptDriver; // // public FlashWebDriverProvider(String flashObjectId, WebDriver javascriptDriver) { // this.flashObjectId = flashObjectId; // this.javascriptDriver = javascriptDriver; // } // // public void initialize() { // delegate.set(new FlashDriver(javascriptDriver, flashObjectId)); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/PerStoryWebDriverSteps.java // public class PerStoryWebDriverSteps extends WebDriverSteps { // // public PerStoryWebDriverSteps(WebDriverProvider driverProvider) { // super(driverProvider); // } // // @BeforeStory // public void beforeStory() throws Exception { // driverProvider.initialize(); // } // // @AfterStory // public void afterStory() throws Exception { // driverProvider.end(); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SeleniumConfiguration.java // public class SeleniumConfiguration extends Configuration { // // private Selenium selenium; // private SeleniumContext seleniumContext; // private WebDriverProvider driverProvider; // // public SeleniumConfiguration() { // } // // public Selenium selenium() { // synchronized (this) { // if (selenium == null) { // selenium = defaultSelenium(); // } // } // return selenium; // } // // public SeleniumConfiguration useSelenium(Selenium selenium){ // this.selenium = selenium; // return this; // } // // public SeleniumContext seleniumContext() { // synchronized (this) { // if (seleniumContext == null) { // seleniumContext = new SeleniumContext(); // } // } // return seleniumContext; // } // // public SeleniumConfiguration useSeleniumContext(SeleniumContext seleniumContext) { // this.seleniumContext = seleniumContext; // return this; // } // // public WebDriverProvider webDriverProvider() { // return driverProvider; // } // // public SeleniumConfiguration useWebDriverProvider(WebDriverProvider webDriverProvider){ // this.driverProvider = webDriverProvider; // return this; // } // // /** // * Creates default Selenium instance: {@link DefaultSelenium("localhost", // * 4444, "*firefox", "http://localhost:8080")} // * // * @return A Selenium instance // */ // public static Selenium defaultSelenium() { // return new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080"); // } // // /** // * Creates default ConditionRunner: {@link JUnitConditionRunner(selenium, // * 10, 100, 1000)}. // * // * @param selenium // * the Selenium instance // * @return A ConditionRunner // */ // public static ConditionRunner defaultConditionRunner(Selenium selenium) { // return new JUnitConditionRunner(selenium, 10, 100, 1000); // } // // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // } // Path: archetypes/web-selenium-flash-archetype/src/main/resources/archetype-resources/src/main/java/FlashStories.java import java.util.List; import org.jbehave.core.Embeddable; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.io.LoadFromClasspath; import org.jbehave.core.io.StoryFinder; import org.jbehave.core.junit.JUnitStories; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.steps.InjectableStepsFactory; import org.jbehave.core.steps.InstanceStepsFactory; import ${package}.pages.Colors; import ${package}.steps.ColorSteps; import org.jbehave.web.selenium.FlashWebDriverProvider; import org.jbehave.web.selenium.PerStoryWebDriverSteps; import org.jbehave.web.selenium.SeleniumConfiguration; import org.jbehave.web.selenium.WebDriverProvider; import org.openqa.selenium.firefox.FirefoxDriver; import static java.util.Arrays.asList; import static org.jbehave.core.io.CodeLocations.codeLocationFromClass; import static org.jbehave.core.reporters.Format.CONSOLE; import static org.jbehave.core.reporters.Format.HTML; import static org.jbehave.core.reporters.Format.TXT; import static org.jbehave.core.reporters.Format.XML; #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}; public class FlashStories extends JUnitStories {
private WebDriverProvider driverProvider = new FlashWebDriverProvider("coloredSquare", new FirefoxDriver());
jbehave/jbehave-web
archetypes/web-selenium-flash-archetype/src/main/resources/archetype-resources/src/main/java/FlashStories.java
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashWebDriverProvider.java // public class FlashWebDriverProvider extends DelegatingWebDriverProvider { // // private String flashObjectId; // private WebDriver javascriptDriver; // // public FlashWebDriverProvider(String flashObjectId, WebDriver javascriptDriver) { // this.flashObjectId = flashObjectId; // this.javascriptDriver = javascriptDriver; // } // // public void initialize() { // delegate.set(new FlashDriver(javascriptDriver, flashObjectId)); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/PerStoryWebDriverSteps.java // public class PerStoryWebDriverSteps extends WebDriverSteps { // // public PerStoryWebDriverSteps(WebDriverProvider driverProvider) { // super(driverProvider); // } // // @BeforeStory // public void beforeStory() throws Exception { // driverProvider.initialize(); // } // // @AfterStory // public void afterStory() throws Exception { // driverProvider.end(); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SeleniumConfiguration.java // public class SeleniumConfiguration extends Configuration { // // private Selenium selenium; // private SeleniumContext seleniumContext; // private WebDriverProvider driverProvider; // // public SeleniumConfiguration() { // } // // public Selenium selenium() { // synchronized (this) { // if (selenium == null) { // selenium = defaultSelenium(); // } // } // return selenium; // } // // public SeleniumConfiguration useSelenium(Selenium selenium){ // this.selenium = selenium; // return this; // } // // public SeleniumContext seleniumContext() { // synchronized (this) { // if (seleniumContext == null) { // seleniumContext = new SeleniumContext(); // } // } // return seleniumContext; // } // // public SeleniumConfiguration useSeleniumContext(SeleniumContext seleniumContext) { // this.seleniumContext = seleniumContext; // return this; // } // // public WebDriverProvider webDriverProvider() { // return driverProvider; // } // // public SeleniumConfiguration useWebDriverProvider(WebDriverProvider webDriverProvider){ // this.driverProvider = webDriverProvider; // return this; // } // // /** // * Creates default Selenium instance: {@link DefaultSelenium("localhost", // * 4444, "*firefox", "http://localhost:8080")} // * // * @return A Selenium instance // */ // public static Selenium defaultSelenium() { // return new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080"); // } // // /** // * Creates default ConditionRunner: {@link JUnitConditionRunner(selenium, // * 10, 100, 1000)}. // * // * @param selenium // * the Selenium instance // * @return A ConditionRunner // */ // public static ConditionRunner defaultConditionRunner(Selenium selenium) { // return new JUnitConditionRunner(selenium, 10, 100, 1000); // } // // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // }
import java.util.List; import org.jbehave.core.Embeddable; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.io.LoadFromClasspath; import org.jbehave.core.io.StoryFinder; import org.jbehave.core.junit.JUnitStories; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.steps.InjectableStepsFactory; import org.jbehave.core.steps.InstanceStepsFactory; import ${package}.pages.Colors; import ${package}.steps.ColorSteps; import org.jbehave.web.selenium.FlashWebDriverProvider; import org.jbehave.web.selenium.PerStoryWebDriverSteps; import org.jbehave.web.selenium.SeleniumConfiguration; import org.jbehave.web.selenium.WebDriverProvider; import org.openqa.selenium.firefox.FirefoxDriver; import static java.util.Arrays.asList; import static org.jbehave.core.io.CodeLocations.codeLocationFromClass; import static org.jbehave.core.reporters.Format.CONSOLE; import static org.jbehave.core.reporters.Format.HTML; import static org.jbehave.core.reporters.Format.TXT; import static org.jbehave.core.reporters.Format.XML;
#set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}; public class FlashStories extends JUnitStories { private WebDriverProvider driverProvider = new FlashWebDriverProvider("coloredSquare", new FirefoxDriver()); private Colors colorsPage = new Colors(driverProvider); @Override public Configuration configuration() { Class<? extends Embeddable> embeddableClass = this.getClass();
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashWebDriverProvider.java // public class FlashWebDriverProvider extends DelegatingWebDriverProvider { // // private String flashObjectId; // private WebDriver javascriptDriver; // // public FlashWebDriverProvider(String flashObjectId, WebDriver javascriptDriver) { // this.flashObjectId = flashObjectId; // this.javascriptDriver = javascriptDriver; // } // // public void initialize() { // delegate.set(new FlashDriver(javascriptDriver, flashObjectId)); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/PerStoryWebDriverSteps.java // public class PerStoryWebDriverSteps extends WebDriverSteps { // // public PerStoryWebDriverSteps(WebDriverProvider driverProvider) { // super(driverProvider); // } // // @BeforeStory // public void beforeStory() throws Exception { // driverProvider.initialize(); // } // // @AfterStory // public void afterStory() throws Exception { // driverProvider.end(); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SeleniumConfiguration.java // public class SeleniumConfiguration extends Configuration { // // private Selenium selenium; // private SeleniumContext seleniumContext; // private WebDriverProvider driverProvider; // // public SeleniumConfiguration() { // } // // public Selenium selenium() { // synchronized (this) { // if (selenium == null) { // selenium = defaultSelenium(); // } // } // return selenium; // } // // public SeleniumConfiguration useSelenium(Selenium selenium){ // this.selenium = selenium; // return this; // } // // public SeleniumContext seleniumContext() { // synchronized (this) { // if (seleniumContext == null) { // seleniumContext = new SeleniumContext(); // } // } // return seleniumContext; // } // // public SeleniumConfiguration useSeleniumContext(SeleniumContext seleniumContext) { // this.seleniumContext = seleniumContext; // return this; // } // // public WebDriverProvider webDriverProvider() { // return driverProvider; // } // // public SeleniumConfiguration useWebDriverProvider(WebDriverProvider webDriverProvider){ // this.driverProvider = webDriverProvider; // return this; // } // // /** // * Creates default Selenium instance: {@link DefaultSelenium("localhost", // * 4444, "*firefox", "http://localhost:8080")} // * // * @return A Selenium instance // */ // public static Selenium defaultSelenium() { // return new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080"); // } // // /** // * Creates default ConditionRunner: {@link JUnitConditionRunner(selenium, // * 10, 100, 1000)}. // * // * @param selenium // * the Selenium instance // * @return A ConditionRunner // */ // public static ConditionRunner defaultConditionRunner(Selenium selenium) { // return new JUnitConditionRunner(selenium, 10, 100, 1000); // } // // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // } // Path: archetypes/web-selenium-flash-archetype/src/main/resources/archetype-resources/src/main/java/FlashStories.java import java.util.List; import org.jbehave.core.Embeddable; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.io.LoadFromClasspath; import org.jbehave.core.io.StoryFinder; import org.jbehave.core.junit.JUnitStories; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.steps.InjectableStepsFactory; import org.jbehave.core.steps.InstanceStepsFactory; import ${package}.pages.Colors; import ${package}.steps.ColorSteps; import org.jbehave.web.selenium.FlashWebDriverProvider; import org.jbehave.web.selenium.PerStoryWebDriverSteps; import org.jbehave.web.selenium.SeleniumConfiguration; import org.jbehave.web.selenium.WebDriverProvider; import org.openqa.selenium.firefox.FirefoxDriver; import static java.util.Arrays.asList; import static org.jbehave.core.io.CodeLocations.codeLocationFromClass; import static org.jbehave.core.reporters.Format.CONSOLE; import static org.jbehave.core.reporters.Format.HTML; import static org.jbehave.core.reporters.Format.TXT; import static org.jbehave.core.reporters.Format.XML; #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}; public class FlashStories extends JUnitStories { private WebDriverProvider driverProvider = new FlashWebDriverProvider("coloredSquare", new FirefoxDriver()); private Colors colorsPage = new Colors(driverProvider); @Override public Configuration configuration() { Class<? extends Embeddable> embeddableClass = this.getClass();
return new SeleniumConfiguration()
jbehave/jbehave-web
archetypes/web-selenium-flash-archetype/src/main/resources/archetype-resources/src/main/java/FlashStories.java
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashWebDriverProvider.java // public class FlashWebDriverProvider extends DelegatingWebDriverProvider { // // private String flashObjectId; // private WebDriver javascriptDriver; // // public FlashWebDriverProvider(String flashObjectId, WebDriver javascriptDriver) { // this.flashObjectId = flashObjectId; // this.javascriptDriver = javascriptDriver; // } // // public void initialize() { // delegate.set(new FlashDriver(javascriptDriver, flashObjectId)); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/PerStoryWebDriverSteps.java // public class PerStoryWebDriverSteps extends WebDriverSteps { // // public PerStoryWebDriverSteps(WebDriverProvider driverProvider) { // super(driverProvider); // } // // @BeforeStory // public void beforeStory() throws Exception { // driverProvider.initialize(); // } // // @AfterStory // public void afterStory() throws Exception { // driverProvider.end(); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SeleniumConfiguration.java // public class SeleniumConfiguration extends Configuration { // // private Selenium selenium; // private SeleniumContext seleniumContext; // private WebDriverProvider driverProvider; // // public SeleniumConfiguration() { // } // // public Selenium selenium() { // synchronized (this) { // if (selenium == null) { // selenium = defaultSelenium(); // } // } // return selenium; // } // // public SeleniumConfiguration useSelenium(Selenium selenium){ // this.selenium = selenium; // return this; // } // // public SeleniumContext seleniumContext() { // synchronized (this) { // if (seleniumContext == null) { // seleniumContext = new SeleniumContext(); // } // } // return seleniumContext; // } // // public SeleniumConfiguration useSeleniumContext(SeleniumContext seleniumContext) { // this.seleniumContext = seleniumContext; // return this; // } // // public WebDriverProvider webDriverProvider() { // return driverProvider; // } // // public SeleniumConfiguration useWebDriverProvider(WebDriverProvider webDriverProvider){ // this.driverProvider = webDriverProvider; // return this; // } // // /** // * Creates default Selenium instance: {@link DefaultSelenium("localhost", // * 4444, "*firefox", "http://localhost:8080")} // * // * @return A Selenium instance // */ // public static Selenium defaultSelenium() { // return new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080"); // } // // /** // * Creates default ConditionRunner: {@link JUnitConditionRunner(selenium, // * 10, 100, 1000)}. // * // * @param selenium // * the Selenium instance // * @return A ConditionRunner // */ // public static ConditionRunner defaultConditionRunner(Selenium selenium) { // return new JUnitConditionRunner(selenium, 10, 100, 1000); // } // // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // }
import java.util.List; import org.jbehave.core.Embeddable; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.io.LoadFromClasspath; import org.jbehave.core.io.StoryFinder; import org.jbehave.core.junit.JUnitStories; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.steps.InjectableStepsFactory; import org.jbehave.core.steps.InstanceStepsFactory; import ${package}.pages.Colors; import ${package}.steps.ColorSteps; import org.jbehave.web.selenium.FlashWebDriverProvider; import org.jbehave.web.selenium.PerStoryWebDriverSteps; import org.jbehave.web.selenium.SeleniumConfiguration; import org.jbehave.web.selenium.WebDriverProvider; import org.openqa.selenium.firefox.FirefoxDriver; import static java.util.Arrays.asList; import static org.jbehave.core.io.CodeLocations.codeLocationFromClass; import static org.jbehave.core.reporters.Format.CONSOLE; import static org.jbehave.core.reporters.Format.HTML; import static org.jbehave.core.reporters.Format.TXT; import static org.jbehave.core.reporters.Format.XML;
#set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}; public class FlashStories extends JUnitStories { private WebDriverProvider driverProvider = new FlashWebDriverProvider("coloredSquare", new FirefoxDriver()); private Colors colorsPage = new Colors(driverProvider); @Override public Configuration configuration() { Class<? extends Embeddable> embeddableClass = this.getClass(); return new SeleniumConfiguration() .useWebDriverProvider(driverProvider) .useStoryLoader(new LoadFromClasspath(embeddableClass)) .useStoryReporterBuilder( new StoryReporterBuilder().withCodeLocation(codeLocationFromClass(embeddableClass)) .withDefaultFormats().withFormats(CONSOLE, TXT, HTML, XML)); } @Override public InjectableStepsFactory stepsFactory() {
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashWebDriverProvider.java // public class FlashWebDriverProvider extends DelegatingWebDriverProvider { // // private String flashObjectId; // private WebDriver javascriptDriver; // // public FlashWebDriverProvider(String flashObjectId, WebDriver javascriptDriver) { // this.flashObjectId = flashObjectId; // this.javascriptDriver = javascriptDriver; // } // // public void initialize() { // delegate.set(new FlashDriver(javascriptDriver, flashObjectId)); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/PerStoryWebDriverSteps.java // public class PerStoryWebDriverSteps extends WebDriverSteps { // // public PerStoryWebDriverSteps(WebDriverProvider driverProvider) { // super(driverProvider); // } // // @BeforeStory // public void beforeStory() throws Exception { // driverProvider.initialize(); // } // // @AfterStory // public void afterStory() throws Exception { // driverProvider.end(); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/SeleniumConfiguration.java // public class SeleniumConfiguration extends Configuration { // // private Selenium selenium; // private SeleniumContext seleniumContext; // private WebDriverProvider driverProvider; // // public SeleniumConfiguration() { // } // // public Selenium selenium() { // synchronized (this) { // if (selenium == null) { // selenium = defaultSelenium(); // } // } // return selenium; // } // // public SeleniumConfiguration useSelenium(Selenium selenium){ // this.selenium = selenium; // return this; // } // // public SeleniumContext seleniumContext() { // synchronized (this) { // if (seleniumContext == null) { // seleniumContext = new SeleniumContext(); // } // } // return seleniumContext; // } // // public SeleniumConfiguration useSeleniumContext(SeleniumContext seleniumContext) { // this.seleniumContext = seleniumContext; // return this; // } // // public WebDriverProvider webDriverProvider() { // return driverProvider; // } // // public SeleniumConfiguration useWebDriverProvider(WebDriverProvider webDriverProvider){ // this.driverProvider = webDriverProvider; // return this; // } // // /** // * Creates default Selenium instance: {@link DefaultSelenium("localhost", // * 4444, "*firefox", "http://localhost:8080")} // * // * @return A Selenium instance // */ // public static Selenium defaultSelenium() { // return new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080"); // } // // /** // * Creates default ConditionRunner: {@link JUnitConditionRunner(selenium, // * 10, 100, 1000)}. // * // * @param selenium // * the Selenium instance // * @return A ConditionRunner // */ // public static ConditionRunner defaultConditionRunner(Selenium selenium) { // return new JUnitConditionRunner(selenium, 10, 100, 1000); // } // // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // } // Path: archetypes/web-selenium-flash-archetype/src/main/resources/archetype-resources/src/main/java/FlashStories.java import java.util.List; import org.jbehave.core.Embeddable; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.io.LoadFromClasspath; import org.jbehave.core.io.StoryFinder; import org.jbehave.core.junit.JUnitStories; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.steps.InjectableStepsFactory; import org.jbehave.core.steps.InstanceStepsFactory; import ${package}.pages.Colors; import ${package}.steps.ColorSteps; import org.jbehave.web.selenium.FlashWebDriverProvider; import org.jbehave.web.selenium.PerStoryWebDriverSteps; import org.jbehave.web.selenium.SeleniumConfiguration; import org.jbehave.web.selenium.WebDriverProvider; import org.openqa.selenium.firefox.FirefoxDriver; import static java.util.Arrays.asList; import static org.jbehave.core.io.CodeLocations.codeLocationFromClass; import static org.jbehave.core.reporters.Format.CONSOLE; import static org.jbehave.core.reporters.Format.HTML; import static org.jbehave.core.reporters.Format.TXT; import static org.jbehave.core.reporters.Format.XML; #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}; public class FlashStories extends JUnitStories { private WebDriverProvider driverProvider = new FlashWebDriverProvider("coloredSquare", new FirefoxDriver()); private Colors colorsPage = new Colors(driverProvider); @Override public Configuration configuration() { Class<? extends Embeddable> embeddableClass = this.getClass(); return new SeleniumConfiguration() .useWebDriverProvider(driverProvider) .useStoryLoader(new LoadFromClasspath(embeddableClass)) .useStoryReporterBuilder( new StoryReporterBuilder().withCodeLocation(codeLocationFromClass(embeddableClass)) .withDefaultFormats().withFormats(CONSOLE, TXT, HTML, XML)); } @Override public InjectableStepsFactory stepsFactory() {
return new InstanceStepsFactory(configuration(), new ColorSteps(colorsPage), new PerStoryWebDriverSteps(
jbehave/jbehave-web
web-runner/src/main/java/org/jbehave/web/runner/wicket/pages/RunResource.java
// Path: web-runner/src/main/java/org/jbehave/web/runner/context/StoryContext.java // @SuppressWarnings("serial") // public class StoryContext implements Serializable { // // private static final String EMPTY = ""; // private String input = EMPTY; // private String metaFilter = EMPTY; // private String output = EMPTY; // private List<String> messages = new ArrayList<String>(); // private Throwable cause = null; // // public StoryContext(){ // } // // public String getInput() { // return input; // } // // public void setInput(String input) { // this.input = input; // } // // public String getMetaFilter() { // return metaFilter; // } // // public void setMetaFilter(String metaFilter) { // this.metaFilter = metaFilter; // } // // public String getOutput() { // return output; // } // // public void setOutput(String output) { // this.output = output; // } // // public List<String> getFailureMessages() { // messages.clear(); // addFailureMessage(cause); // return messages; // } // // private void addFailureMessage(Throwable cause) { // if ( cause != null ){ // if ( cause.getMessage() != null ){ // messages.add(cause.getMessage()); // } // // recurse // addFailureMessage(cause.getCause()); // } // } // // public void clearFailureCause() { // this.cause = null; // } // // public void runFailedFor(Throwable cause) { // this.cause = cause; // } // // public String getFailureStackTrace() { // StringWriter writer = new StringWriter(); // if (cause != null) { // cause.printStackTrace(new PrintWriter(writer)); // } // return writer.getBuffer().toString(); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // // // }
import static java.util.Arrays.asList; import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.io.OutputStream; import java.io.PrintStream; import java.util.Properties; import org.apache.wicket.markup.html.basic.MultiLineLabel; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.jbehave.core.configuration.Keywords; import org.jbehave.core.embedder.Embedder; import org.jbehave.core.embedder.PerformableTree; import org.jbehave.core.embedder.StoryManager; import org.jbehave.core.failures.BatchFailures; import org.jbehave.core.io.ResourceLoader; import org.jbehave.core.model.Story; import org.jbehave.core.reporters.StoryReporter; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.reporters.TxtOutput; import org.jbehave.web.runner.context.StoryContext; import org.jbehave.web.runner.context.StoryOutputStream; import com.google.inject.Inject;
package org.jbehave.web.runner.wicket.pages; @SuppressWarnings("serial") public class RunResource extends Template { @Inject private ResourceLoader loader; @Inject private Embedder embedder; private StoryManager storyManager; private StoryOutputStream outputStream = new StoryOutputStream();
// Path: web-runner/src/main/java/org/jbehave/web/runner/context/StoryContext.java // @SuppressWarnings("serial") // public class StoryContext implements Serializable { // // private static final String EMPTY = ""; // private String input = EMPTY; // private String metaFilter = EMPTY; // private String output = EMPTY; // private List<String> messages = new ArrayList<String>(); // private Throwable cause = null; // // public StoryContext(){ // } // // public String getInput() { // return input; // } // // public void setInput(String input) { // this.input = input; // } // // public String getMetaFilter() { // return metaFilter; // } // // public void setMetaFilter(String metaFilter) { // this.metaFilter = metaFilter; // } // // public String getOutput() { // return output; // } // // public void setOutput(String output) { // this.output = output; // } // // public List<String> getFailureMessages() { // messages.clear(); // addFailureMessage(cause); // return messages; // } // // private void addFailureMessage(Throwable cause) { // if ( cause != null ){ // if ( cause.getMessage() != null ){ // messages.add(cause.getMessage()); // } // // recurse // addFailureMessage(cause.getCause()); // } // } // // public void clearFailureCause() { // this.cause = null; // } // // public void runFailedFor(Throwable cause) { // this.cause = cause; // } // // public String getFailureStackTrace() { // StringWriter writer = new StringWriter(); // if (cause != null) { // cause.printStackTrace(new PrintWriter(writer)); // } // return writer.getBuffer().toString(); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // // // } // Path: web-runner/src/main/java/org/jbehave/web/runner/wicket/pages/RunResource.java import static java.util.Arrays.asList; import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.io.OutputStream; import java.io.PrintStream; import java.util.Properties; import org.apache.wicket.markup.html.basic.MultiLineLabel; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.jbehave.core.configuration.Keywords; import org.jbehave.core.embedder.Embedder; import org.jbehave.core.embedder.PerformableTree; import org.jbehave.core.embedder.StoryManager; import org.jbehave.core.failures.BatchFailures; import org.jbehave.core.io.ResourceLoader; import org.jbehave.core.model.Story; import org.jbehave.core.reporters.StoryReporter; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.reporters.TxtOutput; import org.jbehave.web.runner.context.StoryContext; import org.jbehave.web.runner.context.StoryOutputStream; import com.google.inject.Inject; package org.jbehave.web.runner.wicket.pages; @SuppressWarnings("serial") public class RunResource extends Template { @Inject private ResourceLoader loader; @Inject private Embedder embedder; private StoryManager storyManager; private StoryOutputStream outputStream = new StoryOutputStream();
private StoryContext storyContext = new StoryContext();
jbehave/jbehave-web
web-runner/src/main/java/org/jbehave/web/runner/context/WikiContext.java
// Path: web-runner/src/main/java/org/jbehave/web/runner/wicket/tree/TreeResource.java // @SuppressWarnings("serial") // public class TreeResource implements Serializable { // // private String name; // private String parentName; // private String uri; // private TreeResource parent; // private List<TreeResource> children = new ArrayList<TreeResource>(); // // public TreeResource(Resource resource) { // this.name = resource.getName(); // this.parentName = resource.getParentName(); // this.uri = resource.getURI(); // } // // public TreeResource getParent() { // return parent; // } // // public void setParent(TreeResource parent) { // this.parent = parent; // this.parent.children.add(this); // } // // public List<TreeResource> getChildren() { // return children; // } // // public String getName() { // return name; // } // // public String getParentName() { // return parentName; // } // // public String getUri() { // return uri; // } // // @Override // public String toString() { // return name; // } // // }
import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.ToStringBuilder; import org.jbehave.core.io.rest.Resource; import org.jbehave.web.runner.wicket.tree.TreeResource;
package org.jbehave.web.runner.context; @SuppressWarnings("serial") public class WikiContext implements Serializable { private String uri; private List<SerializableResource> resources;
// Path: web-runner/src/main/java/org/jbehave/web/runner/wicket/tree/TreeResource.java // @SuppressWarnings("serial") // public class TreeResource implements Serializable { // // private String name; // private String parentName; // private String uri; // private TreeResource parent; // private List<TreeResource> children = new ArrayList<TreeResource>(); // // public TreeResource(Resource resource) { // this.name = resource.getName(); // this.parentName = resource.getParentName(); // this.uri = resource.getURI(); // } // // public TreeResource getParent() { // return parent; // } // // public void setParent(TreeResource parent) { // this.parent = parent; // this.parent.children.add(this); // } // // public List<TreeResource> getChildren() { // return children; // } // // public String getName() { // return name; // } // // public String getParentName() { // return parentName; // } // // public String getUri() { // return uri; // } // // @Override // public String toString() { // return name; // } // // } // Path: web-runner/src/main/java/org/jbehave/web/runner/context/WikiContext.java import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.ToStringBuilder; import org.jbehave.core.io.rest.Resource; import org.jbehave.web.runner.wicket.tree.TreeResource; package org.jbehave.web.runner.context; @SuppressWarnings("serial") public class WikiContext implements Serializable { private String uri; private List<SerializableResource> resources;
private List<TreeResource> treeRoots = new ArrayList<TreeResource>();
jbehave/jbehave-web
archetypes/web-selenium-java-spring-archetype/src/main/resources/archetype-resources/src/main/java/etsy/steps/JournaledStoriesSteps.java
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // }
import org.jbehave.core.annotations.AfterStories; import org.jbehave.core.annotations.BeforeStories; import org.jbehave.web.selenium.FirefoxWebDriverProvider; import org.jbehave.web.selenium.PerStoriesWebDriverSteps; import org.jbehave.web.selenium.WebDriverProvider; import org.openqa.selenium.WebDriver; import org.springframework.beans.factory.annotation.Autowired;
#set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}.etsy.steps; public class JournaledStoriesSteps { private static final String JOURNAL_FIREFOX_COMMANDS = System.getProperty("JOURNAL_FIREFOX_COMMANDS", "false");
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // } // Path: archetypes/web-selenium-java-spring-archetype/src/main/resources/archetype-resources/src/main/java/etsy/steps/JournaledStoriesSteps.java import org.jbehave.core.annotations.AfterStories; import org.jbehave.core.annotations.BeforeStories; import org.jbehave.web.selenium.FirefoxWebDriverProvider; import org.jbehave.web.selenium.PerStoriesWebDriverSteps; import org.jbehave.web.selenium.WebDriverProvider; import org.openqa.selenium.WebDriver; import org.springframework.beans.factory.annotation.Autowired; #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}.etsy.steps; public class JournaledStoriesSteps { private static final String JOURNAL_FIREFOX_COMMANDS = System.getProperty("JOURNAL_FIREFOX_COMMANDS", "false");
private final WebDriverProvider webDriverProvider;
jbehave/jbehave-web
archetypes/web-selenium-java-spring-archetype/src/main/resources/archetype-resources/src/main/java/steps/LifecycleSteps.java
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // }
import org.jbehave.core.annotations.BeforeScenario; import org.jbehave.web.selenium.WebDriverProvider; import org.openqa.selenium.WebDriverException;
#set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}.steps; public class LifecycleSteps {
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/WebDriverProvider.java // public interface WebDriverProvider { // // WebDriver get(); // // void initialize(); // // boolean saveScreenshotTo(String path); // // void end(); // } // Path: archetypes/web-selenium-java-spring-archetype/src/main/resources/archetype-resources/src/main/java/steps/LifecycleSteps.java import org.jbehave.core.annotations.BeforeScenario; import org.jbehave.web.selenium.WebDriverProvider; import org.openqa.selenium.WebDriverException; #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}.steps; public class LifecycleSteps {
private final WebDriverProvider webDriverProvider;
jbehave/jbehave-web
web-selenium/src/test/java/org/jbehave/web/selenium/FlashDriverTest.java
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashDriver.java // @SuppressWarnings("serial") // public static class JavascriptNotSupported extends RuntimeException { // // public JavascriptNotSupported(WebDriver delegate) { // super("Javascript not supported by WebDriver "+delegate); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashPage.java // @SuppressWarnings("serial") // public static class FlashNotSupported extends RuntimeException { // // public FlashNotSupported(WebDriver driver) { // super("Flash not supported by WebDriver "+driver); // } // // }
import org.jbehave.web.selenium.FlashDriver.JavascriptNotSupported; import org.jbehave.web.selenium.FlashPage.FlashNotSupported; import org.junit.Test; import org.mockito.Mockito; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.notNullValue; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when;
package org.jbehave.web.selenium; public class FlashDriverTest { @Test public void shouldExecuteJavascriptMethodsOnFlashObject() { FirefoxDriver delegate = Mockito.mock(FirefoxDriver.class); FlashDriver driver = new FlashDriver(delegate, "flashObjectId"); driver.click(); verify(delegate).executeScript("return arguments[0].click();", (Object[]) null); when(delegate.executeScript("return arguments[0].PercentLoaded();", (Object[]) null)).thenReturn("100"); assertThat(driver.percentLoaded(), equalTo(100)); verify(delegate).executeScript("return arguments[0].PercentLoaded();", (Object[]) null); }
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashDriver.java // @SuppressWarnings("serial") // public static class JavascriptNotSupported extends RuntimeException { // // public JavascriptNotSupported(WebDriver delegate) { // super("Javascript not supported by WebDriver "+delegate); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashPage.java // @SuppressWarnings("serial") // public static class FlashNotSupported extends RuntimeException { // // public FlashNotSupported(WebDriver driver) { // super("Flash not supported by WebDriver "+driver); // } // // } // Path: web-selenium/src/test/java/org/jbehave/web/selenium/FlashDriverTest.java import org.jbehave.web.selenium.FlashDriver.JavascriptNotSupported; import org.jbehave.web.selenium.FlashPage.FlashNotSupported; import org.junit.Test; import org.mockito.Mockito; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.notNullValue; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; package org.jbehave.web.selenium; public class FlashDriverTest { @Test public void shouldExecuteJavascriptMethodsOnFlashObject() { FirefoxDriver delegate = Mockito.mock(FirefoxDriver.class); FlashDriver driver = new FlashDriver(delegate, "flashObjectId"); driver.click(); verify(delegate).executeScript("return arguments[0].click();", (Object[]) null); when(delegate.executeScript("return arguments[0].PercentLoaded();", (Object[]) null)).thenReturn("100"); assertThat(driver.percentLoaded(), equalTo(100)); verify(delegate).executeScript("return arguments[0].PercentLoaded();", (Object[]) null); }
@Test(expected = JavascriptNotSupported.class)
jbehave/jbehave-web
web-selenium/src/test/java/org/jbehave/web/selenium/FlashDriverTest.java
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashDriver.java // @SuppressWarnings("serial") // public static class JavascriptNotSupported extends RuntimeException { // // public JavascriptNotSupported(WebDriver delegate) { // super("Javascript not supported by WebDriver "+delegate); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashPage.java // @SuppressWarnings("serial") // public static class FlashNotSupported extends RuntimeException { // // public FlashNotSupported(WebDriver driver) { // super("Flash not supported by WebDriver "+driver); // } // // }
import org.jbehave.web.selenium.FlashDriver.JavascriptNotSupported; import org.jbehave.web.selenium.FlashPage.FlashNotSupported; import org.junit.Test; import org.mockito.Mockito; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.notNullValue; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when;
package org.jbehave.web.selenium; public class FlashDriverTest { @Test public void shouldExecuteJavascriptMethodsOnFlashObject() { FirefoxDriver delegate = Mockito.mock(FirefoxDriver.class); FlashDriver driver = new FlashDriver(delegate, "flashObjectId"); driver.click(); verify(delegate).executeScript("return arguments[0].click();", (Object[]) null); when(delegate.executeScript("return arguments[0].PercentLoaded();", (Object[]) null)).thenReturn("100"); assertThat(driver.percentLoaded(), equalTo(100)); verify(delegate).executeScript("return arguments[0].PercentLoaded();", (Object[]) null); } @Test(expected = JavascriptNotSupported.class) public void shouldThrowAnExceptionIfWebDriverIsNotAJavascriptExecutor() { WebDriver delegate = Mockito.mock(WebDriver.class); FlashDriver driver = new FlashDriver(delegate, "flashObjectId"); driver.click(); } @Test public void shouldProvideFlashDriver() { FlashWebDriverProvider provider = new FlashWebDriverProvider("flashObjectId", new FirefoxDriver()); provider.initialize(); assertThat(provider.get(), instanceOf(FlashDriver.class)); FlashPage page = new FlashPage(provider) { }; assertThat(page.flashDriver(), notNullValue()); provider.get().quit(); }
// Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashDriver.java // @SuppressWarnings("serial") // public static class JavascriptNotSupported extends RuntimeException { // // public JavascriptNotSupported(WebDriver delegate) { // super("Javascript not supported by WebDriver "+delegate); // } // // } // // Path: web-selenium/src/main/java/org/jbehave/web/selenium/FlashPage.java // @SuppressWarnings("serial") // public static class FlashNotSupported extends RuntimeException { // // public FlashNotSupported(WebDriver driver) { // super("Flash not supported by WebDriver "+driver); // } // // } // Path: web-selenium/src/test/java/org/jbehave/web/selenium/FlashDriverTest.java import org.jbehave.web.selenium.FlashDriver.JavascriptNotSupported; import org.jbehave.web.selenium.FlashPage.FlashNotSupported; import org.junit.Test; import org.mockito.Mockito; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.notNullValue; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; package org.jbehave.web.selenium; public class FlashDriverTest { @Test public void shouldExecuteJavascriptMethodsOnFlashObject() { FirefoxDriver delegate = Mockito.mock(FirefoxDriver.class); FlashDriver driver = new FlashDriver(delegate, "flashObjectId"); driver.click(); verify(delegate).executeScript("return arguments[0].click();", (Object[]) null); when(delegate.executeScript("return arguments[0].PercentLoaded();", (Object[]) null)).thenReturn("100"); assertThat(driver.percentLoaded(), equalTo(100)); verify(delegate).executeScript("return arguments[0].PercentLoaded();", (Object[]) null); } @Test(expected = JavascriptNotSupported.class) public void shouldThrowAnExceptionIfWebDriverIsNotAJavascriptExecutor() { WebDriver delegate = Mockito.mock(WebDriver.class); FlashDriver driver = new FlashDriver(delegate, "flashObjectId"); driver.click(); } @Test public void shouldProvideFlashDriver() { FlashWebDriverProvider provider = new FlashWebDriverProvider("flashObjectId", new FirefoxDriver()); provider.initialize(); assertThat(provider.get(), instanceOf(FlashDriver.class)); FlashPage page = new FlashPage(provider) { }; assertThat(page.flashDriver(), notNullValue()); provider.get().quit(); }
@Test(expected = FlashNotSupported.class)
GoogleCloudPlatform/gcs-uploader
app-desktop/src/main/java/com/google/ce/media/contentuploader/exec/CompositeUploadTask.java
// Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/utils/DateUtils.java // public class DateUtils { // private static DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC(); // // public static String now() { // return formatter.print(System.currentTimeMillis()); // } // // public static String time(long millis) { // return formatter.print(millis); // } // }
import com.google.ce.media.contentuploader.message.*; import com.google.ce.media.contentuploader.utils.DateUtils; import com.google.cloud.storage.BlobInfo; import org.apache.commons.codec.digest.PureJavaCrc32C; import org.springframework.context.ApplicationEventPublisher; import java.io.FileInputStream; import java.nio.ByteBuffer; import java.security.NoSuchAlgorithmException; import java.util.HashMap; import java.util.Map;
/* * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.google.ce.media.contentuploader.exec; /** * Created in gcs-uploader on 2020-01-23. */ public class CompositeUploadTask implements Runnable { private final TaskInfo taskInfo; private final UploadTaskPool uploadTaskPool; // private final Hasher md5HasherTotal = md5Digest.newHasher(); // private final Hasher crcHasherTotal = crcDigest.newHasher(); private final PureJavaCrc32C crc32C = new PureJavaCrc32C(); public CompositeUploadTask(TaskInfo taskInfo, UploadTaskPool uploadTaskPool, ApplicationEventPublisher applicationEventPublisher) throws NoSuchAlgorithmException { this.taskInfo = taskInfo; this.uploadTaskPool = uploadTaskPool; } @Override public void run() { if (taskInfo.getStatus() != TaskStatus.WAITING && taskInfo.getStatus() != TaskStatus.QUEUED) { return; } try { Long startTime = System.currentTimeMillis(); taskInfo.setStatus(TaskStatus.RUNNING); taskInfo.setStartTime(startTime); AnalyticsMessage m1 = AnalyticsMessage.from(taskInfo, AnalyticsMessage.Event.COMPOSITE_FILE_START, "Started Composite Upload");
// Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/utils/DateUtils.java // public class DateUtils { // private static DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC(); // // public static String now() { // return formatter.print(System.currentTimeMillis()); // } // // public static String time(long millis) { // return formatter.print(millis); // } // } // Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/exec/CompositeUploadTask.java import com.google.ce.media.contentuploader.message.*; import com.google.ce.media.contentuploader.utils.DateUtils; import com.google.cloud.storage.BlobInfo; import org.apache.commons.codec.digest.PureJavaCrc32C; import org.springframework.context.ApplicationEventPublisher; import java.io.FileInputStream; import java.nio.ByteBuffer; import java.security.NoSuchAlgorithmException; import java.util.HashMap; import java.util.Map; /* * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.google.ce.media.contentuploader.exec; /** * Created in gcs-uploader on 2020-01-23. */ public class CompositeUploadTask implements Runnable { private final TaskInfo taskInfo; private final UploadTaskPool uploadTaskPool; // private final Hasher md5HasherTotal = md5Digest.newHasher(); // private final Hasher crcHasherTotal = crcDigest.newHasher(); private final PureJavaCrc32C crc32C = new PureJavaCrc32C(); public CompositeUploadTask(TaskInfo taskInfo, UploadTaskPool uploadTaskPool, ApplicationEventPublisher applicationEventPublisher) throws NoSuchAlgorithmException { this.taskInfo = taskInfo; this.uploadTaskPool = uploadTaskPool; } @Override public void run() { if (taskInfo.getStatus() != TaskStatus.WAITING && taskInfo.getStatus() != TaskStatus.QUEUED) { return; } try { Long startTime = System.currentTimeMillis(); taskInfo.setStatus(TaskStatus.RUNNING); taskInfo.setStartTime(startTime); AnalyticsMessage m1 = AnalyticsMessage.from(taskInfo, AnalyticsMessage.Event.COMPOSITE_FILE_START, "Started Composite Upload");
m1.setStartTime(DateUtils.time(startTime));
GoogleCloudPlatform/gcs-uploader
app-desktop/src/main/java/com/google/ce/media/contentuploader/config/AuthConfig.java
// Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/message/AuthInfo.java // public class AuthInfo { // // private String bucket; // private String accessToken; // private String refreshToken; // // private String userId, name, email, pictureUrl; // // private Long issuedSeconds, expirationSeconds; // // private List<Destination> destinations; // // private List<Destination> authorizedDestinations; // // private String analyticsEndpoint; // // private String analyticsUsername, analyticsPassword; // // public String getBucket() { // return bucket; // } // // public void setBucket(String bucket) { // this.bucket = bucket; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // // public String getUserId() { // return userId; // } // // public void setUserId(String userId) { // this.userId = userId; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getPictureUrl() { // return pictureUrl; // } // // public void setPictureUrl(String pictureUrl) { // this.pictureUrl = pictureUrl; // } // // public Long getIssuedSeconds() { // return issuedSeconds; // } // // public void setIssuedSeconds(Long issuedSeconds) { // this.issuedSeconds = issuedSeconds; // } // // public Long getExpirationSeconds() { // return expirationSeconds; // } // // public void setExpirationSeconds(Long expirationSeconds) { // this.expirationSeconds = expirationSeconds; // } // // public List<Destination> getDestinations() { // return destinations; // } // // public void setDestinations(List<Destination> destinations) { // this.destinations = destinations; // } // // public String getAnalyticsEndpoint() { // return analyticsEndpoint; // } // // public void setAnalyticsEndpoint(String analyticsEndpoint) { // this.analyticsEndpoint = analyticsEndpoint; // } // // public String getAnalyticsUsername() { // return analyticsUsername; // } // // public void setAnalyticsUsername(String analyticsUsername) { // this.analyticsUsername = analyticsUsername; // } // // public String getAnalyticsPassword() { // return analyticsPassword; // } // // public void setAnalyticsPassword(String analyticsPassword) { // this.analyticsPassword = analyticsPassword; // } // // public List<Destination> getAuthorizedDestinations() { // return authorizedDestinations; // } // // public void setAuthorizedDestinations(List<Destination> authorizedDestinations) { // this.authorizedDestinations = authorizedDestinations; // } // } // // Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/message/Destination.java // public class Destination { // private String gcsBucket; // private String gcsFolder; // private String displayName; // // private Destination() { // } // // public Destination(String gcsBucket, String gcsFolder, String displayName) { // this.gcsBucket = gcsBucket; // this.gcsFolder = gcsFolder; // this.displayName = displayName; // } // // public String getGcsBucket() { // return gcsBucket; // } // // public String getGcsFolder() { // return gcsFolder; // } // // public String getDisplayName() { // return displayName; // } // // @Override // public String toString() { // return displayName; // } // }
import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.google.api.gax.paging.Page; import com.google.auth.oauth2.AccessToken; import com.google.auth.oauth2.GoogleCredentials; import com.google.ce.media.contentuploader.message.AuthInfo; import com.google.ce.media.contentuploader.message.Destination; import com.google.cloud.storage.Blob; import com.google.cloud.storage.Storage; import com.google.cloud.storage.StorageException; import com.google.cloud.storage.StorageOptions; import org.springframework.http.*; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate;
/* * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.google.ce.media.contentuploader.config; /** * Created in gcs-uploader on 2020-01-10. */ @Component public class AuthConfig { public static final long REFRESH_THRESHOLD_SECS = 60*10L; //10 minutes public static final Object REFRESH_LOCK = new Object(); private final EnvConfig envConfig;
// Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/message/AuthInfo.java // public class AuthInfo { // // private String bucket; // private String accessToken; // private String refreshToken; // // private String userId, name, email, pictureUrl; // // private Long issuedSeconds, expirationSeconds; // // private List<Destination> destinations; // // private List<Destination> authorizedDestinations; // // private String analyticsEndpoint; // // private String analyticsUsername, analyticsPassword; // // public String getBucket() { // return bucket; // } // // public void setBucket(String bucket) { // this.bucket = bucket; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // // public String getUserId() { // return userId; // } // // public void setUserId(String userId) { // this.userId = userId; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getPictureUrl() { // return pictureUrl; // } // // public void setPictureUrl(String pictureUrl) { // this.pictureUrl = pictureUrl; // } // // public Long getIssuedSeconds() { // return issuedSeconds; // } // // public void setIssuedSeconds(Long issuedSeconds) { // this.issuedSeconds = issuedSeconds; // } // // public Long getExpirationSeconds() { // return expirationSeconds; // } // // public void setExpirationSeconds(Long expirationSeconds) { // this.expirationSeconds = expirationSeconds; // } // // public List<Destination> getDestinations() { // return destinations; // } // // public void setDestinations(List<Destination> destinations) { // this.destinations = destinations; // } // // public String getAnalyticsEndpoint() { // return analyticsEndpoint; // } // // public void setAnalyticsEndpoint(String analyticsEndpoint) { // this.analyticsEndpoint = analyticsEndpoint; // } // // public String getAnalyticsUsername() { // return analyticsUsername; // } // // public void setAnalyticsUsername(String analyticsUsername) { // this.analyticsUsername = analyticsUsername; // } // // public String getAnalyticsPassword() { // return analyticsPassword; // } // // public void setAnalyticsPassword(String analyticsPassword) { // this.analyticsPassword = analyticsPassword; // } // // public List<Destination> getAuthorizedDestinations() { // return authorizedDestinations; // } // // public void setAuthorizedDestinations(List<Destination> authorizedDestinations) { // this.authorizedDestinations = authorizedDestinations; // } // } // // Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/message/Destination.java // public class Destination { // private String gcsBucket; // private String gcsFolder; // private String displayName; // // private Destination() { // } // // public Destination(String gcsBucket, String gcsFolder, String displayName) { // this.gcsBucket = gcsBucket; // this.gcsFolder = gcsFolder; // this.displayName = displayName; // } // // public String getGcsBucket() { // return gcsBucket; // } // // public String getGcsFolder() { // return gcsFolder; // } // // public String getDisplayName() { // return displayName; // } // // @Override // public String toString() { // return displayName; // } // } // Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/config/AuthConfig.java import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.google.api.gax.paging.Page; import com.google.auth.oauth2.AccessToken; import com.google.auth.oauth2.GoogleCredentials; import com.google.ce.media.contentuploader.message.AuthInfo; import com.google.ce.media.contentuploader.message.Destination; import com.google.cloud.storage.Blob; import com.google.cloud.storage.Storage; import com.google.cloud.storage.StorageException; import com.google.cloud.storage.StorageOptions; import org.springframework.http.*; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; /* * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.google.ce.media.contentuploader.config; /** * Created in gcs-uploader on 2020-01-10. */ @Component public class AuthConfig { public static final long REFRESH_THRESHOLD_SECS = 60*10L; //10 minutes public static final Object REFRESH_LOCK = new Object(); private final EnvConfig envConfig;
private AuthInfo authInfo;
GoogleCloudPlatform/gcs-uploader
app-desktop/src/main/java/com/google/ce/media/contentuploader/config/AuthConfig.java
// Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/message/AuthInfo.java // public class AuthInfo { // // private String bucket; // private String accessToken; // private String refreshToken; // // private String userId, name, email, pictureUrl; // // private Long issuedSeconds, expirationSeconds; // // private List<Destination> destinations; // // private List<Destination> authorizedDestinations; // // private String analyticsEndpoint; // // private String analyticsUsername, analyticsPassword; // // public String getBucket() { // return bucket; // } // // public void setBucket(String bucket) { // this.bucket = bucket; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // // public String getUserId() { // return userId; // } // // public void setUserId(String userId) { // this.userId = userId; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getPictureUrl() { // return pictureUrl; // } // // public void setPictureUrl(String pictureUrl) { // this.pictureUrl = pictureUrl; // } // // public Long getIssuedSeconds() { // return issuedSeconds; // } // // public void setIssuedSeconds(Long issuedSeconds) { // this.issuedSeconds = issuedSeconds; // } // // public Long getExpirationSeconds() { // return expirationSeconds; // } // // public void setExpirationSeconds(Long expirationSeconds) { // this.expirationSeconds = expirationSeconds; // } // // public List<Destination> getDestinations() { // return destinations; // } // // public void setDestinations(List<Destination> destinations) { // this.destinations = destinations; // } // // public String getAnalyticsEndpoint() { // return analyticsEndpoint; // } // // public void setAnalyticsEndpoint(String analyticsEndpoint) { // this.analyticsEndpoint = analyticsEndpoint; // } // // public String getAnalyticsUsername() { // return analyticsUsername; // } // // public void setAnalyticsUsername(String analyticsUsername) { // this.analyticsUsername = analyticsUsername; // } // // public String getAnalyticsPassword() { // return analyticsPassword; // } // // public void setAnalyticsPassword(String analyticsPassword) { // this.analyticsPassword = analyticsPassword; // } // // public List<Destination> getAuthorizedDestinations() { // return authorizedDestinations; // } // // public void setAuthorizedDestinations(List<Destination> authorizedDestinations) { // this.authorizedDestinations = authorizedDestinations; // } // } // // Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/message/Destination.java // public class Destination { // private String gcsBucket; // private String gcsFolder; // private String displayName; // // private Destination() { // } // // public Destination(String gcsBucket, String gcsFolder, String displayName) { // this.gcsBucket = gcsBucket; // this.gcsFolder = gcsFolder; // this.displayName = displayName; // } // // public String getGcsBucket() { // return gcsBucket; // } // // public String getGcsFolder() { // return gcsFolder; // } // // public String getDisplayName() { // return displayName; // } // // @Override // public String toString() { // return displayName; // } // }
import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.google.api.gax.paging.Page; import com.google.auth.oauth2.AccessToken; import com.google.auth.oauth2.GoogleCredentials; import com.google.ce.media.contentuploader.message.AuthInfo; import com.google.ce.media.contentuploader.message.Destination; import com.google.cloud.storage.Blob; import com.google.cloud.storage.Storage; import com.google.cloud.storage.StorageException; import com.google.cloud.storage.StorageOptions; import org.springframework.http.*; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate;
return authInfo; } public Storage getStorage() { synchronized (REFRESH_LOCK) { if((authInfo.getExpirationSeconds() - (System.currentTimeMillis()/1000L)) < REFRESH_THRESHOLD_SECS) { updateToken(null); } return storage; } } public AuthInfo getAuthInfo() { return authInfo; } private void buildStorage() { storage = StorageOptions .newBuilder() .setCredentials(credentials) .build() .getService(); } public interface AuthConfigListener { public void authInfoUpdated(); public void authInfoError(Exception e); } private void validateAuthorization() {
// Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/message/AuthInfo.java // public class AuthInfo { // // private String bucket; // private String accessToken; // private String refreshToken; // // private String userId, name, email, pictureUrl; // // private Long issuedSeconds, expirationSeconds; // // private List<Destination> destinations; // // private List<Destination> authorizedDestinations; // // private String analyticsEndpoint; // // private String analyticsUsername, analyticsPassword; // // public String getBucket() { // return bucket; // } // // public void setBucket(String bucket) { // this.bucket = bucket; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // // public String getUserId() { // return userId; // } // // public void setUserId(String userId) { // this.userId = userId; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getPictureUrl() { // return pictureUrl; // } // // public void setPictureUrl(String pictureUrl) { // this.pictureUrl = pictureUrl; // } // // public Long getIssuedSeconds() { // return issuedSeconds; // } // // public void setIssuedSeconds(Long issuedSeconds) { // this.issuedSeconds = issuedSeconds; // } // // public Long getExpirationSeconds() { // return expirationSeconds; // } // // public void setExpirationSeconds(Long expirationSeconds) { // this.expirationSeconds = expirationSeconds; // } // // public List<Destination> getDestinations() { // return destinations; // } // // public void setDestinations(List<Destination> destinations) { // this.destinations = destinations; // } // // public String getAnalyticsEndpoint() { // return analyticsEndpoint; // } // // public void setAnalyticsEndpoint(String analyticsEndpoint) { // this.analyticsEndpoint = analyticsEndpoint; // } // // public String getAnalyticsUsername() { // return analyticsUsername; // } // // public void setAnalyticsUsername(String analyticsUsername) { // this.analyticsUsername = analyticsUsername; // } // // public String getAnalyticsPassword() { // return analyticsPassword; // } // // public void setAnalyticsPassword(String analyticsPassword) { // this.analyticsPassword = analyticsPassword; // } // // public List<Destination> getAuthorizedDestinations() { // return authorizedDestinations; // } // // public void setAuthorizedDestinations(List<Destination> authorizedDestinations) { // this.authorizedDestinations = authorizedDestinations; // } // } // // Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/message/Destination.java // public class Destination { // private String gcsBucket; // private String gcsFolder; // private String displayName; // // private Destination() { // } // // public Destination(String gcsBucket, String gcsFolder, String displayName) { // this.gcsBucket = gcsBucket; // this.gcsFolder = gcsFolder; // this.displayName = displayName; // } // // public String getGcsBucket() { // return gcsBucket; // } // // public String getGcsFolder() { // return gcsFolder; // } // // public String getDisplayName() { // return displayName; // } // // @Override // public String toString() { // return displayName; // } // } // Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/config/AuthConfig.java import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.google.api.gax.paging.Page; import com.google.auth.oauth2.AccessToken; import com.google.auth.oauth2.GoogleCredentials; import com.google.ce.media.contentuploader.message.AuthInfo; import com.google.ce.media.contentuploader.message.Destination; import com.google.cloud.storage.Blob; import com.google.cloud.storage.Storage; import com.google.cloud.storage.StorageException; import com.google.cloud.storage.StorageOptions; import org.springframework.http.*; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; return authInfo; } public Storage getStorage() { synchronized (REFRESH_LOCK) { if((authInfo.getExpirationSeconds() - (System.currentTimeMillis()/1000L)) < REFRESH_THRESHOLD_SECS) { updateToken(null); } return storage; } } public AuthInfo getAuthInfo() { return authInfo; } private void buildStorage() { storage = StorageOptions .newBuilder() .setCredentials(credentials) .build() .getService(); } public interface AuthConfigListener { public void authInfoUpdated(); public void authInfoError(Exception e); } private void validateAuthorization() {
List<Destination> destinations = authInfo.getDestinations();
GoogleCloudPlatform/gcs-uploader
app-desktop/src/main/java/com/google/ce/media/contentuploader/exec/UploadTask.java
// Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/utils/DateUtils.java // public class DateUtils { // private static DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC(); // // public static String now() { // return formatter.print(System.currentTimeMillis()); // } // // public static String time(long millis) { // return formatter.print(millis); // } // }
import com.google.ce.media.contentuploader.message.*; import com.google.ce.media.contentuploader.utils.DateUtils; import com.google.cloud.WriteChannel; import com.google.cloud.storage.Blob; import com.google.cloud.storage.BlobInfo; import com.google.cloud.storage.Storage; import org.springframework.context.ApplicationEventPublisher; import java.io.FileInputStream; import java.nio.ByteBuffer; import java.nio.file.Files;
/* * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.google.ce.media.contentuploader.exec; /** * Created in gcs-uploader on 2020-01-08. */ public class UploadTask implements Runnable { private final TaskInfo taskInfo; private final ApplicationEventPublisher applicationEventPublisher; public UploadTask(TaskInfo taskInfo, ApplicationEventPublisher applicationEventPublisher) { this.taskInfo = taskInfo; this.applicationEventPublisher = applicationEventPublisher; } @Override public void run() { if(taskInfo.isCancelling()) { System.out.println(">> >> CANCELLING upload for file = " + taskInfo.getFile()); } if (taskInfo.getStatus() != TaskStatus.WAITING && taskInfo.getStatus() != TaskStatus.QUEUED) { return; } taskInfo.setStatus(TaskStatus.RUNNING); taskInfo.setStartTime(System.currentTimeMillis()); AnalyticsMessage m1 = AnalyticsMessage.from(taskInfo, AnalyticsMessage.Event.SINGLE_FILE_START, "Started Single Upload");
// Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/utils/DateUtils.java // public class DateUtils { // private static DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC(); // // public static String now() { // return formatter.print(System.currentTimeMillis()); // } // // public static String time(long millis) { // return formatter.print(millis); // } // } // Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/exec/UploadTask.java import com.google.ce.media.contentuploader.message.*; import com.google.ce.media.contentuploader.utils.DateUtils; import com.google.cloud.WriteChannel; import com.google.cloud.storage.Blob; import com.google.cloud.storage.BlobInfo; import com.google.cloud.storage.Storage; import org.springframework.context.ApplicationEventPublisher; import java.io.FileInputStream; import java.nio.ByteBuffer; import java.nio.file.Files; /* * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.google.ce.media.contentuploader.exec; /** * Created in gcs-uploader on 2020-01-08. */ public class UploadTask implements Runnable { private final TaskInfo taskInfo; private final ApplicationEventPublisher applicationEventPublisher; public UploadTask(TaskInfo taskInfo, ApplicationEventPublisher applicationEventPublisher) { this.taskInfo = taskInfo; this.applicationEventPublisher = applicationEventPublisher; } @Override public void run() { if(taskInfo.isCancelling()) { System.out.println(">> >> CANCELLING upload for file = " + taskInfo.getFile()); } if (taskInfo.getStatus() != TaskStatus.WAITING && taskInfo.getStatus() != TaskStatus.QUEUED) { return; } taskInfo.setStatus(TaskStatus.RUNNING); taskInfo.setStartTime(System.currentTimeMillis()); AnalyticsMessage m1 = AnalyticsMessage.from(taskInfo, AnalyticsMessage.Event.SINGLE_FILE_START, "Started Single Upload");
m1.setStartTime(DateUtils.time(taskInfo.getStartTime()));
GoogleCloudPlatform/gcs-uploader
app-desktop/src/main/java/com/google/ce/media/contentuploader/message/AnalyticsMessage.java
// Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/utils/DateUtils.java // public class DateUtils { // private static DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC(); // // public static String now() { // return formatter.print(System.currentTimeMillis()); // } // // public static String time(long millis) { // return formatter.print(millis); // } // }
import com.google.ce.media.contentuploader.utils.DateUtils; import com.google.cloud.storage.BlobInfo;
this.timeTaken = timeTaken; } public enum Type { TASK, TASKLET, INTERMEDIATE, STATUS, } public enum Event { SINGLE_FILE_START, SINGLE_FILE_END, COMPOSITE_FILE_START, COMPOSITE_FILE_END, SEGMENT_START, SEGMENT_END, STITCH_START, STITCH_END, INFO, LOGIN, RETOKEN, COMPLETE, ERROR, } public static AnalyticsMessage from(TaskInfo taskInfo, Event event, String comment) { AnalyticsMessage message = new AnalyticsMessage(); message.setGuid(taskInfo.getId()); message.setType(Type.TASK);
// Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/utils/DateUtils.java // public class DateUtils { // private static DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC(); // // public static String now() { // return formatter.print(System.currentTimeMillis()); // } // // public static String time(long millis) { // return formatter.print(millis); // } // } // Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/message/AnalyticsMessage.java import com.google.ce.media.contentuploader.utils.DateUtils; import com.google.cloud.storage.BlobInfo; this.timeTaken = timeTaken; } public enum Type { TASK, TASKLET, INTERMEDIATE, STATUS, } public enum Event { SINGLE_FILE_START, SINGLE_FILE_END, COMPOSITE_FILE_START, COMPOSITE_FILE_END, SEGMENT_START, SEGMENT_END, STITCH_START, STITCH_END, INFO, LOGIN, RETOKEN, COMPLETE, ERROR, } public static AnalyticsMessage from(TaskInfo taskInfo, Event event, String comment) { AnalyticsMessage message = new AnalyticsMessage(); message.setGuid(taskInfo.getId()); message.setType(Type.TASK);
message.timestamp = DateUtils.now();
TechzoneMC/NPCLib
api/src/main/java/net/techcable/npclib/ai/AIEnvironment.java
// Path: api/src/main/java/net/techcable/npclib/utils/NPCLog.java // @NoArgsConstructor(access = AccessLevel.PRIVATE) // public class NPCLog { // // public static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("npclib.debug", "false")); // // public static final String PREFIX = "NPCLib"; // // public static void info(String msg) { // log(Level.INFO, msg); // } // // public static void info(String msg, Object... args) { // log(Level.INFO, msg, args); // } // // public static void warn(String msg) { // log(Level.WARNING, msg); // } // // public static void warn(String msg, Object... args) { // log(Level.WARNING, msg, args); // } // // public static void warn(String msg, Throwable t) { // log(Level.WARNING, msg, t); // } // // public static void severe(String msg, Throwable t) { // log(Level.SEVERE, msg, t); // } // // public static void debug(String msg) { // if (DEBUG) { // log(Level.INFO, msg); // } // } // // public static void debug(String msg, Throwable t) { // if (DEBUG) { // log(Level.INFO, msg, t); // } // } // // private static void log(Level level, String msg, Throwable t) { // Bukkit.getLogger().log(level, PREFIX + " " + msg, t); // } // // private static void log(Level level, String msg, Object... args) { // Bukkit.getLogger().log(level, String.format(msg, args)); // } // // private static void log(Level level, String msg) { // Bukkit.getLogger().log(level, msg); // } // }
import com.google.common.base.Preconditions; import lombok.RequiredArgsConstructor; import net.techcable.npclib.utils.NPCLog; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set;
package net.techcable.npclib.ai; @RequiredArgsConstructor public class AIEnvironment { private final Set<AITask> tasks = new HashSet<>(); private final List<Runnable> callbacks = new ArrayList<>(); protected void tick() { for (final AITask task : tasks) { try { task.tick(this); } catch (Throwable t) {
// Path: api/src/main/java/net/techcable/npclib/utils/NPCLog.java // @NoArgsConstructor(access = AccessLevel.PRIVATE) // public class NPCLog { // // public static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("npclib.debug", "false")); // // public static final String PREFIX = "NPCLib"; // // public static void info(String msg) { // log(Level.INFO, msg); // } // // public static void info(String msg, Object... args) { // log(Level.INFO, msg, args); // } // // public static void warn(String msg) { // log(Level.WARNING, msg); // } // // public static void warn(String msg, Object... args) { // log(Level.WARNING, msg, args); // } // // public static void warn(String msg, Throwable t) { // log(Level.WARNING, msg, t); // } // // public static void severe(String msg, Throwable t) { // log(Level.SEVERE, msg, t); // } // // public static void debug(String msg) { // if (DEBUG) { // log(Level.INFO, msg); // } // } // // public static void debug(String msg, Throwable t) { // if (DEBUG) { // log(Level.INFO, msg, t); // } // } // // private static void log(Level level, String msg, Throwable t) { // Bukkit.getLogger().log(level, PREFIX + " " + msg, t); // } // // private static void log(Level level, String msg, Object... args) { // Bukkit.getLogger().log(level, String.format(msg, args)); // } // // private static void log(Level level, String msg) { // Bukkit.getLogger().log(level, msg); // } // } // Path: api/src/main/java/net/techcable/npclib/ai/AIEnvironment.java import com.google.common.base.Preconditions; import lombok.RequiredArgsConstructor; import net.techcable.npclib.utils.NPCLog; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; package net.techcable.npclib.ai; @RequiredArgsConstructor public class AIEnvironment { private final Set<AITask> tasks = new HashSet<>(); private final List<Runnable> callbacks = new ArrayList<>(); protected void tick() { for (final AITask task : tasks) { try { task.tick(this); } catch (Throwable t) {
NPCLog.warn("AI task " + task.getClass().getSimpleName() + " threw an exception", t);
TechzoneMC/NPCLib
api/src/main/java/net/techcable/npclib/NPC.java
// Path: api/src/main/java/net/techcable/npclib/ai/AIEnvironment.java // @RequiredArgsConstructor // public class AIEnvironment { // private final Set<AITask> tasks = new HashSet<>(); // private final List<Runnable> callbacks = new ArrayList<>(); // // protected void tick() { // for (final AITask task : tasks) { // try { // task.tick(this); // } catch (Throwable t) { // NPCLog.warn("AI task " + task.getClass().getSimpleName() + " threw an exception", t); // } // } // for (Runnable callback : callbacks) { // try { // callback.run(); // } catch (Throwable t) { // NPCLog.warn("Callback " + callback.getClass().getSimpleName() + " threw an exception", t); // } // } // callbacks.clear(); // } // // /** // * Add a callback to be ticked as soon as possible // * <p> // * Tasks are guaranteed to be ticked before callbacks // * // * @param callback the callback to run // */ // public void addCallback(Runnable callback) { // Preconditions.checkNotNull(callback, "Null callback"); // callbacks.add(callback); // } // // /** // * Remove this task from the ai environment // * // * @param task the task to remove // */ // public void addTask(AITask task) { // Preconditions.checkNotNull(task, "Null task"); // tasks.add(task); // } // // /** // * Remove this task from the ai environment // * <p> // * Does nothing if the task isn't there // * // * @param task the task to remove // */ // public void removeTask(AITask task) { // Preconditions.checkNotNull(task, "Null task to remove"); // tasks.remove(task); // } // } // // Path: api/src/main/java/net/techcable/npclib/ai/AITask.java // public interface AITask { // // /** // * Run this task in the given ai environment // * // * @param environment the ai environment // */ // public void tick(AIEnvironment environment); // }
import java.util.UUID; import net.techcable.npclib.ai.AIEnvironment; import net.techcable.npclib.ai.AITask; import org.bukkit.Location; import org.bukkit.entity.Entity;
package net.techcable.npclib; /** * Represents a non player controlled nmsEntity * * @author Techcable * @version 2.0 * @since 1.0 */ public interface NPC { /** * Despawn this npc * <p/> * Once despawned it can not be respawned * It will be deregistered from the registry * * @return true if was able to despawn * * @throws java.lang.IllegalStateException if the npc is already despawned */ public void despawn(); /** * Get the nmsEntity associated with this npc * * @return the nmsEntity */ public Entity getEntity(); /** * Get this npc's uuid * * @return the uuid of this npc */ public UUID getUUID(); /** * Returns whether the npc is spawned * * @return true if the npc is spawned */ public boolean isSpawned(); /** * Returns whether the npc has been destroyed * <p> * NPCs that are destroyed can never be respawned * </p> * * @return true if the npc has been destroyed */ public boolean isDestroyed(); /** * Spawn this npc * * @param toSpawn location to spawn this npc * * @return true if the npc was able to spawn * * @throws java.lang.NullPointerException if location is null * @throws java.lang.IllegalArgumentException if already or spawned or {@link #despawn()} has been called */ public void spawn(Location toSpawn); /** * Set the protected status of this NPC * true by default * * @param protect whether or not this npc is invincible */ public void setProtected(boolean protect); /** * Check if the NPC is protected from damage * * @return The protected status of the NPC */ public boolean isProtected(); /** * Add the specified task to the npc * * @param task the task to add */
// Path: api/src/main/java/net/techcable/npclib/ai/AIEnvironment.java // @RequiredArgsConstructor // public class AIEnvironment { // private final Set<AITask> tasks = new HashSet<>(); // private final List<Runnable> callbacks = new ArrayList<>(); // // protected void tick() { // for (final AITask task : tasks) { // try { // task.tick(this); // } catch (Throwable t) { // NPCLog.warn("AI task " + task.getClass().getSimpleName() + " threw an exception", t); // } // } // for (Runnable callback : callbacks) { // try { // callback.run(); // } catch (Throwable t) { // NPCLog.warn("Callback " + callback.getClass().getSimpleName() + " threw an exception", t); // } // } // callbacks.clear(); // } // // /** // * Add a callback to be ticked as soon as possible // * <p> // * Tasks are guaranteed to be ticked before callbacks // * // * @param callback the callback to run // */ // public void addCallback(Runnable callback) { // Preconditions.checkNotNull(callback, "Null callback"); // callbacks.add(callback); // } // // /** // * Remove this task from the ai environment // * // * @param task the task to remove // */ // public void addTask(AITask task) { // Preconditions.checkNotNull(task, "Null task"); // tasks.add(task); // } // // /** // * Remove this task from the ai environment // * <p> // * Does nothing if the task isn't there // * // * @param task the task to remove // */ // public void removeTask(AITask task) { // Preconditions.checkNotNull(task, "Null task to remove"); // tasks.remove(task); // } // } // // Path: api/src/main/java/net/techcable/npclib/ai/AITask.java // public interface AITask { // // /** // * Run this task in the given ai environment // * // * @param environment the ai environment // */ // public void tick(AIEnvironment environment); // } // Path: api/src/main/java/net/techcable/npclib/NPC.java import java.util.UUID; import net.techcable.npclib.ai.AIEnvironment; import net.techcable.npclib.ai.AITask; import org.bukkit.Location; import org.bukkit.entity.Entity; package net.techcable.npclib; /** * Represents a non player controlled nmsEntity * * @author Techcable * @version 2.0 * @since 1.0 */ public interface NPC { /** * Despawn this npc * <p/> * Once despawned it can not be respawned * It will be deregistered from the registry * * @return true if was able to despawn * * @throws java.lang.IllegalStateException if the npc is already despawned */ public void despawn(); /** * Get the nmsEntity associated with this npc * * @return the nmsEntity */ public Entity getEntity(); /** * Get this npc's uuid * * @return the uuid of this npc */ public UUID getUUID(); /** * Returns whether the npc is spawned * * @return true if the npc is spawned */ public boolean isSpawned(); /** * Returns whether the npc has been destroyed * <p> * NPCs that are destroyed can never be respawned * </p> * * @return true if the npc has been destroyed */ public boolean isDestroyed(); /** * Spawn this npc * * @param toSpawn location to spawn this npc * * @return true if the npc was able to spawn * * @throws java.lang.NullPointerException if location is null * @throws java.lang.IllegalArgumentException if already or spawned or {@link #despawn()} has been called */ public void spawn(Location toSpawn); /** * Set the protected status of this NPC * true by default * * @param protect whether or not this npc is invincible */ public void setProtected(boolean protect); /** * Check if the NPC is protected from damage * * @return The protected status of the NPC */ public boolean isProtected(); /** * Add the specified task to the npc * * @param task the task to add */
public void addTask(AITask task);
TechzoneMC/NPCLib
api/src/main/java/net/techcable/npclib/NPC.java
// Path: api/src/main/java/net/techcable/npclib/ai/AIEnvironment.java // @RequiredArgsConstructor // public class AIEnvironment { // private final Set<AITask> tasks = new HashSet<>(); // private final List<Runnable> callbacks = new ArrayList<>(); // // protected void tick() { // for (final AITask task : tasks) { // try { // task.tick(this); // } catch (Throwable t) { // NPCLog.warn("AI task " + task.getClass().getSimpleName() + " threw an exception", t); // } // } // for (Runnable callback : callbacks) { // try { // callback.run(); // } catch (Throwable t) { // NPCLog.warn("Callback " + callback.getClass().getSimpleName() + " threw an exception", t); // } // } // callbacks.clear(); // } // // /** // * Add a callback to be ticked as soon as possible // * <p> // * Tasks are guaranteed to be ticked before callbacks // * // * @param callback the callback to run // */ // public void addCallback(Runnable callback) { // Preconditions.checkNotNull(callback, "Null callback"); // callbacks.add(callback); // } // // /** // * Remove this task from the ai environment // * // * @param task the task to remove // */ // public void addTask(AITask task) { // Preconditions.checkNotNull(task, "Null task"); // tasks.add(task); // } // // /** // * Remove this task from the ai environment // * <p> // * Does nothing if the task isn't there // * // * @param task the task to remove // */ // public void removeTask(AITask task) { // Preconditions.checkNotNull(task, "Null task to remove"); // tasks.remove(task); // } // } // // Path: api/src/main/java/net/techcable/npclib/ai/AITask.java // public interface AITask { // // /** // * Run this task in the given ai environment // * // * @param environment the ai environment // */ // public void tick(AIEnvironment environment); // }
import java.util.UUID; import net.techcable.npclib.ai.AIEnvironment; import net.techcable.npclib.ai.AITask; import org.bukkit.Location; import org.bukkit.entity.Entity;
package net.techcable.npclib; /** * Represents a non player controlled nmsEntity * * @author Techcable * @version 2.0 * @since 1.0 */ public interface NPC { /** * Despawn this npc * <p/> * Once despawned it can not be respawned * It will be deregistered from the registry * * @return true if was able to despawn * * @throws java.lang.IllegalStateException if the npc is already despawned */ public void despawn(); /** * Get the nmsEntity associated with this npc * * @return the nmsEntity */ public Entity getEntity(); /** * Get this npc's uuid * * @return the uuid of this npc */ public UUID getUUID(); /** * Returns whether the npc is spawned * * @return true if the npc is spawned */ public boolean isSpawned(); /** * Returns whether the npc has been destroyed * <p> * NPCs that are destroyed can never be respawned * </p> * * @return true if the npc has been destroyed */ public boolean isDestroyed(); /** * Spawn this npc * * @param toSpawn location to spawn this npc * * @return true if the npc was able to spawn * * @throws java.lang.NullPointerException if location is null * @throws java.lang.IllegalArgumentException if already or spawned or {@link #despawn()} has been called */ public void spawn(Location toSpawn); /** * Set the protected status of this NPC * true by default * * @param protect whether or not this npc is invincible */ public void setProtected(boolean protect); /** * Check if the NPC is protected from damage * * @return The protected status of the NPC */ public boolean isProtected(); /** * Add the specified task to the npc * * @param task the task to add */ public void addTask(AITask task); /** * Get the npc's ai environment * <p> * The ai environment manages the npc's ai * </p> * * @return the npc's ai environment */
// Path: api/src/main/java/net/techcable/npclib/ai/AIEnvironment.java // @RequiredArgsConstructor // public class AIEnvironment { // private final Set<AITask> tasks = new HashSet<>(); // private final List<Runnable> callbacks = new ArrayList<>(); // // protected void tick() { // for (final AITask task : tasks) { // try { // task.tick(this); // } catch (Throwable t) { // NPCLog.warn("AI task " + task.getClass().getSimpleName() + " threw an exception", t); // } // } // for (Runnable callback : callbacks) { // try { // callback.run(); // } catch (Throwable t) { // NPCLog.warn("Callback " + callback.getClass().getSimpleName() + " threw an exception", t); // } // } // callbacks.clear(); // } // // /** // * Add a callback to be ticked as soon as possible // * <p> // * Tasks are guaranteed to be ticked before callbacks // * // * @param callback the callback to run // */ // public void addCallback(Runnable callback) { // Preconditions.checkNotNull(callback, "Null callback"); // callbacks.add(callback); // } // // /** // * Remove this task from the ai environment // * // * @param task the task to remove // */ // public void addTask(AITask task) { // Preconditions.checkNotNull(task, "Null task"); // tasks.add(task); // } // // /** // * Remove this task from the ai environment // * <p> // * Does nothing if the task isn't there // * // * @param task the task to remove // */ // public void removeTask(AITask task) { // Preconditions.checkNotNull(task, "Null task to remove"); // tasks.remove(task); // } // } // // Path: api/src/main/java/net/techcable/npclib/ai/AITask.java // public interface AITask { // // /** // * Run this task in the given ai environment // * // * @param environment the ai environment // */ // public void tick(AIEnvironment environment); // } // Path: api/src/main/java/net/techcable/npclib/NPC.java import java.util.UUID; import net.techcable.npclib.ai.AIEnvironment; import net.techcable.npclib.ai.AITask; import org.bukkit.Location; import org.bukkit.entity.Entity; package net.techcable.npclib; /** * Represents a non player controlled nmsEntity * * @author Techcable * @version 2.0 * @since 1.0 */ public interface NPC { /** * Despawn this npc * <p/> * Once despawned it can not be respawned * It will be deregistered from the registry * * @return true if was able to despawn * * @throws java.lang.IllegalStateException if the npc is already despawned */ public void despawn(); /** * Get the nmsEntity associated with this npc * * @return the nmsEntity */ public Entity getEntity(); /** * Get this npc's uuid * * @return the uuid of this npc */ public UUID getUUID(); /** * Returns whether the npc is spawned * * @return true if the npc is spawned */ public boolean isSpawned(); /** * Returns whether the npc has been destroyed * <p> * NPCs that are destroyed can never be respawned * </p> * * @return true if the npc has been destroyed */ public boolean isDestroyed(); /** * Spawn this npc * * @param toSpawn location to spawn this npc * * @return true if the npc was able to spawn * * @throws java.lang.NullPointerException if location is null * @throws java.lang.IllegalArgumentException if already or spawned or {@link #despawn()} has been called */ public void spawn(Location toSpawn); /** * Set the protected status of this NPC * true by default * * @param protect whether or not this npc is invincible */ public void setProtected(boolean protect); /** * Check if the NPC is protected from damage * * @return The protected status of the NPC */ public boolean isProtected(); /** * Add the specified task to the npc * * @param task the task to add */ public void addTask(AITask task); /** * Get the npc's ai environment * <p> * The ai environment manages the npc's ai * </p> * * @return the npc's ai environment */
public AIEnvironment getAIEnvironment();
TechzoneMC/NPCLib
citizens/src/main/java/net/techcable/npclib/citizens/CitizensNPC.java
// Path: api/src/main/java/net/techcable/npclib/ai/AITask.java // public interface AITask { // // /** // * Run this task in the given ai environment // * // * @param environment the ai environment // */ // public void tick(AIEnvironment environment); // } // // Path: citizens/src/main/java/net/techcable/npclib/citizens/ai/CitizensAIEnvironment.java // public class CitizensAIEnvironment extends AIEnvironment { // // private final CitizensNPC npc; // // public CitizensAIEnvironment(CitizensNPC npc) { // this.npc = npc; // new BukkitRunnable() { // // @Override // public void run() { // tick(); // } // }.runTaskTimer(CitizensAPI.getPlugin(), 0, 1); // } // }
import lombok.*; import java.lang.ref.WeakReference; import java.util.UUID; import net.citizensnpcs.api.npc.NPC; import net.techcable.npclib.ai.AITask; import net.techcable.npclib.citizens.ai.CitizensAIEnvironment; import org.bukkit.Location; import org.bukkit.entity.Entity; import com.google.common.base.Preconditions;
public boolean isSpawned() { return getHandle() != null && getHandle().isSpawned(); } @Override public boolean isDestroyed() { return getHandle() == null || destroyed; } @Override public void spawn(Location toSpawn) { Preconditions.checkNotNull(toSpawn, "Null location"); Preconditions.checkState(getHandle() != null, "This npc has been destroyed"); Preconditions.checkState(!isSpawned(), "Already spawned"); getHandle().spawn(toSpawn); } @Override public void setProtected(boolean protect) { Preconditions.checkState(getHandle() != null, "This npc has been destroyed"); getHandle().setProtected(protect); } @Override public boolean isProtected() { if (getHandle() == null) return false; return getHandle().isProtected(); } @Override
// Path: api/src/main/java/net/techcable/npclib/ai/AITask.java // public interface AITask { // // /** // * Run this task in the given ai environment // * // * @param environment the ai environment // */ // public void tick(AIEnvironment environment); // } // // Path: citizens/src/main/java/net/techcable/npclib/citizens/ai/CitizensAIEnvironment.java // public class CitizensAIEnvironment extends AIEnvironment { // // private final CitizensNPC npc; // // public CitizensAIEnvironment(CitizensNPC npc) { // this.npc = npc; // new BukkitRunnable() { // // @Override // public void run() { // tick(); // } // }.runTaskTimer(CitizensAPI.getPlugin(), 0, 1); // } // } // Path: citizens/src/main/java/net/techcable/npclib/citizens/CitizensNPC.java import lombok.*; import java.lang.ref.WeakReference; import java.util.UUID; import net.citizensnpcs.api.npc.NPC; import net.techcable.npclib.ai.AITask; import net.techcable.npclib.citizens.ai.CitizensAIEnvironment; import org.bukkit.Location; import org.bukkit.entity.Entity; import com.google.common.base.Preconditions; public boolean isSpawned() { return getHandle() != null && getHandle().isSpawned(); } @Override public boolean isDestroyed() { return getHandle() == null || destroyed; } @Override public void spawn(Location toSpawn) { Preconditions.checkNotNull(toSpawn, "Null location"); Preconditions.checkState(getHandle() != null, "This npc has been destroyed"); Preconditions.checkState(!isSpawned(), "Already spawned"); getHandle().spawn(toSpawn); } @Override public void setProtected(boolean protect) { Preconditions.checkState(getHandle() != null, "This npc has been destroyed"); getHandle().setProtected(protect); } @Override public boolean isProtected() { if (getHandle() == null) return false; return getHandle().isProtected(); } @Override
public void addTask(AITask task) {
TechzoneMC/NPCLib
citizens/src/main/java/net/techcable/npclib/citizens/CitizensNPC.java
// Path: api/src/main/java/net/techcable/npclib/ai/AITask.java // public interface AITask { // // /** // * Run this task in the given ai environment // * // * @param environment the ai environment // */ // public void tick(AIEnvironment environment); // } // // Path: citizens/src/main/java/net/techcable/npclib/citizens/ai/CitizensAIEnvironment.java // public class CitizensAIEnvironment extends AIEnvironment { // // private final CitizensNPC npc; // // public CitizensAIEnvironment(CitizensNPC npc) { // this.npc = npc; // new BukkitRunnable() { // // @Override // public void run() { // tick(); // } // }.runTaskTimer(CitizensAPI.getPlugin(), 0, 1); // } // }
import lombok.*; import java.lang.ref.WeakReference; import java.util.UUID; import net.citizensnpcs.api.npc.NPC; import net.techcable.npclib.ai.AITask; import net.techcable.npclib.citizens.ai.CitizensAIEnvironment; import org.bukkit.Location; import org.bukkit.entity.Entity; import com.google.common.base.Preconditions;
public boolean isDestroyed() { return getHandle() == null || destroyed; } @Override public void spawn(Location toSpawn) { Preconditions.checkNotNull(toSpawn, "Null location"); Preconditions.checkState(getHandle() != null, "This npc has been destroyed"); Preconditions.checkState(!isSpawned(), "Already spawned"); getHandle().spawn(toSpawn); } @Override public void setProtected(boolean protect) { Preconditions.checkState(getHandle() != null, "This npc has been destroyed"); getHandle().setProtected(protect); } @Override public boolean isProtected() { if (getHandle() == null) return false; return getHandle().isProtected(); } @Override public void addTask(AITask task) { getAIEnvironment().addTask(task); } @Getter(lazy = true)
// Path: api/src/main/java/net/techcable/npclib/ai/AITask.java // public interface AITask { // // /** // * Run this task in the given ai environment // * // * @param environment the ai environment // */ // public void tick(AIEnvironment environment); // } // // Path: citizens/src/main/java/net/techcable/npclib/citizens/ai/CitizensAIEnvironment.java // public class CitizensAIEnvironment extends AIEnvironment { // // private final CitizensNPC npc; // // public CitizensAIEnvironment(CitizensNPC npc) { // this.npc = npc; // new BukkitRunnable() { // // @Override // public void run() { // tick(); // } // }.runTaskTimer(CitizensAPI.getPlugin(), 0, 1); // } // } // Path: citizens/src/main/java/net/techcable/npclib/citizens/CitizensNPC.java import lombok.*; import java.lang.ref.WeakReference; import java.util.UUID; import net.citizensnpcs.api.npc.NPC; import net.techcable.npclib.ai.AITask; import net.techcable.npclib.citizens.ai.CitizensAIEnvironment; import org.bukkit.Location; import org.bukkit.entity.Entity; import com.google.common.base.Preconditions; public boolean isDestroyed() { return getHandle() == null || destroyed; } @Override public void spawn(Location toSpawn) { Preconditions.checkNotNull(toSpawn, "Null location"); Preconditions.checkState(getHandle() != null, "This npc has been destroyed"); Preconditions.checkState(!isSpawned(), "Already spawned"); getHandle().spawn(toSpawn); } @Override public void setProtected(boolean protect) { Preconditions.checkState(getHandle() != null, "This npc has been destroyed"); getHandle().setProtected(protect); } @Override public boolean isProtected() { if (getHandle() == null) return false; return getHandle().isProtected(); } @Override public void addTask(AITask task) { getAIEnvironment().addTask(task); } @Getter(lazy = true)
private final CitizensAIEnvironment aIEnvironment = new CitizensAIEnvironment(this);
TechzoneMC/NPCLib
citizens/src/main/java/net/techcable/npclib/citizens/LivingCitizensNPC.java
// Path: api/src/main/java/net/techcable/npclib/Animation.java // @RequiredArgsConstructor // public enum Animation { // /** // * Makes the npc act hurt // * <p/> // * Only applicable to living entities // */ // HURT, // /** // * Makes the npc lie on the ground // * <p/> // * Only applicable to living entities // */ // DEAD, // // // Human Animations // // /** // * Makes the npc swing its arm // * <p/> // * Only applicable to human entities // */ // ARM_SWING(HumanNPC.class), // /** // * Makes the npc eat the item it is holding // * <p/> // * Only applicable to human entities // */ // EAT(HumanNPC.class), // /** // * A critical hit animation // * <p/> // * Only applicable to human entities // */ // CRITICAL(HumanNPC.class), // /** // * A 'magic' critical hit animation // * <p/> // * Only applicable to human entities // */ // MAGIC_CRITICAL(HumanNPC.class); // // // private final Class<? extends NPC> appliesTo; // // /** // * Get the type of npc this animation can be applied to // * // * @return the type of npc this animation can be applied to // */ // public Class<? extends NPC> getAppliesTo() { // return appliesTo; // } // // private Animation() { // this(LivingNPC.class); // } // } // // Path: api/src/main/java/net/techcable/npclib/LivingNPC.java // public interface LivingNPC extends NPC { // // /** // * Set the current name of the npc // * // * @param name the new name // */ // public void setName(String name); // // /** // * Retrieve the name of this npc // * // * @return this npc's name // */ // public String getName(); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // @Override // public LivingEntity getEntity(); // // /** // * The npc's head will look in this direction // * // * @param toFace the direction to look // */ // public void faceLocation(Location toFace); // // /** // * Returns if the npc is an a condition to walk // * // * @return if the npc is an a condition to walk // */ // public boolean isAbleToWalk(); // // /** // * Walk to the specified location // * // * @param l the location to walk to // * // * @throws java.lang.IllegalStateException if not in a condition to walk // * @throws PathNotFoundException if the NPC could not walk to the specified location // * @throws NullPointerException if the location is null // */ // public void walkTo(Location l) throws PathNotFoundException; // // /** // * Play the specified animation to all clients // * // * @param animation the animation to play // * // * @throws java.lang.IllegalArgumentException if the annotation can't be played on this type of npc // * @throws java.lang.IllegalStateException if the npc is not spawned // * @throws java.lang.UnsupportedOperationException if this implementation doesn't support the specified animation // */ // public void animate(Animation animation); // // }
import net.citizensnpcs.api.npc.NPC; import net.techcable.npclib.Animation; import net.techcable.npclib.LivingNPC; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import com.google.common.base.Preconditions;
return getHandle().getName(); } @Override public void faceLocation(Location toFace) { Preconditions.checkState(getHandle() != null, "NPC has been destroyed"); Preconditions.checkState(isSpawned(), "NPC has been despawned"); getHandle().faceLocation(toFace); } @Override public boolean isAbleToWalk() { return isSpawned(); } @Override public void walkTo(Location l) { Preconditions.checkNotNull(l, "Null destination"); Preconditions.checkState(isAbleToWalk(), "Unable to walk"); getHandle().getNavigator().setTarget(l); } /** * {@inhertDoc} * <p> * Doesn't handle {@link net.techcable.npclib.Animation#HURT} and {@link net.techcable.npclib.Animation#DEAD} * </p> * */ @Override
// Path: api/src/main/java/net/techcable/npclib/Animation.java // @RequiredArgsConstructor // public enum Animation { // /** // * Makes the npc act hurt // * <p/> // * Only applicable to living entities // */ // HURT, // /** // * Makes the npc lie on the ground // * <p/> // * Only applicable to living entities // */ // DEAD, // // // Human Animations // // /** // * Makes the npc swing its arm // * <p/> // * Only applicable to human entities // */ // ARM_SWING(HumanNPC.class), // /** // * Makes the npc eat the item it is holding // * <p/> // * Only applicable to human entities // */ // EAT(HumanNPC.class), // /** // * A critical hit animation // * <p/> // * Only applicable to human entities // */ // CRITICAL(HumanNPC.class), // /** // * A 'magic' critical hit animation // * <p/> // * Only applicable to human entities // */ // MAGIC_CRITICAL(HumanNPC.class); // // // private final Class<? extends NPC> appliesTo; // // /** // * Get the type of npc this animation can be applied to // * // * @return the type of npc this animation can be applied to // */ // public Class<? extends NPC> getAppliesTo() { // return appliesTo; // } // // private Animation() { // this(LivingNPC.class); // } // } // // Path: api/src/main/java/net/techcable/npclib/LivingNPC.java // public interface LivingNPC extends NPC { // // /** // * Set the current name of the npc // * // * @param name the new name // */ // public void setName(String name); // // /** // * Retrieve the name of this npc // * // * @return this npc's name // */ // public String getName(); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // @Override // public LivingEntity getEntity(); // // /** // * The npc's head will look in this direction // * // * @param toFace the direction to look // */ // public void faceLocation(Location toFace); // // /** // * Returns if the npc is an a condition to walk // * // * @return if the npc is an a condition to walk // */ // public boolean isAbleToWalk(); // // /** // * Walk to the specified location // * // * @param l the location to walk to // * // * @throws java.lang.IllegalStateException if not in a condition to walk // * @throws PathNotFoundException if the NPC could not walk to the specified location // * @throws NullPointerException if the location is null // */ // public void walkTo(Location l) throws PathNotFoundException; // // /** // * Play the specified animation to all clients // * // * @param animation the animation to play // * // * @throws java.lang.IllegalArgumentException if the annotation can't be played on this type of npc // * @throws java.lang.IllegalStateException if the npc is not spawned // * @throws java.lang.UnsupportedOperationException if this implementation doesn't support the specified animation // */ // public void animate(Animation animation); // // } // Path: citizens/src/main/java/net/techcable/npclib/citizens/LivingCitizensNPC.java import net.citizensnpcs.api.npc.NPC; import net.techcable.npclib.Animation; import net.techcable.npclib.LivingNPC; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import com.google.common.base.Preconditions; return getHandle().getName(); } @Override public void faceLocation(Location toFace) { Preconditions.checkState(getHandle() != null, "NPC has been destroyed"); Preconditions.checkState(isSpawned(), "NPC has been despawned"); getHandle().faceLocation(toFace); } @Override public boolean isAbleToWalk() { return isSpawned(); } @Override public void walkTo(Location l) { Preconditions.checkNotNull(l, "Null destination"); Preconditions.checkState(isAbleToWalk(), "Unable to walk"); getHandle().getNavigator().setTarget(l); } /** * {@inhertDoc} * <p> * Doesn't handle {@link net.techcable.npclib.Animation#HURT} and {@link net.techcable.npclib.Animation#DEAD} * </p> * */ @Override
public void animate(Animation animation) {
TechzoneMC/NPCLib
api/src/main/java/net/techcable/npclib/nms/ILivingNPCHook.java
// Path: api/src/main/java/net/techcable/npclib/Animation.java // @RequiredArgsConstructor // public enum Animation { // /** // * Makes the npc act hurt // * <p/> // * Only applicable to living entities // */ // HURT, // /** // * Makes the npc lie on the ground // * <p/> // * Only applicable to living entities // */ // DEAD, // // // Human Animations // // /** // * Makes the npc swing its arm // * <p/> // * Only applicable to human entities // */ // ARM_SWING(HumanNPC.class), // /** // * Makes the npc eat the item it is holding // * <p/> // * Only applicable to human entities // */ // EAT(HumanNPC.class), // /** // * A critical hit animation // * <p/> // * Only applicable to human entities // */ // CRITICAL(HumanNPC.class), // /** // * A 'magic' critical hit animation // * <p/> // * Only applicable to human entities // */ // MAGIC_CRITICAL(HumanNPC.class); // // // private final Class<? extends NPC> appliesTo; // // /** // * Get the type of npc this animation can be applied to // * // * @return the type of npc this animation can be applied to // */ // public Class<? extends NPC> getAppliesTo() { // return appliesTo; // } // // private Animation() { // this(LivingNPC.class); // } // } // // Path: api/src/main/java/net/techcable/npclib/PathNotFoundException.java // public class PathNotFoundException extends Exception { // public PathNotFoundException(Location to, Location from) { // super(String.format("Could not find a path to %s, %s, %s from %s, %s, %s", to.getX(), to.getY(), to.getZ(), from.getX(), from.getY(), from.getZ())); // } // }
import net.techcable.npclib.Animation; import net.techcable.npclib.PathNotFoundException; import org.bukkit.Location; import org.bukkit.entity.LivingEntity;
package net.techcable.npclib.nms; public interface ILivingNPCHook extends INPCHook { public LivingEntity getEntity(); public void look(float pitch, float yaw); public void onTick(); public void setName(String s);
// Path: api/src/main/java/net/techcable/npclib/Animation.java // @RequiredArgsConstructor // public enum Animation { // /** // * Makes the npc act hurt // * <p/> // * Only applicable to living entities // */ // HURT, // /** // * Makes the npc lie on the ground // * <p/> // * Only applicable to living entities // */ // DEAD, // // // Human Animations // // /** // * Makes the npc swing its arm // * <p/> // * Only applicable to human entities // */ // ARM_SWING(HumanNPC.class), // /** // * Makes the npc eat the item it is holding // * <p/> // * Only applicable to human entities // */ // EAT(HumanNPC.class), // /** // * A critical hit animation // * <p/> // * Only applicable to human entities // */ // CRITICAL(HumanNPC.class), // /** // * A 'magic' critical hit animation // * <p/> // * Only applicable to human entities // */ // MAGIC_CRITICAL(HumanNPC.class); // // // private final Class<? extends NPC> appliesTo; // // /** // * Get the type of npc this animation can be applied to // * // * @return the type of npc this animation can be applied to // */ // public Class<? extends NPC> getAppliesTo() { // return appliesTo; // } // // private Animation() { // this(LivingNPC.class); // } // } // // Path: api/src/main/java/net/techcable/npclib/PathNotFoundException.java // public class PathNotFoundException extends Exception { // public PathNotFoundException(Location to, Location from) { // super(String.format("Could not find a path to %s, %s, %s from %s, %s, %s", to.getX(), to.getY(), to.getZ(), from.getX(), from.getY(), from.getZ())); // } // } // Path: api/src/main/java/net/techcable/npclib/nms/ILivingNPCHook.java import net.techcable.npclib.Animation; import net.techcable.npclib.PathNotFoundException; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; package net.techcable.npclib.nms; public interface ILivingNPCHook extends INPCHook { public LivingEntity getEntity(); public void look(float pitch, float yaw); public void onTick(); public void setName(String s);
public void navigateTo(Location l) throws PathNotFoundException;
TechzoneMC/NPCLib
api/src/main/java/net/techcable/npclib/nms/ILivingNPCHook.java
// Path: api/src/main/java/net/techcable/npclib/Animation.java // @RequiredArgsConstructor // public enum Animation { // /** // * Makes the npc act hurt // * <p/> // * Only applicable to living entities // */ // HURT, // /** // * Makes the npc lie on the ground // * <p/> // * Only applicable to living entities // */ // DEAD, // // // Human Animations // // /** // * Makes the npc swing its arm // * <p/> // * Only applicable to human entities // */ // ARM_SWING(HumanNPC.class), // /** // * Makes the npc eat the item it is holding // * <p/> // * Only applicable to human entities // */ // EAT(HumanNPC.class), // /** // * A critical hit animation // * <p/> // * Only applicable to human entities // */ // CRITICAL(HumanNPC.class), // /** // * A 'magic' critical hit animation // * <p/> // * Only applicable to human entities // */ // MAGIC_CRITICAL(HumanNPC.class); // // // private final Class<? extends NPC> appliesTo; // // /** // * Get the type of npc this animation can be applied to // * // * @return the type of npc this animation can be applied to // */ // public Class<? extends NPC> getAppliesTo() { // return appliesTo; // } // // private Animation() { // this(LivingNPC.class); // } // } // // Path: api/src/main/java/net/techcable/npclib/PathNotFoundException.java // public class PathNotFoundException extends Exception { // public PathNotFoundException(Location to, Location from) { // super(String.format("Could not find a path to %s, %s, %s from %s, %s, %s", to.getX(), to.getY(), to.getZ(), from.getX(), from.getY(), from.getZ())); // } // }
import net.techcable.npclib.Animation; import net.techcable.npclib.PathNotFoundException; import org.bukkit.Location; import org.bukkit.entity.LivingEntity;
package net.techcable.npclib.nms; public interface ILivingNPCHook extends INPCHook { public LivingEntity getEntity(); public void look(float pitch, float yaw); public void onTick(); public void setName(String s); public void navigateTo(Location l) throws PathNotFoundException;
// Path: api/src/main/java/net/techcable/npclib/Animation.java // @RequiredArgsConstructor // public enum Animation { // /** // * Makes the npc act hurt // * <p/> // * Only applicable to living entities // */ // HURT, // /** // * Makes the npc lie on the ground // * <p/> // * Only applicable to living entities // */ // DEAD, // // // Human Animations // // /** // * Makes the npc swing its arm // * <p/> // * Only applicable to human entities // */ // ARM_SWING(HumanNPC.class), // /** // * Makes the npc eat the item it is holding // * <p/> // * Only applicable to human entities // */ // EAT(HumanNPC.class), // /** // * A critical hit animation // * <p/> // * Only applicable to human entities // */ // CRITICAL(HumanNPC.class), // /** // * A 'magic' critical hit animation // * <p/> // * Only applicable to human entities // */ // MAGIC_CRITICAL(HumanNPC.class); // // // private final Class<? extends NPC> appliesTo; // // /** // * Get the type of npc this animation can be applied to // * // * @return the type of npc this animation can be applied to // */ // public Class<? extends NPC> getAppliesTo() { // return appliesTo; // } // // private Animation() { // this(LivingNPC.class); // } // } // // Path: api/src/main/java/net/techcable/npclib/PathNotFoundException.java // public class PathNotFoundException extends Exception { // public PathNotFoundException(Location to, Location from) { // super(String.format("Could not find a path to %s, %s, %s from %s, %s, %s", to.getX(), to.getY(), to.getZ(), from.getX(), from.getY(), from.getZ())); // } // } // Path: api/src/main/java/net/techcable/npclib/nms/ILivingNPCHook.java import net.techcable.npclib.Animation; import net.techcable.npclib.PathNotFoundException; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; package net.techcable.npclib.nms; public interface ILivingNPCHook extends INPCHook { public LivingEntity getEntity(); public void look(float pitch, float yaw); public void onTick(); public void setName(String s); public void navigateTo(Location l) throws PathNotFoundException;
public void animate(Animation animation); // NOTE -- API performs validation
TechzoneMC/NPCLib
nms-v1_7_R3/src/main/java/net/techcable/npclib/nms/versions/v1_7_R3/NPCHook.java
// Path: api/src/main/java/net/techcable/npclib/NPC.java // public interface NPC { // // /** // * Despawn this npc // * <p/> // * Once despawned it can not be respawned // * It will be deregistered from the registry // * // * @return true if was able to despawn // * // * @throws java.lang.IllegalStateException if the npc is already despawned // */ // public void despawn(); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // public Entity getEntity(); // // /** // * Get this npc's uuid // * // * @return the uuid of this npc // */ // public UUID getUUID(); // // /** // * Returns whether the npc is spawned // * // * @return true if the npc is spawned // */ // public boolean isSpawned(); // // /** // * Returns whether the npc has been destroyed // * <p> // * NPCs that are destroyed can never be respawned // * </p> // * // * @return true if the npc has been destroyed // */ // public boolean isDestroyed(); // // /** // * Spawn this npc // * // * @param toSpawn location to spawn this npc // * // * @return true if the npc was able to spawn // * // * @throws java.lang.NullPointerException if location is null // * @throws java.lang.IllegalArgumentException if already or spawned or {@link #despawn()} has been called // */ // public void spawn(Location toSpawn); // // /** // * Set the protected status of this NPC // * true by default // * // * @param protect whether or not this npc is invincible // */ // public void setProtected(boolean protect); // // /** // * Check if the NPC is protected from damage // * // * @return The protected status of the NPC // */ // public boolean isProtected(); // // /** // * Add the specified task to the npc // * // * @param task the task to add // */ // public void addTask(AITask task); // // /** // * Get the npc's ai environment // * <p> // * The ai environment manages the npc's ai // * </p> // * // * @return the npc's ai environment // */ // public AIEnvironment getAIEnvironment(); // // } // // Path: api/src/main/java/net/techcable/npclib/nms/INPCHook.java // public interface INPCHook { // // public void onDespawn(); // // public Entity getEntity(); // }
import lombok.*; import net.minecraft.server.v1_7_R3.Entity; import net.techcable.npclib.NPC; import net.techcable.npclib.nms.INPCHook;
package net.techcable.npclib.nms.versions.v1_7_R3; @Getter @RequiredArgsConstructor
// Path: api/src/main/java/net/techcable/npclib/NPC.java // public interface NPC { // // /** // * Despawn this npc // * <p/> // * Once despawned it can not be respawned // * It will be deregistered from the registry // * // * @return true if was able to despawn // * // * @throws java.lang.IllegalStateException if the npc is already despawned // */ // public void despawn(); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // public Entity getEntity(); // // /** // * Get this npc's uuid // * // * @return the uuid of this npc // */ // public UUID getUUID(); // // /** // * Returns whether the npc is spawned // * // * @return true if the npc is spawned // */ // public boolean isSpawned(); // // /** // * Returns whether the npc has been destroyed // * <p> // * NPCs that are destroyed can never be respawned // * </p> // * // * @return true if the npc has been destroyed // */ // public boolean isDestroyed(); // // /** // * Spawn this npc // * // * @param toSpawn location to spawn this npc // * // * @return true if the npc was able to spawn // * // * @throws java.lang.NullPointerException if location is null // * @throws java.lang.IllegalArgumentException if already or spawned or {@link #despawn()} has been called // */ // public void spawn(Location toSpawn); // // /** // * Set the protected status of this NPC // * true by default // * // * @param protect whether or not this npc is invincible // */ // public void setProtected(boolean protect); // // /** // * Check if the NPC is protected from damage // * // * @return The protected status of the NPC // */ // public boolean isProtected(); // // /** // * Add the specified task to the npc // * // * @param task the task to add // */ // public void addTask(AITask task); // // /** // * Get the npc's ai environment // * <p> // * The ai environment manages the npc's ai // * </p> // * // * @return the npc's ai environment // */ // public AIEnvironment getAIEnvironment(); // // } // // Path: api/src/main/java/net/techcable/npclib/nms/INPCHook.java // public interface INPCHook { // // public void onDespawn(); // // public Entity getEntity(); // } // Path: nms-v1_7_R3/src/main/java/net/techcable/npclib/nms/versions/v1_7_R3/NPCHook.java import lombok.*; import net.minecraft.server.v1_7_R3.Entity; import net.techcable.npclib.NPC; import net.techcable.npclib.nms.INPCHook; package net.techcable.npclib.nms.versions.v1_7_R3; @Getter @RequiredArgsConstructor
public class NPCHook implements INPCHook {
TechzoneMC/NPCLib
nms-v1_7_R3/src/main/java/net/techcable/npclib/nms/versions/v1_7_R3/NPCHook.java
// Path: api/src/main/java/net/techcable/npclib/NPC.java // public interface NPC { // // /** // * Despawn this npc // * <p/> // * Once despawned it can not be respawned // * It will be deregistered from the registry // * // * @return true if was able to despawn // * // * @throws java.lang.IllegalStateException if the npc is already despawned // */ // public void despawn(); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // public Entity getEntity(); // // /** // * Get this npc's uuid // * // * @return the uuid of this npc // */ // public UUID getUUID(); // // /** // * Returns whether the npc is spawned // * // * @return true if the npc is spawned // */ // public boolean isSpawned(); // // /** // * Returns whether the npc has been destroyed // * <p> // * NPCs that are destroyed can never be respawned // * </p> // * // * @return true if the npc has been destroyed // */ // public boolean isDestroyed(); // // /** // * Spawn this npc // * // * @param toSpawn location to spawn this npc // * // * @return true if the npc was able to spawn // * // * @throws java.lang.NullPointerException if location is null // * @throws java.lang.IllegalArgumentException if already or spawned or {@link #despawn()} has been called // */ // public void spawn(Location toSpawn); // // /** // * Set the protected status of this NPC // * true by default // * // * @param protect whether or not this npc is invincible // */ // public void setProtected(boolean protect); // // /** // * Check if the NPC is protected from damage // * // * @return The protected status of the NPC // */ // public boolean isProtected(); // // /** // * Add the specified task to the npc // * // * @param task the task to add // */ // public void addTask(AITask task); // // /** // * Get the npc's ai environment // * <p> // * The ai environment manages the npc's ai // * </p> // * // * @return the npc's ai environment // */ // public AIEnvironment getAIEnvironment(); // // } // // Path: api/src/main/java/net/techcable/npclib/nms/INPCHook.java // public interface INPCHook { // // public void onDespawn(); // // public Entity getEntity(); // }
import lombok.*; import net.minecraft.server.v1_7_R3.Entity; import net.techcable.npclib.NPC; import net.techcable.npclib.nms.INPCHook;
package net.techcable.npclib.nms.versions.v1_7_R3; @Getter @RequiredArgsConstructor public class NPCHook implements INPCHook {
// Path: api/src/main/java/net/techcable/npclib/NPC.java // public interface NPC { // // /** // * Despawn this npc // * <p/> // * Once despawned it can not be respawned // * It will be deregistered from the registry // * // * @return true if was able to despawn // * // * @throws java.lang.IllegalStateException if the npc is already despawned // */ // public void despawn(); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // public Entity getEntity(); // // /** // * Get this npc's uuid // * // * @return the uuid of this npc // */ // public UUID getUUID(); // // /** // * Returns whether the npc is spawned // * // * @return true if the npc is spawned // */ // public boolean isSpawned(); // // /** // * Returns whether the npc has been destroyed // * <p> // * NPCs that are destroyed can never be respawned // * </p> // * // * @return true if the npc has been destroyed // */ // public boolean isDestroyed(); // // /** // * Spawn this npc // * // * @param toSpawn location to spawn this npc // * // * @return true if the npc was able to spawn // * // * @throws java.lang.NullPointerException if location is null // * @throws java.lang.IllegalArgumentException if already or spawned or {@link #despawn()} has been called // */ // public void spawn(Location toSpawn); // // /** // * Set the protected status of this NPC // * true by default // * // * @param protect whether or not this npc is invincible // */ // public void setProtected(boolean protect); // // /** // * Check if the NPC is protected from damage // * // * @return The protected status of the NPC // */ // public boolean isProtected(); // // /** // * Add the specified task to the npc // * // * @param task the task to add // */ // public void addTask(AITask task); // // /** // * Get the npc's ai environment // * <p> // * The ai environment manages the npc's ai // * </p> // * // * @return the npc's ai environment // */ // public AIEnvironment getAIEnvironment(); // // } // // Path: api/src/main/java/net/techcable/npclib/nms/INPCHook.java // public interface INPCHook { // // public void onDespawn(); // // public Entity getEntity(); // } // Path: nms-v1_7_R3/src/main/java/net/techcable/npclib/nms/versions/v1_7_R3/NPCHook.java import lombok.*; import net.minecraft.server.v1_7_R3.Entity; import net.techcable.npclib.NPC; import net.techcable.npclib.nms.INPCHook; package net.techcable.npclib.nms.versions.v1_7_R3; @Getter @RequiredArgsConstructor public class NPCHook implements INPCHook {
private final NPC npc;
TechzoneMC/NPCLib
nms-v1_8_R1/src/main/java/net/techcable/npclib/nms/versions/v1_8_R1/NPCHook.java
// Path: api/src/main/java/net/techcable/npclib/NPC.java // public interface NPC { // // /** // * Despawn this npc // * <p/> // * Once despawned it can not be respawned // * It will be deregistered from the registry // * // * @return true if was able to despawn // * // * @throws java.lang.IllegalStateException if the npc is already despawned // */ // public void despawn(); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // public Entity getEntity(); // // /** // * Get this npc's uuid // * // * @return the uuid of this npc // */ // public UUID getUUID(); // // /** // * Returns whether the npc is spawned // * // * @return true if the npc is spawned // */ // public boolean isSpawned(); // // /** // * Returns whether the npc has been destroyed // * <p> // * NPCs that are destroyed can never be respawned // * </p> // * // * @return true if the npc has been destroyed // */ // public boolean isDestroyed(); // // /** // * Spawn this npc // * // * @param toSpawn location to spawn this npc // * // * @return true if the npc was able to spawn // * // * @throws java.lang.NullPointerException if location is null // * @throws java.lang.IllegalArgumentException if already or spawned or {@link #despawn()} has been called // */ // public void spawn(Location toSpawn); // // /** // * Set the protected status of this NPC // * true by default // * // * @param protect whether or not this npc is invincible // */ // public void setProtected(boolean protect); // // /** // * Check if the NPC is protected from damage // * // * @return The protected status of the NPC // */ // public boolean isProtected(); // // /** // * Add the specified task to the npc // * // * @param task the task to add // */ // public void addTask(AITask task); // // /** // * Get the npc's ai environment // * <p> // * The ai environment manages the npc's ai // * </p> // * // * @return the npc's ai environment // */ // public AIEnvironment getAIEnvironment(); // // } // // Path: api/src/main/java/net/techcable/npclib/nms/INPCHook.java // public interface INPCHook { // // public void onDespawn(); // // public Entity getEntity(); // }
import lombok.*; import net.minecraft.server.v1_8_R1.Entity; import net.techcable.npclib.NPC; import net.techcable.npclib.nms.INPCHook;
package net.techcable.npclib.nms.versions.v1_8_R1; @Getter @RequiredArgsConstructor
// Path: api/src/main/java/net/techcable/npclib/NPC.java // public interface NPC { // // /** // * Despawn this npc // * <p/> // * Once despawned it can not be respawned // * It will be deregistered from the registry // * // * @return true if was able to despawn // * // * @throws java.lang.IllegalStateException if the npc is already despawned // */ // public void despawn(); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // public Entity getEntity(); // // /** // * Get this npc's uuid // * // * @return the uuid of this npc // */ // public UUID getUUID(); // // /** // * Returns whether the npc is spawned // * // * @return true if the npc is spawned // */ // public boolean isSpawned(); // // /** // * Returns whether the npc has been destroyed // * <p> // * NPCs that are destroyed can never be respawned // * </p> // * // * @return true if the npc has been destroyed // */ // public boolean isDestroyed(); // // /** // * Spawn this npc // * // * @param toSpawn location to spawn this npc // * // * @return true if the npc was able to spawn // * // * @throws java.lang.NullPointerException if location is null // * @throws java.lang.IllegalArgumentException if already or spawned or {@link #despawn()} has been called // */ // public void spawn(Location toSpawn); // // /** // * Set the protected status of this NPC // * true by default // * // * @param protect whether or not this npc is invincible // */ // public void setProtected(boolean protect); // // /** // * Check if the NPC is protected from damage // * // * @return The protected status of the NPC // */ // public boolean isProtected(); // // /** // * Add the specified task to the npc // * // * @param task the task to add // */ // public void addTask(AITask task); // // /** // * Get the npc's ai environment // * <p> // * The ai environment manages the npc's ai // * </p> // * // * @return the npc's ai environment // */ // public AIEnvironment getAIEnvironment(); // // } // // Path: api/src/main/java/net/techcable/npclib/nms/INPCHook.java // public interface INPCHook { // // public void onDespawn(); // // public Entity getEntity(); // } // Path: nms-v1_8_R1/src/main/java/net/techcable/npclib/nms/versions/v1_8_R1/NPCHook.java import lombok.*; import net.minecraft.server.v1_8_R1.Entity; import net.techcable.npclib.NPC; import net.techcable.npclib.nms.INPCHook; package net.techcable.npclib.nms.versions.v1_8_R1; @Getter @RequiredArgsConstructor
public class NPCHook implements INPCHook {
TechzoneMC/NPCLib
nms-v1_8_R1/src/main/java/net/techcable/npclib/nms/versions/v1_8_R1/NPCHook.java
// Path: api/src/main/java/net/techcable/npclib/NPC.java // public interface NPC { // // /** // * Despawn this npc // * <p/> // * Once despawned it can not be respawned // * It will be deregistered from the registry // * // * @return true if was able to despawn // * // * @throws java.lang.IllegalStateException if the npc is already despawned // */ // public void despawn(); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // public Entity getEntity(); // // /** // * Get this npc's uuid // * // * @return the uuid of this npc // */ // public UUID getUUID(); // // /** // * Returns whether the npc is spawned // * // * @return true if the npc is spawned // */ // public boolean isSpawned(); // // /** // * Returns whether the npc has been destroyed // * <p> // * NPCs that are destroyed can never be respawned // * </p> // * // * @return true if the npc has been destroyed // */ // public boolean isDestroyed(); // // /** // * Spawn this npc // * // * @param toSpawn location to spawn this npc // * // * @return true if the npc was able to spawn // * // * @throws java.lang.NullPointerException if location is null // * @throws java.lang.IllegalArgumentException if already or spawned or {@link #despawn()} has been called // */ // public void spawn(Location toSpawn); // // /** // * Set the protected status of this NPC // * true by default // * // * @param protect whether or not this npc is invincible // */ // public void setProtected(boolean protect); // // /** // * Check if the NPC is protected from damage // * // * @return The protected status of the NPC // */ // public boolean isProtected(); // // /** // * Add the specified task to the npc // * // * @param task the task to add // */ // public void addTask(AITask task); // // /** // * Get the npc's ai environment // * <p> // * The ai environment manages the npc's ai // * </p> // * // * @return the npc's ai environment // */ // public AIEnvironment getAIEnvironment(); // // } // // Path: api/src/main/java/net/techcable/npclib/nms/INPCHook.java // public interface INPCHook { // // public void onDespawn(); // // public Entity getEntity(); // }
import lombok.*; import net.minecraft.server.v1_8_R1.Entity; import net.techcable.npclib.NPC; import net.techcable.npclib.nms.INPCHook;
package net.techcable.npclib.nms.versions.v1_8_R1; @Getter @RequiredArgsConstructor public class NPCHook implements INPCHook {
// Path: api/src/main/java/net/techcable/npclib/NPC.java // public interface NPC { // // /** // * Despawn this npc // * <p/> // * Once despawned it can not be respawned // * It will be deregistered from the registry // * // * @return true if was able to despawn // * // * @throws java.lang.IllegalStateException if the npc is already despawned // */ // public void despawn(); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // public Entity getEntity(); // // /** // * Get this npc's uuid // * // * @return the uuid of this npc // */ // public UUID getUUID(); // // /** // * Returns whether the npc is spawned // * // * @return true if the npc is spawned // */ // public boolean isSpawned(); // // /** // * Returns whether the npc has been destroyed // * <p> // * NPCs that are destroyed can never be respawned // * </p> // * // * @return true if the npc has been destroyed // */ // public boolean isDestroyed(); // // /** // * Spawn this npc // * // * @param toSpawn location to spawn this npc // * // * @return true if the npc was able to spawn // * // * @throws java.lang.NullPointerException if location is null // * @throws java.lang.IllegalArgumentException if already or spawned or {@link #despawn()} has been called // */ // public void spawn(Location toSpawn); // // /** // * Set the protected status of this NPC // * true by default // * // * @param protect whether or not this npc is invincible // */ // public void setProtected(boolean protect); // // /** // * Check if the NPC is protected from damage // * // * @return The protected status of the NPC // */ // public boolean isProtected(); // // /** // * Add the specified task to the npc // * // * @param task the task to add // */ // public void addTask(AITask task); // // /** // * Get the npc's ai environment // * <p> // * The ai environment manages the npc's ai // * </p> // * // * @return the npc's ai environment // */ // public AIEnvironment getAIEnvironment(); // // } // // Path: api/src/main/java/net/techcable/npclib/nms/INPCHook.java // public interface INPCHook { // // public void onDespawn(); // // public Entity getEntity(); // } // Path: nms-v1_8_R1/src/main/java/net/techcable/npclib/nms/versions/v1_8_R1/NPCHook.java import lombok.*; import net.minecraft.server.v1_8_R1.Entity; import net.techcable.npclib.NPC; import net.techcable.npclib.nms.INPCHook; package net.techcable.npclib.nms.versions.v1_8_R1; @Getter @RequiredArgsConstructor public class NPCHook implements INPCHook {
private final NPC npc;
TechzoneMC/NPCLib
nms-v1_7_R4/src/main/java/net/techcable/npclib/nms/versions/v1_7_R4/network/NPCNetworkManager.java
// Path: api/src/main/java/net/techcable/npclib/utils/Reflection.java // public class Reflection { // // public static Class<?> getNmsClass(String name) { // String className = "net.minecraft.server." + getVersion() + "." + name; // return getClass(className); // } // // public static Class<?> getCbClass(String name) { // String className = "org.bukkit.craftbukkit." + getVersion() + "." + name; // return getClass(className); // } // // public static Class<?> getUtilClass(String name) { // try { // return Class.forName(name); //Try before 1.8 first // } catch (ClassNotFoundException ex) { // try { // return Class.forName("net.minecraft.util." + name); //Not 1.8 // } catch (ClassNotFoundException ex2) { // return null; // } // } // } // // public static String getVersion() { // String packageName = Bukkit.getServer().getClass().getPackage().getName(); // return packageName.substring(packageName.lastIndexOf('.') + 1); // } // // public static Object getHandle(Object wrapper) { // Method getHandle = makeMethod(wrapper.getClass(), "getHandle"); // return callMethod(getHandle, wrapper); // } // // //Utils // public static Method makeMethod(Class<?> clazz, String methodName, Class<?>... paramaters) { // try { // return clazz.getDeclaredMethod(methodName, paramaters); // } catch (NoSuchMethodException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> T callMethod(Method method, Object instance, Object... paramaters) { // if (method == null) throw new RuntimeException("No such method"); // method.setAccessible(true); // try { // return (T) method.invoke(instance, paramaters); // } catch (InvocationTargetException ex) { // throw new RuntimeException(ex.getCause()); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> Constructor<T> makeConstructor(Class<?> clazz, Class<?>... paramaterTypes) { // try { // return (Constructor<T>) clazz.getConstructor(paramaterTypes); // } catch (NoSuchMethodException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static <T> T callConstructor(Constructor<T> constructor, Object... paramaters) { // if (constructor == null) throw new RuntimeException("No such constructor"); // constructor.setAccessible(true); // try { // return (T) constructor.newInstance(paramaters); // } catch (InvocationTargetException ex) { // throw new RuntimeException(ex.getCause()); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static Field makeField(Class<?> clazz, String name) { // try { // return clazz.getDeclaredField(name); // } catch (NoSuchFieldException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> T getField(Field field, Object instance) { // if (field == null) throw new RuntimeException("No such field"); // field.setAccessible(true); // try { // return (T) field.get(instance); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static void setField(Field field, Object instance, Object value) { // if (field == null) throw new RuntimeException("No such field"); // field.setAccessible(true); // try { // field.set(instance, value); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static Class<?> getClass(String name) { // try { // return Class.forName(name); // } catch (ClassNotFoundException ex) { // return null; // } // } // // public static <T> Class<? extends T> getClass(String name, Class<T> superClass) { // try { // return Class.forName(name).asSubclass(superClass); // } catch (ClassCastException | ClassNotFoundException ex) { // return null; // } // } // }
import lombok.*; import java.lang.reflect.Field; import net.minecraft.server.v1_7_R4.NetworkManager; import net.techcable.npclib.utils.Reflection;
package net.techcable.npclib.nms.versions.v1_7_R4.network; @Getter public class NPCNetworkManager extends NetworkManager { public NPCNetworkManager() { super(false); //MCP = isClientSide
// Path: api/src/main/java/net/techcable/npclib/utils/Reflection.java // public class Reflection { // // public static Class<?> getNmsClass(String name) { // String className = "net.minecraft.server." + getVersion() + "." + name; // return getClass(className); // } // // public static Class<?> getCbClass(String name) { // String className = "org.bukkit.craftbukkit." + getVersion() + "." + name; // return getClass(className); // } // // public static Class<?> getUtilClass(String name) { // try { // return Class.forName(name); //Try before 1.8 first // } catch (ClassNotFoundException ex) { // try { // return Class.forName("net.minecraft.util." + name); //Not 1.8 // } catch (ClassNotFoundException ex2) { // return null; // } // } // } // // public static String getVersion() { // String packageName = Bukkit.getServer().getClass().getPackage().getName(); // return packageName.substring(packageName.lastIndexOf('.') + 1); // } // // public static Object getHandle(Object wrapper) { // Method getHandle = makeMethod(wrapper.getClass(), "getHandle"); // return callMethod(getHandle, wrapper); // } // // //Utils // public static Method makeMethod(Class<?> clazz, String methodName, Class<?>... paramaters) { // try { // return clazz.getDeclaredMethod(methodName, paramaters); // } catch (NoSuchMethodException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> T callMethod(Method method, Object instance, Object... paramaters) { // if (method == null) throw new RuntimeException("No such method"); // method.setAccessible(true); // try { // return (T) method.invoke(instance, paramaters); // } catch (InvocationTargetException ex) { // throw new RuntimeException(ex.getCause()); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> Constructor<T> makeConstructor(Class<?> clazz, Class<?>... paramaterTypes) { // try { // return (Constructor<T>) clazz.getConstructor(paramaterTypes); // } catch (NoSuchMethodException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static <T> T callConstructor(Constructor<T> constructor, Object... paramaters) { // if (constructor == null) throw new RuntimeException("No such constructor"); // constructor.setAccessible(true); // try { // return (T) constructor.newInstance(paramaters); // } catch (InvocationTargetException ex) { // throw new RuntimeException(ex.getCause()); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static Field makeField(Class<?> clazz, String name) { // try { // return clazz.getDeclaredField(name); // } catch (NoSuchFieldException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> T getField(Field field, Object instance) { // if (field == null) throw new RuntimeException("No such field"); // field.setAccessible(true); // try { // return (T) field.get(instance); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static void setField(Field field, Object instance, Object value) { // if (field == null) throw new RuntimeException("No such field"); // field.setAccessible(true); // try { // field.set(instance, value); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static Class<?> getClass(String name) { // try { // return Class.forName(name); // } catch (ClassNotFoundException ex) { // return null; // } // } // // public static <T> Class<? extends T> getClass(String name, Class<T> superClass) { // try { // return Class.forName(name).asSubclass(superClass); // } catch (ClassCastException | ClassNotFoundException ex) { // return null; // } // } // } // Path: nms-v1_7_R4/src/main/java/net/techcable/npclib/nms/versions/v1_7_R4/network/NPCNetworkManager.java import lombok.*; import java.lang.reflect.Field; import net.minecraft.server.v1_7_R4.NetworkManager; import net.techcable.npclib.utils.Reflection; package net.techcable.npclib.nms.versions.v1_7_R4.network; @Getter public class NPCNetworkManager extends NetworkManager { public NPCNetworkManager() { super(false); //MCP = isClientSide
Field channel = Reflection.makeField(NetworkManager.class, "m"); //MCP = channel
TechzoneMC/NPCLib
nms-v1_7_R4/src/main/java/net/techcable/npclib/nms/versions/v1_7_R4/ProtocolHack.java
// Path: api/src/main/java/net/techcable/npclib/utils/Reflection.java // public class Reflection { // // public static Class<?> getNmsClass(String name) { // String className = "net.minecraft.server." + getVersion() + "." + name; // return getClass(className); // } // // public static Class<?> getCbClass(String name) { // String className = "org.bukkit.craftbukkit." + getVersion() + "." + name; // return getClass(className); // } // // public static Class<?> getUtilClass(String name) { // try { // return Class.forName(name); //Try before 1.8 first // } catch (ClassNotFoundException ex) { // try { // return Class.forName("net.minecraft.util." + name); //Not 1.8 // } catch (ClassNotFoundException ex2) { // return null; // } // } // } // // public static String getVersion() { // String packageName = Bukkit.getServer().getClass().getPackage().getName(); // return packageName.substring(packageName.lastIndexOf('.') + 1); // } // // public static Object getHandle(Object wrapper) { // Method getHandle = makeMethod(wrapper.getClass(), "getHandle"); // return callMethod(getHandle, wrapper); // } // // //Utils // public static Method makeMethod(Class<?> clazz, String methodName, Class<?>... paramaters) { // try { // return clazz.getDeclaredMethod(methodName, paramaters); // } catch (NoSuchMethodException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> T callMethod(Method method, Object instance, Object... paramaters) { // if (method == null) throw new RuntimeException("No such method"); // method.setAccessible(true); // try { // return (T) method.invoke(instance, paramaters); // } catch (InvocationTargetException ex) { // throw new RuntimeException(ex.getCause()); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> Constructor<T> makeConstructor(Class<?> clazz, Class<?>... paramaterTypes) { // try { // return (Constructor<T>) clazz.getConstructor(paramaterTypes); // } catch (NoSuchMethodException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static <T> T callConstructor(Constructor<T> constructor, Object... paramaters) { // if (constructor == null) throw new RuntimeException("No such constructor"); // constructor.setAccessible(true); // try { // return (T) constructor.newInstance(paramaters); // } catch (InvocationTargetException ex) { // throw new RuntimeException(ex.getCause()); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static Field makeField(Class<?> clazz, String name) { // try { // return clazz.getDeclaredField(name); // } catch (NoSuchFieldException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> T getField(Field field, Object instance) { // if (field == null) throw new RuntimeException("No such field"); // field.setAccessible(true); // try { // return (T) field.get(instance); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static void setField(Field field, Object instance, Object value) { // if (field == null) throw new RuntimeException("No such field"); // field.setAccessible(true); // try { // field.set(instance, value); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static Class<?> getClass(String name) { // try { // return Class.forName(name); // } catch (ClassNotFoundException ex) { // return null; // } // } // // public static <T> Class<? extends T> getClass(String name, Class<T> superClass) { // try { // return Class.forName(name).asSubclass(superClass); // } catch (ClassCastException | ClassNotFoundException ex) { // return null; // } // } // }
import java.lang.reflect.Method; import net.minecraft.server.v1_7_R4.EntityPlayer; import net.minecraft.server.v1_7_R4.Packet; import net.techcable.npclib.utils.Reflection;
package net.techcable.npclib.nms.versions.v1_7_R4; public class ProtocolHack { private ProtocolHack() { } public static boolean isProtocolHack() { try { Class.forName("org.spigotmc.ProtocolData"); return true; } catch (ClassNotFoundException ex) { return false; } }
// Path: api/src/main/java/net/techcable/npclib/utils/Reflection.java // public class Reflection { // // public static Class<?> getNmsClass(String name) { // String className = "net.minecraft.server." + getVersion() + "." + name; // return getClass(className); // } // // public static Class<?> getCbClass(String name) { // String className = "org.bukkit.craftbukkit." + getVersion() + "." + name; // return getClass(className); // } // // public static Class<?> getUtilClass(String name) { // try { // return Class.forName(name); //Try before 1.8 first // } catch (ClassNotFoundException ex) { // try { // return Class.forName("net.minecraft.util." + name); //Not 1.8 // } catch (ClassNotFoundException ex2) { // return null; // } // } // } // // public static String getVersion() { // String packageName = Bukkit.getServer().getClass().getPackage().getName(); // return packageName.substring(packageName.lastIndexOf('.') + 1); // } // // public static Object getHandle(Object wrapper) { // Method getHandle = makeMethod(wrapper.getClass(), "getHandle"); // return callMethod(getHandle, wrapper); // } // // //Utils // public static Method makeMethod(Class<?> clazz, String methodName, Class<?>... paramaters) { // try { // return clazz.getDeclaredMethod(methodName, paramaters); // } catch (NoSuchMethodException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> T callMethod(Method method, Object instance, Object... paramaters) { // if (method == null) throw new RuntimeException("No such method"); // method.setAccessible(true); // try { // return (T) method.invoke(instance, paramaters); // } catch (InvocationTargetException ex) { // throw new RuntimeException(ex.getCause()); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> Constructor<T> makeConstructor(Class<?> clazz, Class<?>... paramaterTypes) { // try { // return (Constructor<T>) clazz.getConstructor(paramaterTypes); // } catch (NoSuchMethodException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static <T> T callConstructor(Constructor<T> constructor, Object... paramaters) { // if (constructor == null) throw new RuntimeException("No such constructor"); // constructor.setAccessible(true); // try { // return (T) constructor.newInstance(paramaters); // } catch (InvocationTargetException ex) { // throw new RuntimeException(ex.getCause()); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static Field makeField(Class<?> clazz, String name) { // try { // return clazz.getDeclaredField(name); // } catch (NoSuchFieldException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> T getField(Field field, Object instance) { // if (field == null) throw new RuntimeException("No such field"); // field.setAccessible(true); // try { // return (T) field.get(instance); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static void setField(Field field, Object instance, Object value) { // if (field == null) throw new RuntimeException("No such field"); // field.setAccessible(true); // try { // field.set(instance, value); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static Class<?> getClass(String name) { // try { // return Class.forName(name); // } catch (ClassNotFoundException ex) { // return null; // } // } // // public static <T> Class<? extends T> getClass(String name, Class<T> superClass) { // try { // return Class.forName(name).asSubclass(superClass); // } catch (ClassCastException | ClassNotFoundException ex) { // return null; // } // } // } // Path: nms-v1_7_R4/src/main/java/net/techcable/npclib/nms/versions/v1_7_R4/ProtocolHack.java import java.lang.reflect.Method; import net.minecraft.server.v1_7_R4.EntityPlayer; import net.minecraft.server.v1_7_R4.Packet; import net.techcable.npclib.utils.Reflection; package net.techcable.npclib.nms.versions.v1_7_R4; public class ProtocolHack { private ProtocolHack() { } public static boolean isProtocolHack() { try { Class.forName("org.spigotmc.ProtocolData"); return true; } catch (ClassNotFoundException ex) { return false; } }
private static final Method addPlayerMethod = Reflection.makeMethod(getPlayerInfoClass(), "addPlayer", EntityPlayer.class);
TechzoneMC/NPCLib
nms-v1_8_R2/src/main/java/net/techcable/npclib/nms/versions/v1_8_R2/network/NPCConnection.java
// Path: nms-v1_8_R2/src/main/java/net/techcable/npclib/nms/versions/v1_8_R2/NMS.java // public class NMS implements net.techcable.npclib.nms.NMS { // // private static NMS instance; // // public NMS() { // if (instance == null) instance = this; // } // // public static NMS getInstance() { // return instance; // } // // // @Override // public IHumanNPCHook spawnHumanNPC(Location toSpawn, HumanNPC npc) { // return new HumanNPCHook(npc, toSpawn); // } // // @Override // public void onJoin(Player joined, Collection<? extends NPC> npcs) { // for (NPC npc : npcs) { // if (!(npc instanceof HumanNPC)) continue; // HumanNPCHook hook = getHook((HumanNPC) npc); // if (hook == null) continue; // hook.onJoin(joined); // } // } // // // UTILS // public static final String NO_CRAFTBUKKIT_MSG = "Non-CraftBukkit implementations are unsupported"; // // public static EntityPlayer getHandle(Player player) { // if (!(player instanceof CraftPlayer)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftPlayer) player).getHandle(); // } // // public static EntityLiving getHandle(LivingEntity entity) { // if (!(entity instanceof CraftLivingEntity)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftLivingEntity) entity).getHandle(); // } // // // public static MinecraftServer getServer() { // Server server = Bukkit.getServer(); // if (!(server instanceof CraftServer)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftServer) server).getServer(); // } // // public static WorldServer getHandle(World world) { // if (!(world instanceof CraftWorld)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftWorld) world).getHandle(); // } // // public static HumanNPCHook getHook(HumanNPC npc) { // EntityPlayer player = getHandle(npc.getEntity()); // if (player instanceof EntityNPCPlayer) return null; // return ((EntityNPCPlayer) player).getHook(); // } // // public static LivingNPCHook getHook(LivingNPC npc) { // if (npc instanceof HumanNPC) return getHook((HumanNPC) npc); // EntityLiving entity = getHandle(npc.getEntity()); // if (entity instanceof LivingHookable) return ((LivingHookable) entity).getHook(); // return null; // } // // public static void sendToAll(Packet packet) { // for (Player p : Bukkit.getOnlinePlayers()) { // getHandle(p).playerConnection.sendPacket(packet); // } // } // // private static final LoadingCache<UUID, GameProfile> properties = CacheBuilder.newBuilder() // .expireAfterAccess(5, TimeUnit.MINUTES) // .build(new CacheLoader<UUID, GameProfile>() { // // @Override // public GameProfile load(UUID uuid) throws Exception { // return MinecraftServer.getServer().aC().fillProfileProperties(new GameProfile(uuid, null), true); // } // }); // // public static void setSkin(GameProfile profile, UUID skinId) { // GameProfile skinProfile; // if (Bukkit.getPlayer(skinId) != null) { // skinProfile = getHandle(Bukkit.getPlayer(skinId)).getProfile(); // } else { // skinProfile = properties.getUnchecked(skinId); // } // if (skinProfile.getProperties().containsKey("textures")) { // profile.getProperties().removeAll("textures"); // profile.getProperties().putAll("textures", skinProfile.getProperties().get("textures")); // } else { // NPCLog.debug("Skin with uuid not found: " + skinId); // } // } // }
import lombok.*; import net.minecraft.server.v1_8_R2.EntityPlayer; import net.minecraft.server.v1_8_R2.Packet; import net.minecraft.server.v1_8_R2.PlayerConnection; import net.techcable.npclib.nms.versions.v1_8_R2.NMS;
package net.techcable.npclib.nms.versions.v1_8_R2.network; @Getter public class NPCConnection extends PlayerConnection { public NPCConnection(EntityPlayer player) {
// Path: nms-v1_8_R2/src/main/java/net/techcable/npclib/nms/versions/v1_8_R2/NMS.java // public class NMS implements net.techcable.npclib.nms.NMS { // // private static NMS instance; // // public NMS() { // if (instance == null) instance = this; // } // // public static NMS getInstance() { // return instance; // } // // // @Override // public IHumanNPCHook spawnHumanNPC(Location toSpawn, HumanNPC npc) { // return new HumanNPCHook(npc, toSpawn); // } // // @Override // public void onJoin(Player joined, Collection<? extends NPC> npcs) { // for (NPC npc : npcs) { // if (!(npc instanceof HumanNPC)) continue; // HumanNPCHook hook = getHook((HumanNPC) npc); // if (hook == null) continue; // hook.onJoin(joined); // } // } // // // UTILS // public static final String NO_CRAFTBUKKIT_MSG = "Non-CraftBukkit implementations are unsupported"; // // public static EntityPlayer getHandle(Player player) { // if (!(player instanceof CraftPlayer)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftPlayer) player).getHandle(); // } // // public static EntityLiving getHandle(LivingEntity entity) { // if (!(entity instanceof CraftLivingEntity)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftLivingEntity) entity).getHandle(); // } // // // public static MinecraftServer getServer() { // Server server = Bukkit.getServer(); // if (!(server instanceof CraftServer)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftServer) server).getServer(); // } // // public static WorldServer getHandle(World world) { // if (!(world instanceof CraftWorld)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftWorld) world).getHandle(); // } // // public static HumanNPCHook getHook(HumanNPC npc) { // EntityPlayer player = getHandle(npc.getEntity()); // if (player instanceof EntityNPCPlayer) return null; // return ((EntityNPCPlayer) player).getHook(); // } // // public static LivingNPCHook getHook(LivingNPC npc) { // if (npc instanceof HumanNPC) return getHook((HumanNPC) npc); // EntityLiving entity = getHandle(npc.getEntity()); // if (entity instanceof LivingHookable) return ((LivingHookable) entity).getHook(); // return null; // } // // public static void sendToAll(Packet packet) { // for (Player p : Bukkit.getOnlinePlayers()) { // getHandle(p).playerConnection.sendPacket(packet); // } // } // // private static final LoadingCache<UUID, GameProfile> properties = CacheBuilder.newBuilder() // .expireAfterAccess(5, TimeUnit.MINUTES) // .build(new CacheLoader<UUID, GameProfile>() { // // @Override // public GameProfile load(UUID uuid) throws Exception { // return MinecraftServer.getServer().aC().fillProfileProperties(new GameProfile(uuid, null), true); // } // }); // // public static void setSkin(GameProfile profile, UUID skinId) { // GameProfile skinProfile; // if (Bukkit.getPlayer(skinId) != null) { // skinProfile = getHandle(Bukkit.getPlayer(skinId)).getProfile(); // } else { // skinProfile = properties.getUnchecked(skinId); // } // if (skinProfile.getProperties().containsKey("textures")) { // profile.getProperties().removeAll("textures"); // profile.getProperties().putAll("textures", skinProfile.getProperties().get("textures")); // } else { // NPCLog.debug("Skin with uuid not found: " + skinId); // } // } // } // Path: nms-v1_8_R2/src/main/java/net/techcable/npclib/nms/versions/v1_8_R2/network/NPCConnection.java import lombok.*; import net.minecraft.server.v1_8_R2.EntityPlayer; import net.minecraft.server.v1_8_R2.Packet; import net.minecraft.server.v1_8_R2.PlayerConnection; import net.techcable.npclib.nms.versions.v1_8_R2.NMS; package net.techcable.npclib.nms.versions.v1_8_R2.network; @Getter public class NPCConnection extends PlayerConnection { public NPCConnection(EntityPlayer player) {
super(NMS.getServer(), new NPCNetworkManager(), player);
TechzoneMC/NPCLib
nms-v1_7_R4/src/main/java/net/techcable/npclib/nms/versions/v1_7_R4/network/NPCConnection.java
// Path: nms-v1_7_R4/src/main/java/net/techcable/npclib/nms/versions/v1_7_R4/NMS.java // public class NMS implements net.techcable.npclib.nms.NMS { // // private static NMS instance; // // public NMS() { // if (instance == null) instance = this; // } // // public static NMS getInstance() { // return instance; // } // // @Override // public IHumanNPCHook spawnHumanNPC(Location toSpawn, HumanNPC npc) { // return new HumanNPCHook(npc, toSpawn); // } // // @Override // public void onJoin(Player joined, Collection<? extends NPC> npcs) { // for (NPC npc : npcs) { // if (!(npc instanceof HumanNPC)) continue; // HumanNPCHook hook = getHandle((HumanNPC) npc); // if (hook == null) continue; // hook.onJoin(joined); // } // } // // // UTILS // public static final String NO_CRAFTBUKKIT_MSG = "Non-CraftBukkit implementations are unsupported"; // // public static EntityPlayer getHandle(Player player) { // if (!(player instanceof CraftPlayer)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftPlayer) player).getHandle(); // } // // public static EntityLiving getHandle(LivingEntity player) { // if (!(player instanceof CraftLivingEntity)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftLivingEntity) player).getHandle(); // } // // public static MinecraftServer getServer() { // Server server = Bukkit.getServer(); // if (!(server instanceof CraftServer)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftServer) server).getServer(); // } // // public static WorldServer getHandle(World world) { // if (!(world instanceof CraftWorld)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftWorld) world).getHandle(); // } // // public static HumanNPCHook getHandle(HumanNPC npc) { // EntityPlayer player = getHandle(npc.getEntity()); // if (player instanceof EntityNPCPlayer) return null; // return ((EntityNPCPlayer) player).getHook(); // } // // public static void sendToAll(Packet packet) { // for (EntityPlayer p : (List<EntityPlayer>) MinecraftServer.getServer().getPlayerList().players) { // p.playerConnection.sendPacket(packet); // } // } // private static final Cache<UUID, GameProfile> properties = CacheBuilder.newBuilder() // .expireAfterAccess(5, TimeUnit.MINUTES) // .build(new CacheLoader<UUID, GameProfile>() { // // @Override // public GameProfile load(UUID uuid) throws Exception { // return MinecraftServer.getServer().av().fillProfileProperties(new GameProfile(uuid, null), true); // } // }); // // public static void setSkin(GameProfile profile, UUID skinId) { // GameProfile skinProfile; // if (Bukkit.getPlayer(skinId) != null) { // skinProfile = getHandle(Bukkit.getPlayer(skinId)).getProfile(); // } else { // skinProfile = properties.getUnchecked(skinId); // } // if (skinProfile.getProperties().containsKey("textures")) { // profile.getProperties().removeAll("textures"); // profile.getProperties().putAll("textures", skinProfile.getProperties().get("textures")); // } else { // NPCLog.debug("Skin with uuid not found: " + skinId); // } // } // }
import lombok.*; import net.minecraft.server.v1_7_R4.EntityPlayer; import net.minecraft.server.v1_7_R4.Packet; import net.minecraft.server.v1_7_R4.PlayerConnection; import net.techcable.npclib.nms.versions.v1_7_R4.NMS;
package net.techcable.npclib.nms.versions.v1_7_R4.network; @Getter public class NPCConnection extends PlayerConnection { public NPCConnection(EntityPlayer npc) {
// Path: nms-v1_7_R4/src/main/java/net/techcable/npclib/nms/versions/v1_7_R4/NMS.java // public class NMS implements net.techcable.npclib.nms.NMS { // // private static NMS instance; // // public NMS() { // if (instance == null) instance = this; // } // // public static NMS getInstance() { // return instance; // } // // @Override // public IHumanNPCHook spawnHumanNPC(Location toSpawn, HumanNPC npc) { // return new HumanNPCHook(npc, toSpawn); // } // // @Override // public void onJoin(Player joined, Collection<? extends NPC> npcs) { // for (NPC npc : npcs) { // if (!(npc instanceof HumanNPC)) continue; // HumanNPCHook hook = getHandle((HumanNPC) npc); // if (hook == null) continue; // hook.onJoin(joined); // } // } // // // UTILS // public static final String NO_CRAFTBUKKIT_MSG = "Non-CraftBukkit implementations are unsupported"; // // public static EntityPlayer getHandle(Player player) { // if (!(player instanceof CraftPlayer)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftPlayer) player).getHandle(); // } // // public static EntityLiving getHandle(LivingEntity player) { // if (!(player instanceof CraftLivingEntity)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftLivingEntity) player).getHandle(); // } // // public static MinecraftServer getServer() { // Server server = Bukkit.getServer(); // if (!(server instanceof CraftServer)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftServer) server).getServer(); // } // // public static WorldServer getHandle(World world) { // if (!(world instanceof CraftWorld)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftWorld) world).getHandle(); // } // // public static HumanNPCHook getHandle(HumanNPC npc) { // EntityPlayer player = getHandle(npc.getEntity()); // if (player instanceof EntityNPCPlayer) return null; // return ((EntityNPCPlayer) player).getHook(); // } // // public static void sendToAll(Packet packet) { // for (EntityPlayer p : (List<EntityPlayer>) MinecraftServer.getServer().getPlayerList().players) { // p.playerConnection.sendPacket(packet); // } // } // private static final Cache<UUID, GameProfile> properties = CacheBuilder.newBuilder() // .expireAfterAccess(5, TimeUnit.MINUTES) // .build(new CacheLoader<UUID, GameProfile>() { // // @Override // public GameProfile load(UUID uuid) throws Exception { // return MinecraftServer.getServer().av().fillProfileProperties(new GameProfile(uuid, null), true); // } // }); // // public static void setSkin(GameProfile profile, UUID skinId) { // GameProfile skinProfile; // if (Bukkit.getPlayer(skinId) != null) { // skinProfile = getHandle(Bukkit.getPlayer(skinId)).getProfile(); // } else { // skinProfile = properties.getUnchecked(skinId); // } // if (skinProfile.getProperties().containsKey("textures")) { // profile.getProperties().removeAll("textures"); // profile.getProperties().putAll("textures", skinProfile.getProperties().get("textures")); // } else { // NPCLog.debug("Skin with uuid not found: " + skinId); // } // } // } // Path: nms-v1_7_R4/src/main/java/net/techcable/npclib/nms/versions/v1_7_R4/network/NPCConnection.java import lombok.*; import net.minecraft.server.v1_7_R4.EntityPlayer; import net.minecraft.server.v1_7_R4.Packet; import net.minecraft.server.v1_7_R4.PlayerConnection; import net.techcable.npclib.nms.versions.v1_7_R4.NMS; package net.techcable.npclib.nms.versions.v1_7_R4.network; @Getter public class NPCConnection extends PlayerConnection { public NPCConnection(EntityPlayer npc) {
super(NMS.getServer(), new NPCNetworkManager(), npc);
TechzoneMC/NPCLib
nms-v1_8_R1/src/main/java/net/techcable/npclib/nms/versions/v1_8_R1/network/NPCNetworkManager.java
// Path: api/src/main/java/net/techcable/npclib/utils/Reflection.java // public class Reflection { // // public static Class<?> getNmsClass(String name) { // String className = "net.minecraft.server." + getVersion() + "." + name; // return getClass(className); // } // // public static Class<?> getCbClass(String name) { // String className = "org.bukkit.craftbukkit." + getVersion() + "." + name; // return getClass(className); // } // // public static Class<?> getUtilClass(String name) { // try { // return Class.forName(name); //Try before 1.8 first // } catch (ClassNotFoundException ex) { // try { // return Class.forName("net.minecraft.util." + name); //Not 1.8 // } catch (ClassNotFoundException ex2) { // return null; // } // } // } // // public static String getVersion() { // String packageName = Bukkit.getServer().getClass().getPackage().getName(); // return packageName.substring(packageName.lastIndexOf('.') + 1); // } // // public static Object getHandle(Object wrapper) { // Method getHandle = makeMethod(wrapper.getClass(), "getHandle"); // return callMethod(getHandle, wrapper); // } // // //Utils // public static Method makeMethod(Class<?> clazz, String methodName, Class<?>... paramaters) { // try { // return clazz.getDeclaredMethod(methodName, paramaters); // } catch (NoSuchMethodException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> T callMethod(Method method, Object instance, Object... paramaters) { // if (method == null) throw new RuntimeException("No such method"); // method.setAccessible(true); // try { // return (T) method.invoke(instance, paramaters); // } catch (InvocationTargetException ex) { // throw new RuntimeException(ex.getCause()); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> Constructor<T> makeConstructor(Class<?> clazz, Class<?>... paramaterTypes) { // try { // return (Constructor<T>) clazz.getConstructor(paramaterTypes); // } catch (NoSuchMethodException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static <T> T callConstructor(Constructor<T> constructor, Object... paramaters) { // if (constructor == null) throw new RuntimeException("No such constructor"); // constructor.setAccessible(true); // try { // return (T) constructor.newInstance(paramaters); // } catch (InvocationTargetException ex) { // throw new RuntimeException(ex.getCause()); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static Field makeField(Class<?> clazz, String name) { // try { // return clazz.getDeclaredField(name); // } catch (NoSuchFieldException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> T getField(Field field, Object instance) { // if (field == null) throw new RuntimeException("No such field"); // field.setAccessible(true); // try { // return (T) field.get(instance); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static void setField(Field field, Object instance, Object value) { // if (field == null) throw new RuntimeException("No such field"); // field.setAccessible(true); // try { // field.set(instance, value); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static Class<?> getClass(String name) { // try { // return Class.forName(name); // } catch (ClassNotFoundException ex) { // return null; // } // } // // public static <T> Class<? extends T> getClass(String name, Class<T> superClass) { // try { // return Class.forName(name).asSubclass(superClass); // } catch (ClassCastException | ClassNotFoundException ex) { // return null; // } // } // }
import lombok.*; import java.lang.reflect.Field; import net.minecraft.server.v1_8_R1.EnumProtocolDirection; import net.minecraft.server.v1_8_R1.NetworkManager; import net.techcable.npclib.utils.Reflection;
package net.techcable.npclib.nms.versions.v1_8_R1.network; @Getter public class NPCNetworkManager extends NetworkManager { public NPCNetworkManager() { super(EnumProtocolDirection.CLIENTBOUND); //MCP = isClientSide ---- SRG=field_150747_h
// Path: api/src/main/java/net/techcable/npclib/utils/Reflection.java // public class Reflection { // // public static Class<?> getNmsClass(String name) { // String className = "net.minecraft.server." + getVersion() + "." + name; // return getClass(className); // } // // public static Class<?> getCbClass(String name) { // String className = "org.bukkit.craftbukkit." + getVersion() + "." + name; // return getClass(className); // } // // public static Class<?> getUtilClass(String name) { // try { // return Class.forName(name); //Try before 1.8 first // } catch (ClassNotFoundException ex) { // try { // return Class.forName("net.minecraft.util." + name); //Not 1.8 // } catch (ClassNotFoundException ex2) { // return null; // } // } // } // // public static String getVersion() { // String packageName = Bukkit.getServer().getClass().getPackage().getName(); // return packageName.substring(packageName.lastIndexOf('.') + 1); // } // // public static Object getHandle(Object wrapper) { // Method getHandle = makeMethod(wrapper.getClass(), "getHandle"); // return callMethod(getHandle, wrapper); // } // // //Utils // public static Method makeMethod(Class<?> clazz, String methodName, Class<?>... paramaters) { // try { // return clazz.getDeclaredMethod(methodName, paramaters); // } catch (NoSuchMethodException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> T callMethod(Method method, Object instance, Object... paramaters) { // if (method == null) throw new RuntimeException("No such method"); // method.setAccessible(true); // try { // return (T) method.invoke(instance, paramaters); // } catch (InvocationTargetException ex) { // throw new RuntimeException(ex.getCause()); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> Constructor<T> makeConstructor(Class<?> clazz, Class<?>... paramaterTypes) { // try { // return (Constructor<T>) clazz.getConstructor(paramaterTypes); // } catch (NoSuchMethodException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static <T> T callConstructor(Constructor<T> constructor, Object... paramaters) { // if (constructor == null) throw new RuntimeException("No such constructor"); // constructor.setAccessible(true); // try { // return (T) constructor.newInstance(paramaters); // } catch (InvocationTargetException ex) { // throw new RuntimeException(ex.getCause()); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static Field makeField(Class<?> clazz, String name) { // try { // return clazz.getDeclaredField(name); // } catch (NoSuchFieldException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> T getField(Field field, Object instance) { // if (field == null) throw new RuntimeException("No such field"); // field.setAccessible(true); // try { // return (T) field.get(instance); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static void setField(Field field, Object instance, Object value) { // if (field == null) throw new RuntimeException("No such field"); // field.setAccessible(true); // try { // field.set(instance, value); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static Class<?> getClass(String name) { // try { // return Class.forName(name); // } catch (ClassNotFoundException ex) { // return null; // } // } // // public static <T> Class<? extends T> getClass(String name, Class<T> superClass) { // try { // return Class.forName(name).asSubclass(superClass); // } catch (ClassCastException | ClassNotFoundException ex) { // return null; // } // } // } // Path: nms-v1_8_R1/src/main/java/net/techcable/npclib/nms/versions/v1_8_R1/network/NPCNetworkManager.java import lombok.*; import java.lang.reflect.Field; import net.minecraft.server.v1_8_R1.EnumProtocolDirection; import net.minecraft.server.v1_8_R1.NetworkManager; import net.techcable.npclib.utils.Reflection; package net.techcable.npclib.nms.versions.v1_8_R1.network; @Getter public class NPCNetworkManager extends NetworkManager { public NPCNetworkManager() { super(EnumProtocolDirection.CLIENTBOUND); //MCP = isClientSide ---- SRG=field_150747_h
Field channel = Reflection.makeField(NetworkManager.class, "i"); //MCP = channel ---- SRG=field_150746_k
TechzoneMC/NPCLib
nms-v1_9_R1/src/main/java/net/techcable/npclib/nms/versions/v1_9_R1/network/NPCConnection.java
// Path: nms-v1_9_R1/src/main/java/net/techcable/npclib/nms/versions/v1_9_R1/NMS.java // public class NMS implements net.techcable.npclib.nms.NMS { // // private static NMS instance; // // public NMS() { // if (instance == null) instance = this; // } // // public static NMS getInstance() { // return instance; // } // // // @Override // public IHumanNPCHook spawnHumanNPC(Location toSpawn, HumanNPC npc) { // return new HumanNPCHook(npc, toSpawn); // } // // @Override // public void onJoin(Player joined, Collection<? extends NPC> npcs) { // for (NPC npc : npcs) { // if (!(npc instanceof HumanNPC)) continue; // HumanNPCHook hook = getHook((HumanNPC) npc); // if (hook == null) continue; // hook.onJoin(joined); // } // } // // // UTILS // public static final String NO_CRAFTBUKKIT_MSG = "Non-CraftBukkit implementations are unsupported"; // // public static EntityPlayer getHandle(Player player) { // if (!(player instanceof CraftPlayer)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftPlayer) player).getHandle(); // } // // public static EntityLiving getHandle(LivingEntity player) { // if (!(player instanceof CraftLivingEntity)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftLivingEntity) player).getHandle(); // } // // public static MinecraftServer getServer() { // Server server = Bukkit.getServer(); // if (!(server instanceof CraftServer)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftServer) server).getServer(); // } // // public static WorldServer getHandle(World world) { // if (!(world instanceof CraftWorld)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftWorld) world).getHandle(); // } // // public static HumanNPCHook getHook(HumanNPC npc) { // EntityPlayer player = getHandle(npc.getEntity()); // if (player instanceof EntityNPCPlayer) return null; // return ((EntityNPCPlayer) player).getHook(); // } // // public static LivingNPCHook getHook(LivingNPC npc) { // if (npc instanceof HumanNPC) return getHook((HumanNPC) npc); // EntityLiving entity = getHandle(npc.getEntity()); // if (entity instanceof LivingHookable) return ((LivingHookable) entity).getHook(); // return null; // } // // public static void sendToAll(Packet packet) { // for (Player p : Bukkit.getOnlinePlayers()) { // getHandle(p).playerConnection.sendPacket(packet); // } // } // // private static final LoadingCache<UUID, GameProfile> properties = CacheBuilder.newBuilder() // .expireAfterAccess(5, TimeUnit.MINUTES) // .build(new CacheLoader<UUID, GameProfile>() { // // @Override // public GameProfile load(UUID uuid) throws Exception { // return MinecraftServer.getServer().ay().fillProfileProperties(new GameProfile(uuid, null), true); // } // }); // // public static void setSkin(GameProfile profile, UUID skinId) { // GameProfile skinProfile; // if (Bukkit.getPlayer(skinId) != null) { // skinProfile = getHandle(Bukkit.getPlayer(skinId)).getProfile(); // } else { // skinProfile = properties.getUnchecked(skinId); // } // if (skinProfile.getProperties().containsKey("textures")) { // profile.getProperties().removeAll("textures"); // profile.getProperties().putAll("textures", skinProfile.getProperties().get("textures")); // } else { // NPCLog.debug("Skin with uuid not found: " + skinId); // } // } // }
import lombok.*; import net.minecraft.server.v1_9_R1.EntityPlayer; import net.minecraft.server.v1_9_R1.Packet; import net.minecraft.server.v1_9_R1.PlayerConnection; import net.techcable.npclib.nms.versions.v1_9_R1.NMS;
package net.techcable.npclib.nms.versions.v1_9_R1.network; @Getter public class NPCConnection extends PlayerConnection { public NPCConnection(EntityPlayer player) {
// Path: nms-v1_9_R1/src/main/java/net/techcable/npclib/nms/versions/v1_9_R1/NMS.java // public class NMS implements net.techcable.npclib.nms.NMS { // // private static NMS instance; // // public NMS() { // if (instance == null) instance = this; // } // // public static NMS getInstance() { // return instance; // } // // // @Override // public IHumanNPCHook spawnHumanNPC(Location toSpawn, HumanNPC npc) { // return new HumanNPCHook(npc, toSpawn); // } // // @Override // public void onJoin(Player joined, Collection<? extends NPC> npcs) { // for (NPC npc : npcs) { // if (!(npc instanceof HumanNPC)) continue; // HumanNPCHook hook = getHook((HumanNPC) npc); // if (hook == null) continue; // hook.onJoin(joined); // } // } // // // UTILS // public static final String NO_CRAFTBUKKIT_MSG = "Non-CraftBukkit implementations are unsupported"; // // public static EntityPlayer getHandle(Player player) { // if (!(player instanceof CraftPlayer)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftPlayer) player).getHandle(); // } // // public static EntityLiving getHandle(LivingEntity player) { // if (!(player instanceof CraftLivingEntity)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftLivingEntity) player).getHandle(); // } // // public static MinecraftServer getServer() { // Server server = Bukkit.getServer(); // if (!(server instanceof CraftServer)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftServer) server).getServer(); // } // // public static WorldServer getHandle(World world) { // if (!(world instanceof CraftWorld)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftWorld) world).getHandle(); // } // // public static HumanNPCHook getHook(HumanNPC npc) { // EntityPlayer player = getHandle(npc.getEntity()); // if (player instanceof EntityNPCPlayer) return null; // return ((EntityNPCPlayer) player).getHook(); // } // // public static LivingNPCHook getHook(LivingNPC npc) { // if (npc instanceof HumanNPC) return getHook((HumanNPC) npc); // EntityLiving entity = getHandle(npc.getEntity()); // if (entity instanceof LivingHookable) return ((LivingHookable) entity).getHook(); // return null; // } // // public static void sendToAll(Packet packet) { // for (Player p : Bukkit.getOnlinePlayers()) { // getHandle(p).playerConnection.sendPacket(packet); // } // } // // private static final LoadingCache<UUID, GameProfile> properties = CacheBuilder.newBuilder() // .expireAfterAccess(5, TimeUnit.MINUTES) // .build(new CacheLoader<UUID, GameProfile>() { // // @Override // public GameProfile load(UUID uuid) throws Exception { // return MinecraftServer.getServer().ay().fillProfileProperties(new GameProfile(uuid, null), true); // } // }); // // public static void setSkin(GameProfile profile, UUID skinId) { // GameProfile skinProfile; // if (Bukkit.getPlayer(skinId) != null) { // skinProfile = getHandle(Bukkit.getPlayer(skinId)).getProfile(); // } else { // skinProfile = properties.getUnchecked(skinId); // } // if (skinProfile.getProperties().containsKey("textures")) { // profile.getProperties().removeAll("textures"); // profile.getProperties().putAll("textures", skinProfile.getProperties().get("textures")); // } else { // NPCLog.debug("Skin with uuid not found: " + skinId); // } // } // } // Path: nms-v1_9_R1/src/main/java/net/techcable/npclib/nms/versions/v1_9_R1/network/NPCConnection.java import lombok.*; import net.minecraft.server.v1_9_R1.EntityPlayer; import net.minecraft.server.v1_9_R1.Packet; import net.minecraft.server.v1_9_R1.PlayerConnection; import net.techcable.npclib.nms.versions.v1_9_R1.NMS; package net.techcable.npclib.nms.versions.v1_9_R1.network; @Getter public class NPCConnection extends PlayerConnection { public NPCConnection(EntityPlayer player) {
super(NMS.getServer(), new NPCNetworkManager(), player);
TechzoneMC/NPCLib
citizens/src/main/java/net/techcable/npclib/citizens/HumanCitizensNPC.java
// Path: api/src/main/java/net/techcable/npclib/Animation.java // @RequiredArgsConstructor // public enum Animation { // /** // * Makes the npc act hurt // * <p/> // * Only applicable to living entities // */ // HURT, // /** // * Makes the npc lie on the ground // * <p/> // * Only applicable to living entities // */ // DEAD, // // // Human Animations // // /** // * Makes the npc swing its arm // * <p/> // * Only applicable to human entities // */ // ARM_SWING(HumanNPC.class), // /** // * Makes the npc eat the item it is holding // * <p/> // * Only applicable to human entities // */ // EAT(HumanNPC.class), // /** // * A critical hit animation // * <p/> // * Only applicable to human entities // */ // CRITICAL(HumanNPC.class), // /** // * A 'magic' critical hit animation // * <p/> // * Only applicable to human entities // */ // MAGIC_CRITICAL(HumanNPC.class); // // // private final Class<? extends NPC> appliesTo; // // /** // * Get the type of npc this animation can be applied to // * // * @return the type of npc this animation can be applied to // */ // public Class<? extends NPC> getAppliesTo() { // return appliesTo; // } // // private Animation() { // this(LivingNPC.class); // } // } // // Path: api/src/main/java/net/techcable/npclib/HumanNPC.java // public interface HumanNPC extends LivingNPC { // // /** // * Return this npc's skin // * <p/> // * A value of null represents a steve skin // * // * @return this npc's skin // */ // public UUID getSkin(); // // /** // * Set the npc's skin // * <p/> // * A value of null represents a steve skin // * // * @param skin the player id with the skin you want // * // * @throws UnsupportedOperationException if skins aren't supported // */ // public void setSkin(UUID skin); // // /** // * Set the npc's skin // * <p/> // * A value of null represents a steve skin // * // * @param skin the player name with the skin you want // * // * @throws UnsupportedOperationException if skins aren't supported // */ // public void setSkin(String skin); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // @Override // public Player getEntity(); // // /** // * Set if the npc is shown in the tab list // * // * @param show whether or not to show this npc in the tab list // * // * @throws java.lang.IllegalStateException if the npcc is not spawned // */ // public void setShowInTabList(boolean show); // // /** // * Return if the npc is shown in the tab list // * // * @return true if the npc is shown in the tab list // */ // public boolean isShownInTabList(); // }
import java.util.UUID; import com.google.common.base.Preconditions; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.util.PlayerAnimation; import net.techcable.npclib.Animation; import net.techcable.npclib.HumanNPC; import org.bukkit.Bukkit; import org.bukkit.entity.Player;
public void setSkin(String skin) { Preconditions.checkNotNull(skin, "Skin is null"); // Hacky uuid load UUID id = Bukkit.getOfflinePlayer(skin).getUniqueId(); // If the uuid's variant is '3' than it must be an offline uuid Preconditions.checkArgument(id.variant() != 3, "Invalid player name %s", skin); setSkin(id); } @Override public Player getEntity() { if (super.getEntity() == null) return null; return (Player) super.getEntity(); } public static final String REMOVE_PLAYER_LIST_META = "removefromplayerlist"; @Override public void setShowInTabList(boolean show) { Preconditions.checkState(isSpawned(), "Can not set shown in tablist if not spawned"); getHandle().data().set(REMOVE_PLAYER_LIST_META, !show); } @Override public boolean isShownInTabList() { return !((Boolean) getHandle().data().get(REMOVE_PLAYER_LIST_META)); } @Override
// Path: api/src/main/java/net/techcable/npclib/Animation.java // @RequiredArgsConstructor // public enum Animation { // /** // * Makes the npc act hurt // * <p/> // * Only applicable to living entities // */ // HURT, // /** // * Makes the npc lie on the ground // * <p/> // * Only applicable to living entities // */ // DEAD, // // // Human Animations // // /** // * Makes the npc swing its arm // * <p/> // * Only applicable to human entities // */ // ARM_SWING(HumanNPC.class), // /** // * Makes the npc eat the item it is holding // * <p/> // * Only applicable to human entities // */ // EAT(HumanNPC.class), // /** // * A critical hit animation // * <p/> // * Only applicable to human entities // */ // CRITICAL(HumanNPC.class), // /** // * A 'magic' critical hit animation // * <p/> // * Only applicable to human entities // */ // MAGIC_CRITICAL(HumanNPC.class); // // // private final Class<? extends NPC> appliesTo; // // /** // * Get the type of npc this animation can be applied to // * // * @return the type of npc this animation can be applied to // */ // public Class<? extends NPC> getAppliesTo() { // return appliesTo; // } // // private Animation() { // this(LivingNPC.class); // } // } // // Path: api/src/main/java/net/techcable/npclib/HumanNPC.java // public interface HumanNPC extends LivingNPC { // // /** // * Return this npc's skin // * <p/> // * A value of null represents a steve skin // * // * @return this npc's skin // */ // public UUID getSkin(); // // /** // * Set the npc's skin // * <p/> // * A value of null represents a steve skin // * // * @param skin the player id with the skin you want // * // * @throws UnsupportedOperationException if skins aren't supported // */ // public void setSkin(UUID skin); // // /** // * Set the npc's skin // * <p/> // * A value of null represents a steve skin // * // * @param skin the player name with the skin you want // * // * @throws UnsupportedOperationException if skins aren't supported // */ // public void setSkin(String skin); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // @Override // public Player getEntity(); // // /** // * Set if the npc is shown in the tab list // * // * @param show whether or not to show this npc in the tab list // * // * @throws java.lang.IllegalStateException if the npcc is not spawned // */ // public void setShowInTabList(boolean show); // // /** // * Return if the npc is shown in the tab list // * // * @return true if the npc is shown in the tab list // */ // public boolean isShownInTabList(); // } // Path: citizens/src/main/java/net/techcable/npclib/citizens/HumanCitizensNPC.java import java.util.UUID; import com.google.common.base.Preconditions; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.util.PlayerAnimation; import net.techcable.npclib.Animation; import net.techcable.npclib.HumanNPC; import org.bukkit.Bukkit; import org.bukkit.entity.Player; public void setSkin(String skin) { Preconditions.checkNotNull(skin, "Skin is null"); // Hacky uuid load UUID id = Bukkit.getOfflinePlayer(skin).getUniqueId(); // If the uuid's variant is '3' than it must be an offline uuid Preconditions.checkArgument(id.variant() != 3, "Invalid player name %s", skin); setSkin(id); } @Override public Player getEntity() { if (super.getEntity() == null) return null; return (Player) super.getEntity(); } public static final String REMOVE_PLAYER_LIST_META = "removefromplayerlist"; @Override public void setShowInTabList(boolean show) { Preconditions.checkState(isSpawned(), "Can not set shown in tablist if not spawned"); getHandle().data().set(REMOVE_PLAYER_LIST_META, !show); } @Override public boolean isShownInTabList() { return !((Boolean) getHandle().data().get(REMOVE_PLAYER_LIST_META)); } @Override
public void animate(Animation animation) {
TechzoneMC/NPCLib
nms/src/main/java/net/techcable/npclib/nms/NMSLivingNPC.java
// Path: api/src/main/java/net/techcable/npclib/Animation.java // @RequiredArgsConstructor // public enum Animation { // /** // * Makes the npc act hurt // * <p/> // * Only applicable to living entities // */ // HURT, // /** // * Makes the npc lie on the ground // * <p/> // * Only applicable to living entities // */ // DEAD, // // // Human Animations // // /** // * Makes the npc swing its arm // * <p/> // * Only applicable to human entities // */ // ARM_SWING(HumanNPC.class), // /** // * Makes the npc eat the item it is holding // * <p/> // * Only applicable to human entities // */ // EAT(HumanNPC.class), // /** // * A critical hit animation // * <p/> // * Only applicable to human entities // */ // CRITICAL(HumanNPC.class), // /** // * A 'magic' critical hit animation // * <p/> // * Only applicable to human entities // */ // MAGIC_CRITICAL(HumanNPC.class); // // // private final Class<? extends NPC> appliesTo; // // /** // * Get the type of npc this animation can be applied to // * // * @return the type of npc this animation can be applied to // */ // public Class<? extends NPC> getAppliesTo() { // return appliesTo; // } // // private Animation() { // this(LivingNPC.class); // } // } // // Path: api/src/main/java/net/techcable/npclib/LivingNPC.java // public interface LivingNPC extends NPC { // // /** // * Set the current name of the npc // * // * @param name the new name // */ // public void setName(String name); // // /** // * Retrieve the name of this npc // * // * @return this npc's name // */ // public String getName(); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // @Override // public LivingEntity getEntity(); // // /** // * The npc's head will look in this direction // * // * @param toFace the direction to look // */ // public void faceLocation(Location toFace); // // /** // * Returns if the npc is an a condition to walk // * // * @return if the npc is an a condition to walk // */ // public boolean isAbleToWalk(); // // /** // * Walk to the specified location // * // * @param l the location to walk to // * // * @throws java.lang.IllegalStateException if not in a condition to walk // * @throws PathNotFoundException if the NPC could not walk to the specified location // * @throws NullPointerException if the location is null // */ // public void walkTo(Location l) throws PathNotFoundException; // // /** // * Play the specified animation to all clients // * // * @param animation the animation to play // * // * @throws java.lang.IllegalArgumentException if the annotation can't be played on this type of npc // * @throws java.lang.IllegalStateException if the npc is not spawned // * @throws java.lang.UnsupportedOperationException if this implementation doesn't support the specified animation // */ // public void animate(Animation animation); // // } // // Path: api/src/main/java/net/techcable/npclib/PathNotFoundException.java // public class PathNotFoundException extends Exception { // public PathNotFoundException(Location to, Location from) { // super(String.format("Could not find a path to %s, %s, %s from %s, %s, %s", to.getX(), to.getY(), to.getZ(), from.getX(), from.getY(), from.getZ())); // } // } // // Path: api/src/main/java/net/techcable/npclib/ai/AITask.java // public interface AITask { // // /** // * Run this task in the given ai environment // * // * @param environment the ai environment // */ // public void tick(AIEnvironment environment); // } // // Path: nms/src/main/java/net/techcable/npclib/nms/ai/NMSAIEnvironment.java // public class NMSAIEnvironment extends AIEnvironment { // // private final NMSNPC npc; // // public NMSAIEnvironment(final NMSNPC npc) { // this.npc = npc; // new BukkitRunnable() { // // @Override // public void run() { // if (npc.isDestroyed()) cancel(); // if (!npc.isSpawned()) return; // tick(); // } // }.runTaskTimer(npc.getRegistry().getPlugin(), 0, 1); // } // }
import lombok.*; import java.util.UUID; import net.techcable.npclib.Animation; import net.techcable.npclib.LivingNPC; import net.techcable.npclib.PathNotFoundException; import net.techcable.npclib.ai.AITask; import net.techcable.npclib.nms.ai.NMSAIEnvironment; import org.bukkit.Location; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import com.google.common.base.Preconditions;
package net.techcable.npclib.nms; public abstract class NMSLivingNPC<T extends ILivingNPCHook> extends NMSNPC<T> implements LivingNPC { private final EntityType entityType; public NMSLivingNPC(NMSRegistry registry, UUID id, String name, EntityType entityType) { super(registry, id, name); this.entityType = entityType; } @Override public void setName(String s) { super.setName(s); if (isSpawned()) getHook().setName(s); } @Override public LivingEntity getEntity() { return (LivingEntity) super.getEntity(); } @Override
// Path: api/src/main/java/net/techcable/npclib/Animation.java // @RequiredArgsConstructor // public enum Animation { // /** // * Makes the npc act hurt // * <p/> // * Only applicable to living entities // */ // HURT, // /** // * Makes the npc lie on the ground // * <p/> // * Only applicable to living entities // */ // DEAD, // // // Human Animations // // /** // * Makes the npc swing its arm // * <p/> // * Only applicable to human entities // */ // ARM_SWING(HumanNPC.class), // /** // * Makes the npc eat the item it is holding // * <p/> // * Only applicable to human entities // */ // EAT(HumanNPC.class), // /** // * A critical hit animation // * <p/> // * Only applicable to human entities // */ // CRITICAL(HumanNPC.class), // /** // * A 'magic' critical hit animation // * <p/> // * Only applicable to human entities // */ // MAGIC_CRITICAL(HumanNPC.class); // // // private final Class<? extends NPC> appliesTo; // // /** // * Get the type of npc this animation can be applied to // * // * @return the type of npc this animation can be applied to // */ // public Class<? extends NPC> getAppliesTo() { // return appliesTo; // } // // private Animation() { // this(LivingNPC.class); // } // } // // Path: api/src/main/java/net/techcable/npclib/LivingNPC.java // public interface LivingNPC extends NPC { // // /** // * Set the current name of the npc // * // * @param name the new name // */ // public void setName(String name); // // /** // * Retrieve the name of this npc // * // * @return this npc's name // */ // public String getName(); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // @Override // public LivingEntity getEntity(); // // /** // * The npc's head will look in this direction // * // * @param toFace the direction to look // */ // public void faceLocation(Location toFace); // // /** // * Returns if the npc is an a condition to walk // * // * @return if the npc is an a condition to walk // */ // public boolean isAbleToWalk(); // // /** // * Walk to the specified location // * // * @param l the location to walk to // * // * @throws java.lang.IllegalStateException if not in a condition to walk // * @throws PathNotFoundException if the NPC could not walk to the specified location // * @throws NullPointerException if the location is null // */ // public void walkTo(Location l) throws PathNotFoundException; // // /** // * Play the specified animation to all clients // * // * @param animation the animation to play // * // * @throws java.lang.IllegalArgumentException if the annotation can't be played on this type of npc // * @throws java.lang.IllegalStateException if the npc is not spawned // * @throws java.lang.UnsupportedOperationException if this implementation doesn't support the specified animation // */ // public void animate(Animation animation); // // } // // Path: api/src/main/java/net/techcable/npclib/PathNotFoundException.java // public class PathNotFoundException extends Exception { // public PathNotFoundException(Location to, Location from) { // super(String.format("Could not find a path to %s, %s, %s from %s, %s, %s", to.getX(), to.getY(), to.getZ(), from.getX(), from.getY(), from.getZ())); // } // } // // Path: api/src/main/java/net/techcable/npclib/ai/AITask.java // public interface AITask { // // /** // * Run this task in the given ai environment // * // * @param environment the ai environment // */ // public void tick(AIEnvironment environment); // } // // Path: nms/src/main/java/net/techcable/npclib/nms/ai/NMSAIEnvironment.java // public class NMSAIEnvironment extends AIEnvironment { // // private final NMSNPC npc; // // public NMSAIEnvironment(final NMSNPC npc) { // this.npc = npc; // new BukkitRunnable() { // // @Override // public void run() { // if (npc.isDestroyed()) cancel(); // if (!npc.isSpawned()) return; // tick(); // } // }.runTaskTimer(npc.getRegistry().getPlugin(), 0, 1); // } // } // Path: nms/src/main/java/net/techcable/npclib/nms/NMSLivingNPC.java import lombok.*; import java.util.UUID; import net.techcable.npclib.Animation; import net.techcable.npclib.LivingNPC; import net.techcable.npclib.PathNotFoundException; import net.techcable.npclib.ai.AITask; import net.techcable.npclib.nms.ai.NMSAIEnvironment; import org.bukkit.Location; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import com.google.common.base.Preconditions; package net.techcable.npclib.nms; public abstract class NMSLivingNPC<T extends ILivingNPCHook> extends NMSNPC<T> implements LivingNPC { private final EntityType entityType; public NMSLivingNPC(NMSRegistry registry, UUID id, String name, EntityType entityType) { super(registry, id, name); this.entityType = entityType; } @Override public void setName(String s) { super.setName(s); if (isSpawned()) getHook().setName(s); } @Override public LivingEntity getEntity() { return (LivingEntity) super.getEntity(); } @Override
public void walkTo(Location l) throws PathNotFoundException {
TechzoneMC/NPCLib
nms-v1_8_R3/src/main/java/net/techcable/npclib/nms/versions/v1_8_R3/NPCHook.java
// Path: api/src/main/java/net/techcable/npclib/NPC.java // public interface NPC { // // /** // * Despawn this npc // * <p/> // * Once despawned it can not be respawned // * It will be deregistered from the registry // * // * @return true if was able to despawn // * // * @throws java.lang.IllegalStateException if the npc is already despawned // */ // public void despawn(); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // public Entity getEntity(); // // /** // * Get this npc's uuid // * // * @return the uuid of this npc // */ // public UUID getUUID(); // // /** // * Returns whether the npc is spawned // * // * @return true if the npc is spawned // */ // public boolean isSpawned(); // // /** // * Returns whether the npc has been destroyed // * <p> // * NPCs that are destroyed can never be respawned // * </p> // * // * @return true if the npc has been destroyed // */ // public boolean isDestroyed(); // // /** // * Spawn this npc // * // * @param toSpawn location to spawn this npc // * // * @return true if the npc was able to spawn // * // * @throws java.lang.NullPointerException if location is null // * @throws java.lang.IllegalArgumentException if already or spawned or {@link #despawn()} has been called // */ // public void spawn(Location toSpawn); // // /** // * Set the protected status of this NPC // * true by default // * // * @param protect whether or not this npc is invincible // */ // public void setProtected(boolean protect); // // /** // * Check if the NPC is protected from damage // * // * @return The protected status of the NPC // */ // public boolean isProtected(); // // /** // * Add the specified task to the npc // * // * @param task the task to add // */ // public void addTask(AITask task); // // /** // * Get the npc's ai environment // * <p> // * The ai environment manages the npc's ai // * </p> // * // * @return the npc's ai environment // */ // public AIEnvironment getAIEnvironment(); // // } // // Path: api/src/main/java/net/techcable/npclib/nms/INPCHook.java // public interface INPCHook { // // public void onDespawn(); // // public Entity getEntity(); // }
import lombok.*; import net.minecraft.server.v1_8_R3.Entity; import net.techcable.npclib.NPC; import net.techcable.npclib.nms.INPCHook;
package net.techcable.npclib.nms.versions.v1_8_R3; @Getter @RequiredArgsConstructor
// Path: api/src/main/java/net/techcable/npclib/NPC.java // public interface NPC { // // /** // * Despawn this npc // * <p/> // * Once despawned it can not be respawned // * It will be deregistered from the registry // * // * @return true if was able to despawn // * // * @throws java.lang.IllegalStateException if the npc is already despawned // */ // public void despawn(); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // public Entity getEntity(); // // /** // * Get this npc's uuid // * // * @return the uuid of this npc // */ // public UUID getUUID(); // // /** // * Returns whether the npc is spawned // * // * @return true if the npc is spawned // */ // public boolean isSpawned(); // // /** // * Returns whether the npc has been destroyed // * <p> // * NPCs that are destroyed can never be respawned // * </p> // * // * @return true if the npc has been destroyed // */ // public boolean isDestroyed(); // // /** // * Spawn this npc // * // * @param toSpawn location to spawn this npc // * // * @return true if the npc was able to spawn // * // * @throws java.lang.NullPointerException if location is null // * @throws java.lang.IllegalArgumentException if already or spawned or {@link #despawn()} has been called // */ // public void spawn(Location toSpawn); // // /** // * Set the protected status of this NPC // * true by default // * // * @param protect whether or not this npc is invincible // */ // public void setProtected(boolean protect); // // /** // * Check if the NPC is protected from damage // * // * @return The protected status of the NPC // */ // public boolean isProtected(); // // /** // * Add the specified task to the npc // * // * @param task the task to add // */ // public void addTask(AITask task); // // /** // * Get the npc's ai environment // * <p> // * The ai environment manages the npc's ai // * </p> // * // * @return the npc's ai environment // */ // public AIEnvironment getAIEnvironment(); // // } // // Path: api/src/main/java/net/techcable/npclib/nms/INPCHook.java // public interface INPCHook { // // public void onDespawn(); // // public Entity getEntity(); // } // Path: nms-v1_8_R3/src/main/java/net/techcable/npclib/nms/versions/v1_8_R3/NPCHook.java import lombok.*; import net.minecraft.server.v1_8_R3.Entity; import net.techcable.npclib.NPC; import net.techcable.npclib.nms.INPCHook; package net.techcable.npclib.nms.versions.v1_8_R3; @Getter @RequiredArgsConstructor
public class NPCHook implements INPCHook {
TechzoneMC/NPCLib
nms-v1_8_R3/src/main/java/net/techcable/npclib/nms/versions/v1_8_R3/NPCHook.java
// Path: api/src/main/java/net/techcable/npclib/NPC.java // public interface NPC { // // /** // * Despawn this npc // * <p/> // * Once despawned it can not be respawned // * It will be deregistered from the registry // * // * @return true if was able to despawn // * // * @throws java.lang.IllegalStateException if the npc is already despawned // */ // public void despawn(); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // public Entity getEntity(); // // /** // * Get this npc's uuid // * // * @return the uuid of this npc // */ // public UUID getUUID(); // // /** // * Returns whether the npc is spawned // * // * @return true if the npc is spawned // */ // public boolean isSpawned(); // // /** // * Returns whether the npc has been destroyed // * <p> // * NPCs that are destroyed can never be respawned // * </p> // * // * @return true if the npc has been destroyed // */ // public boolean isDestroyed(); // // /** // * Spawn this npc // * // * @param toSpawn location to spawn this npc // * // * @return true if the npc was able to spawn // * // * @throws java.lang.NullPointerException if location is null // * @throws java.lang.IllegalArgumentException if already or spawned or {@link #despawn()} has been called // */ // public void spawn(Location toSpawn); // // /** // * Set the protected status of this NPC // * true by default // * // * @param protect whether or not this npc is invincible // */ // public void setProtected(boolean protect); // // /** // * Check if the NPC is protected from damage // * // * @return The protected status of the NPC // */ // public boolean isProtected(); // // /** // * Add the specified task to the npc // * // * @param task the task to add // */ // public void addTask(AITask task); // // /** // * Get the npc's ai environment // * <p> // * The ai environment manages the npc's ai // * </p> // * // * @return the npc's ai environment // */ // public AIEnvironment getAIEnvironment(); // // } // // Path: api/src/main/java/net/techcable/npclib/nms/INPCHook.java // public interface INPCHook { // // public void onDespawn(); // // public Entity getEntity(); // }
import lombok.*; import net.minecraft.server.v1_8_R3.Entity; import net.techcable.npclib.NPC; import net.techcable.npclib.nms.INPCHook;
package net.techcable.npclib.nms.versions.v1_8_R3; @Getter @RequiredArgsConstructor public class NPCHook implements INPCHook {
// Path: api/src/main/java/net/techcable/npclib/NPC.java // public interface NPC { // // /** // * Despawn this npc // * <p/> // * Once despawned it can not be respawned // * It will be deregistered from the registry // * // * @return true if was able to despawn // * // * @throws java.lang.IllegalStateException if the npc is already despawned // */ // public void despawn(); // // /** // * Get the nmsEntity associated with this npc // * // * @return the nmsEntity // */ // public Entity getEntity(); // // /** // * Get this npc's uuid // * // * @return the uuid of this npc // */ // public UUID getUUID(); // // /** // * Returns whether the npc is spawned // * // * @return true if the npc is spawned // */ // public boolean isSpawned(); // // /** // * Returns whether the npc has been destroyed // * <p> // * NPCs that are destroyed can never be respawned // * </p> // * // * @return true if the npc has been destroyed // */ // public boolean isDestroyed(); // // /** // * Spawn this npc // * // * @param toSpawn location to spawn this npc // * // * @return true if the npc was able to spawn // * // * @throws java.lang.NullPointerException if location is null // * @throws java.lang.IllegalArgumentException if already or spawned or {@link #despawn()} has been called // */ // public void spawn(Location toSpawn); // // /** // * Set the protected status of this NPC // * true by default // * // * @param protect whether or not this npc is invincible // */ // public void setProtected(boolean protect); // // /** // * Check if the NPC is protected from damage // * // * @return The protected status of the NPC // */ // public boolean isProtected(); // // /** // * Add the specified task to the npc // * // * @param task the task to add // */ // public void addTask(AITask task); // // /** // * Get the npc's ai environment // * <p> // * The ai environment manages the npc's ai // * </p> // * // * @return the npc's ai environment // */ // public AIEnvironment getAIEnvironment(); // // } // // Path: api/src/main/java/net/techcable/npclib/nms/INPCHook.java // public interface INPCHook { // // public void onDespawn(); // // public Entity getEntity(); // } // Path: nms-v1_8_R3/src/main/java/net/techcable/npclib/nms/versions/v1_8_R3/NPCHook.java import lombok.*; import net.minecraft.server.v1_8_R3.Entity; import net.techcable.npclib.NPC; import net.techcable.npclib.nms.INPCHook; package net.techcable.npclib.nms.versions.v1_8_R3; @Getter @RequiredArgsConstructor public class NPCHook implements INPCHook {
private final NPC npc;
TechzoneMC/NPCLib
nms-v1_8_R3/src/main/java/net/techcable/npclib/nms/versions/v1_8_R3/network/NPCConnection.java
// Path: nms-v1_8_R3/src/main/java/net/techcable/npclib/nms/versions/v1_8_R3/NMS.java // public class NMS implements net.techcable.npclib.nms.NMS { // // private static NMS instance; // // public NMS() { // if (instance == null) instance = this; // } // // public static NMS getInstance() { // return instance; // } // // // @Override // public IHumanNPCHook spawnHumanNPC(Location toSpawn, HumanNPC npc) { // return new HumanNPCHook(npc, toSpawn); // } // // @Override // public void onJoin(Player joined, Collection<? extends NPC> npcs) { // for (NPC npc : npcs) { // if (!(npc instanceof HumanNPC)) continue; // HumanNPCHook hook = getHook((HumanNPC) npc); // if (hook == null) continue; // hook.onJoin(joined); // } // } // // // UTILS // public static final String NO_CRAFTBUKKIT_MSG = "Non-CraftBukkit implementations are unsupported"; // // public static EntityPlayer getHandle(Player player) { // if (!(player instanceof CraftPlayer)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftPlayer) player).getHandle(); // } // // public static EntityLiving getHandle(LivingEntity player) { // if (!(player instanceof CraftLivingEntity)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftLivingEntity) player).getHandle(); // } // // public static MinecraftServer getServer() { // Server server = Bukkit.getServer(); // if (!(server instanceof CraftServer)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftServer) server).getServer(); // } // // public static WorldServer getHandle(World world) { // if (!(world instanceof CraftWorld)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftWorld) world).getHandle(); // } // // public static HumanNPCHook getHook(HumanNPC npc) { // EntityPlayer player = getHandle(npc.getEntity()); // if (player instanceof EntityNPCPlayer) return null; // return ((EntityNPCPlayer) player).getHook(); // } // // public static LivingNPCHook getHook(LivingNPC npc) { // if (npc instanceof HumanNPC) return getHook((HumanNPC) npc); // EntityLiving entity = getHandle(npc.getEntity()); // if (entity instanceof LivingHookable) return ((LivingHookable) entity).getHook(); // return null; // } // // public static void sendToAll(Packet packet) { // for (Player p : Bukkit.getOnlinePlayers()) { // getHandle(p).playerConnection.sendPacket(packet); // } // } // // private static final LoadingCache<UUID, GameProfile> properties = CacheBuilder.newBuilder() // .expireAfterAccess(5, TimeUnit.MINUTES) // .build(new CacheLoader<UUID, GameProfile>() { // // @Override // public GameProfile load(UUID uuid) throws Exception { // return MinecraftServer.getServer().aD().fillProfileProperties(new GameProfile(uuid, null), true); // } // }); // // public static void setSkin(GameProfile profile, UUID skinId) { // GameProfile skinProfile; // if (Bukkit.getPlayer(skinId) != null) { // skinProfile = getHandle(Bukkit.getPlayer(skinId)).getProfile(); // } else { // skinProfile = properties.getUnchecked(skinId); // } // if (skinProfile.getProperties().containsKey("textures")) { // profile.getProperties().removeAll("textures"); // profile.getProperties().putAll("textures", skinProfile.getProperties().get("textures")); // } else { // NPCLog.debug("Skin with uuid not found: " + skinId); // } // } // }
import lombok.*; import net.minecraft.server.v1_8_R3.EntityPlayer; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PlayerConnection; import net.techcable.npclib.nms.versions.v1_8_R3.NMS;
package net.techcable.npclib.nms.versions.v1_8_R3.network; @Getter public class NPCConnection extends PlayerConnection { public NPCConnection(EntityPlayer player) {
// Path: nms-v1_8_R3/src/main/java/net/techcable/npclib/nms/versions/v1_8_R3/NMS.java // public class NMS implements net.techcable.npclib.nms.NMS { // // private static NMS instance; // // public NMS() { // if (instance == null) instance = this; // } // // public static NMS getInstance() { // return instance; // } // // // @Override // public IHumanNPCHook spawnHumanNPC(Location toSpawn, HumanNPC npc) { // return new HumanNPCHook(npc, toSpawn); // } // // @Override // public void onJoin(Player joined, Collection<? extends NPC> npcs) { // for (NPC npc : npcs) { // if (!(npc instanceof HumanNPC)) continue; // HumanNPCHook hook = getHook((HumanNPC) npc); // if (hook == null) continue; // hook.onJoin(joined); // } // } // // // UTILS // public static final String NO_CRAFTBUKKIT_MSG = "Non-CraftBukkit implementations are unsupported"; // // public static EntityPlayer getHandle(Player player) { // if (!(player instanceof CraftPlayer)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftPlayer) player).getHandle(); // } // // public static EntityLiving getHandle(LivingEntity player) { // if (!(player instanceof CraftLivingEntity)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftLivingEntity) player).getHandle(); // } // // public static MinecraftServer getServer() { // Server server = Bukkit.getServer(); // if (!(server instanceof CraftServer)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftServer) server).getServer(); // } // // public static WorldServer getHandle(World world) { // if (!(world instanceof CraftWorld)) throw new UnsupportedOperationException(NO_CRAFTBUKKIT_MSG); // return ((CraftWorld) world).getHandle(); // } // // public static HumanNPCHook getHook(HumanNPC npc) { // EntityPlayer player = getHandle(npc.getEntity()); // if (player instanceof EntityNPCPlayer) return null; // return ((EntityNPCPlayer) player).getHook(); // } // // public static LivingNPCHook getHook(LivingNPC npc) { // if (npc instanceof HumanNPC) return getHook((HumanNPC) npc); // EntityLiving entity = getHandle(npc.getEntity()); // if (entity instanceof LivingHookable) return ((LivingHookable) entity).getHook(); // return null; // } // // public static void sendToAll(Packet packet) { // for (Player p : Bukkit.getOnlinePlayers()) { // getHandle(p).playerConnection.sendPacket(packet); // } // } // // private static final LoadingCache<UUID, GameProfile> properties = CacheBuilder.newBuilder() // .expireAfterAccess(5, TimeUnit.MINUTES) // .build(new CacheLoader<UUID, GameProfile>() { // // @Override // public GameProfile load(UUID uuid) throws Exception { // return MinecraftServer.getServer().aD().fillProfileProperties(new GameProfile(uuid, null), true); // } // }); // // public static void setSkin(GameProfile profile, UUID skinId) { // GameProfile skinProfile; // if (Bukkit.getPlayer(skinId) != null) { // skinProfile = getHandle(Bukkit.getPlayer(skinId)).getProfile(); // } else { // skinProfile = properties.getUnchecked(skinId); // } // if (skinProfile.getProperties().containsKey("textures")) { // profile.getProperties().removeAll("textures"); // profile.getProperties().putAll("textures", skinProfile.getProperties().get("textures")); // } else { // NPCLog.debug("Skin with uuid not found: " + skinId); // } // } // } // Path: nms-v1_8_R3/src/main/java/net/techcable/npclib/nms/versions/v1_8_R3/network/NPCConnection.java import lombok.*; import net.minecraft.server.v1_8_R3.EntityPlayer; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PlayerConnection; import net.techcable.npclib.nms.versions.v1_8_R3.NMS; package net.techcable.npclib.nms.versions.v1_8_R3.network; @Getter public class NPCConnection extends PlayerConnection { public NPCConnection(EntityPlayer player) {
super(NMS.getServer(), new NPCNetworkManager(), player);
TechzoneMC/NPCLib
nms-v1_8_R2/src/main/java/net/techcable/npclib/nms/versions/v1_8_R2/network/NPCNetworkManager.java
// Path: api/src/main/java/net/techcable/npclib/utils/Reflection.java // public class Reflection { // // public static Class<?> getNmsClass(String name) { // String className = "net.minecraft.server." + getVersion() + "." + name; // return getClass(className); // } // // public static Class<?> getCbClass(String name) { // String className = "org.bukkit.craftbukkit." + getVersion() + "." + name; // return getClass(className); // } // // public static Class<?> getUtilClass(String name) { // try { // return Class.forName(name); //Try before 1.8 first // } catch (ClassNotFoundException ex) { // try { // return Class.forName("net.minecraft.util." + name); //Not 1.8 // } catch (ClassNotFoundException ex2) { // return null; // } // } // } // // public static String getVersion() { // String packageName = Bukkit.getServer().getClass().getPackage().getName(); // return packageName.substring(packageName.lastIndexOf('.') + 1); // } // // public static Object getHandle(Object wrapper) { // Method getHandle = makeMethod(wrapper.getClass(), "getHandle"); // return callMethod(getHandle, wrapper); // } // // //Utils // public static Method makeMethod(Class<?> clazz, String methodName, Class<?>... paramaters) { // try { // return clazz.getDeclaredMethod(methodName, paramaters); // } catch (NoSuchMethodException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> T callMethod(Method method, Object instance, Object... paramaters) { // if (method == null) throw new RuntimeException("No such method"); // method.setAccessible(true); // try { // return (T) method.invoke(instance, paramaters); // } catch (InvocationTargetException ex) { // throw new RuntimeException(ex.getCause()); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> Constructor<T> makeConstructor(Class<?> clazz, Class<?>... paramaterTypes) { // try { // return (Constructor<T>) clazz.getConstructor(paramaterTypes); // } catch (NoSuchMethodException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static <T> T callConstructor(Constructor<T> constructor, Object... paramaters) { // if (constructor == null) throw new RuntimeException("No such constructor"); // constructor.setAccessible(true); // try { // return (T) constructor.newInstance(paramaters); // } catch (InvocationTargetException ex) { // throw new RuntimeException(ex.getCause()); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static Field makeField(Class<?> clazz, String name) { // try { // return clazz.getDeclaredField(name); // } catch (NoSuchFieldException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> T getField(Field field, Object instance) { // if (field == null) throw new RuntimeException("No such field"); // field.setAccessible(true); // try { // return (T) field.get(instance); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static void setField(Field field, Object instance, Object value) { // if (field == null) throw new RuntimeException("No such field"); // field.setAccessible(true); // try { // field.set(instance, value); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static Class<?> getClass(String name) { // try { // return Class.forName(name); // } catch (ClassNotFoundException ex) { // return null; // } // } // // public static <T> Class<? extends T> getClass(String name, Class<T> superClass) { // try { // return Class.forName(name).asSubclass(superClass); // } catch (ClassCastException | ClassNotFoundException ex) { // return null; // } // } // }
import lombok.*; import java.lang.reflect.Field; import net.minecraft.server.v1_8_R2.EnumProtocolDirection; import net.minecraft.server.v1_8_R2.NetworkManager; import net.techcable.npclib.utils.Reflection;
package net.techcable.npclib.nms.versions.v1_8_R2.network; @Getter public class NPCNetworkManager extends NetworkManager { public NPCNetworkManager() { super(EnumProtocolDirection.CLIENTBOUND); //MCP = isClientSide ---- SRG=field_150747_h
// Path: api/src/main/java/net/techcable/npclib/utils/Reflection.java // public class Reflection { // // public static Class<?> getNmsClass(String name) { // String className = "net.minecraft.server." + getVersion() + "." + name; // return getClass(className); // } // // public static Class<?> getCbClass(String name) { // String className = "org.bukkit.craftbukkit." + getVersion() + "." + name; // return getClass(className); // } // // public static Class<?> getUtilClass(String name) { // try { // return Class.forName(name); //Try before 1.8 first // } catch (ClassNotFoundException ex) { // try { // return Class.forName("net.minecraft.util." + name); //Not 1.8 // } catch (ClassNotFoundException ex2) { // return null; // } // } // } // // public static String getVersion() { // String packageName = Bukkit.getServer().getClass().getPackage().getName(); // return packageName.substring(packageName.lastIndexOf('.') + 1); // } // // public static Object getHandle(Object wrapper) { // Method getHandle = makeMethod(wrapper.getClass(), "getHandle"); // return callMethod(getHandle, wrapper); // } // // //Utils // public static Method makeMethod(Class<?> clazz, String methodName, Class<?>... paramaters) { // try { // return clazz.getDeclaredMethod(methodName, paramaters); // } catch (NoSuchMethodException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> T callMethod(Method method, Object instance, Object... paramaters) { // if (method == null) throw new RuntimeException("No such method"); // method.setAccessible(true); // try { // return (T) method.invoke(instance, paramaters); // } catch (InvocationTargetException ex) { // throw new RuntimeException(ex.getCause()); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> Constructor<T> makeConstructor(Class<?> clazz, Class<?>... paramaterTypes) { // try { // return (Constructor<T>) clazz.getConstructor(paramaterTypes); // } catch (NoSuchMethodException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static <T> T callConstructor(Constructor<T> constructor, Object... paramaters) { // if (constructor == null) throw new RuntimeException("No such constructor"); // constructor.setAccessible(true); // try { // return (T) constructor.newInstance(paramaters); // } catch (InvocationTargetException ex) { // throw new RuntimeException(ex.getCause()); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static Field makeField(Class<?> clazz, String name) { // try { // return clazz.getDeclaredField(name); // } catch (NoSuchFieldException ex) { // return null; // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // @SuppressWarnings("unchecked") // public static <T> T getField(Field field, Object instance) { // if (field == null) throw new RuntimeException("No such field"); // field.setAccessible(true); // try { // return (T) field.get(instance); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static void setField(Field field, Object instance, Object value) { // if (field == null) throw new RuntimeException("No such field"); // field.setAccessible(true); // try { // field.set(instance, value); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public static Class<?> getClass(String name) { // try { // return Class.forName(name); // } catch (ClassNotFoundException ex) { // return null; // } // } // // public static <T> Class<? extends T> getClass(String name, Class<T> superClass) { // try { // return Class.forName(name).asSubclass(superClass); // } catch (ClassCastException | ClassNotFoundException ex) { // return null; // } // } // } // Path: nms-v1_8_R2/src/main/java/net/techcable/npclib/nms/versions/v1_8_R2/network/NPCNetworkManager.java import lombok.*; import java.lang.reflect.Field; import net.minecraft.server.v1_8_R2.EnumProtocolDirection; import net.minecraft.server.v1_8_R2.NetworkManager; import net.techcable.npclib.utils.Reflection; package net.techcable.npclib.nms.versions.v1_8_R2.network; @Getter public class NPCNetworkManager extends NetworkManager { public NPCNetworkManager() { super(EnumProtocolDirection.CLIENTBOUND); //MCP = isClientSide ---- SRG=field_150747_h
Field channel = Reflection.makeField(NetworkManager.class, "k"); //MCP = channel ---- SRG=field_150746_k