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 |
|---|---|---|---|---|---|---|
vclub/A-Native-TesterHome | app/src/main/java/com/testerhome/nativeandroid/networks/TopicsService.java | // Path: app/src/main/java/com/testerhome/nativeandroid/models/NotificationResponse.java
// public class NotificationResponse {
//
// private List<NotificationEntity> notifications;
//
// public List<NotificationEntity> getNotifications(){
// return notifications;
// }
//
// public void setNotifications(List<NotificationEntity> notifications){
// this.notifications = notifications;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicDetailResponse.java
// public class TopicDetailResponse {
// private TopicDetailEntity topic;
//
// public TopicDetailEntity getTopic() {
// return topic;
// }
//
// public void setTopic(TopicDetailEntity topic) {
// this.topic = topic;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicReplyResponse.java
// public class TopicReplyResponse {
//
// private List<TopicReplyEntity> replies;
//
// public List<TopicReplyEntity> getTopicReply(){
// return replies;
// }
//
// public void setTopicReply(List<TopicReplyEntity> replies){
// this.replies = replies;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicsResponse.java
// public class TopicsResponse {
//
// private List<TopicEntity> topics;
//
// public List<TopicEntity> getTopics() {
// return topics;
// }
//
// public void setTopics(List<TopicEntity> topics) {
// this.topics = topics;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/UserResponse.java
// public class UserResponse {
//
// private TesterUser user;
//
// public TesterUser getUser() {
// return user;
// }
//
// public void setUser(TesterUser user) {
// this.user = user;
// }
// }
| import com.testerhome.nativeandroid.models.NotificationResponse;
import com.testerhome.nativeandroid.models.TopicDetailResponse;
import com.testerhome.nativeandroid.models.TopicReplyResponse;
import com.testerhome.nativeandroid.models.TopicsResponse;
import com.testerhome.nativeandroid.models.UserResponse;
import retrofit.Callback;
import retrofit.client.Response;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query; | package com.testerhome.nativeandroid.networks;
/**
* Created by Bin Li on 2015/9/15.
*/
public interface TopicsService {
@GET("/topics.json")
void getTopicsByType(@Query("type") String type,
@Query("offset") int offset, | // Path: app/src/main/java/com/testerhome/nativeandroid/models/NotificationResponse.java
// public class NotificationResponse {
//
// private List<NotificationEntity> notifications;
//
// public List<NotificationEntity> getNotifications(){
// return notifications;
// }
//
// public void setNotifications(List<NotificationEntity> notifications){
// this.notifications = notifications;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicDetailResponse.java
// public class TopicDetailResponse {
// private TopicDetailEntity topic;
//
// public TopicDetailEntity getTopic() {
// return topic;
// }
//
// public void setTopic(TopicDetailEntity topic) {
// this.topic = topic;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicReplyResponse.java
// public class TopicReplyResponse {
//
// private List<TopicReplyEntity> replies;
//
// public List<TopicReplyEntity> getTopicReply(){
// return replies;
// }
//
// public void setTopicReply(List<TopicReplyEntity> replies){
// this.replies = replies;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicsResponse.java
// public class TopicsResponse {
//
// private List<TopicEntity> topics;
//
// public List<TopicEntity> getTopics() {
// return topics;
// }
//
// public void setTopics(List<TopicEntity> topics) {
// this.topics = topics;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/UserResponse.java
// public class UserResponse {
//
// private TesterUser user;
//
// public TesterUser getUser() {
// return user;
// }
//
// public void setUser(TesterUser user) {
// this.user = user;
// }
// }
// Path: app/src/main/java/com/testerhome/nativeandroid/networks/TopicsService.java
import com.testerhome.nativeandroid.models.NotificationResponse;
import com.testerhome.nativeandroid.models.TopicDetailResponse;
import com.testerhome.nativeandroid.models.TopicReplyResponse;
import com.testerhome.nativeandroid.models.TopicsResponse;
import com.testerhome.nativeandroid.models.UserResponse;
import retrofit.Callback;
import retrofit.client.Response;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query;
package com.testerhome.nativeandroid.networks;
/**
* Created by Bin Li on 2015/9/15.
*/
public interface TopicsService {
@GET("/topics.json")
void getTopicsByType(@Query("type") String type,
@Query("offset") int offset, | Callback<TopicsResponse> callback); |
vclub/A-Native-TesterHome | app/src/main/java/com/testerhome/nativeandroid/networks/TopicsService.java | // Path: app/src/main/java/com/testerhome/nativeandroid/models/NotificationResponse.java
// public class NotificationResponse {
//
// private List<NotificationEntity> notifications;
//
// public List<NotificationEntity> getNotifications(){
// return notifications;
// }
//
// public void setNotifications(List<NotificationEntity> notifications){
// this.notifications = notifications;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicDetailResponse.java
// public class TopicDetailResponse {
// private TopicDetailEntity topic;
//
// public TopicDetailEntity getTopic() {
// return topic;
// }
//
// public void setTopic(TopicDetailEntity topic) {
// this.topic = topic;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicReplyResponse.java
// public class TopicReplyResponse {
//
// private List<TopicReplyEntity> replies;
//
// public List<TopicReplyEntity> getTopicReply(){
// return replies;
// }
//
// public void setTopicReply(List<TopicReplyEntity> replies){
// this.replies = replies;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicsResponse.java
// public class TopicsResponse {
//
// private List<TopicEntity> topics;
//
// public List<TopicEntity> getTopics() {
// return topics;
// }
//
// public void setTopics(List<TopicEntity> topics) {
// this.topics = topics;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/UserResponse.java
// public class UserResponse {
//
// private TesterUser user;
//
// public TesterUser getUser() {
// return user;
// }
//
// public void setUser(TesterUser user) {
// this.user = user;
// }
// }
| import com.testerhome.nativeandroid.models.NotificationResponse;
import com.testerhome.nativeandroid.models.TopicDetailResponse;
import com.testerhome.nativeandroid.models.TopicReplyResponse;
import com.testerhome.nativeandroid.models.TopicsResponse;
import com.testerhome.nativeandroid.models.UserResponse;
import retrofit.Callback;
import retrofit.client.Response;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query; | package com.testerhome.nativeandroid.networks;
/**
* Created by Bin Li on 2015/9/15.
*/
public interface TopicsService {
@GET("/topics.json")
void getTopicsByType(@Query("type") String type,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/topics.json")
void getTopicsByNodeId(@Query("node_id") int nodeId,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/topics/{id}.json")
void getTopicById(@Path("id") String id, | // Path: app/src/main/java/com/testerhome/nativeandroid/models/NotificationResponse.java
// public class NotificationResponse {
//
// private List<NotificationEntity> notifications;
//
// public List<NotificationEntity> getNotifications(){
// return notifications;
// }
//
// public void setNotifications(List<NotificationEntity> notifications){
// this.notifications = notifications;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicDetailResponse.java
// public class TopicDetailResponse {
// private TopicDetailEntity topic;
//
// public TopicDetailEntity getTopic() {
// return topic;
// }
//
// public void setTopic(TopicDetailEntity topic) {
// this.topic = topic;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicReplyResponse.java
// public class TopicReplyResponse {
//
// private List<TopicReplyEntity> replies;
//
// public List<TopicReplyEntity> getTopicReply(){
// return replies;
// }
//
// public void setTopicReply(List<TopicReplyEntity> replies){
// this.replies = replies;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicsResponse.java
// public class TopicsResponse {
//
// private List<TopicEntity> topics;
//
// public List<TopicEntity> getTopics() {
// return topics;
// }
//
// public void setTopics(List<TopicEntity> topics) {
// this.topics = topics;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/UserResponse.java
// public class UserResponse {
//
// private TesterUser user;
//
// public TesterUser getUser() {
// return user;
// }
//
// public void setUser(TesterUser user) {
// this.user = user;
// }
// }
// Path: app/src/main/java/com/testerhome/nativeandroid/networks/TopicsService.java
import com.testerhome.nativeandroid.models.NotificationResponse;
import com.testerhome.nativeandroid.models.TopicDetailResponse;
import com.testerhome.nativeandroid.models.TopicReplyResponse;
import com.testerhome.nativeandroid.models.TopicsResponse;
import com.testerhome.nativeandroid.models.UserResponse;
import retrofit.Callback;
import retrofit.client.Response;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query;
package com.testerhome.nativeandroid.networks;
/**
* Created by Bin Li on 2015/9/15.
*/
public interface TopicsService {
@GET("/topics.json")
void getTopicsByType(@Query("type") String type,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/topics.json")
void getTopicsByNodeId(@Query("node_id") int nodeId,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/topics/{id}.json")
void getTopicById(@Path("id") String id, | Callback<TopicDetailResponse> callback); |
vclub/A-Native-TesterHome | app/src/main/java/com/testerhome/nativeandroid/networks/TopicsService.java | // Path: app/src/main/java/com/testerhome/nativeandroid/models/NotificationResponse.java
// public class NotificationResponse {
//
// private List<NotificationEntity> notifications;
//
// public List<NotificationEntity> getNotifications(){
// return notifications;
// }
//
// public void setNotifications(List<NotificationEntity> notifications){
// this.notifications = notifications;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicDetailResponse.java
// public class TopicDetailResponse {
// private TopicDetailEntity topic;
//
// public TopicDetailEntity getTopic() {
// return topic;
// }
//
// public void setTopic(TopicDetailEntity topic) {
// this.topic = topic;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicReplyResponse.java
// public class TopicReplyResponse {
//
// private List<TopicReplyEntity> replies;
//
// public List<TopicReplyEntity> getTopicReply(){
// return replies;
// }
//
// public void setTopicReply(List<TopicReplyEntity> replies){
// this.replies = replies;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicsResponse.java
// public class TopicsResponse {
//
// private List<TopicEntity> topics;
//
// public List<TopicEntity> getTopics() {
// return topics;
// }
//
// public void setTopics(List<TopicEntity> topics) {
// this.topics = topics;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/UserResponse.java
// public class UserResponse {
//
// private TesterUser user;
//
// public TesterUser getUser() {
// return user;
// }
//
// public void setUser(TesterUser user) {
// this.user = user;
// }
// }
| import com.testerhome.nativeandroid.models.NotificationResponse;
import com.testerhome.nativeandroid.models.TopicDetailResponse;
import com.testerhome.nativeandroid.models.TopicReplyResponse;
import com.testerhome.nativeandroid.models.TopicsResponse;
import com.testerhome.nativeandroid.models.UserResponse;
import retrofit.Callback;
import retrofit.client.Response;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query; | package com.testerhome.nativeandroid.networks;
/**
* Created by Bin Li on 2015/9/15.
*/
public interface TopicsService {
@GET("/topics.json")
void getTopicsByType(@Query("type") String type,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/topics.json")
void getTopicsByNodeId(@Query("node_id") int nodeId,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/topics/{id}.json")
void getTopicById(@Path("id") String id,
Callback<TopicDetailResponse> callback);
@GET("/users/{username}/topics.json")
void getUserTopics(@Path("username") String username,
@Query("access_token") String accessToken,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/users/{username}/favorites.json")
void getUserFavorite(@Path("username") String username,
@Query("access_token") String accessToken,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/users/{username}.json")
void getUserInfo(@Path("username") String username,
@Query("access_token") String accessToken, | // Path: app/src/main/java/com/testerhome/nativeandroid/models/NotificationResponse.java
// public class NotificationResponse {
//
// private List<NotificationEntity> notifications;
//
// public List<NotificationEntity> getNotifications(){
// return notifications;
// }
//
// public void setNotifications(List<NotificationEntity> notifications){
// this.notifications = notifications;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicDetailResponse.java
// public class TopicDetailResponse {
// private TopicDetailEntity topic;
//
// public TopicDetailEntity getTopic() {
// return topic;
// }
//
// public void setTopic(TopicDetailEntity topic) {
// this.topic = topic;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicReplyResponse.java
// public class TopicReplyResponse {
//
// private List<TopicReplyEntity> replies;
//
// public List<TopicReplyEntity> getTopicReply(){
// return replies;
// }
//
// public void setTopicReply(List<TopicReplyEntity> replies){
// this.replies = replies;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicsResponse.java
// public class TopicsResponse {
//
// private List<TopicEntity> topics;
//
// public List<TopicEntity> getTopics() {
// return topics;
// }
//
// public void setTopics(List<TopicEntity> topics) {
// this.topics = topics;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/UserResponse.java
// public class UserResponse {
//
// private TesterUser user;
//
// public TesterUser getUser() {
// return user;
// }
//
// public void setUser(TesterUser user) {
// this.user = user;
// }
// }
// Path: app/src/main/java/com/testerhome/nativeandroid/networks/TopicsService.java
import com.testerhome.nativeandroid.models.NotificationResponse;
import com.testerhome.nativeandroid.models.TopicDetailResponse;
import com.testerhome.nativeandroid.models.TopicReplyResponse;
import com.testerhome.nativeandroid.models.TopicsResponse;
import com.testerhome.nativeandroid.models.UserResponse;
import retrofit.Callback;
import retrofit.client.Response;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query;
package com.testerhome.nativeandroid.networks;
/**
* Created by Bin Li on 2015/9/15.
*/
public interface TopicsService {
@GET("/topics.json")
void getTopicsByType(@Query("type") String type,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/topics.json")
void getTopicsByNodeId(@Query("node_id") int nodeId,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/topics/{id}.json")
void getTopicById(@Path("id") String id,
Callback<TopicDetailResponse> callback);
@GET("/users/{username}/topics.json")
void getUserTopics(@Path("username") String username,
@Query("access_token") String accessToken,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/users/{username}/favorites.json")
void getUserFavorite(@Path("username") String username,
@Query("access_token") String accessToken,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/users/{username}.json")
void getUserInfo(@Path("username") String username,
@Query("access_token") String accessToken, | Callback<UserResponse> callback); |
vclub/A-Native-TesterHome | app/src/main/java/com/testerhome/nativeandroid/networks/TopicsService.java | // Path: app/src/main/java/com/testerhome/nativeandroid/models/NotificationResponse.java
// public class NotificationResponse {
//
// private List<NotificationEntity> notifications;
//
// public List<NotificationEntity> getNotifications(){
// return notifications;
// }
//
// public void setNotifications(List<NotificationEntity> notifications){
// this.notifications = notifications;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicDetailResponse.java
// public class TopicDetailResponse {
// private TopicDetailEntity topic;
//
// public TopicDetailEntity getTopic() {
// return topic;
// }
//
// public void setTopic(TopicDetailEntity topic) {
// this.topic = topic;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicReplyResponse.java
// public class TopicReplyResponse {
//
// private List<TopicReplyEntity> replies;
//
// public List<TopicReplyEntity> getTopicReply(){
// return replies;
// }
//
// public void setTopicReply(List<TopicReplyEntity> replies){
// this.replies = replies;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicsResponse.java
// public class TopicsResponse {
//
// private List<TopicEntity> topics;
//
// public List<TopicEntity> getTopics() {
// return topics;
// }
//
// public void setTopics(List<TopicEntity> topics) {
// this.topics = topics;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/UserResponse.java
// public class UserResponse {
//
// private TesterUser user;
//
// public TesterUser getUser() {
// return user;
// }
//
// public void setUser(TesterUser user) {
// this.user = user;
// }
// }
| import com.testerhome.nativeandroid.models.NotificationResponse;
import com.testerhome.nativeandroid.models.TopicDetailResponse;
import com.testerhome.nativeandroid.models.TopicReplyResponse;
import com.testerhome.nativeandroid.models.TopicsResponse;
import com.testerhome.nativeandroid.models.UserResponse;
import retrofit.Callback;
import retrofit.client.Response;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query; | package com.testerhome.nativeandroid.networks;
/**
* Created by Bin Li on 2015/9/15.
*/
public interface TopicsService {
@GET("/topics.json")
void getTopicsByType(@Query("type") String type,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/topics.json")
void getTopicsByNodeId(@Query("node_id") int nodeId,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/topics/{id}.json")
void getTopicById(@Path("id") String id,
Callback<TopicDetailResponse> callback);
@GET("/users/{username}/topics.json")
void getUserTopics(@Path("username") String username,
@Query("access_token") String accessToken,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/users/{username}/favorites.json")
void getUserFavorite(@Path("username") String username,
@Query("access_token") String accessToken,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/users/{username}.json")
void getUserInfo(@Path("username") String username,
@Query("access_token") String accessToken,
Callback<UserResponse> callback);
@GET("/topics/{id}/replies.json")
void getTopicsReplies(@Path("id") String id,
@Query("offset") int offset, | // Path: app/src/main/java/com/testerhome/nativeandroid/models/NotificationResponse.java
// public class NotificationResponse {
//
// private List<NotificationEntity> notifications;
//
// public List<NotificationEntity> getNotifications(){
// return notifications;
// }
//
// public void setNotifications(List<NotificationEntity> notifications){
// this.notifications = notifications;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicDetailResponse.java
// public class TopicDetailResponse {
// private TopicDetailEntity topic;
//
// public TopicDetailEntity getTopic() {
// return topic;
// }
//
// public void setTopic(TopicDetailEntity topic) {
// this.topic = topic;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicReplyResponse.java
// public class TopicReplyResponse {
//
// private List<TopicReplyEntity> replies;
//
// public List<TopicReplyEntity> getTopicReply(){
// return replies;
// }
//
// public void setTopicReply(List<TopicReplyEntity> replies){
// this.replies = replies;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicsResponse.java
// public class TopicsResponse {
//
// private List<TopicEntity> topics;
//
// public List<TopicEntity> getTopics() {
// return topics;
// }
//
// public void setTopics(List<TopicEntity> topics) {
// this.topics = topics;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/UserResponse.java
// public class UserResponse {
//
// private TesterUser user;
//
// public TesterUser getUser() {
// return user;
// }
//
// public void setUser(TesterUser user) {
// this.user = user;
// }
// }
// Path: app/src/main/java/com/testerhome/nativeandroid/networks/TopicsService.java
import com.testerhome.nativeandroid.models.NotificationResponse;
import com.testerhome.nativeandroid.models.TopicDetailResponse;
import com.testerhome.nativeandroid.models.TopicReplyResponse;
import com.testerhome.nativeandroid.models.TopicsResponse;
import com.testerhome.nativeandroid.models.UserResponse;
import retrofit.Callback;
import retrofit.client.Response;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query;
package com.testerhome.nativeandroid.networks;
/**
* Created by Bin Li on 2015/9/15.
*/
public interface TopicsService {
@GET("/topics.json")
void getTopicsByType(@Query("type") String type,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/topics.json")
void getTopicsByNodeId(@Query("node_id") int nodeId,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/topics/{id}.json")
void getTopicById(@Path("id") String id,
Callback<TopicDetailResponse> callback);
@GET("/users/{username}/topics.json")
void getUserTopics(@Path("username") String username,
@Query("access_token") String accessToken,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/users/{username}/favorites.json")
void getUserFavorite(@Path("username") String username,
@Query("access_token") String accessToken,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/users/{username}.json")
void getUserInfo(@Path("username") String username,
@Query("access_token") String accessToken,
Callback<UserResponse> callback);
@GET("/topics/{id}/replies.json")
void getTopicsReplies(@Path("id") String id,
@Query("offset") int offset, | Callback<TopicReplyResponse> callback); |
vclub/A-Native-TesterHome | app/src/main/java/com/testerhome/nativeandroid/networks/TopicsService.java | // Path: app/src/main/java/com/testerhome/nativeandroid/models/NotificationResponse.java
// public class NotificationResponse {
//
// private List<NotificationEntity> notifications;
//
// public List<NotificationEntity> getNotifications(){
// return notifications;
// }
//
// public void setNotifications(List<NotificationEntity> notifications){
// this.notifications = notifications;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicDetailResponse.java
// public class TopicDetailResponse {
// private TopicDetailEntity topic;
//
// public TopicDetailEntity getTopic() {
// return topic;
// }
//
// public void setTopic(TopicDetailEntity topic) {
// this.topic = topic;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicReplyResponse.java
// public class TopicReplyResponse {
//
// private List<TopicReplyEntity> replies;
//
// public List<TopicReplyEntity> getTopicReply(){
// return replies;
// }
//
// public void setTopicReply(List<TopicReplyEntity> replies){
// this.replies = replies;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicsResponse.java
// public class TopicsResponse {
//
// private List<TopicEntity> topics;
//
// public List<TopicEntity> getTopics() {
// return topics;
// }
//
// public void setTopics(List<TopicEntity> topics) {
// this.topics = topics;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/UserResponse.java
// public class UserResponse {
//
// private TesterUser user;
//
// public TesterUser getUser() {
// return user;
// }
//
// public void setUser(TesterUser user) {
// this.user = user;
// }
// }
| import com.testerhome.nativeandroid.models.NotificationResponse;
import com.testerhome.nativeandroid.models.TopicDetailResponse;
import com.testerhome.nativeandroid.models.TopicReplyResponse;
import com.testerhome.nativeandroid.models.TopicsResponse;
import com.testerhome.nativeandroid.models.UserResponse;
import retrofit.Callback;
import retrofit.client.Response;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query; |
@GET("/topics/{id}.json")
void getTopicById(@Path("id") String id,
Callback<TopicDetailResponse> callback);
@GET("/users/{username}/topics.json")
void getUserTopics(@Path("username") String username,
@Query("access_token") String accessToken,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/users/{username}/favorites.json")
void getUserFavorite(@Path("username") String username,
@Query("access_token") String accessToken,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/users/{username}.json")
void getUserInfo(@Path("username") String username,
@Query("access_token") String accessToken,
Callback<UserResponse> callback);
@GET("/topics/{id}/replies.json")
void getTopicsReplies(@Path("id") String id,
@Query("offset") int offset,
Callback<TopicReplyResponse> callback);
@GET("/notifications.json")
void getNotifications(@Query("access_token") String access_token,
@Query("offset") int offset, | // Path: app/src/main/java/com/testerhome/nativeandroid/models/NotificationResponse.java
// public class NotificationResponse {
//
// private List<NotificationEntity> notifications;
//
// public List<NotificationEntity> getNotifications(){
// return notifications;
// }
//
// public void setNotifications(List<NotificationEntity> notifications){
// this.notifications = notifications;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicDetailResponse.java
// public class TopicDetailResponse {
// private TopicDetailEntity topic;
//
// public TopicDetailEntity getTopic() {
// return topic;
// }
//
// public void setTopic(TopicDetailEntity topic) {
// this.topic = topic;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicReplyResponse.java
// public class TopicReplyResponse {
//
// private List<TopicReplyEntity> replies;
//
// public List<TopicReplyEntity> getTopicReply(){
// return replies;
// }
//
// public void setTopicReply(List<TopicReplyEntity> replies){
// this.replies = replies;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/TopicsResponse.java
// public class TopicsResponse {
//
// private List<TopicEntity> topics;
//
// public List<TopicEntity> getTopics() {
// return topics;
// }
//
// public void setTopics(List<TopicEntity> topics) {
// this.topics = topics;
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/models/UserResponse.java
// public class UserResponse {
//
// private TesterUser user;
//
// public TesterUser getUser() {
// return user;
// }
//
// public void setUser(TesterUser user) {
// this.user = user;
// }
// }
// Path: app/src/main/java/com/testerhome/nativeandroid/networks/TopicsService.java
import com.testerhome.nativeandroid.models.NotificationResponse;
import com.testerhome.nativeandroid.models.TopicDetailResponse;
import com.testerhome.nativeandroid.models.TopicReplyResponse;
import com.testerhome.nativeandroid.models.TopicsResponse;
import com.testerhome.nativeandroid.models.UserResponse;
import retrofit.Callback;
import retrofit.client.Response;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query;
@GET("/topics/{id}.json")
void getTopicById(@Path("id") String id,
Callback<TopicDetailResponse> callback);
@GET("/users/{username}/topics.json")
void getUserTopics(@Path("username") String username,
@Query("access_token") String accessToken,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/users/{username}/favorites.json")
void getUserFavorite(@Path("username") String username,
@Query("access_token") String accessToken,
@Query("offset") int offset,
Callback<TopicsResponse> callback);
@GET("/users/{username}.json")
void getUserInfo(@Path("username") String username,
@Query("access_token") String accessToken,
Callback<UserResponse> callback);
@GET("/topics/{id}/replies.json")
void getTopicsReplies(@Path("id") String id,
@Query("offset") int offset,
Callback<TopicReplyResponse> callback);
@GET("/notifications.json")
void getNotifications(@Query("access_token") String access_token,
@Query("offset") int offset, | Callback<NotificationResponse> callback); |
vclub/A-Native-TesterHome | app/src/main/java/com/testerhome/nativeandroid/auth/UserAccountAuthenticator.java | // Path: app/src/main/java/com/testerhome/nativeandroid/views/UserLoginActivity.java
// public class UserLoginActivity extends BackBaseActivity {
//
// }
| import android.accounts.AbstractAccountAuthenticator;
import android.accounts.Account;
import android.accounts.AccountAuthenticatorResponse;
import android.accounts.AccountManager;
import android.accounts.NetworkErrorException;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.testerhome.nativeandroid.views.UserLoginActivity; | package com.testerhome.nativeandroid.auth;
/**
* Created by vclub on 15/10/13.
*/
public class UserAccountAuthenticator extends AbstractAccountAuthenticator {
private String _tag = "UserAccountAuthenticator";
private Context _context;
public UserAccountAuthenticator(Context context) {
super(context);
_context = context;
}
@Override
public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) {
return null;
}
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options)
throws NetworkErrorException {
Log.d(_tag, accountType + " - " + authTokenType);
Bundle ret = new Bundle();
| // Path: app/src/main/java/com/testerhome/nativeandroid/views/UserLoginActivity.java
// public class UserLoginActivity extends BackBaseActivity {
//
// }
// Path: app/src/main/java/com/testerhome/nativeandroid/auth/UserAccountAuthenticator.java
import android.accounts.AbstractAccountAuthenticator;
import android.accounts.Account;
import android.accounts.AccountAuthenticatorResponse;
import android.accounts.AccountManager;
import android.accounts.NetworkErrorException;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.testerhome.nativeandroid.views.UserLoginActivity;
package com.testerhome.nativeandroid.auth;
/**
* Created by vclub on 15/10/13.
*/
public class UserAccountAuthenticator extends AbstractAccountAuthenticator {
private String _tag = "UserAccountAuthenticator";
private Context _context;
public UserAccountAuthenticator(Context context) {
super(context);
_context = context;
}
@Override
public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) {
return null;
}
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options)
throws NetworkErrorException {
Log.d(_tag, accountType + " - " + authTokenType);
Bundle ret = new Bundle();
| Intent intent = new Intent(_context, UserLoginActivity.class); |
vclub/A-Native-TesterHome | app/src/main/java/com/testerhome/nativeandroid/views/TopicReplyActivity.java | // Path: app/src/main/java/com/testerhome/nativeandroid/fragments/TopicReplyFragment.java
// public class TopicReplyFragment extends BaseFragment {
// @Bind(R.id.rv_topic_list)
// RecyclerView recyclerViewTopicList;
//
// @Bind(R.id.srl_refresh)
// SwipeRefreshLayout swipeRefreshLayout;
//
// private int mNextCursor = 0;
//
// private TopicReplyAdapter mAdatper;
// private String topicId;
//
// public static TopicReplyFragment newInstance(String id) {
// Bundle args = new Bundle();
// args.putString("id", id);
// TopicReplyFragment fragment = new TopicReplyFragment();
// fragment.setArguments(args);
// return fragment;
// }
//
// @Override
// protected int getLayoutRes() {
// return R.layout.fragment_topics;
// }
//
// @Override
// public void onActivityCreated(Bundle savedInstanceState) {
// super.onActivityCreated(savedInstanceState);
// topicId = getArguments().getString("id");
// setupView();
//
// }
//
// private void setupView() {
//
// mAdatper = new TopicReplyAdapter(getActivity());
// mAdatper.setListener(new TopicReplyAdapter.EndlessListener() {
// @Override
// public void onListEnded() {
// if (mNextCursor > 0) {
// loadTopicReplies(topicId);
// }
// }
// });
// swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_light, android.R.color.holo_red_light, android.R.color.holo_orange_light, android.R.color.holo_green_light);
//
// recyclerViewTopicList.setLayoutManager(new LinearLayoutManager(getActivity()));
// recyclerViewTopicList.addItemDecoration(new DividerItemDecoration(getActivity(),
// DividerItemDecoration.VERTICAL_LIST));
// recyclerViewTopicList.setAdapter(mAdatper);
//
// swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
// @Override
// public void onRefresh() {
// mNextCursor = 0;
// loadTopicReplies(topicId);
// }
// });
//
// loadTopicReplies(topicId);
// }
//
//
// private void loadTopicReplies(String topicId) {
//
// TesterHomeApi.getInstance().getTopicsService().getTopicsReplies(topicId,
// mNextCursor*20,
// new Callback<TopicReplyResponse>() {
// @Override
// public void success(TopicReplyResponse topicReplyResponse, Response response) {
//
// if (swipeRefreshLayout.isRefreshing()) {
// swipeRefreshLayout.setRefreshing(false);
// }
// if (topicReplyResponse.getTopicReply().size() > 0) {
//
// if (mNextCursor == 0) {
// mAdatper.setItems(topicReplyResponse.getTopicReply());
// } else {
// mAdatper.addItems(topicReplyResponse.getTopicReply());
// }
//
// if(topicReplyResponse.getTopicReply().size()==20){
// mNextCursor += 1;
// }else{
// mNextCursor = 0;
// }
// } else {
// mNextCursor = 0;
// }
// }
//
// @Override
// public void failure(RetrofitError error) {
// if (swipeRefreshLayout != null && swipeRefreshLayout.isRefreshing()) {
// swipeRefreshLayout.setRefreshing(false);
// }
// Log.e("demo", "failure() called with: " + "error = [" + error + "]"
// + error.getUrl());
// }
// });
// }
//
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/views/base/BackBaseActivity.java
// public abstract class BackBaseActivity extends BaseActivity {
//
// @Override
// protected void setupToolbar() {
// super.setupToolbar();
// if (toolbar != null)
// toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// if (item.getItemId() == android.R.id.home){
// this.onBackPressed();
// }
// return super.onOptionsItemSelected(item);
// }
// }
| import android.os.Bundle;
import com.testerhome.nativeandroid.R;
import com.testerhome.nativeandroid.fragments.TopicReplyFragment;
import com.testerhome.nativeandroid.views.base.BackBaseActivity; | package com.testerhome.nativeandroid.views;
/**
* Created by cvtpc on 2015/10/16.
*/
public class TopicReplyActivity extends BackBaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_back_base);
setCustomTitle("回帖列表");
setupView();
}
private void setupView() {
getSupportFragmentManager().beginTransaction().replace(R.id.container, | // Path: app/src/main/java/com/testerhome/nativeandroid/fragments/TopicReplyFragment.java
// public class TopicReplyFragment extends BaseFragment {
// @Bind(R.id.rv_topic_list)
// RecyclerView recyclerViewTopicList;
//
// @Bind(R.id.srl_refresh)
// SwipeRefreshLayout swipeRefreshLayout;
//
// private int mNextCursor = 0;
//
// private TopicReplyAdapter mAdatper;
// private String topicId;
//
// public static TopicReplyFragment newInstance(String id) {
// Bundle args = new Bundle();
// args.putString("id", id);
// TopicReplyFragment fragment = new TopicReplyFragment();
// fragment.setArguments(args);
// return fragment;
// }
//
// @Override
// protected int getLayoutRes() {
// return R.layout.fragment_topics;
// }
//
// @Override
// public void onActivityCreated(Bundle savedInstanceState) {
// super.onActivityCreated(savedInstanceState);
// topicId = getArguments().getString("id");
// setupView();
//
// }
//
// private void setupView() {
//
// mAdatper = new TopicReplyAdapter(getActivity());
// mAdatper.setListener(new TopicReplyAdapter.EndlessListener() {
// @Override
// public void onListEnded() {
// if (mNextCursor > 0) {
// loadTopicReplies(topicId);
// }
// }
// });
// swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_light, android.R.color.holo_red_light, android.R.color.holo_orange_light, android.R.color.holo_green_light);
//
// recyclerViewTopicList.setLayoutManager(new LinearLayoutManager(getActivity()));
// recyclerViewTopicList.addItemDecoration(new DividerItemDecoration(getActivity(),
// DividerItemDecoration.VERTICAL_LIST));
// recyclerViewTopicList.setAdapter(mAdatper);
//
// swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
// @Override
// public void onRefresh() {
// mNextCursor = 0;
// loadTopicReplies(topicId);
// }
// });
//
// loadTopicReplies(topicId);
// }
//
//
// private void loadTopicReplies(String topicId) {
//
// TesterHomeApi.getInstance().getTopicsService().getTopicsReplies(topicId,
// mNextCursor*20,
// new Callback<TopicReplyResponse>() {
// @Override
// public void success(TopicReplyResponse topicReplyResponse, Response response) {
//
// if (swipeRefreshLayout.isRefreshing()) {
// swipeRefreshLayout.setRefreshing(false);
// }
// if (topicReplyResponse.getTopicReply().size() > 0) {
//
// if (mNextCursor == 0) {
// mAdatper.setItems(topicReplyResponse.getTopicReply());
// } else {
// mAdatper.addItems(topicReplyResponse.getTopicReply());
// }
//
// if(topicReplyResponse.getTopicReply().size()==20){
// mNextCursor += 1;
// }else{
// mNextCursor = 0;
// }
// } else {
// mNextCursor = 0;
// }
// }
//
// @Override
// public void failure(RetrofitError error) {
// if (swipeRefreshLayout != null && swipeRefreshLayout.isRefreshing()) {
// swipeRefreshLayout.setRefreshing(false);
// }
// Log.e("demo", "failure() called with: " + "error = [" + error + "]"
// + error.getUrl());
// }
// });
// }
//
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/views/base/BackBaseActivity.java
// public abstract class BackBaseActivity extends BaseActivity {
//
// @Override
// protected void setupToolbar() {
// super.setupToolbar();
// if (toolbar != null)
// toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// if (item.getItemId() == android.R.id.home){
// this.onBackPressed();
// }
// return super.onOptionsItemSelected(item);
// }
// }
// Path: app/src/main/java/com/testerhome/nativeandroid/views/TopicReplyActivity.java
import android.os.Bundle;
import com.testerhome.nativeandroid.R;
import com.testerhome.nativeandroid.fragments.TopicReplyFragment;
import com.testerhome.nativeandroid.views.base.BackBaseActivity;
package com.testerhome.nativeandroid.views;
/**
* Created by cvtpc on 2015/10/16.
*/
public class TopicReplyActivity extends BackBaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_back_base);
setCustomTitle("回帖列表");
setupView();
}
private void setupView() {
getSupportFragmentManager().beginTransaction().replace(R.id.container, | TopicReplyFragment.newInstance(String.valueOf(getIntent().getIntExtra("topic_id", 0)))) |
vclub/A-Native-TesterHome | app/src/main/java/com/testerhome/nativeandroid/views/AccountFavoriteActivity.java | // Path: app/src/main/java/com/testerhome/nativeandroid/fragments/AccountFavoriteFragment.java
// public class AccountFavoriteFragment extends BaseFragment {
//
// @Bind(R.id.rv_topic_list)
// RecyclerView recyclerViewTopicList;
//
// @Bind(R.id.srl_refresh)
// SwipeRefreshLayout swipeRefreshLayout;
//
// private int mNextCursor = 0;
//
// private TopicsListAdapter mAdatper;
//
//
// public static AccountFavoriteFragment newInstance() {
// AccountFavoriteFragment fragment = new AccountFavoriteFragment();
// return fragment;
// }
//
// @Override
// protected int getLayoutRes() {
// return R.layout.fragment_topics;
// }
//
// @Override
// public void onActivityCreated(Bundle savedInstanceState) {
// super.onActivityCreated(savedInstanceState);
//
// if (mTesterHomeAccount == null){
// getUserInfo();
// }
//
// setupView();
// }
//
// private void setupView() {
// mAdatper = new TopicsListAdapter(getActivity());
// mAdatper.setListener(new TopicsListAdapter.EndlessListener() {
// @Override
// public void onListEnded() {
// if (mNextCursor > 0) {
// mNextCursor = mNextCursor + 1;
// loadTopics();
// }
// }
// });
//
// recyclerViewTopicList.setLayoutManager(new LinearLayoutManager(getActivity()));
// recyclerViewTopicList.addItemDecoration(new DividerItemDecoration(getActivity(),
// DividerItemDecoration.VERTICAL_LIST));
// recyclerViewTopicList.setAdapter(mAdatper);
//
// swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
// @Override
// public void onRefresh() {
// mNextCursor = 0;
// loadTopics();
// }
// });
//
// loadTopics();
// }
//
// private TesterUser mTesterHomeAccount;
//
// private void getUserInfo(){
// mTesterHomeAccount = TesterHomeAccountService.getInstance(getContext()).getActiveAccountInfo();
// }
//
// private void loadTopics() {
//
// TesterHomeApi.getInstance().getTopicsService().getUserFavorite(mTesterHomeAccount.getLogin(),
// mTesterHomeAccount.getAccess_token(),
// mNextCursor,
// new Callback<TopicsResponse>() {
// @Override
// public void success(TopicsResponse topicsResponse, Response response) {
//
// if (swipeRefreshLayout.isRefreshing()) {
// swipeRefreshLayout.setRefreshing(false);
// }
// if (topicsResponse.getTopics().size() > 0) {
// if (mNextCursor == 0) {
// mAdatper.setItems(topicsResponse.getTopics());
// } else {
// mAdatper.addItems(topicsResponse.getTopics());
// }
// } else {
// mNextCursor = 0;
// }
// }
//
// @Override
// public void failure(RetrofitError error) {
// if (swipeRefreshLayout != null && swipeRefreshLayout.isRefreshing()) {
// swipeRefreshLayout.setRefreshing(false);
// }
// Log.e("demo", "failure() called with: " + "error = [" + error + "]"
// + error.getUrl());
// }
// });
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/views/base/BackBaseActivity.java
// public abstract class BackBaseActivity extends BaseActivity {
//
// @Override
// protected void setupToolbar() {
// super.setupToolbar();
// if (toolbar != null)
// toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// if (item.getItemId() == android.R.id.home){
// this.onBackPressed();
// }
// return super.onOptionsItemSelected(item);
// }
// }
| import android.os.Bundle;
import com.testerhome.nativeandroid.R;
import com.testerhome.nativeandroid.fragments.AccountFavoriteFragment;
import com.testerhome.nativeandroid.views.base.BackBaseActivity; | package com.testerhome.nativeandroid.views;
/**
* Created by vclub on 15/10/14.
*/
public class AccountFavoriteActivity extends BackBaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account_favorite);
setCustomTitle("我的收藏");
setupView();
}
private void setupView() {
getSupportFragmentManager().beginTransaction().replace(R.id.container, | // Path: app/src/main/java/com/testerhome/nativeandroid/fragments/AccountFavoriteFragment.java
// public class AccountFavoriteFragment extends BaseFragment {
//
// @Bind(R.id.rv_topic_list)
// RecyclerView recyclerViewTopicList;
//
// @Bind(R.id.srl_refresh)
// SwipeRefreshLayout swipeRefreshLayout;
//
// private int mNextCursor = 0;
//
// private TopicsListAdapter mAdatper;
//
//
// public static AccountFavoriteFragment newInstance() {
// AccountFavoriteFragment fragment = new AccountFavoriteFragment();
// return fragment;
// }
//
// @Override
// protected int getLayoutRes() {
// return R.layout.fragment_topics;
// }
//
// @Override
// public void onActivityCreated(Bundle savedInstanceState) {
// super.onActivityCreated(savedInstanceState);
//
// if (mTesterHomeAccount == null){
// getUserInfo();
// }
//
// setupView();
// }
//
// private void setupView() {
// mAdatper = new TopicsListAdapter(getActivity());
// mAdatper.setListener(new TopicsListAdapter.EndlessListener() {
// @Override
// public void onListEnded() {
// if (mNextCursor > 0) {
// mNextCursor = mNextCursor + 1;
// loadTopics();
// }
// }
// });
//
// recyclerViewTopicList.setLayoutManager(new LinearLayoutManager(getActivity()));
// recyclerViewTopicList.addItemDecoration(new DividerItemDecoration(getActivity(),
// DividerItemDecoration.VERTICAL_LIST));
// recyclerViewTopicList.setAdapter(mAdatper);
//
// swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
// @Override
// public void onRefresh() {
// mNextCursor = 0;
// loadTopics();
// }
// });
//
// loadTopics();
// }
//
// private TesterUser mTesterHomeAccount;
//
// private void getUserInfo(){
// mTesterHomeAccount = TesterHomeAccountService.getInstance(getContext()).getActiveAccountInfo();
// }
//
// private void loadTopics() {
//
// TesterHomeApi.getInstance().getTopicsService().getUserFavorite(mTesterHomeAccount.getLogin(),
// mTesterHomeAccount.getAccess_token(),
// mNextCursor,
// new Callback<TopicsResponse>() {
// @Override
// public void success(TopicsResponse topicsResponse, Response response) {
//
// if (swipeRefreshLayout.isRefreshing()) {
// swipeRefreshLayout.setRefreshing(false);
// }
// if (topicsResponse.getTopics().size() > 0) {
// if (mNextCursor == 0) {
// mAdatper.setItems(topicsResponse.getTopics());
// } else {
// mAdatper.addItems(topicsResponse.getTopics());
// }
// } else {
// mNextCursor = 0;
// }
// }
//
// @Override
// public void failure(RetrofitError error) {
// if (swipeRefreshLayout != null && swipeRefreshLayout.isRefreshing()) {
// swipeRefreshLayout.setRefreshing(false);
// }
// Log.e("demo", "failure() called with: " + "error = [" + error + "]"
// + error.getUrl());
// }
// });
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/views/base/BackBaseActivity.java
// public abstract class BackBaseActivity extends BaseActivity {
//
// @Override
// protected void setupToolbar() {
// super.setupToolbar();
// if (toolbar != null)
// toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// if (item.getItemId() == android.R.id.home){
// this.onBackPressed();
// }
// return super.onOptionsItemSelected(item);
// }
// }
// Path: app/src/main/java/com/testerhome/nativeandroid/views/AccountFavoriteActivity.java
import android.os.Bundle;
import com.testerhome.nativeandroid.R;
import com.testerhome.nativeandroid.fragments.AccountFavoriteFragment;
import com.testerhome.nativeandroid.views.base.BackBaseActivity;
package com.testerhome.nativeandroid.views;
/**
* Created by vclub on 15/10/14.
*/
public class AccountFavoriteActivity extends BackBaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account_favorite);
setCustomTitle("我的收藏");
setupView();
}
private void setupView() {
getSupportFragmentManager().beginTransaction().replace(R.id.container, | AccountFavoriteFragment.newInstance()) |
vclub/A-Native-TesterHome | app/src/main/java/com/testerhome/nativeandroid/views/TopicDetailActivity.java | // Path: app/src/main/java/com/testerhome/nativeandroid/fragments/TopicDetailFragment.java
// public class TopicDetailFragment extends BaseFragment {
//
// @Bind(R.id.tv_detail_title)
// TextView tvDetailTitle;
// @Bind(R.id.sdv_detail_user_avatar)
// SimpleDraweeView sdvDetailUserAvatar;
// @Bind(R.id.tv_detail_name)
// TextView tvDetailName;
// @Bind(R.id.tv_detail_username)
// TextView tvDetailUsername;
// @Bind(R.id.tv_detail_publish_date)
// TextView tvDetailPublishDate;
//
// private String mTopicId;
//
// @Bind(R.id.tv_detail_body)
// MarkdownView tvDetailBody;
//
// public static TopicDetailFragment newInstance(Integer topicId) {
// Bundle args = new Bundle();
// args.putInt("topic_id", topicId);
// TopicDetailFragment fragment = new TopicDetailFragment();
// fragment.setArguments(args);
// fragment.mTopicId = topicId.toString();
// return fragment;
// }
//
// @Override
// public void onActivityCreated(Bundle savedInstanceState) {
// super.onActivityCreated(savedInstanceState);
//
// // getArguments().getString("topic_id");
// // tvDetailBody.getSettings().setUseWideViewPort(true);
// // tvDetailBody.getSettings().setLoadWithOverviewMode(true);
// loadInfo();
// }
//
// @Override
// protected int getLayoutRes() {
// return R.layout.fragment_topic_detail;
// }
//
// private void loadInfo() {
// TesterHomeApi.getInstance().getTopicsService().getTopicById(mTopicId,
// new Callback<TopicDetailResponse>() {
// @Override
// public void success(TopicDetailResponse topicDetailResponse, Response response) {
// TopicDetailEntity topicEntity = topicDetailResponse.getTopic();
// tvDetailTitle.setText(topicEntity.getTitle());
// tvDetailName.setText(topicEntity.getNode_name() + ".");
// tvDetailUsername.setText(TextUtils.isEmpty(topicEntity.getUser().getLogin()) ? "匿名用户" : topicEntity.getUser().getName());
// tvDetailPublishDate.setText(StringUtils.formatPublishDateTime(topicEntity.getCreated_at())
// + "." + topicEntity.getHits() + "次阅读");
// sdvDetailUserAvatar.setImageURI(Uri.parse(Config.getImageUrl(topicEntity.getUser().getAvatar_url())));
//
//
// showWebContent(topicEntity.getBody_html());
// // tvDetailBody.loadMarkdown(topicEntity.getBody());
// }
//
// @Override
// public void failure(RetrofitError error) {
//
// }
// });
// }
//
// private void showWebContent(String htmlBody){
// String prompt = "";
// AssetManager assetManager = getActivity().getResources().getAssets();
//
// try{
// InputStream inputStream = assetManager.open("upgrade.html");
// byte[] b = new byte[inputStream.available()];
// inputStream.read(b);
// prompt = new String(b);
// prompt = prompt.concat(htmlBody.replace("<img src=\"/photo/", "<img src=\"https://testerhome.com/photo/")).concat("</body></html>");
// inputStream.close();
// }catch (IOException e){
// Log.e("", "Counldn't open updrage-alter.html", e);
// }
//
// tvDetailBody.setBackgroundColor(0);
// tvDetailBody.loadDataWithBaseURL(null, prompt, "text/html", "utf-8", null);
// }
//
// @Override
// public void onDestroyView() {
// super.onDestroyView();
// ButterKnife.unbind(this);
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/views/base/BackBaseActivity.java
// public abstract class BackBaseActivity extends BaseActivity {
//
// @Override
// protected void setupToolbar() {
// super.setupToolbar();
// if (toolbar != null)
// toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// if (item.getItemId() == android.R.id.home){
// this.onBackPressed();
// }
// return super.onOptionsItemSelected(item);
// }
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import com.testerhome.nativeandroid.R;
import com.testerhome.nativeandroid.fragments.TopicDetailFragment;
import com.testerhome.nativeandroid.views.base.BackBaseActivity;
import butterknife.Bind;
import butterknife.ButterKnife; | package com.testerhome.nativeandroid.views;
/**
* Created by vclub on 15/9/17.
*/
public class TopicDetailActivity extends BackBaseActivity {
@Bind(R.id.toolbar)
Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_back_base);
ButterKnife.bind(this);
setCustomTitle("帖子详情");
setupView();
toolbar.setOnMenuItemClickListener(onMenuItemClick);
}
private void setupView() {
getSupportFragmentManager().beginTransaction().replace(R.id.container, | // Path: app/src/main/java/com/testerhome/nativeandroid/fragments/TopicDetailFragment.java
// public class TopicDetailFragment extends BaseFragment {
//
// @Bind(R.id.tv_detail_title)
// TextView tvDetailTitle;
// @Bind(R.id.sdv_detail_user_avatar)
// SimpleDraweeView sdvDetailUserAvatar;
// @Bind(R.id.tv_detail_name)
// TextView tvDetailName;
// @Bind(R.id.tv_detail_username)
// TextView tvDetailUsername;
// @Bind(R.id.tv_detail_publish_date)
// TextView tvDetailPublishDate;
//
// private String mTopicId;
//
// @Bind(R.id.tv_detail_body)
// MarkdownView tvDetailBody;
//
// public static TopicDetailFragment newInstance(Integer topicId) {
// Bundle args = new Bundle();
// args.putInt("topic_id", topicId);
// TopicDetailFragment fragment = new TopicDetailFragment();
// fragment.setArguments(args);
// fragment.mTopicId = topicId.toString();
// return fragment;
// }
//
// @Override
// public void onActivityCreated(Bundle savedInstanceState) {
// super.onActivityCreated(savedInstanceState);
//
// // getArguments().getString("topic_id");
// // tvDetailBody.getSettings().setUseWideViewPort(true);
// // tvDetailBody.getSettings().setLoadWithOverviewMode(true);
// loadInfo();
// }
//
// @Override
// protected int getLayoutRes() {
// return R.layout.fragment_topic_detail;
// }
//
// private void loadInfo() {
// TesterHomeApi.getInstance().getTopicsService().getTopicById(mTopicId,
// new Callback<TopicDetailResponse>() {
// @Override
// public void success(TopicDetailResponse topicDetailResponse, Response response) {
// TopicDetailEntity topicEntity = topicDetailResponse.getTopic();
// tvDetailTitle.setText(topicEntity.getTitle());
// tvDetailName.setText(topicEntity.getNode_name() + ".");
// tvDetailUsername.setText(TextUtils.isEmpty(topicEntity.getUser().getLogin()) ? "匿名用户" : topicEntity.getUser().getName());
// tvDetailPublishDate.setText(StringUtils.formatPublishDateTime(topicEntity.getCreated_at())
// + "." + topicEntity.getHits() + "次阅读");
// sdvDetailUserAvatar.setImageURI(Uri.parse(Config.getImageUrl(topicEntity.getUser().getAvatar_url())));
//
//
// showWebContent(topicEntity.getBody_html());
// // tvDetailBody.loadMarkdown(topicEntity.getBody());
// }
//
// @Override
// public void failure(RetrofitError error) {
//
// }
// });
// }
//
// private void showWebContent(String htmlBody){
// String prompt = "";
// AssetManager assetManager = getActivity().getResources().getAssets();
//
// try{
// InputStream inputStream = assetManager.open("upgrade.html");
// byte[] b = new byte[inputStream.available()];
// inputStream.read(b);
// prompt = new String(b);
// prompt = prompt.concat(htmlBody.replace("<img src=\"/photo/", "<img src=\"https://testerhome.com/photo/")).concat("</body></html>");
// inputStream.close();
// }catch (IOException e){
// Log.e("", "Counldn't open updrage-alter.html", e);
// }
//
// tvDetailBody.setBackgroundColor(0);
// tvDetailBody.loadDataWithBaseURL(null, prompt, "text/html", "utf-8", null);
// }
//
// @Override
// public void onDestroyView() {
// super.onDestroyView();
// ButterKnife.unbind(this);
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/views/base/BackBaseActivity.java
// public abstract class BackBaseActivity extends BaseActivity {
//
// @Override
// protected void setupToolbar() {
// super.setupToolbar();
// if (toolbar != null)
// toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// if (item.getItemId() == android.R.id.home){
// this.onBackPressed();
// }
// return super.onOptionsItemSelected(item);
// }
// }
// Path: app/src/main/java/com/testerhome/nativeandroid/views/TopicDetailActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import com.testerhome.nativeandroid.R;
import com.testerhome.nativeandroid.fragments.TopicDetailFragment;
import com.testerhome.nativeandroid.views.base.BackBaseActivity;
import butterknife.Bind;
import butterknife.ButterKnife;
package com.testerhome.nativeandroid.views;
/**
* Created by vclub on 15/9/17.
*/
public class TopicDetailActivity extends BackBaseActivity {
@Bind(R.id.toolbar)
Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_back_base);
ButterKnife.bind(this);
setCustomTitle("帖子详情");
setupView();
toolbar.setOnMenuItemClickListener(onMenuItemClick);
}
private void setupView() {
getSupportFragmentManager().beginTransaction().replace(R.id.container, | TopicDetailFragment.newInstance(getIntent().getIntExtra("topic_id", 0))) |
vclub/A-Native-TesterHome | app/src/main/java/com/testerhome/nativeandroid/views/AccountTopicsActivity.java | // Path: app/src/main/java/com/testerhome/nativeandroid/fragments/AccountTopicsFragment.java
// public class AccountTopicsFragment extends BaseFragment {
//
// @Bind(R.id.rv_topic_list)
// RecyclerView recyclerViewTopicList;
//
// @Bind(R.id.srl_refresh)
// SwipeRefreshLayout swipeRefreshLayout;
//
// private int mNextCursor = 0;
//
// private TopicsListAdapter mAdatper;
//
//
// public static AccountTopicsFragment newInstance() {
// AccountTopicsFragment fragment = new AccountTopicsFragment();
// return fragment;
// }
//
// @Override
// protected int getLayoutRes() {
// return R.layout.fragment_topics;
// }
//
// @Override
// public void onActivityCreated(Bundle savedInstanceState) {
// super.onActivityCreated(savedInstanceState);
// setupView();
//
// if (mTesterHomeAccount == null) {
// getUserInfo();
// }
//
// }
//
// @Override
// public void onStart() {
// super.onStart();
//
// loadTopics();
// }
//
// private void setupView() {
// mAdatper = new TopicsListAdapter(getActivity());
// mAdatper.setListener(new TopicsListAdapter.EndlessListener() {
// @Override
// public void onListEnded() {
// if (mNextCursor > 0) {
// mNextCursor = mNextCursor + 1;
// loadTopics();
// }
// }
// });
//
// recyclerViewTopicList.setLayoutManager(new LinearLayoutManager(getActivity()));
// recyclerViewTopicList.addItemDecoration(new DividerItemDecoration(getActivity(),
// DividerItemDecoration.VERTICAL_LIST));
// recyclerViewTopicList.setAdapter(mAdatper);
//
// swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
// @Override
// public void onRefresh() {
// mNextCursor = 0;
// loadTopics();
// }
// });
//
// }
//
// private TesterUser mTesterHomeAccount;
//
// private void getUserInfo() {
// mTesterHomeAccount = TesterHomeAccountService.getInstance(getContext()).getActiveAccountInfo();
// }
//
//
// private void loadTopics() {
//
// TesterHomeApi.getInstance().getTopicsService().getUserTopics(mTesterHomeAccount.getLogin(),
// mTesterHomeAccount.getAccess_token(),
// mNextCursor,
// new Callback<TopicsResponse>() {
// @Override
// public void success(TopicsResponse topicsResponse, Response response) {
//
// if (swipeRefreshLayout.isRefreshing()) {
// swipeRefreshLayout.setRefreshing(false);
// }
// if (topicsResponse.getTopics().size() > 0) {
// if (mNextCursor == 0) {
// mAdatper.setItems(topicsResponse.getTopics());
// } else {
// mAdatper.addItems(topicsResponse.getTopics());
// }
// } else {
// mNextCursor = 0;
// }
// }
//
// @Override
// public void failure(RetrofitError error) {
// if (swipeRefreshLayout != null && swipeRefreshLayout.isRefreshing()) {
// swipeRefreshLayout.setRefreshing(false);
// }
// Log.e("demo", "failure() called with: " + "error = [" + error + "]"
// + error.getUrl());
// }
// });
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/views/base/BackBaseActivity.java
// public abstract class BackBaseActivity extends BaseActivity {
//
// @Override
// protected void setupToolbar() {
// super.setupToolbar();
// if (toolbar != null)
// toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// if (item.getItemId() == android.R.id.home){
// this.onBackPressed();
// }
// return super.onOptionsItemSelected(item);
// }
// }
| import android.os.Bundle;
import com.testerhome.nativeandroid.R;
import com.testerhome.nativeandroid.fragments.AccountTopicsFragment;
import com.testerhome.nativeandroid.views.base.BackBaseActivity; | package com.testerhome.nativeandroid.views;
/**
* Created by vclub on 15/10/14.
*/
public class AccountTopicsActivity extends BackBaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account_topics);
setCustomTitle("我的发帖");
setupView();
}
private void setupView() {
getSupportFragmentManager().beginTransaction().replace(R.id.container, | // Path: app/src/main/java/com/testerhome/nativeandroid/fragments/AccountTopicsFragment.java
// public class AccountTopicsFragment extends BaseFragment {
//
// @Bind(R.id.rv_topic_list)
// RecyclerView recyclerViewTopicList;
//
// @Bind(R.id.srl_refresh)
// SwipeRefreshLayout swipeRefreshLayout;
//
// private int mNextCursor = 0;
//
// private TopicsListAdapter mAdatper;
//
//
// public static AccountTopicsFragment newInstance() {
// AccountTopicsFragment fragment = new AccountTopicsFragment();
// return fragment;
// }
//
// @Override
// protected int getLayoutRes() {
// return R.layout.fragment_topics;
// }
//
// @Override
// public void onActivityCreated(Bundle savedInstanceState) {
// super.onActivityCreated(savedInstanceState);
// setupView();
//
// if (mTesterHomeAccount == null) {
// getUserInfo();
// }
//
// }
//
// @Override
// public void onStart() {
// super.onStart();
//
// loadTopics();
// }
//
// private void setupView() {
// mAdatper = new TopicsListAdapter(getActivity());
// mAdatper.setListener(new TopicsListAdapter.EndlessListener() {
// @Override
// public void onListEnded() {
// if (mNextCursor > 0) {
// mNextCursor = mNextCursor + 1;
// loadTopics();
// }
// }
// });
//
// recyclerViewTopicList.setLayoutManager(new LinearLayoutManager(getActivity()));
// recyclerViewTopicList.addItemDecoration(new DividerItemDecoration(getActivity(),
// DividerItemDecoration.VERTICAL_LIST));
// recyclerViewTopicList.setAdapter(mAdatper);
//
// swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
// @Override
// public void onRefresh() {
// mNextCursor = 0;
// loadTopics();
// }
// });
//
// }
//
// private TesterUser mTesterHomeAccount;
//
// private void getUserInfo() {
// mTesterHomeAccount = TesterHomeAccountService.getInstance(getContext()).getActiveAccountInfo();
// }
//
//
// private void loadTopics() {
//
// TesterHomeApi.getInstance().getTopicsService().getUserTopics(mTesterHomeAccount.getLogin(),
// mTesterHomeAccount.getAccess_token(),
// mNextCursor,
// new Callback<TopicsResponse>() {
// @Override
// public void success(TopicsResponse topicsResponse, Response response) {
//
// if (swipeRefreshLayout.isRefreshing()) {
// swipeRefreshLayout.setRefreshing(false);
// }
// if (topicsResponse.getTopics().size() > 0) {
// if (mNextCursor == 0) {
// mAdatper.setItems(topicsResponse.getTopics());
// } else {
// mAdatper.addItems(topicsResponse.getTopics());
// }
// } else {
// mNextCursor = 0;
// }
// }
//
// @Override
// public void failure(RetrofitError error) {
// if (swipeRefreshLayout != null && swipeRefreshLayout.isRefreshing()) {
// swipeRefreshLayout.setRefreshing(false);
// }
// Log.e("demo", "failure() called with: " + "error = [" + error + "]"
// + error.getUrl());
// }
// });
// }
// }
//
// Path: app/src/main/java/com/testerhome/nativeandroid/views/base/BackBaseActivity.java
// public abstract class BackBaseActivity extends BaseActivity {
//
// @Override
// protected void setupToolbar() {
// super.setupToolbar();
// if (toolbar != null)
// toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// if (item.getItemId() == android.R.id.home){
// this.onBackPressed();
// }
// return super.onOptionsItemSelected(item);
// }
// }
// Path: app/src/main/java/com/testerhome/nativeandroid/views/AccountTopicsActivity.java
import android.os.Bundle;
import com.testerhome.nativeandroid.R;
import com.testerhome.nativeandroid.fragments.AccountTopicsFragment;
import com.testerhome.nativeandroid.views.base.BackBaseActivity;
package com.testerhome.nativeandroid.views;
/**
* Created by vclub on 15/10/14.
*/
public class AccountTopicsActivity extends BackBaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account_topics);
setCustomTitle("我的发帖");
setupView();
}
private void setupView() {
getSupportFragmentManager().beginTransaction().replace(R.id.container, | AccountTopicsFragment.newInstance()) |
vclub/A-Native-TesterHome | app/src/main/java/com/testerhome/nativeandroid/networks/TesterHomeApi.java | // Path: app/src/main/java/com/testerhome/nativeandroid/Config.java
// public class Config {
//
// // recent - 最新
// // popular - 热门的话题(回帖和喜欢超过一定的数量
// // no_reply - 还没有任何回帖的
// // excellent - 精华帖
// // last_actived - 最近活跃的
//
// public static final String TOPICS_TYPE_RECENT = "recent";
// public static final String TOPICS_TYPE_POPULAR = "popular";
// public static final String TOPICS_TYPE_NO_REPLY = "no_reply";
// public static final String TOPICS_TYPE_EXCELLENT = "excellent";
// public static final String TOPICS_TYPE_LAST_ACTIVED = "last_actived";
// public static final int TOPIC_JOB_NODEID = 19;
// public static final String BASE_URL = "https://testerhome.com/api/v3";
// public static final String TOPICREPLY = "TopicReply";
// public static final String FOLLOW = "Follow";
// public static final String TOPIC = "Topic";
//
// public static String getImageUrl(String imagePath){
// if(!imagePath.contains("https://testerhome.com")){
// return "https://testerhome.com".concat(imagePath);
// }else{
// return imagePath;
// }
//
// }
// }
| import com.testerhome.nativeandroid.Config;
import retrofit.RestAdapter;
import retrofit.client.OkClient; | package com.testerhome.nativeandroid.networks;
/**
* Created by Bin Li on 2015/9/16.
*/
public class TesterHomeApi {
private static TesterHomeApi instance;
private TopicsService topicsService;
public static TesterHomeApi getInstance() {
if (instance == null){
instance = new TesterHomeApi();
}
return instance;
}
private TesterHomeApi(){
RestAdapter restAdapter = buildRestAdapter();
this.topicsService = restAdapter.create(TopicsService.class);
}
private RestAdapter buildRestAdapter() {
return new RestAdapter.Builder() | // Path: app/src/main/java/com/testerhome/nativeandroid/Config.java
// public class Config {
//
// // recent - 最新
// // popular - 热门的话题(回帖和喜欢超过一定的数量
// // no_reply - 还没有任何回帖的
// // excellent - 精华帖
// // last_actived - 最近活跃的
//
// public static final String TOPICS_TYPE_RECENT = "recent";
// public static final String TOPICS_TYPE_POPULAR = "popular";
// public static final String TOPICS_TYPE_NO_REPLY = "no_reply";
// public static final String TOPICS_TYPE_EXCELLENT = "excellent";
// public static final String TOPICS_TYPE_LAST_ACTIVED = "last_actived";
// public static final int TOPIC_JOB_NODEID = 19;
// public static final String BASE_URL = "https://testerhome.com/api/v3";
// public static final String TOPICREPLY = "TopicReply";
// public static final String FOLLOW = "Follow";
// public static final String TOPIC = "Topic";
//
// public static String getImageUrl(String imagePath){
// if(!imagePath.contains("https://testerhome.com")){
// return "https://testerhome.com".concat(imagePath);
// }else{
// return imagePath;
// }
//
// }
// }
// Path: app/src/main/java/com/testerhome/nativeandroid/networks/TesterHomeApi.java
import com.testerhome.nativeandroid.Config;
import retrofit.RestAdapter;
import retrofit.client.OkClient;
package com.testerhome.nativeandroid.networks;
/**
* Created by Bin Li on 2015/9/16.
*/
public class TesterHomeApi {
private static TesterHomeApi instance;
private TopicsService topicsService;
public static TesterHomeApi getInstance() {
if (instance == null){
instance = new TesterHomeApi();
}
return instance;
}
private TesterHomeApi(){
RestAdapter restAdapter = buildRestAdapter();
this.topicsService = restAdapter.create(TopicsService.class);
}
private RestAdapter buildRestAdapter() {
return new RestAdapter.Builder() | .setEndpoint(Config.BASE_URL) |
kakawait/cas-security-spring-boot-starter | cas-security-spring-boot-autoconfigure/src/main/java/com/kakawait/spring/boot/security/cas/autoconfigure/CasAuthenticationProviderSecurityBuilder.java | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/authentication/DynamicProxyCallbackUrlCasAuthenticationProvider.java
// public class DynamicProxyCallbackUrlCasAuthenticationProvider extends CasAuthenticationProvider {
// @Override
// public Authentication authenticate(Authentication authentication) {
// if (authentication.getDetails() instanceof ProxyCallbackAndServiceAuthenticationDetails) {
// if (getTicketValidator() instanceof Cas20ServiceTicketValidator) {
// String proxyCallbackUrl =
// ((ProxyCallbackAndServiceAuthenticationDetails) authentication.getDetails()).getProxyCallbackUrl();
// ((Cas20ServiceTicketValidator) getTicketValidator()).setProxyCallbackUrl(proxyCallbackUrl);
// } else if (getTicketValidator() instanceof ProxyCallbackUrlAwareTicketValidator) {
// String proxyCallbackUrl =
// ((ProxyCallbackAndServiceAuthenticationDetails) authentication.getDetails()).getProxyCallbackUrl();
// ((ProxyCallbackUrlAwareTicketValidator) getTicketValidator()).setProxyCallbackUrl(proxyCallbackUrl);
// }
// }
// return super.authenticate(authentication);
// }
// }
| import com.kakawait.spring.security.cas.authentication.DynamicProxyCallbackUrlCasAuthenticationProvider;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.jasig.cas.client.validation.TicketValidator;
import org.springframework.context.MessageSource;
import org.springframework.security.cas.authentication.CasAssertionAuthenticationToken;
import org.springframework.security.cas.authentication.CasAuthenticationProvider;
import org.springframework.security.cas.authentication.StatelessTicketCache;
import org.springframework.security.config.annotation.SecurityBuilder;
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
import org.springframework.security.core.userdetails.AuthenticationUserDetailsService; | package com.kakawait.spring.boot.security.cas.autoconfigure;
/**
* @author Thibaud Leprêtre
*/
@Accessors(fluent = true)
@Setter
public class CasAuthenticationProviderSecurityBuilder implements SecurityBuilder<CasAuthenticationProvider> {
private CasSecurityProperties.ServiceResolutionMode serviceResolutionMode;
private AuthenticationUserDetailsService<CasAssertionAuthenticationToken> authenticationUserDetailsService;
private GrantedAuthoritiesMapper grantedAuthoritiesMapper;
private MessageSource messageSource;
private StatelessTicketCache statelessTicketCache;
private TicketValidator ticketValidator;
private String key;
@Override
public CasAuthenticationProvider build() {
CasAuthenticationProvider provider;
if (serviceResolutionMode == CasSecurityProperties.ServiceResolutionMode.DYNAMIC) { | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/authentication/DynamicProxyCallbackUrlCasAuthenticationProvider.java
// public class DynamicProxyCallbackUrlCasAuthenticationProvider extends CasAuthenticationProvider {
// @Override
// public Authentication authenticate(Authentication authentication) {
// if (authentication.getDetails() instanceof ProxyCallbackAndServiceAuthenticationDetails) {
// if (getTicketValidator() instanceof Cas20ServiceTicketValidator) {
// String proxyCallbackUrl =
// ((ProxyCallbackAndServiceAuthenticationDetails) authentication.getDetails()).getProxyCallbackUrl();
// ((Cas20ServiceTicketValidator) getTicketValidator()).setProxyCallbackUrl(proxyCallbackUrl);
// } else if (getTicketValidator() instanceof ProxyCallbackUrlAwareTicketValidator) {
// String proxyCallbackUrl =
// ((ProxyCallbackAndServiceAuthenticationDetails) authentication.getDetails()).getProxyCallbackUrl();
// ((ProxyCallbackUrlAwareTicketValidator) getTicketValidator()).setProxyCallbackUrl(proxyCallbackUrl);
// }
// }
// return super.authenticate(authentication);
// }
// }
// Path: cas-security-spring-boot-autoconfigure/src/main/java/com/kakawait/spring/boot/security/cas/autoconfigure/CasAuthenticationProviderSecurityBuilder.java
import com.kakawait.spring.security.cas.authentication.DynamicProxyCallbackUrlCasAuthenticationProvider;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.jasig.cas.client.validation.TicketValidator;
import org.springframework.context.MessageSource;
import org.springframework.security.cas.authentication.CasAssertionAuthenticationToken;
import org.springframework.security.cas.authentication.CasAuthenticationProvider;
import org.springframework.security.cas.authentication.StatelessTicketCache;
import org.springframework.security.config.annotation.SecurityBuilder;
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
import org.springframework.security.core.userdetails.AuthenticationUserDetailsService;
package com.kakawait.spring.boot.security.cas.autoconfigure;
/**
* @author Thibaud Leprêtre
*/
@Accessors(fluent = true)
@Setter
public class CasAuthenticationProviderSecurityBuilder implements SecurityBuilder<CasAuthenticationProvider> {
private CasSecurityProperties.ServiceResolutionMode serviceResolutionMode;
private AuthenticationUserDetailsService<CasAssertionAuthenticationToken> authenticationUserDetailsService;
private GrantedAuthoritiesMapper grantedAuthoritiesMapper;
private MessageSource messageSource;
private StatelessTicketCache statelessTicketCache;
private TicketValidator ticketValidator;
private String key;
@Override
public CasAuthenticationProvider build() {
CasAuthenticationProvider provider;
if (serviceResolutionMode == CasSecurityProperties.ServiceResolutionMode.DYNAMIC) { | provider = new DynamicProxyCallbackUrlCasAuthenticationProvider(); |
kakawait/cas-security-spring-boot-starter | spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/authentication/DynamicProxyCallbackUrlCasAuthenticationProvider.java | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/client/validation/ProxyCallbackUrlAwareTicketValidator.java
// public interface ProxyCallbackUrlAwareTicketValidator {
// void setProxyCallbackUrl(String proxyCallbackUrl);
// }
//
// Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/web/authentication/ProxyCallbackAndServiceAuthenticationDetails.java
// public interface ProxyCallbackAndServiceAuthenticationDetails extends ServiceAuthenticationDetails {
// String getProxyCallbackUrl();
//
// void setContext(HttpServletRequest context);
// }
| import com.kakawait.spring.security.cas.client.validation.ProxyCallbackUrlAwareTicketValidator;
import com.kakawait.spring.security.cas.web.authentication.ProxyCallbackAndServiceAuthenticationDetails;
import org.jasig.cas.client.validation.Cas20ServiceTicketValidator;
import org.springframework.security.cas.authentication.CasAuthenticationProvider;
import org.springframework.security.core.Authentication; | package com.kakawait.spring.security.cas.authentication;
/**
* @author Thibaud Leprêtre
*/
public class DynamicProxyCallbackUrlCasAuthenticationProvider extends CasAuthenticationProvider {
@Override
public Authentication authenticate(Authentication authentication) { | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/client/validation/ProxyCallbackUrlAwareTicketValidator.java
// public interface ProxyCallbackUrlAwareTicketValidator {
// void setProxyCallbackUrl(String proxyCallbackUrl);
// }
//
// Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/web/authentication/ProxyCallbackAndServiceAuthenticationDetails.java
// public interface ProxyCallbackAndServiceAuthenticationDetails extends ServiceAuthenticationDetails {
// String getProxyCallbackUrl();
//
// void setContext(HttpServletRequest context);
// }
// Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/authentication/DynamicProxyCallbackUrlCasAuthenticationProvider.java
import com.kakawait.spring.security.cas.client.validation.ProxyCallbackUrlAwareTicketValidator;
import com.kakawait.spring.security.cas.web.authentication.ProxyCallbackAndServiceAuthenticationDetails;
import org.jasig.cas.client.validation.Cas20ServiceTicketValidator;
import org.springframework.security.cas.authentication.CasAuthenticationProvider;
import org.springframework.security.core.Authentication;
package com.kakawait.spring.security.cas.authentication;
/**
* @author Thibaud Leprêtre
*/
public class DynamicProxyCallbackUrlCasAuthenticationProvider extends CasAuthenticationProvider {
@Override
public Authentication authenticate(Authentication authentication) { | if (authentication.getDetails() instanceof ProxyCallbackAndServiceAuthenticationDetails) { |
kakawait/cas-security-spring-boot-starter | spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/authentication/DynamicProxyCallbackUrlCasAuthenticationProvider.java | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/client/validation/ProxyCallbackUrlAwareTicketValidator.java
// public interface ProxyCallbackUrlAwareTicketValidator {
// void setProxyCallbackUrl(String proxyCallbackUrl);
// }
//
// Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/web/authentication/ProxyCallbackAndServiceAuthenticationDetails.java
// public interface ProxyCallbackAndServiceAuthenticationDetails extends ServiceAuthenticationDetails {
// String getProxyCallbackUrl();
//
// void setContext(HttpServletRequest context);
// }
| import com.kakawait.spring.security.cas.client.validation.ProxyCallbackUrlAwareTicketValidator;
import com.kakawait.spring.security.cas.web.authentication.ProxyCallbackAndServiceAuthenticationDetails;
import org.jasig.cas.client.validation.Cas20ServiceTicketValidator;
import org.springframework.security.cas.authentication.CasAuthenticationProvider;
import org.springframework.security.core.Authentication; | package com.kakawait.spring.security.cas.authentication;
/**
* @author Thibaud Leprêtre
*/
public class DynamicProxyCallbackUrlCasAuthenticationProvider extends CasAuthenticationProvider {
@Override
public Authentication authenticate(Authentication authentication) {
if (authentication.getDetails() instanceof ProxyCallbackAndServiceAuthenticationDetails) {
if (getTicketValidator() instanceof Cas20ServiceTicketValidator) {
String proxyCallbackUrl =
((ProxyCallbackAndServiceAuthenticationDetails) authentication.getDetails()).getProxyCallbackUrl();
((Cas20ServiceTicketValidator) getTicketValidator()).setProxyCallbackUrl(proxyCallbackUrl); | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/client/validation/ProxyCallbackUrlAwareTicketValidator.java
// public interface ProxyCallbackUrlAwareTicketValidator {
// void setProxyCallbackUrl(String proxyCallbackUrl);
// }
//
// Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/web/authentication/ProxyCallbackAndServiceAuthenticationDetails.java
// public interface ProxyCallbackAndServiceAuthenticationDetails extends ServiceAuthenticationDetails {
// String getProxyCallbackUrl();
//
// void setContext(HttpServletRequest context);
// }
// Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/authentication/DynamicProxyCallbackUrlCasAuthenticationProvider.java
import com.kakawait.spring.security.cas.client.validation.ProxyCallbackUrlAwareTicketValidator;
import com.kakawait.spring.security.cas.web.authentication.ProxyCallbackAndServiceAuthenticationDetails;
import org.jasig.cas.client.validation.Cas20ServiceTicketValidator;
import org.springframework.security.cas.authentication.CasAuthenticationProvider;
import org.springframework.security.core.Authentication;
package com.kakawait.spring.security.cas.authentication;
/**
* @author Thibaud Leprêtre
*/
public class DynamicProxyCallbackUrlCasAuthenticationProvider extends CasAuthenticationProvider {
@Override
public Authentication authenticate(Authentication authentication) {
if (authentication.getDetails() instanceof ProxyCallbackAndServiceAuthenticationDetails) {
if (getTicketValidator() instanceof Cas20ServiceTicketValidator) {
String proxyCallbackUrl =
((ProxyCallbackAndServiceAuthenticationDetails) authentication.getDetails()).getProxyCallbackUrl();
((Cas20ServiceTicketValidator) getTicketValidator()).setProxyCallbackUrl(proxyCallbackUrl); | } else if (getTicketValidator() instanceof ProxyCallbackUrlAwareTicketValidator) { |
kakawait/cas-security-spring-boot-starter | spring-security-cas-extension/src/test/java/com/kakawait/spring/security/cas/web/authentication/DefaultProxyCallbackAndServiceAuthenticationDetailsTest.java | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/LaxServiceProperties.java
// public class LaxServiceProperties extends ServiceProperties {
//
// private final boolean dynamicServiceResolution;
//
// public LaxServiceProperties() {
// this(true);
// }
//
// public LaxServiceProperties(boolean dynamicServiceResolution) {
// this.dynamicServiceResolution = dynamicServiceResolution;
// }
//
// @Override
// public void afterPropertiesSet() {
// if (!dynamicServiceResolution) {
// try {
// super.afterPropertiesSet();
// } catch (RuntimeException e) {
// throw e;
// } catch (Exception e) {
// // Old version of spring security throw Exception for afterPropertiesSet()
// throw new RuntimeException(e);
// }
// } else {
// Assert.hasLength(getArtifactParameter(), "artifactParameter cannot be empty.");
// Assert.hasLength(getServiceParameter(), "serviceParameter cannot be empty.");
// }
// }
//
// public boolean isDynamicServiceResolution() {
// return dynamicServiceResolution;
// }
// }
| import com.kakawait.spring.security.cas.LaxServiceProperties;
import org.junit.Before;
import org.junit.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.security.cas.ServiceProperties;
import java.net.URI;
import static org.assertj.core.api.Assertions.assertThat; | package com.kakawait.spring.security.cas.web.authentication;
/**
* @author Thibaud Leprêtre
*/
public class DefaultProxyCallbackAndServiceAuthenticationDetailsTest {
private ServiceProperties serviceProperties;
private MockHttpServletRequest request;
@Before
public void setUp() { | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/LaxServiceProperties.java
// public class LaxServiceProperties extends ServiceProperties {
//
// private final boolean dynamicServiceResolution;
//
// public LaxServiceProperties() {
// this(true);
// }
//
// public LaxServiceProperties(boolean dynamicServiceResolution) {
// this.dynamicServiceResolution = dynamicServiceResolution;
// }
//
// @Override
// public void afterPropertiesSet() {
// if (!dynamicServiceResolution) {
// try {
// super.afterPropertiesSet();
// } catch (RuntimeException e) {
// throw e;
// } catch (Exception e) {
// // Old version of spring security throw Exception for afterPropertiesSet()
// throw new RuntimeException(e);
// }
// } else {
// Assert.hasLength(getArtifactParameter(), "artifactParameter cannot be empty.");
// Assert.hasLength(getServiceParameter(), "serviceParameter cannot be empty.");
// }
// }
//
// public boolean isDynamicServiceResolution() {
// return dynamicServiceResolution;
// }
// }
// Path: spring-security-cas-extension/src/test/java/com/kakawait/spring/security/cas/web/authentication/DefaultProxyCallbackAndServiceAuthenticationDetailsTest.java
import com.kakawait.spring.security.cas.LaxServiceProperties;
import org.junit.Before;
import org.junit.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.security.cas.ServiceProperties;
import java.net.URI;
import static org.assertj.core.api.Assertions.assertThat;
package com.kakawait.spring.security.cas.web.authentication;
/**
* @author Thibaud Leprêtre
*/
public class DefaultProxyCallbackAndServiceAuthenticationDetailsTest {
private ServiceProperties serviceProperties;
private MockHttpServletRequest request;
@Before
public void setUp() { | serviceProperties = new LaxServiceProperties(); |
kakawait/cas-security-spring-boot-starter | spring-security-cas-extension/src/test/java/com/kakawait/spring/security/cas/client/ticket/AttributePrincipalProxyTicketProviderTest.java | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/client/validation/AssertionProvider.java
// public interface AssertionProvider {
//
// /**
// * Retrieve current request {@link Assertion}.
// * @return the current request {@link Assertion}.
// */
// @Nonnull
// Assertion getAssertion();
// }
| import com.kakawait.spring.security.cas.client.validation.AssertionProvider;
import org.jasig.cas.client.authentication.AttributePrincipal;
import org.jasig.cas.client.validation.Assertion;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | package com.kakawait.spring.security.cas.client.ticket;
/**
* @author Thibaud Leprêtre
*/
@RunWith(MockitoJUnitRunner.class)
public class AttributePrincipalProxyTicketProviderTest {
@Mock | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/client/validation/AssertionProvider.java
// public interface AssertionProvider {
//
// /**
// * Retrieve current request {@link Assertion}.
// * @return the current request {@link Assertion}.
// */
// @Nonnull
// Assertion getAssertion();
// }
// Path: spring-security-cas-extension/src/test/java/com/kakawait/spring/security/cas/client/ticket/AttributePrincipalProxyTicketProviderTest.java
import com.kakawait.spring.security.cas.client.validation.AssertionProvider;
import org.jasig.cas.client.authentication.AttributePrincipal;
import org.jasig.cas.client.validation.Assertion;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
package com.kakawait.spring.security.cas.client.ticket;
/**
* @author Thibaud Leprêtre
*/
@RunWith(MockitoJUnitRunner.class)
public class AttributePrincipalProxyTicketProviderTest {
@Mock | private AssertionProvider assertionProvider; |
kakawait/cas-security-spring-boot-starter | spring-security-cas-extension/src/test/java/com/kakawait/spring/security/cas/web/authentication/ProxyCallbackAndServiceAuthenticationDetailsSourceTest.java | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/LaxServiceProperties.java
// public class LaxServiceProperties extends ServiceProperties {
//
// private final boolean dynamicServiceResolution;
//
// public LaxServiceProperties() {
// this(true);
// }
//
// public LaxServiceProperties(boolean dynamicServiceResolution) {
// this.dynamicServiceResolution = dynamicServiceResolution;
// }
//
// @Override
// public void afterPropertiesSet() {
// if (!dynamicServiceResolution) {
// try {
// super.afterPropertiesSet();
// } catch (RuntimeException e) {
// throw e;
// } catch (Exception e) {
// // Old version of spring security throw Exception for afterPropertiesSet()
// throw new RuntimeException(e);
// }
// } else {
// Assert.hasLength(getArtifactParameter(), "artifactParameter cannot be empty.");
// Assert.hasLength(getServiceParameter(), "serviceParameter cannot be empty.");
// }
// }
//
// public boolean isDynamicServiceResolution() {
// return dynamicServiceResolution;
// }
// }
| import com.kakawait.spring.security.cas.LaxServiceProperties;
import org.junit.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.security.cas.ServiceProperties;
import org.springframework.security.cas.web.authentication.ServiceAuthenticationDetails;
import java.net.URI;
import javax.servlet.http.HttpServletRequest;
import static org.assertj.core.api.Assertions.assertThat; | package com.kakawait.spring.security.cas.web.authentication;
/**
* @author Thibaud Leprêtre
*/
public class ProxyCallbackAndServiceAuthenticationDetailsSourceTest {
@Test
public void buildDetails_WithUri_DefaultProxyCallbackAndServiceAuthenticationDetails() { | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/LaxServiceProperties.java
// public class LaxServiceProperties extends ServiceProperties {
//
// private final boolean dynamicServiceResolution;
//
// public LaxServiceProperties() {
// this(true);
// }
//
// public LaxServiceProperties(boolean dynamicServiceResolution) {
// this.dynamicServiceResolution = dynamicServiceResolution;
// }
//
// @Override
// public void afterPropertiesSet() {
// if (!dynamicServiceResolution) {
// try {
// super.afterPropertiesSet();
// } catch (RuntimeException e) {
// throw e;
// } catch (Exception e) {
// // Old version of spring security throw Exception for afterPropertiesSet()
// throw new RuntimeException(e);
// }
// } else {
// Assert.hasLength(getArtifactParameter(), "artifactParameter cannot be empty.");
// Assert.hasLength(getServiceParameter(), "serviceParameter cannot be empty.");
// }
// }
//
// public boolean isDynamicServiceResolution() {
// return dynamicServiceResolution;
// }
// }
// Path: spring-security-cas-extension/src/test/java/com/kakawait/spring/security/cas/web/authentication/ProxyCallbackAndServiceAuthenticationDetailsSourceTest.java
import com.kakawait.spring.security.cas.LaxServiceProperties;
import org.junit.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.security.cas.ServiceProperties;
import org.springframework.security.cas.web.authentication.ServiceAuthenticationDetails;
import java.net.URI;
import javax.servlet.http.HttpServletRequest;
import static org.assertj.core.api.Assertions.assertThat;
package com.kakawait.spring.security.cas.web.authentication;
/**
* @author Thibaud Leprêtre
*/
public class ProxyCallbackAndServiceAuthenticationDetailsSourceTest {
@Test
public void buildDetails_WithUri_DefaultProxyCallbackAndServiceAuthenticationDetails() { | ServiceProperties serviceProperties = new LaxServiceProperties(); |
kakawait/cas-security-spring-boot-starter | spring-security-cas-extension/src/test/java/com/kakawait/spring/security/cas/client/CasAuthorizationInterceptorTest.java | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/client/ticket/ProxyTicketProvider.java
// public interface ProxyTicketProvider {
//
// /**
// * Ask proxy ticket for a given service to CAS server.
// *
// * @param service service name or (mostly) service URL
// * @return the proxy ticket or {@code null} if CAS server won't be able to return us a proxy ticket for given
// * {@code service}
// */
// String getProxyTicket(String service);
// }
| import com.kakawait.spring.security.cas.client.ticket.ProxyTicketProvider;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.mock.http.client.MockClientHttpRequest;
import org.springframework.security.cas.ServiceProperties;
import java.io.IOException;
import java.net.URI;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | package com.kakawait.spring.security.cas.client;
/**
* @author Thibaud Leprêtre
*/
@RunWith(MockitoJUnitRunner.class)
public class CasAuthorizationInterceptorTest {
@Mock | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/client/ticket/ProxyTicketProvider.java
// public interface ProxyTicketProvider {
//
// /**
// * Ask proxy ticket for a given service to CAS server.
// *
// * @param service service name or (mostly) service URL
// * @return the proxy ticket or {@code null} if CAS server won't be able to return us a proxy ticket for given
// * {@code service}
// */
// String getProxyTicket(String service);
// }
// Path: spring-security-cas-extension/src/test/java/com/kakawait/spring/security/cas/client/CasAuthorizationInterceptorTest.java
import com.kakawait.spring.security.cas.client.ticket.ProxyTicketProvider;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.mock.http.client.MockClientHttpRequest;
import org.springframework.security.cas.ServiceProperties;
import java.io.IOException;
import java.net.URI;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
package com.kakawait.spring.security.cas.client;
/**
* @author Thibaud Leprêtre
*/
@RunWith(MockitoJUnitRunner.class)
public class CasAuthorizationInterceptorTest {
@Mock | private ProxyTicketProvider proxyTicketProvider; |
kakawait/cas-security-spring-boot-starter | cas-security-spring-boot-autoconfigure/src/main/java/com/kakawait/spring/boot/security/cas/autoconfigure/SpringBoot1CasHttpSecurityConfigurerAdapter.java | // Path: cas-security-spring-boot-autoconfigure/src/main/java/com/kakawait/spring/boot/security/cas/autoconfigure/SpringBoot1CasHttpSecurityConfigurerAdapter.java
// static final String SECURITY_PROPERTIES_HEADERS_CLASS =
// "org.springframework.boot.autoconfigure.security.SecurityProperties$Headers";
| import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.cas.web.CasAuthenticationFilter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Method;
import java.util.List;
import static com.kakawait.spring.boot.security.cas.autoconfigure.SpringBoot1CasHttpSecurityConfigurerAdapter.SpringBoot1SecurityProperties.SECURITY_PROPERTIES_HEADERS_CLASS; | package com.kakawait.spring.boot.security.cas.autoconfigure;
/**
* @author Thibaud Leprêtre
*/
@Order(CasSecurityProperties.CAS_AUTH_ORDER - 10)
class SpringBoot1CasHttpSecurityConfigurerAdapter extends CasSecurityConfigurerAdapter {
private static final String SPRING_BOOT_WEB_SECURITY_CONFIGURATION_CLASS =
"org.springframework.boot.autoconfigure.security.SpringBootWebSecurityConfiguration";
private final SpringBoot1SecurityProperties securityProperties;
SpringBoot1CasHttpSecurityConfigurerAdapter(SpringBoot1SecurityProperties securityProperties) {
this.securityProperties = securityProperties;
}
@Override
public void configure(HttpSecurity http) throws Exception {
if (securityProperties.isRequireSsl()) {
http.requiresChannel().anyRequest().requiresSecure();
}
if (!securityProperties.isEnableCsrf()) {
http.csrf().disable();
}
configureHeaders(http);
if (securityProperties.getBasic().isEnabled()) {
BasicAuthenticationFilter basicAuthFilter = new BasicAuthenticationFilter(
http.getSharedObject(ApplicationContext.class).getBean(AuthenticationManager.class));
http.addFilterBefore(basicAuthFilter, CasAuthenticationFilter.class);
}
}
@SuppressWarnings("ConstantConditions")
private void configureHeaders(HttpSecurity http) throws Exception {
Method method = ReflectionUtils.findMethod(Class.forName(SPRING_BOOT_WEB_SECURITY_CONFIGURATION_CLASS), | // Path: cas-security-spring-boot-autoconfigure/src/main/java/com/kakawait/spring/boot/security/cas/autoconfigure/SpringBoot1CasHttpSecurityConfigurerAdapter.java
// static final String SECURITY_PROPERTIES_HEADERS_CLASS =
// "org.springframework.boot.autoconfigure.security.SecurityProperties$Headers";
// Path: cas-security-spring-boot-autoconfigure/src/main/java/com/kakawait/spring/boot/security/cas/autoconfigure/SpringBoot1CasHttpSecurityConfigurerAdapter.java
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.cas.web.CasAuthenticationFilter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Method;
import java.util.List;
import static com.kakawait.spring.boot.security.cas.autoconfigure.SpringBoot1CasHttpSecurityConfigurerAdapter.SpringBoot1SecurityProperties.SECURITY_PROPERTIES_HEADERS_CLASS;
package com.kakawait.spring.boot.security.cas.autoconfigure;
/**
* @author Thibaud Leprêtre
*/
@Order(CasSecurityProperties.CAS_AUTH_ORDER - 10)
class SpringBoot1CasHttpSecurityConfigurerAdapter extends CasSecurityConfigurerAdapter {
private static final String SPRING_BOOT_WEB_SECURITY_CONFIGURATION_CLASS =
"org.springframework.boot.autoconfigure.security.SpringBootWebSecurityConfiguration";
private final SpringBoot1SecurityProperties securityProperties;
SpringBoot1CasHttpSecurityConfigurerAdapter(SpringBoot1SecurityProperties securityProperties) {
this.securityProperties = securityProperties;
}
@Override
public void configure(HttpSecurity http) throws Exception {
if (securityProperties.isRequireSsl()) {
http.requiresChannel().anyRequest().requiresSecure();
}
if (!securityProperties.isEnableCsrf()) {
http.csrf().disable();
}
configureHeaders(http);
if (securityProperties.getBasic().isEnabled()) {
BasicAuthenticationFilter basicAuthFilter = new BasicAuthenticationFilter(
http.getSharedObject(ApplicationContext.class).getBean(AuthenticationManager.class));
http.addFilterBefore(basicAuthFilter, CasAuthenticationFilter.class);
}
}
@SuppressWarnings("ConstantConditions")
private void configureHeaders(HttpSecurity http) throws Exception {
Method method = ReflectionUtils.findMethod(Class.forName(SPRING_BOOT_WEB_SECURITY_CONFIGURATION_CLASS), | "configureHeaders", HeadersConfigurer.class, Class.forName(SECURITY_PROPERTIES_HEADERS_CLASS)); |
kakawait/cas-security-spring-boot-starter | cas-security-spring-boot-autoconfigure/src/test/java/com/kakawait/spring/boot/security/cas/autoconfigure/CasAuthenticationProviderSecurityBuilderTest.java | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/authentication/DynamicProxyCallbackUrlCasAuthenticationProvider.java
// public class DynamicProxyCallbackUrlCasAuthenticationProvider extends CasAuthenticationProvider {
// @Override
// public Authentication authenticate(Authentication authentication) {
// if (authentication.getDetails() instanceof ProxyCallbackAndServiceAuthenticationDetails) {
// if (getTicketValidator() instanceof Cas20ServiceTicketValidator) {
// String proxyCallbackUrl =
// ((ProxyCallbackAndServiceAuthenticationDetails) authentication.getDetails()).getProxyCallbackUrl();
// ((Cas20ServiceTicketValidator) getTicketValidator()).setProxyCallbackUrl(proxyCallbackUrl);
// } else if (getTicketValidator() instanceof ProxyCallbackUrlAwareTicketValidator) {
// String proxyCallbackUrl =
// ((ProxyCallbackAndServiceAuthenticationDetails) authentication.getDetails()).getProxyCallbackUrl();
// ((ProxyCallbackUrlAwareTicketValidator) getTicketValidator()).setProxyCallbackUrl(proxyCallbackUrl);
// }
// }
// return super.authenticate(authentication);
// }
// }
| import com.kakawait.spring.security.cas.authentication.DynamicProxyCallbackUrlCasAuthenticationProvider;
import org.jasig.cas.client.validation.TicketValidator;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.context.MessageSource;
import org.springframework.security.cas.authentication.CasAuthenticationProvider;
import org.springframework.security.cas.authentication.StatelessTicketCache;
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
import org.springframework.security.core.userdetails.AuthenticationUserDetailsService;
import java.util.Comparator;
import static org.assertj.core.api.Assertions.assertThat; | package com.kakawait.spring.boot.security.cas.autoconfigure;
/**
* @author Thibaud Leprêtre
*/
public class CasAuthenticationProviderSecurityBuilderTest {
private CasAuthenticationProviderSecurityBuilder builder;
@Before
public void setUp() {
builder = new CasAuthenticationProviderSecurityBuilder();
}
@Test
public void build_Default_ResolutionModeStatic() {
assertThat(builder.build()).isExactlyInstanceOf(CasAuthenticationProvider.class);
}
@Test
public void build_WithDynamicResolutionMode_InstanceOfDynamicProxyCallbackUrlCasAuthenticationProvider() {
builder.serviceResolutionMode(CasSecurityProperties.ServiceResolutionMode.DYNAMIC);
| // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/authentication/DynamicProxyCallbackUrlCasAuthenticationProvider.java
// public class DynamicProxyCallbackUrlCasAuthenticationProvider extends CasAuthenticationProvider {
// @Override
// public Authentication authenticate(Authentication authentication) {
// if (authentication.getDetails() instanceof ProxyCallbackAndServiceAuthenticationDetails) {
// if (getTicketValidator() instanceof Cas20ServiceTicketValidator) {
// String proxyCallbackUrl =
// ((ProxyCallbackAndServiceAuthenticationDetails) authentication.getDetails()).getProxyCallbackUrl();
// ((Cas20ServiceTicketValidator) getTicketValidator()).setProxyCallbackUrl(proxyCallbackUrl);
// } else if (getTicketValidator() instanceof ProxyCallbackUrlAwareTicketValidator) {
// String proxyCallbackUrl =
// ((ProxyCallbackAndServiceAuthenticationDetails) authentication.getDetails()).getProxyCallbackUrl();
// ((ProxyCallbackUrlAwareTicketValidator) getTicketValidator()).setProxyCallbackUrl(proxyCallbackUrl);
// }
// }
// return super.authenticate(authentication);
// }
// }
// Path: cas-security-spring-boot-autoconfigure/src/test/java/com/kakawait/spring/boot/security/cas/autoconfigure/CasAuthenticationProviderSecurityBuilderTest.java
import com.kakawait.spring.security.cas.authentication.DynamicProxyCallbackUrlCasAuthenticationProvider;
import org.jasig.cas.client.validation.TicketValidator;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.context.MessageSource;
import org.springframework.security.cas.authentication.CasAuthenticationProvider;
import org.springframework.security.cas.authentication.StatelessTicketCache;
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
import org.springframework.security.core.userdetails.AuthenticationUserDetailsService;
import java.util.Comparator;
import static org.assertj.core.api.Assertions.assertThat;
package com.kakawait.spring.boot.security.cas.autoconfigure;
/**
* @author Thibaud Leprêtre
*/
public class CasAuthenticationProviderSecurityBuilderTest {
private CasAuthenticationProviderSecurityBuilder builder;
@Before
public void setUp() {
builder = new CasAuthenticationProviderSecurityBuilder();
}
@Test
public void build_Default_ResolutionModeStatic() {
assertThat(builder.build()).isExactlyInstanceOf(CasAuthenticationProvider.class);
}
@Test
public void build_WithDynamicResolutionMode_InstanceOfDynamicProxyCallbackUrlCasAuthenticationProvider() {
builder.serviceResolutionMode(CasSecurityProperties.ServiceResolutionMode.DYNAMIC);
| assertThat(builder.build()).isExactlyInstanceOf(DynamicProxyCallbackUrlCasAuthenticationProvider.class); |
kakawait/cas-security-spring-boot-starter | spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/client/CasAuthorizationInterceptor.java | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/client/ticket/ProxyTicketProvider.java
// public interface ProxyTicketProvider {
//
// /**
// * Ask proxy ticket for a given service to CAS server.
// *
// * @param service service name or (mostly) service URL
// * @return the proxy ticket or {@code null} if CAS server won't be able to return us a proxy ticket for given
// * {@code service}
// */
// String getProxyTicket(String service);
// }
| import com.kakawait.spring.security.cas.client.ticket.ProxyTicketProvider;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.client.support.HttpRequestWrapper;
import org.springframework.security.cas.ServiceProperties;
import org.springframework.util.StringUtils;
import org.springframework.web.util.UriComponentsBuilder;
import java.io.IOException;
import java.net.URI; | package com.kakawait.spring.security.cas.client;
/**
* Implementation of {@link ClientHttpRequestInterceptor} to apply Proxy ticket query parameter.
*
* @see ProxyTicketProvider
* @author Jonathan Coueraud
* @author Thibaud Leprêtre
* @since 0.7.0
*/
public class CasAuthorizationInterceptor implements ClientHttpRequestInterceptor {
private final ServiceProperties serviceProperties;
| // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/client/ticket/ProxyTicketProvider.java
// public interface ProxyTicketProvider {
//
// /**
// * Ask proxy ticket for a given service to CAS server.
// *
// * @param service service name or (mostly) service URL
// * @return the proxy ticket or {@code null} if CAS server won't be able to return us a proxy ticket for given
// * {@code service}
// */
// String getProxyTicket(String service);
// }
// Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/client/CasAuthorizationInterceptor.java
import com.kakawait.spring.security.cas.client.ticket.ProxyTicketProvider;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.client.support.HttpRequestWrapper;
import org.springframework.security.cas.ServiceProperties;
import org.springframework.util.StringUtils;
import org.springframework.web.util.UriComponentsBuilder;
import java.io.IOException;
import java.net.URI;
package com.kakawait.spring.security.cas.client;
/**
* Implementation of {@link ClientHttpRequestInterceptor} to apply Proxy ticket query parameter.
*
* @see ProxyTicketProvider
* @author Jonathan Coueraud
* @author Thibaud Leprêtre
* @since 0.7.0
*/
public class CasAuthorizationInterceptor implements ClientHttpRequestInterceptor {
private final ServiceProperties serviceProperties;
| private final ProxyTicketProvider proxyTicketProvider; |
kakawait/cas-security-spring-boot-starter | spring-security-cas-extension/src/test/java/com/kakawait/spring/security/cas/web/RequestAwareCasAuthenticationEntryPointTest.java | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/LaxServiceProperties.java
// public class LaxServiceProperties extends ServiceProperties {
//
// private final boolean dynamicServiceResolution;
//
// public LaxServiceProperties() {
// this(true);
// }
//
// public LaxServiceProperties(boolean dynamicServiceResolution) {
// this.dynamicServiceResolution = dynamicServiceResolution;
// }
//
// @Override
// public void afterPropertiesSet() {
// if (!dynamicServiceResolution) {
// try {
// super.afterPropertiesSet();
// } catch (RuntimeException e) {
// throw e;
// } catch (Exception e) {
// // Old version of spring security throw Exception for afterPropertiesSet()
// throw new RuntimeException(e);
// }
// } else {
// Assert.hasLength(getArtifactParameter(), "artifactParameter cannot be empty.");
// Assert.hasLength(getServiceParameter(), "serviceParameter cannot be empty.");
// }
// }
//
// public boolean isDynamicServiceResolution() {
// return dynamicServiceResolution;
// }
// }
| import com.kakawait.spring.security.cas.LaxServiceProperties;
import org.junit.Test;
import org.springframework.http.HttpMethod;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import java.net.URI;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy; | package com.kakawait.spring.security.cas.web;
/**
* @author Thibaud Leprêtre
*/
public class RequestAwareCasAuthenticationEntryPointTest {
private static final String CAS_SERVER_LOGIN_URL = "http://cas.server.com/cas/login";
@Test
public void constructor_WithNullLoginPath_IllegalArgumentException() {
assertThatThrownBy(() -> new RequestAwareCasAuthenticationEntryPoint(null))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
public void afterPropertiesSet_WithNullOrEmptyLoginUrl_IllegalArgumentException() {
RequestAwareCasAuthenticationEntryPoint entryPoint =
new RequestAwareCasAuthenticationEntryPoint(URI.create("/"));
entryPoint.setLoginUrl(null);
assertThatThrownBy(entryPoint::afterPropertiesSet).isInstanceOf(IllegalArgumentException.class);
entryPoint.setLoginUrl("");
assertThatThrownBy(entryPoint::afterPropertiesSet).isInstanceOf(IllegalArgumentException.class);
}
@Test
public void afterPropertiesSet_WithNullLoginUrl_IllegalArgumentException() {
RequestAwareCasAuthenticationEntryPoint entryPoint =
new RequestAwareCasAuthenticationEntryPoint(URI.create("/"));
entryPoint.setServiceProperties(null);
assertThatThrownBy(entryPoint::afterPropertiesSet).isInstanceOf(IllegalArgumentException.class);
}
@Test
public void createServiceUrl_AbsoluteUrlAsLoginPath_NoTransformation() {
String loginPath = "http://localhost/my/custom/login/path";
RequestAwareCasAuthenticationEntryPoint entryPoint =
new RequestAwareCasAuthenticationEntryPoint(URI.create(loginPath));
entryPoint.setLoginUrl(CAS_SERVER_LOGIN_URL); | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/LaxServiceProperties.java
// public class LaxServiceProperties extends ServiceProperties {
//
// private final boolean dynamicServiceResolution;
//
// public LaxServiceProperties() {
// this(true);
// }
//
// public LaxServiceProperties(boolean dynamicServiceResolution) {
// this.dynamicServiceResolution = dynamicServiceResolution;
// }
//
// @Override
// public void afterPropertiesSet() {
// if (!dynamicServiceResolution) {
// try {
// super.afterPropertiesSet();
// } catch (RuntimeException e) {
// throw e;
// } catch (Exception e) {
// // Old version of spring security throw Exception for afterPropertiesSet()
// throw new RuntimeException(e);
// }
// } else {
// Assert.hasLength(getArtifactParameter(), "artifactParameter cannot be empty.");
// Assert.hasLength(getServiceParameter(), "serviceParameter cannot be empty.");
// }
// }
//
// public boolean isDynamicServiceResolution() {
// return dynamicServiceResolution;
// }
// }
// Path: spring-security-cas-extension/src/test/java/com/kakawait/spring/security/cas/web/RequestAwareCasAuthenticationEntryPointTest.java
import com.kakawait.spring.security.cas.LaxServiceProperties;
import org.junit.Test;
import org.springframework.http.HttpMethod;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import java.net.URI;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
package com.kakawait.spring.security.cas.web;
/**
* @author Thibaud Leprêtre
*/
public class RequestAwareCasAuthenticationEntryPointTest {
private static final String CAS_SERVER_LOGIN_URL = "http://cas.server.com/cas/login";
@Test
public void constructor_WithNullLoginPath_IllegalArgumentException() {
assertThatThrownBy(() -> new RequestAwareCasAuthenticationEntryPoint(null))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
public void afterPropertiesSet_WithNullOrEmptyLoginUrl_IllegalArgumentException() {
RequestAwareCasAuthenticationEntryPoint entryPoint =
new RequestAwareCasAuthenticationEntryPoint(URI.create("/"));
entryPoint.setLoginUrl(null);
assertThatThrownBy(entryPoint::afterPropertiesSet).isInstanceOf(IllegalArgumentException.class);
entryPoint.setLoginUrl("");
assertThatThrownBy(entryPoint::afterPropertiesSet).isInstanceOf(IllegalArgumentException.class);
}
@Test
public void afterPropertiesSet_WithNullLoginUrl_IllegalArgumentException() {
RequestAwareCasAuthenticationEntryPoint entryPoint =
new RequestAwareCasAuthenticationEntryPoint(URI.create("/"));
entryPoint.setServiceProperties(null);
assertThatThrownBy(entryPoint::afterPropertiesSet).isInstanceOf(IllegalArgumentException.class);
}
@Test
public void createServiceUrl_AbsoluteUrlAsLoginPath_NoTransformation() {
String loginPath = "http://localhost/my/custom/login/path";
RequestAwareCasAuthenticationEntryPoint entryPoint =
new RequestAwareCasAuthenticationEntryPoint(URI.create(loginPath));
entryPoint.setLoginUrl(CAS_SERVER_LOGIN_URL); | entryPoint.setServiceProperties(new LaxServiceProperties()); |
kakawait/cas-security-spring-boot-starter | spring-security-cas-extension/src/test/java/com/kakawait/spring/security/cas/web/authentication/RequestAwareCasLogoutSuccessHandlerTest.java | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/LaxServiceProperties.java
// public class LaxServiceProperties extends ServiceProperties {
//
// private final boolean dynamicServiceResolution;
//
// public LaxServiceProperties() {
// this(true);
// }
//
// public LaxServiceProperties(boolean dynamicServiceResolution) {
// this.dynamicServiceResolution = dynamicServiceResolution;
// }
//
// @Override
// public void afterPropertiesSet() {
// if (!dynamicServiceResolution) {
// try {
// super.afterPropertiesSet();
// } catch (RuntimeException e) {
// throw e;
// } catch (Exception e) {
// // Old version of spring security throw Exception for afterPropertiesSet()
// throw new RuntimeException(e);
// }
// } else {
// Assert.hasLength(getArtifactParameter(), "artifactParameter cannot be empty.");
// Assert.hasLength(getServiceParameter(), "serviceParameter cannot be empty.");
// }
// }
//
// public boolean isDynamicServiceResolution() {
// return dynamicServiceResolution;
// }
// }
| import com.kakawait.spring.security.cas.LaxServiceProperties;
import org.junit.Before;
import org.junit.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import java.io.IOException;
import java.net.URI;
import javax.servlet.ServletException;
import static java.net.URLEncoder.encode;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat; | package com.kakawait.spring.security.cas.web.authentication;
/**
* @author Thibaud Leprêtre
*/
public class RequestAwareCasLogoutSuccessHandlerTest {
private static final URI casLogout = URI.create("http://cas.server/cas/logout");
private MockHttpServletRequest request;
private MockHttpServletResponse response;
@Before
public void setUp() {
request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
}
@Test
public void onLogoutSuccess_WithService_UseHttpServletRequestAsService()
throws IOException, ServletException { | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/LaxServiceProperties.java
// public class LaxServiceProperties extends ServiceProperties {
//
// private final boolean dynamicServiceResolution;
//
// public LaxServiceProperties() {
// this(true);
// }
//
// public LaxServiceProperties(boolean dynamicServiceResolution) {
// this.dynamicServiceResolution = dynamicServiceResolution;
// }
//
// @Override
// public void afterPropertiesSet() {
// if (!dynamicServiceResolution) {
// try {
// super.afterPropertiesSet();
// } catch (RuntimeException e) {
// throw e;
// } catch (Exception e) {
// // Old version of spring security throw Exception for afterPropertiesSet()
// throw new RuntimeException(e);
// }
// } else {
// Assert.hasLength(getArtifactParameter(), "artifactParameter cannot be empty.");
// Assert.hasLength(getServiceParameter(), "serviceParameter cannot be empty.");
// }
// }
//
// public boolean isDynamicServiceResolution() {
// return dynamicServiceResolution;
// }
// }
// Path: spring-security-cas-extension/src/test/java/com/kakawait/spring/security/cas/web/authentication/RequestAwareCasLogoutSuccessHandlerTest.java
import com.kakawait.spring.security.cas.LaxServiceProperties;
import org.junit.Before;
import org.junit.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import java.io.IOException;
import java.net.URI;
import javax.servlet.ServletException;
import static java.net.URLEncoder.encode;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
package com.kakawait.spring.security.cas.web.authentication;
/**
* @author Thibaud Leprêtre
*/
public class RequestAwareCasLogoutSuccessHandlerTest {
private static final URI casLogout = URI.create("http://cas.server/cas/logout");
private MockHttpServletRequest request;
private MockHttpServletResponse response;
@Before
public void setUp() {
request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
}
@Test
public void onLogoutSuccess_WithService_UseHttpServletRequestAsService()
throws IOException, ServletException { | LaxServiceProperties serviceProperties = new LaxServiceProperties(); |
kakawait/cas-security-spring-boot-starter | spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/client/ticket/AttributePrincipalProxyTicketProvider.java | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/client/validation/AssertionProvider.java
// public interface AssertionProvider {
//
// /**
// * Retrieve current request {@link Assertion}.
// * @return the current request {@link Assertion}.
// */
// @Nonnull
// Assertion getAssertion();
// }
| import com.kakawait.spring.security.cas.client.validation.AssertionProvider;
import org.jasig.cas.client.authentication.AttributePrincipal;
import org.jasig.cas.client.validation.Assertion;
import org.springframework.util.Assert; | package com.kakawait.spring.security.cas.client.ticket;
/**
* A standard implementation of {@link ProxyTicketProvider} that rely on
* {@link AttributePrincipal#getProxyTicketFor(String)}.
*
* @see AssertionProvider
* @author Jonathan Coueraud
* @author Thibaud Leprêtre
* @since 0.7.0
*/
public class AttributePrincipalProxyTicketProvider implements ProxyTicketProvider {
private static final String EXCEPTION_MESSAGE = "Unable to provide a proxy ticket with null %s";
| // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/client/validation/AssertionProvider.java
// public interface AssertionProvider {
//
// /**
// * Retrieve current request {@link Assertion}.
// * @return the current request {@link Assertion}.
// */
// @Nonnull
// Assertion getAssertion();
// }
// Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/client/ticket/AttributePrincipalProxyTicketProvider.java
import com.kakawait.spring.security.cas.client.validation.AssertionProvider;
import org.jasig.cas.client.authentication.AttributePrincipal;
import org.jasig.cas.client.validation.Assertion;
import org.springframework.util.Assert;
package com.kakawait.spring.security.cas.client.ticket;
/**
* A standard implementation of {@link ProxyTicketProvider} that rely on
* {@link AttributePrincipal#getProxyTicketFor(String)}.
*
* @see AssertionProvider
* @author Jonathan Coueraud
* @author Thibaud Leprêtre
* @since 0.7.0
*/
public class AttributePrincipalProxyTicketProvider implements ProxyTicketProvider {
private static final String EXCEPTION_MESSAGE = "Unable to provide a proxy ticket with null %s";
| private final AssertionProvider assertionProvider; |
kakawait/cas-security-spring-boot-starter | spring-security-cas-extension/src/test/java/com/kakawait/spring/security/cas/authentication/DynamicProxyCallbackUrlCasAuthenticationProviderTest.java | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/web/authentication/ProxyCallbackAndServiceAuthenticationDetails.java
// public interface ProxyCallbackAndServiceAuthenticationDetails extends ServiceAuthenticationDetails {
// String getProxyCallbackUrl();
//
// void setContext(HttpServletRequest context);
// }
| import com.kakawait.spring.security.cas.web.authentication.ProxyCallbackAndServiceAuthenticationDetails;
import org.jasig.cas.client.validation.Cas20ServiceTicketValidator;
import org.jasig.cas.client.validation.TicketValidator;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.security.cas.web.authentication.ServiceAuthenticationDetails;
import org.springframework.security.core.Authentication;
import javax.servlet.http.HttpServletRequest;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when; | when(authentication.getDetails()).thenReturn(null);
authenticationProvider.authenticate(authentication);
verify(authentication, times(1)).getDetails();
verifyZeroInteractions(ticketValidator);
}
@Test
public void authenticate_WithDetailsNotInstanceOfProxyCallbackAndServiceAuthenticationDetails_DoNothing() {
TicketValidator ticketValidator = mock(TicketValidator.class);
DynamicProxyCallbackUrlCasAuthenticationProvider authenticationProvider =
new DynamicProxyCallbackUrlCasAuthenticationProvider();
authenticationProvider.setTicketValidator(ticketValidator);
when(authentication.getDetails()).thenReturn((ServiceAuthenticationDetails) () -> "http://localhost");
authenticationProvider.authenticate(authentication);
verify(authentication, times(1)).getDetails();
verifyZeroInteractions(ticketValidator);
}
@Test
public void authenticate_WithNullTicketValidator_DoNothing() {
DynamicProxyCallbackUrlCasAuthenticationProvider authenticationProvider =
new DynamicProxyCallbackUrlCasAuthenticationProvider();
authenticationProvider.setTicketValidator(null);
| // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/web/authentication/ProxyCallbackAndServiceAuthenticationDetails.java
// public interface ProxyCallbackAndServiceAuthenticationDetails extends ServiceAuthenticationDetails {
// String getProxyCallbackUrl();
//
// void setContext(HttpServletRequest context);
// }
// Path: spring-security-cas-extension/src/test/java/com/kakawait/spring/security/cas/authentication/DynamicProxyCallbackUrlCasAuthenticationProviderTest.java
import com.kakawait.spring.security.cas.web.authentication.ProxyCallbackAndServiceAuthenticationDetails;
import org.jasig.cas.client.validation.Cas20ServiceTicketValidator;
import org.jasig.cas.client.validation.TicketValidator;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.security.cas.web.authentication.ServiceAuthenticationDetails;
import org.springframework.security.core.Authentication;
import javax.servlet.http.HttpServletRequest;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
when(authentication.getDetails()).thenReturn(null);
authenticationProvider.authenticate(authentication);
verify(authentication, times(1)).getDetails();
verifyZeroInteractions(ticketValidator);
}
@Test
public void authenticate_WithDetailsNotInstanceOfProxyCallbackAndServiceAuthenticationDetails_DoNothing() {
TicketValidator ticketValidator = mock(TicketValidator.class);
DynamicProxyCallbackUrlCasAuthenticationProvider authenticationProvider =
new DynamicProxyCallbackUrlCasAuthenticationProvider();
authenticationProvider.setTicketValidator(ticketValidator);
when(authentication.getDetails()).thenReturn((ServiceAuthenticationDetails) () -> "http://localhost");
authenticationProvider.authenticate(authentication);
verify(authentication, times(1)).getDetails();
verifyZeroInteractions(ticketValidator);
}
@Test
public void authenticate_WithNullTicketValidator_DoNothing() {
DynamicProxyCallbackUrlCasAuthenticationProvider authenticationProvider =
new DynamicProxyCallbackUrlCasAuthenticationProvider();
authenticationProvider.setTicketValidator(null);
| when(authentication.getDetails()).thenReturn(new ProxyCallbackAndServiceAuthenticationDetails() { |
kakawait/cas-security-spring-boot-starter | cas-security-spring-boot-autoconfigure/src/main/java/com/kakawait/spring/boot/security/cas/autoconfigure/CasAssertionUserDetailsServiceConfiguration.java | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/userdetails/GrantedAuthoritiesFromAssertionAttributesWithDefaultRolesUserDetailsService.java
// public class GrantedAuthoritiesFromAssertionAttributesWithDefaultRolesUserDetailsService
// extends AbstractCasAssertionUserDetailsService {
//
// private static final String NON_EXISTENT_PASSWORD_VALUE = "NO_PASSWORD";
//
// private final String[] attributes;
//
// private final Collection<? extends GrantedAuthority> defaultGrantedAuthorities;
//
// private boolean toUppercase = true;
//
// public GrantedAuthoritiesFromAssertionAttributesWithDefaultRolesUserDetailsService(String[] attributes,
// Collection<? extends GrantedAuthority> defaultGrantedAuthorities) {
// this.attributes = (attributes == null) ? new String[0] : attributes;
// this.defaultGrantedAuthorities = (defaultGrantedAuthorities == null) ? new ArrayList<>()
// : defaultGrantedAuthorities;
// }
//
// protected UserDetails loadUserDetails(Assertion assertion) {
// String username = assertion.getPrincipal().getName();
// if (!StringUtils.hasText(username)) {
// throw new UsernameNotFoundException("Unable to retrieve username from CAS assertion");
// }
//
// Map<String, Object> principalAttributes = assertion.getPrincipal().getAttributes();
// List<GrantedAuthority> authorities = Arrays
// .stream(attributes)
// .map(principalAttributes::get)
// .filter(Objects::nonNull)
// .flatMap(v -> (v instanceof Collection) ? ((Collection<?>) v).stream() : Stream.of(v))
// .map(v -> toUppercase ? v.toString().toUpperCase() : v.toString())
// .map(r -> r.replaceFirst("^ROLE_", ""))
// .map(r -> new SimpleGrantedAuthority("ROLE_" + r))
// .collect(Collectors.toList());
//
// authorities.addAll(defaultGrantedAuthorities);
//
// return new User(username, NON_EXISTENT_PASSWORD_VALUE, authorities);
// }
// }
| import com.kakawait.spring.security.cas.userdetails.GrantedAuthoritiesFromAssertionAttributesWithDefaultRolesUserDetailsService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.security.cas.userdetails.AbstractCasAssertionUserDetailsService;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors; | package com.kakawait.spring.boot.security.cas.autoconfigure;
/**
* @author Thibaud Leprêtre
*/
@ConditionalOnMissingBean(AbstractCasAssertionUserDetailsService.class)
class CasAssertionUserDetailsServiceConfiguration {
@Bean
AbstractCasAssertionUserDetailsService defaultRolesAuthenticationUserDetailsService(
CasSecurityProperties casSecurityProperties) {
Set<SimpleGrantedAuthority> authorities = Arrays.stream(casSecurityProperties.getUser().getDefaultRoles())
.map(r -> r.replaceFirst("^ROLE_", ""))
.map(r -> new SimpleGrantedAuthority("ROLE_" + r))
.collect(Collectors.toSet());
String[] attributes = casSecurityProperties.getUser().getRolesAttributes(); | // Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/userdetails/GrantedAuthoritiesFromAssertionAttributesWithDefaultRolesUserDetailsService.java
// public class GrantedAuthoritiesFromAssertionAttributesWithDefaultRolesUserDetailsService
// extends AbstractCasAssertionUserDetailsService {
//
// private static final String NON_EXISTENT_PASSWORD_VALUE = "NO_PASSWORD";
//
// private final String[] attributes;
//
// private final Collection<? extends GrantedAuthority> defaultGrantedAuthorities;
//
// private boolean toUppercase = true;
//
// public GrantedAuthoritiesFromAssertionAttributesWithDefaultRolesUserDetailsService(String[] attributes,
// Collection<? extends GrantedAuthority> defaultGrantedAuthorities) {
// this.attributes = (attributes == null) ? new String[0] : attributes;
// this.defaultGrantedAuthorities = (defaultGrantedAuthorities == null) ? new ArrayList<>()
// : defaultGrantedAuthorities;
// }
//
// protected UserDetails loadUserDetails(Assertion assertion) {
// String username = assertion.getPrincipal().getName();
// if (!StringUtils.hasText(username)) {
// throw new UsernameNotFoundException("Unable to retrieve username from CAS assertion");
// }
//
// Map<String, Object> principalAttributes = assertion.getPrincipal().getAttributes();
// List<GrantedAuthority> authorities = Arrays
// .stream(attributes)
// .map(principalAttributes::get)
// .filter(Objects::nonNull)
// .flatMap(v -> (v instanceof Collection) ? ((Collection<?>) v).stream() : Stream.of(v))
// .map(v -> toUppercase ? v.toString().toUpperCase() : v.toString())
// .map(r -> r.replaceFirst("^ROLE_", ""))
// .map(r -> new SimpleGrantedAuthority("ROLE_" + r))
// .collect(Collectors.toList());
//
// authorities.addAll(defaultGrantedAuthorities);
//
// return new User(username, NON_EXISTENT_PASSWORD_VALUE, authorities);
// }
// }
// Path: cas-security-spring-boot-autoconfigure/src/main/java/com/kakawait/spring/boot/security/cas/autoconfigure/CasAssertionUserDetailsServiceConfiguration.java
import com.kakawait.spring.security.cas.userdetails.GrantedAuthoritiesFromAssertionAttributesWithDefaultRolesUserDetailsService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.security.cas.userdetails.AbstractCasAssertionUserDetailsService;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
package com.kakawait.spring.boot.security.cas.autoconfigure;
/**
* @author Thibaud Leprêtre
*/
@ConditionalOnMissingBean(AbstractCasAssertionUserDetailsService.class)
class CasAssertionUserDetailsServiceConfiguration {
@Bean
AbstractCasAssertionUserDetailsService defaultRolesAuthenticationUserDetailsService(
CasSecurityProperties casSecurityProperties) {
Set<SimpleGrantedAuthority> authorities = Arrays.stream(casSecurityProperties.getUser().getDefaultRoles())
.map(r -> r.replaceFirst("^ROLE_", ""))
.map(r -> new SimpleGrantedAuthority("ROLE_" + r))
.collect(Collectors.toSet());
String[] attributes = casSecurityProperties.getUser().getRolesAttributes(); | return new GrantedAuthoritiesFromAssertionAttributesWithDefaultRolesUserDetailsService(attributes, authorities); |
naver/android-utilset | UtilSetSampleApp/src/com/navercorp/utilsettest/input/KeyboardUtilsTestActivity.java | // Path: UtilSet/src/com/navercorp/utilset/input/KeyboardUtils.java
// public class KeyboardUtils {
// private static SoftwareKeyDetector deviceKeyboardDetector;
//
// static {
// deviceKeyboardDetector = new SoftwareKeyDetector();
// }
//
// /**
// * Shows keypad
// *
// * @param context
// * @param view View to have keypad control
// */
// public static void showSoftKeyboard(Context context, View view) {
// InputMethodManager imm = (InputMethodManager) context
// .getSystemService(Context.INPUT_METHOD_SERVICE);
// imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
// }
//
// /**
// * Hides keypad
// *
// * @param context
// * @param view View holding keypad control
// */
// public static void hideSoftKeyboard(Context context, View view) {
// InputMethodManager imm = (InputMethodManager) context
// .getSystemService(Context.INPUT_METHOD_SERVICE);
// imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
// }
//
// /**
// * Toggles keypad
// *
// * @param context
// */
// public static void toggleKeyPad(Context context) {
// InputMethodManager imm = (InputMethodManager) context
// .getSystemService(Context.INPUT_METHOD_SERVICE);
// if (imm != null) {
// imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
// }
// }
//
// /**
// * Delayed version of {@link #hideSoftKeyboard(Context, View)
// * hideSoftKeyboard} method
// *
// * @param context
// * @param view View holding keypad control
// */
// public static void delayedHideSoftKeyboard(final Context context,
// final View view, int delay) {
// TimerTask task = new TimerTask() {
// @Override
// public void run() {
// hideSoftKeyboard(context, view);
// }
// };
//
// Timer timer = new Timer();
// timer.schedule(task, delay);
// }
//
// /**
// * Delayed version of {@link #showSoftKeyboard(Context, View)
// * showSoftKeyboard} method
// *
// * @param context
// * @param view View to have keypad control
// */
// public static void delayedShowSoftKeyboard(final Context context,
// final View view, int delay) {
// TimerTask task = new TimerTask() {
// @Override
// public void run() {
// showSoftKeyboard(context, view);
// }
// };
//
// Timer timer = new Timer();
// timer.schedule(task, delay);
// }
//
// /**
// * Determines if the device has software keys.
// *
// * @return true if device has software keys; false otherwise
// */
// public static boolean hasSoftwareKeys(Context context) {
// return deviceKeyboardDetector.hasSoftwareKeys(context);
// }
// }
| import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import com.navercorp.utilset.input.KeyboardUtils;
import com.navercorp.utilsettest.R; | package com.navercorp.utilsettest.input;
public class KeyboardUtilsTestActivity extends FragmentActivity implements OnClickListener {
Context context;
EditText editTextKeyboardUtils;
Button keyboardUtilsShowButton;
Button keyboardUtilsHideButton;
Button keyboardUtilsToggleButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_keyboardutils);
editTextKeyboardUtils = (EditText) findViewById(R.id.editTextKeyboardUtils);
keyboardUtilsShowButton = (Button) findViewById(R.id.keyboardUtilsShowButton);
keyboardUtilsHideButton = (Button) findViewById(R.id.keyboardUtilsHideButton);
keyboardUtilsToggleButton = (Button) findViewById(R.id.keyboardUtilsToggleButton);
keyboardUtilsShowButton.setOnClickListener(this);
keyboardUtilsHideButton.setOnClickListener(this);
keyboardUtilsToggleButton.setOnClickListener(this);
context = this;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
int id = v.getId();
switch (id) {
case R.id.keyboardUtilsShowButton : | // Path: UtilSet/src/com/navercorp/utilset/input/KeyboardUtils.java
// public class KeyboardUtils {
// private static SoftwareKeyDetector deviceKeyboardDetector;
//
// static {
// deviceKeyboardDetector = new SoftwareKeyDetector();
// }
//
// /**
// * Shows keypad
// *
// * @param context
// * @param view View to have keypad control
// */
// public static void showSoftKeyboard(Context context, View view) {
// InputMethodManager imm = (InputMethodManager) context
// .getSystemService(Context.INPUT_METHOD_SERVICE);
// imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
// }
//
// /**
// * Hides keypad
// *
// * @param context
// * @param view View holding keypad control
// */
// public static void hideSoftKeyboard(Context context, View view) {
// InputMethodManager imm = (InputMethodManager) context
// .getSystemService(Context.INPUT_METHOD_SERVICE);
// imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
// }
//
// /**
// * Toggles keypad
// *
// * @param context
// */
// public static void toggleKeyPad(Context context) {
// InputMethodManager imm = (InputMethodManager) context
// .getSystemService(Context.INPUT_METHOD_SERVICE);
// if (imm != null) {
// imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
// }
// }
//
// /**
// * Delayed version of {@link #hideSoftKeyboard(Context, View)
// * hideSoftKeyboard} method
// *
// * @param context
// * @param view View holding keypad control
// */
// public static void delayedHideSoftKeyboard(final Context context,
// final View view, int delay) {
// TimerTask task = new TimerTask() {
// @Override
// public void run() {
// hideSoftKeyboard(context, view);
// }
// };
//
// Timer timer = new Timer();
// timer.schedule(task, delay);
// }
//
// /**
// * Delayed version of {@link #showSoftKeyboard(Context, View)
// * showSoftKeyboard} method
// *
// * @param context
// * @param view View to have keypad control
// */
// public static void delayedShowSoftKeyboard(final Context context,
// final View view, int delay) {
// TimerTask task = new TimerTask() {
// @Override
// public void run() {
// showSoftKeyboard(context, view);
// }
// };
//
// Timer timer = new Timer();
// timer.schedule(task, delay);
// }
//
// /**
// * Determines if the device has software keys.
// *
// * @return true if device has software keys; false otherwise
// */
// public static boolean hasSoftwareKeys(Context context) {
// return deviceKeyboardDetector.hasSoftwareKeys(context);
// }
// }
// Path: UtilSetSampleApp/src/com/navercorp/utilsettest/input/KeyboardUtilsTestActivity.java
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import com.navercorp.utilset.input.KeyboardUtils;
import com.navercorp.utilsettest.R;
package com.navercorp.utilsettest.input;
public class KeyboardUtilsTestActivity extends FragmentActivity implements OnClickListener {
Context context;
EditText editTextKeyboardUtils;
Button keyboardUtilsShowButton;
Button keyboardUtilsHideButton;
Button keyboardUtilsToggleButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_keyboardutils);
editTextKeyboardUtils = (EditText) findViewById(R.id.editTextKeyboardUtils);
keyboardUtilsShowButton = (Button) findViewById(R.id.keyboardUtilsShowButton);
keyboardUtilsHideButton = (Button) findViewById(R.id.keyboardUtilsHideButton);
keyboardUtilsToggleButton = (Button) findViewById(R.id.keyboardUtilsToggleButton);
keyboardUtilsShowButton.setOnClickListener(this);
keyboardUtilsHideButton.setOnClickListener(this);
keyboardUtilsToggleButton.setOnClickListener(this);
context = this;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
int id = v.getId();
switch (id) {
case R.id.keyboardUtilsShowButton : | KeyboardUtils.showSoftKeyboard(this, editTextKeyboardUtils); |
naver/android-utilset | UtilSetSampleApp/src/com/navercorp/utilsettest/system/SystemUtilsTestActivity.java | // Path: UtilSet/src/com/navercorp/utilset/system/SystemUtils.java
// public class SystemUtils {
// private static RootChecker rootChecker;
//
// static {
// rootChecker = new RootChecker();
// }
//
// /**
// * Returns boolean that indicates whether current device is rooted or not.
// *
// * <p>This method is <i>not</i> guaranteed to cover all the root methods.
// * It takes simple approach;
// * It tries to finds 'su' command and then executes.
// * If 'su' command is not found or unable to execute then an exception will be thrown.
// * This indicates that device is rooted.
// * Because this is well known way to check root, Root tools today may not be detected by this method.
// * For more detailed implementation, refer to '<a href=https://code.google.com/p/roottools/>RootTools</a>' library.
// *
// * @return true if the device is rooted; false otherwise
// * @throws RuntimeException if root check fails
// */
// public static boolean isRooted() {
// return rootChecker.checkRootingDevice();
// }
//
// /**
// * Returns the number of cores of device.<br>
// * Until JELLY_BEAN_MR1, It is possible for processors to be off-line for power saving purpose and those off-line CPUs may not be counted.<br>
// * Use this method if Runtime.availableProcessors() seems not to return exact core numbers.
// *
// * @return the number of cores
// */
// public static int getProcessorNumbers() {
// return ProcessorUtils.getNumCores();
// }
// }
| import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.widget.TextView;
import com.navercorp.utilset.system.SystemUtils;
import com.navercorp.utilsettest.R; |
utilSetTask = new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
// TODO Auto-generated method stub
return utilSetTest();
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
textViewSystemUtils.setText(result);
}
};
utilSetTask.execute();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
utilSetTask.cancel(true);
utilSetTask = null;
}
public String utilSetTest() {
String result = "*************** UtilSetTest ***************\n"; | // Path: UtilSet/src/com/navercorp/utilset/system/SystemUtils.java
// public class SystemUtils {
// private static RootChecker rootChecker;
//
// static {
// rootChecker = new RootChecker();
// }
//
// /**
// * Returns boolean that indicates whether current device is rooted or not.
// *
// * <p>This method is <i>not</i> guaranteed to cover all the root methods.
// * It takes simple approach;
// * It tries to finds 'su' command and then executes.
// * If 'su' command is not found or unable to execute then an exception will be thrown.
// * This indicates that device is rooted.
// * Because this is well known way to check root, Root tools today may not be detected by this method.
// * For more detailed implementation, refer to '<a href=https://code.google.com/p/roottools/>RootTools</a>' library.
// *
// * @return true if the device is rooted; false otherwise
// * @throws RuntimeException if root check fails
// */
// public static boolean isRooted() {
// return rootChecker.checkRootingDevice();
// }
//
// /**
// * Returns the number of cores of device.<br>
// * Until JELLY_BEAN_MR1, It is possible for processors to be off-line for power saving purpose and those off-line CPUs may not be counted.<br>
// * Use this method if Runtime.availableProcessors() seems not to return exact core numbers.
// *
// * @return the number of cores
// */
// public static int getProcessorNumbers() {
// return ProcessorUtils.getNumCores();
// }
// }
// Path: UtilSetSampleApp/src/com/navercorp/utilsettest/system/SystemUtilsTestActivity.java
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.widget.TextView;
import com.navercorp.utilset.system.SystemUtils;
import com.navercorp.utilsettest.R;
utilSetTask = new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
// TODO Auto-generated method stub
return utilSetTest();
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
textViewSystemUtils.setText(result);
}
};
utilSetTask.execute();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
utilSetTask.cancel(true);
utilSetTask = null;
}
public String utilSetTest() {
String result = "*************** UtilSetTest ***************\n"; | result += "getProcessorNumbers : " + SystemUtils.getProcessorNumbers() +"\n"; |
naver/android-utilset | UtilSetSampleApp/src/com/navercorp/utilsettest/device/DeviceUtilsTestActivity.java | // Path: UtilSet/src/com/navercorp/utilset/device/DeviceUtils.java
// public class DeviceUtils {
// private static DeviceTypeDetector deviceTypeDetector;
// private static PhoneNumberUtils phoneNumberUtils;
//
// static {
// phoneNumberUtils = new PhoneNumberUtils();
// deviceTypeDetector = new DeviceTypeDetector();
// }
//
// /**
// * Gives type information of user device.<br>
// *
// * According to the <a href="http://developer.android.com/guide/practices/screens_support.html">Google API guide</a>,
// * devices whose screen size is less than 7 inches will be classified as a handset.<br>
// * For example, Huge looking mobile phones like Samsung galaxy Note III will be sorted as a handset by this rule.<br>
// * Among the rest, devices with 7 inch screen and LDPI will be classified as a handset too.<br>
// * All other devices with 7 or larger screen will be classified as a tablet.
// *
// * @param context
// * Context derived from Activity. ApplicationContext can not be
// * used to take advantage of this function.
// *
// * @return DeviceType.Tablet if the screen size is equal to or larger than
// * XLarge, which is defined as display size from 7 to 10 inches; <br>
// * DeviceType.Handset if the screen size is smaller than XLarge
// */
// public static DeviceType getDeviceType(Context context) {
// return deviceTypeDetector.getDeviceType(context);
// }
//
// /**
// * Returns launcher type.
// *
// * @param context
// * Context to provide package information
// * @return LauncherType
// */
// public static LauncherType getLauncherType(Context context) {
// return LauncherTypeDetector.getType(context);
// }
//
// /**
// * Determines if user device has capability of SMS.<p>
// *
// * Requires READ_PHONE_STATE Permission must be set to use this function
// * @param context
// * Context to derive device information
// * @return true if user device has SMS capability; false otherwise
// */
// public static boolean hasSmsCapability(Context context) {
// return phoneNumberUtils.isAbleToReceiveSms(context);
// }
// }
| import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.widget.TextView;
import com.navercorp.utilset.device.DeviceUtils;
import com.navercorp.utilsettest.R; | deviceUtilsTask = new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
// TODO Auto-generated method stub
return utilSetTest();
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
textViewUtilSet.setText(result);
}
};
deviceUtilsTask.execute();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
deviceUtilsTask.cancel(true);
deviceUtilsTask = null;
}
public String utilSetTest() {
String result = "*************** UtilSetTest ***************\n"; | // Path: UtilSet/src/com/navercorp/utilset/device/DeviceUtils.java
// public class DeviceUtils {
// private static DeviceTypeDetector deviceTypeDetector;
// private static PhoneNumberUtils phoneNumberUtils;
//
// static {
// phoneNumberUtils = new PhoneNumberUtils();
// deviceTypeDetector = new DeviceTypeDetector();
// }
//
// /**
// * Gives type information of user device.<br>
// *
// * According to the <a href="http://developer.android.com/guide/practices/screens_support.html">Google API guide</a>,
// * devices whose screen size is less than 7 inches will be classified as a handset.<br>
// * For example, Huge looking mobile phones like Samsung galaxy Note III will be sorted as a handset by this rule.<br>
// * Among the rest, devices with 7 inch screen and LDPI will be classified as a handset too.<br>
// * All other devices with 7 or larger screen will be classified as a tablet.
// *
// * @param context
// * Context derived from Activity. ApplicationContext can not be
// * used to take advantage of this function.
// *
// * @return DeviceType.Tablet if the screen size is equal to or larger than
// * XLarge, which is defined as display size from 7 to 10 inches; <br>
// * DeviceType.Handset if the screen size is smaller than XLarge
// */
// public static DeviceType getDeviceType(Context context) {
// return deviceTypeDetector.getDeviceType(context);
// }
//
// /**
// * Returns launcher type.
// *
// * @param context
// * Context to provide package information
// * @return LauncherType
// */
// public static LauncherType getLauncherType(Context context) {
// return LauncherTypeDetector.getType(context);
// }
//
// /**
// * Determines if user device has capability of SMS.<p>
// *
// * Requires READ_PHONE_STATE Permission must be set to use this function
// * @param context
// * Context to derive device information
// * @return true if user device has SMS capability; false otherwise
// */
// public static boolean hasSmsCapability(Context context) {
// return phoneNumberUtils.isAbleToReceiveSms(context);
// }
// }
// Path: UtilSetSampleApp/src/com/navercorp/utilsettest/device/DeviceUtilsTestActivity.java
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.widget.TextView;
import com.navercorp.utilset.device.DeviceUtils;
import com.navercorp.utilsettest.R;
deviceUtilsTask = new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
// TODO Auto-generated method stub
return utilSetTest();
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
textViewUtilSet.setText(result);
}
};
deviceUtilsTask.execute();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
deviceUtilsTask.cancel(true);
deviceUtilsTask = null;
}
public String utilSetTest() {
String result = "*************** UtilSetTest ***************\n"; | result += "LauncherType : " + DeviceUtils.getLauncherType(this).toString() +"\n"; |
naver/android-utilset | UtilSetSampleApp/src/com/navercorp/utilsettest/audio/VolumeUtilsTestActivity.java | // Path: UtilSet/src/com/navercorp/utilset/audio/VolumeUtils.java
// public class VolumeUtils {
// private VolumeUtils() {}
//
// /**
// * Returns current media volume
// * @param context
// * @return current volume
// */
// public static int getCurrentVolume(Context context) {
// AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
// return mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
// }
//
// /**
// * Sets media volume.<br>
// * When setting the value of parameter 'volume' greater than the maximum value of the media volume will not either cause error or throw exception but maximize the media volume.<br>
// * Setting the value of volume lower than 0 will minimize the media volume.
// *
// * @param context Context
// * @param volume volume to be changed
// */
// public static void setVolume(Context context, int volume) {
// adjustMediaVolume(context, volume, 0);
// }
//
// /**
// * Sets media volume and displays volume level.<br>
// * When setting the value of parameter 'volume' greater than the maximum value of the media volume will not either cause error or throw exception but maximize the media volume.<br>
// * Setting the value of volume lower than 0 will minimize the media volume.
// *
// * @param context Context
// * @param volume volume to be changed
// */
// public static void setVolumeWithLevel(Context context, int volume) {
// adjustMediaVolume(context, volume, AudioManager.FLAG_SHOW_UI);
// }
//
// /**
// * Increases media volume
// *
// * @param context
// */
// public static void increaseVolume(Context context) {
// adjustMediaVolume(context, getCurrentVolume(context) + 1, 0);
// }
//
// /**
// * Increases media volume and displays volume level
// *
// * @param context
// */
// public static void increaseVolumeWithLevel(Context context) {
// adjustMediaVolume(context, getCurrentVolume(context) + 1, AudioManager.FLAG_SHOW_UI);
// }
//
// /**
// * Decreases media volume
// *
// * @param context
// */
// public static void decreaseVolume(Context context) {
// adjustMediaVolume(context, getCurrentVolume(context) - 1, 0);
// }
//
// /**
// * Decreases media volume and displays volume level
// *
// * @param context
// */
// public static void decreaseVolumeWithLevel(Context context) {
// adjustMediaVolume(context, getCurrentVolume(context) - 1, AudioManager.FLAG_SHOW_UI);
// }
//
// /** Returns maximum volume the media volume can have
// *
// * @param context Context
// * @return Maximum volume
// */
// public static int getMaximumVolume(Context context) {
// return ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE)).getStreamMaxVolume(AudioManager.STREAM_MUSIC);
// }
//
// /** Returns minimum volume the media volume can have
// *
// * @param context Context
// * @return Minimum volume
// */
// public static int getMinimumVolume(Context context) {
// return 0;
// }
//
// private static void adjustMediaVolume(Context context, int volume, int flag) {
// final int MAX_VOLUME = getMaximumVolume(context);
// final int MIN_VOLUME = 0;
//
// if( volume < MIN_VOLUME ) {
// volume = MIN_VOLUME;
// } else if( volume > MAX_VOLUME ) {
// volume = MAX_VOLUME;
// }
//
// AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
// if (audioManager != null) {
// audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume, flag);
// }
// }
// }
| import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import com.navercorp.utilset.audio.VolumeUtils;
import com.navercorp.utilsettest.R; | package com.navercorp.utilsettest.audio;
public class VolumeUtilsTestActivity extends FragmentActivity {
private Button volumeUpButton;
private Button volumeDownButton;
private TextView currentVolumeTextView;
private Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.acitivty_volumeutils);
volumeUpButton = (Button) findViewById(R.id.volumeUpButton);
volumeDownButton = (Button) findViewById(R.id.volumeDownButton);
volumeUpButton.setOnClickListener(onClickListener);
volumeDownButton.setOnClickListener(onClickListener);
currentVolumeTextView = (TextView) findViewById(R.id.currentVolumeTextView);
context = this;
init();
}
private void init() { | // Path: UtilSet/src/com/navercorp/utilset/audio/VolumeUtils.java
// public class VolumeUtils {
// private VolumeUtils() {}
//
// /**
// * Returns current media volume
// * @param context
// * @return current volume
// */
// public static int getCurrentVolume(Context context) {
// AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
// return mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
// }
//
// /**
// * Sets media volume.<br>
// * When setting the value of parameter 'volume' greater than the maximum value of the media volume will not either cause error or throw exception but maximize the media volume.<br>
// * Setting the value of volume lower than 0 will minimize the media volume.
// *
// * @param context Context
// * @param volume volume to be changed
// */
// public static void setVolume(Context context, int volume) {
// adjustMediaVolume(context, volume, 0);
// }
//
// /**
// * Sets media volume and displays volume level.<br>
// * When setting the value of parameter 'volume' greater than the maximum value of the media volume will not either cause error or throw exception but maximize the media volume.<br>
// * Setting the value of volume lower than 0 will minimize the media volume.
// *
// * @param context Context
// * @param volume volume to be changed
// */
// public static void setVolumeWithLevel(Context context, int volume) {
// adjustMediaVolume(context, volume, AudioManager.FLAG_SHOW_UI);
// }
//
// /**
// * Increases media volume
// *
// * @param context
// */
// public static void increaseVolume(Context context) {
// adjustMediaVolume(context, getCurrentVolume(context) + 1, 0);
// }
//
// /**
// * Increases media volume and displays volume level
// *
// * @param context
// */
// public static void increaseVolumeWithLevel(Context context) {
// adjustMediaVolume(context, getCurrentVolume(context) + 1, AudioManager.FLAG_SHOW_UI);
// }
//
// /**
// * Decreases media volume
// *
// * @param context
// */
// public static void decreaseVolume(Context context) {
// adjustMediaVolume(context, getCurrentVolume(context) - 1, 0);
// }
//
// /**
// * Decreases media volume and displays volume level
// *
// * @param context
// */
// public static void decreaseVolumeWithLevel(Context context) {
// adjustMediaVolume(context, getCurrentVolume(context) - 1, AudioManager.FLAG_SHOW_UI);
// }
//
// /** Returns maximum volume the media volume can have
// *
// * @param context Context
// * @return Maximum volume
// */
// public static int getMaximumVolume(Context context) {
// return ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE)).getStreamMaxVolume(AudioManager.STREAM_MUSIC);
// }
//
// /** Returns minimum volume the media volume can have
// *
// * @param context Context
// * @return Minimum volume
// */
// public static int getMinimumVolume(Context context) {
// return 0;
// }
//
// private static void adjustMediaVolume(Context context, int volume, int flag) {
// final int MAX_VOLUME = getMaximumVolume(context);
// final int MIN_VOLUME = 0;
//
// if( volume < MIN_VOLUME ) {
// volume = MIN_VOLUME;
// } else if( volume > MAX_VOLUME ) {
// volume = MAX_VOLUME;
// }
//
// AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
// if (audioManager != null) {
// audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume, flag);
// }
// }
// }
// Path: UtilSetSampleApp/src/com/navercorp/utilsettest/audio/VolumeUtilsTestActivity.java
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import com.navercorp.utilset.audio.VolumeUtils;
import com.navercorp.utilsettest.R;
package com.navercorp.utilsettest.audio;
public class VolumeUtilsTestActivity extends FragmentActivity {
private Button volumeUpButton;
private Button volumeDownButton;
private TextView currentVolumeTextView;
private Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.acitivty_volumeutils);
volumeUpButton = (Button) findViewById(R.id.volumeUpButton);
volumeDownButton = (Button) findViewById(R.id.volumeDownButton);
volumeUpButton.setOnClickListener(onClickListener);
volumeDownButton.setOnClickListener(onClickListener);
currentVolumeTextView = (TextView) findViewById(R.id.currentVolumeTextView);
context = this;
init();
}
private void init() { | int curVolume = VolumeUtils.getCurrentVolume(this); |
naver/android-utilset | UtilSetSampleApp/src/com/navercorp/utilsettest/storage/DiskUtilsTestAcitivity.java | // Path: UtilSet/src/com/navercorp/utilset/storage/DiskUtils.java
// public final class DiskUtils {
// private static final String DATA_FOLDER = "/Android/data";
// protected static final String TEMPORARY_FOLDER = "/temp";
// protected static final String CACHE_FOLDER = "/cache";
//
// /**
// * Checks if External storage is mounted
// * @return true if mounted; false otherwise
// */
// public static boolean isExternalStorageMounted() {
// return Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
// }
//
// /**
// * Returns directory name to save cache data in the external storage<p>
// *
// * This method always returns path of external storage even if it does not exist.<br>
// * As such, make sure to call isExternalStorageMounted method as state-testing method and then call this function only if state-testing method returns true.
// *
// * @param context Context to get external storage information
// * @return String containing cache directory name
// */
// public static String getExternalDirPath(Context context) {
// return Environment.getExternalStorageDirectory().getAbsolutePath() + DATA_FOLDER + File.separator + context.getPackageName() + CACHE_FOLDER;
// }
//
// /**
// * Returns directory name to save temporary files in the external storage for temporary<p>
// *
// * This method always returns path of external storage even if it does not exist.<br>
// * As such, make sure to call isExternalStorageMounted method as state-testing method and then call this function only if state-testing method returns true.
// *
// * @param context Context to get external storage information
// * @return String containing temporary directory name
// */
// public static String getExternalTemporaryDirPath(Context context) {
// return Environment.getExternalStorageDirectory().getAbsolutePath() + DATA_FOLDER + File.separator + context.getPackageName() + TEMPORARY_FOLDER;
// }
//
//
// /**
// * Returns root directory of the external storage.<p>
// *
// * This method always returns path of external storage even if it does not exist.<br>
// * As such, make sure to call isExternalStorageMounted method as state-testing method and then call this function only if state-testing method returns true.
// *
// * @param context Context to get external storage information
// * @return String containing external root directory name
// */
// public static String getExternalContextRootDir(Context context) {
// return Environment.getExternalStorageDirectory().getAbsolutePath() + DATA_FOLDER + File.separator + context.getPackageName();
// }
// }
| import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.widget.TextView;
import com.navercorp.utilset.storage.DiskUtils;
import com.navercorp.utilsettest.R; |
diskUtilsTask = new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
// TODO Auto-generated method stub
return diskUtils();
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
textViewDiskUtils.setText(result);
}
};
diskUtilsTask.execute();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
diskUtilsTask.cancel(true);
diskUtilsTask = null;
}
private String diskUtils() {
String result = "*************** DiskUtils ***************\n"; | // Path: UtilSet/src/com/navercorp/utilset/storage/DiskUtils.java
// public final class DiskUtils {
// private static final String DATA_FOLDER = "/Android/data";
// protected static final String TEMPORARY_FOLDER = "/temp";
// protected static final String CACHE_FOLDER = "/cache";
//
// /**
// * Checks if External storage is mounted
// * @return true if mounted; false otherwise
// */
// public static boolean isExternalStorageMounted() {
// return Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
// }
//
// /**
// * Returns directory name to save cache data in the external storage<p>
// *
// * This method always returns path of external storage even if it does not exist.<br>
// * As such, make sure to call isExternalStorageMounted method as state-testing method and then call this function only if state-testing method returns true.
// *
// * @param context Context to get external storage information
// * @return String containing cache directory name
// */
// public static String getExternalDirPath(Context context) {
// return Environment.getExternalStorageDirectory().getAbsolutePath() + DATA_FOLDER + File.separator + context.getPackageName() + CACHE_FOLDER;
// }
//
// /**
// * Returns directory name to save temporary files in the external storage for temporary<p>
// *
// * This method always returns path of external storage even if it does not exist.<br>
// * As such, make sure to call isExternalStorageMounted method as state-testing method and then call this function only if state-testing method returns true.
// *
// * @param context Context to get external storage information
// * @return String containing temporary directory name
// */
// public static String getExternalTemporaryDirPath(Context context) {
// return Environment.getExternalStorageDirectory().getAbsolutePath() + DATA_FOLDER + File.separator + context.getPackageName() + TEMPORARY_FOLDER;
// }
//
//
// /**
// * Returns root directory of the external storage.<p>
// *
// * This method always returns path of external storage even if it does not exist.<br>
// * As such, make sure to call isExternalStorageMounted method as state-testing method and then call this function only if state-testing method returns true.
// *
// * @param context Context to get external storage information
// * @return String containing external root directory name
// */
// public static String getExternalContextRootDir(Context context) {
// return Environment.getExternalStorageDirectory().getAbsolutePath() + DATA_FOLDER + File.separator + context.getPackageName();
// }
// }
// Path: UtilSetSampleApp/src/com/navercorp/utilsettest/storage/DiskUtilsTestAcitivity.java
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.widget.TextView;
import com.navercorp.utilset.storage.DiskUtils;
import com.navercorp.utilsettest.R;
diskUtilsTask = new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
// TODO Auto-generated method stub
return diskUtils();
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
textViewDiskUtils.setText(result);
}
};
diskUtilsTask.execute();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
diskUtilsTask.cancel(true);
diskUtilsTask = null;
}
private String diskUtils() {
String result = "*************** DiskUtils ***************\n"; | result += "isExternalStorageMounted : " + DiskUtils.isExternalStorageMounted() + "\n"; |
naver/android-utilset | UtilSetInstrumentationTest/src/com/navercorp/utilsettest/test/KeyboardUtilsTestCase.java | // Path: UtilSetSampleApp/src/com/navercorp/utilsettest/input/KeyboardUtilsTestActivity.java
// public class KeyboardUtilsTestActivity extends FragmentActivity implements OnClickListener {
// Context context;
// EditText editTextKeyboardUtils;
// Button keyboardUtilsShowButton;
// Button keyboardUtilsHideButton;
// Button keyboardUtilsToggleButton;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// // TODO Auto-generated method stub
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_keyboardutils);
// editTextKeyboardUtils = (EditText) findViewById(R.id.editTextKeyboardUtils);
//
// keyboardUtilsShowButton = (Button) findViewById(R.id.keyboardUtilsShowButton);
// keyboardUtilsHideButton = (Button) findViewById(R.id.keyboardUtilsHideButton);
// keyboardUtilsToggleButton = (Button) findViewById(R.id.keyboardUtilsToggleButton);
//
//
// keyboardUtilsShowButton.setOnClickListener(this);
// keyboardUtilsHideButton.setOnClickListener(this);
// keyboardUtilsToggleButton.setOnClickListener(this);
//
// context = this;
// }
//
// @Override
// public void onClick(View v) {
// // TODO Auto-generated method stub
// int id = v.getId();
// switch (id) {
// case R.id.keyboardUtilsShowButton :
// KeyboardUtils.showSoftKeyboard(this, editTextKeyboardUtils);
// break;
//
// case R.id.keyboardUtilsHideButton :
// KeyboardUtils.hideSoftKeyboard(this, editTextKeyboardUtils);
// break;
//
// case R.id.keyboardUtilsToggleButton :
// KeyboardUtils.toggleKeyPad(this);
// break;
// }
// }
// }
//
// Path: UtilSetInstrumentationTest/src/com/navercorp/utilsettest/introduction/Introduction.java
// public enum Introduction {
// CipherUtilsTestCase_testCipher() {
// @Override
// public String getIntroduction() {
// return "CipherUtils provides simple AES encryption.\n" +
// "So this test shows the ciphertext by applying AES encryption utility function on user entered plaintext." +
// "Short after the encryption, you can verify the encrypted string can be restored to the exactly same string as the original one by decryption utility function.";
// }
// },
//
// VolumeUpDownTestCase_testVolumeUpAndDown() {
// @Override
// public String getIntroduction() {
// return "This method manipulates media volume.\n" +
// "Three times of volume up and then the same number of volume down will be done.";
// }
// },
//
// KeyboardUtilsTestCase_testKeyboard() {
// @Override
// public String getIntroduction() {
// return "This method shows a software keyboard being shown, hid, and toggled.\n" +
// "\n\n*** Should you not see the keyboard appear, when this being run on emulator, uncheck Hardware keyboard present option on your emulator property in AVD Manager. " +
// "This will make it work ***";
// }//
// },
//
// NetworkListenerTestCase_showIntroductionDialog() {
// @Override
// public String getIntroduction() {
// return "When network state changes, for example, from 3G/4G to WiFi or in the opposite case, INetworkStateChangedListener will be notified if registered.\n" +
// "This shows network state change by turning on and off the WiFi Adapter.\n" +
// "If USIM is not inserted or no Access Point is near, this test shows nothing more than changing WiFi state.";
// }
// },
//
// ScreenUtilsTestCase_testSetBrightness() {
// @Override
// public String getIntroduction() {
// return "This test makes screen the darkest and then the brightest\n";
// }
//
// },
//
// StringUtils_testHighCompressionRatio() {
// @Override
// public String getIntroduction() {
// return "This test simulates string compression util.\n" +
// "This is good example of how efficiently recurring characters can be compressed, " +
// "this is not usual case though.\n" +
// "Following this test, an inefficient test will be executed.\n";
// }
// },
//
// StringUtils_testLowCompressionRatio() {
// @Override
// public String getIntroduction() {
// return "Followed by efficient test previously done, " +
// "this test demonstrates how disordered characters serverely affects on compression ratio";
// }
// }
// ;
//
// abstract public String getIntroduction();
//
// static public void showIntroductionDialog(FragmentActivity fa, Introduction introduction, int time) {
// IntroductionDialogController idc = IntroductionDialogFactory.getInstance(fa, introduction.getIntroduction(), time);
//
// try {
// Thread.sleep(500);
// idc.show();
// Thread.sleep(500);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
//
// static public void showIntroductionDialog(FragmentActivity fa, Introduction introduction) {
// showIntroductionDialog(fa, introduction, DEFAULT_TIME);
// }
//
// private static int DEFAULT_TIME = 5000;
// }
| import android.support.v4.app.FragmentActivity;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.SmallTest;
import com.jayway.android.robotium.solo.Solo;
import com.navercorp.utilsettest.input.KeyboardUtilsTestActivity;
import com.navercorp.utilsettest.introduction.Introduction; | package com.navercorp.utilsettest.test;
public class KeyboardUtilsTestCase extends ActivityInstrumentationTestCase2<KeyboardUtilsTestActivity> {
private Solo solo;
FragmentActivity activity;
public KeyboardUtilsTestCase() {
super(KeyboardUtilsTestActivity.class);
}
@Override
protected void setUp() throws Exception {
// TODO Auto-generated method stub
super.setUp();
activity = getActivity();
solo = new Solo(getInstrumentation(), activity);
}
@SmallTest
public void testKeyboard() {
solo.waitForActivity(activity.getClass().getSimpleName());
| // Path: UtilSetSampleApp/src/com/navercorp/utilsettest/input/KeyboardUtilsTestActivity.java
// public class KeyboardUtilsTestActivity extends FragmentActivity implements OnClickListener {
// Context context;
// EditText editTextKeyboardUtils;
// Button keyboardUtilsShowButton;
// Button keyboardUtilsHideButton;
// Button keyboardUtilsToggleButton;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// // TODO Auto-generated method stub
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_keyboardutils);
// editTextKeyboardUtils = (EditText) findViewById(R.id.editTextKeyboardUtils);
//
// keyboardUtilsShowButton = (Button) findViewById(R.id.keyboardUtilsShowButton);
// keyboardUtilsHideButton = (Button) findViewById(R.id.keyboardUtilsHideButton);
// keyboardUtilsToggleButton = (Button) findViewById(R.id.keyboardUtilsToggleButton);
//
//
// keyboardUtilsShowButton.setOnClickListener(this);
// keyboardUtilsHideButton.setOnClickListener(this);
// keyboardUtilsToggleButton.setOnClickListener(this);
//
// context = this;
// }
//
// @Override
// public void onClick(View v) {
// // TODO Auto-generated method stub
// int id = v.getId();
// switch (id) {
// case R.id.keyboardUtilsShowButton :
// KeyboardUtils.showSoftKeyboard(this, editTextKeyboardUtils);
// break;
//
// case R.id.keyboardUtilsHideButton :
// KeyboardUtils.hideSoftKeyboard(this, editTextKeyboardUtils);
// break;
//
// case R.id.keyboardUtilsToggleButton :
// KeyboardUtils.toggleKeyPad(this);
// break;
// }
// }
// }
//
// Path: UtilSetInstrumentationTest/src/com/navercorp/utilsettest/introduction/Introduction.java
// public enum Introduction {
// CipherUtilsTestCase_testCipher() {
// @Override
// public String getIntroduction() {
// return "CipherUtils provides simple AES encryption.\n" +
// "So this test shows the ciphertext by applying AES encryption utility function on user entered plaintext." +
// "Short after the encryption, you can verify the encrypted string can be restored to the exactly same string as the original one by decryption utility function.";
// }
// },
//
// VolumeUpDownTestCase_testVolumeUpAndDown() {
// @Override
// public String getIntroduction() {
// return "This method manipulates media volume.\n" +
// "Three times of volume up and then the same number of volume down will be done.";
// }
// },
//
// KeyboardUtilsTestCase_testKeyboard() {
// @Override
// public String getIntroduction() {
// return "This method shows a software keyboard being shown, hid, and toggled.\n" +
// "\n\n*** Should you not see the keyboard appear, when this being run on emulator, uncheck Hardware keyboard present option on your emulator property in AVD Manager. " +
// "This will make it work ***";
// }//
// },
//
// NetworkListenerTestCase_showIntroductionDialog() {
// @Override
// public String getIntroduction() {
// return "When network state changes, for example, from 3G/4G to WiFi or in the opposite case, INetworkStateChangedListener will be notified if registered.\n" +
// "This shows network state change by turning on and off the WiFi Adapter.\n" +
// "If USIM is not inserted or no Access Point is near, this test shows nothing more than changing WiFi state.";
// }
// },
//
// ScreenUtilsTestCase_testSetBrightness() {
// @Override
// public String getIntroduction() {
// return "This test makes screen the darkest and then the brightest\n";
// }
//
// },
//
// StringUtils_testHighCompressionRatio() {
// @Override
// public String getIntroduction() {
// return "This test simulates string compression util.\n" +
// "This is good example of how efficiently recurring characters can be compressed, " +
// "this is not usual case though.\n" +
// "Following this test, an inefficient test will be executed.\n";
// }
// },
//
// StringUtils_testLowCompressionRatio() {
// @Override
// public String getIntroduction() {
// return "Followed by efficient test previously done, " +
// "this test demonstrates how disordered characters serverely affects on compression ratio";
// }
// }
// ;
//
// abstract public String getIntroduction();
//
// static public void showIntroductionDialog(FragmentActivity fa, Introduction introduction, int time) {
// IntroductionDialogController idc = IntroductionDialogFactory.getInstance(fa, introduction.getIntroduction(), time);
//
// try {
// Thread.sleep(500);
// idc.show();
// Thread.sleep(500);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
//
// static public void showIntroductionDialog(FragmentActivity fa, Introduction introduction) {
// showIntroductionDialog(fa, introduction, DEFAULT_TIME);
// }
//
// private static int DEFAULT_TIME = 5000;
// }
// Path: UtilSetInstrumentationTest/src/com/navercorp/utilsettest/test/KeyboardUtilsTestCase.java
import android.support.v4.app.FragmentActivity;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.SmallTest;
import com.jayway.android.robotium.solo.Solo;
import com.navercorp.utilsettest.input.KeyboardUtilsTestActivity;
import com.navercorp.utilsettest.introduction.Introduction;
package com.navercorp.utilsettest.test;
public class KeyboardUtilsTestCase extends ActivityInstrumentationTestCase2<KeyboardUtilsTestActivity> {
private Solo solo;
FragmentActivity activity;
public KeyboardUtilsTestCase() {
super(KeyboardUtilsTestActivity.class);
}
@Override
protected void setUp() throws Exception {
// TODO Auto-generated method stub
super.setUp();
activity = getActivity();
solo = new Solo(getInstrumentation(), activity);
}
@SmallTest
public void testKeyboard() {
solo.waitForActivity(activity.getClass().getSimpleName());
| Introduction.showIntroductionDialog(activity, Introduction.KeyboardUtilsTestCase_testKeyboard); |
naver/android-utilset | UtilSetInstrumentationTest/src/com/navercorp/utilsettest/introduction/Introduction.java | // Path: UtilSetSampleApp/src/com/navercorp/utilsettest/dialog/IntroductionDialogController.java
// public class IntroductionDialogController {
// private static final String TAG = "IntroductionDialogFragment";
// private IntroductionDialogFragment idf;
// private FragmentManager fm;
//
// public IntroductionDialogController(FragmentManager fm, String description, int time) {
// this.idf = new IntroductionDialogFragment("What is this test for", description, time);
// this.fm = fm;
// }
//
// public void show() {
// idf.show(fm, TAG);
// }
//
// public boolean isShowing() {
// return idf.isShowing();
// }
//
// public void dismiss() {
// idf.dismiss();
// }
// }
//
// Path: UtilSetSampleApp/src/com/navercorp/utilsettest/dialog/IntroductionDialogFactory.java
// public class IntroductionDialogFactory {
// public static IntroductionDialogController getInstance(FragmentActivity fa, String description, int time) {
// return new IntroductionDialogController(fa.getSupportFragmentManager(), description, time);
// }
// }
| import android.support.v4.app.FragmentActivity;
import com.navercorp.utilsettest.dialog.IntroductionDialogController;
import com.navercorp.utilsettest.dialog.IntroductionDialogFactory; | ScreenUtilsTestCase_testSetBrightness() {
@Override
public String getIntroduction() {
return "This test makes screen the darkest and then the brightest\n";
}
},
StringUtils_testHighCompressionRatio() {
@Override
public String getIntroduction() {
return "This test simulates string compression util.\n" +
"This is good example of how efficiently recurring characters can be compressed, " +
"this is not usual case though.\n" +
"Following this test, an inefficient test will be executed.\n";
}
},
StringUtils_testLowCompressionRatio() {
@Override
public String getIntroduction() {
return "Followed by efficient test previously done, " +
"this test demonstrates how disordered characters serverely affects on compression ratio";
}
}
;
abstract public String getIntroduction();
static public void showIntroductionDialog(FragmentActivity fa, Introduction introduction, int time) { | // Path: UtilSetSampleApp/src/com/navercorp/utilsettest/dialog/IntroductionDialogController.java
// public class IntroductionDialogController {
// private static final String TAG = "IntroductionDialogFragment";
// private IntroductionDialogFragment idf;
// private FragmentManager fm;
//
// public IntroductionDialogController(FragmentManager fm, String description, int time) {
// this.idf = new IntroductionDialogFragment("What is this test for", description, time);
// this.fm = fm;
// }
//
// public void show() {
// idf.show(fm, TAG);
// }
//
// public boolean isShowing() {
// return idf.isShowing();
// }
//
// public void dismiss() {
// idf.dismiss();
// }
// }
//
// Path: UtilSetSampleApp/src/com/navercorp/utilsettest/dialog/IntroductionDialogFactory.java
// public class IntroductionDialogFactory {
// public static IntroductionDialogController getInstance(FragmentActivity fa, String description, int time) {
// return new IntroductionDialogController(fa.getSupportFragmentManager(), description, time);
// }
// }
// Path: UtilSetInstrumentationTest/src/com/navercorp/utilsettest/introduction/Introduction.java
import android.support.v4.app.FragmentActivity;
import com.navercorp.utilsettest.dialog.IntroductionDialogController;
import com.navercorp.utilsettest.dialog.IntroductionDialogFactory;
ScreenUtilsTestCase_testSetBrightness() {
@Override
public String getIntroduction() {
return "This test makes screen the darkest and then the brightest\n";
}
},
StringUtils_testHighCompressionRatio() {
@Override
public String getIntroduction() {
return "This test simulates string compression util.\n" +
"This is good example of how efficiently recurring characters can be compressed, " +
"this is not usual case though.\n" +
"Following this test, an inefficient test will be executed.\n";
}
},
StringUtils_testLowCompressionRatio() {
@Override
public String getIntroduction() {
return "Followed by efficient test previously done, " +
"this test demonstrates how disordered characters serverely affects on compression ratio";
}
}
;
abstract public String getIntroduction();
static public void showIntroductionDialog(FragmentActivity fa, Introduction introduction, int time) { | IntroductionDialogController idc = IntroductionDialogFactory.getInstance(fa, introduction.getIntroduction(), time); |
naver/android-utilset | UtilSetInstrumentationTest/src/com/navercorp/utilsettest/introduction/Introduction.java | // Path: UtilSetSampleApp/src/com/navercorp/utilsettest/dialog/IntroductionDialogController.java
// public class IntroductionDialogController {
// private static final String TAG = "IntroductionDialogFragment";
// private IntroductionDialogFragment idf;
// private FragmentManager fm;
//
// public IntroductionDialogController(FragmentManager fm, String description, int time) {
// this.idf = new IntroductionDialogFragment("What is this test for", description, time);
// this.fm = fm;
// }
//
// public void show() {
// idf.show(fm, TAG);
// }
//
// public boolean isShowing() {
// return idf.isShowing();
// }
//
// public void dismiss() {
// idf.dismiss();
// }
// }
//
// Path: UtilSetSampleApp/src/com/navercorp/utilsettest/dialog/IntroductionDialogFactory.java
// public class IntroductionDialogFactory {
// public static IntroductionDialogController getInstance(FragmentActivity fa, String description, int time) {
// return new IntroductionDialogController(fa.getSupportFragmentManager(), description, time);
// }
// }
| import android.support.v4.app.FragmentActivity;
import com.navercorp.utilsettest.dialog.IntroductionDialogController;
import com.navercorp.utilsettest.dialog.IntroductionDialogFactory; | ScreenUtilsTestCase_testSetBrightness() {
@Override
public String getIntroduction() {
return "This test makes screen the darkest and then the brightest\n";
}
},
StringUtils_testHighCompressionRatio() {
@Override
public String getIntroduction() {
return "This test simulates string compression util.\n" +
"This is good example of how efficiently recurring characters can be compressed, " +
"this is not usual case though.\n" +
"Following this test, an inefficient test will be executed.\n";
}
},
StringUtils_testLowCompressionRatio() {
@Override
public String getIntroduction() {
return "Followed by efficient test previously done, " +
"this test demonstrates how disordered characters serverely affects on compression ratio";
}
}
;
abstract public String getIntroduction();
static public void showIntroductionDialog(FragmentActivity fa, Introduction introduction, int time) { | // Path: UtilSetSampleApp/src/com/navercorp/utilsettest/dialog/IntroductionDialogController.java
// public class IntroductionDialogController {
// private static final String TAG = "IntroductionDialogFragment";
// private IntroductionDialogFragment idf;
// private FragmentManager fm;
//
// public IntroductionDialogController(FragmentManager fm, String description, int time) {
// this.idf = new IntroductionDialogFragment("What is this test for", description, time);
// this.fm = fm;
// }
//
// public void show() {
// idf.show(fm, TAG);
// }
//
// public boolean isShowing() {
// return idf.isShowing();
// }
//
// public void dismiss() {
// idf.dismiss();
// }
// }
//
// Path: UtilSetSampleApp/src/com/navercorp/utilsettest/dialog/IntroductionDialogFactory.java
// public class IntroductionDialogFactory {
// public static IntroductionDialogController getInstance(FragmentActivity fa, String description, int time) {
// return new IntroductionDialogController(fa.getSupportFragmentManager(), description, time);
// }
// }
// Path: UtilSetInstrumentationTest/src/com/navercorp/utilsettest/introduction/Introduction.java
import android.support.v4.app.FragmentActivity;
import com.navercorp.utilsettest.dialog.IntroductionDialogController;
import com.navercorp.utilsettest.dialog.IntroductionDialogFactory;
ScreenUtilsTestCase_testSetBrightness() {
@Override
public String getIntroduction() {
return "This test makes screen the darkest and then the brightest\n";
}
},
StringUtils_testHighCompressionRatio() {
@Override
public String getIntroduction() {
return "This test simulates string compression util.\n" +
"This is good example of how efficiently recurring characters can be compressed, " +
"this is not usual case though.\n" +
"Following this test, an inefficient test will be executed.\n";
}
},
StringUtils_testLowCompressionRatio() {
@Override
public String getIntroduction() {
return "Followed by efficient test previously done, " +
"this test demonstrates how disordered characters serverely affects on compression ratio";
}
}
;
abstract public String getIntroduction();
static public void showIntroductionDialog(FragmentActivity fa, Introduction introduction, int time) { | IntroductionDialogController idc = IntroductionDialogFactory.getInstance(fa, introduction.getIntroduction(), time); |
naver/android-utilset | UtilSetInstrumentationTest/src/com/navercorp/utilsettest/test/StringUtilsTestCase.java | // Path: UtilSetInstrumentationTest/src/com/navercorp/utilsettest/introduction/Introduction.java
// public enum Introduction {
// CipherUtilsTestCase_testCipher() {
// @Override
// public String getIntroduction() {
// return "CipherUtils provides simple AES encryption.\n" +
// "So this test shows the ciphertext by applying AES encryption utility function on user entered plaintext." +
// "Short after the encryption, you can verify the encrypted string can be restored to the exactly same string as the original one by decryption utility function.";
// }
// },
//
// VolumeUpDownTestCase_testVolumeUpAndDown() {
// @Override
// public String getIntroduction() {
// return "This method manipulates media volume.\n" +
// "Three times of volume up and then the same number of volume down will be done.";
// }
// },
//
// KeyboardUtilsTestCase_testKeyboard() {
// @Override
// public String getIntroduction() {
// return "This method shows a software keyboard being shown, hid, and toggled.\n" +
// "\n\n*** Should you not see the keyboard appear, when this being run on emulator, uncheck Hardware keyboard present option on your emulator property in AVD Manager. " +
// "This will make it work ***";
// }//
// },
//
// NetworkListenerTestCase_showIntroductionDialog() {
// @Override
// public String getIntroduction() {
// return "When network state changes, for example, from 3G/4G to WiFi or in the opposite case, INetworkStateChangedListener will be notified if registered.\n" +
// "This shows network state change by turning on and off the WiFi Adapter.\n" +
// "If USIM is not inserted or no Access Point is near, this test shows nothing more than changing WiFi state.";
// }
// },
//
// ScreenUtilsTestCase_testSetBrightness() {
// @Override
// public String getIntroduction() {
// return "This test makes screen the darkest and then the brightest\n";
// }
//
// },
//
// StringUtils_testHighCompressionRatio() {
// @Override
// public String getIntroduction() {
// return "This test simulates string compression util.\n" +
// "This is good example of how efficiently recurring characters can be compressed, " +
// "this is not usual case though.\n" +
// "Following this test, an inefficient test will be executed.\n";
// }
// },
//
// StringUtils_testLowCompressionRatio() {
// @Override
// public String getIntroduction() {
// return "Followed by efficient test previously done, " +
// "this test demonstrates how disordered characters serverely affects on compression ratio";
// }
// }
// ;
//
// abstract public String getIntroduction();
//
// static public void showIntroductionDialog(FragmentActivity fa, Introduction introduction, int time) {
// IntroductionDialogController idc = IntroductionDialogFactory.getInstance(fa, introduction.getIntroduction(), time);
//
// try {
// Thread.sleep(500);
// idc.show();
// Thread.sleep(500);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
//
// static public void showIntroductionDialog(FragmentActivity fa, Introduction introduction) {
// showIntroductionDialog(fa, introduction, DEFAULT_TIME);
// }
//
// private static int DEFAULT_TIME = 5000;
// }
//
// Path: UtilSetSampleApp/src/com/navercorp/utilsettest/string/StringUtilsTestActivity.java
// public class StringUtilsTestActivity extends FragmentActivity {
// EditText uncompressedText;
// TextView compressedText;
// Button submit;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_stringutils);
//
// uncompressedText = (EditText) findViewById(R.id.uncompressedTextStringUtils);
// compressedText = (TextView) findViewById(R.id.compressedTextStringUtils);
// submit = (Button) findViewById(R.id.submitButtonStringUtils);
// submit.setOnClickListener(onClickListener);
// }
//
// OnClickListener onClickListener = new OnClickListener() {
// @Override
// public void onClick(View v) {
// String s = uncompressedText.getText().toString();
// String compressed = CompressUtils.compressString(s);
// compressedText.setText(compressed);
// }
// };
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// // Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.main, menu);
// return true;
// }
// }
| import java.util.concurrent.ExecutionException;
import android.os.AsyncTask;
import android.support.v4.app.FragmentActivity;
import android.test.ActivityInstrumentationTestCase2;
import com.jayway.android.robotium.solo.Solo;
import com.navercorp.utilsettest.introduction.Introduction;
import com.navercorp.utilsettest.string.StringUtilsTestActivity; | String string = params[0];
int length = string.length();
for (int i=0;i<length;++i) {
solo.enterText(0, string.charAt(i)+"");
}
solo.clickOnButton(0);
return null;
}
};
private void executeTypingAndCompression(String string) {
task.execute(string);
try {
task.get();
Thread.sleep(1000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (ExecutionException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
public void testHighCompressionRatio() {
solo.waitForActivity(activity.getClass().getSimpleName());
| // Path: UtilSetInstrumentationTest/src/com/navercorp/utilsettest/introduction/Introduction.java
// public enum Introduction {
// CipherUtilsTestCase_testCipher() {
// @Override
// public String getIntroduction() {
// return "CipherUtils provides simple AES encryption.\n" +
// "So this test shows the ciphertext by applying AES encryption utility function on user entered plaintext." +
// "Short after the encryption, you can verify the encrypted string can be restored to the exactly same string as the original one by decryption utility function.";
// }
// },
//
// VolumeUpDownTestCase_testVolumeUpAndDown() {
// @Override
// public String getIntroduction() {
// return "This method manipulates media volume.\n" +
// "Three times of volume up and then the same number of volume down will be done.";
// }
// },
//
// KeyboardUtilsTestCase_testKeyboard() {
// @Override
// public String getIntroduction() {
// return "This method shows a software keyboard being shown, hid, and toggled.\n" +
// "\n\n*** Should you not see the keyboard appear, when this being run on emulator, uncheck Hardware keyboard present option on your emulator property in AVD Manager. " +
// "This will make it work ***";
// }//
// },
//
// NetworkListenerTestCase_showIntroductionDialog() {
// @Override
// public String getIntroduction() {
// return "When network state changes, for example, from 3G/4G to WiFi or in the opposite case, INetworkStateChangedListener will be notified if registered.\n" +
// "This shows network state change by turning on and off the WiFi Adapter.\n" +
// "If USIM is not inserted or no Access Point is near, this test shows nothing more than changing WiFi state.";
// }
// },
//
// ScreenUtilsTestCase_testSetBrightness() {
// @Override
// public String getIntroduction() {
// return "This test makes screen the darkest and then the brightest\n";
// }
//
// },
//
// StringUtils_testHighCompressionRatio() {
// @Override
// public String getIntroduction() {
// return "This test simulates string compression util.\n" +
// "This is good example of how efficiently recurring characters can be compressed, " +
// "this is not usual case though.\n" +
// "Following this test, an inefficient test will be executed.\n";
// }
// },
//
// StringUtils_testLowCompressionRatio() {
// @Override
// public String getIntroduction() {
// return "Followed by efficient test previously done, " +
// "this test demonstrates how disordered characters serverely affects on compression ratio";
// }
// }
// ;
//
// abstract public String getIntroduction();
//
// static public void showIntroductionDialog(FragmentActivity fa, Introduction introduction, int time) {
// IntroductionDialogController idc = IntroductionDialogFactory.getInstance(fa, introduction.getIntroduction(), time);
//
// try {
// Thread.sleep(500);
// idc.show();
// Thread.sleep(500);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
//
// static public void showIntroductionDialog(FragmentActivity fa, Introduction introduction) {
// showIntroductionDialog(fa, introduction, DEFAULT_TIME);
// }
//
// private static int DEFAULT_TIME = 5000;
// }
//
// Path: UtilSetSampleApp/src/com/navercorp/utilsettest/string/StringUtilsTestActivity.java
// public class StringUtilsTestActivity extends FragmentActivity {
// EditText uncompressedText;
// TextView compressedText;
// Button submit;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_stringutils);
//
// uncompressedText = (EditText) findViewById(R.id.uncompressedTextStringUtils);
// compressedText = (TextView) findViewById(R.id.compressedTextStringUtils);
// submit = (Button) findViewById(R.id.submitButtonStringUtils);
// submit.setOnClickListener(onClickListener);
// }
//
// OnClickListener onClickListener = new OnClickListener() {
// @Override
// public void onClick(View v) {
// String s = uncompressedText.getText().toString();
// String compressed = CompressUtils.compressString(s);
// compressedText.setText(compressed);
// }
// };
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// // Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.main, menu);
// return true;
// }
// }
// Path: UtilSetInstrumentationTest/src/com/navercorp/utilsettest/test/StringUtilsTestCase.java
import java.util.concurrent.ExecutionException;
import android.os.AsyncTask;
import android.support.v4.app.FragmentActivity;
import android.test.ActivityInstrumentationTestCase2;
import com.jayway.android.robotium.solo.Solo;
import com.navercorp.utilsettest.introduction.Introduction;
import com.navercorp.utilsettest.string.StringUtilsTestActivity;
String string = params[0];
int length = string.length();
for (int i=0;i<length;++i) {
solo.enterText(0, string.charAt(i)+"");
}
solo.clickOnButton(0);
return null;
}
};
private void executeTypingAndCompression(String string) {
task.execute(string);
try {
task.get();
Thread.sleep(1000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (ExecutionException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
public void testHighCompressionRatio() {
solo.waitForActivity(activity.getClass().getSimpleName());
| Introduction.showIntroductionDialog(activity, Introduction.StringUtils_testHighCompressionRatio); |
naver/android-utilset | UtilSet/test/com/navercorp/utilset/cipher/CipherUtilsTest.java | // Path: UtilSet/src/com/navercorp/utilset/cipher/CipherMode.java
// public enum CipherMode {
// AES,
// }
//
// Path: UtilSet/src/com/navercorp/utilset/cipher/CipherUtils.java
// public class CipherUtils {
// CipherMode cipherMode;
// CipherObject cipherObject;
//
// public CipherUtils() {
// this(CipherMode.AES);
// }
//
// public CipherUtils(CipherMode cipherMode) {
// this.cipherMode = cipherMode;
// cipherObject = CipherObjectFactory.getInstance(this.cipherMode);
// }
//
// /**
// *
// * @param seed Seed string which is used for encryption and decryption
// * @param plainText String to be encrypted
// * @return encrypted text
// */
// public String encrypt(String seed, String plainText) {
// return cipherObject.encrypt(seed, plainText);
// }
//
// /**
// *
// * @param seed Seed string which is used for encryption and decryption
// * @param cipherText String encrypted by encrypt method
// * @return plain text
// */
// public String decrypt(String seed, String cipherText) {
// return cipherObject.decrypt(seed, cipherText);
// }
// }
| import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLog;
import com.navercorp.utilset.cipher.CipherMode;
import com.navercorp.utilset.cipher.CipherUtils; | package com.navercorp.utilset.cipher;
/**
* @author jaemin.woo
*
*/
@RunWith(RobolectricTestRunner.class)
@Config(manifest=Config.NONE)
public class CipherUtilsTest {
private static String SEED = "SEED";
private static String PLAIN_TEXT = "PLAIN_TEXT";
@Before
public void setUp() {
ShadowLog.stream = System.out;
}
private String encrypt(String seed, String plainText) { | // Path: UtilSet/src/com/navercorp/utilset/cipher/CipherMode.java
// public enum CipherMode {
// AES,
// }
//
// Path: UtilSet/src/com/navercorp/utilset/cipher/CipherUtils.java
// public class CipherUtils {
// CipherMode cipherMode;
// CipherObject cipherObject;
//
// public CipherUtils() {
// this(CipherMode.AES);
// }
//
// public CipherUtils(CipherMode cipherMode) {
// this.cipherMode = cipherMode;
// cipherObject = CipherObjectFactory.getInstance(this.cipherMode);
// }
//
// /**
// *
// * @param seed Seed string which is used for encryption and decryption
// * @param plainText String to be encrypted
// * @return encrypted text
// */
// public String encrypt(String seed, String plainText) {
// return cipherObject.encrypt(seed, plainText);
// }
//
// /**
// *
// * @param seed Seed string which is used for encryption and decryption
// * @param cipherText String encrypted by encrypt method
// * @return plain text
// */
// public String decrypt(String seed, String cipherText) {
// return cipherObject.decrypt(seed, cipherText);
// }
// }
// Path: UtilSet/test/com/navercorp/utilset/cipher/CipherUtilsTest.java
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLog;
import com.navercorp.utilset.cipher.CipherMode;
import com.navercorp.utilset.cipher.CipherUtils;
package com.navercorp.utilset.cipher;
/**
* @author jaemin.woo
*
*/
@RunWith(RobolectricTestRunner.class)
@Config(manifest=Config.NONE)
public class CipherUtilsTest {
private static String SEED = "SEED";
private static String PLAIN_TEXT = "PLAIN_TEXT";
@Before
public void setUp() {
ShadowLog.stream = System.out;
}
private String encrypt(String seed, String plainText) { | CipherUtils cipherUtils = new CipherUtils(CipherMode.AES); |
naver/android-utilset | UtilSet/test/com/navercorp/utilset/cipher/CipherUtilsTest.java | // Path: UtilSet/src/com/navercorp/utilset/cipher/CipherMode.java
// public enum CipherMode {
// AES,
// }
//
// Path: UtilSet/src/com/navercorp/utilset/cipher/CipherUtils.java
// public class CipherUtils {
// CipherMode cipherMode;
// CipherObject cipherObject;
//
// public CipherUtils() {
// this(CipherMode.AES);
// }
//
// public CipherUtils(CipherMode cipherMode) {
// this.cipherMode = cipherMode;
// cipherObject = CipherObjectFactory.getInstance(this.cipherMode);
// }
//
// /**
// *
// * @param seed Seed string which is used for encryption and decryption
// * @param plainText String to be encrypted
// * @return encrypted text
// */
// public String encrypt(String seed, String plainText) {
// return cipherObject.encrypt(seed, plainText);
// }
//
// /**
// *
// * @param seed Seed string which is used for encryption and decryption
// * @param cipherText String encrypted by encrypt method
// * @return plain text
// */
// public String decrypt(String seed, String cipherText) {
// return cipherObject.decrypt(seed, cipherText);
// }
// }
| import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLog;
import com.navercorp.utilset.cipher.CipherMode;
import com.navercorp.utilset.cipher.CipherUtils; | package com.navercorp.utilset.cipher;
/**
* @author jaemin.woo
*
*/
@RunWith(RobolectricTestRunner.class)
@Config(manifest=Config.NONE)
public class CipherUtilsTest {
private static String SEED = "SEED";
private static String PLAIN_TEXT = "PLAIN_TEXT";
@Before
public void setUp() {
ShadowLog.stream = System.out;
}
private String encrypt(String seed, String plainText) { | // Path: UtilSet/src/com/navercorp/utilset/cipher/CipherMode.java
// public enum CipherMode {
// AES,
// }
//
// Path: UtilSet/src/com/navercorp/utilset/cipher/CipherUtils.java
// public class CipherUtils {
// CipherMode cipherMode;
// CipherObject cipherObject;
//
// public CipherUtils() {
// this(CipherMode.AES);
// }
//
// public CipherUtils(CipherMode cipherMode) {
// this.cipherMode = cipherMode;
// cipherObject = CipherObjectFactory.getInstance(this.cipherMode);
// }
//
// /**
// *
// * @param seed Seed string which is used for encryption and decryption
// * @param plainText String to be encrypted
// * @return encrypted text
// */
// public String encrypt(String seed, String plainText) {
// return cipherObject.encrypt(seed, plainText);
// }
//
// /**
// *
// * @param seed Seed string which is used for encryption and decryption
// * @param cipherText String encrypted by encrypt method
// * @return plain text
// */
// public String decrypt(String seed, String cipherText) {
// return cipherObject.decrypt(seed, cipherText);
// }
// }
// Path: UtilSet/test/com/navercorp/utilset/cipher/CipherUtilsTest.java
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLog;
import com.navercorp.utilset.cipher.CipherMode;
import com.navercorp.utilset.cipher.CipherUtils;
package com.navercorp.utilset.cipher;
/**
* @author jaemin.woo
*
*/
@RunWith(RobolectricTestRunner.class)
@Config(manifest=Config.NONE)
public class CipherUtilsTest {
private static String SEED = "SEED";
private static String PLAIN_TEXT = "PLAIN_TEXT";
@Before
public void setUp() {
ShadowLog.stream = System.out;
}
private String encrypt(String seed, String plainText) { | CipherUtils cipherUtils = new CipherUtils(CipherMode.AES); |
naver/android-utilset | UtilSetSampleApp/src/com/navercorp/utilsettest/cipher/CipherTestActivity.java | // Path: UtilSet/src/com/navercorp/utilset/cipher/CipherUtils.java
// public class CipherUtils {
// CipherMode cipherMode;
// CipherObject cipherObject;
//
// public CipherUtils() {
// this(CipherMode.AES);
// }
//
// public CipherUtils(CipherMode cipherMode) {
// this.cipherMode = cipherMode;
// cipherObject = CipherObjectFactory.getInstance(this.cipherMode);
// }
//
// /**
// *
// * @param seed Seed string which is used for encryption and decryption
// * @param plainText String to be encrypted
// * @return encrypted text
// */
// public String encrypt(String seed, String plainText) {
// return cipherObject.encrypt(seed, plainText);
// }
//
// /**
// *
// * @param seed Seed string which is used for encryption and decryption
// * @param cipherText String encrypted by encrypt method
// * @return plain text
// */
// public String decrypt(String seed, String cipherText) {
// return cipherObject.decrypt(seed, cipherText);
// }
// }
| import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import com.navercorp.utilset.cipher.CipherUtils;
import com.navercorp.utilsettest.R; | package com.navercorp.utilsettest.cipher;
public class CipherTestActivity extends FragmentActivity implements OnClickListener {
EditText plainTextCipherTest;
EditText seedTextCipherTest;
Button encryptButtonCipherTest;
Button decryptButtonCipherTest; | // Path: UtilSet/src/com/navercorp/utilset/cipher/CipherUtils.java
// public class CipherUtils {
// CipherMode cipherMode;
// CipherObject cipherObject;
//
// public CipherUtils() {
// this(CipherMode.AES);
// }
//
// public CipherUtils(CipherMode cipherMode) {
// this.cipherMode = cipherMode;
// cipherObject = CipherObjectFactory.getInstance(this.cipherMode);
// }
//
// /**
// *
// * @param seed Seed string which is used for encryption and decryption
// * @param plainText String to be encrypted
// * @return encrypted text
// */
// public String encrypt(String seed, String plainText) {
// return cipherObject.encrypt(seed, plainText);
// }
//
// /**
// *
// * @param seed Seed string which is used for encryption and decryption
// * @param cipherText String encrypted by encrypt method
// * @return plain text
// */
// public String decrypt(String seed, String cipherText) {
// return cipherObject.decrypt(seed, cipherText);
// }
// }
// Path: UtilSetSampleApp/src/com/navercorp/utilsettest/cipher/CipherTestActivity.java
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import com.navercorp.utilset.cipher.CipherUtils;
import com.navercorp.utilsettest.R;
package com.navercorp.utilsettest.cipher;
public class CipherTestActivity extends FragmentActivity implements OnClickListener {
EditText plainTextCipherTest;
EditText seedTextCipherTest;
Button encryptButtonCipherTest;
Button decryptButtonCipherTest; | CipherUtils cipherUtils; |
naver/android-utilset | UtilSetSampleApp/src/com/navercorp/utilsettest/string/StringUtilsTestActivity.java | // Path: UtilSet/src/com/navercorp/utilset/string/CompressUtils.java
// public class CompressUtils {
// private static StringCompressor stringCompressor;
//
// static {
// stringCompressor = new StringCompressor();
// }
//
// public static String compressString(String stringToBeCompressed) {
// return stringCompressor.compress(stringToBeCompressed);
// }
//
// public static String decompressString(String stringToBeDecompressed) {
// return stringCompressor.decompress(stringToBeDecompressed);
// }
// }
| import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.navercorp.utilset.string.CompressUtils;
import com.navercorp.utilsettest.R; | package com.navercorp.utilsettest.string;
public class StringUtilsTestActivity extends FragmentActivity {
EditText uncompressedText;
TextView compressedText;
Button submit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stringutils);
uncompressedText = (EditText) findViewById(R.id.uncompressedTextStringUtils);
compressedText = (TextView) findViewById(R.id.compressedTextStringUtils);
submit = (Button) findViewById(R.id.submitButtonStringUtils);
submit.setOnClickListener(onClickListener);
}
OnClickListener onClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
String s = uncompressedText.getText().toString(); | // Path: UtilSet/src/com/navercorp/utilset/string/CompressUtils.java
// public class CompressUtils {
// private static StringCompressor stringCompressor;
//
// static {
// stringCompressor = new StringCompressor();
// }
//
// public static String compressString(String stringToBeCompressed) {
// return stringCompressor.compress(stringToBeCompressed);
// }
//
// public static String decompressString(String stringToBeDecompressed) {
// return stringCompressor.decompress(stringToBeDecompressed);
// }
// }
// Path: UtilSetSampleApp/src/com/navercorp/utilsettest/string/StringUtilsTestActivity.java
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.navercorp.utilset.string.CompressUtils;
import com.navercorp.utilsettest.R;
package com.navercorp.utilsettest.string;
public class StringUtilsTestActivity extends FragmentActivity {
EditText uncompressedText;
TextView compressedText;
Button submit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stringutils);
uncompressedText = (EditText) findViewById(R.id.uncompressedTextStringUtils);
compressedText = (TextView) findViewById(R.id.compressedTextStringUtils);
submit = (Button) findViewById(R.id.submitButtonStringUtils);
submit.setOnClickListener(onClickListener);
}
OnClickListener onClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
String s = uncompressedText.getText().toString(); | String compressed = CompressUtils.compressString(s); |
pascoej/ajario | src/main/java/me/pascoej/ajario/packet/serverbound/MouseMove.java | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
| import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer; | package me.pascoej.ajario.packet.serverbound;
/**
* Created by john on 6/14/15.
*/
public class MouseMove extends ServerBoundPacket {
private final double x;
private final double y;
public MouseMove(double x, double y) {
this.x = x;
this.y = y;
}
@Override
protected int size() {
return 21;
}
@Override
protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
byteBuffer.putDouble(x);
byteBuffer.putDouble(y);
byteBuffer.putInt(0);
return byteBuffer;
}
@Override | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
// Path: src/main/java/me/pascoej/ajario/packet/serverbound/MouseMove.java
import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer;
package me.pascoej.ajario.packet.serverbound;
/**
* Created by john on 6/14/15.
*/
public class MouseMove extends ServerBoundPacket {
private final double x;
private final double y;
public MouseMove(double x, double y) {
this.x = x;
this.y = y;
}
@Override
protected int size() {
return 21;
}
@Override
protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
byteBuffer.putDouble(x);
byteBuffer.putDouble(y);
byteBuffer.putInt(0);
return byteBuffer;
}
@Override | public PacketType getType() { |
pascoej/ajario | src/main/java/me/pascoej/ajario/AgarClient.java | // Path: src/main/java/me/pascoej/ajario/node/FoodNode.java
// public class FoodNode extends Node {
// public FoodNode(int nodeId) {
// super(nodeId, NodeType.FOOD);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/Node.java
// public class Node {
// private final int nodeId;
// private final NodeType nodeType;
// private long lastUpdate;
// private short x, y, size;
// double vX, vY;
//
// Node(int nodeId, NodeType nodeType) {
// this.nodeId = nodeId;
// this.nodeType = nodeType;
// }
//
// List<Double> errors = new ArrayList<>();
//
// public void updatePositionSize(short x, short y, short size) {
// long currentTime = System.currentTimeMillis();
// this.x = x;
// this.y = y;
// this.size = size;
// lastUpdate = currentTime;
// }
//
// public NodeType getNodeType() {
// return nodeType;
// }
//
// public int getNodeId() {
// return nodeId;
// }
//
// public double getLastUpdate() {
// return lastUpdate;
// }
//
// public short getX() {
// return x;
// }
//
// public short getY() {
// return y;
// }
//
// public short getSize() {
// return size;
// }
//
// public double distanceSquared(Node node1) {
// double xDiff = node1.getX() - this.getX();
// double yDiff = node1.getY() - this.getY();
// return (xDiff * xDiff) + (yDiff * yDiff);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/PlayerNode.java
// public class PlayerNode extends Node {
// private String name;
// private boolean mine;
//
// public PlayerNode(int nodeId) {
// super(nodeId, NodeType.PLAYER);
// }
//
// public String getName() {
// if (name == null) {
// return "";
// }
// return name;
// }
//
// public boolean isMine() {
// return mine;
// }
//
// public void setMine() {
// this.mine = true;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/VirusNode.java
// public class VirusNode extends Node {
// public VirusNode(int nodeId) {
// super(nodeId, NodeType.VIRUS);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/PacketListener.java
// public interface PacketListener {
// void onRecvPacket(ClientBoundPacket agarPacket);
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/Session.java
// public class Session {
// private WebSocketHandler webSocketHandler;
// private URI uri;
// public Session(URI uri) {
// this.uri = uri;
// webSocketHandler = new WebSocketHandler(uri,this);
// }
//
// public void connect() {
// Set<PacketListener> packetListenerList = webSocketHandler.getPacketListeners();
// webSocketHandler = new WebSocketHandler(uri,this);
// webSocketHandler.getPacketListeners().addAll(packetListenerList);
// webSocketHandler.connect();
// }
//
// public void sendPacket(AgarPacket agarPacket) {
// if (!webSocketHandler.isOpen())
// return;
// try {
// webSocketHandler.sendPacket(agarPacket);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public void close() {
// webSocketHandler.close();
// webSocketHandler.clearPacketListeners();
// }
//
// public void registerPacketListener(PacketListener packetListener) {
// webSocketHandler.registerPacketListener(packetListener);
// }
//
// public void unregisterPacketListener(PacketListener packetListener) {
// webSocketHandler.unregisterPacketListener(packetListener);
// }
//
// public boolean isReady() {
// return webSocketHandler.isOpen();
// }
// }
| import me.pascoej.ajario.node.FoodNode;
import me.pascoej.ajario.node.Node;
import me.pascoej.ajario.node.PlayerNode;
import me.pascoej.ajario.node.VirusNode;
import me.pascoej.ajario.packet.clientbound.*;
import me.pascoej.ajario.packet.serverbound.*;
import me.pascoej.ajario.protocol.PacketListener;
import me.pascoej.ajario.protocol.Session;
import java.net.URI; | package me.pascoej.ajario;
/**
* Created by john on 6/14/15.
*/
public class AgarClient implements PacketListener {
private final World world = new World(); | // Path: src/main/java/me/pascoej/ajario/node/FoodNode.java
// public class FoodNode extends Node {
// public FoodNode(int nodeId) {
// super(nodeId, NodeType.FOOD);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/Node.java
// public class Node {
// private final int nodeId;
// private final NodeType nodeType;
// private long lastUpdate;
// private short x, y, size;
// double vX, vY;
//
// Node(int nodeId, NodeType nodeType) {
// this.nodeId = nodeId;
// this.nodeType = nodeType;
// }
//
// List<Double> errors = new ArrayList<>();
//
// public void updatePositionSize(short x, short y, short size) {
// long currentTime = System.currentTimeMillis();
// this.x = x;
// this.y = y;
// this.size = size;
// lastUpdate = currentTime;
// }
//
// public NodeType getNodeType() {
// return nodeType;
// }
//
// public int getNodeId() {
// return nodeId;
// }
//
// public double getLastUpdate() {
// return lastUpdate;
// }
//
// public short getX() {
// return x;
// }
//
// public short getY() {
// return y;
// }
//
// public short getSize() {
// return size;
// }
//
// public double distanceSquared(Node node1) {
// double xDiff = node1.getX() - this.getX();
// double yDiff = node1.getY() - this.getY();
// return (xDiff * xDiff) + (yDiff * yDiff);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/PlayerNode.java
// public class PlayerNode extends Node {
// private String name;
// private boolean mine;
//
// public PlayerNode(int nodeId) {
// super(nodeId, NodeType.PLAYER);
// }
//
// public String getName() {
// if (name == null) {
// return "";
// }
// return name;
// }
//
// public boolean isMine() {
// return mine;
// }
//
// public void setMine() {
// this.mine = true;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/VirusNode.java
// public class VirusNode extends Node {
// public VirusNode(int nodeId) {
// super(nodeId, NodeType.VIRUS);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/PacketListener.java
// public interface PacketListener {
// void onRecvPacket(ClientBoundPacket agarPacket);
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/Session.java
// public class Session {
// private WebSocketHandler webSocketHandler;
// private URI uri;
// public Session(URI uri) {
// this.uri = uri;
// webSocketHandler = new WebSocketHandler(uri,this);
// }
//
// public void connect() {
// Set<PacketListener> packetListenerList = webSocketHandler.getPacketListeners();
// webSocketHandler = new WebSocketHandler(uri,this);
// webSocketHandler.getPacketListeners().addAll(packetListenerList);
// webSocketHandler.connect();
// }
//
// public void sendPacket(AgarPacket agarPacket) {
// if (!webSocketHandler.isOpen())
// return;
// try {
// webSocketHandler.sendPacket(agarPacket);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public void close() {
// webSocketHandler.close();
// webSocketHandler.clearPacketListeners();
// }
//
// public void registerPacketListener(PacketListener packetListener) {
// webSocketHandler.registerPacketListener(packetListener);
// }
//
// public void unregisterPacketListener(PacketListener packetListener) {
// webSocketHandler.unregisterPacketListener(packetListener);
// }
//
// public boolean isReady() {
// return webSocketHandler.isOpen();
// }
// }
// Path: src/main/java/me/pascoej/ajario/AgarClient.java
import me.pascoej.ajario.node.FoodNode;
import me.pascoej.ajario.node.Node;
import me.pascoej.ajario.node.PlayerNode;
import me.pascoej.ajario.node.VirusNode;
import me.pascoej.ajario.packet.clientbound.*;
import me.pascoej.ajario.packet.serverbound.*;
import me.pascoej.ajario.protocol.PacketListener;
import me.pascoej.ajario.protocol.Session;
import java.net.URI;
package me.pascoej.ajario;
/**
* Created by john on 6/14/15.
*/
public class AgarClient implements PacketListener {
private final World world = new World(); | private Session session; |
pascoej/ajario | src/main/java/me/pascoej/ajario/AgarClient.java | // Path: src/main/java/me/pascoej/ajario/node/FoodNode.java
// public class FoodNode extends Node {
// public FoodNode(int nodeId) {
// super(nodeId, NodeType.FOOD);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/Node.java
// public class Node {
// private final int nodeId;
// private final NodeType nodeType;
// private long lastUpdate;
// private short x, y, size;
// double vX, vY;
//
// Node(int nodeId, NodeType nodeType) {
// this.nodeId = nodeId;
// this.nodeType = nodeType;
// }
//
// List<Double> errors = new ArrayList<>();
//
// public void updatePositionSize(short x, short y, short size) {
// long currentTime = System.currentTimeMillis();
// this.x = x;
// this.y = y;
// this.size = size;
// lastUpdate = currentTime;
// }
//
// public NodeType getNodeType() {
// return nodeType;
// }
//
// public int getNodeId() {
// return nodeId;
// }
//
// public double getLastUpdate() {
// return lastUpdate;
// }
//
// public short getX() {
// return x;
// }
//
// public short getY() {
// return y;
// }
//
// public short getSize() {
// return size;
// }
//
// public double distanceSquared(Node node1) {
// double xDiff = node1.getX() - this.getX();
// double yDiff = node1.getY() - this.getY();
// return (xDiff * xDiff) + (yDiff * yDiff);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/PlayerNode.java
// public class PlayerNode extends Node {
// private String name;
// private boolean mine;
//
// public PlayerNode(int nodeId) {
// super(nodeId, NodeType.PLAYER);
// }
//
// public String getName() {
// if (name == null) {
// return "";
// }
// return name;
// }
//
// public boolean isMine() {
// return mine;
// }
//
// public void setMine() {
// this.mine = true;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/VirusNode.java
// public class VirusNode extends Node {
// public VirusNode(int nodeId) {
// super(nodeId, NodeType.VIRUS);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/PacketListener.java
// public interface PacketListener {
// void onRecvPacket(ClientBoundPacket agarPacket);
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/Session.java
// public class Session {
// private WebSocketHandler webSocketHandler;
// private URI uri;
// public Session(URI uri) {
// this.uri = uri;
// webSocketHandler = new WebSocketHandler(uri,this);
// }
//
// public void connect() {
// Set<PacketListener> packetListenerList = webSocketHandler.getPacketListeners();
// webSocketHandler = new WebSocketHandler(uri,this);
// webSocketHandler.getPacketListeners().addAll(packetListenerList);
// webSocketHandler.connect();
// }
//
// public void sendPacket(AgarPacket agarPacket) {
// if (!webSocketHandler.isOpen())
// return;
// try {
// webSocketHandler.sendPacket(agarPacket);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public void close() {
// webSocketHandler.close();
// webSocketHandler.clearPacketListeners();
// }
//
// public void registerPacketListener(PacketListener packetListener) {
// webSocketHandler.registerPacketListener(packetListener);
// }
//
// public void unregisterPacketListener(PacketListener packetListener) {
// webSocketHandler.unregisterPacketListener(packetListener);
// }
//
// public boolean isReady() {
// return webSocketHandler.isOpen();
// }
// }
| import me.pascoej.ajario.node.FoodNode;
import me.pascoej.ajario.node.Node;
import me.pascoej.ajario.node.PlayerNode;
import me.pascoej.ajario.node.VirusNode;
import me.pascoej.ajario.packet.clientbound.*;
import me.pascoej.ajario.packet.serverbound.*;
import me.pascoej.ajario.protocol.PacketListener;
import me.pascoej.ajario.protocol.Session;
import java.net.URI; | public String getNickname() {
return nickname;
}
public void enterGame(String name) {
nickname = name;
session.sendPacket(new SetNickname(name));
}
public World getWorld() {
return world;
}
@Override
public void onRecvPacket(ClientBoundPacket agarPacket) {
//System.out.println(agarPacket.getType() + ":" + agarPacket);
switch (agarPacket.packetCType()) {
case UPDATE_NODES:
UpdateNodes updateNodes = (UpdateNodes) agarPacket;
handleUpdateNodes(updateNodes);
break;
case UPDATE_POSITION_SIZE:
UpdatePositionAndSize updatePositionAndSize = (UpdatePositionAndSize) agarPacket;
world.setCenterSize(updatePositionAndSize.getX(), updatePositionAndSize.getY(), updatePositionAndSize.getSize());
break;
case CLEAR_ALL_NODES:
world.clearAll();
break;
case ADD_NODE:
AddNode addNode = (AddNode) agarPacket;
int nodeId = addNode.getNodeId(); | // Path: src/main/java/me/pascoej/ajario/node/FoodNode.java
// public class FoodNode extends Node {
// public FoodNode(int nodeId) {
// super(nodeId, NodeType.FOOD);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/Node.java
// public class Node {
// private final int nodeId;
// private final NodeType nodeType;
// private long lastUpdate;
// private short x, y, size;
// double vX, vY;
//
// Node(int nodeId, NodeType nodeType) {
// this.nodeId = nodeId;
// this.nodeType = nodeType;
// }
//
// List<Double> errors = new ArrayList<>();
//
// public void updatePositionSize(short x, short y, short size) {
// long currentTime = System.currentTimeMillis();
// this.x = x;
// this.y = y;
// this.size = size;
// lastUpdate = currentTime;
// }
//
// public NodeType getNodeType() {
// return nodeType;
// }
//
// public int getNodeId() {
// return nodeId;
// }
//
// public double getLastUpdate() {
// return lastUpdate;
// }
//
// public short getX() {
// return x;
// }
//
// public short getY() {
// return y;
// }
//
// public short getSize() {
// return size;
// }
//
// public double distanceSquared(Node node1) {
// double xDiff = node1.getX() - this.getX();
// double yDiff = node1.getY() - this.getY();
// return (xDiff * xDiff) + (yDiff * yDiff);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/PlayerNode.java
// public class PlayerNode extends Node {
// private String name;
// private boolean mine;
//
// public PlayerNode(int nodeId) {
// super(nodeId, NodeType.PLAYER);
// }
//
// public String getName() {
// if (name == null) {
// return "";
// }
// return name;
// }
//
// public boolean isMine() {
// return mine;
// }
//
// public void setMine() {
// this.mine = true;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/VirusNode.java
// public class VirusNode extends Node {
// public VirusNode(int nodeId) {
// super(nodeId, NodeType.VIRUS);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/PacketListener.java
// public interface PacketListener {
// void onRecvPacket(ClientBoundPacket agarPacket);
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/Session.java
// public class Session {
// private WebSocketHandler webSocketHandler;
// private URI uri;
// public Session(URI uri) {
// this.uri = uri;
// webSocketHandler = new WebSocketHandler(uri,this);
// }
//
// public void connect() {
// Set<PacketListener> packetListenerList = webSocketHandler.getPacketListeners();
// webSocketHandler = new WebSocketHandler(uri,this);
// webSocketHandler.getPacketListeners().addAll(packetListenerList);
// webSocketHandler.connect();
// }
//
// public void sendPacket(AgarPacket agarPacket) {
// if (!webSocketHandler.isOpen())
// return;
// try {
// webSocketHandler.sendPacket(agarPacket);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public void close() {
// webSocketHandler.close();
// webSocketHandler.clearPacketListeners();
// }
//
// public void registerPacketListener(PacketListener packetListener) {
// webSocketHandler.registerPacketListener(packetListener);
// }
//
// public void unregisterPacketListener(PacketListener packetListener) {
// webSocketHandler.unregisterPacketListener(packetListener);
// }
//
// public boolean isReady() {
// return webSocketHandler.isOpen();
// }
// }
// Path: src/main/java/me/pascoej/ajario/AgarClient.java
import me.pascoej.ajario.node.FoodNode;
import me.pascoej.ajario.node.Node;
import me.pascoej.ajario.node.PlayerNode;
import me.pascoej.ajario.node.VirusNode;
import me.pascoej.ajario.packet.clientbound.*;
import me.pascoej.ajario.packet.serverbound.*;
import me.pascoej.ajario.protocol.PacketListener;
import me.pascoej.ajario.protocol.Session;
import java.net.URI;
public String getNickname() {
return nickname;
}
public void enterGame(String name) {
nickname = name;
session.sendPacket(new SetNickname(name));
}
public World getWorld() {
return world;
}
@Override
public void onRecvPacket(ClientBoundPacket agarPacket) {
//System.out.println(agarPacket.getType() + ":" + agarPacket);
switch (agarPacket.packetCType()) {
case UPDATE_NODES:
UpdateNodes updateNodes = (UpdateNodes) agarPacket;
handleUpdateNodes(updateNodes);
break;
case UPDATE_POSITION_SIZE:
UpdatePositionAndSize updatePositionAndSize = (UpdatePositionAndSize) agarPacket;
world.setCenterSize(updatePositionAndSize.getX(), updatePositionAndSize.getY(), updatePositionAndSize.getSize());
break;
case CLEAR_ALL_NODES:
world.clearAll();
break;
case ADD_NODE:
AddNode addNode = (AddNode) agarPacket;
int nodeId = addNode.getNodeId(); | PlayerNode node = (PlayerNode) world.getNode(nodeId); |
pascoej/ajario | src/main/java/me/pascoej/ajario/AgarClient.java | // Path: src/main/java/me/pascoej/ajario/node/FoodNode.java
// public class FoodNode extends Node {
// public FoodNode(int nodeId) {
// super(nodeId, NodeType.FOOD);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/Node.java
// public class Node {
// private final int nodeId;
// private final NodeType nodeType;
// private long lastUpdate;
// private short x, y, size;
// double vX, vY;
//
// Node(int nodeId, NodeType nodeType) {
// this.nodeId = nodeId;
// this.nodeType = nodeType;
// }
//
// List<Double> errors = new ArrayList<>();
//
// public void updatePositionSize(short x, short y, short size) {
// long currentTime = System.currentTimeMillis();
// this.x = x;
// this.y = y;
// this.size = size;
// lastUpdate = currentTime;
// }
//
// public NodeType getNodeType() {
// return nodeType;
// }
//
// public int getNodeId() {
// return nodeId;
// }
//
// public double getLastUpdate() {
// return lastUpdate;
// }
//
// public short getX() {
// return x;
// }
//
// public short getY() {
// return y;
// }
//
// public short getSize() {
// return size;
// }
//
// public double distanceSquared(Node node1) {
// double xDiff = node1.getX() - this.getX();
// double yDiff = node1.getY() - this.getY();
// return (xDiff * xDiff) + (yDiff * yDiff);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/PlayerNode.java
// public class PlayerNode extends Node {
// private String name;
// private boolean mine;
//
// public PlayerNode(int nodeId) {
// super(nodeId, NodeType.PLAYER);
// }
//
// public String getName() {
// if (name == null) {
// return "";
// }
// return name;
// }
//
// public boolean isMine() {
// return mine;
// }
//
// public void setMine() {
// this.mine = true;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/VirusNode.java
// public class VirusNode extends Node {
// public VirusNode(int nodeId) {
// super(nodeId, NodeType.VIRUS);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/PacketListener.java
// public interface PacketListener {
// void onRecvPacket(ClientBoundPacket agarPacket);
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/Session.java
// public class Session {
// private WebSocketHandler webSocketHandler;
// private URI uri;
// public Session(URI uri) {
// this.uri = uri;
// webSocketHandler = new WebSocketHandler(uri,this);
// }
//
// public void connect() {
// Set<PacketListener> packetListenerList = webSocketHandler.getPacketListeners();
// webSocketHandler = new WebSocketHandler(uri,this);
// webSocketHandler.getPacketListeners().addAll(packetListenerList);
// webSocketHandler.connect();
// }
//
// public void sendPacket(AgarPacket agarPacket) {
// if (!webSocketHandler.isOpen())
// return;
// try {
// webSocketHandler.sendPacket(agarPacket);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public void close() {
// webSocketHandler.close();
// webSocketHandler.clearPacketListeners();
// }
//
// public void registerPacketListener(PacketListener packetListener) {
// webSocketHandler.registerPacketListener(packetListener);
// }
//
// public void unregisterPacketListener(PacketListener packetListener) {
// webSocketHandler.unregisterPacketListener(packetListener);
// }
//
// public boolean isReady() {
// return webSocketHandler.isOpen();
// }
// }
| import me.pascoej.ajario.node.FoodNode;
import me.pascoej.ajario.node.Node;
import me.pascoej.ajario.node.PlayerNode;
import me.pascoej.ajario.node.VirusNode;
import me.pascoej.ajario.packet.clientbound.*;
import me.pascoej.ajario.packet.serverbound.*;
import me.pascoej.ajario.protocol.PacketListener;
import me.pascoej.ajario.protocol.Session;
import java.net.URI; | }
public void joinGame() {
session.sendPacket(new SetNickname(nickname));
}
public void serverResetPacket() {
session.sendPacket(new ConnectionResetPacket());
}
public boolean isDead() {
return world.getClientNodes().isEmpty();
}
private static final int RECALCULATE_INTERVAL = 50;
private int updatePackets = 0;
private long lastUpdateNodeTime = System.currentTimeMillis();
private double updatePerSecond = 0;
public int getUpdatePerSecond() {
return (int) updatePerSecond;
}
private void handleUpdateNodes(UpdateNodes updateNodes) {
updatePackets += 1;
if (updatePackets >= RECALCULATE_INTERVAL) {
long currentTime = System.currentTimeMillis();
long elapsed = currentTime - lastUpdateNodeTime;
updatePerSecond = (double) updatePackets/((double)elapsed/1000.0);
}
for (UpdateNodes.NodeData nodeData : updateNodes.getNodeDataList()) {
int id = nodeData.getNodeId(); | // Path: src/main/java/me/pascoej/ajario/node/FoodNode.java
// public class FoodNode extends Node {
// public FoodNode(int nodeId) {
// super(nodeId, NodeType.FOOD);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/Node.java
// public class Node {
// private final int nodeId;
// private final NodeType nodeType;
// private long lastUpdate;
// private short x, y, size;
// double vX, vY;
//
// Node(int nodeId, NodeType nodeType) {
// this.nodeId = nodeId;
// this.nodeType = nodeType;
// }
//
// List<Double> errors = new ArrayList<>();
//
// public void updatePositionSize(short x, short y, short size) {
// long currentTime = System.currentTimeMillis();
// this.x = x;
// this.y = y;
// this.size = size;
// lastUpdate = currentTime;
// }
//
// public NodeType getNodeType() {
// return nodeType;
// }
//
// public int getNodeId() {
// return nodeId;
// }
//
// public double getLastUpdate() {
// return lastUpdate;
// }
//
// public short getX() {
// return x;
// }
//
// public short getY() {
// return y;
// }
//
// public short getSize() {
// return size;
// }
//
// public double distanceSquared(Node node1) {
// double xDiff = node1.getX() - this.getX();
// double yDiff = node1.getY() - this.getY();
// return (xDiff * xDiff) + (yDiff * yDiff);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/PlayerNode.java
// public class PlayerNode extends Node {
// private String name;
// private boolean mine;
//
// public PlayerNode(int nodeId) {
// super(nodeId, NodeType.PLAYER);
// }
//
// public String getName() {
// if (name == null) {
// return "";
// }
// return name;
// }
//
// public boolean isMine() {
// return mine;
// }
//
// public void setMine() {
// this.mine = true;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/VirusNode.java
// public class VirusNode extends Node {
// public VirusNode(int nodeId) {
// super(nodeId, NodeType.VIRUS);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/PacketListener.java
// public interface PacketListener {
// void onRecvPacket(ClientBoundPacket agarPacket);
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/Session.java
// public class Session {
// private WebSocketHandler webSocketHandler;
// private URI uri;
// public Session(URI uri) {
// this.uri = uri;
// webSocketHandler = new WebSocketHandler(uri,this);
// }
//
// public void connect() {
// Set<PacketListener> packetListenerList = webSocketHandler.getPacketListeners();
// webSocketHandler = new WebSocketHandler(uri,this);
// webSocketHandler.getPacketListeners().addAll(packetListenerList);
// webSocketHandler.connect();
// }
//
// public void sendPacket(AgarPacket agarPacket) {
// if (!webSocketHandler.isOpen())
// return;
// try {
// webSocketHandler.sendPacket(agarPacket);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public void close() {
// webSocketHandler.close();
// webSocketHandler.clearPacketListeners();
// }
//
// public void registerPacketListener(PacketListener packetListener) {
// webSocketHandler.registerPacketListener(packetListener);
// }
//
// public void unregisterPacketListener(PacketListener packetListener) {
// webSocketHandler.unregisterPacketListener(packetListener);
// }
//
// public boolean isReady() {
// return webSocketHandler.isOpen();
// }
// }
// Path: src/main/java/me/pascoej/ajario/AgarClient.java
import me.pascoej.ajario.node.FoodNode;
import me.pascoej.ajario.node.Node;
import me.pascoej.ajario.node.PlayerNode;
import me.pascoej.ajario.node.VirusNode;
import me.pascoej.ajario.packet.clientbound.*;
import me.pascoej.ajario.packet.serverbound.*;
import me.pascoej.ajario.protocol.PacketListener;
import me.pascoej.ajario.protocol.Session;
import java.net.URI;
}
public void joinGame() {
session.sendPacket(new SetNickname(nickname));
}
public void serverResetPacket() {
session.sendPacket(new ConnectionResetPacket());
}
public boolean isDead() {
return world.getClientNodes().isEmpty();
}
private static final int RECALCULATE_INTERVAL = 50;
private int updatePackets = 0;
private long lastUpdateNodeTime = System.currentTimeMillis();
private double updatePerSecond = 0;
public int getUpdatePerSecond() {
return (int) updatePerSecond;
}
private void handleUpdateNodes(UpdateNodes updateNodes) {
updatePackets += 1;
if (updatePackets >= RECALCULATE_INTERVAL) {
long currentTime = System.currentTimeMillis();
long elapsed = currentTime - lastUpdateNodeTime;
updatePerSecond = (double) updatePackets/((double)elapsed/1000.0);
}
for (UpdateNodes.NodeData nodeData : updateNodes.getNodeDataList()) {
int id = nodeData.getNodeId(); | Node node = world.getNode(id); |
pascoej/ajario | src/main/java/me/pascoej/ajario/AgarClient.java | // Path: src/main/java/me/pascoej/ajario/node/FoodNode.java
// public class FoodNode extends Node {
// public FoodNode(int nodeId) {
// super(nodeId, NodeType.FOOD);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/Node.java
// public class Node {
// private final int nodeId;
// private final NodeType nodeType;
// private long lastUpdate;
// private short x, y, size;
// double vX, vY;
//
// Node(int nodeId, NodeType nodeType) {
// this.nodeId = nodeId;
// this.nodeType = nodeType;
// }
//
// List<Double> errors = new ArrayList<>();
//
// public void updatePositionSize(short x, short y, short size) {
// long currentTime = System.currentTimeMillis();
// this.x = x;
// this.y = y;
// this.size = size;
// lastUpdate = currentTime;
// }
//
// public NodeType getNodeType() {
// return nodeType;
// }
//
// public int getNodeId() {
// return nodeId;
// }
//
// public double getLastUpdate() {
// return lastUpdate;
// }
//
// public short getX() {
// return x;
// }
//
// public short getY() {
// return y;
// }
//
// public short getSize() {
// return size;
// }
//
// public double distanceSquared(Node node1) {
// double xDiff = node1.getX() - this.getX();
// double yDiff = node1.getY() - this.getY();
// return (xDiff * xDiff) + (yDiff * yDiff);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/PlayerNode.java
// public class PlayerNode extends Node {
// private String name;
// private boolean mine;
//
// public PlayerNode(int nodeId) {
// super(nodeId, NodeType.PLAYER);
// }
//
// public String getName() {
// if (name == null) {
// return "";
// }
// return name;
// }
//
// public boolean isMine() {
// return mine;
// }
//
// public void setMine() {
// this.mine = true;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/VirusNode.java
// public class VirusNode extends Node {
// public VirusNode(int nodeId) {
// super(nodeId, NodeType.VIRUS);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/PacketListener.java
// public interface PacketListener {
// void onRecvPacket(ClientBoundPacket agarPacket);
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/Session.java
// public class Session {
// private WebSocketHandler webSocketHandler;
// private URI uri;
// public Session(URI uri) {
// this.uri = uri;
// webSocketHandler = new WebSocketHandler(uri,this);
// }
//
// public void connect() {
// Set<PacketListener> packetListenerList = webSocketHandler.getPacketListeners();
// webSocketHandler = new WebSocketHandler(uri,this);
// webSocketHandler.getPacketListeners().addAll(packetListenerList);
// webSocketHandler.connect();
// }
//
// public void sendPacket(AgarPacket agarPacket) {
// if (!webSocketHandler.isOpen())
// return;
// try {
// webSocketHandler.sendPacket(agarPacket);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public void close() {
// webSocketHandler.close();
// webSocketHandler.clearPacketListeners();
// }
//
// public void registerPacketListener(PacketListener packetListener) {
// webSocketHandler.registerPacketListener(packetListener);
// }
//
// public void unregisterPacketListener(PacketListener packetListener) {
// webSocketHandler.unregisterPacketListener(packetListener);
// }
//
// public boolean isReady() {
// return webSocketHandler.isOpen();
// }
// }
| import me.pascoej.ajario.node.FoodNode;
import me.pascoej.ajario.node.Node;
import me.pascoej.ajario.node.PlayerNode;
import me.pascoej.ajario.node.VirusNode;
import me.pascoej.ajario.packet.clientbound.*;
import me.pascoej.ajario.packet.serverbound.*;
import me.pascoej.ajario.protocol.PacketListener;
import me.pascoej.ajario.protocol.Session;
import java.net.URI; | session.sendPacket(new SetNickname(nickname));
}
public void serverResetPacket() {
session.sendPacket(new ConnectionResetPacket());
}
public boolean isDead() {
return world.getClientNodes().isEmpty();
}
private static final int RECALCULATE_INTERVAL = 50;
private int updatePackets = 0;
private long lastUpdateNodeTime = System.currentTimeMillis();
private double updatePerSecond = 0;
public int getUpdatePerSecond() {
return (int) updatePerSecond;
}
private void handleUpdateNodes(UpdateNodes updateNodes) {
updatePackets += 1;
if (updatePackets >= RECALCULATE_INTERVAL) {
long currentTime = System.currentTimeMillis();
long elapsed = currentTime - lastUpdateNodeTime;
updatePerSecond = (double) updatePackets/((double)elapsed/1000.0);
}
for (UpdateNodes.NodeData nodeData : updateNodes.getNodeDataList()) {
int id = nodeData.getNodeId();
Node node = world.getNode(id);
if (node == null) {
if (nodeData.isVirus()) { | // Path: src/main/java/me/pascoej/ajario/node/FoodNode.java
// public class FoodNode extends Node {
// public FoodNode(int nodeId) {
// super(nodeId, NodeType.FOOD);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/Node.java
// public class Node {
// private final int nodeId;
// private final NodeType nodeType;
// private long lastUpdate;
// private short x, y, size;
// double vX, vY;
//
// Node(int nodeId, NodeType nodeType) {
// this.nodeId = nodeId;
// this.nodeType = nodeType;
// }
//
// List<Double> errors = new ArrayList<>();
//
// public void updatePositionSize(short x, short y, short size) {
// long currentTime = System.currentTimeMillis();
// this.x = x;
// this.y = y;
// this.size = size;
// lastUpdate = currentTime;
// }
//
// public NodeType getNodeType() {
// return nodeType;
// }
//
// public int getNodeId() {
// return nodeId;
// }
//
// public double getLastUpdate() {
// return lastUpdate;
// }
//
// public short getX() {
// return x;
// }
//
// public short getY() {
// return y;
// }
//
// public short getSize() {
// return size;
// }
//
// public double distanceSquared(Node node1) {
// double xDiff = node1.getX() - this.getX();
// double yDiff = node1.getY() - this.getY();
// return (xDiff * xDiff) + (yDiff * yDiff);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/PlayerNode.java
// public class PlayerNode extends Node {
// private String name;
// private boolean mine;
//
// public PlayerNode(int nodeId) {
// super(nodeId, NodeType.PLAYER);
// }
//
// public String getName() {
// if (name == null) {
// return "";
// }
// return name;
// }
//
// public boolean isMine() {
// return mine;
// }
//
// public void setMine() {
// this.mine = true;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/VirusNode.java
// public class VirusNode extends Node {
// public VirusNode(int nodeId) {
// super(nodeId, NodeType.VIRUS);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/PacketListener.java
// public interface PacketListener {
// void onRecvPacket(ClientBoundPacket agarPacket);
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/Session.java
// public class Session {
// private WebSocketHandler webSocketHandler;
// private URI uri;
// public Session(URI uri) {
// this.uri = uri;
// webSocketHandler = new WebSocketHandler(uri,this);
// }
//
// public void connect() {
// Set<PacketListener> packetListenerList = webSocketHandler.getPacketListeners();
// webSocketHandler = new WebSocketHandler(uri,this);
// webSocketHandler.getPacketListeners().addAll(packetListenerList);
// webSocketHandler.connect();
// }
//
// public void sendPacket(AgarPacket agarPacket) {
// if (!webSocketHandler.isOpen())
// return;
// try {
// webSocketHandler.sendPacket(agarPacket);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public void close() {
// webSocketHandler.close();
// webSocketHandler.clearPacketListeners();
// }
//
// public void registerPacketListener(PacketListener packetListener) {
// webSocketHandler.registerPacketListener(packetListener);
// }
//
// public void unregisterPacketListener(PacketListener packetListener) {
// webSocketHandler.unregisterPacketListener(packetListener);
// }
//
// public boolean isReady() {
// return webSocketHandler.isOpen();
// }
// }
// Path: src/main/java/me/pascoej/ajario/AgarClient.java
import me.pascoej.ajario.node.FoodNode;
import me.pascoej.ajario.node.Node;
import me.pascoej.ajario.node.PlayerNode;
import me.pascoej.ajario.node.VirusNode;
import me.pascoej.ajario.packet.clientbound.*;
import me.pascoej.ajario.packet.serverbound.*;
import me.pascoej.ajario.protocol.PacketListener;
import me.pascoej.ajario.protocol.Session;
import java.net.URI;
session.sendPacket(new SetNickname(nickname));
}
public void serverResetPacket() {
session.sendPacket(new ConnectionResetPacket());
}
public boolean isDead() {
return world.getClientNodes().isEmpty();
}
private static final int RECALCULATE_INTERVAL = 50;
private int updatePackets = 0;
private long lastUpdateNodeTime = System.currentTimeMillis();
private double updatePerSecond = 0;
public int getUpdatePerSecond() {
return (int) updatePerSecond;
}
private void handleUpdateNodes(UpdateNodes updateNodes) {
updatePackets += 1;
if (updatePackets >= RECALCULATE_INTERVAL) {
long currentTime = System.currentTimeMillis();
long elapsed = currentTime - lastUpdateNodeTime;
updatePerSecond = (double) updatePackets/((double)elapsed/1000.0);
}
for (UpdateNodes.NodeData nodeData : updateNodes.getNodeDataList()) {
int id = nodeData.getNodeId();
Node node = world.getNode(id);
if (node == null) {
if (nodeData.isVirus()) { | node = new VirusNode(id); |
pascoej/ajario | src/main/java/me/pascoej/ajario/AgarClient.java | // Path: src/main/java/me/pascoej/ajario/node/FoodNode.java
// public class FoodNode extends Node {
// public FoodNode(int nodeId) {
// super(nodeId, NodeType.FOOD);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/Node.java
// public class Node {
// private final int nodeId;
// private final NodeType nodeType;
// private long lastUpdate;
// private short x, y, size;
// double vX, vY;
//
// Node(int nodeId, NodeType nodeType) {
// this.nodeId = nodeId;
// this.nodeType = nodeType;
// }
//
// List<Double> errors = new ArrayList<>();
//
// public void updatePositionSize(short x, short y, short size) {
// long currentTime = System.currentTimeMillis();
// this.x = x;
// this.y = y;
// this.size = size;
// lastUpdate = currentTime;
// }
//
// public NodeType getNodeType() {
// return nodeType;
// }
//
// public int getNodeId() {
// return nodeId;
// }
//
// public double getLastUpdate() {
// return lastUpdate;
// }
//
// public short getX() {
// return x;
// }
//
// public short getY() {
// return y;
// }
//
// public short getSize() {
// return size;
// }
//
// public double distanceSquared(Node node1) {
// double xDiff = node1.getX() - this.getX();
// double yDiff = node1.getY() - this.getY();
// return (xDiff * xDiff) + (yDiff * yDiff);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/PlayerNode.java
// public class PlayerNode extends Node {
// private String name;
// private boolean mine;
//
// public PlayerNode(int nodeId) {
// super(nodeId, NodeType.PLAYER);
// }
//
// public String getName() {
// if (name == null) {
// return "";
// }
// return name;
// }
//
// public boolean isMine() {
// return mine;
// }
//
// public void setMine() {
// this.mine = true;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/VirusNode.java
// public class VirusNode extends Node {
// public VirusNode(int nodeId) {
// super(nodeId, NodeType.VIRUS);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/PacketListener.java
// public interface PacketListener {
// void onRecvPacket(ClientBoundPacket agarPacket);
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/Session.java
// public class Session {
// private WebSocketHandler webSocketHandler;
// private URI uri;
// public Session(URI uri) {
// this.uri = uri;
// webSocketHandler = new WebSocketHandler(uri,this);
// }
//
// public void connect() {
// Set<PacketListener> packetListenerList = webSocketHandler.getPacketListeners();
// webSocketHandler = new WebSocketHandler(uri,this);
// webSocketHandler.getPacketListeners().addAll(packetListenerList);
// webSocketHandler.connect();
// }
//
// public void sendPacket(AgarPacket agarPacket) {
// if (!webSocketHandler.isOpen())
// return;
// try {
// webSocketHandler.sendPacket(agarPacket);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public void close() {
// webSocketHandler.close();
// webSocketHandler.clearPacketListeners();
// }
//
// public void registerPacketListener(PacketListener packetListener) {
// webSocketHandler.registerPacketListener(packetListener);
// }
//
// public void unregisterPacketListener(PacketListener packetListener) {
// webSocketHandler.unregisterPacketListener(packetListener);
// }
//
// public boolean isReady() {
// return webSocketHandler.isOpen();
// }
// }
| import me.pascoej.ajario.node.FoodNode;
import me.pascoej.ajario.node.Node;
import me.pascoej.ajario.node.PlayerNode;
import me.pascoej.ajario.node.VirusNode;
import me.pascoej.ajario.packet.clientbound.*;
import me.pascoej.ajario.packet.serverbound.*;
import me.pascoej.ajario.protocol.PacketListener;
import me.pascoej.ajario.protocol.Session;
import java.net.URI; | public void serverResetPacket() {
session.sendPacket(new ConnectionResetPacket());
}
public boolean isDead() {
return world.getClientNodes().isEmpty();
}
private static final int RECALCULATE_INTERVAL = 50;
private int updatePackets = 0;
private long lastUpdateNodeTime = System.currentTimeMillis();
private double updatePerSecond = 0;
public int getUpdatePerSecond() {
return (int) updatePerSecond;
}
private void handleUpdateNodes(UpdateNodes updateNodes) {
updatePackets += 1;
if (updatePackets >= RECALCULATE_INTERVAL) {
long currentTime = System.currentTimeMillis();
long elapsed = currentTime - lastUpdateNodeTime;
updatePerSecond = (double) updatePackets/((double)elapsed/1000.0);
}
for (UpdateNodes.NodeData nodeData : updateNodes.getNodeDataList()) {
int id = nodeData.getNodeId();
Node node = world.getNode(id);
if (node == null) {
if (nodeData.isVirus()) {
node = new VirusNode(id);
} else if (nodeData.getSize() < 20 && nodeData.getName().equals("")) { | // Path: src/main/java/me/pascoej/ajario/node/FoodNode.java
// public class FoodNode extends Node {
// public FoodNode(int nodeId) {
// super(nodeId, NodeType.FOOD);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/Node.java
// public class Node {
// private final int nodeId;
// private final NodeType nodeType;
// private long lastUpdate;
// private short x, y, size;
// double vX, vY;
//
// Node(int nodeId, NodeType nodeType) {
// this.nodeId = nodeId;
// this.nodeType = nodeType;
// }
//
// List<Double> errors = new ArrayList<>();
//
// public void updatePositionSize(short x, short y, short size) {
// long currentTime = System.currentTimeMillis();
// this.x = x;
// this.y = y;
// this.size = size;
// lastUpdate = currentTime;
// }
//
// public NodeType getNodeType() {
// return nodeType;
// }
//
// public int getNodeId() {
// return nodeId;
// }
//
// public double getLastUpdate() {
// return lastUpdate;
// }
//
// public short getX() {
// return x;
// }
//
// public short getY() {
// return y;
// }
//
// public short getSize() {
// return size;
// }
//
// public double distanceSquared(Node node1) {
// double xDiff = node1.getX() - this.getX();
// double yDiff = node1.getY() - this.getY();
// return (xDiff * xDiff) + (yDiff * yDiff);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/PlayerNode.java
// public class PlayerNode extends Node {
// private String name;
// private boolean mine;
//
// public PlayerNode(int nodeId) {
// super(nodeId, NodeType.PLAYER);
// }
//
// public String getName() {
// if (name == null) {
// return "";
// }
// return name;
// }
//
// public boolean isMine() {
// return mine;
// }
//
// public void setMine() {
// this.mine = true;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/VirusNode.java
// public class VirusNode extends Node {
// public VirusNode(int nodeId) {
// super(nodeId, NodeType.VIRUS);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/PacketListener.java
// public interface PacketListener {
// void onRecvPacket(ClientBoundPacket agarPacket);
// }
//
// Path: src/main/java/me/pascoej/ajario/protocol/Session.java
// public class Session {
// private WebSocketHandler webSocketHandler;
// private URI uri;
// public Session(URI uri) {
// this.uri = uri;
// webSocketHandler = new WebSocketHandler(uri,this);
// }
//
// public void connect() {
// Set<PacketListener> packetListenerList = webSocketHandler.getPacketListeners();
// webSocketHandler = new WebSocketHandler(uri,this);
// webSocketHandler.getPacketListeners().addAll(packetListenerList);
// webSocketHandler.connect();
// }
//
// public void sendPacket(AgarPacket agarPacket) {
// if (!webSocketHandler.isOpen())
// return;
// try {
// webSocketHandler.sendPacket(agarPacket);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public void close() {
// webSocketHandler.close();
// webSocketHandler.clearPacketListeners();
// }
//
// public void registerPacketListener(PacketListener packetListener) {
// webSocketHandler.registerPacketListener(packetListener);
// }
//
// public void unregisterPacketListener(PacketListener packetListener) {
// webSocketHandler.unregisterPacketListener(packetListener);
// }
//
// public boolean isReady() {
// return webSocketHandler.isOpen();
// }
// }
// Path: src/main/java/me/pascoej/ajario/AgarClient.java
import me.pascoej.ajario.node.FoodNode;
import me.pascoej.ajario.node.Node;
import me.pascoej.ajario.node.PlayerNode;
import me.pascoej.ajario.node.VirusNode;
import me.pascoej.ajario.packet.clientbound.*;
import me.pascoej.ajario.packet.serverbound.*;
import me.pascoej.ajario.protocol.PacketListener;
import me.pascoej.ajario.protocol.Session;
import java.net.URI;
public void serverResetPacket() {
session.sendPacket(new ConnectionResetPacket());
}
public boolean isDead() {
return world.getClientNodes().isEmpty();
}
private static final int RECALCULATE_INTERVAL = 50;
private int updatePackets = 0;
private long lastUpdateNodeTime = System.currentTimeMillis();
private double updatePerSecond = 0;
public int getUpdatePerSecond() {
return (int) updatePerSecond;
}
private void handleUpdateNodes(UpdateNodes updateNodes) {
updatePackets += 1;
if (updatePackets >= RECALCULATE_INTERVAL) {
long currentTime = System.currentTimeMillis();
long elapsed = currentTime - lastUpdateNodeTime;
updatePerSecond = (double) updatePackets/((double)elapsed/1000.0);
}
for (UpdateNodes.NodeData nodeData : updateNodes.getNodeDataList()) {
int id = nodeData.getNodeId();
Node node = world.getNode(id);
if (node == null) {
if (nodeData.isVirus()) {
node = new VirusNode(id);
} else if (nodeData.getSize() < 20 && nodeData.getName().equals("")) { | node = new FoodNode(id); |
pascoej/ajario | src/main/java/me/pascoej/ajario/packet/serverbound/SetNickname.java | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
| import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets; | package me.pascoej.ajario.packet.serverbound;
/**
* Created by john on 6/14/15.
*/
public class SetNickname extends ServerBoundPacket {
private final String nickName;
public SetNickname(String nickName) {
this.nickName = nickName;
}
@Override
protected int size() {
return 1 + 2 * nickName.length();
}
@Override
protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
byteBuffer.put(StandardCharsets.UTF_16LE.encode(nickName));
return byteBuffer;
}
@Override | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
// Path: src/main/java/me/pascoej/ajario/packet/serverbound/SetNickname.java
import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
package me.pascoej.ajario.packet.serverbound;
/**
* Created by john on 6/14/15.
*/
public class SetNickname extends ServerBoundPacket {
private final String nickName;
public SetNickname(String nickName) {
this.nickName = nickName;
}
@Override
protected int size() {
return 1 + 2 * nickName.length();
}
@Override
protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
byteBuffer.put(StandardCharsets.UTF_16LE.encode(nickName));
return byteBuffer;
}
@Override | public PacketType getType() { |
pascoej/ajario | src/main/java/me/pascoej/ajario/packet/clientbound/UpdatePositionAndSize.java | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
| import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer; | package me.pascoej.ajario.packet.clientbound;
/**
* Created by john on 6/14/15.
*/
public class UpdatePositionAndSize extends ClientBoundPacket {
private final float x;
private final float y;
private final float size;
public UpdatePositionAndSize(ByteBuffer byteBuffer) {
super(byteBuffer);
x = byteBuffer.getFloat();
y = byteBuffer.getFloat();
size = byteBuffer.getFloat();
}
public float getX() {
return x;
}
public float getY() {
return y;
}
public float getSize() {
return size;
}
@Override | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/UpdatePositionAndSize.java
import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer;
package me.pascoej.ajario.packet.clientbound;
/**
* Created by john on 6/14/15.
*/
public class UpdatePositionAndSize extends ClientBoundPacket {
private final float x;
private final float y;
private final float size;
public UpdatePositionAndSize(ByteBuffer byteBuffer) {
super(byteBuffer);
x = byteBuffer.getFloat();
y = byteBuffer.getFloat();
size = byteBuffer.getFloat();
}
public float getX() {
return x;
}
public float getY() {
return y;
}
public float getSize() {
return size;
}
@Override | public PacketType getType() { |
pascoej/ajario | src/main/java/me/pascoej/ajario/packet/clientbound/UpdateNodes.java | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
//
// Path: src/main/java/me/pascoej/ajario/util/ByteUtil.java
// public class ByteUtil {
// public static String popString(ByteBuffer byteBuffer) {
// StringBuilder sb = new StringBuilder(byteBuffer.limit());
// while (true) {
// short num = byteBuffer.getShort();
// if (num == 0) {
// return sb.toString();
// }
// sb.append((char) num);
// }
// }
//
// public static String toBinaryString(byte in) {
// return String.format("%8s", Integer.toBinaryString(in & 0xFF)).replace(' ', '0');
// }
// }
| import me.pascoej.ajario.packet.PacketType;
import me.pascoej.ajario.util.ByteUtil;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; | }
short x = byteBuffer.getShort();
short y = byteBuffer.getShort();
short size = byteBuffer.getShort();
byte r = byteBuffer.get();
byte g = byteBuffer.get();
byte b = byteBuffer.get();
boolean virus = false;
boolean agitated = false;
byte flags = byteBuffer.get();
int skips = 0;
if (bitSet(flags, (byte) 1)) {
virus = true;
}
if (bitSet(flags, (byte) 16)) {
agitated = true;
}
if (bitSet(flags, (byte) 2)) {
skips += 4;
}
if (bitSet(flags, (byte) 4)) {
skips += 8;
}
if (bitSet(flags, (byte) 8)) {
skips += 16;
}
byteBuffer.position(byteBuffer.position() + skips); | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
//
// Path: src/main/java/me/pascoej/ajario/util/ByteUtil.java
// public class ByteUtil {
// public static String popString(ByteBuffer byteBuffer) {
// StringBuilder sb = new StringBuilder(byteBuffer.limit());
// while (true) {
// short num = byteBuffer.getShort();
// if (num == 0) {
// return sb.toString();
// }
// sb.append((char) num);
// }
// }
//
// public static String toBinaryString(byte in) {
// return String.format("%8s", Integer.toBinaryString(in & 0xFF)).replace(' ', '0');
// }
// }
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/UpdateNodes.java
import me.pascoej.ajario.packet.PacketType;
import me.pascoej.ajario.util.ByteUtil;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
}
short x = byteBuffer.getShort();
short y = byteBuffer.getShort();
short size = byteBuffer.getShort();
byte r = byteBuffer.get();
byte g = byteBuffer.get();
byte b = byteBuffer.get();
boolean virus = false;
boolean agitated = false;
byte flags = byteBuffer.get();
int skips = 0;
if (bitSet(flags, (byte) 1)) {
virus = true;
}
if (bitSet(flags, (byte) 16)) {
agitated = true;
}
if (bitSet(flags, (byte) 2)) {
skips += 4;
}
if (bitSet(flags, (byte) 4)) {
skips += 8;
}
if (bitSet(flags, (byte) 8)) {
skips += 16;
}
byteBuffer.position(byteBuffer.position() + skips); | String name = ByteUtil.popString(byteBuffer); |
pascoej/ajario | src/main/java/me/pascoej/ajario/packet/clientbound/UpdateNodes.java | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
//
// Path: src/main/java/me/pascoej/ajario/util/ByteUtil.java
// public class ByteUtil {
// public static String popString(ByteBuffer byteBuffer) {
// StringBuilder sb = new StringBuilder(byteBuffer.limit());
// while (true) {
// short num = byteBuffer.getShort();
// if (num == 0) {
// return sb.toString();
// }
// sb.append((char) num);
// }
// }
//
// public static String toBinaryString(byte in) {
// return String.format("%8s", Integer.toBinaryString(in & 0xFF)).replace(' ', '0');
// }
// }
| import me.pascoej.ajario.packet.PacketType;
import me.pascoej.ajario.util.ByteUtil;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; | byteBuffer.position(byteBuffer.position() + skips);
String name = ByteUtil.popString(byteBuffer);
NodeData nodeData = new NodeData(nodeId, x, y, size, r, g, b, name, virus, agitated);
nodeDataList.add(nodeData);
}
activeNodes = byteBuffer.getInt();
activeNodeIds = new int[activeNodes];
for (int j = 0; j < activeNodes; j++) {
activeNodeIds[j] = byteBuffer.getInt();
}
}
private boolean bitSet(byte value1, byte value2) {
return (value1 & value2) == value2;
}
public List<NodeData> getNodeDataList() {
return nodeDataList;
}
public int getActiveNodes() {
return activeNodes;
}
public int[] getActiveNodeIds() {
return activeNodeIds;
}
@Override | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
//
// Path: src/main/java/me/pascoej/ajario/util/ByteUtil.java
// public class ByteUtil {
// public static String popString(ByteBuffer byteBuffer) {
// StringBuilder sb = new StringBuilder(byteBuffer.limit());
// while (true) {
// short num = byteBuffer.getShort();
// if (num == 0) {
// return sb.toString();
// }
// sb.append((char) num);
// }
// }
//
// public static String toBinaryString(byte in) {
// return String.format("%8s", Integer.toBinaryString(in & 0xFF)).replace(' ', '0');
// }
// }
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/UpdateNodes.java
import me.pascoej.ajario.packet.PacketType;
import me.pascoej.ajario.util.ByteUtil;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
byteBuffer.position(byteBuffer.position() + skips);
String name = ByteUtil.popString(byteBuffer);
NodeData nodeData = new NodeData(nodeId, x, y, size, r, g, b, name, virus, agitated);
nodeDataList.add(nodeData);
}
activeNodes = byteBuffer.getInt();
activeNodeIds = new int[activeNodes];
for (int j = 0; j < activeNodes; j++) {
activeNodeIds[j] = byteBuffer.getInt();
}
}
private boolean bitSet(byte value1, byte value2) {
return (value1 & value2) == value2;
}
public List<NodeData> getNodeDataList() {
return nodeDataList;
}
public int getActiveNodes() {
return activeNodes;
}
public int[] getActiveNodeIds() {
return activeNodeIds;
}
@Override | public PacketType getType() { |
pascoej/ajario | src/main/java/me/pascoej/ajario/packet/clientbound/ClientBoundPacket.java | // Path: src/main/java/me/pascoej/ajario/packet/AgarPacket.java
// public interface AgarPacket {
// byte[] toBytes();
//
// PacketType getType();
//
// static AgarPacket parseByteBuffer(ByteBuffer byteBuffer) {
// if (byteBuffer.capacity() == 0) {
// return null;
// }
// PacketType.ClientBound packetType = PacketType.ClientBound.packetType(byteBuffer.get());
// if (packetType == null) {
// return null;
// }
// switch (packetType) {
// case UPDATE_NODES:
// return new UpdateNodes(byteBuffer);
// case UPDATE_POSITION_SIZE:
// return new UpdatePositionAndSize(byteBuffer);
// case CLEAR_ALL_NODES:
// return new ClearAllNodes(byteBuffer);
// case ADD_NODE:
// return new AddNode(byteBuffer);
// case UPDATE_LEADERBOARD:
// return new UpdateLeaderBoard(byteBuffer);
// case SET_BORDER:
// return new SetBorder(byteBuffer);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
| import me.pascoej.ajario.packet.AgarPacket;
import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer; | package me.pascoej.ajario.packet.clientbound;
/**
* Created by john on 6/14/15.
*/
public abstract class ClientBoundPacket implements AgarPacket {
private final ByteBuffer byteBuffer;
ClientBoundPacket(ByteBuffer byteBuffer) {
this.byteBuffer = byteBuffer;
byteBuffer.position(1);
}
@Override
public byte[] toBytes() {
return byteBuffer.array();
}
| // Path: src/main/java/me/pascoej/ajario/packet/AgarPacket.java
// public interface AgarPacket {
// byte[] toBytes();
//
// PacketType getType();
//
// static AgarPacket parseByteBuffer(ByteBuffer byteBuffer) {
// if (byteBuffer.capacity() == 0) {
// return null;
// }
// PacketType.ClientBound packetType = PacketType.ClientBound.packetType(byteBuffer.get());
// if (packetType == null) {
// return null;
// }
// switch (packetType) {
// case UPDATE_NODES:
// return new UpdateNodes(byteBuffer);
// case UPDATE_POSITION_SIZE:
// return new UpdatePositionAndSize(byteBuffer);
// case CLEAR_ALL_NODES:
// return new ClearAllNodes(byteBuffer);
// case ADD_NODE:
// return new AddNode(byteBuffer);
// case UPDATE_LEADERBOARD:
// return new UpdateLeaderBoard(byteBuffer);
// case SET_BORDER:
// return new SetBorder(byteBuffer);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/ClientBoundPacket.java
import me.pascoej.ajario.packet.AgarPacket;
import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer;
package me.pascoej.ajario.packet.clientbound;
/**
* Created by john on 6/14/15.
*/
public abstract class ClientBoundPacket implements AgarPacket {
private final ByteBuffer byteBuffer;
ClientBoundPacket(ByteBuffer byteBuffer) {
this.byteBuffer = byteBuffer;
byteBuffer.position(1);
}
@Override
public byte[] toBytes() {
return byteBuffer.array();
}
| public PacketType.ClientBound packetCType() { |
pascoej/ajario | src/main/java/me/pascoej/ajario/packet/serverbound/Spectate.java | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
| import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer; | package me.pascoej.ajario.packet.serverbound;
/**
* Created by john on 6/14/15.
*/
public class Spectate extends ServerBoundPacket {
@Override
protected int size() {
return 1;
}
@Override
protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
return byteBuffer;
}
@Override | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
// Path: src/main/java/me/pascoej/ajario/packet/serverbound/Spectate.java
import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer;
package me.pascoej.ajario.packet.serverbound;
/**
* Created by john on 6/14/15.
*/
public class Spectate extends ServerBoundPacket {
@Override
protected int size() {
return 1;
}
@Override
protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
return byteBuffer;
}
@Override | public PacketType getType() { |
pascoej/ajario | src/main/java/me/pascoej/ajario/packet/clientbound/AddNode.java | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
| import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer; | package me.pascoej.ajario.packet.clientbound;
/**
* Created by john on 6/14/15.
*/
public class AddNode extends ClientBoundPacket {
private final int nodeId;
public AddNode(ByteBuffer byteBuffer) {
super(byteBuffer);
this.nodeId = byteBuffer.getInt();
}
public int getNodeId() {
return nodeId;
}
@Override | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/AddNode.java
import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer;
package me.pascoej.ajario.packet.clientbound;
/**
* Created by john on 6/14/15.
*/
public class AddNode extends ClientBoundPacket {
private final int nodeId;
public AddNode(ByteBuffer byteBuffer) {
super(byteBuffer);
this.nodeId = byteBuffer.getInt();
}
public int getNodeId() {
return nodeId;
}
@Override | public PacketType getType() { |
pascoej/ajario | src/main/java/me/pascoej/ajario/packet/serverbound/EjectMass.java | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
| import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer; | package me.pascoej.ajario.packet.serverbound;
/**
* Created by john on 6/14/15.
*/
public class EjectMass extends ServerBoundPacket {
@Override
protected int size() {
return 1;
}
@Override
protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
return byteBuffer;
}
@Override | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
// Path: src/main/java/me/pascoej/ajario/packet/serverbound/EjectMass.java
import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer;
package me.pascoej.ajario.packet.serverbound;
/**
* Created by john on 6/14/15.
*/
public class EjectMass extends ServerBoundPacket {
@Override
protected int size() {
return 1;
}
@Override
protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
return byteBuffer;
}
@Override | public PacketType getType() { |
pascoej/ajario | src/main/java/me/pascoej/ajario/World.java | // Path: src/main/java/me/pascoej/ajario/node/Node.java
// public class Node {
// private final int nodeId;
// private final NodeType nodeType;
// private long lastUpdate;
// private short x, y, size;
// double vX, vY;
//
// Node(int nodeId, NodeType nodeType) {
// this.nodeId = nodeId;
// this.nodeType = nodeType;
// }
//
// List<Double> errors = new ArrayList<>();
//
// public void updatePositionSize(short x, short y, short size) {
// long currentTime = System.currentTimeMillis();
// this.x = x;
// this.y = y;
// this.size = size;
// lastUpdate = currentTime;
// }
//
// public NodeType getNodeType() {
// return nodeType;
// }
//
// public int getNodeId() {
// return nodeId;
// }
//
// public double getLastUpdate() {
// return lastUpdate;
// }
//
// public short getX() {
// return x;
// }
//
// public short getY() {
// return y;
// }
//
// public short getSize() {
// return size;
// }
//
// public double distanceSquared(Node node1) {
// double xDiff = node1.getX() - this.getX();
// double yDiff = node1.getY() - this.getY();
// return (xDiff * xDiff) + (yDiff * yDiff);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/PlayerNode.java
// public class PlayerNode extends Node {
// private String name;
// private boolean mine;
//
// public PlayerNode(int nodeId) {
// super(nodeId, NodeType.PLAYER);
// }
//
// public String getName() {
// if (name == null) {
// return "";
// }
// return name;
// }
//
// public boolean isMine() {
// return mine;
// }
//
// public void setMine() {
// this.mine = true;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
| import me.pascoej.ajario.node.Node;
import me.pascoej.ajario.node.PlayerNode;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList; | package me.pascoej.ajario;
/**
* Created by john on 6/14/15.
*/
public class World {
private static final double WORLD_SIZE = 11180.339887498949; | // Path: src/main/java/me/pascoej/ajario/node/Node.java
// public class Node {
// private final int nodeId;
// private final NodeType nodeType;
// private long lastUpdate;
// private short x, y, size;
// double vX, vY;
//
// Node(int nodeId, NodeType nodeType) {
// this.nodeId = nodeId;
// this.nodeType = nodeType;
// }
//
// List<Double> errors = new ArrayList<>();
//
// public void updatePositionSize(short x, short y, short size) {
// long currentTime = System.currentTimeMillis();
// this.x = x;
// this.y = y;
// this.size = size;
// lastUpdate = currentTime;
// }
//
// public NodeType getNodeType() {
// return nodeType;
// }
//
// public int getNodeId() {
// return nodeId;
// }
//
// public double getLastUpdate() {
// return lastUpdate;
// }
//
// public short getX() {
// return x;
// }
//
// public short getY() {
// return y;
// }
//
// public short getSize() {
// return size;
// }
//
// public double distanceSquared(Node node1) {
// double xDiff = node1.getX() - this.getX();
// double yDiff = node1.getY() - this.getY();
// return (xDiff * xDiff) + (yDiff * yDiff);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/PlayerNode.java
// public class PlayerNode extends Node {
// private String name;
// private boolean mine;
//
// public PlayerNode(int nodeId) {
// super(nodeId, NodeType.PLAYER);
// }
//
// public String getName() {
// if (name == null) {
// return "";
// }
// return name;
// }
//
// public boolean isMine() {
// return mine;
// }
//
// public void setMine() {
// this.mine = true;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
// Path: src/main/java/me/pascoej/ajario/World.java
import me.pascoej.ajario.node.Node;
import me.pascoej.ajario.node.PlayerNode;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
package me.pascoej.ajario;
/**
* Created by john on 6/14/15.
*/
public class World {
private static final double WORLD_SIZE = 11180.339887498949; | private final Map<Integer, Node> nodeById = new HashMap<>(); |
pascoej/ajario | src/main/java/me/pascoej/ajario/World.java | // Path: src/main/java/me/pascoej/ajario/node/Node.java
// public class Node {
// private final int nodeId;
// private final NodeType nodeType;
// private long lastUpdate;
// private short x, y, size;
// double vX, vY;
//
// Node(int nodeId, NodeType nodeType) {
// this.nodeId = nodeId;
// this.nodeType = nodeType;
// }
//
// List<Double> errors = new ArrayList<>();
//
// public void updatePositionSize(short x, short y, short size) {
// long currentTime = System.currentTimeMillis();
// this.x = x;
// this.y = y;
// this.size = size;
// lastUpdate = currentTime;
// }
//
// public NodeType getNodeType() {
// return nodeType;
// }
//
// public int getNodeId() {
// return nodeId;
// }
//
// public double getLastUpdate() {
// return lastUpdate;
// }
//
// public short getX() {
// return x;
// }
//
// public short getY() {
// return y;
// }
//
// public short getSize() {
// return size;
// }
//
// public double distanceSquared(Node node1) {
// double xDiff = node1.getX() - this.getX();
// double yDiff = node1.getY() - this.getY();
// return (xDiff * xDiff) + (yDiff * yDiff);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/PlayerNode.java
// public class PlayerNode extends Node {
// private String name;
// private boolean mine;
//
// public PlayerNode(int nodeId) {
// super(nodeId, NodeType.PLAYER);
// }
//
// public String getName() {
// if (name == null) {
// return "";
// }
// return name;
// }
//
// public boolean isMine() {
// return mine;
// }
//
// public void setMine() {
// this.mine = true;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
| import me.pascoej.ajario.node.Node;
import me.pascoej.ajario.node.PlayerNode;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList; | public void addClientsNode(Node node) {
addNode(node);
clientNodes.add(node);
}
public List<Node> getNodes() {
return nodes;
}
public List<Node> getClientNodes() {
return clientNodes;
}
public Node getNode(int id) {
return nodeById.get(id);
}
public void removeNode(int id) {
Node node = nodeById.get(id);
removeNode(node);
}
public void removeNode(Node node) {
nodes.remove(node);
nodeById.remove(node.getNodeId());
if (clientNodes.contains(node)) {
clientNodes.remove(node);
}
}
| // Path: src/main/java/me/pascoej/ajario/node/Node.java
// public class Node {
// private final int nodeId;
// private final NodeType nodeType;
// private long lastUpdate;
// private short x, y, size;
// double vX, vY;
//
// Node(int nodeId, NodeType nodeType) {
// this.nodeId = nodeId;
// this.nodeType = nodeType;
// }
//
// List<Double> errors = new ArrayList<>();
//
// public void updatePositionSize(short x, short y, short size) {
// long currentTime = System.currentTimeMillis();
// this.x = x;
// this.y = y;
// this.size = size;
// lastUpdate = currentTime;
// }
//
// public NodeType getNodeType() {
// return nodeType;
// }
//
// public int getNodeId() {
// return nodeId;
// }
//
// public double getLastUpdate() {
// return lastUpdate;
// }
//
// public short getX() {
// return x;
// }
//
// public short getY() {
// return y;
// }
//
// public short getSize() {
// return size;
// }
//
// public double distanceSquared(Node node1) {
// double xDiff = node1.getX() - this.getX();
// double yDiff = node1.getY() - this.getY();
// return (xDiff * xDiff) + (yDiff * yDiff);
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/node/PlayerNode.java
// public class PlayerNode extends Node {
// private String name;
// private boolean mine;
//
// public PlayerNode(int nodeId) {
// super(nodeId, NodeType.PLAYER);
// }
//
// public String getName() {
// if (name == null) {
// return "";
// }
// return name;
// }
//
// public boolean isMine() {
// return mine;
// }
//
// public void setMine() {
// this.mine = true;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
// Path: src/main/java/me/pascoej/ajario/World.java
import me.pascoej.ajario.node.Node;
import me.pascoej.ajario.node.PlayerNode;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
public void addClientsNode(Node node) {
addNode(node);
clientNodes.add(node);
}
public List<Node> getNodes() {
return nodes;
}
public List<Node> getClientNodes() {
return clientNodes;
}
public Node getNode(int id) {
return nodeById.get(id);
}
public void removeNode(int id) {
Node node = nodeById.get(id);
removeNode(node);
}
public void removeNode(Node node) {
nodes.remove(node);
nodeById.remove(node.getNodeId());
if (clientNodes.contains(node)) {
clientNodes.remove(node);
}
}
| public boolean isSplit(PlayerNode node) { |
pascoej/ajario | src/main/java/me/pascoej/ajario/protocol/WebSocketHandler.java | // Path: src/main/java/me/pascoej/ajario/packet/AgarPacket.java
// public interface AgarPacket {
// byte[] toBytes();
//
// PacketType getType();
//
// static AgarPacket parseByteBuffer(ByteBuffer byteBuffer) {
// if (byteBuffer.capacity() == 0) {
// return null;
// }
// PacketType.ClientBound packetType = PacketType.ClientBound.packetType(byteBuffer.get());
// if (packetType == null) {
// return null;
// }
// switch (packetType) {
// case UPDATE_NODES:
// return new UpdateNodes(byteBuffer);
// case UPDATE_POSITION_SIZE:
// return new UpdatePositionAndSize(byteBuffer);
// case CLEAR_ALL_NODES:
// return new ClearAllNodes(byteBuffer);
// case ADD_NODE:
// return new AddNode(byteBuffer);
// case UPDATE_LEADERBOARD:
// return new UpdateLeaderBoard(byteBuffer);
// case SET_BORDER:
// return new SetBorder(byteBuffer);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/ClientBoundPacket.java
// public abstract class ClientBoundPacket implements AgarPacket {
// private final ByteBuffer byteBuffer;
//
// ClientBoundPacket(ByteBuffer byteBuffer) {
// this.byteBuffer = byteBuffer;
// byteBuffer.position(1);
// }
//
// @Override
// public byte[] toBytes() {
// return byteBuffer.array();
// }
//
// public PacketType.ClientBound packetCType() {
// return (PacketType.ClientBound) getType();
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/serverbound/ConnectionResetPacket.java
// public class ConnectionResetPacket extends ServerBoundPacket {
//
//
// public PacketType getType() {
// return PacketType.ServerBound.RESET_CONNECTION;
// }
//
//
// @Override
// protected int size() {
// return 5;
// }
//
// @Override
// protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
// byteBuffer.putInt(1);
// return byteBuffer;
// }
// }
| import me.pascoej.ajario.packet.AgarPacket;
import me.pascoej.ajario.packet.PacketType;
import me.pascoej.ajario.packet.clientbound.ClientBoundPacket;
import me.pascoej.ajario.packet.serverbound.ConnectionResetPacket;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_17;
import org.java_websocket.handshake.ServerHandshake;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.*; | package me.pascoej.ajario.protocol;
/**
* Created by john on 6/14/15.
*/
public class WebSocketHandler extends WebSocketClient {
private final Set<PacketListener> packetListenerList = new HashSet<>();
private boolean open = false; | // Path: src/main/java/me/pascoej/ajario/packet/AgarPacket.java
// public interface AgarPacket {
// byte[] toBytes();
//
// PacketType getType();
//
// static AgarPacket parseByteBuffer(ByteBuffer byteBuffer) {
// if (byteBuffer.capacity() == 0) {
// return null;
// }
// PacketType.ClientBound packetType = PacketType.ClientBound.packetType(byteBuffer.get());
// if (packetType == null) {
// return null;
// }
// switch (packetType) {
// case UPDATE_NODES:
// return new UpdateNodes(byteBuffer);
// case UPDATE_POSITION_SIZE:
// return new UpdatePositionAndSize(byteBuffer);
// case CLEAR_ALL_NODES:
// return new ClearAllNodes(byteBuffer);
// case ADD_NODE:
// return new AddNode(byteBuffer);
// case UPDATE_LEADERBOARD:
// return new UpdateLeaderBoard(byteBuffer);
// case SET_BORDER:
// return new SetBorder(byteBuffer);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/ClientBoundPacket.java
// public abstract class ClientBoundPacket implements AgarPacket {
// private final ByteBuffer byteBuffer;
//
// ClientBoundPacket(ByteBuffer byteBuffer) {
// this.byteBuffer = byteBuffer;
// byteBuffer.position(1);
// }
//
// @Override
// public byte[] toBytes() {
// return byteBuffer.array();
// }
//
// public PacketType.ClientBound packetCType() {
// return (PacketType.ClientBound) getType();
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/serverbound/ConnectionResetPacket.java
// public class ConnectionResetPacket extends ServerBoundPacket {
//
//
// public PacketType getType() {
// return PacketType.ServerBound.RESET_CONNECTION;
// }
//
//
// @Override
// protected int size() {
// return 5;
// }
//
// @Override
// protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
// byteBuffer.putInt(1);
// return byteBuffer;
// }
// }
// Path: src/main/java/me/pascoej/ajario/protocol/WebSocketHandler.java
import me.pascoej.ajario.packet.AgarPacket;
import me.pascoej.ajario.packet.PacketType;
import me.pascoej.ajario.packet.clientbound.ClientBoundPacket;
import me.pascoej.ajario.packet.serverbound.ConnectionResetPacket;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_17;
import org.java_websocket.handshake.ServerHandshake;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.*;
package me.pascoej.ajario.protocol;
/**
* Created by john on 6/14/15.
*/
public class WebSocketHandler extends WebSocketClient {
private final Set<PacketListener> packetListenerList = new HashSet<>();
private boolean open = false; | private Queue<AgarPacket> packetQueue = new ArrayDeque<>(); |
pascoej/ajario | src/main/java/me/pascoej/ajario/protocol/WebSocketHandler.java | // Path: src/main/java/me/pascoej/ajario/packet/AgarPacket.java
// public interface AgarPacket {
// byte[] toBytes();
//
// PacketType getType();
//
// static AgarPacket parseByteBuffer(ByteBuffer byteBuffer) {
// if (byteBuffer.capacity() == 0) {
// return null;
// }
// PacketType.ClientBound packetType = PacketType.ClientBound.packetType(byteBuffer.get());
// if (packetType == null) {
// return null;
// }
// switch (packetType) {
// case UPDATE_NODES:
// return new UpdateNodes(byteBuffer);
// case UPDATE_POSITION_SIZE:
// return new UpdatePositionAndSize(byteBuffer);
// case CLEAR_ALL_NODES:
// return new ClearAllNodes(byteBuffer);
// case ADD_NODE:
// return new AddNode(byteBuffer);
// case UPDATE_LEADERBOARD:
// return new UpdateLeaderBoard(byteBuffer);
// case SET_BORDER:
// return new SetBorder(byteBuffer);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/ClientBoundPacket.java
// public abstract class ClientBoundPacket implements AgarPacket {
// private final ByteBuffer byteBuffer;
//
// ClientBoundPacket(ByteBuffer byteBuffer) {
// this.byteBuffer = byteBuffer;
// byteBuffer.position(1);
// }
//
// @Override
// public byte[] toBytes() {
// return byteBuffer.array();
// }
//
// public PacketType.ClientBound packetCType() {
// return (PacketType.ClientBound) getType();
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/serverbound/ConnectionResetPacket.java
// public class ConnectionResetPacket extends ServerBoundPacket {
//
//
// public PacketType getType() {
// return PacketType.ServerBound.RESET_CONNECTION;
// }
//
//
// @Override
// protected int size() {
// return 5;
// }
//
// @Override
// protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
// byteBuffer.putInt(1);
// return byteBuffer;
// }
// }
| import me.pascoej.ajario.packet.AgarPacket;
import me.pascoej.ajario.packet.PacketType;
import me.pascoej.ajario.packet.clientbound.ClientBoundPacket;
import me.pascoej.ajario.packet.serverbound.ConnectionResetPacket;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_17;
import org.java_websocket.handshake.ServerHandshake;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.*; | package me.pascoej.ajario.protocol;
/**
* Created by john on 6/14/15.
*/
public class WebSocketHandler extends WebSocketClient {
private final Set<PacketListener> packetListenerList = new HashSet<>();
private boolean open = false;
private Queue<AgarPacket> packetQueue = new ArrayDeque<>();
private Session session;
public WebSocketHandler(URI serverURI, Session session) {
super(serverURI, new Draft_17(), headers(), 0);
this.session = session;
}
public Set<PacketListener> getPacketListeners() {
return packetListenerList;
}
@Override
public void onOpen(ServerHandshake serverHandshake) {
open = true; | // Path: src/main/java/me/pascoej/ajario/packet/AgarPacket.java
// public interface AgarPacket {
// byte[] toBytes();
//
// PacketType getType();
//
// static AgarPacket parseByteBuffer(ByteBuffer byteBuffer) {
// if (byteBuffer.capacity() == 0) {
// return null;
// }
// PacketType.ClientBound packetType = PacketType.ClientBound.packetType(byteBuffer.get());
// if (packetType == null) {
// return null;
// }
// switch (packetType) {
// case UPDATE_NODES:
// return new UpdateNodes(byteBuffer);
// case UPDATE_POSITION_SIZE:
// return new UpdatePositionAndSize(byteBuffer);
// case CLEAR_ALL_NODES:
// return new ClearAllNodes(byteBuffer);
// case ADD_NODE:
// return new AddNode(byteBuffer);
// case UPDATE_LEADERBOARD:
// return new UpdateLeaderBoard(byteBuffer);
// case SET_BORDER:
// return new SetBorder(byteBuffer);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/ClientBoundPacket.java
// public abstract class ClientBoundPacket implements AgarPacket {
// private final ByteBuffer byteBuffer;
//
// ClientBoundPacket(ByteBuffer byteBuffer) {
// this.byteBuffer = byteBuffer;
// byteBuffer.position(1);
// }
//
// @Override
// public byte[] toBytes() {
// return byteBuffer.array();
// }
//
// public PacketType.ClientBound packetCType() {
// return (PacketType.ClientBound) getType();
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/serverbound/ConnectionResetPacket.java
// public class ConnectionResetPacket extends ServerBoundPacket {
//
//
// public PacketType getType() {
// return PacketType.ServerBound.RESET_CONNECTION;
// }
//
//
// @Override
// protected int size() {
// return 5;
// }
//
// @Override
// protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
// byteBuffer.putInt(1);
// return byteBuffer;
// }
// }
// Path: src/main/java/me/pascoej/ajario/protocol/WebSocketHandler.java
import me.pascoej.ajario.packet.AgarPacket;
import me.pascoej.ajario.packet.PacketType;
import me.pascoej.ajario.packet.clientbound.ClientBoundPacket;
import me.pascoej.ajario.packet.serverbound.ConnectionResetPacket;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_17;
import org.java_websocket.handshake.ServerHandshake;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.*;
package me.pascoej.ajario.protocol;
/**
* Created by john on 6/14/15.
*/
public class WebSocketHandler extends WebSocketClient {
private final Set<PacketListener> packetListenerList = new HashSet<>();
private boolean open = false;
private Queue<AgarPacket> packetQueue = new ArrayDeque<>();
private Session session;
public WebSocketHandler(URI serverURI, Session session) {
super(serverURI, new Draft_17(), headers(), 0);
this.session = session;
}
public Set<PacketListener> getPacketListeners() {
return packetListenerList;
}
@Override
public void onOpen(ServerHandshake serverHandshake) {
open = true; | sendPacket(new ConnectionResetPacket()); |
pascoej/ajario | src/main/java/me/pascoej/ajario/protocol/WebSocketHandler.java | // Path: src/main/java/me/pascoej/ajario/packet/AgarPacket.java
// public interface AgarPacket {
// byte[] toBytes();
//
// PacketType getType();
//
// static AgarPacket parseByteBuffer(ByteBuffer byteBuffer) {
// if (byteBuffer.capacity() == 0) {
// return null;
// }
// PacketType.ClientBound packetType = PacketType.ClientBound.packetType(byteBuffer.get());
// if (packetType == null) {
// return null;
// }
// switch (packetType) {
// case UPDATE_NODES:
// return new UpdateNodes(byteBuffer);
// case UPDATE_POSITION_SIZE:
// return new UpdatePositionAndSize(byteBuffer);
// case CLEAR_ALL_NODES:
// return new ClearAllNodes(byteBuffer);
// case ADD_NODE:
// return new AddNode(byteBuffer);
// case UPDATE_LEADERBOARD:
// return new UpdateLeaderBoard(byteBuffer);
// case SET_BORDER:
// return new SetBorder(byteBuffer);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/ClientBoundPacket.java
// public abstract class ClientBoundPacket implements AgarPacket {
// private final ByteBuffer byteBuffer;
//
// ClientBoundPacket(ByteBuffer byteBuffer) {
// this.byteBuffer = byteBuffer;
// byteBuffer.position(1);
// }
//
// @Override
// public byte[] toBytes() {
// return byteBuffer.array();
// }
//
// public PacketType.ClientBound packetCType() {
// return (PacketType.ClientBound) getType();
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/serverbound/ConnectionResetPacket.java
// public class ConnectionResetPacket extends ServerBoundPacket {
//
//
// public PacketType getType() {
// return PacketType.ServerBound.RESET_CONNECTION;
// }
//
//
// @Override
// protected int size() {
// return 5;
// }
//
// @Override
// protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
// byteBuffer.putInt(1);
// return byteBuffer;
// }
// }
| import me.pascoej.ajario.packet.AgarPacket;
import me.pascoej.ajario.packet.PacketType;
import me.pascoej.ajario.packet.clientbound.ClientBoundPacket;
import me.pascoej.ajario.packet.serverbound.ConnectionResetPacket;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_17;
import org.java_websocket.handshake.ServerHandshake;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.*; | }
public Set<PacketListener> getPacketListeners() {
return packetListenerList;
}
@Override
public void onOpen(ServerHandshake serverHandshake) {
open = true;
sendPacket(new ConnectionResetPacket());
while (!packetQueue.isEmpty()) {
AgarPacket agarPacket = packetQueue.poll();
sendPacket(agarPacket);
}
}
public boolean isOpen() {
return open;
}
@Override
public void onMessage(String s) {
}
@Override
public void onMessage(ByteBuffer bytes) {
try {
bytes = bytes.order(ByteOrder.LITTLE_ENDIAN);
AgarPacket agarPacket = AgarPacket.parseByteBuffer(bytes);
if (agarPacket != null) { | // Path: src/main/java/me/pascoej/ajario/packet/AgarPacket.java
// public interface AgarPacket {
// byte[] toBytes();
//
// PacketType getType();
//
// static AgarPacket parseByteBuffer(ByteBuffer byteBuffer) {
// if (byteBuffer.capacity() == 0) {
// return null;
// }
// PacketType.ClientBound packetType = PacketType.ClientBound.packetType(byteBuffer.get());
// if (packetType == null) {
// return null;
// }
// switch (packetType) {
// case UPDATE_NODES:
// return new UpdateNodes(byteBuffer);
// case UPDATE_POSITION_SIZE:
// return new UpdatePositionAndSize(byteBuffer);
// case CLEAR_ALL_NODES:
// return new ClearAllNodes(byteBuffer);
// case ADD_NODE:
// return new AddNode(byteBuffer);
// case UPDATE_LEADERBOARD:
// return new UpdateLeaderBoard(byteBuffer);
// case SET_BORDER:
// return new SetBorder(byteBuffer);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/ClientBoundPacket.java
// public abstract class ClientBoundPacket implements AgarPacket {
// private final ByteBuffer byteBuffer;
//
// ClientBoundPacket(ByteBuffer byteBuffer) {
// this.byteBuffer = byteBuffer;
// byteBuffer.position(1);
// }
//
// @Override
// public byte[] toBytes() {
// return byteBuffer.array();
// }
//
// public PacketType.ClientBound packetCType() {
// return (PacketType.ClientBound) getType();
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/serverbound/ConnectionResetPacket.java
// public class ConnectionResetPacket extends ServerBoundPacket {
//
//
// public PacketType getType() {
// return PacketType.ServerBound.RESET_CONNECTION;
// }
//
//
// @Override
// protected int size() {
// return 5;
// }
//
// @Override
// protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
// byteBuffer.putInt(1);
// return byteBuffer;
// }
// }
// Path: src/main/java/me/pascoej/ajario/protocol/WebSocketHandler.java
import me.pascoej.ajario.packet.AgarPacket;
import me.pascoej.ajario.packet.PacketType;
import me.pascoej.ajario.packet.clientbound.ClientBoundPacket;
import me.pascoej.ajario.packet.serverbound.ConnectionResetPacket;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_17;
import org.java_websocket.handshake.ServerHandshake;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.*;
}
public Set<PacketListener> getPacketListeners() {
return packetListenerList;
}
@Override
public void onOpen(ServerHandshake serverHandshake) {
open = true;
sendPacket(new ConnectionResetPacket());
while (!packetQueue.isEmpty()) {
AgarPacket agarPacket = packetQueue.poll();
sendPacket(agarPacket);
}
}
public boolean isOpen() {
return open;
}
@Override
public void onMessage(String s) {
}
@Override
public void onMessage(ByteBuffer bytes) {
try {
bytes = bytes.order(ByteOrder.LITTLE_ENDIAN);
AgarPacket agarPacket = AgarPacket.parseByteBuffer(bytes);
if (agarPacket != null) { | if (agarPacket.getType() == PacketType.ClientBound.UPDATE_POSITION_SIZE) { |
pascoej/ajario | src/main/java/me/pascoej/ajario/protocol/WebSocketHandler.java | // Path: src/main/java/me/pascoej/ajario/packet/AgarPacket.java
// public interface AgarPacket {
// byte[] toBytes();
//
// PacketType getType();
//
// static AgarPacket parseByteBuffer(ByteBuffer byteBuffer) {
// if (byteBuffer.capacity() == 0) {
// return null;
// }
// PacketType.ClientBound packetType = PacketType.ClientBound.packetType(byteBuffer.get());
// if (packetType == null) {
// return null;
// }
// switch (packetType) {
// case UPDATE_NODES:
// return new UpdateNodes(byteBuffer);
// case UPDATE_POSITION_SIZE:
// return new UpdatePositionAndSize(byteBuffer);
// case CLEAR_ALL_NODES:
// return new ClearAllNodes(byteBuffer);
// case ADD_NODE:
// return new AddNode(byteBuffer);
// case UPDATE_LEADERBOARD:
// return new UpdateLeaderBoard(byteBuffer);
// case SET_BORDER:
// return new SetBorder(byteBuffer);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/ClientBoundPacket.java
// public abstract class ClientBoundPacket implements AgarPacket {
// private final ByteBuffer byteBuffer;
//
// ClientBoundPacket(ByteBuffer byteBuffer) {
// this.byteBuffer = byteBuffer;
// byteBuffer.position(1);
// }
//
// @Override
// public byte[] toBytes() {
// return byteBuffer.array();
// }
//
// public PacketType.ClientBound packetCType() {
// return (PacketType.ClientBound) getType();
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/serverbound/ConnectionResetPacket.java
// public class ConnectionResetPacket extends ServerBoundPacket {
//
//
// public PacketType getType() {
// return PacketType.ServerBound.RESET_CONNECTION;
// }
//
//
// @Override
// protected int size() {
// return 5;
// }
//
// @Override
// protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
// byteBuffer.putInt(1);
// return byteBuffer;
// }
// }
| import me.pascoej.ajario.packet.AgarPacket;
import me.pascoej.ajario.packet.PacketType;
import me.pascoej.ajario.packet.clientbound.ClientBoundPacket;
import me.pascoej.ajario.packet.serverbound.ConnectionResetPacket;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_17;
import org.java_websocket.handshake.ServerHandshake;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.*; | }
@Override
public void onOpen(ServerHandshake serverHandshake) {
open = true;
sendPacket(new ConnectionResetPacket());
while (!packetQueue.isEmpty()) {
AgarPacket agarPacket = packetQueue.poll();
sendPacket(agarPacket);
}
}
public boolean isOpen() {
return open;
}
@Override
public void onMessage(String s) {
}
@Override
public void onMessage(ByteBuffer bytes) {
try {
bytes = bytes.order(ByteOrder.LITTLE_ENDIAN);
AgarPacket agarPacket = AgarPacket.parseByteBuffer(bytes);
if (agarPacket != null) {
if (agarPacket.getType() == PacketType.ClientBound.UPDATE_POSITION_SIZE) {
System.out.println(agarPacket);
}
for (PacketListener packetListener : packetListenerList) { | // Path: src/main/java/me/pascoej/ajario/packet/AgarPacket.java
// public interface AgarPacket {
// byte[] toBytes();
//
// PacketType getType();
//
// static AgarPacket parseByteBuffer(ByteBuffer byteBuffer) {
// if (byteBuffer.capacity() == 0) {
// return null;
// }
// PacketType.ClientBound packetType = PacketType.ClientBound.packetType(byteBuffer.get());
// if (packetType == null) {
// return null;
// }
// switch (packetType) {
// case UPDATE_NODES:
// return new UpdateNodes(byteBuffer);
// case UPDATE_POSITION_SIZE:
// return new UpdatePositionAndSize(byteBuffer);
// case CLEAR_ALL_NODES:
// return new ClearAllNodes(byteBuffer);
// case ADD_NODE:
// return new AddNode(byteBuffer);
// case UPDATE_LEADERBOARD:
// return new UpdateLeaderBoard(byteBuffer);
// case SET_BORDER:
// return new SetBorder(byteBuffer);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/ClientBoundPacket.java
// public abstract class ClientBoundPacket implements AgarPacket {
// private final ByteBuffer byteBuffer;
//
// ClientBoundPacket(ByteBuffer byteBuffer) {
// this.byteBuffer = byteBuffer;
// byteBuffer.position(1);
// }
//
// @Override
// public byte[] toBytes() {
// return byteBuffer.array();
// }
//
// public PacketType.ClientBound packetCType() {
// return (PacketType.ClientBound) getType();
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/packet/serverbound/ConnectionResetPacket.java
// public class ConnectionResetPacket extends ServerBoundPacket {
//
//
// public PacketType getType() {
// return PacketType.ServerBound.RESET_CONNECTION;
// }
//
//
// @Override
// protected int size() {
// return 5;
// }
//
// @Override
// protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
// byteBuffer.putInt(1);
// return byteBuffer;
// }
// }
// Path: src/main/java/me/pascoej/ajario/protocol/WebSocketHandler.java
import me.pascoej.ajario.packet.AgarPacket;
import me.pascoej.ajario.packet.PacketType;
import me.pascoej.ajario.packet.clientbound.ClientBoundPacket;
import me.pascoej.ajario.packet.serverbound.ConnectionResetPacket;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_17;
import org.java_websocket.handshake.ServerHandshake;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.*;
}
@Override
public void onOpen(ServerHandshake serverHandshake) {
open = true;
sendPacket(new ConnectionResetPacket());
while (!packetQueue.isEmpty()) {
AgarPacket agarPacket = packetQueue.poll();
sendPacket(agarPacket);
}
}
public boolean isOpen() {
return open;
}
@Override
public void onMessage(String s) {
}
@Override
public void onMessage(ByteBuffer bytes) {
try {
bytes = bytes.order(ByteOrder.LITTLE_ENDIAN);
AgarPacket agarPacket = AgarPacket.parseByteBuffer(bytes);
if (agarPacket != null) {
if (agarPacket.getType() == PacketType.ClientBound.UPDATE_POSITION_SIZE) {
System.out.println(agarPacket);
}
for (PacketListener packetListener : packetListenerList) { | packetListener.onRecvPacket((ClientBoundPacket) agarPacket); |
pascoej/ajario | src/main/java/me/pascoej/ajario/gui/views/ServerChooserView.java | // Path: src/main/java/me/pascoej/ajario/gui/ClientGUI.java
// public class ClientGUI extends BasicGame {
// private final AgarClient agarClient;
// private boolean showFPS = false;
// private boolean fullscreen = false;
// private final List<View> views = new CopyOnWriteArrayList<>();
// private GameContainer gameContainer;
//
// public ClientGUI(AgarClient agarClient) {
// super("Ajar Client");
// this.agarClient = agarClient;
// }
//
// @Override
// public void keyPressed(int key, char c) {
// if (key == Keyboard.KEY_BACKSLASH) {
// showFPS = !showFPS;
// } else if (key == Keyboard.KEY_9) {
// fullscreen = !fullscreen;
// } else if (key == Keyboard.KEY_ESCAPE) {
// System.exit(0);
// } else if ((key == Keyboard.KEY_GRAVE || key == 13) && !hasViewClass(ServerChooserView.class) && !hasViewClass(OptionsView.class)) {
// addView(new ServerChooserView(this));
// }
// if (key == Keyboard.KEY_M) {
// agarClient.serverResetPacket();
// }
// }
//
// @Override
// public void init(GameContainer gameContainer) throws SlickException {
// this.gameContainer = gameContainer;
// gameContainer.setVSync(true);
// addView(new GameView(agarClient));
// }
//
// private boolean hasViewClass(Class clazz) {
// for (View view : views) {
// if (view.getClass() == clazz) {
// return true;
// }
// }
// return false;
// }
//
// public void addView(View view) {
// views.add(view);
// gameContainer.getInput().addListener(view);
// }
//
// public GameView getGameView() {
// return (GameView) views.get(0);
// }
//
// public AgarClient getAgarClient() {
// return agarClient;
// }
//
// public void removeView(View view) {
// views.remove(view);
// gameContainer.getInput().removeListener(view);
// }
//
// int refresh = 0;
//
// @Override
// public void update(GameContainer gameContainer, int i) throws SlickException {
// if (gameContainer.isShowingFPS() != showFPS) {
// gameContainer.setShowFPS(showFPS);
// }
// if (gameContainer.isFullscreen() != fullscreen) {
// if (fullscreen) {
// if (gameContainer instanceof AppGameContainer) {
// AppGameContainer appGameContainer = (AppGameContainer) gameContainer;
// appGameContainer.setDisplayMode(1440, 900, true);
// init(gameContainer);
// }
// }
// }
// agarClient.update();
// }
//
//
// @Override
// public void render(GameContainer gameContainer, Graphics g) throws SlickException {
// if (showFPS) {
// g.setColor(Color.white);
// String text = "u/s: " + agarClient.getUpdatePerSecond();
// int textHeight = g.getFont().getHeight(text);
// int textWidth = g.getFont().getWidth(text);
// int textX = gameContainer.getWidth()-5-textWidth;
// int textY = gameContainer.getHeight()-5-textHeight;
// g.drawString(text,textX,textY);
// }
// views.stream().filter(View::shouldDraw).forEach(view -> view.render(gameContainer, g));
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/util/ServerChooserUtil.java
// public class ServerChooserUtil {
// private static final String[] regions = {"US-Fremont", "US-Atlanta", "BR-Brazil", "EU-London", "RU-Russia", "JP-Tokyo", "CN-China", "SG-Singapore"};
// private static final String requestURL = "http://m.agar.io/";
//
// public static String[] getRegions() {
// return regions;
// }
//
// public static URI getServer(String regionName) {
// try {
// return URI.create("ws://" + new Resty().text(requestURL, form(data("region", regionName))).toString());
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
// public static URI bestServer(String regionName, int amount) {
// //for fun
// return IntStream.range(0,amount).parallel().mapToObj(a->getServer(regionName)).distinct().parallel().collect(Collectors.toMap(a -> a, LagScore::lagScore)).entrySet().stream().min((entry1, entry2) -> entry1.getValue() > entry2.getValue() ? 1 : -1).get().getKey();
// }
// }
| import me.pascoej.ajario.gui.ClientGUI;
import me.pascoej.ajario.util.ServerChooserUtil;
import org.lwjgl.input.Keyboard;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import java.net.URI; | package me.pascoej.ajario.gui.views;
/**
* Created by john on 6/15/15.
*/
public class ServerChooserView extends View {
private final ClientGUI clientGUI; | // Path: src/main/java/me/pascoej/ajario/gui/ClientGUI.java
// public class ClientGUI extends BasicGame {
// private final AgarClient agarClient;
// private boolean showFPS = false;
// private boolean fullscreen = false;
// private final List<View> views = new CopyOnWriteArrayList<>();
// private GameContainer gameContainer;
//
// public ClientGUI(AgarClient agarClient) {
// super("Ajar Client");
// this.agarClient = agarClient;
// }
//
// @Override
// public void keyPressed(int key, char c) {
// if (key == Keyboard.KEY_BACKSLASH) {
// showFPS = !showFPS;
// } else if (key == Keyboard.KEY_9) {
// fullscreen = !fullscreen;
// } else if (key == Keyboard.KEY_ESCAPE) {
// System.exit(0);
// } else if ((key == Keyboard.KEY_GRAVE || key == 13) && !hasViewClass(ServerChooserView.class) && !hasViewClass(OptionsView.class)) {
// addView(new ServerChooserView(this));
// }
// if (key == Keyboard.KEY_M) {
// agarClient.serverResetPacket();
// }
// }
//
// @Override
// public void init(GameContainer gameContainer) throws SlickException {
// this.gameContainer = gameContainer;
// gameContainer.setVSync(true);
// addView(new GameView(agarClient));
// }
//
// private boolean hasViewClass(Class clazz) {
// for (View view : views) {
// if (view.getClass() == clazz) {
// return true;
// }
// }
// return false;
// }
//
// public void addView(View view) {
// views.add(view);
// gameContainer.getInput().addListener(view);
// }
//
// public GameView getGameView() {
// return (GameView) views.get(0);
// }
//
// public AgarClient getAgarClient() {
// return agarClient;
// }
//
// public void removeView(View view) {
// views.remove(view);
// gameContainer.getInput().removeListener(view);
// }
//
// int refresh = 0;
//
// @Override
// public void update(GameContainer gameContainer, int i) throws SlickException {
// if (gameContainer.isShowingFPS() != showFPS) {
// gameContainer.setShowFPS(showFPS);
// }
// if (gameContainer.isFullscreen() != fullscreen) {
// if (fullscreen) {
// if (gameContainer instanceof AppGameContainer) {
// AppGameContainer appGameContainer = (AppGameContainer) gameContainer;
// appGameContainer.setDisplayMode(1440, 900, true);
// init(gameContainer);
// }
// }
// }
// agarClient.update();
// }
//
//
// @Override
// public void render(GameContainer gameContainer, Graphics g) throws SlickException {
// if (showFPS) {
// g.setColor(Color.white);
// String text = "u/s: " + agarClient.getUpdatePerSecond();
// int textHeight = g.getFont().getHeight(text);
// int textWidth = g.getFont().getWidth(text);
// int textX = gameContainer.getWidth()-5-textWidth;
// int textY = gameContainer.getHeight()-5-textHeight;
// g.drawString(text,textX,textY);
// }
// views.stream().filter(View::shouldDraw).forEach(view -> view.render(gameContainer, g));
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/util/ServerChooserUtil.java
// public class ServerChooserUtil {
// private static final String[] regions = {"US-Fremont", "US-Atlanta", "BR-Brazil", "EU-London", "RU-Russia", "JP-Tokyo", "CN-China", "SG-Singapore"};
// private static final String requestURL = "http://m.agar.io/";
//
// public static String[] getRegions() {
// return regions;
// }
//
// public static URI getServer(String regionName) {
// try {
// return URI.create("ws://" + new Resty().text(requestURL, form(data("region", regionName))).toString());
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
// public static URI bestServer(String regionName, int amount) {
// //for fun
// return IntStream.range(0,amount).parallel().mapToObj(a->getServer(regionName)).distinct().parallel().collect(Collectors.toMap(a -> a, LagScore::lagScore)).entrySet().stream().min((entry1, entry2) -> entry1.getValue() > entry2.getValue() ? 1 : -1).get().getKey();
// }
// }
// Path: src/main/java/me/pascoej/ajario/gui/views/ServerChooserView.java
import me.pascoej.ajario.gui.ClientGUI;
import me.pascoej.ajario.util.ServerChooserUtil;
import org.lwjgl.input.Keyboard;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import java.net.URI;
package me.pascoej.ajario.gui.views;
/**
* Created by john on 6/15/15.
*/
public class ServerChooserView extends View {
private final ClientGUI clientGUI; | private final String[] regions = ServerChooserUtil.getRegions(); |
pascoej/ajario | src/main/java/me/pascoej/ajario/gui/views/MessageView.java | // Path: src/main/java/me/pascoej/ajario/gui/ClientGUI.java
// public class ClientGUI extends BasicGame {
// private final AgarClient agarClient;
// private boolean showFPS = false;
// private boolean fullscreen = false;
// private final List<View> views = new CopyOnWriteArrayList<>();
// private GameContainer gameContainer;
//
// public ClientGUI(AgarClient agarClient) {
// super("Ajar Client");
// this.agarClient = agarClient;
// }
//
// @Override
// public void keyPressed(int key, char c) {
// if (key == Keyboard.KEY_BACKSLASH) {
// showFPS = !showFPS;
// } else if (key == Keyboard.KEY_9) {
// fullscreen = !fullscreen;
// } else if (key == Keyboard.KEY_ESCAPE) {
// System.exit(0);
// } else if ((key == Keyboard.KEY_GRAVE || key == 13) && !hasViewClass(ServerChooserView.class) && !hasViewClass(OptionsView.class)) {
// addView(new ServerChooserView(this));
// }
// if (key == Keyboard.KEY_M) {
// agarClient.serverResetPacket();
// }
// }
//
// @Override
// public void init(GameContainer gameContainer) throws SlickException {
// this.gameContainer = gameContainer;
// gameContainer.setVSync(true);
// addView(new GameView(agarClient));
// }
//
// private boolean hasViewClass(Class clazz) {
// for (View view : views) {
// if (view.getClass() == clazz) {
// return true;
// }
// }
// return false;
// }
//
// public void addView(View view) {
// views.add(view);
// gameContainer.getInput().addListener(view);
// }
//
// public GameView getGameView() {
// return (GameView) views.get(0);
// }
//
// public AgarClient getAgarClient() {
// return agarClient;
// }
//
// public void removeView(View view) {
// views.remove(view);
// gameContainer.getInput().removeListener(view);
// }
//
// int refresh = 0;
//
// @Override
// public void update(GameContainer gameContainer, int i) throws SlickException {
// if (gameContainer.isShowingFPS() != showFPS) {
// gameContainer.setShowFPS(showFPS);
// }
// if (gameContainer.isFullscreen() != fullscreen) {
// if (fullscreen) {
// if (gameContainer instanceof AppGameContainer) {
// AppGameContainer appGameContainer = (AppGameContainer) gameContainer;
// appGameContainer.setDisplayMode(1440, 900, true);
// init(gameContainer);
// }
// }
// }
// agarClient.update();
// }
//
//
// @Override
// public void render(GameContainer gameContainer, Graphics g) throws SlickException {
// if (showFPS) {
// g.setColor(Color.white);
// String text = "u/s: " + agarClient.getUpdatePerSecond();
// int textHeight = g.getFont().getHeight(text);
// int textWidth = g.getFont().getWidth(text);
// int textX = gameContainer.getWidth()-5-textWidth;
// int textY = gameContainer.getHeight()-5-textHeight;
// g.drawString(text,textX,textY);
// }
// views.stream().filter(View::shouldDraw).forEach(view -> view.render(gameContainer, g));
// }
// }
| import me.pascoej.ajario.gui.ClientGUI;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics; | package me.pascoej.ajario.gui.views;
/**
* Created by john on 6/15/15.
*/
public class MessageView extends View {
private long startTime = -1; | // Path: src/main/java/me/pascoej/ajario/gui/ClientGUI.java
// public class ClientGUI extends BasicGame {
// private final AgarClient agarClient;
// private boolean showFPS = false;
// private boolean fullscreen = false;
// private final List<View> views = new CopyOnWriteArrayList<>();
// private GameContainer gameContainer;
//
// public ClientGUI(AgarClient agarClient) {
// super("Ajar Client");
// this.agarClient = agarClient;
// }
//
// @Override
// public void keyPressed(int key, char c) {
// if (key == Keyboard.KEY_BACKSLASH) {
// showFPS = !showFPS;
// } else if (key == Keyboard.KEY_9) {
// fullscreen = !fullscreen;
// } else if (key == Keyboard.KEY_ESCAPE) {
// System.exit(0);
// } else if ((key == Keyboard.KEY_GRAVE || key == 13) && !hasViewClass(ServerChooserView.class) && !hasViewClass(OptionsView.class)) {
// addView(new ServerChooserView(this));
// }
// if (key == Keyboard.KEY_M) {
// agarClient.serverResetPacket();
// }
// }
//
// @Override
// public void init(GameContainer gameContainer) throws SlickException {
// this.gameContainer = gameContainer;
// gameContainer.setVSync(true);
// addView(new GameView(agarClient));
// }
//
// private boolean hasViewClass(Class clazz) {
// for (View view : views) {
// if (view.getClass() == clazz) {
// return true;
// }
// }
// return false;
// }
//
// public void addView(View view) {
// views.add(view);
// gameContainer.getInput().addListener(view);
// }
//
// public GameView getGameView() {
// return (GameView) views.get(0);
// }
//
// public AgarClient getAgarClient() {
// return agarClient;
// }
//
// public void removeView(View view) {
// views.remove(view);
// gameContainer.getInput().removeListener(view);
// }
//
// int refresh = 0;
//
// @Override
// public void update(GameContainer gameContainer, int i) throws SlickException {
// if (gameContainer.isShowingFPS() != showFPS) {
// gameContainer.setShowFPS(showFPS);
// }
// if (gameContainer.isFullscreen() != fullscreen) {
// if (fullscreen) {
// if (gameContainer instanceof AppGameContainer) {
// AppGameContainer appGameContainer = (AppGameContainer) gameContainer;
// appGameContainer.setDisplayMode(1440, 900, true);
// init(gameContainer);
// }
// }
// }
// agarClient.update();
// }
//
//
// @Override
// public void render(GameContainer gameContainer, Graphics g) throws SlickException {
// if (showFPS) {
// g.setColor(Color.white);
// String text = "u/s: " + agarClient.getUpdatePerSecond();
// int textHeight = g.getFont().getHeight(text);
// int textWidth = g.getFont().getWidth(text);
// int textX = gameContainer.getWidth()-5-textWidth;
// int textY = gameContainer.getHeight()-5-textHeight;
// g.drawString(text,textX,textY);
// }
// views.stream().filter(View::shouldDraw).forEach(view -> view.render(gameContainer, g));
// }
// }
// Path: src/main/java/me/pascoej/ajario/gui/views/MessageView.java
import me.pascoej.ajario.gui.ClientGUI;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
package me.pascoej.ajario.gui.views;
/**
* Created by john on 6/15/15.
*/
public class MessageView extends View {
private long startTime = -1; | private final ClientGUI clientGUI; |
pascoej/ajario | src/main/java/me/pascoej/ajario/GuiClientMain.java | // Path: src/main/java/me/pascoej/ajario/gui/ClientGUI.java
// public class ClientGUI extends BasicGame {
// private final AgarClient agarClient;
// private boolean showFPS = false;
// private boolean fullscreen = false;
// private final List<View> views = new CopyOnWriteArrayList<>();
// private GameContainer gameContainer;
//
// public ClientGUI(AgarClient agarClient) {
// super("Ajar Client");
// this.agarClient = agarClient;
// }
//
// @Override
// public void keyPressed(int key, char c) {
// if (key == Keyboard.KEY_BACKSLASH) {
// showFPS = !showFPS;
// } else if (key == Keyboard.KEY_9) {
// fullscreen = !fullscreen;
// } else if (key == Keyboard.KEY_ESCAPE) {
// System.exit(0);
// } else if ((key == Keyboard.KEY_GRAVE || key == 13) && !hasViewClass(ServerChooserView.class) && !hasViewClass(OptionsView.class)) {
// addView(new ServerChooserView(this));
// }
// if (key == Keyboard.KEY_M) {
// agarClient.serverResetPacket();
// }
// }
//
// @Override
// public void init(GameContainer gameContainer) throws SlickException {
// this.gameContainer = gameContainer;
// gameContainer.setVSync(true);
// addView(new GameView(agarClient));
// }
//
// private boolean hasViewClass(Class clazz) {
// for (View view : views) {
// if (view.getClass() == clazz) {
// return true;
// }
// }
// return false;
// }
//
// public void addView(View view) {
// views.add(view);
// gameContainer.getInput().addListener(view);
// }
//
// public GameView getGameView() {
// return (GameView) views.get(0);
// }
//
// public AgarClient getAgarClient() {
// return agarClient;
// }
//
// public void removeView(View view) {
// views.remove(view);
// gameContainer.getInput().removeListener(view);
// }
//
// int refresh = 0;
//
// @Override
// public void update(GameContainer gameContainer, int i) throws SlickException {
// if (gameContainer.isShowingFPS() != showFPS) {
// gameContainer.setShowFPS(showFPS);
// }
// if (gameContainer.isFullscreen() != fullscreen) {
// if (fullscreen) {
// if (gameContainer instanceof AppGameContainer) {
// AppGameContainer appGameContainer = (AppGameContainer) gameContainer;
// appGameContainer.setDisplayMode(1440, 900, true);
// init(gameContainer);
// }
// }
// }
// agarClient.update();
// }
//
//
// @Override
// public void render(GameContainer gameContainer, Graphics g) throws SlickException {
// if (showFPS) {
// g.setColor(Color.white);
// String text = "u/s: " + agarClient.getUpdatePerSecond();
// int textHeight = g.getFont().getHeight(text);
// int textWidth = g.getFont().getWidth(text);
// int textX = gameContainer.getWidth()-5-textWidth;
// int textY = gameContainer.getHeight()-5-textHeight;
// g.drawString(text,textX,textY);
// }
// views.stream().filter(View::shouldDraw).forEach(view -> view.render(gameContainer, g));
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/util/ServerChooserUtil.java
// public class ServerChooserUtil {
// private static final String[] regions = {"US-Fremont", "US-Atlanta", "BR-Brazil", "EU-London", "RU-Russia", "JP-Tokyo", "CN-China", "SG-Singapore"};
// private static final String requestURL = "http://m.agar.io/";
//
// public static String[] getRegions() {
// return regions;
// }
//
// public static URI getServer(String regionName) {
// try {
// return URI.create("ws://" + new Resty().text(requestURL, form(data("region", regionName))).toString());
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
// public static URI bestServer(String regionName, int amount) {
// //for fun
// return IntStream.range(0,amount).parallel().mapToObj(a->getServer(regionName)).distinct().parallel().collect(Collectors.toMap(a -> a, LagScore::lagScore)).entrySet().stream().min((entry1, entry2) -> entry1.getValue() > entry2.getValue() ? 1 : -1).get().getKey();
// }
// }
| import me.pascoej.ajario.gui.ClientGUI;
import me.pascoej.ajario.util.ServerChooserUtil;
import org.newdawn.slick.CanvasGameContainer;
import javax.swing.*; | package me.pascoej.ajario;
/**
* Created by john on 6/14/15.
*/
class GuiClientMain {
public static void main(String[] args) {
try {
JFrame frame = new JFrame("Ajar - agar.io client by pascoej");
AgarClient session = new AgarClient(); | // Path: src/main/java/me/pascoej/ajario/gui/ClientGUI.java
// public class ClientGUI extends BasicGame {
// private final AgarClient agarClient;
// private boolean showFPS = false;
// private boolean fullscreen = false;
// private final List<View> views = new CopyOnWriteArrayList<>();
// private GameContainer gameContainer;
//
// public ClientGUI(AgarClient agarClient) {
// super("Ajar Client");
// this.agarClient = agarClient;
// }
//
// @Override
// public void keyPressed(int key, char c) {
// if (key == Keyboard.KEY_BACKSLASH) {
// showFPS = !showFPS;
// } else if (key == Keyboard.KEY_9) {
// fullscreen = !fullscreen;
// } else if (key == Keyboard.KEY_ESCAPE) {
// System.exit(0);
// } else if ((key == Keyboard.KEY_GRAVE || key == 13) && !hasViewClass(ServerChooserView.class) && !hasViewClass(OptionsView.class)) {
// addView(new ServerChooserView(this));
// }
// if (key == Keyboard.KEY_M) {
// agarClient.serverResetPacket();
// }
// }
//
// @Override
// public void init(GameContainer gameContainer) throws SlickException {
// this.gameContainer = gameContainer;
// gameContainer.setVSync(true);
// addView(new GameView(agarClient));
// }
//
// private boolean hasViewClass(Class clazz) {
// for (View view : views) {
// if (view.getClass() == clazz) {
// return true;
// }
// }
// return false;
// }
//
// public void addView(View view) {
// views.add(view);
// gameContainer.getInput().addListener(view);
// }
//
// public GameView getGameView() {
// return (GameView) views.get(0);
// }
//
// public AgarClient getAgarClient() {
// return agarClient;
// }
//
// public void removeView(View view) {
// views.remove(view);
// gameContainer.getInput().removeListener(view);
// }
//
// int refresh = 0;
//
// @Override
// public void update(GameContainer gameContainer, int i) throws SlickException {
// if (gameContainer.isShowingFPS() != showFPS) {
// gameContainer.setShowFPS(showFPS);
// }
// if (gameContainer.isFullscreen() != fullscreen) {
// if (fullscreen) {
// if (gameContainer instanceof AppGameContainer) {
// AppGameContainer appGameContainer = (AppGameContainer) gameContainer;
// appGameContainer.setDisplayMode(1440, 900, true);
// init(gameContainer);
// }
// }
// }
// agarClient.update();
// }
//
//
// @Override
// public void render(GameContainer gameContainer, Graphics g) throws SlickException {
// if (showFPS) {
// g.setColor(Color.white);
// String text = "u/s: " + agarClient.getUpdatePerSecond();
// int textHeight = g.getFont().getHeight(text);
// int textWidth = g.getFont().getWidth(text);
// int textX = gameContainer.getWidth()-5-textWidth;
// int textY = gameContainer.getHeight()-5-textHeight;
// g.drawString(text,textX,textY);
// }
// views.stream().filter(View::shouldDraw).forEach(view -> view.render(gameContainer, g));
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/util/ServerChooserUtil.java
// public class ServerChooserUtil {
// private static final String[] regions = {"US-Fremont", "US-Atlanta", "BR-Brazil", "EU-London", "RU-Russia", "JP-Tokyo", "CN-China", "SG-Singapore"};
// private static final String requestURL = "http://m.agar.io/";
//
// public static String[] getRegions() {
// return regions;
// }
//
// public static URI getServer(String regionName) {
// try {
// return URI.create("ws://" + new Resty().text(requestURL, form(data("region", regionName))).toString());
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
// public static URI bestServer(String regionName, int amount) {
// //for fun
// return IntStream.range(0,amount).parallel().mapToObj(a->getServer(regionName)).distinct().parallel().collect(Collectors.toMap(a -> a, LagScore::lagScore)).entrySet().stream().min((entry1, entry2) -> entry1.getValue() > entry2.getValue() ? 1 : -1).get().getKey();
// }
// }
// Path: src/main/java/me/pascoej/ajario/GuiClientMain.java
import me.pascoej.ajario.gui.ClientGUI;
import me.pascoej.ajario.util.ServerChooserUtil;
import org.newdawn.slick.CanvasGameContainer;
import javax.swing.*;
package me.pascoej.ajario;
/**
* Created by john on 6/14/15.
*/
class GuiClientMain {
public static void main(String[] args) {
try {
JFrame frame = new JFrame("Ajar - agar.io client by pascoej");
AgarClient session = new AgarClient(); | session.connect(ServerChooserUtil.getServer("US-Fremont")); |
pascoej/ajario | src/main/java/me/pascoej/ajario/GuiClientMain.java | // Path: src/main/java/me/pascoej/ajario/gui/ClientGUI.java
// public class ClientGUI extends BasicGame {
// private final AgarClient agarClient;
// private boolean showFPS = false;
// private boolean fullscreen = false;
// private final List<View> views = new CopyOnWriteArrayList<>();
// private GameContainer gameContainer;
//
// public ClientGUI(AgarClient agarClient) {
// super("Ajar Client");
// this.agarClient = agarClient;
// }
//
// @Override
// public void keyPressed(int key, char c) {
// if (key == Keyboard.KEY_BACKSLASH) {
// showFPS = !showFPS;
// } else if (key == Keyboard.KEY_9) {
// fullscreen = !fullscreen;
// } else if (key == Keyboard.KEY_ESCAPE) {
// System.exit(0);
// } else if ((key == Keyboard.KEY_GRAVE || key == 13) && !hasViewClass(ServerChooserView.class) && !hasViewClass(OptionsView.class)) {
// addView(new ServerChooserView(this));
// }
// if (key == Keyboard.KEY_M) {
// agarClient.serverResetPacket();
// }
// }
//
// @Override
// public void init(GameContainer gameContainer) throws SlickException {
// this.gameContainer = gameContainer;
// gameContainer.setVSync(true);
// addView(new GameView(agarClient));
// }
//
// private boolean hasViewClass(Class clazz) {
// for (View view : views) {
// if (view.getClass() == clazz) {
// return true;
// }
// }
// return false;
// }
//
// public void addView(View view) {
// views.add(view);
// gameContainer.getInput().addListener(view);
// }
//
// public GameView getGameView() {
// return (GameView) views.get(0);
// }
//
// public AgarClient getAgarClient() {
// return agarClient;
// }
//
// public void removeView(View view) {
// views.remove(view);
// gameContainer.getInput().removeListener(view);
// }
//
// int refresh = 0;
//
// @Override
// public void update(GameContainer gameContainer, int i) throws SlickException {
// if (gameContainer.isShowingFPS() != showFPS) {
// gameContainer.setShowFPS(showFPS);
// }
// if (gameContainer.isFullscreen() != fullscreen) {
// if (fullscreen) {
// if (gameContainer instanceof AppGameContainer) {
// AppGameContainer appGameContainer = (AppGameContainer) gameContainer;
// appGameContainer.setDisplayMode(1440, 900, true);
// init(gameContainer);
// }
// }
// }
// agarClient.update();
// }
//
//
// @Override
// public void render(GameContainer gameContainer, Graphics g) throws SlickException {
// if (showFPS) {
// g.setColor(Color.white);
// String text = "u/s: " + agarClient.getUpdatePerSecond();
// int textHeight = g.getFont().getHeight(text);
// int textWidth = g.getFont().getWidth(text);
// int textX = gameContainer.getWidth()-5-textWidth;
// int textY = gameContainer.getHeight()-5-textHeight;
// g.drawString(text,textX,textY);
// }
// views.stream().filter(View::shouldDraw).forEach(view -> view.render(gameContainer, g));
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/util/ServerChooserUtil.java
// public class ServerChooserUtil {
// private static final String[] regions = {"US-Fremont", "US-Atlanta", "BR-Brazil", "EU-London", "RU-Russia", "JP-Tokyo", "CN-China", "SG-Singapore"};
// private static final String requestURL = "http://m.agar.io/";
//
// public static String[] getRegions() {
// return regions;
// }
//
// public static URI getServer(String regionName) {
// try {
// return URI.create("ws://" + new Resty().text(requestURL, form(data("region", regionName))).toString());
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
// public static URI bestServer(String regionName, int amount) {
// //for fun
// return IntStream.range(0,amount).parallel().mapToObj(a->getServer(regionName)).distinct().parallel().collect(Collectors.toMap(a -> a, LagScore::lagScore)).entrySet().stream().min((entry1, entry2) -> entry1.getValue() > entry2.getValue() ? 1 : -1).get().getKey();
// }
// }
| import me.pascoej.ajario.gui.ClientGUI;
import me.pascoej.ajario.util.ServerChooserUtil;
import org.newdawn.slick.CanvasGameContainer;
import javax.swing.*; | package me.pascoej.ajario;
/**
* Created by john on 6/14/15.
*/
class GuiClientMain {
public static void main(String[] args) {
try {
JFrame frame = new JFrame("Ajar - agar.io client by pascoej");
AgarClient session = new AgarClient();
session.connect(ServerChooserUtil.getServer("US-Fremont")); | // Path: src/main/java/me/pascoej/ajario/gui/ClientGUI.java
// public class ClientGUI extends BasicGame {
// private final AgarClient agarClient;
// private boolean showFPS = false;
// private boolean fullscreen = false;
// private final List<View> views = new CopyOnWriteArrayList<>();
// private GameContainer gameContainer;
//
// public ClientGUI(AgarClient agarClient) {
// super("Ajar Client");
// this.agarClient = agarClient;
// }
//
// @Override
// public void keyPressed(int key, char c) {
// if (key == Keyboard.KEY_BACKSLASH) {
// showFPS = !showFPS;
// } else if (key == Keyboard.KEY_9) {
// fullscreen = !fullscreen;
// } else if (key == Keyboard.KEY_ESCAPE) {
// System.exit(0);
// } else if ((key == Keyboard.KEY_GRAVE || key == 13) && !hasViewClass(ServerChooserView.class) && !hasViewClass(OptionsView.class)) {
// addView(new ServerChooserView(this));
// }
// if (key == Keyboard.KEY_M) {
// agarClient.serverResetPacket();
// }
// }
//
// @Override
// public void init(GameContainer gameContainer) throws SlickException {
// this.gameContainer = gameContainer;
// gameContainer.setVSync(true);
// addView(new GameView(agarClient));
// }
//
// private boolean hasViewClass(Class clazz) {
// for (View view : views) {
// if (view.getClass() == clazz) {
// return true;
// }
// }
// return false;
// }
//
// public void addView(View view) {
// views.add(view);
// gameContainer.getInput().addListener(view);
// }
//
// public GameView getGameView() {
// return (GameView) views.get(0);
// }
//
// public AgarClient getAgarClient() {
// return agarClient;
// }
//
// public void removeView(View view) {
// views.remove(view);
// gameContainer.getInput().removeListener(view);
// }
//
// int refresh = 0;
//
// @Override
// public void update(GameContainer gameContainer, int i) throws SlickException {
// if (gameContainer.isShowingFPS() != showFPS) {
// gameContainer.setShowFPS(showFPS);
// }
// if (gameContainer.isFullscreen() != fullscreen) {
// if (fullscreen) {
// if (gameContainer instanceof AppGameContainer) {
// AppGameContainer appGameContainer = (AppGameContainer) gameContainer;
// appGameContainer.setDisplayMode(1440, 900, true);
// init(gameContainer);
// }
// }
// }
// agarClient.update();
// }
//
//
// @Override
// public void render(GameContainer gameContainer, Graphics g) throws SlickException {
// if (showFPS) {
// g.setColor(Color.white);
// String text = "u/s: " + agarClient.getUpdatePerSecond();
// int textHeight = g.getFont().getHeight(text);
// int textWidth = g.getFont().getWidth(text);
// int textX = gameContainer.getWidth()-5-textWidth;
// int textY = gameContainer.getHeight()-5-textHeight;
// g.drawString(text,textX,textY);
// }
// views.stream().filter(View::shouldDraw).forEach(view -> view.render(gameContainer, g));
// }
// }
//
// Path: src/main/java/me/pascoej/ajario/util/ServerChooserUtil.java
// public class ServerChooserUtil {
// private static final String[] regions = {"US-Fremont", "US-Atlanta", "BR-Brazil", "EU-London", "RU-Russia", "JP-Tokyo", "CN-China", "SG-Singapore"};
// private static final String requestURL = "http://m.agar.io/";
//
// public static String[] getRegions() {
// return regions;
// }
//
// public static URI getServer(String regionName) {
// try {
// return URI.create("ws://" + new Resty().text(requestURL, form(data("region", regionName))).toString());
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
// public static URI bestServer(String regionName, int amount) {
// //for fun
// return IntStream.range(0,amount).parallel().mapToObj(a->getServer(regionName)).distinct().parallel().collect(Collectors.toMap(a -> a, LagScore::lagScore)).entrySet().stream().min((entry1, entry2) -> entry1.getValue() > entry2.getValue() ? 1 : -1).get().getKey();
// }
// }
// Path: src/main/java/me/pascoej/ajario/GuiClientMain.java
import me.pascoej.ajario.gui.ClientGUI;
import me.pascoej.ajario.util.ServerChooserUtil;
import org.newdawn.slick.CanvasGameContainer;
import javax.swing.*;
package me.pascoej.ajario;
/**
* Created by john on 6/14/15.
*/
class GuiClientMain {
public static void main(String[] args) {
try {
JFrame frame = new JFrame("Ajar - agar.io client by pascoej");
AgarClient session = new AgarClient();
session.connect(ServerChooserUtil.getServer("US-Fremont")); | ClientGUI clientGUI = new ClientGUI(session); |
pascoej/ajario | src/main/java/me/pascoej/ajario/packet/serverbound/Split.java | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
| import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer; | package me.pascoej.ajario.packet.serverbound;
/**
* Created by john on 6/14/15.
*/
public class Split extends ServerBoundPacket {
@Override
protected int size() {
return 1;
}
@Override
protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
return byteBuffer;
}
@Override | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
// Path: src/main/java/me/pascoej/ajario/packet/serverbound/Split.java
import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer;
package me.pascoej.ajario.packet.serverbound;
/**
* Created by john on 6/14/15.
*/
public class Split extends ServerBoundPacket {
@Override
protected int size() {
return 1;
}
@Override
protected ByteBuffer addPayload(ByteBuffer byteBuffer) {
return byteBuffer;
}
@Override | public PacketType getType() { |
pascoej/ajario | src/main/java/me/pascoej/ajario/packet/clientbound/ClearAllNodes.java | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
| import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer; | package me.pascoej.ajario.packet.clientbound;
/**
* Created by john on 6/14/15.
*/
public class ClearAllNodes extends ClientBoundPacket {
public ClearAllNodes(ByteBuffer byteBuffer) {
super(byteBuffer);
}
@Override | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/ClearAllNodes.java
import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer;
package me.pascoej.ajario.packet.clientbound;
/**
* Created by john on 6/14/15.
*/
public class ClearAllNodes extends ClientBoundPacket {
public ClearAllNodes(ByteBuffer byteBuffer) {
super(byteBuffer);
}
@Override | public PacketType getType() { |
pascoej/ajario | src/main/java/me/pascoej/ajario/protocol/Session.java | // Path: src/main/java/me/pascoej/ajario/packet/AgarPacket.java
// public interface AgarPacket {
// byte[] toBytes();
//
// PacketType getType();
//
// static AgarPacket parseByteBuffer(ByteBuffer byteBuffer) {
// if (byteBuffer.capacity() == 0) {
// return null;
// }
// PacketType.ClientBound packetType = PacketType.ClientBound.packetType(byteBuffer.get());
// if (packetType == null) {
// return null;
// }
// switch (packetType) {
// case UPDATE_NODES:
// return new UpdateNodes(byteBuffer);
// case UPDATE_POSITION_SIZE:
// return new UpdatePositionAndSize(byteBuffer);
// case CLEAR_ALL_NODES:
// return new ClearAllNodes(byteBuffer);
// case ADD_NODE:
// return new AddNode(byteBuffer);
// case UPDATE_LEADERBOARD:
// return new UpdateLeaderBoard(byteBuffer);
// case SET_BORDER:
// return new SetBorder(byteBuffer);
// }
// return null;
// }
// }
| import me.pascoej.ajario.packet.AgarPacket;
import java.net.URI;
import java.util.Set; | package me.pascoej.ajario.protocol;
/**
* Created by john on 6/14/15.
*/
public class Session {
private WebSocketHandler webSocketHandler;
private URI uri;
public Session(URI uri) {
this.uri = uri;
webSocketHandler = new WebSocketHandler(uri,this);
}
public void connect() {
Set<PacketListener> packetListenerList = webSocketHandler.getPacketListeners();
webSocketHandler = new WebSocketHandler(uri,this);
webSocketHandler.getPacketListeners().addAll(packetListenerList);
webSocketHandler.connect();
}
| // Path: src/main/java/me/pascoej/ajario/packet/AgarPacket.java
// public interface AgarPacket {
// byte[] toBytes();
//
// PacketType getType();
//
// static AgarPacket parseByteBuffer(ByteBuffer byteBuffer) {
// if (byteBuffer.capacity() == 0) {
// return null;
// }
// PacketType.ClientBound packetType = PacketType.ClientBound.packetType(byteBuffer.get());
// if (packetType == null) {
// return null;
// }
// switch (packetType) {
// case UPDATE_NODES:
// return new UpdateNodes(byteBuffer);
// case UPDATE_POSITION_SIZE:
// return new UpdatePositionAndSize(byteBuffer);
// case CLEAR_ALL_NODES:
// return new ClearAllNodes(byteBuffer);
// case ADD_NODE:
// return new AddNode(byteBuffer);
// case UPDATE_LEADERBOARD:
// return new UpdateLeaderBoard(byteBuffer);
// case SET_BORDER:
// return new SetBorder(byteBuffer);
// }
// return null;
// }
// }
// Path: src/main/java/me/pascoej/ajario/protocol/Session.java
import me.pascoej.ajario.packet.AgarPacket;
import java.net.URI;
import java.util.Set;
package me.pascoej.ajario.protocol;
/**
* Created by john on 6/14/15.
*/
public class Session {
private WebSocketHandler webSocketHandler;
private URI uri;
public Session(URI uri) {
this.uri = uri;
webSocketHandler = new WebSocketHandler(uri,this);
}
public void connect() {
Set<PacketListener> packetListenerList = webSocketHandler.getPacketListeners();
webSocketHandler = new WebSocketHandler(uri,this);
webSocketHandler.getPacketListeners().addAll(packetListenerList);
webSocketHandler.connect();
}
| public void sendPacket(AgarPacket agarPacket) { |
pascoej/ajario | src/main/java/me/pascoej/ajario/packet/clientbound/SetBorder.java | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
| import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer; | top = byteBuffer.getDouble();
}
public double getLeft() {
return left;
}
public double getBottom() {
return bottom;
}
public double getRight() {
return right;
}
public double getTop() {
return top;
}
@Override
public String toString() {
return "SetBorder{" +
"left=" + left +
", bottom=" + bottom +
", right=" + right +
", top=" + top +
"} " + super.toString();
}
@Override | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/SetBorder.java
import me.pascoej.ajario.packet.PacketType;
import java.nio.ByteBuffer;
top = byteBuffer.getDouble();
}
public double getLeft() {
return left;
}
public double getBottom() {
return bottom;
}
public double getRight() {
return right;
}
public double getTop() {
return top;
}
@Override
public String toString() {
return "SetBorder{" +
"left=" + left +
", bottom=" + bottom +
", right=" + right +
", top=" + top +
"} " + super.toString();
}
@Override | public PacketType getType() { |
pascoej/ajario | src/main/java/me/pascoej/ajario/packet/clientbound/UpdateLeaderBoard.java | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
//
// Path: src/main/java/me/pascoej/ajario/util/ByteUtil.java
// public class ByteUtil {
// public static String popString(ByteBuffer byteBuffer) {
// StringBuilder sb = new StringBuilder(byteBuffer.limit());
// while (true) {
// short num = byteBuffer.getShort();
// if (num == 0) {
// return sb.toString();
// }
// sb.append((char) num);
// }
// }
//
// public static String toBinaryString(byte in) {
// return String.format("%8s", Integer.toBinaryString(in & 0xFF)).replace(' ', '0');
// }
// }
| import me.pascoej.ajario.packet.PacketType;
import me.pascoej.ajario.util.ByteUtil;
import java.nio.ByteBuffer;
import java.util.Arrays; | package me.pascoej.ajario.packet.clientbound;
/**
* Created by john on 6/14/15.
*/
public class UpdateLeaderBoard extends ClientBoundPacket {
private final LeaderboardPosition[] leaderboardPositions;
public UpdateLeaderBoard(ByteBuffer byteBuffer) {
super(byteBuffer);
int numberOfNodes = byteBuffer.getInt();
leaderboardPositions = new LeaderboardPosition[numberOfNodes];
for (int i = 0; i < numberOfNodes; i++) {
int nodeId = byteBuffer.getInt(); | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
//
// Path: src/main/java/me/pascoej/ajario/util/ByteUtil.java
// public class ByteUtil {
// public static String popString(ByteBuffer byteBuffer) {
// StringBuilder sb = new StringBuilder(byteBuffer.limit());
// while (true) {
// short num = byteBuffer.getShort();
// if (num == 0) {
// return sb.toString();
// }
// sb.append((char) num);
// }
// }
//
// public static String toBinaryString(byte in) {
// return String.format("%8s", Integer.toBinaryString(in & 0xFF)).replace(' ', '0');
// }
// }
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/UpdateLeaderBoard.java
import me.pascoej.ajario.packet.PacketType;
import me.pascoej.ajario.util.ByteUtil;
import java.nio.ByteBuffer;
import java.util.Arrays;
package me.pascoej.ajario.packet.clientbound;
/**
* Created by john on 6/14/15.
*/
public class UpdateLeaderBoard extends ClientBoundPacket {
private final LeaderboardPosition[] leaderboardPositions;
public UpdateLeaderBoard(ByteBuffer byteBuffer) {
super(byteBuffer);
int numberOfNodes = byteBuffer.getInt();
leaderboardPositions = new LeaderboardPosition[numberOfNodes];
for (int i = 0; i < numberOfNodes; i++) {
int nodeId = byteBuffer.getInt(); | String name = ByteUtil.popString(byteBuffer); |
pascoej/ajario | src/main/java/me/pascoej/ajario/packet/clientbound/UpdateLeaderBoard.java | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
//
// Path: src/main/java/me/pascoej/ajario/util/ByteUtil.java
// public class ByteUtil {
// public static String popString(ByteBuffer byteBuffer) {
// StringBuilder sb = new StringBuilder(byteBuffer.limit());
// while (true) {
// short num = byteBuffer.getShort();
// if (num == 0) {
// return sb.toString();
// }
// sb.append((char) num);
// }
// }
//
// public static String toBinaryString(byte in) {
// return String.format("%8s", Integer.toBinaryString(in & 0xFF)).replace(' ', '0');
// }
// }
| import me.pascoej.ajario.packet.PacketType;
import me.pascoej.ajario.util.ByteUtil;
import java.nio.ByteBuffer;
import java.util.Arrays; | package me.pascoej.ajario.packet.clientbound;
/**
* Created by john on 6/14/15.
*/
public class UpdateLeaderBoard extends ClientBoundPacket {
private final LeaderboardPosition[] leaderboardPositions;
public UpdateLeaderBoard(ByteBuffer byteBuffer) {
super(byteBuffer);
int numberOfNodes = byteBuffer.getInt();
leaderboardPositions = new LeaderboardPosition[numberOfNodes];
for (int i = 0; i < numberOfNodes; i++) {
int nodeId = byteBuffer.getInt();
String name = ByteUtil.popString(byteBuffer);
leaderboardPositions[i] = new LeaderboardPosition(nodeId, name);
}
}
public LeaderboardPosition[] getLeaderboardPositions() {
return leaderboardPositions;
}
@Override | // Path: src/main/java/me/pascoej/ajario/packet/PacketType.java
// public interface PacketType {
// enum ServerBound implements PacketType {
// SET_NICKNAME(0), SPECTATE(1), MOUSE_MOVE(16), SPLIT(17), EJECT_MASS(21), RESET_CONNECTION(255);
// private final byte id;
//
// ServerBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ServerBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ServerBound> initPacketTypeById() {
// Map<Byte, ServerBound> map = new HashMap<>();
// for (ServerBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ServerBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
//
// enum ClientBound implements PacketType {
// UPDATE_NODES(16), UPDATE_POSITION_SIZE(17), CLEAR_ALL_NODES(20), ADD_NODE(32), UPDATE_LEADERBOARD(49),
// SET_BORDER(64);
// private final byte id;
//
// ClientBound(int id) {
// this.id = (byte) id;
// }
//
// public byte getId() {
// return id;
// }
//
// private static final Map<Byte, ClientBound> packetTypeById = Collections.unmodifiableMap(initPacketTypeById());
//
// private static Map<Byte, ClientBound> initPacketTypeById() {
// Map<Byte, ClientBound> map = new HashMap<>();
// for (ClientBound packetType : values()) {
// map.put(packetType.getId(), packetType);
// }
// return map;
// }
//
// public static ClientBound packetType(byte id) {
// return packetTypeById.get(id);
// }
// }
//
// byte getId();
// }
//
// Path: src/main/java/me/pascoej/ajario/util/ByteUtil.java
// public class ByteUtil {
// public static String popString(ByteBuffer byteBuffer) {
// StringBuilder sb = new StringBuilder(byteBuffer.limit());
// while (true) {
// short num = byteBuffer.getShort();
// if (num == 0) {
// return sb.toString();
// }
// sb.append((char) num);
// }
// }
//
// public static String toBinaryString(byte in) {
// return String.format("%8s", Integer.toBinaryString(in & 0xFF)).replace(' ', '0');
// }
// }
// Path: src/main/java/me/pascoej/ajario/packet/clientbound/UpdateLeaderBoard.java
import me.pascoej.ajario.packet.PacketType;
import me.pascoej.ajario.util.ByteUtil;
import java.nio.ByteBuffer;
import java.util.Arrays;
package me.pascoej.ajario.packet.clientbound;
/**
* Created by john on 6/14/15.
*/
public class UpdateLeaderBoard extends ClientBoundPacket {
private final LeaderboardPosition[] leaderboardPositions;
public UpdateLeaderBoard(ByteBuffer byteBuffer) {
super(byteBuffer);
int numberOfNodes = byteBuffer.getInt();
leaderboardPositions = new LeaderboardPosition[numberOfNodes];
for (int i = 0; i < numberOfNodes; i++) {
int nodeId = byteBuffer.getInt();
String name = ByteUtil.popString(byteBuffer);
leaderboardPositions[i] = new LeaderboardPosition(nodeId, name);
}
}
public LeaderboardPosition[] getLeaderboardPositions() {
return leaderboardPositions;
}
@Override | public PacketType getType() { |
abbashosseini/Vinci | app/src/main/java/com/example/abbas/myapplication/tab2.java | // Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Classes/Storage.java
// public class Storage {
//
// private final File filesDir;
// private final boolean isCreated;
// private final Loader loader;
// private final Logger logger = Logger.getLogger(getClass().getSimpleName());
// private final File fileImage;
//
// public Storage(Loader loader){
//
// this.loader = loader;
//
// this.loader.load(Loader.ImageUrl, loader);
//
// filesDir = LocalPath();
// if (filesDir.mkdirs())
// logger.info(String.format("%s path is created ", filesDir.getAbsolutePath()));
// else
// logger.info("faild to create the path");
//
//
// String filename = String.format("%d_%d.jpg", Loader.ImageUrl.length(), Loader.ImageUrl.hashCode());
// fileImage = new File(filesDir, filename);
//
// OutputStream os = null;
// try {
// os = new FileOutputStream(fileImage);
//
// } catch (Exception e) {
// Log.e(getClass().getSimpleName(), "Error writing bitmap", e);
//
// }
//
// //hold dawn to response if he created return true
// isCreated = loader.BitmapCompress.compress(Bitmap.CompressFormat.PNG, 100, os);
//
//
// }
//
// public File FileObject(){
// return fileImage;
// }
//
// public static File LocalPath(){
// return new File(android.os.Environment.getExternalStorageDirectory(), "Vinci/files");
// }
//
// public boolean remove(){
// return fileImage.exists() && fileImage.delete();
// }
//
// public boolean isCreated(){
// return isCreated;
// }
//
// public Bitmap getBitmap(){
// return loader.BitmapCompress;
// }
//
// public URI Path(){
// return URI.create(filesDir.getAbsolutePath());
// }
//
// public URI getfullPath(){
// return URI.create(filesDir.getAbsoluteFile().getAbsolutePath());
// }
//
// public void deleteAll(){
//
// File[] files = filesDir.listFiles();
//
// if(files == null)
// return;
//
// for(File f:files)
// if (f.delete())
// Log.i(getClass().getSimpleName(), String.format("file with %s name are deleted.", f.getName()));
// }
//
// }
//
// Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Vinci.java
// public class Vinci {
//
// protected static volatile Vinci Base_singleton;
// protected final Context ctxt;
//
// Vinci(Context context) {
// this.ctxt = context;
// }
//
// /**
// * create correct vinci object and make sure have one true instance
// *
// * @return Vinci object
// **/
// public static Vinci base(Context context) {
//
// if (Base_singleton == null) {
// synchronized (Vinci.class) {
// if (Base_singleton == null) {
// Base_singleton = new Vinci(context);
// }
// }
// }
// return Base_singleton;
// }
//
// /**
// * <p>
// * this method you can access it Builder pattern style
// * and you can access all emthods and api
// * </p>
// *
// * @author Abbas hosseini
// * @version 1.0
// * @since 2016-04-18
// * @return Loader object
// *
// **/
//
// public Loader process(){
// return new Loader(this.ctxt);
// }
//
//
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import java.util.List;
import mklib.hosseini.com.vinci.Classes.Storage;
import mklib.hosseini.com.vinci.Vinci; | package com.example.abbas.myapplication;
/**
* Created by abbas on 8/24/15.
*/
public class tab2 extends RecyclerView.Adapter<tab2.ViewHolder>{
private List<String> mItems;
protected Context context;
public tab2(List<String> items){
mItems = items;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup,int i){
View v = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.list_row_tabs2, viewGroup, false);
context = viewGroup.getContext();
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int i) {
final String uri = mItems.get(i);
| // Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Classes/Storage.java
// public class Storage {
//
// private final File filesDir;
// private final boolean isCreated;
// private final Loader loader;
// private final Logger logger = Logger.getLogger(getClass().getSimpleName());
// private final File fileImage;
//
// public Storage(Loader loader){
//
// this.loader = loader;
//
// this.loader.load(Loader.ImageUrl, loader);
//
// filesDir = LocalPath();
// if (filesDir.mkdirs())
// logger.info(String.format("%s path is created ", filesDir.getAbsolutePath()));
// else
// logger.info("faild to create the path");
//
//
// String filename = String.format("%d_%d.jpg", Loader.ImageUrl.length(), Loader.ImageUrl.hashCode());
// fileImage = new File(filesDir, filename);
//
// OutputStream os = null;
// try {
// os = new FileOutputStream(fileImage);
//
// } catch (Exception e) {
// Log.e(getClass().getSimpleName(), "Error writing bitmap", e);
//
// }
//
// //hold dawn to response if he created return true
// isCreated = loader.BitmapCompress.compress(Bitmap.CompressFormat.PNG, 100, os);
//
//
// }
//
// public File FileObject(){
// return fileImage;
// }
//
// public static File LocalPath(){
// return new File(android.os.Environment.getExternalStorageDirectory(), "Vinci/files");
// }
//
// public boolean remove(){
// return fileImage.exists() && fileImage.delete();
// }
//
// public boolean isCreated(){
// return isCreated;
// }
//
// public Bitmap getBitmap(){
// return loader.BitmapCompress;
// }
//
// public URI Path(){
// return URI.create(filesDir.getAbsolutePath());
// }
//
// public URI getfullPath(){
// return URI.create(filesDir.getAbsoluteFile().getAbsolutePath());
// }
//
// public void deleteAll(){
//
// File[] files = filesDir.listFiles();
//
// if(files == null)
// return;
//
// for(File f:files)
// if (f.delete())
// Log.i(getClass().getSimpleName(), String.format("file with %s name are deleted.", f.getName()));
// }
//
// }
//
// Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Vinci.java
// public class Vinci {
//
// protected static volatile Vinci Base_singleton;
// protected final Context ctxt;
//
// Vinci(Context context) {
// this.ctxt = context;
// }
//
// /**
// * create correct vinci object and make sure have one true instance
// *
// * @return Vinci object
// **/
// public static Vinci base(Context context) {
//
// if (Base_singleton == null) {
// synchronized (Vinci.class) {
// if (Base_singleton == null) {
// Base_singleton = new Vinci(context);
// }
// }
// }
// return Base_singleton;
// }
//
// /**
// * <p>
// * this method you can access it Builder pattern style
// * and you can access all emthods and api
// * </p>
// *
// * @author Abbas hosseini
// * @version 1.0
// * @since 2016-04-18
// * @return Loader object
// *
// **/
//
// public Loader process(){
// return new Loader(this.ctxt);
// }
//
//
// }
// Path: app/src/main/java/com/example/abbas/myapplication/tab2.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import java.util.List;
import mklib.hosseini.com.vinci.Classes.Storage;
import mklib.hosseini.com.vinci.Vinci;
package com.example.abbas.myapplication;
/**
* Created by abbas on 8/24/15.
*/
public class tab2 extends RecyclerView.Adapter<tab2.ViewHolder>{
private List<String> mItems;
protected Context context;
public tab2(List<String> items){
mItems = items;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup,int i){
View v = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.list_row_tabs2, viewGroup, false);
context = viewGroup.getContext();
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int i) {
final String uri = mItems.get(i);
| Vinci |
abbashosseini/Vinci | app/src/main/java/com/example/abbas/myapplication/tab2.java | // Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Classes/Storage.java
// public class Storage {
//
// private final File filesDir;
// private final boolean isCreated;
// private final Loader loader;
// private final Logger logger = Logger.getLogger(getClass().getSimpleName());
// private final File fileImage;
//
// public Storage(Loader loader){
//
// this.loader = loader;
//
// this.loader.load(Loader.ImageUrl, loader);
//
// filesDir = LocalPath();
// if (filesDir.mkdirs())
// logger.info(String.format("%s path is created ", filesDir.getAbsolutePath()));
// else
// logger.info("faild to create the path");
//
//
// String filename = String.format("%d_%d.jpg", Loader.ImageUrl.length(), Loader.ImageUrl.hashCode());
// fileImage = new File(filesDir, filename);
//
// OutputStream os = null;
// try {
// os = new FileOutputStream(fileImage);
//
// } catch (Exception e) {
// Log.e(getClass().getSimpleName(), "Error writing bitmap", e);
//
// }
//
// //hold dawn to response if he created return true
// isCreated = loader.BitmapCompress.compress(Bitmap.CompressFormat.PNG, 100, os);
//
//
// }
//
// public File FileObject(){
// return fileImage;
// }
//
// public static File LocalPath(){
// return new File(android.os.Environment.getExternalStorageDirectory(), "Vinci/files");
// }
//
// public boolean remove(){
// return fileImage.exists() && fileImage.delete();
// }
//
// public boolean isCreated(){
// return isCreated;
// }
//
// public Bitmap getBitmap(){
// return loader.BitmapCompress;
// }
//
// public URI Path(){
// return URI.create(filesDir.getAbsolutePath());
// }
//
// public URI getfullPath(){
// return URI.create(filesDir.getAbsoluteFile().getAbsolutePath());
// }
//
// public void deleteAll(){
//
// File[] files = filesDir.listFiles();
//
// if(files == null)
// return;
//
// for(File f:files)
// if (f.delete())
// Log.i(getClass().getSimpleName(), String.format("file with %s name are deleted.", f.getName()));
// }
//
// }
//
// Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Vinci.java
// public class Vinci {
//
// protected static volatile Vinci Base_singleton;
// protected final Context ctxt;
//
// Vinci(Context context) {
// this.ctxt = context;
// }
//
// /**
// * create correct vinci object and make sure have one true instance
// *
// * @return Vinci object
// **/
// public static Vinci base(Context context) {
//
// if (Base_singleton == null) {
// synchronized (Vinci.class) {
// if (Base_singleton == null) {
// Base_singleton = new Vinci(context);
// }
// }
// }
// return Base_singleton;
// }
//
// /**
// * <p>
// * this method you can access it Builder pattern style
// * and you can access all emthods and api
// * </p>
// *
// * @author Abbas hosseini
// * @version 1.0
// * @since 2016-04-18
// * @return Loader object
// *
// **/
//
// public Loader process(){
// return new Loader(this.ctxt);
// }
//
//
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import java.util.List;
import mklib.hosseini.com.vinci.Classes.Storage;
import mklib.hosseini.com.vinci.Vinci; | @Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup,int i){
View v = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.list_row_tabs2, viewGroup, false);
context = viewGroup.getContext();
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int i) {
final String uri = mItems.get(i);
Vinci
.base(context)
.process()
.load(uri)
.view(viewHolder.Writer);
viewHolder.remove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Vinci.base(context).process().load(uri).file().remove();
}
});
viewHolder.Save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
| // Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Classes/Storage.java
// public class Storage {
//
// private final File filesDir;
// private final boolean isCreated;
// private final Loader loader;
// private final Logger logger = Logger.getLogger(getClass().getSimpleName());
// private final File fileImage;
//
// public Storage(Loader loader){
//
// this.loader = loader;
//
// this.loader.load(Loader.ImageUrl, loader);
//
// filesDir = LocalPath();
// if (filesDir.mkdirs())
// logger.info(String.format("%s path is created ", filesDir.getAbsolutePath()));
// else
// logger.info("faild to create the path");
//
//
// String filename = String.format("%d_%d.jpg", Loader.ImageUrl.length(), Loader.ImageUrl.hashCode());
// fileImage = new File(filesDir, filename);
//
// OutputStream os = null;
// try {
// os = new FileOutputStream(fileImage);
//
// } catch (Exception e) {
// Log.e(getClass().getSimpleName(), "Error writing bitmap", e);
//
// }
//
// //hold dawn to response if he created return true
// isCreated = loader.BitmapCompress.compress(Bitmap.CompressFormat.PNG, 100, os);
//
//
// }
//
// public File FileObject(){
// return fileImage;
// }
//
// public static File LocalPath(){
// return new File(android.os.Environment.getExternalStorageDirectory(), "Vinci/files");
// }
//
// public boolean remove(){
// return fileImage.exists() && fileImage.delete();
// }
//
// public boolean isCreated(){
// return isCreated;
// }
//
// public Bitmap getBitmap(){
// return loader.BitmapCompress;
// }
//
// public URI Path(){
// return URI.create(filesDir.getAbsolutePath());
// }
//
// public URI getfullPath(){
// return URI.create(filesDir.getAbsoluteFile().getAbsolutePath());
// }
//
// public void deleteAll(){
//
// File[] files = filesDir.listFiles();
//
// if(files == null)
// return;
//
// for(File f:files)
// if (f.delete())
// Log.i(getClass().getSimpleName(), String.format("file with %s name are deleted.", f.getName()));
// }
//
// }
//
// Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Vinci.java
// public class Vinci {
//
// protected static volatile Vinci Base_singleton;
// protected final Context ctxt;
//
// Vinci(Context context) {
// this.ctxt = context;
// }
//
// /**
// * create correct vinci object and make sure have one true instance
// *
// * @return Vinci object
// **/
// public static Vinci base(Context context) {
//
// if (Base_singleton == null) {
// synchronized (Vinci.class) {
// if (Base_singleton == null) {
// Base_singleton = new Vinci(context);
// }
// }
// }
// return Base_singleton;
// }
//
// /**
// * <p>
// * this method you can access it Builder pattern style
// * and you can access all emthods and api
// * </p>
// *
// * @author Abbas hosseini
// * @version 1.0
// * @since 2016-04-18
// * @return Loader object
// *
// **/
//
// public Loader process(){
// return new Loader(this.ctxt);
// }
//
//
// }
// Path: app/src/main/java/com/example/abbas/myapplication/tab2.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import java.util.List;
import mklib.hosseini.com.vinci.Classes.Storage;
import mklib.hosseini.com.vinci.Vinci;
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup,int i){
View v = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.list_row_tabs2, viewGroup, false);
context = viewGroup.getContext();
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int i) {
final String uri = mItems.get(i);
Vinci
.base(context)
.process()
.load(uri)
.view(viewHolder.Writer);
viewHolder.remove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Vinci.base(context).process().load(uri).file().remove();
}
});
viewHolder.Save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
| Storage store = Vinci.base(context).process().load(uri).file(); |
abbashosseini/Vinci | Vinci/src/main/java/mklib/hosseini/com/vinci/Classes/ProducerConsumer/Consumer.java | // Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Classes/Request.java
// public interface Request {
//
// void onSuccess(Bitmap bitmap);
//
// void onFailure(Throwable e);
//
// }
| import android.graphics.Bitmap;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import mklib.hosseini.com.vinci.Classes.Request; | package mklib.hosseini.com.vinci.Classes.ProducerConsumer;
/**
* Created by abbas on 4/14/16.
*/
class Consumer implements Runnable {
final BlockingQueue<Bitmap> queue = new LinkedBlockingQueue<>(); | // Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Classes/Request.java
// public interface Request {
//
// void onSuccess(Bitmap bitmap);
//
// void onFailure(Throwable e);
//
// }
// Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Classes/ProducerConsumer/Consumer.java
import android.graphics.Bitmap;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import mklib.hosseini.com.vinci.Classes.Request;
package mklib.hosseini.com.vinci.Classes.ProducerConsumer;
/**
* Created by abbas on 4/14/16.
*/
class Consumer implements Runnable {
final BlockingQueue<Bitmap> queue = new LinkedBlockingQueue<>(); | final Request request; |
abbashosseini/Vinci | app/src/main/java/com/example/abbas/myapplication/tab1.java | // Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Classes/AsyncBitmap.java
// public interface AsyncBitmap<T> {
//
// void onFinish(T object);
// }
//
// Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Classes/Request.java
// public interface Request {
//
// void onSuccess(Bitmap bitmap);
//
// void onFailure(Throwable e);
//
// }
//
// Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Vinci.java
// public class Vinci {
//
// protected static volatile Vinci Base_singleton;
// protected final Context ctxt;
//
// Vinci(Context context) {
// this.ctxt = context;
// }
//
// /**
// * create correct vinci object and make sure have one true instance
// *
// * @return Vinci object
// **/
// public static Vinci base(Context context) {
//
// if (Base_singleton == null) {
// synchronized (Vinci.class) {
// if (Base_singleton == null) {
// Base_singleton = new Vinci(context);
// }
// }
// }
// return Base_singleton;
// }
//
// /**
// * <p>
// * this method you can access it Builder pattern style
// * and you can access all emthods and api
// * </p>
// *
// * @author Abbas hosseini
// * @version 1.0
// * @since 2016-04-18
// * @return Loader object
// *
// **/
//
// public Loader process(){
// return new Loader(this.ctxt);
// }
//
//
// }
| import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import java.io.File;
import java.util.List;
import mklib.hosseini.com.vinci.Classes.AsyncBitmap;
import mklib.hosseini.com.vinci.Classes.Request;
import mklib.hosseini.com.vinci.Vinci; | package com.example.abbas.myapplication;
/**
* Created by abbas on 8/24/15.
*/
public class tab1 extends RecyclerView.Adapter<tab1.ViewHolder> implements Request{
private List<File> mItems;
protected Context context;
public tab1(List<File> items){
mItems= items;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup,int i){
View v = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.list_row_readitem_tabs1, viewGroup, false);
context = viewGroup.getContext();
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int i) {
final File uri = mItems.get(i);
Log.e("file", String.valueOf(BitmapFactory.decodeFile(uri.getAbsolutePath()).getByteCount()));
// viewHolder.Writer.post(new Runnable() {
// @Override
// public void run() {
| // Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Classes/AsyncBitmap.java
// public interface AsyncBitmap<T> {
//
// void onFinish(T object);
// }
//
// Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Classes/Request.java
// public interface Request {
//
// void onSuccess(Bitmap bitmap);
//
// void onFailure(Throwable e);
//
// }
//
// Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Vinci.java
// public class Vinci {
//
// protected static volatile Vinci Base_singleton;
// protected final Context ctxt;
//
// Vinci(Context context) {
// this.ctxt = context;
// }
//
// /**
// * create correct vinci object and make sure have one true instance
// *
// * @return Vinci object
// **/
// public static Vinci base(Context context) {
//
// if (Base_singleton == null) {
// synchronized (Vinci.class) {
// if (Base_singleton == null) {
// Base_singleton = new Vinci(context);
// }
// }
// }
// return Base_singleton;
// }
//
// /**
// * <p>
// * this method you can access it Builder pattern style
// * and you can access all emthods and api
// * </p>
// *
// * @author Abbas hosseini
// * @version 1.0
// * @since 2016-04-18
// * @return Loader object
// *
// **/
//
// public Loader process(){
// return new Loader(this.ctxt);
// }
//
//
// }
// Path: app/src/main/java/com/example/abbas/myapplication/tab1.java
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import java.io.File;
import java.util.List;
import mklib.hosseini.com.vinci.Classes.AsyncBitmap;
import mklib.hosseini.com.vinci.Classes.Request;
import mklib.hosseini.com.vinci.Vinci;
package com.example.abbas.myapplication;
/**
* Created by abbas on 8/24/15.
*/
public class tab1 extends RecyclerView.Adapter<tab1.ViewHolder> implements Request{
private List<File> mItems;
protected Context context;
public tab1(List<File> items){
mItems= items;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup,int i){
View v = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.list_row_readitem_tabs1, viewGroup, false);
context = viewGroup.getContext();
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int i) {
final File uri = mItems.get(i);
Log.e("file", String.valueOf(BitmapFactory.decodeFile(uri.getAbsolutePath()).getByteCount()));
// viewHolder.Writer.post(new Runnable() {
// @Override
// public void run() {
| Vinci |
abbashosseini/Vinci | app/src/main/java/com/example/abbas/myapplication/tab1.java | // Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Classes/AsyncBitmap.java
// public interface AsyncBitmap<T> {
//
// void onFinish(T object);
// }
//
// Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Classes/Request.java
// public interface Request {
//
// void onSuccess(Bitmap bitmap);
//
// void onFailure(Throwable e);
//
// }
//
// Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Vinci.java
// public class Vinci {
//
// protected static volatile Vinci Base_singleton;
// protected final Context ctxt;
//
// Vinci(Context context) {
// this.ctxt = context;
// }
//
// /**
// * create correct vinci object and make sure have one true instance
// *
// * @return Vinci object
// **/
// public static Vinci base(Context context) {
//
// if (Base_singleton == null) {
// synchronized (Vinci.class) {
// if (Base_singleton == null) {
// Base_singleton = new Vinci(context);
// }
// }
// }
// return Base_singleton;
// }
//
// /**
// * <p>
// * this method you can access it Builder pattern style
// * and you can access all emthods and api
// * </p>
// *
// * @author Abbas hosseini
// * @version 1.0
// * @since 2016-04-18
// * @return Loader object
// *
// **/
//
// public Loader process(){
// return new Loader(this.ctxt);
// }
//
//
// }
| import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import java.io.File;
import java.util.List;
import mklib.hosseini.com.vinci.Classes.AsyncBitmap;
import mklib.hosseini.com.vinci.Classes.Request;
import mklib.hosseini.com.vinci.Vinci; | package com.example.abbas.myapplication;
/**
* Created by abbas on 8/24/15.
*/
public class tab1 extends RecyclerView.Adapter<tab1.ViewHolder> implements Request{
private List<File> mItems;
protected Context context;
public tab1(List<File> items){
mItems= items;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup,int i){
View v = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.list_row_readitem_tabs1, viewGroup, false);
context = viewGroup.getContext();
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int i) {
final File uri = mItems.get(i);
Log.e("file", String.valueOf(BitmapFactory.decodeFile(uri.getAbsolutePath()).getByteCount()));
// viewHolder.Writer.post(new Runnable() {
// @Override
// public void run() {
Vinci
.base(context)
.process() | // Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Classes/AsyncBitmap.java
// public interface AsyncBitmap<T> {
//
// void onFinish(T object);
// }
//
// Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Classes/Request.java
// public interface Request {
//
// void onSuccess(Bitmap bitmap);
//
// void onFailure(Throwable e);
//
// }
//
// Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Vinci.java
// public class Vinci {
//
// protected static volatile Vinci Base_singleton;
// protected final Context ctxt;
//
// Vinci(Context context) {
// this.ctxt = context;
// }
//
// /**
// * create correct vinci object and make sure have one true instance
// *
// * @return Vinci object
// **/
// public static Vinci base(Context context) {
//
// if (Base_singleton == null) {
// synchronized (Vinci.class) {
// if (Base_singleton == null) {
// Base_singleton = new Vinci(context);
// }
// }
// }
// return Base_singleton;
// }
//
// /**
// * <p>
// * this method you can access it Builder pattern style
// * and you can access all emthods and api
// * </p>
// *
// * @author Abbas hosseini
// * @version 1.0
// * @since 2016-04-18
// * @return Loader object
// *
// **/
//
// public Loader process(){
// return new Loader(this.ctxt);
// }
//
//
// }
// Path: app/src/main/java/com/example/abbas/myapplication/tab1.java
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import java.io.File;
import java.util.List;
import mklib.hosseini.com.vinci.Classes.AsyncBitmap;
import mklib.hosseini.com.vinci.Classes.Request;
import mklib.hosseini.com.vinci.Vinci;
package com.example.abbas.myapplication;
/**
* Created by abbas on 8/24/15.
*/
public class tab1 extends RecyclerView.Adapter<tab1.ViewHolder> implements Request{
private List<File> mItems;
protected Context context;
public tab1(List<File> items){
mItems= items;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup,int i){
View v = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.list_row_readitem_tabs1, viewGroup, false);
context = viewGroup.getContext();
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int i) {
final File uri = mItems.get(i);
Log.e("file", String.valueOf(BitmapFactory.decodeFile(uri.getAbsolutePath()).getByteCount()));
// viewHolder.Writer.post(new Runnable() {
// @Override
// public void run() {
Vinci
.base(context)
.process() | .decodeFile(uri, new AsyncBitmap<Bitmap>() { |
abbashosseini/Vinci | app/src/main/java/com/example/abbas/myapplication/FirstTab.java | // Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Vinci.java
// public class Vinci {
//
// protected static volatile Vinci Base_singleton;
// protected final Context ctxt;
//
// Vinci(Context context) {
// this.ctxt = context;
// }
//
// /**
// * create correct vinci object and make sure have one true instance
// *
// * @return Vinci object
// **/
// public static Vinci base(Context context) {
//
// if (Base_singleton == null) {
// synchronized (Vinci.class) {
// if (Base_singleton == null) {
// Base_singleton = new Vinci(context);
// }
// }
// }
// return Base_singleton;
// }
//
// /**
// * <p>
// * this method you can access it Builder pattern style
// * and you can access all emthods and api
// * </p>
// *
// * @author Abbas hosseini
// * @version 1.0
// * @since 2016-04-18
// * @return Loader object
// *
// **/
//
// public Loader process(){
// return new Loader(this.ctxt);
// }
//
//
// }
| import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import mklib.hosseini.com.vinci.Vinci; | package com.example.abbas.myapplication;
/**
* Created by abbas on 8/24/15.
*/
public class FirstTab extends android.support.v4.app.Fragment {
private static final String TAB_POSITION = "tab_position";
private static final String TITLE = "TITLE";
public static FirstTab newInstance(int tabPosition) {
FirstTab fragment = new FirstTab();
Bundle args = new Bundle();
args.putInt(TAB_POSITION, tabPosition);
fragment.setArguments(args);
return fragment;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View v = inflater.inflate(
R.layout.fragment_list_view, container, false);
final RecyclerView recyclerView =
(RecyclerView) v.findViewById(R.id.recyclerview);
// String[] urls = {
// "http://192.168.43.70/VinCi/Mona_Lisa1.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa2.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa3.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa4.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa5.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa6.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa7.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa8.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa9.jpg"
// };
// String[] urls2 = {
// "http://192.168.43.70/VinCi/Mona_Lisa1.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa2.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa3.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa4.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa5.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa6.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa7.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa8.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa9.jpg"
// };
| // Path: Vinci/src/main/java/mklib/hosseini/com/vinci/Vinci.java
// public class Vinci {
//
// protected static volatile Vinci Base_singleton;
// protected final Context ctxt;
//
// Vinci(Context context) {
// this.ctxt = context;
// }
//
// /**
// * create correct vinci object and make sure have one true instance
// *
// * @return Vinci object
// **/
// public static Vinci base(Context context) {
//
// if (Base_singleton == null) {
// synchronized (Vinci.class) {
// if (Base_singleton == null) {
// Base_singleton = new Vinci(context);
// }
// }
// }
// return Base_singleton;
// }
//
// /**
// * <p>
// * this method you can access it Builder pattern style
// * and you can access all emthods and api
// * </p>
// *
// * @author Abbas hosseini
// * @version 1.0
// * @since 2016-04-18
// * @return Loader object
// *
// **/
//
// public Loader process(){
// return new Loader(this.ctxt);
// }
//
//
// }
// Path: app/src/main/java/com/example/abbas/myapplication/FirstTab.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import mklib.hosseini.com.vinci.Vinci;
package com.example.abbas.myapplication;
/**
* Created by abbas on 8/24/15.
*/
public class FirstTab extends android.support.v4.app.Fragment {
private static final String TAB_POSITION = "tab_position";
private static final String TITLE = "TITLE";
public static FirstTab newInstance(int tabPosition) {
FirstTab fragment = new FirstTab();
Bundle args = new Bundle();
args.putInt(TAB_POSITION, tabPosition);
fragment.setArguments(args);
return fragment;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View v = inflater.inflate(
R.layout.fragment_list_view, container, false);
final RecyclerView recyclerView =
(RecyclerView) v.findViewById(R.id.recyclerview);
// String[] urls = {
// "http://192.168.43.70/VinCi/Mona_Lisa1.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa2.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa3.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa4.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa5.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa6.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa7.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa8.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa9.jpg"
// };
// String[] urls2 = {
// "http://192.168.43.70/VinCi/Mona_Lisa1.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa2.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa3.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa4.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa5.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa6.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa7.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa8.jpg",
// "http://192.168.43.70/VinCi/Mona_Lisa9.jpg"
// };
| List<File> files = Vinci.base(getContext()).process().files().list(); |
instaclick/PDI-Plugin-Step-AMQP | src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPluginDialog.java | // Path: src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPluginMeta.java
// public static class Binding
// {
// private final String target;
// private final String routing;
// private final String target_type;
//
// Binding(final String target, final String target_type, final String routing)
// {
// this.target = target;
// this.routing = routing;
// this.target_type = target_type;
// }
//
// public String getTarget()
// {
// return target;
// }
//
// public String getRouting()
// {
// return routing;
// }
// public String getTargetType()
// {
// return target_type;
// }
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/Messages.java
// public static String getString(String key)
// {
// return BaseMessages.getString(PKG, key);
// }
| import com.instaclick.pentaho.plugin.amqp.AMQPPluginMeta.Binding;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.widgets.Composite;
import org.pentaho.di.core.Props;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.MessageBox;
import org.pentaho.di.ui.core.widget.ColumnInfo;
import org.pentaho.di.ui.core.widget.TableView;
import org.pentaho.di.core.Const;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.BaseStepMeta;
import org.pentaho.di.trans.step.StepDialogInterface;
import org.pentaho.di.ui.trans.step.BaseStepDialog;
import org.pentaho.di.ui.core.widget.TextVar;
import static com.instaclick.pentaho.plugin.amqp.Messages.getString;
| }
private void setModeDependendFileds() {
if (AMQPPluginData.MODE_PRODUCER.equals(comboMode.getText())) {
enableProducerFields();
}
if (AMQPPluginData.MODE_CONSUMER.equals(comboMode.getText())) {
enableConsumerFields();
}
}
private void enableProducerFields()
{
textLimit.setVisible(false);
labelLimit.setVisible(false);
textPrefetchCount.setVisible(false);
labelPrefetchCount.setVisible(false);
textWaitTimeout.setVisible(false);
labelWaitTimeout.setVisible(false);
comboExchtype.setVisible(true);
labelExchtype.setVisible(true);
labelWaitingConsumer.setVisible(false);
checkWaitingConsumer.setVisible(false);
labelRequeue.setVisible(false);
checkRequeue.setVisible(false);
| // Path: src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPluginMeta.java
// public static class Binding
// {
// private final String target;
// private final String routing;
// private final String target_type;
//
// Binding(final String target, final String target_type, final String routing)
// {
// this.target = target;
// this.routing = routing;
// this.target_type = target_type;
// }
//
// public String getTarget()
// {
// return target;
// }
//
// public String getRouting()
// {
// return routing;
// }
// public String getTargetType()
// {
// return target_type;
// }
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/Messages.java
// public static String getString(String key)
// {
// return BaseMessages.getString(PKG, key);
// }
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPluginDialog.java
import com.instaclick.pentaho.plugin.amqp.AMQPPluginMeta.Binding;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.widgets.Composite;
import org.pentaho.di.core.Props;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.MessageBox;
import org.pentaho.di.ui.core.widget.ColumnInfo;
import org.pentaho.di.ui.core.widget.TableView;
import org.pentaho.di.core.Const;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.BaseStepMeta;
import org.pentaho.di.trans.step.StepDialogInterface;
import org.pentaho.di.ui.trans.step.BaseStepDialog;
import org.pentaho.di.ui.core.widget.TextVar;
import static com.instaclick.pentaho.plugin.amqp.Messages.getString;
}
private void setModeDependendFileds() {
if (AMQPPluginData.MODE_PRODUCER.equals(comboMode.getText())) {
enableProducerFields();
}
if (AMQPPluginData.MODE_CONSUMER.equals(comboMode.getText())) {
enableConsumerFields();
}
}
private void enableProducerFields()
{
textLimit.setVisible(false);
labelLimit.setVisible(false);
textPrefetchCount.setVisible(false);
labelPrefetchCount.setVisible(false);
textWaitTimeout.setVisible(false);
labelWaitTimeout.setVisible(false);
comboExchtype.setVisible(true);
labelExchtype.setVisible(true);
labelWaitingConsumer.setVisible(false);
checkWaitingConsumer.setVisible(false);
labelRequeue.setVisible(false);
checkRequeue.setVisible(false);
| labelTarget.setText(getString("AmqpPlugin.Exchange.Label"));
|
instaclick/PDI-Plugin-Step-AMQP | src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPluginDialog.java | // Path: src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPluginMeta.java
// public static class Binding
// {
// private final String target;
// private final String routing;
// private final String target_type;
//
// Binding(final String target, final String target_type, final String routing)
// {
// this.target = target;
// this.routing = routing;
// this.target_type = target_type;
// }
//
// public String getTarget()
// {
// return target;
// }
//
// public String getRouting()
// {
// return routing;
// }
// public String getTargetType()
// {
// return target_type;
// }
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/Messages.java
// public static String getString(String key)
// {
// return BaseMessages.getString(PKG, key);
// }
| import com.instaclick.pentaho.plugin.amqp.AMQPPluginMeta.Binding;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.widgets.Composite;
import org.pentaho.di.core.Props;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.MessageBox;
import org.pentaho.di.ui.core.widget.ColumnInfo;
import org.pentaho.di.ui.core.widget.TableView;
import org.pentaho.di.core.Const;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.BaseStepMeta;
import org.pentaho.di.trans.step.StepDialogInterface;
import org.pentaho.di.ui.trans.step.BaseStepDialog;
import org.pentaho.di.ui.core.widget.TextVar;
import static com.instaclick.pentaho.plugin.amqp.Messages.getString;
| if (AMQPPluginData.MODE_PRODUCER.equals(comboMode.getText())) {
enableProducerFields();
}
if (AMQPPluginData.MODE_CONSUMER.equals(comboMode.getText())) {
enableConsumerFields();
}
setFieldText(textURI, input.getUri());
setFieldText(textHost, input.getHost());
setFieldText(textPort, input.getPort());
setFieldText(textVhost, input.getVhost());
setFieldText(textTarget, input.getTarget());
setFieldText(textRouting, input.getRouting());
setFieldText(textLimit, input.getLimitString());
setFieldText(textUsername, input.getUsername());
setFieldText(textPassword, input.getPassword());
setFieldText(textBodyField, input.getBodyField());
setFieldText(textDeliveryTagField, input.getDeliveryTagField());
setFieldText(textAckStepName, input.getAckStepName());
setFieldText(textAckStepDeliveryTagField, input.getAckStepDeliveryTagField());
setFieldText(textRejectStepName, input.getRejectStepName());
setFieldText(textRejectStepDeliveryTagField, input.getRejectStepDeliveryTagField());
setFieldText(textPrefetchCount, input.getPrefetchCountString());
setFieldText(textWaitTimeout, input.getWaitTimeoutString());
for (int i = 0; i < input.getBindings().size(); i++) {
| // Path: src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPluginMeta.java
// public static class Binding
// {
// private final String target;
// private final String routing;
// private final String target_type;
//
// Binding(final String target, final String target_type, final String routing)
// {
// this.target = target;
// this.routing = routing;
// this.target_type = target_type;
// }
//
// public String getTarget()
// {
// return target;
// }
//
// public String getRouting()
// {
// return routing;
// }
// public String getTargetType()
// {
// return target_type;
// }
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/Messages.java
// public static String getString(String key)
// {
// return BaseMessages.getString(PKG, key);
// }
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPluginDialog.java
import com.instaclick.pentaho.plugin.amqp.AMQPPluginMeta.Binding;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.widgets.Composite;
import org.pentaho.di.core.Props;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.MessageBox;
import org.pentaho.di.ui.core.widget.ColumnInfo;
import org.pentaho.di.ui.core.widget.TableView;
import org.pentaho.di.core.Const;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.BaseStepMeta;
import org.pentaho.di.trans.step.StepDialogInterface;
import org.pentaho.di.ui.trans.step.BaseStepDialog;
import org.pentaho.di.ui.core.widget.TextVar;
import static com.instaclick.pentaho.plugin.amqp.Messages.getString;
if (AMQPPluginData.MODE_PRODUCER.equals(comboMode.getText())) {
enableProducerFields();
}
if (AMQPPluginData.MODE_CONSUMER.equals(comboMode.getText())) {
enableConsumerFields();
}
setFieldText(textURI, input.getUri());
setFieldText(textHost, input.getHost());
setFieldText(textPort, input.getPort());
setFieldText(textVhost, input.getVhost());
setFieldText(textTarget, input.getTarget());
setFieldText(textRouting, input.getRouting());
setFieldText(textLimit, input.getLimitString());
setFieldText(textUsername, input.getUsername());
setFieldText(textPassword, input.getPassword());
setFieldText(textBodyField, input.getBodyField());
setFieldText(textDeliveryTagField, input.getDeliveryTagField());
setFieldText(textAckStepName, input.getAckStepName());
setFieldText(textAckStepDeliveryTagField, input.getAckStepDeliveryTagField());
setFieldText(textRejectStepName, input.getRejectStepName());
setFieldText(textRejectStepDeliveryTagField, input.getRejectStepDeliveryTagField());
setFieldText(textPrefetchCount, input.getPrefetchCountString());
setFieldText(textWaitTimeout, input.getWaitTimeoutString());
for (int i = 0; i < input.getBindings().size(); i++) {
| final Binding binding = input.getBindings().get(i);
|
instaclick/PDI-Plugin-Step-AMQP | src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPluginMetaInjection.java | // Path: src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPluginMeta.java
// public static class Binding
// {
// private final String target;
// private final String routing;
// private final String target_type;
//
// Binding(final String target, final String target_type, final String routing)
// {
// this.target = target;
// this.routing = routing;
// this.target_type = target_type;
// }
//
// public String getTarget()
// {
// return target;
// }
//
// public String getRouting()
// {
// return routing;
// }
// public String getTargetType()
// {
// return target_type;
// }
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/Messages.java
// public static String getString(String key)
// {
// return BaseMessages.getString(PKG, key);
// }
| import com.instaclick.pentaho.plugin.amqp.AMQPPluginMeta.Binding;
import java.util.ArrayList;
import java.util.List;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.row.ValueMetaInterface;
import org.pentaho.di.trans.step.StepInjectionMetaEntry;
import org.pentaho.di.trans.step.StepInjectionUtil;
import org.pentaho.di.trans.step.StepMetaInjectionEntryInterface;
import org.pentaho.di.trans.step.StepMetaInjectionInterface;
import org.pentaho.di.core.Const;
import static com.instaclick.pentaho.plugin.amqp.Messages.getString; |
package com.instaclick.pentaho.plugin.amqp;
/**
* This takes care of the external metadata injection into the AMQPPluginMeta class
*
* @author Shvedchenko, Denys
*/
public class AMQPPluginMetaInjection implements StepMetaInjectionInterface {
public enum Entry implements StepMetaInjectionEntryInterface {
| // Path: src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPluginMeta.java
// public static class Binding
// {
// private final String target;
// private final String routing;
// private final String target_type;
//
// Binding(final String target, final String target_type, final String routing)
// {
// this.target = target;
// this.routing = routing;
// this.target_type = target_type;
// }
//
// public String getTarget()
// {
// return target;
// }
//
// public String getRouting()
// {
// return routing;
// }
// public String getTargetType()
// {
// return target_type;
// }
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/Messages.java
// public static String getString(String key)
// {
// return BaseMessages.getString(PKG, key);
// }
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPluginMetaInjection.java
import com.instaclick.pentaho.plugin.amqp.AMQPPluginMeta.Binding;
import java.util.ArrayList;
import java.util.List;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.row.ValueMetaInterface;
import org.pentaho.di.trans.step.StepInjectionMetaEntry;
import org.pentaho.di.trans.step.StepInjectionUtil;
import org.pentaho.di.trans.step.StepMetaInjectionEntryInterface;
import org.pentaho.di.trans.step.StepMetaInjectionInterface;
import org.pentaho.di.core.Const;
import static com.instaclick.pentaho.plugin.amqp.Messages.getString;
package com.instaclick.pentaho.plugin.amqp;
/**
* This takes care of the external metadata injection into the AMQPPluginMeta class
*
* @author Shvedchenko, Denys
*/
public class AMQPPluginMetaInjection implements StepMetaInjectionInterface {
public enum Entry implements StepMetaInjectionEntryInterface {
| AMQP_MODE( ValueMetaInterface.TYPE_STRING, getString("AmqpPlugin.Type.Label") ), |
instaclick/PDI-Plugin-Step-AMQP | src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPluginMetaInjection.java | // Path: src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPluginMeta.java
// public static class Binding
// {
// private final String target;
// private final String routing;
// private final String target_type;
//
// Binding(final String target, final String target_type, final String routing)
// {
// this.target = target;
// this.routing = routing;
// this.target_type = target_type;
// }
//
// public String getTarget()
// {
// return target;
// }
//
// public String getRouting()
// {
// return routing;
// }
// public String getTargetType()
// {
// return target_type;
// }
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/Messages.java
// public static String getString(String key)
// {
// return BaseMessages.getString(PKG, key);
// }
| import com.instaclick.pentaho.plugin.amqp.AMQPPluginMeta.Binding;
import java.util.ArrayList;
import java.util.List;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.row.ValueMetaInterface;
import org.pentaho.di.trans.step.StepInjectionMetaEntry;
import org.pentaho.di.trans.step.StepInjectionUtil;
import org.pentaho.di.trans.step.StepMetaInjectionEntryInterface;
import org.pentaho.di.trans.step.StepMetaInjectionInterface;
import org.pentaho.di.core.Const;
import static com.instaclick.pentaho.plugin.amqp.Messages.getString; | list.add( StepInjectionUtil.getEntry( Entry.DELIVERYTAG, meta.getDeliveryTagField() ) );
list.add( StepInjectionUtil.getEntry( Entry.TARGET, meta.getTarget() ) );
list.add( StepInjectionUtil.getEntry( Entry.ROUTING, meta.getRouting() ) );
list.add( StepInjectionUtil.getEntry( Entry.LIMIT, meta.getLimitString() ) );
list.add( StepInjectionUtil.getEntry( Entry.TRANSACTIONAL, meta.isTransactional() ) );
list.add( StepInjectionUtil.getEntry( Entry.AMQP_USERNAME, meta.getUsername() ) );
list.add( StepInjectionUtil.getEntry( Entry.AMQP_PASSWORD, meta.getPassword() ) );
list.add( StepInjectionUtil.getEntry( Entry.AMQP_HOST, meta.getHost() ) );
list.add( StepInjectionUtil.getEntry( Entry.AMQP_PORT, meta.getPort() ) );
list.add( StepInjectionUtil.getEntry( Entry.AMQP_VHOST, meta.getVhost() ) );
list.add( StepInjectionUtil.getEntry( Entry.DURABLE, meta.isDurable() ) );
list.add( StepInjectionUtil.getEntry( Entry.AUTODEL, meta.isAutodel() ) );
list.add( StepInjectionUtil.getEntry( Entry.REQUEUE, meta.isRequeue() ) );
list.add( StepInjectionUtil.getEntry( Entry.EXCHTYPE, meta.getExchtype() ) );
list.add( StepInjectionUtil.getEntry( Entry.EXCLUSIVE, meta.isExclusive() ) );
list.add( StepInjectionUtil.getEntry( Entry.WAITINGCONSUMER, meta.isWaitingConsumer() ) );
list.add( StepInjectionUtil.getEntry( Entry.WAITTIMEOUT, meta.getWaitTimeoutString() ) );
list.add( StepInjectionUtil.getEntry( Entry.PREFETCHCOUNT, meta.getPrefetchCountString() ) );
list.add( StepInjectionUtil.getEntry( Entry.DECLARE, meta.isDeclare() ) );
list.add( StepInjectionUtil.getEntry( Entry.ACKSTEPNAME, meta.getAckStepName() ) );
list.add( StepInjectionUtil.getEntry( Entry.ACKSTEPDELIVERYTAG, meta.getAckStepDeliveryTagField() ) );
list.add( StepInjectionUtil.getEntry( Entry.REJECTSTEPNAME, meta.getRejectStepName() ) );
list.add( StepInjectionUtil.getEntry( Entry.REJECTSTEPDELIVERYTAG, meta.getRejectStepDeliveryTagField() ) );
StepInjectionMetaEntry fieldsEntry = StepInjectionUtil.getEntry( Entry.BINDINGS );
list.add( fieldsEntry );
for ( int i = 0; i < meta.getBindings().size(); i++ ) {
StepInjectionMetaEntry fieldEntry = StepInjectionUtil.getEntry( Entry.BINDING_ROW );
List<StepInjectionMetaEntry> details = fieldEntry.getDetails(); | // Path: src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPluginMeta.java
// public static class Binding
// {
// private final String target;
// private final String routing;
// private final String target_type;
//
// Binding(final String target, final String target_type, final String routing)
// {
// this.target = target;
// this.routing = routing;
// this.target_type = target_type;
// }
//
// public String getTarget()
// {
// return target;
// }
//
// public String getRouting()
// {
// return routing;
// }
// public String getTargetType()
// {
// return target_type;
// }
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/Messages.java
// public static String getString(String key)
// {
// return BaseMessages.getString(PKG, key);
// }
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPluginMetaInjection.java
import com.instaclick.pentaho.plugin.amqp.AMQPPluginMeta.Binding;
import java.util.ArrayList;
import java.util.List;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.row.ValueMetaInterface;
import org.pentaho.di.trans.step.StepInjectionMetaEntry;
import org.pentaho.di.trans.step.StepInjectionUtil;
import org.pentaho.di.trans.step.StepMetaInjectionEntryInterface;
import org.pentaho.di.trans.step.StepMetaInjectionInterface;
import org.pentaho.di.core.Const;
import static com.instaclick.pentaho.plugin.amqp.Messages.getString;
list.add( StepInjectionUtil.getEntry( Entry.DELIVERYTAG, meta.getDeliveryTagField() ) );
list.add( StepInjectionUtil.getEntry( Entry.TARGET, meta.getTarget() ) );
list.add( StepInjectionUtil.getEntry( Entry.ROUTING, meta.getRouting() ) );
list.add( StepInjectionUtil.getEntry( Entry.LIMIT, meta.getLimitString() ) );
list.add( StepInjectionUtil.getEntry( Entry.TRANSACTIONAL, meta.isTransactional() ) );
list.add( StepInjectionUtil.getEntry( Entry.AMQP_USERNAME, meta.getUsername() ) );
list.add( StepInjectionUtil.getEntry( Entry.AMQP_PASSWORD, meta.getPassword() ) );
list.add( StepInjectionUtil.getEntry( Entry.AMQP_HOST, meta.getHost() ) );
list.add( StepInjectionUtil.getEntry( Entry.AMQP_PORT, meta.getPort() ) );
list.add( StepInjectionUtil.getEntry( Entry.AMQP_VHOST, meta.getVhost() ) );
list.add( StepInjectionUtil.getEntry( Entry.DURABLE, meta.isDurable() ) );
list.add( StepInjectionUtil.getEntry( Entry.AUTODEL, meta.isAutodel() ) );
list.add( StepInjectionUtil.getEntry( Entry.REQUEUE, meta.isRequeue() ) );
list.add( StepInjectionUtil.getEntry( Entry.EXCHTYPE, meta.getExchtype() ) );
list.add( StepInjectionUtil.getEntry( Entry.EXCLUSIVE, meta.isExclusive() ) );
list.add( StepInjectionUtil.getEntry( Entry.WAITINGCONSUMER, meta.isWaitingConsumer() ) );
list.add( StepInjectionUtil.getEntry( Entry.WAITTIMEOUT, meta.getWaitTimeoutString() ) );
list.add( StepInjectionUtil.getEntry( Entry.PREFETCHCOUNT, meta.getPrefetchCountString() ) );
list.add( StepInjectionUtil.getEntry( Entry.DECLARE, meta.isDeclare() ) );
list.add( StepInjectionUtil.getEntry( Entry.ACKSTEPNAME, meta.getAckStepName() ) );
list.add( StepInjectionUtil.getEntry( Entry.ACKSTEPDELIVERYTAG, meta.getAckStepDeliveryTagField() ) );
list.add( StepInjectionUtil.getEntry( Entry.REJECTSTEPNAME, meta.getRejectStepName() ) );
list.add( StepInjectionUtil.getEntry( Entry.REJECTSTEPDELIVERYTAG, meta.getRejectStepDeliveryTagField() ) );
StepInjectionMetaEntry fieldsEntry = StepInjectionUtil.getEntry( Entry.BINDINGS );
list.add( fieldsEntry );
for ( int i = 0; i < meta.getBindings().size(); i++ ) {
StepInjectionMetaEntry fieldEntry = StepInjectionUtil.getEntry( Entry.BINDING_ROW );
List<StepInjectionMetaEntry> details = fieldEntry.getDetails(); | final Binding binding = meta.getBindings().get(i); |
instaclick/PDI-Plugin-Step-AMQP | src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPlugin.java | // Path: src/main/java/com/instaclick/pentaho/plugin/amqp/Messages.java
// public static String getString(String key)
// {
// return BaseMessages.getString(PKG, key);
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/processor/Processor.java
// public interface Processor
// {
// public boolean process(final Object[] r) throws KettleStepException, IOException;
// public void start() throws KettleStepException, IOException;
// public void shutdown() throws KettleStepException, IOException;
// public void onSuccess() throws KettleStepException, IOException;
// public void onFailure() throws KettleStepException, IOException;
// public void cancel() throws KettleStepException, IOException;
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/processor/ProcessorFactory.java
// public class ProcessorFactory
// {
// private final ConnectionFactory factory = new ConnectionFactory();
//
// protected Connection connectionFor(final AMQPPluginData data) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// if ( ! Const.isEmpty(data.uri)) {
// factory.setUri(data.uri);
//
// return factory.newConnection();
// }
//
// factory.setHost(data.host);
// factory.setPort(data.port);
// factory.setUsername(data.username);
// factory.setPassword(data.password);
//
// if (data.vhost != null) {
// factory.setVirtualHost(data.vhost);
// }
//
// if (data.useSsl) {
// factory.useSslProtocol();
// }
//
// return factory.newConnection();
// }
//
// protected Channel channelFor(final AMQPPluginData data) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// final Connection conn = connectionFor(data);
// final Channel channel = conn.createChannel();
// final int qos = data.isConsumer ? data.prefetchCount : 0;
//
// channel.basicQos(qos);
//
// if ( ! conn.isOpen()) {
// throw new AMQPException("Unable to open a AMQP connection");
// }
//
// if ( ! channel.isOpen()) {
// throw new AMQPException("Unable to open an AMQP channel");
// }
//
// return channel;
// }
//
// public Processor processorFor(final AMQPPlugin step,final AMQPPluginData data, final AMQPPluginMeta meta) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// final Channel channel = channelFor(data);
// final List<Initializer> initializers = new ArrayList<Initializer>();
//
// if (data.activeConfirmation) {
// initializers.add(ActiveConvirmationInitializer.INSTANCE);
// }
//
// if (data.isConsumer && data.isDeclare) {
// initializers.add(ConsumerDeclareInitializer.INSTANCE);
// }
//
// if (data.isProducer && data.isDeclare) {
// initializers.add(ProducerDeclareInitializer.INSTANCE);
// }
//
// if (data.isConsumer && data.isWaitingConsumer) {
// return new WaitingConsumerProcessor(channel, step, data, initializers);
// }
//
// if (data.isConsumer) {
// return new BasicConsumerProcessor(channel, step, data, initializers);
// }
//
// if (data.isProducer) {
// return new ProducerProcessor(channel, step, data, initializers);
// }
//
// throw new RuntimeException("Unknown mode");
// }
// }
| import java.io.IOException;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.exception.KettleStepException;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.BaseStep;
import org.pentaho.di.trans.step.StepDataInterface;
import org.pentaho.di.trans.step.StepInterface;
import org.pentaho.di.trans.step.StepMeta;
import org.pentaho.di.trans.step.StepMetaInterface;
import static com.instaclick.pentaho.plugin.amqp.Messages.getString;
import com.instaclick.pentaho.plugin.amqp.processor.Processor;
import com.instaclick.pentaho.plugin.amqp.processor.ProcessorFactory;
import static org.pentaho.di.core.encryption.KettleTwoWayPasswordEncoder.decryptPasswordOptionallyEncrypted;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.row.RowMeta;
import org.pentaho.di.trans.TransListener;
import org.pentaho.di.core.row.RowMetaInterface;
| package com.instaclick.pentaho.plugin.amqp;
public class AMQPPlugin extends BaseStep implements StepInterface
{
private AMQPPluginData data;
private AMQPPluginMeta meta;
| // Path: src/main/java/com/instaclick/pentaho/plugin/amqp/Messages.java
// public static String getString(String key)
// {
// return BaseMessages.getString(PKG, key);
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/processor/Processor.java
// public interface Processor
// {
// public boolean process(final Object[] r) throws KettleStepException, IOException;
// public void start() throws KettleStepException, IOException;
// public void shutdown() throws KettleStepException, IOException;
// public void onSuccess() throws KettleStepException, IOException;
// public void onFailure() throws KettleStepException, IOException;
// public void cancel() throws KettleStepException, IOException;
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/processor/ProcessorFactory.java
// public class ProcessorFactory
// {
// private final ConnectionFactory factory = new ConnectionFactory();
//
// protected Connection connectionFor(final AMQPPluginData data) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// if ( ! Const.isEmpty(data.uri)) {
// factory.setUri(data.uri);
//
// return factory.newConnection();
// }
//
// factory.setHost(data.host);
// factory.setPort(data.port);
// factory.setUsername(data.username);
// factory.setPassword(data.password);
//
// if (data.vhost != null) {
// factory.setVirtualHost(data.vhost);
// }
//
// if (data.useSsl) {
// factory.useSslProtocol();
// }
//
// return factory.newConnection();
// }
//
// protected Channel channelFor(final AMQPPluginData data) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// final Connection conn = connectionFor(data);
// final Channel channel = conn.createChannel();
// final int qos = data.isConsumer ? data.prefetchCount : 0;
//
// channel.basicQos(qos);
//
// if ( ! conn.isOpen()) {
// throw new AMQPException("Unable to open a AMQP connection");
// }
//
// if ( ! channel.isOpen()) {
// throw new AMQPException("Unable to open an AMQP channel");
// }
//
// return channel;
// }
//
// public Processor processorFor(final AMQPPlugin step,final AMQPPluginData data, final AMQPPluginMeta meta) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// final Channel channel = channelFor(data);
// final List<Initializer> initializers = new ArrayList<Initializer>();
//
// if (data.activeConfirmation) {
// initializers.add(ActiveConvirmationInitializer.INSTANCE);
// }
//
// if (data.isConsumer && data.isDeclare) {
// initializers.add(ConsumerDeclareInitializer.INSTANCE);
// }
//
// if (data.isProducer && data.isDeclare) {
// initializers.add(ProducerDeclareInitializer.INSTANCE);
// }
//
// if (data.isConsumer && data.isWaitingConsumer) {
// return new WaitingConsumerProcessor(channel, step, data, initializers);
// }
//
// if (data.isConsumer) {
// return new BasicConsumerProcessor(channel, step, data, initializers);
// }
//
// if (data.isProducer) {
// return new ProducerProcessor(channel, step, data, initializers);
// }
//
// throw new RuntimeException("Unknown mode");
// }
// }
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPlugin.java
import java.io.IOException;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.exception.KettleStepException;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.BaseStep;
import org.pentaho.di.trans.step.StepDataInterface;
import org.pentaho.di.trans.step.StepInterface;
import org.pentaho.di.trans.step.StepMeta;
import org.pentaho.di.trans.step.StepMetaInterface;
import static com.instaclick.pentaho.plugin.amqp.Messages.getString;
import com.instaclick.pentaho.plugin.amqp.processor.Processor;
import com.instaclick.pentaho.plugin.amqp.processor.ProcessorFactory;
import static org.pentaho.di.core.encryption.KettleTwoWayPasswordEncoder.decryptPasswordOptionallyEncrypted;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.row.RowMeta;
import org.pentaho.di.trans.TransListener;
import org.pentaho.di.core.row.RowMetaInterface;
package com.instaclick.pentaho.plugin.amqp;
public class AMQPPlugin extends BaseStep implements StepInterface
{
private AMQPPluginData data;
private AMQPPluginMeta meta;
| final private ProcessorFactory factory = new ProcessorFactory();
|
instaclick/PDI-Plugin-Step-AMQP | src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPlugin.java | // Path: src/main/java/com/instaclick/pentaho/plugin/amqp/Messages.java
// public static String getString(String key)
// {
// return BaseMessages.getString(PKG, key);
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/processor/Processor.java
// public interface Processor
// {
// public boolean process(final Object[] r) throws KettleStepException, IOException;
// public void start() throws KettleStepException, IOException;
// public void shutdown() throws KettleStepException, IOException;
// public void onSuccess() throws KettleStepException, IOException;
// public void onFailure() throws KettleStepException, IOException;
// public void cancel() throws KettleStepException, IOException;
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/processor/ProcessorFactory.java
// public class ProcessorFactory
// {
// private final ConnectionFactory factory = new ConnectionFactory();
//
// protected Connection connectionFor(final AMQPPluginData data) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// if ( ! Const.isEmpty(data.uri)) {
// factory.setUri(data.uri);
//
// return factory.newConnection();
// }
//
// factory.setHost(data.host);
// factory.setPort(data.port);
// factory.setUsername(data.username);
// factory.setPassword(data.password);
//
// if (data.vhost != null) {
// factory.setVirtualHost(data.vhost);
// }
//
// if (data.useSsl) {
// factory.useSslProtocol();
// }
//
// return factory.newConnection();
// }
//
// protected Channel channelFor(final AMQPPluginData data) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// final Connection conn = connectionFor(data);
// final Channel channel = conn.createChannel();
// final int qos = data.isConsumer ? data.prefetchCount : 0;
//
// channel.basicQos(qos);
//
// if ( ! conn.isOpen()) {
// throw new AMQPException("Unable to open a AMQP connection");
// }
//
// if ( ! channel.isOpen()) {
// throw new AMQPException("Unable to open an AMQP channel");
// }
//
// return channel;
// }
//
// public Processor processorFor(final AMQPPlugin step,final AMQPPluginData data, final AMQPPluginMeta meta) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// final Channel channel = channelFor(data);
// final List<Initializer> initializers = new ArrayList<Initializer>();
//
// if (data.activeConfirmation) {
// initializers.add(ActiveConvirmationInitializer.INSTANCE);
// }
//
// if (data.isConsumer && data.isDeclare) {
// initializers.add(ConsumerDeclareInitializer.INSTANCE);
// }
//
// if (data.isProducer && data.isDeclare) {
// initializers.add(ProducerDeclareInitializer.INSTANCE);
// }
//
// if (data.isConsumer && data.isWaitingConsumer) {
// return new WaitingConsumerProcessor(channel, step, data, initializers);
// }
//
// if (data.isConsumer) {
// return new BasicConsumerProcessor(channel, step, data, initializers);
// }
//
// if (data.isProducer) {
// return new ProducerProcessor(channel, step, data, initializers);
// }
//
// throw new RuntimeException("Unknown mode");
// }
// }
| import java.io.IOException;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.exception.KettleStepException;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.BaseStep;
import org.pentaho.di.trans.step.StepDataInterface;
import org.pentaho.di.trans.step.StepInterface;
import org.pentaho.di.trans.step.StepMeta;
import org.pentaho.di.trans.step.StepMetaInterface;
import static com.instaclick.pentaho.plugin.amqp.Messages.getString;
import com.instaclick.pentaho.plugin.amqp.processor.Processor;
import com.instaclick.pentaho.plugin.amqp.processor.ProcessorFactory;
import static org.pentaho.di.core.encryption.KettleTwoWayPasswordEncoder.decryptPasswordOptionallyEncrypted;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.row.RowMeta;
import org.pentaho.di.trans.TransListener;
import org.pentaho.di.core.row.RowMetaInterface;
| package com.instaclick.pentaho.plugin.amqp;
public class AMQPPlugin extends BaseStep implements StepInterface
{
private AMQPPluginData data;
private AMQPPluginMeta meta;
final private ProcessorFactory factory = new ProcessorFactory();
| // Path: src/main/java/com/instaclick/pentaho/plugin/amqp/Messages.java
// public static String getString(String key)
// {
// return BaseMessages.getString(PKG, key);
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/processor/Processor.java
// public interface Processor
// {
// public boolean process(final Object[] r) throws KettleStepException, IOException;
// public void start() throws KettleStepException, IOException;
// public void shutdown() throws KettleStepException, IOException;
// public void onSuccess() throws KettleStepException, IOException;
// public void onFailure() throws KettleStepException, IOException;
// public void cancel() throws KettleStepException, IOException;
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/processor/ProcessorFactory.java
// public class ProcessorFactory
// {
// private final ConnectionFactory factory = new ConnectionFactory();
//
// protected Connection connectionFor(final AMQPPluginData data) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// if ( ! Const.isEmpty(data.uri)) {
// factory.setUri(data.uri);
//
// return factory.newConnection();
// }
//
// factory.setHost(data.host);
// factory.setPort(data.port);
// factory.setUsername(data.username);
// factory.setPassword(data.password);
//
// if (data.vhost != null) {
// factory.setVirtualHost(data.vhost);
// }
//
// if (data.useSsl) {
// factory.useSslProtocol();
// }
//
// return factory.newConnection();
// }
//
// protected Channel channelFor(final AMQPPluginData data) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// final Connection conn = connectionFor(data);
// final Channel channel = conn.createChannel();
// final int qos = data.isConsumer ? data.prefetchCount : 0;
//
// channel.basicQos(qos);
//
// if ( ! conn.isOpen()) {
// throw new AMQPException("Unable to open a AMQP connection");
// }
//
// if ( ! channel.isOpen()) {
// throw new AMQPException("Unable to open an AMQP channel");
// }
//
// return channel;
// }
//
// public Processor processorFor(final AMQPPlugin step,final AMQPPluginData data, final AMQPPluginMeta meta) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// final Channel channel = channelFor(data);
// final List<Initializer> initializers = new ArrayList<Initializer>();
//
// if (data.activeConfirmation) {
// initializers.add(ActiveConvirmationInitializer.INSTANCE);
// }
//
// if (data.isConsumer && data.isDeclare) {
// initializers.add(ConsumerDeclareInitializer.INSTANCE);
// }
//
// if (data.isProducer && data.isDeclare) {
// initializers.add(ProducerDeclareInitializer.INSTANCE);
// }
//
// if (data.isConsumer && data.isWaitingConsumer) {
// return new WaitingConsumerProcessor(channel, step, data, initializers);
// }
//
// if (data.isConsumer) {
// return new BasicConsumerProcessor(channel, step, data, initializers);
// }
//
// if (data.isProducer) {
// return new ProducerProcessor(channel, step, data, initializers);
// }
//
// throw new RuntimeException("Unknown mode");
// }
// }
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPlugin.java
import java.io.IOException;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.exception.KettleStepException;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.BaseStep;
import org.pentaho.di.trans.step.StepDataInterface;
import org.pentaho.di.trans.step.StepInterface;
import org.pentaho.di.trans.step.StepMeta;
import org.pentaho.di.trans.step.StepMetaInterface;
import static com.instaclick.pentaho.plugin.amqp.Messages.getString;
import com.instaclick.pentaho.plugin.amqp.processor.Processor;
import com.instaclick.pentaho.plugin.amqp.processor.ProcessorFactory;
import static org.pentaho.di.core.encryption.KettleTwoWayPasswordEncoder.decryptPasswordOptionallyEncrypted;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.row.RowMeta;
import org.pentaho.di.trans.TransListener;
import org.pentaho.di.core.row.RowMetaInterface;
package com.instaclick.pentaho.plugin.amqp;
public class AMQPPlugin extends BaseStep implements StepInterface
{
private AMQPPluginData data;
private AMQPPluginMeta meta;
final private ProcessorFactory factory = new ProcessorFactory();
| private Processor processor;
|
instaclick/PDI-Plugin-Step-AMQP | src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPlugin.java | // Path: src/main/java/com/instaclick/pentaho/plugin/amqp/Messages.java
// public static String getString(String key)
// {
// return BaseMessages.getString(PKG, key);
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/processor/Processor.java
// public interface Processor
// {
// public boolean process(final Object[] r) throws KettleStepException, IOException;
// public void start() throws KettleStepException, IOException;
// public void shutdown() throws KettleStepException, IOException;
// public void onSuccess() throws KettleStepException, IOException;
// public void onFailure() throws KettleStepException, IOException;
// public void cancel() throws KettleStepException, IOException;
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/processor/ProcessorFactory.java
// public class ProcessorFactory
// {
// private final ConnectionFactory factory = new ConnectionFactory();
//
// protected Connection connectionFor(final AMQPPluginData data) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// if ( ! Const.isEmpty(data.uri)) {
// factory.setUri(data.uri);
//
// return factory.newConnection();
// }
//
// factory.setHost(data.host);
// factory.setPort(data.port);
// factory.setUsername(data.username);
// factory.setPassword(data.password);
//
// if (data.vhost != null) {
// factory.setVirtualHost(data.vhost);
// }
//
// if (data.useSsl) {
// factory.useSslProtocol();
// }
//
// return factory.newConnection();
// }
//
// protected Channel channelFor(final AMQPPluginData data) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// final Connection conn = connectionFor(data);
// final Channel channel = conn.createChannel();
// final int qos = data.isConsumer ? data.prefetchCount : 0;
//
// channel.basicQos(qos);
//
// if ( ! conn.isOpen()) {
// throw new AMQPException("Unable to open a AMQP connection");
// }
//
// if ( ! channel.isOpen()) {
// throw new AMQPException("Unable to open an AMQP channel");
// }
//
// return channel;
// }
//
// public Processor processorFor(final AMQPPlugin step,final AMQPPluginData data, final AMQPPluginMeta meta) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// final Channel channel = channelFor(data);
// final List<Initializer> initializers = new ArrayList<Initializer>();
//
// if (data.activeConfirmation) {
// initializers.add(ActiveConvirmationInitializer.INSTANCE);
// }
//
// if (data.isConsumer && data.isDeclare) {
// initializers.add(ConsumerDeclareInitializer.INSTANCE);
// }
//
// if (data.isProducer && data.isDeclare) {
// initializers.add(ProducerDeclareInitializer.INSTANCE);
// }
//
// if (data.isConsumer && data.isWaitingConsumer) {
// return new WaitingConsumerProcessor(channel, step, data, initializers);
// }
//
// if (data.isConsumer) {
// return new BasicConsumerProcessor(channel, step, data, initializers);
// }
//
// if (data.isProducer) {
// return new ProducerProcessor(channel, step, data, initializers);
// }
//
// throw new RuntimeException("Unknown mode");
// }
// }
| import java.io.IOException;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.exception.KettleStepException;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.BaseStep;
import org.pentaho.di.trans.step.StepDataInterface;
import org.pentaho.di.trans.step.StepInterface;
import org.pentaho.di.trans.step.StepMeta;
import org.pentaho.di.trans.step.StepMetaInterface;
import static com.instaclick.pentaho.plugin.amqp.Messages.getString;
import com.instaclick.pentaho.plugin.amqp.processor.Processor;
import com.instaclick.pentaho.plugin.amqp.processor.ProcessorFactory;
import static org.pentaho.di.core.encryption.KettleTwoWayPasswordEncoder.decryptPasswordOptionallyEncrypted;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.row.RowMeta;
import org.pentaho.di.trans.TransListener;
import org.pentaho.di.core.row.RowMetaInterface;
| data.exchtype = meta.getExchtype();
data.isAutodel = meta.isAutodel();
data.isDurable = meta.isDurable();
data.isDeclare = meta.isDeclare();
data.isExclusive = meta.isExclusive();
if ( ! Const.isEmpty(routing)) {
data.routingIndex = data.outputRowMeta.indexOfValue(routing);
if (data.routingIndex < 0) {
throw new AMQPException("Unable to retrieve routing key field : " + meta.getRouting());
}
}
if ( ! Const.isEmpty(deliveryTagField)) {
data.deliveryTagIndex = data.outputRowMeta.indexOfValue(deliveryTagField);
if (data.deliveryTagIndex < 0) {
throw new AMQPException("Unable to retrieve DeliveryTag field : " + deliveryTagField);
}
}
if (data.bodyFieldIndex < 0) {
throw new AMQPException("Unable to retrieve body field : " + body);
}
if (data.target == null) {
throw new AMQPException("Unable to retrieve queue/exchange name");
}
| // Path: src/main/java/com/instaclick/pentaho/plugin/amqp/Messages.java
// public static String getString(String key)
// {
// return BaseMessages.getString(PKG, key);
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/processor/Processor.java
// public interface Processor
// {
// public boolean process(final Object[] r) throws KettleStepException, IOException;
// public void start() throws KettleStepException, IOException;
// public void shutdown() throws KettleStepException, IOException;
// public void onSuccess() throws KettleStepException, IOException;
// public void onFailure() throws KettleStepException, IOException;
// public void cancel() throws KettleStepException, IOException;
// }
//
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/processor/ProcessorFactory.java
// public class ProcessorFactory
// {
// private final ConnectionFactory factory = new ConnectionFactory();
//
// protected Connection connectionFor(final AMQPPluginData data) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// if ( ! Const.isEmpty(data.uri)) {
// factory.setUri(data.uri);
//
// return factory.newConnection();
// }
//
// factory.setHost(data.host);
// factory.setPort(data.port);
// factory.setUsername(data.username);
// factory.setPassword(data.password);
//
// if (data.vhost != null) {
// factory.setVirtualHost(data.vhost);
// }
//
// if (data.useSsl) {
// factory.useSslProtocol();
// }
//
// return factory.newConnection();
// }
//
// protected Channel channelFor(final AMQPPluginData data) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// final Connection conn = connectionFor(data);
// final Channel channel = conn.createChannel();
// final int qos = data.isConsumer ? data.prefetchCount : 0;
//
// channel.basicQos(qos);
//
// if ( ! conn.isOpen()) {
// throw new AMQPException("Unable to open a AMQP connection");
// }
//
// if ( ! channel.isOpen()) {
// throw new AMQPException("Unable to open an AMQP channel");
// }
//
// return channel;
// }
//
// public Processor processorFor(final AMQPPlugin step,final AMQPPluginData data, final AMQPPluginMeta meta) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException
// {
// final Channel channel = channelFor(data);
// final List<Initializer> initializers = new ArrayList<Initializer>();
//
// if (data.activeConfirmation) {
// initializers.add(ActiveConvirmationInitializer.INSTANCE);
// }
//
// if (data.isConsumer && data.isDeclare) {
// initializers.add(ConsumerDeclareInitializer.INSTANCE);
// }
//
// if (data.isProducer && data.isDeclare) {
// initializers.add(ProducerDeclareInitializer.INSTANCE);
// }
//
// if (data.isConsumer && data.isWaitingConsumer) {
// return new WaitingConsumerProcessor(channel, step, data, initializers);
// }
//
// if (data.isConsumer) {
// return new BasicConsumerProcessor(channel, step, data, initializers);
// }
//
// if (data.isProducer) {
// return new ProducerProcessor(channel, step, data, initializers);
// }
//
// throw new RuntimeException("Unknown mode");
// }
// }
// Path: src/main/java/com/instaclick/pentaho/plugin/amqp/AMQPPlugin.java
import java.io.IOException;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.exception.KettleStepException;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.BaseStep;
import org.pentaho.di.trans.step.StepDataInterface;
import org.pentaho.di.trans.step.StepInterface;
import org.pentaho.di.trans.step.StepMeta;
import org.pentaho.di.trans.step.StepMetaInterface;
import static com.instaclick.pentaho.plugin.amqp.Messages.getString;
import com.instaclick.pentaho.plugin.amqp.processor.Processor;
import com.instaclick.pentaho.plugin.amqp.processor.ProcessorFactory;
import static org.pentaho.di.core.encryption.KettleTwoWayPasswordEncoder.decryptPasswordOptionallyEncrypted;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.row.RowMeta;
import org.pentaho.di.trans.TransListener;
import org.pentaho.di.core.row.RowMetaInterface;
data.exchtype = meta.getExchtype();
data.isAutodel = meta.isAutodel();
data.isDurable = meta.isDurable();
data.isDeclare = meta.isDeclare();
data.isExclusive = meta.isExclusive();
if ( ! Const.isEmpty(routing)) {
data.routingIndex = data.outputRowMeta.indexOfValue(routing);
if (data.routingIndex < 0) {
throw new AMQPException("Unable to retrieve routing key field : " + meta.getRouting());
}
}
if ( ! Const.isEmpty(deliveryTagField)) {
data.deliveryTagIndex = data.outputRowMeta.indexOfValue(deliveryTagField);
if (data.deliveryTagIndex < 0) {
throw new AMQPException("Unable to retrieve DeliveryTag field : " + deliveryTagField);
}
}
if (data.bodyFieldIndex < 0) {
throw new AMQPException("Unable to retrieve body field : " + body);
}
if (data.target == null) {
throw new AMQPException("Unable to retrieve queue/exchange name");
}
| logMinimal(getString("AmqpPlugin.Body.Label") + " : " + body);
|
ccascone/JNetMan | src/jnetman/snmp/SnmpClient.java | // Path: src/jnetman/network/AddressException.java
// @SuppressWarnings("serial")
// public class AddressException extends Exception {
//
// public AddressException() {
// super();
// }
//
// public AddressException(String msg) {
// super(msg);
// }
//
// }
//
// Path: src/jnetman/network/NetworkDevice.java
// public abstract class NetworkDevice {
//
// private String name;
// private Network network;
// private InetAddress address;
// protected Logger logger;
//
// protected NetworkDevice(String name, Network network) {
// this.name = name;
// this.network = network;
// this.logger = Logger.getLogger("network."
// + StringUtils.uncapitalize(this.getClass().getSimpleName())
// + "." + name);
// logger.debug("New " + this.getClass().getSimpleName() + " created");
// }
//
// /**
// * Returns the name of the node. This is the name that will be used to refer
// * to the node when called from other methods inside the NetworkManager.
// *
// * @return the name of the node in String format
// */
// public String getName() {
// return this.name;
// }
//
// protected void setName(String name) {
// if (this.network != null)
// throw new RuntimeException(
// "It is forbidden to change the name once the "
// + "NetworkDevice has been added to the Network");
// this.name = name;
// }
//
// /**
// * Returns the IP address of the node.
// *
// * @return IP address of the node in InetAddress format
// * @throws AddressException
// * If no address is explicitly
// */
// public InetAddress getAddress() throws AddressException {
// return this.address;
// }
//
// /**
// * Assign an IP address to the node.
// *
// * @param address
// * The IP address to assign in InetAddress format
// */
// public void setAddress(InetAddress address) {
// this.address = address;
// logger.debug("IP address updated >> " + this.address.getHostAddress());
// }
//
// /**
// * Returns the Network object to which the node belongs.
// *
// * @return The network to which the node belongs as a Network object
// */
// public Network getNetwork() {
// return this.network;
// }
//
// protected void setNetwork(Network network) {
// if (this.name == null)
// throw new RuntimeException(
// "You must assign a name to this NetworkDevice before "
// + "adding it to the Network");
// this.network = network;
// }
//
// public String toString() {
// if (this.address != null)
// return this.getClass().getCanonicalName() + " " + name + " : "
// + address.getHostAddress();
// else
// return this.getClass().getCanonicalName() + " " + name + " : null";
// }
//
// public abstract Agent getAgent() throws AddressException;
//
// }
//
// Path: src/jnetman/session/SnmpPref.java
// public class SnmpPref {
//
// static private PropertiesParser prop = new PropertiesParser(
// Session.getSnmpPropertiesFile());
//
// static public String getUser() {
// return prop.getString("V3_USER");
// }
//
// static public String getPassword() {
// return prop.getString("V3_AUTHPRIV_PASSWORD");
// }
//
// static public int getPort() {
// return prop.getInt("AGENT_PORT");
// }
//
// static public int getTrapsPort() {
// return prop.getInt("TRAPS_PORT");
// }
//
// static public int getTimeout() {
// return prop.getInt("TIMEOUT");
// }
//
// static public int getMaxRetries() {
// return prop.getInt("MAX_RETRIES");
// }
//
// static public boolean isSnmp4jLogEnabled() {
// return prop.getBoolean("ENABLE_SNMP4J_LOG");
// }
//
// }
| import java.io.IOException;
import java.util.Vector;
import jnetman.network.AddressException;
import jnetman.network.NetworkDevice;
import jnetman.session.SnmpPref;
import org.apache.log4j.Logger;
import org.snmp4j.PDU;
import org.snmp4j.ScopedPDU;
import org.snmp4j.Snmp;
import org.snmp4j.Target;
import org.snmp4j.UserTarget;
import org.snmp4j.event.ResponseEvent;
import org.snmp4j.log.Log4jLogFactory;
import org.snmp4j.log.LogFactory;
import org.snmp4j.mp.MPv3;
import org.snmp4j.mp.SnmpConstants;
import org.snmp4j.security.AuthMD5;
import org.snmp4j.security.PrivDES;
import org.snmp4j.security.SecurityLevel;
import org.snmp4j.security.SecurityModels;
import org.snmp4j.security.SecurityProtocols;
import org.snmp4j.security.USM;
import org.snmp4j.security.UsmUser;
import org.snmp4j.smi.Address;
import org.snmp4j.smi.GenericAddress;
import org.snmp4j.smi.Integer32;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.OctetString;
import org.snmp4j.smi.Variable;
import org.snmp4j.smi.VariableBinding;
import org.snmp4j.transport.DefaultUdpTransportMapping;
import org.snmp4j.util.PDUFactory;
import org.snmp4j.util.TreeEvent;
import org.snmp4j.util.TreeListener;
import org.snmp4j.util.TreeUtils; | package jnetman.snmp;
public class SnmpClient implements PDUFactory {
private Snmp snmpInstance; | // Path: src/jnetman/network/AddressException.java
// @SuppressWarnings("serial")
// public class AddressException extends Exception {
//
// public AddressException() {
// super();
// }
//
// public AddressException(String msg) {
// super(msg);
// }
//
// }
//
// Path: src/jnetman/network/NetworkDevice.java
// public abstract class NetworkDevice {
//
// private String name;
// private Network network;
// private InetAddress address;
// protected Logger logger;
//
// protected NetworkDevice(String name, Network network) {
// this.name = name;
// this.network = network;
// this.logger = Logger.getLogger("network."
// + StringUtils.uncapitalize(this.getClass().getSimpleName())
// + "." + name);
// logger.debug("New " + this.getClass().getSimpleName() + " created");
// }
//
// /**
// * Returns the name of the node. This is the name that will be used to refer
// * to the node when called from other methods inside the NetworkManager.
// *
// * @return the name of the node in String format
// */
// public String getName() {
// return this.name;
// }
//
// protected void setName(String name) {
// if (this.network != null)
// throw new RuntimeException(
// "It is forbidden to change the name once the "
// + "NetworkDevice has been added to the Network");
// this.name = name;
// }
//
// /**
// * Returns the IP address of the node.
// *
// * @return IP address of the node in InetAddress format
// * @throws AddressException
// * If no address is explicitly
// */
// public InetAddress getAddress() throws AddressException {
// return this.address;
// }
//
// /**
// * Assign an IP address to the node.
// *
// * @param address
// * The IP address to assign in InetAddress format
// */
// public void setAddress(InetAddress address) {
// this.address = address;
// logger.debug("IP address updated >> " + this.address.getHostAddress());
// }
//
// /**
// * Returns the Network object to which the node belongs.
// *
// * @return The network to which the node belongs as a Network object
// */
// public Network getNetwork() {
// return this.network;
// }
//
// protected void setNetwork(Network network) {
// if (this.name == null)
// throw new RuntimeException(
// "You must assign a name to this NetworkDevice before "
// + "adding it to the Network");
// this.network = network;
// }
//
// public String toString() {
// if (this.address != null)
// return this.getClass().getCanonicalName() + " " + name + " : "
// + address.getHostAddress();
// else
// return this.getClass().getCanonicalName() + " " + name + " : null";
// }
//
// public abstract Agent getAgent() throws AddressException;
//
// }
//
// Path: src/jnetman/session/SnmpPref.java
// public class SnmpPref {
//
// static private PropertiesParser prop = new PropertiesParser(
// Session.getSnmpPropertiesFile());
//
// static public String getUser() {
// return prop.getString("V3_USER");
// }
//
// static public String getPassword() {
// return prop.getString("V3_AUTHPRIV_PASSWORD");
// }
//
// static public int getPort() {
// return prop.getInt("AGENT_PORT");
// }
//
// static public int getTrapsPort() {
// return prop.getInt("TRAPS_PORT");
// }
//
// static public int getTimeout() {
// return prop.getInt("TIMEOUT");
// }
//
// static public int getMaxRetries() {
// return prop.getInt("MAX_RETRIES");
// }
//
// static public boolean isSnmp4jLogEnabled() {
// return prop.getBoolean("ENABLE_SNMP4J_LOG");
// }
//
// }
// Path: src/jnetman/snmp/SnmpClient.java
import java.io.IOException;
import java.util.Vector;
import jnetman.network.AddressException;
import jnetman.network.NetworkDevice;
import jnetman.session.SnmpPref;
import org.apache.log4j.Logger;
import org.snmp4j.PDU;
import org.snmp4j.ScopedPDU;
import org.snmp4j.Snmp;
import org.snmp4j.Target;
import org.snmp4j.UserTarget;
import org.snmp4j.event.ResponseEvent;
import org.snmp4j.log.Log4jLogFactory;
import org.snmp4j.log.LogFactory;
import org.snmp4j.mp.MPv3;
import org.snmp4j.mp.SnmpConstants;
import org.snmp4j.security.AuthMD5;
import org.snmp4j.security.PrivDES;
import org.snmp4j.security.SecurityLevel;
import org.snmp4j.security.SecurityModels;
import org.snmp4j.security.SecurityProtocols;
import org.snmp4j.security.USM;
import org.snmp4j.security.UsmUser;
import org.snmp4j.smi.Address;
import org.snmp4j.smi.GenericAddress;
import org.snmp4j.smi.Integer32;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.OctetString;
import org.snmp4j.smi.Variable;
import org.snmp4j.smi.VariableBinding;
import org.snmp4j.transport.DefaultUdpTransportMapping;
import org.snmp4j.util.PDUFactory;
import org.snmp4j.util.TreeEvent;
import org.snmp4j.util.TreeListener;
import org.snmp4j.util.TreeUtils;
package jnetman.snmp;
public class SnmpClient implements PDUFactory {
private Snmp snmpInstance; | private NetworkDevice targetDevice; |
ccascone/JNetMan | src/jnetman/snmp/SnmpTrapReceiver.java | // Path: src/jnetman/session/SnmpPref.java
// public class SnmpPref {
//
// static private PropertiesParser prop = new PropertiesParser(
// Session.getSnmpPropertiesFile());
//
// static public String getUser() {
// return prop.getString("V3_USER");
// }
//
// static public String getPassword() {
// return prop.getString("V3_AUTHPRIV_PASSWORD");
// }
//
// static public int getPort() {
// return prop.getInt("AGENT_PORT");
// }
//
// static public int getTrapsPort() {
// return prop.getInt("TRAPS_PORT");
// }
//
// static public int getTimeout() {
// return prop.getInt("TIMEOUT");
// }
//
// static public int getMaxRetries() {
// return prop.getInt("MAX_RETRIES");
// }
//
// static public boolean isSnmp4jLogEnabled() {
// return prop.getBoolean("ENABLE_SNMP4J_LOG");
// }
//
// }
| import java.io.IOException;
import java.net.UnknownHostException;
import jnetman.session.SnmpPref;
import org.apache.log4j.Logger;
import org.snmp4j.CommandResponder;
import org.snmp4j.CommandResponderEvent;
import org.snmp4j.MessageDispatcherImpl;
import org.snmp4j.Snmp;
import org.snmp4j.mp.MPv1;
import org.snmp4j.mp.MPv2c;
import org.snmp4j.mp.MPv3;
import org.snmp4j.security.SecurityModels;
import org.snmp4j.security.SecurityProtocols;
import org.snmp4j.security.USM;
import org.snmp4j.smi.Address;
import org.snmp4j.smi.GenericAddress;
import org.snmp4j.smi.OctetString;
import org.snmp4j.smi.UdpAddress;
import org.snmp4j.transport.DefaultUdpTransportMapping;
import org.snmp4j.util.MultiThreadedMessageDispatcher;
import org.snmp4j.util.ThreadPool; | package jnetman.snmp;
public class SnmpTrapReceiver implements CommandResponder {
// initialize Log4J logging
static Logger logger = Logger.getLogger("snmp.snmpTrapReceiver");
private MultiThreadedMessageDispatcher dispatcher;
private Snmp snmp = null;
private Address listenAddress;
private ThreadPool threadPool;
private int n = 0;
private long start = -1;
public SnmpTrapReceiver() {
logger.debug("Created");
}
private void init() throws UnknownHostException, IOException {
threadPool = ThreadPool.create("Trap", 4);
dispatcher = new MultiThreadedMessageDispatcher(threadPool,
new MessageDispatcherImpl());
listenAddress = GenericAddress.parse("udp:0.0.0.0/" | // Path: src/jnetman/session/SnmpPref.java
// public class SnmpPref {
//
// static private PropertiesParser prop = new PropertiesParser(
// Session.getSnmpPropertiesFile());
//
// static public String getUser() {
// return prop.getString("V3_USER");
// }
//
// static public String getPassword() {
// return prop.getString("V3_AUTHPRIV_PASSWORD");
// }
//
// static public int getPort() {
// return prop.getInt("AGENT_PORT");
// }
//
// static public int getTrapsPort() {
// return prop.getInt("TRAPS_PORT");
// }
//
// static public int getTimeout() {
// return prop.getInt("TIMEOUT");
// }
//
// static public int getMaxRetries() {
// return prop.getInt("MAX_RETRIES");
// }
//
// static public boolean isSnmp4jLogEnabled() {
// return prop.getBoolean("ENABLE_SNMP4J_LOG");
// }
//
// }
// Path: src/jnetman/snmp/SnmpTrapReceiver.java
import java.io.IOException;
import java.net.UnknownHostException;
import jnetman.session.SnmpPref;
import org.apache.log4j.Logger;
import org.snmp4j.CommandResponder;
import org.snmp4j.CommandResponderEvent;
import org.snmp4j.MessageDispatcherImpl;
import org.snmp4j.Snmp;
import org.snmp4j.mp.MPv1;
import org.snmp4j.mp.MPv2c;
import org.snmp4j.mp.MPv3;
import org.snmp4j.security.SecurityModels;
import org.snmp4j.security.SecurityProtocols;
import org.snmp4j.security.USM;
import org.snmp4j.smi.Address;
import org.snmp4j.smi.GenericAddress;
import org.snmp4j.smi.OctetString;
import org.snmp4j.smi.UdpAddress;
import org.snmp4j.transport.DefaultUdpTransportMapping;
import org.snmp4j.util.MultiThreadedMessageDispatcher;
import org.snmp4j.util.ThreadPool;
package jnetman.snmp;
public class SnmpTrapReceiver implements CommandResponder {
// initialize Log4J logging
static Logger logger = Logger.getLogger("snmp.snmpTrapReceiver");
private MultiThreadedMessageDispatcher dispatcher;
private Snmp snmp = null;
private Address listenAddress;
private ThreadPool threadPool;
private int n = 0;
private long start = -1;
public SnmpTrapReceiver() {
logger.debug("Created");
}
private void init() throws UnknownHostException, IOException {
threadPool = ThreadPool.create("Trap", 4);
dispatcher = new MultiThreadedMessageDispatcher(threadPool,
new MessageDispatcherImpl());
listenAddress = GenericAddress.parse("udp:0.0.0.0/" | + SnmpPref.getTrapsPort()); |
LaurenceYang/EasyHttp | sample/src/main/java/com/yang/demo/MainActivity.java | // Path: sample/src/main/java/com/yang/demo/entity/MainEntity.java
// public class MainEntity {
// private String title;
// private String desc;
// private int type;
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDesc() {
// return desc;
// }
//
// public void setDesc(String desc) {
// this.desc = desc;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
// }
//
// Path: sample/src/main/java/com/yang/demo/adapter/MainAdapter.java
// public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
// private ArrayList<MainEntity> mList;
// private Context mContext;
//
// public MainAdapter(Context context) {
// this.mContext = context;
// }
//
// public void setData(ArrayList<MainEntity> list) {
// mList = list;
// notifyDataSetChanged();
// }
//
// @Override
// public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View view = LayoutInflater.from(mContext).inflate(R.layout.main_item, parent, false);
// return new ViewHolder(view);
// }
//
// @Override
// public void onBindViewHolder(ViewHolder holder, int position) {
// Log.d("test", "onBindViewHolder called position : " + position);
// final MainEntity entity = mList.get(position);
//
// holder.title.setText(entity.getTitle());
// holder.desc.setText(entity.getDesc());
//
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// switch (entity.getType()) {
// case 1:
// Intent intent = new Intent(mContext, GetActivity.class);
// mContext.startActivity(intent);
// break;
// case 2:
// intent = new Intent(mContext, PostActivity.class);
// mContext.startActivity(intent);
// break;
// case 3:
// intent = new Intent(mContext, DownloadActivity.class);
// mContext.startActivity(intent);
// break;
// case 4:
// intent = new Intent(mContext, UploadActivity.class);
// mContext.startActivity(intent);
// break;
// case 5:
// intent = new Intent(mContext, RxGetActivity.class);
// mContext.startActivity(intent);
// break;
// case 6:
// intent = new Intent(mContext, RxPostActivity.class);
// mContext.startActivity(intent);
// break;
// default:
// break;
// }
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mList != null ? mList.size() : 0;
// }
//
// class ViewHolder extends RecyclerView.ViewHolder {
// @BindView(R.id.title)
// TextView title;
// @BindView(R.id.desc)
// TextView desc;
//
// public ViewHolder(View itemView) {
// super(itemView);
// ButterKnife.bind(this, itemView);
// }
// }
// }
| import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import com.yang.demo.entity.MainEntity;
import com.yang.demo.adapter.MainAdapter;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife; | package com.yang.demo;
public class MainActivity extends AppCompatActivity {
private MainAdapter mMainAdapter;
@BindView(R.id.list)
RecyclerView mRecyclerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
mMainAdapter = new MainAdapter(this);
mRecyclerView.setAdapter(mMainAdapter);
mMainAdapter.setData(getEntities());
}
| // Path: sample/src/main/java/com/yang/demo/entity/MainEntity.java
// public class MainEntity {
// private String title;
// private String desc;
// private int type;
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDesc() {
// return desc;
// }
//
// public void setDesc(String desc) {
// this.desc = desc;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
// }
//
// Path: sample/src/main/java/com/yang/demo/adapter/MainAdapter.java
// public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
// private ArrayList<MainEntity> mList;
// private Context mContext;
//
// public MainAdapter(Context context) {
// this.mContext = context;
// }
//
// public void setData(ArrayList<MainEntity> list) {
// mList = list;
// notifyDataSetChanged();
// }
//
// @Override
// public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View view = LayoutInflater.from(mContext).inflate(R.layout.main_item, parent, false);
// return new ViewHolder(view);
// }
//
// @Override
// public void onBindViewHolder(ViewHolder holder, int position) {
// Log.d("test", "onBindViewHolder called position : " + position);
// final MainEntity entity = mList.get(position);
//
// holder.title.setText(entity.getTitle());
// holder.desc.setText(entity.getDesc());
//
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// switch (entity.getType()) {
// case 1:
// Intent intent = new Intent(mContext, GetActivity.class);
// mContext.startActivity(intent);
// break;
// case 2:
// intent = new Intent(mContext, PostActivity.class);
// mContext.startActivity(intent);
// break;
// case 3:
// intent = new Intent(mContext, DownloadActivity.class);
// mContext.startActivity(intent);
// break;
// case 4:
// intent = new Intent(mContext, UploadActivity.class);
// mContext.startActivity(intent);
// break;
// case 5:
// intent = new Intent(mContext, RxGetActivity.class);
// mContext.startActivity(intent);
// break;
// case 6:
// intent = new Intent(mContext, RxPostActivity.class);
// mContext.startActivity(intent);
// break;
// default:
// break;
// }
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mList != null ? mList.size() : 0;
// }
//
// class ViewHolder extends RecyclerView.ViewHolder {
// @BindView(R.id.title)
// TextView title;
// @BindView(R.id.desc)
// TextView desc;
//
// public ViewHolder(View itemView) {
// super(itemView);
// ButterKnife.bind(this, itemView);
// }
// }
// }
// Path: sample/src/main/java/com/yang/demo/MainActivity.java
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import com.yang.demo.entity.MainEntity;
import com.yang.demo.adapter.MainAdapter;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
package com.yang.demo;
public class MainActivity extends AppCompatActivity {
private MainAdapter mMainAdapter;
@BindView(R.id.list)
RecyclerView mRecyclerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
mMainAdapter = new MainAdapter(this);
mRecyclerView.setAdapter(mMainAdapter);
mMainAdapter.setData(getEntities());
}
| private ArrayList<MainEntity> getEntities() { |
LaurenceYang/EasyHttp | sample/src/main/java/com/yang/demo/MainApplication.java | // Path: easy-http-library/src/main/java/com/yang/easyhttp/EasyHttpClient.java
// public class EasyHttpClient {
// /**
// * EasyHttpClient init.
// * @param context
// */
// public static void init(Context context) {
// EasyHttpClientManager.getInstance().init(context);
// }
//
// public static void init(Context context, EasyHttpConfig config) {
// EasyHttpClientManager.getInstance().init(context, config);
// }
//
// /**
// * Download environment init.
// * Make sure the init function is only called once.
// */
// public static void initDownloadEnvironment() {
// EasyDownloadManager.getInstance().init(EasyHttpClientManager.getInstance().getContext());
// }
//
// public static void initDownloadEnvironment(int threadCount) {
// EasyDownloadManager.getInstance().init(EasyHttpClientManager.getInstance().getContext(), threadCount);
// }
//
// /**
// * set the debug mode.
// * @param debug
// */
// public static void setDebug(boolean debug) {
// EasyHttpClientManager.getInstance().setDebug(debug);
// }
//
// /**
// * get request.
// * @param url
// * @param callback
// * @param <T>
// */
// public static <T> void get(String url, EasyCallback<T> callback) {
// get(url, null, callback);
// }
//
// public static <T> void get(String url, EasyRequestParams easyRequestParams, EasyCallback<T> callBack) {
// EasyHttpClientManager.getInstance().get(url, easyRequestParams, EasyCacheType.CACHE_TYPE_NO_SETTING, callBack);
// }
//
// public static <T> void get(String url, int cacheType, EasyCallback<T> callback) {
// get(url, null, cacheType, callback);
// }
//
// public static <T> void get(String url, EasyRequestParams easyRequestParams, int cacheType, EasyCallback<T> callback) {
// EasyHttpClientManager.getInstance().get(url, easyRequestParams, cacheType, callback);
// }
//
// /**
// * post request.
// * @param url
// * @param easyRequestParams
// * @param callback
// * @param <T>
// */
// public static <T> void post(String url, EasyRequestParams easyRequestParams, EasyCallback<T> callback) {
// EasyHttpClientManager.getInstance().postOrDeleteOrPut(url, easyRequestParams, callback, EasyHttpClientManager.REQUEST_POST);
// }
//
// /**
// * delete request.
// * @param url
// * @param easyRequestParams
// * @param callback
// * @param <T>
// */
// public static <T> void delete(String url, EasyRequestParams easyRequestParams, EasyCallback<T> callback) {
// EasyHttpClientManager.getInstance().postOrDeleteOrPut(url, easyRequestParams, callback, EasyHttpClientManager.REQUEST_DELETE);
// }
//
// /**
// * put request
// * @param url
// * @param easyRequestParams
// * @param callback
// * @param <T>
// */
// public static <T> void put(String url, EasyRequestParams easyRequestParams, EasyCallback<T> callback) {
// EasyHttpClientManager.getInstance().postOrDeleteOrPut(url, easyRequestParams, callback, EasyHttpClientManager.REQUEST_PUT);
// }
//
// /**
// * upload file.
// * @param url
// * @param filePath
// * @param callback
// * @param <T>
// */
// public static <T> void uploadFile(String url, String filePath, EasyCallback<T> callback) {
// EasyHttpClientManager.getInstance().uploadFile(url, filePath, callback);
// }
//
// /**
// * cancel request.
// * @param cacheType
// */
// public static void cancel(int cacheType) {
// EasyHttpClientManager.getInstance().cancelRequest(cacheType);
// }
// }
| import android.app.Application;
import com.yang.easyhttp.EasyHttpClient; | package com.yang.demo;
/**
* Created by yangyang on 2017/2/17.
*/
public class MainApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// 初始化HttpClient. | // Path: easy-http-library/src/main/java/com/yang/easyhttp/EasyHttpClient.java
// public class EasyHttpClient {
// /**
// * EasyHttpClient init.
// * @param context
// */
// public static void init(Context context) {
// EasyHttpClientManager.getInstance().init(context);
// }
//
// public static void init(Context context, EasyHttpConfig config) {
// EasyHttpClientManager.getInstance().init(context, config);
// }
//
// /**
// * Download environment init.
// * Make sure the init function is only called once.
// */
// public static void initDownloadEnvironment() {
// EasyDownloadManager.getInstance().init(EasyHttpClientManager.getInstance().getContext());
// }
//
// public static void initDownloadEnvironment(int threadCount) {
// EasyDownloadManager.getInstance().init(EasyHttpClientManager.getInstance().getContext(), threadCount);
// }
//
// /**
// * set the debug mode.
// * @param debug
// */
// public static void setDebug(boolean debug) {
// EasyHttpClientManager.getInstance().setDebug(debug);
// }
//
// /**
// * get request.
// * @param url
// * @param callback
// * @param <T>
// */
// public static <T> void get(String url, EasyCallback<T> callback) {
// get(url, null, callback);
// }
//
// public static <T> void get(String url, EasyRequestParams easyRequestParams, EasyCallback<T> callBack) {
// EasyHttpClientManager.getInstance().get(url, easyRequestParams, EasyCacheType.CACHE_TYPE_NO_SETTING, callBack);
// }
//
// public static <T> void get(String url, int cacheType, EasyCallback<T> callback) {
// get(url, null, cacheType, callback);
// }
//
// public static <T> void get(String url, EasyRequestParams easyRequestParams, int cacheType, EasyCallback<T> callback) {
// EasyHttpClientManager.getInstance().get(url, easyRequestParams, cacheType, callback);
// }
//
// /**
// * post request.
// * @param url
// * @param easyRequestParams
// * @param callback
// * @param <T>
// */
// public static <T> void post(String url, EasyRequestParams easyRequestParams, EasyCallback<T> callback) {
// EasyHttpClientManager.getInstance().postOrDeleteOrPut(url, easyRequestParams, callback, EasyHttpClientManager.REQUEST_POST);
// }
//
// /**
// * delete request.
// * @param url
// * @param easyRequestParams
// * @param callback
// * @param <T>
// */
// public static <T> void delete(String url, EasyRequestParams easyRequestParams, EasyCallback<T> callback) {
// EasyHttpClientManager.getInstance().postOrDeleteOrPut(url, easyRequestParams, callback, EasyHttpClientManager.REQUEST_DELETE);
// }
//
// /**
// * put request
// * @param url
// * @param easyRequestParams
// * @param callback
// * @param <T>
// */
// public static <T> void put(String url, EasyRequestParams easyRequestParams, EasyCallback<T> callback) {
// EasyHttpClientManager.getInstance().postOrDeleteOrPut(url, easyRequestParams, callback, EasyHttpClientManager.REQUEST_PUT);
// }
//
// /**
// * upload file.
// * @param url
// * @param filePath
// * @param callback
// * @param <T>
// */
// public static <T> void uploadFile(String url, String filePath, EasyCallback<T> callback) {
// EasyHttpClientManager.getInstance().uploadFile(url, filePath, callback);
// }
//
// /**
// * cancel request.
// * @param cacheType
// */
// public static void cancel(int cacheType) {
// EasyHttpClientManager.getInstance().cancelRequest(cacheType);
// }
// }
// Path: sample/src/main/java/com/yang/demo/MainApplication.java
import android.app.Application;
import com.yang.easyhttp.EasyHttpClient;
package com.yang.demo;
/**
* Created by yangyang on 2017/2/17.
*/
public class MainApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// 初始化HttpClient. | EasyHttpClient.init(this); |
LaurenceYang/EasyHttp | sample/src/main/java/com/yang/demo/activity/RxPostActivity.java | // Path: sample/src/main/java/com/yang/demo/entity/PostEntity.java
// public class PostEntity {
// int status;
// String message;
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
//
// Path: easy-http-library/src/main/java/com/yang/easyhttp/request/EasyRequestParams.java
// public class EasyRequestParams {
// private ConcurrentHashMap<String, String> mRequestParams = new ConcurrentHashMap<>();
// private ConcurrentHashMap<String, String> mRequestHeaders = new ConcurrentHashMap<>();
//
//
// public void put(String key, String value) {
// if (key != null && value != null) {
// mRequestParams.put(key, value);
// }
// }
//
// public ConcurrentHashMap<String, String> getRequestParams() {
// return mRequestParams;
// }
//
// public void addHeader(String key, String value) {
// if (key != null && value != null) {
// mRequestHeaders.put(key, value);
// }
// }
//
// public ConcurrentHashMap<String, String> getRequestHeaders() {
// return mRequestHeaders;
// }
//
// @Override
// public String toString() {
// StringBuilder result = new StringBuilder();
// for (ConcurrentHashMap.Entry<String, String> entry : mRequestParams.entrySet()) {
// if (result.length() > 0)
// result.append("&");
//
// result.append(entry.getKey());
// result.append("=");
// result.append(entry.getValue());
// }
// return result.toString();
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/RxEasyHttp.java
// public class RxEasyHttp {
// /**
// * Get请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> get(String url, RxEasyConverter<T> converter) {
// return get(url, null, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, EasyCacheType.CACHE_TYPE_NO_SETTING, converter);
// }
//
// public static <T> Flowable<T> get(String url, int cacheType, RxEasyConverter<T> converter) {
// return get(url, null, cacheType, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, int cacheType, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, cacheType, converter);
// }
//
// /**
// * Post请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> post(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().post(url, easyRequestParams, converter);
// }
//
// /**
// * post file RxJava形式
// * @param url
// * @param filePath
// * @return
// */
// public static <T> Flowable<T> uploadFile(String url, String filePath, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().uploadFile(url, filePath, converter);
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/converter/RxEasyCustomConverter.java
// public abstract class RxEasyCustomConverter<T> implements RxEasyConverter<T> {
//
// @Override
// public T convert(String body) throws Exception {
// Class clazz = this.getClass();
// Type superClassType = clazz.getGenericSuperclass();
// Type tArg = ((ParameterizedType) superClassType).getActualTypeArguments()[0];
// Gson gson = EasyHttpClientManager.getInstance().getGson();
// return gson.fromJson(body, tArg);
// }
// }
| import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.yang.demo.R;
import com.yang.demo.entity.PostEntity;
import com.yang.easyhttp.request.EasyRequestParams;
import com.yang.easyhttprx.RxEasyHttp;
import com.yang.easyhttprx.converter.RxEasyCustomConverter;
import org.reactivestreams.Subscription;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.FlowableSubscriber;
import io.reactivex.android.schedulers.AndroidSchedulers; | package com.yang.demo.activity;
/**
* Created by yangyang on 2017/2/17.
*/
public class RxPostActivity extends AppCompatActivity {
@BindView(R.id.comment)
EditText comment;
@BindView(R.id.submit)
Button submit;
@BindView(R.id.result)
TextView result;
ProgressDialog dialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.post_main);
ButterKnife.bind(this);
dialog = new ProgressDialog(this);
}
@OnClick(R.id.submit)
public void submit() {
Editable content = comment.getText();
if (TextUtils.isEmpty(content)) {
Toast.makeText(this, "comment is empty", Toast.LENGTH_SHORT);
return;
}
| // Path: sample/src/main/java/com/yang/demo/entity/PostEntity.java
// public class PostEntity {
// int status;
// String message;
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
//
// Path: easy-http-library/src/main/java/com/yang/easyhttp/request/EasyRequestParams.java
// public class EasyRequestParams {
// private ConcurrentHashMap<String, String> mRequestParams = new ConcurrentHashMap<>();
// private ConcurrentHashMap<String, String> mRequestHeaders = new ConcurrentHashMap<>();
//
//
// public void put(String key, String value) {
// if (key != null && value != null) {
// mRequestParams.put(key, value);
// }
// }
//
// public ConcurrentHashMap<String, String> getRequestParams() {
// return mRequestParams;
// }
//
// public void addHeader(String key, String value) {
// if (key != null && value != null) {
// mRequestHeaders.put(key, value);
// }
// }
//
// public ConcurrentHashMap<String, String> getRequestHeaders() {
// return mRequestHeaders;
// }
//
// @Override
// public String toString() {
// StringBuilder result = new StringBuilder();
// for (ConcurrentHashMap.Entry<String, String> entry : mRequestParams.entrySet()) {
// if (result.length() > 0)
// result.append("&");
//
// result.append(entry.getKey());
// result.append("=");
// result.append(entry.getValue());
// }
// return result.toString();
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/RxEasyHttp.java
// public class RxEasyHttp {
// /**
// * Get请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> get(String url, RxEasyConverter<T> converter) {
// return get(url, null, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, EasyCacheType.CACHE_TYPE_NO_SETTING, converter);
// }
//
// public static <T> Flowable<T> get(String url, int cacheType, RxEasyConverter<T> converter) {
// return get(url, null, cacheType, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, int cacheType, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, cacheType, converter);
// }
//
// /**
// * Post请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> post(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().post(url, easyRequestParams, converter);
// }
//
// /**
// * post file RxJava形式
// * @param url
// * @param filePath
// * @return
// */
// public static <T> Flowable<T> uploadFile(String url, String filePath, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().uploadFile(url, filePath, converter);
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/converter/RxEasyCustomConverter.java
// public abstract class RxEasyCustomConverter<T> implements RxEasyConverter<T> {
//
// @Override
// public T convert(String body) throws Exception {
// Class clazz = this.getClass();
// Type superClassType = clazz.getGenericSuperclass();
// Type tArg = ((ParameterizedType) superClassType).getActualTypeArguments()[0];
// Gson gson = EasyHttpClientManager.getInstance().getGson();
// return gson.fromJson(body, tArg);
// }
// }
// Path: sample/src/main/java/com/yang/demo/activity/RxPostActivity.java
import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.yang.demo.R;
import com.yang.demo.entity.PostEntity;
import com.yang.easyhttp.request.EasyRequestParams;
import com.yang.easyhttprx.RxEasyHttp;
import com.yang.easyhttprx.converter.RxEasyCustomConverter;
import org.reactivestreams.Subscription;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.FlowableSubscriber;
import io.reactivex.android.schedulers.AndroidSchedulers;
package com.yang.demo.activity;
/**
* Created by yangyang on 2017/2/17.
*/
public class RxPostActivity extends AppCompatActivity {
@BindView(R.id.comment)
EditText comment;
@BindView(R.id.submit)
Button submit;
@BindView(R.id.result)
TextView result;
ProgressDialog dialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.post_main);
ButterKnife.bind(this);
dialog = new ProgressDialog(this);
}
@OnClick(R.id.submit)
public void submit() {
Editable content = comment.getText();
if (TextUtils.isEmpty(content)) {
Toast.makeText(this, "comment is empty", Toast.LENGTH_SHORT);
return;
}
| EasyRequestParams params = new EasyRequestParams(); |
LaurenceYang/EasyHttp | sample/src/main/java/com/yang/demo/activity/RxPostActivity.java | // Path: sample/src/main/java/com/yang/demo/entity/PostEntity.java
// public class PostEntity {
// int status;
// String message;
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
//
// Path: easy-http-library/src/main/java/com/yang/easyhttp/request/EasyRequestParams.java
// public class EasyRequestParams {
// private ConcurrentHashMap<String, String> mRequestParams = new ConcurrentHashMap<>();
// private ConcurrentHashMap<String, String> mRequestHeaders = new ConcurrentHashMap<>();
//
//
// public void put(String key, String value) {
// if (key != null && value != null) {
// mRequestParams.put(key, value);
// }
// }
//
// public ConcurrentHashMap<String, String> getRequestParams() {
// return mRequestParams;
// }
//
// public void addHeader(String key, String value) {
// if (key != null && value != null) {
// mRequestHeaders.put(key, value);
// }
// }
//
// public ConcurrentHashMap<String, String> getRequestHeaders() {
// return mRequestHeaders;
// }
//
// @Override
// public String toString() {
// StringBuilder result = new StringBuilder();
// for (ConcurrentHashMap.Entry<String, String> entry : mRequestParams.entrySet()) {
// if (result.length() > 0)
// result.append("&");
//
// result.append(entry.getKey());
// result.append("=");
// result.append(entry.getValue());
// }
// return result.toString();
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/RxEasyHttp.java
// public class RxEasyHttp {
// /**
// * Get请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> get(String url, RxEasyConverter<T> converter) {
// return get(url, null, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, EasyCacheType.CACHE_TYPE_NO_SETTING, converter);
// }
//
// public static <T> Flowable<T> get(String url, int cacheType, RxEasyConverter<T> converter) {
// return get(url, null, cacheType, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, int cacheType, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, cacheType, converter);
// }
//
// /**
// * Post请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> post(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().post(url, easyRequestParams, converter);
// }
//
// /**
// * post file RxJava形式
// * @param url
// * @param filePath
// * @return
// */
// public static <T> Flowable<T> uploadFile(String url, String filePath, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().uploadFile(url, filePath, converter);
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/converter/RxEasyCustomConverter.java
// public abstract class RxEasyCustomConverter<T> implements RxEasyConverter<T> {
//
// @Override
// public T convert(String body) throws Exception {
// Class clazz = this.getClass();
// Type superClassType = clazz.getGenericSuperclass();
// Type tArg = ((ParameterizedType) superClassType).getActualTypeArguments()[0];
// Gson gson = EasyHttpClientManager.getInstance().getGson();
// return gson.fromJson(body, tArg);
// }
// }
| import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.yang.demo.R;
import com.yang.demo.entity.PostEntity;
import com.yang.easyhttp.request.EasyRequestParams;
import com.yang.easyhttprx.RxEasyHttp;
import com.yang.easyhttprx.converter.RxEasyCustomConverter;
import org.reactivestreams.Subscription;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.FlowableSubscriber;
import io.reactivex.android.schedulers.AndroidSchedulers; | package com.yang.demo.activity;
/**
* Created by yangyang on 2017/2/17.
*/
public class RxPostActivity extends AppCompatActivity {
@BindView(R.id.comment)
EditText comment;
@BindView(R.id.submit)
Button submit;
@BindView(R.id.result)
TextView result;
ProgressDialog dialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.post_main);
ButterKnife.bind(this);
dialog = new ProgressDialog(this);
}
@OnClick(R.id.submit)
public void submit() {
Editable content = comment.getText();
if (TextUtils.isEmpty(content)) {
Toast.makeText(this, "comment is empty", Toast.LENGTH_SHORT);
return;
}
EasyRequestParams params = new EasyRequestParams();
params.put("content", content.toString());
String url = "http://book.km.com/app/index.php?c=version&a=feedback";
| // Path: sample/src/main/java/com/yang/demo/entity/PostEntity.java
// public class PostEntity {
// int status;
// String message;
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
//
// Path: easy-http-library/src/main/java/com/yang/easyhttp/request/EasyRequestParams.java
// public class EasyRequestParams {
// private ConcurrentHashMap<String, String> mRequestParams = new ConcurrentHashMap<>();
// private ConcurrentHashMap<String, String> mRequestHeaders = new ConcurrentHashMap<>();
//
//
// public void put(String key, String value) {
// if (key != null && value != null) {
// mRequestParams.put(key, value);
// }
// }
//
// public ConcurrentHashMap<String, String> getRequestParams() {
// return mRequestParams;
// }
//
// public void addHeader(String key, String value) {
// if (key != null && value != null) {
// mRequestHeaders.put(key, value);
// }
// }
//
// public ConcurrentHashMap<String, String> getRequestHeaders() {
// return mRequestHeaders;
// }
//
// @Override
// public String toString() {
// StringBuilder result = new StringBuilder();
// for (ConcurrentHashMap.Entry<String, String> entry : mRequestParams.entrySet()) {
// if (result.length() > 0)
// result.append("&");
//
// result.append(entry.getKey());
// result.append("=");
// result.append(entry.getValue());
// }
// return result.toString();
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/RxEasyHttp.java
// public class RxEasyHttp {
// /**
// * Get请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> get(String url, RxEasyConverter<T> converter) {
// return get(url, null, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, EasyCacheType.CACHE_TYPE_NO_SETTING, converter);
// }
//
// public static <T> Flowable<T> get(String url, int cacheType, RxEasyConverter<T> converter) {
// return get(url, null, cacheType, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, int cacheType, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, cacheType, converter);
// }
//
// /**
// * Post请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> post(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().post(url, easyRequestParams, converter);
// }
//
// /**
// * post file RxJava形式
// * @param url
// * @param filePath
// * @return
// */
// public static <T> Flowable<T> uploadFile(String url, String filePath, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().uploadFile(url, filePath, converter);
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/converter/RxEasyCustomConverter.java
// public abstract class RxEasyCustomConverter<T> implements RxEasyConverter<T> {
//
// @Override
// public T convert(String body) throws Exception {
// Class clazz = this.getClass();
// Type superClassType = clazz.getGenericSuperclass();
// Type tArg = ((ParameterizedType) superClassType).getActualTypeArguments()[0];
// Gson gson = EasyHttpClientManager.getInstance().getGson();
// return gson.fromJson(body, tArg);
// }
// }
// Path: sample/src/main/java/com/yang/demo/activity/RxPostActivity.java
import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.yang.demo.R;
import com.yang.demo.entity.PostEntity;
import com.yang.easyhttp.request.EasyRequestParams;
import com.yang.easyhttprx.RxEasyHttp;
import com.yang.easyhttprx.converter.RxEasyCustomConverter;
import org.reactivestreams.Subscription;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.FlowableSubscriber;
import io.reactivex.android.schedulers.AndroidSchedulers;
package com.yang.demo.activity;
/**
* Created by yangyang on 2017/2/17.
*/
public class RxPostActivity extends AppCompatActivity {
@BindView(R.id.comment)
EditText comment;
@BindView(R.id.submit)
Button submit;
@BindView(R.id.result)
TextView result;
ProgressDialog dialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.post_main);
ButterKnife.bind(this);
dialog = new ProgressDialog(this);
}
@OnClick(R.id.submit)
public void submit() {
Editable content = comment.getText();
if (TextUtils.isEmpty(content)) {
Toast.makeText(this, "comment is empty", Toast.LENGTH_SHORT);
return;
}
EasyRequestParams params = new EasyRequestParams();
params.put("content", content.toString());
String url = "http://book.km.com/app/index.php?c=version&a=feedback";
| RxEasyHttp.post(url, params, new RxEasyCustomConverter<PostEntity>() { |
LaurenceYang/EasyHttp | sample/src/main/java/com/yang/demo/activity/RxPostActivity.java | // Path: sample/src/main/java/com/yang/demo/entity/PostEntity.java
// public class PostEntity {
// int status;
// String message;
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
//
// Path: easy-http-library/src/main/java/com/yang/easyhttp/request/EasyRequestParams.java
// public class EasyRequestParams {
// private ConcurrentHashMap<String, String> mRequestParams = new ConcurrentHashMap<>();
// private ConcurrentHashMap<String, String> mRequestHeaders = new ConcurrentHashMap<>();
//
//
// public void put(String key, String value) {
// if (key != null && value != null) {
// mRequestParams.put(key, value);
// }
// }
//
// public ConcurrentHashMap<String, String> getRequestParams() {
// return mRequestParams;
// }
//
// public void addHeader(String key, String value) {
// if (key != null && value != null) {
// mRequestHeaders.put(key, value);
// }
// }
//
// public ConcurrentHashMap<String, String> getRequestHeaders() {
// return mRequestHeaders;
// }
//
// @Override
// public String toString() {
// StringBuilder result = new StringBuilder();
// for (ConcurrentHashMap.Entry<String, String> entry : mRequestParams.entrySet()) {
// if (result.length() > 0)
// result.append("&");
//
// result.append(entry.getKey());
// result.append("=");
// result.append(entry.getValue());
// }
// return result.toString();
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/RxEasyHttp.java
// public class RxEasyHttp {
// /**
// * Get请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> get(String url, RxEasyConverter<T> converter) {
// return get(url, null, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, EasyCacheType.CACHE_TYPE_NO_SETTING, converter);
// }
//
// public static <T> Flowable<T> get(String url, int cacheType, RxEasyConverter<T> converter) {
// return get(url, null, cacheType, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, int cacheType, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, cacheType, converter);
// }
//
// /**
// * Post请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> post(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().post(url, easyRequestParams, converter);
// }
//
// /**
// * post file RxJava形式
// * @param url
// * @param filePath
// * @return
// */
// public static <T> Flowable<T> uploadFile(String url, String filePath, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().uploadFile(url, filePath, converter);
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/converter/RxEasyCustomConverter.java
// public abstract class RxEasyCustomConverter<T> implements RxEasyConverter<T> {
//
// @Override
// public T convert(String body) throws Exception {
// Class clazz = this.getClass();
// Type superClassType = clazz.getGenericSuperclass();
// Type tArg = ((ParameterizedType) superClassType).getActualTypeArguments()[0];
// Gson gson = EasyHttpClientManager.getInstance().getGson();
// return gson.fromJson(body, tArg);
// }
// }
| import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.yang.demo.R;
import com.yang.demo.entity.PostEntity;
import com.yang.easyhttp.request.EasyRequestParams;
import com.yang.easyhttprx.RxEasyHttp;
import com.yang.easyhttprx.converter.RxEasyCustomConverter;
import org.reactivestreams.Subscription;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.FlowableSubscriber;
import io.reactivex.android.schedulers.AndroidSchedulers; | package com.yang.demo.activity;
/**
* Created by yangyang on 2017/2/17.
*/
public class RxPostActivity extends AppCompatActivity {
@BindView(R.id.comment)
EditText comment;
@BindView(R.id.submit)
Button submit;
@BindView(R.id.result)
TextView result;
ProgressDialog dialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.post_main);
ButterKnife.bind(this);
dialog = new ProgressDialog(this);
}
@OnClick(R.id.submit)
public void submit() {
Editable content = comment.getText();
if (TextUtils.isEmpty(content)) {
Toast.makeText(this, "comment is empty", Toast.LENGTH_SHORT);
return;
}
EasyRequestParams params = new EasyRequestParams();
params.put("content", content.toString());
String url = "http://book.km.com/app/index.php?c=version&a=feedback";
| // Path: sample/src/main/java/com/yang/demo/entity/PostEntity.java
// public class PostEntity {
// int status;
// String message;
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
//
// Path: easy-http-library/src/main/java/com/yang/easyhttp/request/EasyRequestParams.java
// public class EasyRequestParams {
// private ConcurrentHashMap<String, String> mRequestParams = new ConcurrentHashMap<>();
// private ConcurrentHashMap<String, String> mRequestHeaders = new ConcurrentHashMap<>();
//
//
// public void put(String key, String value) {
// if (key != null && value != null) {
// mRequestParams.put(key, value);
// }
// }
//
// public ConcurrentHashMap<String, String> getRequestParams() {
// return mRequestParams;
// }
//
// public void addHeader(String key, String value) {
// if (key != null && value != null) {
// mRequestHeaders.put(key, value);
// }
// }
//
// public ConcurrentHashMap<String, String> getRequestHeaders() {
// return mRequestHeaders;
// }
//
// @Override
// public String toString() {
// StringBuilder result = new StringBuilder();
// for (ConcurrentHashMap.Entry<String, String> entry : mRequestParams.entrySet()) {
// if (result.length() > 0)
// result.append("&");
//
// result.append(entry.getKey());
// result.append("=");
// result.append(entry.getValue());
// }
// return result.toString();
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/RxEasyHttp.java
// public class RxEasyHttp {
// /**
// * Get请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> get(String url, RxEasyConverter<T> converter) {
// return get(url, null, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, EasyCacheType.CACHE_TYPE_NO_SETTING, converter);
// }
//
// public static <T> Flowable<T> get(String url, int cacheType, RxEasyConverter<T> converter) {
// return get(url, null, cacheType, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, int cacheType, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, cacheType, converter);
// }
//
// /**
// * Post请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> post(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().post(url, easyRequestParams, converter);
// }
//
// /**
// * post file RxJava形式
// * @param url
// * @param filePath
// * @return
// */
// public static <T> Flowable<T> uploadFile(String url, String filePath, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().uploadFile(url, filePath, converter);
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/converter/RxEasyCustomConverter.java
// public abstract class RxEasyCustomConverter<T> implements RxEasyConverter<T> {
//
// @Override
// public T convert(String body) throws Exception {
// Class clazz = this.getClass();
// Type superClassType = clazz.getGenericSuperclass();
// Type tArg = ((ParameterizedType) superClassType).getActualTypeArguments()[0];
// Gson gson = EasyHttpClientManager.getInstance().getGson();
// return gson.fromJson(body, tArg);
// }
// }
// Path: sample/src/main/java/com/yang/demo/activity/RxPostActivity.java
import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.yang.demo.R;
import com.yang.demo.entity.PostEntity;
import com.yang.easyhttp.request.EasyRequestParams;
import com.yang.easyhttprx.RxEasyHttp;
import com.yang.easyhttprx.converter.RxEasyCustomConverter;
import org.reactivestreams.Subscription;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.FlowableSubscriber;
import io.reactivex.android.schedulers.AndroidSchedulers;
package com.yang.demo.activity;
/**
* Created by yangyang on 2017/2/17.
*/
public class RxPostActivity extends AppCompatActivity {
@BindView(R.id.comment)
EditText comment;
@BindView(R.id.submit)
Button submit;
@BindView(R.id.result)
TextView result;
ProgressDialog dialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.post_main);
ButterKnife.bind(this);
dialog = new ProgressDialog(this);
}
@OnClick(R.id.submit)
public void submit() {
Editable content = comment.getText();
if (TextUtils.isEmpty(content)) {
Toast.makeText(this, "comment is empty", Toast.LENGTH_SHORT);
return;
}
EasyRequestParams params = new EasyRequestParams();
params.put("content", content.toString());
String url = "http://book.km.com/app/index.php?c=version&a=feedback";
| RxEasyHttp.post(url, params, new RxEasyCustomConverter<PostEntity>() { |
LaurenceYang/EasyHttp | sample/src/main/java/com/yang/demo/activity/RxPostActivity.java | // Path: sample/src/main/java/com/yang/demo/entity/PostEntity.java
// public class PostEntity {
// int status;
// String message;
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
//
// Path: easy-http-library/src/main/java/com/yang/easyhttp/request/EasyRequestParams.java
// public class EasyRequestParams {
// private ConcurrentHashMap<String, String> mRequestParams = new ConcurrentHashMap<>();
// private ConcurrentHashMap<String, String> mRequestHeaders = new ConcurrentHashMap<>();
//
//
// public void put(String key, String value) {
// if (key != null && value != null) {
// mRequestParams.put(key, value);
// }
// }
//
// public ConcurrentHashMap<String, String> getRequestParams() {
// return mRequestParams;
// }
//
// public void addHeader(String key, String value) {
// if (key != null && value != null) {
// mRequestHeaders.put(key, value);
// }
// }
//
// public ConcurrentHashMap<String, String> getRequestHeaders() {
// return mRequestHeaders;
// }
//
// @Override
// public String toString() {
// StringBuilder result = new StringBuilder();
// for (ConcurrentHashMap.Entry<String, String> entry : mRequestParams.entrySet()) {
// if (result.length() > 0)
// result.append("&");
//
// result.append(entry.getKey());
// result.append("=");
// result.append(entry.getValue());
// }
// return result.toString();
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/RxEasyHttp.java
// public class RxEasyHttp {
// /**
// * Get请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> get(String url, RxEasyConverter<T> converter) {
// return get(url, null, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, EasyCacheType.CACHE_TYPE_NO_SETTING, converter);
// }
//
// public static <T> Flowable<T> get(String url, int cacheType, RxEasyConverter<T> converter) {
// return get(url, null, cacheType, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, int cacheType, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, cacheType, converter);
// }
//
// /**
// * Post请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> post(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().post(url, easyRequestParams, converter);
// }
//
// /**
// * post file RxJava形式
// * @param url
// * @param filePath
// * @return
// */
// public static <T> Flowable<T> uploadFile(String url, String filePath, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().uploadFile(url, filePath, converter);
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/converter/RxEasyCustomConverter.java
// public abstract class RxEasyCustomConverter<T> implements RxEasyConverter<T> {
//
// @Override
// public T convert(String body) throws Exception {
// Class clazz = this.getClass();
// Type superClassType = clazz.getGenericSuperclass();
// Type tArg = ((ParameterizedType) superClassType).getActualTypeArguments()[0];
// Gson gson = EasyHttpClientManager.getInstance().getGson();
// return gson.fromJson(body, tArg);
// }
// }
| import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.yang.demo.R;
import com.yang.demo.entity.PostEntity;
import com.yang.easyhttp.request.EasyRequestParams;
import com.yang.easyhttprx.RxEasyHttp;
import com.yang.easyhttprx.converter.RxEasyCustomConverter;
import org.reactivestreams.Subscription;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.FlowableSubscriber;
import io.reactivex.android.schedulers.AndroidSchedulers; | package com.yang.demo.activity;
/**
* Created by yangyang on 2017/2/17.
*/
public class RxPostActivity extends AppCompatActivity {
@BindView(R.id.comment)
EditText comment;
@BindView(R.id.submit)
Button submit;
@BindView(R.id.result)
TextView result;
ProgressDialog dialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.post_main);
ButterKnife.bind(this);
dialog = new ProgressDialog(this);
}
@OnClick(R.id.submit)
public void submit() {
Editable content = comment.getText();
if (TextUtils.isEmpty(content)) {
Toast.makeText(this, "comment is empty", Toast.LENGTH_SHORT);
return;
}
EasyRequestParams params = new EasyRequestParams();
params.put("content", content.toString());
String url = "http://book.km.com/app/index.php?c=version&a=feedback";
| // Path: sample/src/main/java/com/yang/demo/entity/PostEntity.java
// public class PostEntity {
// int status;
// String message;
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
//
// Path: easy-http-library/src/main/java/com/yang/easyhttp/request/EasyRequestParams.java
// public class EasyRequestParams {
// private ConcurrentHashMap<String, String> mRequestParams = new ConcurrentHashMap<>();
// private ConcurrentHashMap<String, String> mRequestHeaders = new ConcurrentHashMap<>();
//
//
// public void put(String key, String value) {
// if (key != null && value != null) {
// mRequestParams.put(key, value);
// }
// }
//
// public ConcurrentHashMap<String, String> getRequestParams() {
// return mRequestParams;
// }
//
// public void addHeader(String key, String value) {
// if (key != null && value != null) {
// mRequestHeaders.put(key, value);
// }
// }
//
// public ConcurrentHashMap<String, String> getRequestHeaders() {
// return mRequestHeaders;
// }
//
// @Override
// public String toString() {
// StringBuilder result = new StringBuilder();
// for (ConcurrentHashMap.Entry<String, String> entry : mRequestParams.entrySet()) {
// if (result.length() > 0)
// result.append("&");
//
// result.append(entry.getKey());
// result.append("=");
// result.append(entry.getValue());
// }
// return result.toString();
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/RxEasyHttp.java
// public class RxEasyHttp {
// /**
// * Get请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> get(String url, RxEasyConverter<T> converter) {
// return get(url, null, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, EasyCacheType.CACHE_TYPE_NO_SETTING, converter);
// }
//
// public static <T> Flowable<T> get(String url, int cacheType, RxEasyConverter<T> converter) {
// return get(url, null, cacheType, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, int cacheType, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, cacheType, converter);
// }
//
// /**
// * Post请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> post(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().post(url, easyRequestParams, converter);
// }
//
// /**
// * post file RxJava形式
// * @param url
// * @param filePath
// * @return
// */
// public static <T> Flowable<T> uploadFile(String url, String filePath, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().uploadFile(url, filePath, converter);
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/converter/RxEasyCustomConverter.java
// public abstract class RxEasyCustomConverter<T> implements RxEasyConverter<T> {
//
// @Override
// public T convert(String body) throws Exception {
// Class clazz = this.getClass();
// Type superClassType = clazz.getGenericSuperclass();
// Type tArg = ((ParameterizedType) superClassType).getActualTypeArguments()[0];
// Gson gson = EasyHttpClientManager.getInstance().getGson();
// return gson.fromJson(body, tArg);
// }
// }
// Path: sample/src/main/java/com/yang/demo/activity/RxPostActivity.java
import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.yang.demo.R;
import com.yang.demo.entity.PostEntity;
import com.yang.easyhttp.request.EasyRequestParams;
import com.yang.easyhttprx.RxEasyHttp;
import com.yang.easyhttprx.converter.RxEasyCustomConverter;
import org.reactivestreams.Subscription;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.FlowableSubscriber;
import io.reactivex.android.schedulers.AndroidSchedulers;
package com.yang.demo.activity;
/**
* Created by yangyang on 2017/2/17.
*/
public class RxPostActivity extends AppCompatActivity {
@BindView(R.id.comment)
EditText comment;
@BindView(R.id.submit)
Button submit;
@BindView(R.id.result)
TextView result;
ProgressDialog dialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.post_main);
ButterKnife.bind(this);
dialog = new ProgressDialog(this);
}
@OnClick(R.id.submit)
public void submit() {
Editable content = comment.getText();
if (TextUtils.isEmpty(content)) {
Toast.makeText(this, "comment is empty", Toast.LENGTH_SHORT);
return;
}
EasyRequestParams params = new EasyRequestParams();
params.put("content", content.toString());
String url = "http://book.km.com/app/index.php?c=version&a=feedback";
| RxEasyHttp.post(url, params, new RxEasyCustomConverter<PostEntity>() { |
LaurenceYang/EasyHttp | sample/src/main/java/com/yang/demo/activity/RxGetActivity.java | // Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/RxEasyHttp.java
// public class RxEasyHttp {
// /**
// * Get请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> get(String url, RxEasyConverter<T> converter) {
// return get(url, null, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, EasyCacheType.CACHE_TYPE_NO_SETTING, converter);
// }
//
// public static <T> Flowable<T> get(String url, int cacheType, RxEasyConverter<T> converter) {
// return get(url, null, cacheType, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, int cacheType, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, cacheType, converter);
// }
//
// /**
// * Post请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> post(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().post(url, easyRequestParams, converter);
// }
//
// /**
// * post file RxJava形式
// * @param url
// * @param filePath
// * @return
// */
// public static <T> Flowable<T> uploadFile(String url, String filePath, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().uploadFile(url, filePath, converter);
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/converter/RxEasyStringConverter.java
// public class RxEasyStringConverter implements RxEasyConverter<String> {
// @Override
// public String convert(String body) throws Exception {
// return body;
// }
//
// @Override
// public void doNothing() {
//
// }
// }
| import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.yang.demo.R;
import com.yang.easyhttprx.RxEasyHttp;
import com.yang.easyhttprx.converter.RxEasyStringConverter;
import org.reactivestreams.Subscription;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.FlowableSubscriber;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer; | package com.yang.demo.activity;
/**
* Created by yangyang on 2017/2/17.
*/
public class RxGetActivity extends AppCompatActivity {
@BindView(R.id.url)
EditText urlView;
@BindView(R.id.go)
Button go;
@BindView(R.id.body)
TextView body;
ProgressDialog dialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.get_main);
ButterKnife.bind(this);
dialog = new ProgressDialog(this);
}
@OnClick(R.id.go)
public void go() {
Editable url = urlView.getText();
if (TextUtils.isEmpty(url)) {
Toast.makeText(this, "url is empty", Toast.LENGTH_SHORT);
return;
}
| // Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/RxEasyHttp.java
// public class RxEasyHttp {
// /**
// * Get请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> get(String url, RxEasyConverter<T> converter) {
// return get(url, null, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, EasyCacheType.CACHE_TYPE_NO_SETTING, converter);
// }
//
// public static <T> Flowable<T> get(String url, int cacheType, RxEasyConverter<T> converter) {
// return get(url, null, cacheType, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, int cacheType, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, cacheType, converter);
// }
//
// /**
// * Post请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> post(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().post(url, easyRequestParams, converter);
// }
//
// /**
// * post file RxJava形式
// * @param url
// * @param filePath
// * @return
// */
// public static <T> Flowable<T> uploadFile(String url, String filePath, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().uploadFile(url, filePath, converter);
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/converter/RxEasyStringConverter.java
// public class RxEasyStringConverter implements RxEasyConverter<String> {
// @Override
// public String convert(String body) throws Exception {
// return body;
// }
//
// @Override
// public void doNothing() {
//
// }
// }
// Path: sample/src/main/java/com/yang/demo/activity/RxGetActivity.java
import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.yang.demo.R;
import com.yang.easyhttprx.RxEasyHttp;
import com.yang.easyhttprx.converter.RxEasyStringConverter;
import org.reactivestreams.Subscription;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.FlowableSubscriber;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;
package com.yang.demo.activity;
/**
* Created by yangyang on 2017/2/17.
*/
public class RxGetActivity extends AppCompatActivity {
@BindView(R.id.url)
EditText urlView;
@BindView(R.id.go)
Button go;
@BindView(R.id.body)
TextView body;
ProgressDialog dialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.get_main);
ButterKnife.bind(this);
dialog = new ProgressDialog(this);
}
@OnClick(R.id.go)
public void go() {
Editable url = urlView.getText();
if (TextUtils.isEmpty(url)) {
Toast.makeText(this, "url is empty", Toast.LENGTH_SHORT);
return;
}
| RxEasyHttp.get(url.toString(), new RxEasyStringConverter()) |
LaurenceYang/EasyHttp | sample/src/main/java/com/yang/demo/activity/RxGetActivity.java | // Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/RxEasyHttp.java
// public class RxEasyHttp {
// /**
// * Get请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> get(String url, RxEasyConverter<T> converter) {
// return get(url, null, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, EasyCacheType.CACHE_TYPE_NO_SETTING, converter);
// }
//
// public static <T> Flowable<T> get(String url, int cacheType, RxEasyConverter<T> converter) {
// return get(url, null, cacheType, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, int cacheType, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, cacheType, converter);
// }
//
// /**
// * Post请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> post(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().post(url, easyRequestParams, converter);
// }
//
// /**
// * post file RxJava形式
// * @param url
// * @param filePath
// * @return
// */
// public static <T> Flowable<T> uploadFile(String url, String filePath, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().uploadFile(url, filePath, converter);
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/converter/RxEasyStringConverter.java
// public class RxEasyStringConverter implements RxEasyConverter<String> {
// @Override
// public String convert(String body) throws Exception {
// return body;
// }
//
// @Override
// public void doNothing() {
//
// }
// }
| import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.yang.demo.R;
import com.yang.easyhttprx.RxEasyHttp;
import com.yang.easyhttprx.converter.RxEasyStringConverter;
import org.reactivestreams.Subscription;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.FlowableSubscriber;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer; | package com.yang.demo.activity;
/**
* Created by yangyang on 2017/2/17.
*/
public class RxGetActivity extends AppCompatActivity {
@BindView(R.id.url)
EditText urlView;
@BindView(R.id.go)
Button go;
@BindView(R.id.body)
TextView body;
ProgressDialog dialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.get_main);
ButterKnife.bind(this);
dialog = new ProgressDialog(this);
}
@OnClick(R.id.go)
public void go() {
Editable url = urlView.getText();
if (TextUtils.isEmpty(url)) {
Toast.makeText(this, "url is empty", Toast.LENGTH_SHORT);
return;
}
| // Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/RxEasyHttp.java
// public class RxEasyHttp {
// /**
// * Get请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> get(String url, RxEasyConverter<T> converter) {
// return get(url, null, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, EasyCacheType.CACHE_TYPE_NO_SETTING, converter);
// }
//
// public static <T> Flowable<T> get(String url, int cacheType, RxEasyConverter<T> converter) {
// return get(url, null, cacheType, converter);
// }
//
// public static <T> Flowable<T> get(String url, EasyRequestParams easyRequestParams, int cacheType, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().get(url, easyRequestParams, cacheType, converter);
// }
//
// /**
// * Post请求RxJava形式
// * @param url
// * @return
// */
// public static <T> Flowable<T> post(String url, EasyRequestParams easyRequestParams, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().post(url, easyRequestParams, converter);
// }
//
// /**
// * post file RxJava形式
// * @param url
// * @param filePath
// * @return
// */
// public static <T> Flowable<T> uploadFile(String url, String filePath, RxEasyConverter<T> converter) {
// return RxEasyHttpManager.getInstance().uploadFile(url, filePath, converter);
// }
// }
//
// Path: easy-http-library-rx/src/main/java/com/yang/easyhttprx/converter/RxEasyStringConverter.java
// public class RxEasyStringConverter implements RxEasyConverter<String> {
// @Override
// public String convert(String body) throws Exception {
// return body;
// }
//
// @Override
// public void doNothing() {
//
// }
// }
// Path: sample/src/main/java/com/yang/demo/activity/RxGetActivity.java
import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.yang.demo.R;
import com.yang.easyhttprx.RxEasyHttp;
import com.yang.easyhttprx.converter.RxEasyStringConverter;
import org.reactivestreams.Subscription;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.FlowableSubscriber;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;
package com.yang.demo.activity;
/**
* Created by yangyang on 2017/2/17.
*/
public class RxGetActivity extends AppCompatActivity {
@BindView(R.id.url)
EditText urlView;
@BindView(R.id.go)
Button go;
@BindView(R.id.body)
TextView body;
ProgressDialog dialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.get_main);
ButterKnife.bind(this);
dialog = new ProgressDialog(this);
}
@OnClick(R.id.go)
public void go() {
Editable url = urlView.getText();
if (TextUtils.isEmpty(url)) {
Toast.makeText(this, "url is empty", Toast.LENGTH_SHORT);
return;
}
| RxEasyHttp.get(url.toString(), new RxEasyStringConverter()) |
BoD/android-contentprovider-generator | acpg-lib/src/main/java/org/jraf/acpg/lib/model/Field.java | // Path: acpg-lib/src/main/java/org/jraf/acpg/lib/GeneratorException.java
// public class GeneratorException extends Exception {
// public GeneratorException(String message) {
// super(message);
// }
//
// public GeneratorException(String message, Throwable cause) {
// super(message, cause);
// }
// }
| import org.apache.commons.lang.WordUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jraf.acpg.lib.GeneratorException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale; | private static final String ON_DELETE_ACTION_SET_DEFAULT = "SET DEFAULT";
private static final String ON_DELETE_ACTION_CASCADE = "CASCADE";
public enum Type {
// @formatter:off
STRING(TYPE_STRING, "TEXT", String.class, String.class),
INTEGER(TYPE_INTEGER, "INTEGER", Integer.class, int.class),
LONG(TYPE_LONG, "INTEGER", Long.class, long.class),
FLOAT(TYPE_FLOAT, "REAL", Float.class, float.class),
DOUBLE(TYPE_DOUBLE, "REAL", Double.class, double.class),
BOOLEAN(TYPE_BOOLEAN, "INTEGER", Boolean.class, boolean.class),
DATE(TYPE_DATE, "INTEGER", Date.class, Date.class),
BYTE_ARRAY(TYPE_BYTE_ARRAY, "BLOB", byte[].class, byte[].class),
ENUM(TYPE_ENUM, "INTEGER", null, null),
// @formatter:on
;
private String mJsonName;
private String mSqlType;
private Class<?> mNullableJavaType;
private Class<?> mNotNullableJavaType;
private Type(String jsonName, String sqlType, Class<?> nullableJavaType, Class<?> notNullableJavaType) {
mJsonName = jsonName;
mSqlType = sqlType;
mNullableJavaType = nullableJavaType;
mNotNullableJavaType = notNullableJavaType;
sTypeJsonNames.put(jsonName, this);
}
| // Path: acpg-lib/src/main/java/org/jraf/acpg/lib/GeneratorException.java
// public class GeneratorException extends Exception {
// public GeneratorException(String message) {
// super(message);
// }
//
// public GeneratorException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: acpg-lib/src/main/java/org/jraf/acpg/lib/model/Field.java
import org.apache.commons.lang.WordUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jraf.acpg.lib.GeneratorException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
private static final String ON_DELETE_ACTION_SET_DEFAULT = "SET DEFAULT";
private static final String ON_DELETE_ACTION_CASCADE = "CASCADE";
public enum Type {
// @formatter:off
STRING(TYPE_STRING, "TEXT", String.class, String.class),
INTEGER(TYPE_INTEGER, "INTEGER", Integer.class, int.class),
LONG(TYPE_LONG, "INTEGER", Long.class, long.class),
FLOAT(TYPE_FLOAT, "REAL", Float.class, float.class),
DOUBLE(TYPE_DOUBLE, "REAL", Double.class, double.class),
BOOLEAN(TYPE_BOOLEAN, "INTEGER", Boolean.class, boolean.class),
DATE(TYPE_DATE, "INTEGER", Date.class, Date.class),
BYTE_ARRAY(TYPE_BYTE_ARRAY, "BLOB", byte[].class, byte[].class),
ENUM(TYPE_ENUM, "INTEGER", null, null),
// @formatter:on
;
private String mJsonName;
private String mSqlType;
private Class<?> mNullableJavaType;
private Class<?> mNotNullableJavaType;
private Type(String jsonName, String sqlType, Class<?> nullableJavaType, Class<?> notNullableJavaType) {
mJsonName = jsonName;
mSqlType = sqlType;
mNullableJavaType = nullableJavaType;
mNotNullableJavaType = notNullableJavaType;
sTypeJsonNames.put(jsonName, this);
}
| public static Type fromJsonName(String jsonName) throws GeneratorException { |
BoD/android-contentprovider-generator | acpg-lib/src/main/java/org/jraf/acpg/lib/model/Model.java | // Path: acpg-lib/src/main/java/org/jraf/acpg/lib/GeneratorException.java
// public class GeneratorException extends Exception {
// public GeneratorException(String message) {
// super(message);
// }
//
// public GeneratorException(String message, Throwable cause) {
// super(message, cause);
// }
// }
| import org.jraf.acpg.lib.GeneratorException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; | /*
* This source is part of the
* _____ ___ ____
* __ / / _ \/ _ | / __/___ _______ _
* / // / , _/ __ |/ _/_/ _ \/ __/ _ `/
* \___/_/|_/_/ |_/_/ (_)___/_/ \_, /
* /___/
* repository.
*
* Copyright (C) 2012-2017 Benoit 'BoD' Lubek (BoD@JRAF.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.jraf.acpg.lib.model;
public class Model {
private static final Logger LOG = LogManager.getLogger(Model.class);
private final List<Entity> mEntities = new ArrayList<Entity>();
private String mHeader;
public void addEntity(Entity entity) {
mEntities.add(entity);
}
public List<Entity> getEntities() {
return Collections.unmodifiableList(mEntities);
}
public void setHeader(String header) {
mHeader = header;
}
public String getHeader() {
return mHeader;
}
@Override
public String toString() {
return mEntities.toString();
}
| // Path: acpg-lib/src/main/java/org/jraf/acpg/lib/GeneratorException.java
// public class GeneratorException extends Exception {
// public GeneratorException(String message) {
// super(message);
// }
//
// public GeneratorException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: acpg-lib/src/main/java/org/jraf/acpg/lib/model/Model.java
import org.jraf.acpg.lib.GeneratorException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/*
* This source is part of the
* _____ ___ ____
* __ / / _ \/ _ | / __/___ _______ _
* / // / , _/ __ |/ _/_/ _ \/ __/ _ `/
* \___/_/|_/_/ |_/_/ (_)___/_/ \_, /
* /___/
* repository.
*
* Copyright (C) 2012-2017 Benoit 'BoD' Lubek (BoD@JRAF.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.jraf.acpg.lib.model;
public class Model {
private static final Logger LOG = LogManager.getLogger(Model.class);
private final List<Entity> mEntities = new ArrayList<Entity>();
private String mHeader;
public void addEntity(Entity entity) {
mEntities.add(entity);
}
public List<Entity> getEntities() {
return Collections.unmodifiableList(mEntities);
}
public void setHeader(String header) {
mHeader = header;
}
public String getHeader() {
return mHeader;
}
@Override
public String toString() {
return mEntities.toString();
}
| public void flagAmbiguousFields() throws GeneratorException { |
BoD/android-contentprovider-generator | acpg-lib/src/main/java/org/jraf/acpg/lib/config/ConfigParser.java | // Path: acpg-lib/src/main/java/org/jraf/acpg/lib/GeneratorException.java
// public class GeneratorException extends Exception {
// public GeneratorException(String message) {
// super(message);
// }
//
// public GeneratorException(String message, Throwable cause) {
// super(message, cause);
// }
// }
| import org.jraf.acpg.lib.GeneratorException;
import java.io.File;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.fasterxml.jackson.databind.ObjectMapper; | /*
* This source is part of the
* _____ ___ ____
* __ / / _ \/ _ | / __/___ _______ _
* / // / , _/ __ |/ _/_/ _ \/ __/ _ `/
* \___/_/|_/_/ |_/_/ (_)___/_/ \_, /
* /___/
* repository.
*
* Copyright (C) 2012-2017 Benoit 'BoD' Lubek (BoD@JRAF.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.jraf.acpg.lib.config;
public class ConfigParser {
private static final Logger LOG = LogManager.getLogger(ConfigParser.class);
private static final int SYNTAX_VERSION = 4;
| // Path: acpg-lib/src/main/java/org/jraf/acpg/lib/GeneratorException.java
// public class GeneratorException extends Exception {
// public GeneratorException(String message) {
// super(message);
// }
//
// public GeneratorException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: acpg-lib/src/main/java/org/jraf/acpg/lib/config/ConfigParser.java
import org.jraf.acpg.lib.GeneratorException;
import java.io.File;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.fasterxml.jackson.databind.ObjectMapper;
/*
* This source is part of the
* _____ ___ ____
* __ / / _ \/ _ | / __/___ _______ _
* / // / , _/ __ |/ _/_/ _ \/ __/ _ `/
* \___/_/|_/_/ |_/_/ (_)___/_/ \_, /
* /___/
* repository.
*
* Copyright (C) 2012-2017 Benoit 'BoD' Lubek (BoD@JRAF.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.jraf.acpg.lib.config;
public class ConfigParser {
private static final Logger LOG = LogManager.getLogger(ConfigParser.class);
private static final int SYNTAX_VERSION = 4;
| public Config parseConfig(File configFile) throws GeneratorException { |
BoD/android-contentprovider-generator | acpg-lib/src/main/java/org/jraf/acpg/lib/model/Entity.java | // Path: acpg-lib/src/main/java/org/jraf/acpg/lib/GeneratorException.java
// public class GeneratorException extends Exception {
// public GeneratorException(String message) {
// super(message);
// }
//
// public GeneratorException(String message, Throwable cause) {
// super(message, cause);
// }
// }
| import org.apache.commons.lang.WordUtils;
import org.jraf.acpg.lib.GeneratorException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map; | private static final String DOT = "\".\"";
private static final String AS = "\" AS \"";
private static final String PREFIX = ".PREFIX_";
private static final Map<String, Entity> ALL_ENTITIES = new HashMap<>();
private final String mName;
private final List<Field> mFields = new ArrayList<>();
private final List<Constraint> mConstraints = new ArrayList<>();
private final String mDocumentation;
private final List<SortOrder> mSortOrders = new ArrayList<>();
public Entity(String name, String documentation) {
mName = name;
mDocumentation = documentation;
ALL_ENTITIES.put(name, this);
}
public void addField(Field field) {
mFields.add(field);
}
public void addField(int index, Field field) {
mFields.add(index, field);
}
public List<Field> getFields() {
return Collections.unmodifiableList(mFields);
}
| // Path: acpg-lib/src/main/java/org/jraf/acpg/lib/GeneratorException.java
// public class GeneratorException extends Exception {
// public GeneratorException(String message) {
// super(message);
// }
//
// public GeneratorException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: acpg-lib/src/main/java/org/jraf/acpg/lib/model/Entity.java
import org.apache.commons.lang.WordUtils;
import org.jraf.acpg.lib.GeneratorException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
private static final String DOT = "\".\"";
private static final String AS = "\" AS \"";
private static final String PREFIX = ".PREFIX_";
private static final Map<String, Entity> ALL_ENTITIES = new HashMap<>();
private final String mName;
private final List<Field> mFields = new ArrayList<>();
private final List<Constraint> mConstraints = new ArrayList<>();
private final String mDocumentation;
private final List<SortOrder> mSortOrders = new ArrayList<>();
public Entity(String name, String documentation) {
mName = name;
mDocumentation = documentation;
ALL_ENTITIES.put(name, this);
}
public void addField(Field field) {
mFields.add(field);
}
public void addField(int index, Field field) {
mFields.add(index, field);
}
public List<Field> getFields() {
return Collections.unmodifiableList(mFields);
}
| public List<Field> getFieldsIncludingJoins() throws GeneratorException { |
google/thread-weaver | examples/NameManagerTest.java | // Path: main/com/google/testing/threadtester/AnnotatedTestRunner.java
// public class AnnotatedTestRunner extends BaseThreadedTestRunner {
// @Override
// protected String getWrapperName() {
// return AnnotatedTestWrapper.class.getName();
// }
// }
| import com.google.testing.threadtester.AnnotatedTestRunner;
import com.google.testing.threadtester.ThreadedAfter;
import com.google.testing.threadtester.ThreadedBefore;
import com.google.testing.threadtester.ThreadedMain;
import com.google.testing.threadtester.ThreadedSecondary;
import junit.framework.TestCase;
import java.util.Arrays;
import java.util.List; | /*
* Copyright 2009 Weaver authors
*
* This code is part of the Weaver tutorial and may be freely used.
*/
/**
* Unit test for NameManager. Demonstrates use of
* {@link com.google.testing.threadtester.AnnotatedTestRunner}.
*
* @author alasdair.mackintosh@gmail.com (Alasdair Mackintosh)
*/
public class NameManagerTest extends TestCase {
private static final String HELLO = "Hello";
private volatile NameManager nameManager;
public void testPutIfAbsent() {
// Create an AnnotatedTestRunner that will run the threaded tests defined in
// this class. These tests are expected to makes calls to NameManager. | // Path: main/com/google/testing/threadtester/AnnotatedTestRunner.java
// public class AnnotatedTestRunner extends BaseThreadedTestRunner {
// @Override
// protected String getWrapperName() {
// return AnnotatedTestWrapper.class.getName();
// }
// }
// Path: examples/NameManagerTest.java
import com.google.testing.threadtester.AnnotatedTestRunner;
import com.google.testing.threadtester.ThreadedAfter;
import com.google.testing.threadtester.ThreadedBefore;
import com.google.testing.threadtester.ThreadedMain;
import com.google.testing.threadtester.ThreadedSecondary;
import junit.framework.TestCase;
import java.util.Arrays;
import java.util.List;
/*
* Copyright 2009 Weaver authors
*
* This code is part of the Weaver tutorial and may be freely used.
*/
/**
* Unit test for NameManager. Demonstrates use of
* {@link com.google.testing.threadtester.AnnotatedTestRunner}.
*
* @author alasdair.mackintosh@gmail.com (Alasdair Mackintosh)
*/
public class NameManagerTest extends TestCase {
private static final String HELLO = "Hello";
private volatile NameManager nameManager;
public void testPutIfAbsent() {
// Create an AnnotatedTestRunner that will run the threaded tests defined in
// this class. These tests are expected to makes calls to NameManager. | AnnotatedTestRunner runner = new AnnotatedTestRunner(); |
google/thread-weaver | examples/UniqueListTest.java | // Path: main/com/google/testing/threadtester/AnnotatedTestRunner.java
// public class AnnotatedTestRunner extends BaseThreadedTestRunner {
// @Override
// protected String getWrapperName() {
// return AnnotatedTestWrapper.class.getName();
// }
// }
//
// Path: main/com/google/testing/threadtester/MethodOption.java
// public enum MethodOption {
// /**
// * Only the method called directly by the @ThreadedMain method is tested.
// * This is the normal mod of operation.
// */
// MAIN_METHOD (0),
//
// /**
// * All methods in the instrumented classes are tested.
// */
// ALL_METHODS (1),
//
// /**
// * An explicit list of methods is tested.
// */
// LISTED_METHODS (2);
//
// public final int value;
//
// MethodOption(int v) {
// this.value = v;
// }
//
// /**
// * Creates a MethodOption from its integer equivalent.
// */
// static MethodOption fromInt(int v){
// for (MethodOption m: MethodOption.values()) {
// if (m.value == v)
// return m;
// }
// throw new IllegalArgumentException("Invalid value " + v);
// }
// }
| import com.google.testing.threadtester.AnnotatedTestRunner;
import com.google.testing.threadtester.MethodOption;
import com.google.testing.threadtester.ThreadedAfter;
import com.google.testing.threadtester.ThreadedBefore;
import com.google.testing.threadtester.ThreadedMain;
import com.google.testing.threadtester.ThreadedSecondary;
import java.util.HashSet;
import junit.framework.TestCase; | /*
* Copyright 2009 Weaver authors
*
* This code is part of the Weaver tutorial and may be freely used.
*/
/**
* Unit test for UniqueList. Demonstrates use of
* {@link com.google.testing.threadtester.AnnotatedTestRunner}.
*
* NOTE: This test will fail. It was written to demonstrate a fault in the class
* under test.
*
* @author alasdair.mackintosh@gmail.com (Alasdair Mackintosh)
*/
public class UniqueListTest extends TestCase {
private static final String HELLO = "Hello";
private volatile UniqueList<String> uniqueList;
public void testPutIfAbsent() {
System.out.printf("In testPutIfAbsent\n");
// Create an AnnotatedTestRunner that will run the threaded tests defined in this
// class. We want to test the behaviour of the private method "putIfAbsentInternal" so
// we need to specify it by name using runner.setMethodOption() | // Path: main/com/google/testing/threadtester/AnnotatedTestRunner.java
// public class AnnotatedTestRunner extends BaseThreadedTestRunner {
// @Override
// protected String getWrapperName() {
// return AnnotatedTestWrapper.class.getName();
// }
// }
//
// Path: main/com/google/testing/threadtester/MethodOption.java
// public enum MethodOption {
// /**
// * Only the method called directly by the @ThreadedMain method is tested.
// * This is the normal mod of operation.
// */
// MAIN_METHOD (0),
//
// /**
// * All methods in the instrumented classes are tested.
// */
// ALL_METHODS (1),
//
// /**
// * An explicit list of methods is tested.
// */
// LISTED_METHODS (2);
//
// public final int value;
//
// MethodOption(int v) {
// this.value = v;
// }
//
// /**
// * Creates a MethodOption from its integer equivalent.
// */
// static MethodOption fromInt(int v){
// for (MethodOption m: MethodOption.values()) {
// if (m.value == v)
// return m;
// }
// throw new IllegalArgumentException("Invalid value " + v);
// }
// }
// Path: examples/UniqueListTest.java
import com.google.testing.threadtester.AnnotatedTestRunner;
import com.google.testing.threadtester.MethodOption;
import com.google.testing.threadtester.ThreadedAfter;
import com.google.testing.threadtester.ThreadedBefore;
import com.google.testing.threadtester.ThreadedMain;
import com.google.testing.threadtester.ThreadedSecondary;
import java.util.HashSet;
import junit.framework.TestCase;
/*
* Copyright 2009 Weaver authors
*
* This code is part of the Weaver tutorial and may be freely used.
*/
/**
* Unit test for UniqueList. Demonstrates use of
* {@link com.google.testing.threadtester.AnnotatedTestRunner}.
*
* NOTE: This test will fail. It was written to demonstrate a fault in the class
* under test.
*
* @author alasdair.mackintosh@gmail.com (Alasdair Mackintosh)
*/
public class UniqueListTest extends TestCase {
private static final String HELLO = "Hello";
private volatile UniqueList<String> uniqueList;
public void testPutIfAbsent() {
System.out.printf("In testPutIfAbsent\n");
// Create an AnnotatedTestRunner that will run the threaded tests defined in this
// class. We want to test the behaviour of the private method "putIfAbsentInternal" so
// we need to specify it by name using runner.setMethodOption() | AnnotatedTestRunner runner = new AnnotatedTestRunner(); |
google/thread-weaver | examples/UniqueListTest.java | // Path: main/com/google/testing/threadtester/AnnotatedTestRunner.java
// public class AnnotatedTestRunner extends BaseThreadedTestRunner {
// @Override
// protected String getWrapperName() {
// return AnnotatedTestWrapper.class.getName();
// }
// }
//
// Path: main/com/google/testing/threadtester/MethodOption.java
// public enum MethodOption {
// /**
// * Only the method called directly by the @ThreadedMain method is tested.
// * This is the normal mod of operation.
// */
// MAIN_METHOD (0),
//
// /**
// * All methods in the instrumented classes are tested.
// */
// ALL_METHODS (1),
//
// /**
// * An explicit list of methods is tested.
// */
// LISTED_METHODS (2);
//
// public final int value;
//
// MethodOption(int v) {
// this.value = v;
// }
//
// /**
// * Creates a MethodOption from its integer equivalent.
// */
// static MethodOption fromInt(int v){
// for (MethodOption m: MethodOption.values()) {
// if (m.value == v)
// return m;
// }
// throw new IllegalArgumentException("Invalid value " + v);
// }
// }
| import com.google.testing.threadtester.AnnotatedTestRunner;
import com.google.testing.threadtester.MethodOption;
import com.google.testing.threadtester.ThreadedAfter;
import com.google.testing.threadtester.ThreadedBefore;
import com.google.testing.threadtester.ThreadedMain;
import com.google.testing.threadtester.ThreadedSecondary;
import java.util.HashSet;
import junit.framework.TestCase; | /*
* Copyright 2009 Weaver authors
*
* This code is part of the Weaver tutorial and may be freely used.
*/
/**
* Unit test for UniqueList. Demonstrates use of
* {@link com.google.testing.threadtester.AnnotatedTestRunner}.
*
* NOTE: This test will fail. It was written to demonstrate a fault in the class
* under test.
*
* @author alasdair.mackintosh@gmail.com (Alasdair Mackintosh)
*/
public class UniqueListTest extends TestCase {
private static final String HELLO = "Hello";
private volatile UniqueList<String> uniqueList;
public void testPutIfAbsent() {
System.out.printf("In testPutIfAbsent\n");
// Create an AnnotatedTestRunner that will run the threaded tests defined in this
// class. We want to test the behaviour of the private method "putIfAbsentInternal" so
// we need to specify it by name using runner.setMethodOption()
AnnotatedTestRunner runner = new AnnotatedTestRunner();
HashSet<String> methods = new HashSet<String>(); | // Path: main/com/google/testing/threadtester/AnnotatedTestRunner.java
// public class AnnotatedTestRunner extends BaseThreadedTestRunner {
// @Override
// protected String getWrapperName() {
// return AnnotatedTestWrapper.class.getName();
// }
// }
//
// Path: main/com/google/testing/threadtester/MethodOption.java
// public enum MethodOption {
// /**
// * Only the method called directly by the @ThreadedMain method is tested.
// * This is the normal mod of operation.
// */
// MAIN_METHOD (0),
//
// /**
// * All methods in the instrumented classes are tested.
// */
// ALL_METHODS (1),
//
// /**
// * An explicit list of methods is tested.
// */
// LISTED_METHODS (2);
//
// public final int value;
//
// MethodOption(int v) {
// this.value = v;
// }
//
// /**
// * Creates a MethodOption from its integer equivalent.
// */
// static MethodOption fromInt(int v){
// for (MethodOption m: MethodOption.values()) {
// if (m.value == v)
// return m;
// }
// throw new IllegalArgumentException("Invalid value " + v);
// }
// }
// Path: examples/UniqueListTest.java
import com.google.testing.threadtester.AnnotatedTestRunner;
import com.google.testing.threadtester.MethodOption;
import com.google.testing.threadtester.ThreadedAfter;
import com.google.testing.threadtester.ThreadedBefore;
import com.google.testing.threadtester.ThreadedMain;
import com.google.testing.threadtester.ThreadedSecondary;
import java.util.HashSet;
import junit.framework.TestCase;
/*
* Copyright 2009 Weaver authors
*
* This code is part of the Weaver tutorial and may be freely used.
*/
/**
* Unit test for UniqueList. Demonstrates use of
* {@link com.google.testing.threadtester.AnnotatedTestRunner}.
*
* NOTE: This test will fail. It was written to demonstrate a fault in the class
* under test.
*
* @author alasdair.mackintosh@gmail.com (Alasdair Mackintosh)
*/
public class UniqueListTest extends TestCase {
private static final String HELLO = "Hello";
private volatile UniqueList<String> uniqueList;
public void testPutIfAbsent() {
System.out.printf("In testPutIfAbsent\n");
// Create an AnnotatedTestRunner that will run the threaded tests defined in this
// class. We want to test the behaviour of the private method "putIfAbsentInternal" so
// we need to specify it by name using runner.setMethodOption()
AnnotatedTestRunner runner = new AnnotatedTestRunner();
HashSet<String> methods = new HashSet<String>(); | runner.setMethodOption(MethodOption.ALL_METHODS, methods); |
keeps/roda-in | src/main/java/org/roda/rodain/core/sip/SipRepresentation.java | // Path: src/main/java/org/roda/rodain/core/schema/RepresentationContentType.java
// public class RepresentationContentType {
// private String packageType;
// private String value;
// private String otherValue;
//
// public RepresentationContentType(String value) {
// super();
// this.packageType = Constants.SIP_DEFAULT_PACKAGE_TYPE;
// this.value = value;
// this.otherValue = "";
// }
//
// public RepresentationContentType(String packageType, String value) {
// super();
// this.packageType = packageType;
// this.value = value;
// this.otherValue = "";
// }
//
// public RepresentationContentType(RepresentationContentType repContentType) {
// super();
// this.packageType = repContentType.getPackageType();
// this.value = repContentType.getValue();
// this.otherValue = repContentType.getOtherValue();
// }
//
// public String getPackageType() {
// return packageType;
// }
//
// public void setPackageType(String packageType) {
// this.packageType = packageType;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getValue() {
// return value;
// }
//
// public String getOtherValue() {
// return otherValue;
// }
//
// public void setOtherValue(String otherValue) {
// this.otherValue = otherValue;
// }
//
// public static RepresentationContentType defaultRepresentationContentType() {
// return new RepresentationContentType(Constants.SIP_DEFAULT_PACKAGE_TYPE,
// Constants.SIP_DEFAULT_REPRESENTATION_CONTENT_TYPE);
// }
//
// public String asString() {
// return packageType + " - " + value;
// }
//
// public String asStringWithOtherValue() {
// return packageType + " - " + value + " (" + otherValue + ")";
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((otherValue == null) ? 0 : otherValue.hashCode());
// result = prime * result + ((packageType == null) ? 0 : packageType.hashCode());
// result = prime * result + ((value == null) ? 0 : value.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// RepresentationContentType other = (RepresentationContentType) obj;
// if (otherValue == null) {
// if (other.otherValue != null)
// return false;
// } else if (!otherValue.equals(other.otherValue))
// return false;
// if (packageType == null) {
// if (other.packageType != null)
// return false;
// } else if (!packageType.equals(other.packageType))
// return false;
// if (value == null) {
// if (other.value != null)
// return false;
// } else if (!value.equals(other.value))
// return false;
// return true;
// }
//
// }
| import java.nio.file.Path;
import java.util.HashSet;
import java.util.Set;
import org.roda.rodain.core.rules.TreeNode;
import org.roda.rodain.core.schema.RepresentationContentType; | package org.roda.rodain.core.sip;
/**
* @author Andre Pereira apereira@keep.pt
* @since 07-03-2016.
*/
public class SipRepresentation {
private String name; | // Path: src/main/java/org/roda/rodain/core/schema/RepresentationContentType.java
// public class RepresentationContentType {
// private String packageType;
// private String value;
// private String otherValue;
//
// public RepresentationContentType(String value) {
// super();
// this.packageType = Constants.SIP_DEFAULT_PACKAGE_TYPE;
// this.value = value;
// this.otherValue = "";
// }
//
// public RepresentationContentType(String packageType, String value) {
// super();
// this.packageType = packageType;
// this.value = value;
// this.otherValue = "";
// }
//
// public RepresentationContentType(RepresentationContentType repContentType) {
// super();
// this.packageType = repContentType.getPackageType();
// this.value = repContentType.getValue();
// this.otherValue = repContentType.getOtherValue();
// }
//
// public String getPackageType() {
// return packageType;
// }
//
// public void setPackageType(String packageType) {
// this.packageType = packageType;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getValue() {
// return value;
// }
//
// public String getOtherValue() {
// return otherValue;
// }
//
// public void setOtherValue(String otherValue) {
// this.otherValue = otherValue;
// }
//
// public static RepresentationContentType defaultRepresentationContentType() {
// return new RepresentationContentType(Constants.SIP_DEFAULT_PACKAGE_TYPE,
// Constants.SIP_DEFAULT_REPRESENTATION_CONTENT_TYPE);
// }
//
// public String asString() {
// return packageType + " - " + value;
// }
//
// public String asStringWithOtherValue() {
// return packageType + " - " + value + " (" + otherValue + ")";
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((otherValue == null) ? 0 : otherValue.hashCode());
// result = prime * result + ((packageType == null) ? 0 : packageType.hashCode());
// result = prime * result + ((value == null) ? 0 : value.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// RepresentationContentType other = (RepresentationContentType) obj;
// if (otherValue == null) {
// if (other.otherValue != null)
// return false;
// } else if (!otherValue.equals(other.otherValue))
// return false;
// if (packageType == null) {
// if (other.packageType != null)
// return false;
// } else if (!packageType.equals(other.packageType))
// return false;
// if (value == null) {
// if (other.value != null)
// return false;
// } else if (!value.equals(other.value))
// return false;
// return true;
// }
//
// }
// Path: src/main/java/org/roda/rodain/core/sip/SipRepresentation.java
import java.nio.file.Path;
import java.util.HashSet;
import java.util.Set;
import org.roda.rodain.core.rules.TreeNode;
import org.roda.rodain.core.schema.RepresentationContentType;
package org.roda.rodain.core.sip;
/**
* @author Andre Pereira apereira@keep.pt
* @since 07-03-2016.
*/
public class SipRepresentation {
private String name; | private RepresentationContentType type; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.