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
|
---|---|---|---|---|---|---|
onepiecex/mq-aliyun | mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/util/ControllerMethods.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
| import java.io.Serializable;
import com.github.mq.consumer.models.Action; | /**
* Created by wangziqing on 17/06/02.
*/
package com.github.mq.consumer.util;
/**
* Created by wangziqing on 17/7/17.
*/
public class ControllerMethods {
public interface ControllerMethod extends Serializable { }
@FunctionalInterface
public interface ControllerMethod0 extends ControllerMethod { | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/util/ControllerMethods.java
import java.io.Serializable;
import com.github.mq.consumer.models.Action;
/**
* Created by wangziqing on 17/06/02.
*/
package com.github.mq.consumer.util;
/**
* Created by wangziqing on 17/7/17.
*/
public class ControllerMethods {
public interface ControllerMethod extends Serializable { }
@FunctionalInterface
public interface ControllerMethod0 extends ControllerMethod { | Action apply() throws Exception; |
onepiecex/mq-aliyun | mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/ConsumerBuild.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/util/ControllerMethods.java
// public class ControllerMethods {
// public interface ControllerMethod extends Serializable { }
//
//
// @FunctionalInterface
// public interface ControllerMethod0 extends ControllerMethod {
// Action apply() throws Exception;
// }
//
// @FunctionalInterface
// public interface ControllerMethod1<A> extends ControllerMethod {
// Action apply(A a) throws Exception;
// }
//
// @FunctionalInterface
// public interface ControllerMethod2<A,B> extends ControllerMethod {
// Action apply(A a, B b) throws Exception;
// }
// @FunctionalInterface
// public interface ControllerMethod3<A,B,C> extends ControllerMethod {
// Action apply(A a, B b, C c) throws Exception;
// }
//
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/util/WithControllerMethod.java
// public interface WithControllerMethod<T> {
//
// T subscribeTag(String tag, ControllerMethods.ControllerMethod controllerMethod);
//
// default T subscribeTag(String tag, ControllerMethods.ControllerMethod0 controllerMethod) {
// return subscribeTag(tag,(ControllerMethods.ControllerMethod)controllerMethod);
// }
//
// default <A> T subscribeTag(String tag, ControllerMethods.ControllerMethod1<A> controllerMethod) {
// return subscribeTag(tag,(ControllerMethods.ControllerMethod)controllerMethod);
// }
//
// default <A,B> T subscribeTag(String tag, ControllerMethods.ControllerMethod2<A, B> controllerMethod) {
// return subscribeTag(tag,(ControllerMethods.ControllerMethod)controllerMethod);
// }
//
// default <A,B,C> T subscribeTag(String tag, ControllerMethods.ControllerMethod3<A,B,C> controllerMethod) {
// return subscribeTag(tag,(ControllerMethods.ControllerMethod)controllerMethod);
// }
//
// }
| import com.github.mq.consumer.util.ControllerMethods;
import com.github.mq.consumer.util.WithControllerMethod; | package com.github.mq.consumer;
/**
* Created by wangziqing on 17/7/13.
*/
public interface ConsumerBuild extends WithControllerMethod<ConsumerBuild> {
ConsumerBuild subscribeTopic(String topic); | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/util/ControllerMethods.java
// public class ControllerMethods {
// public interface ControllerMethod extends Serializable { }
//
//
// @FunctionalInterface
// public interface ControllerMethod0 extends ControllerMethod {
// Action apply() throws Exception;
// }
//
// @FunctionalInterface
// public interface ControllerMethod1<A> extends ControllerMethod {
// Action apply(A a) throws Exception;
// }
//
// @FunctionalInterface
// public interface ControllerMethod2<A,B> extends ControllerMethod {
// Action apply(A a, B b) throws Exception;
// }
// @FunctionalInterface
// public interface ControllerMethod3<A,B,C> extends ControllerMethod {
// Action apply(A a, B b, C c) throws Exception;
// }
//
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/util/WithControllerMethod.java
// public interface WithControllerMethod<T> {
//
// T subscribeTag(String tag, ControllerMethods.ControllerMethod controllerMethod);
//
// default T subscribeTag(String tag, ControllerMethods.ControllerMethod0 controllerMethod) {
// return subscribeTag(tag,(ControllerMethods.ControllerMethod)controllerMethod);
// }
//
// default <A> T subscribeTag(String tag, ControllerMethods.ControllerMethod1<A> controllerMethod) {
// return subscribeTag(tag,(ControllerMethods.ControllerMethod)controllerMethod);
// }
//
// default <A,B> T subscribeTag(String tag, ControllerMethods.ControllerMethod2<A, B> controllerMethod) {
// return subscribeTag(tag,(ControllerMethods.ControllerMethod)controllerMethod);
// }
//
// default <A,B,C> T subscribeTag(String tag, ControllerMethods.ControllerMethod3<A,B,C> controllerMethod) {
// return subscribeTag(tag,(ControllerMethods.ControllerMethod)controllerMethod);
// }
//
// }
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/ConsumerBuild.java
import com.github.mq.consumer.util.ControllerMethods;
import com.github.mq.consumer.util.WithControllerMethod;
package com.github.mq.consumer;
/**
* Created by wangziqing on 17/7/13.
*/
public interface ConsumerBuild extends WithControllerMethod<ConsumerBuild> {
ConsumerBuild subscribeTopic(String topic); | ConsumerBuild subscribeTag(String tag, ControllerMethods.ControllerMethod controllerMethod); |
onepiecex/mq-aliyun | mq-aliyun-example/src/main/java/com/mq/aliyun/example/Application.java | // Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
// public interface ProducerFactory {
// void sendAsync(final Enum address,final Object message);
// void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption);
// void sendAsync(final Enum address,final Object message, final SendCallback sendCallback);
// void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption, final SendCallback sendCallback);
//
// SendResult orderSend(final Enum address, final Object message, final String shardingKey);
// SendResult orderSend(final Enum address, final Object message, final String shardingKey,final DeliveryOption deliveryOption);
//
// Producer getProducer(String pid);
// OrderProducer getOrderProducer(String pid);
// void addProducer(String pid);
// void addOrdereProducer(String pid);
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/Dish.java
// public class Dish {
// private Long id;
// private String name;
// public Dish(){}
//
// public Dish(Long id,String name){
// this.id = id;
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/producers/OrderProducer.java
// @Pid(value = "PID_MEICANYUN" , ordered = true)
// public enum OrderProducer {
// @To(topic = "MEICANYUN_SHARDING",tag = "send.mail")
// SEND_MAIL;
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/producers/TestProducer.java
// @Pid(value = "PID_MEICANYUN")
// public enum TestProducer {
// @To(topic = "MEICANYUN", tag = "dish.add")
// DISH_ADD,
//
// @To(topic = "WEBSOCKET", tag = "dish.update")
// DISH_UPDATE,
//
// @To(topic = "WEBSOCKET", tag = "dish.del")
// DISH_DEL
// }
| import com.aliyun.openservices.ons.api.SendResult;
import com.github.mq.producer.ProducerFactory;
import com.mq.aliyun.example.model.Dish;
import com.mq.aliyun.example.producers.OrderProducer;
import com.mq.aliyun.example.producers.TestProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; | package com.mq.aliyun.example;
/**
* Created by wangziqing on 17/7/25.
*/
@SpringBootApplication
public class Application implements CommandLineRunner {
@Autowired | // Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
// public interface ProducerFactory {
// void sendAsync(final Enum address,final Object message);
// void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption);
// void sendAsync(final Enum address,final Object message, final SendCallback sendCallback);
// void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption, final SendCallback sendCallback);
//
// SendResult orderSend(final Enum address, final Object message, final String shardingKey);
// SendResult orderSend(final Enum address, final Object message, final String shardingKey,final DeliveryOption deliveryOption);
//
// Producer getProducer(String pid);
// OrderProducer getOrderProducer(String pid);
// void addProducer(String pid);
// void addOrdereProducer(String pid);
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/Dish.java
// public class Dish {
// private Long id;
// private String name;
// public Dish(){}
//
// public Dish(Long id,String name){
// this.id = id;
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/producers/OrderProducer.java
// @Pid(value = "PID_MEICANYUN" , ordered = true)
// public enum OrderProducer {
// @To(topic = "MEICANYUN_SHARDING",tag = "send.mail")
// SEND_MAIL;
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/producers/TestProducer.java
// @Pid(value = "PID_MEICANYUN")
// public enum TestProducer {
// @To(topic = "MEICANYUN", tag = "dish.add")
// DISH_ADD,
//
// @To(topic = "WEBSOCKET", tag = "dish.update")
// DISH_UPDATE,
//
// @To(topic = "WEBSOCKET", tag = "dish.del")
// DISH_DEL
// }
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/Application.java
import com.aliyun.openservices.ons.api.SendResult;
import com.github.mq.producer.ProducerFactory;
import com.mq.aliyun.example.model.Dish;
import com.mq.aliyun.example.producers.OrderProducer;
import com.mq.aliyun.example.producers.TestProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
package com.mq.aliyun.example;
/**
* Created by wangziqing on 17/7/25.
*/
@SpringBootApplication
public class Application implements CommandLineRunner {
@Autowired | private ProducerFactory producerFactory; |
onepiecex/mq-aliyun | mq-aliyun-example/src/main/java/com/mq/aliyun/example/Application.java | // Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
// public interface ProducerFactory {
// void sendAsync(final Enum address,final Object message);
// void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption);
// void sendAsync(final Enum address,final Object message, final SendCallback sendCallback);
// void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption, final SendCallback sendCallback);
//
// SendResult orderSend(final Enum address, final Object message, final String shardingKey);
// SendResult orderSend(final Enum address, final Object message, final String shardingKey,final DeliveryOption deliveryOption);
//
// Producer getProducer(String pid);
// OrderProducer getOrderProducer(String pid);
// void addProducer(String pid);
// void addOrdereProducer(String pid);
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/Dish.java
// public class Dish {
// private Long id;
// private String name;
// public Dish(){}
//
// public Dish(Long id,String name){
// this.id = id;
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/producers/OrderProducer.java
// @Pid(value = "PID_MEICANYUN" , ordered = true)
// public enum OrderProducer {
// @To(topic = "MEICANYUN_SHARDING",tag = "send.mail")
// SEND_MAIL;
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/producers/TestProducer.java
// @Pid(value = "PID_MEICANYUN")
// public enum TestProducer {
// @To(topic = "MEICANYUN", tag = "dish.add")
// DISH_ADD,
//
// @To(topic = "WEBSOCKET", tag = "dish.update")
// DISH_UPDATE,
//
// @To(topic = "WEBSOCKET", tag = "dish.del")
// DISH_DEL
// }
| import com.aliyun.openservices.ons.api.SendResult;
import com.github.mq.producer.ProducerFactory;
import com.mq.aliyun.example.model.Dish;
import com.mq.aliyun.example.producers.OrderProducer;
import com.mq.aliyun.example.producers.TestProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; | package com.mq.aliyun.example;
/**
* Created by wangziqing on 17/7/25.
*/
@SpringBootApplication
public class Application implements CommandLineRunner {
@Autowired
private ProducerFactory producerFactory;
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
@Override
public void run(String... args) throws Exception { | // Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
// public interface ProducerFactory {
// void sendAsync(final Enum address,final Object message);
// void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption);
// void sendAsync(final Enum address,final Object message, final SendCallback sendCallback);
// void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption, final SendCallback sendCallback);
//
// SendResult orderSend(final Enum address, final Object message, final String shardingKey);
// SendResult orderSend(final Enum address, final Object message, final String shardingKey,final DeliveryOption deliveryOption);
//
// Producer getProducer(String pid);
// OrderProducer getOrderProducer(String pid);
// void addProducer(String pid);
// void addOrdereProducer(String pid);
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/Dish.java
// public class Dish {
// private Long id;
// private String name;
// public Dish(){}
//
// public Dish(Long id,String name){
// this.id = id;
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/producers/OrderProducer.java
// @Pid(value = "PID_MEICANYUN" , ordered = true)
// public enum OrderProducer {
// @To(topic = "MEICANYUN_SHARDING",tag = "send.mail")
// SEND_MAIL;
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/producers/TestProducer.java
// @Pid(value = "PID_MEICANYUN")
// public enum TestProducer {
// @To(topic = "MEICANYUN", tag = "dish.add")
// DISH_ADD,
//
// @To(topic = "WEBSOCKET", tag = "dish.update")
// DISH_UPDATE,
//
// @To(topic = "WEBSOCKET", tag = "dish.del")
// DISH_DEL
// }
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/Application.java
import com.aliyun.openservices.ons.api.SendResult;
import com.github.mq.producer.ProducerFactory;
import com.mq.aliyun.example.model.Dish;
import com.mq.aliyun.example.producers.OrderProducer;
import com.mq.aliyun.example.producers.TestProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
package com.mq.aliyun.example;
/**
* Created by wangziqing on 17/7/25.
*/
@SpringBootApplication
public class Application implements CommandLineRunner {
@Autowired
private ProducerFactory producerFactory;
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
@Override
public void run(String... args) throws Exception { | producerFactory.sendAsync(TestProducer.DISH_ADD, new Dish(1L, "name")); |
onepiecex/mq-aliyun | mq-aliyun-example/src/main/java/com/mq/aliyun/example/Application.java | // Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
// public interface ProducerFactory {
// void sendAsync(final Enum address,final Object message);
// void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption);
// void sendAsync(final Enum address,final Object message, final SendCallback sendCallback);
// void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption, final SendCallback sendCallback);
//
// SendResult orderSend(final Enum address, final Object message, final String shardingKey);
// SendResult orderSend(final Enum address, final Object message, final String shardingKey,final DeliveryOption deliveryOption);
//
// Producer getProducer(String pid);
// OrderProducer getOrderProducer(String pid);
// void addProducer(String pid);
// void addOrdereProducer(String pid);
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/Dish.java
// public class Dish {
// private Long id;
// private String name;
// public Dish(){}
//
// public Dish(Long id,String name){
// this.id = id;
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/producers/OrderProducer.java
// @Pid(value = "PID_MEICANYUN" , ordered = true)
// public enum OrderProducer {
// @To(topic = "MEICANYUN_SHARDING",tag = "send.mail")
// SEND_MAIL;
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/producers/TestProducer.java
// @Pid(value = "PID_MEICANYUN")
// public enum TestProducer {
// @To(topic = "MEICANYUN", tag = "dish.add")
// DISH_ADD,
//
// @To(topic = "WEBSOCKET", tag = "dish.update")
// DISH_UPDATE,
//
// @To(topic = "WEBSOCKET", tag = "dish.del")
// DISH_DEL
// }
| import com.aliyun.openservices.ons.api.SendResult;
import com.github.mq.producer.ProducerFactory;
import com.mq.aliyun.example.model.Dish;
import com.mq.aliyun.example.producers.OrderProducer;
import com.mq.aliyun.example.producers.TestProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; | package com.mq.aliyun.example;
/**
* Created by wangziqing on 17/7/25.
*/
@SpringBootApplication
public class Application implements CommandLineRunner {
@Autowired
private ProducerFactory producerFactory;
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
@Override
public void run(String... args) throws Exception { | // Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
// public interface ProducerFactory {
// void sendAsync(final Enum address,final Object message);
// void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption);
// void sendAsync(final Enum address,final Object message, final SendCallback sendCallback);
// void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption, final SendCallback sendCallback);
//
// SendResult orderSend(final Enum address, final Object message, final String shardingKey);
// SendResult orderSend(final Enum address, final Object message, final String shardingKey,final DeliveryOption deliveryOption);
//
// Producer getProducer(String pid);
// OrderProducer getOrderProducer(String pid);
// void addProducer(String pid);
// void addOrdereProducer(String pid);
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/Dish.java
// public class Dish {
// private Long id;
// private String name;
// public Dish(){}
//
// public Dish(Long id,String name){
// this.id = id;
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/producers/OrderProducer.java
// @Pid(value = "PID_MEICANYUN" , ordered = true)
// public enum OrderProducer {
// @To(topic = "MEICANYUN_SHARDING",tag = "send.mail")
// SEND_MAIL;
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/producers/TestProducer.java
// @Pid(value = "PID_MEICANYUN")
// public enum TestProducer {
// @To(topic = "MEICANYUN", tag = "dish.add")
// DISH_ADD,
//
// @To(topic = "WEBSOCKET", tag = "dish.update")
// DISH_UPDATE,
//
// @To(topic = "WEBSOCKET", tag = "dish.del")
// DISH_DEL
// }
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/Application.java
import com.aliyun.openservices.ons.api.SendResult;
import com.github.mq.producer.ProducerFactory;
import com.mq.aliyun.example.model.Dish;
import com.mq.aliyun.example.producers.OrderProducer;
import com.mq.aliyun.example.producers.TestProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
package com.mq.aliyun.example;
/**
* Created by wangziqing on 17/7/25.
*/
@SpringBootApplication
public class Application implements CommandLineRunner {
@Autowired
private ProducerFactory producerFactory;
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
@Override
public void run(String... args) throws Exception { | producerFactory.sendAsync(TestProducer.DISH_ADD, new Dish(1L, "name")); |
onepiecex/mq-aliyun | mq-aliyun-example/src/main/java/com/mq/aliyun/example/Application.java | // Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
// public interface ProducerFactory {
// void sendAsync(final Enum address,final Object message);
// void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption);
// void sendAsync(final Enum address,final Object message, final SendCallback sendCallback);
// void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption, final SendCallback sendCallback);
//
// SendResult orderSend(final Enum address, final Object message, final String shardingKey);
// SendResult orderSend(final Enum address, final Object message, final String shardingKey,final DeliveryOption deliveryOption);
//
// Producer getProducer(String pid);
// OrderProducer getOrderProducer(String pid);
// void addProducer(String pid);
// void addOrdereProducer(String pid);
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/Dish.java
// public class Dish {
// private Long id;
// private String name;
// public Dish(){}
//
// public Dish(Long id,String name){
// this.id = id;
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/producers/OrderProducer.java
// @Pid(value = "PID_MEICANYUN" , ordered = true)
// public enum OrderProducer {
// @To(topic = "MEICANYUN_SHARDING",tag = "send.mail")
// SEND_MAIL;
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/producers/TestProducer.java
// @Pid(value = "PID_MEICANYUN")
// public enum TestProducer {
// @To(topic = "MEICANYUN", tag = "dish.add")
// DISH_ADD,
//
// @To(topic = "WEBSOCKET", tag = "dish.update")
// DISH_UPDATE,
//
// @To(topic = "WEBSOCKET", tag = "dish.del")
// DISH_DEL
// }
| import com.aliyun.openservices.ons.api.SendResult;
import com.github.mq.producer.ProducerFactory;
import com.mq.aliyun.example.model.Dish;
import com.mq.aliyun.example.producers.OrderProducer;
import com.mq.aliyun.example.producers.TestProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; | package com.mq.aliyun.example;
/**
* Created by wangziqing on 17/7/25.
*/
@SpringBootApplication
public class Application implements CommandLineRunner {
@Autowired
private ProducerFactory producerFactory;
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
@Override
public void run(String... args) throws Exception {
producerFactory.sendAsync(TestProducer.DISH_ADD, new Dish(1L, "name"));
// producerFactory.sendAsync(TestProducer.DISH_UPDATE,
// new Dish(2L, "name"),
// new DeliveryOption("key").setDeliverTime(System.currentTimeMillis() + 1000 * 60));
//
// producerFactory.sendAsync(TestProducer.DISH_DEL, 1L, new SendCallback() {
// @Override
// public void onSuccess(SendResult sendResult) {
// //send success
// //do some thing...
// }
//
// @Override
// public void onException(OnExceptionContext context) {
// //send fail
// //do some thing...
// }
// }); | // Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
// public interface ProducerFactory {
// void sendAsync(final Enum address,final Object message);
// void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption);
// void sendAsync(final Enum address,final Object message, final SendCallback sendCallback);
// void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption, final SendCallback sendCallback);
//
// SendResult orderSend(final Enum address, final Object message, final String shardingKey);
// SendResult orderSend(final Enum address, final Object message, final String shardingKey,final DeliveryOption deliveryOption);
//
// Producer getProducer(String pid);
// OrderProducer getOrderProducer(String pid);
// void addProducer(String pid);
// void addOrdereProducer(String pid);
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/Dish.java
// public class Dish {
// private Long id;
// private String name;
// public Dish(){}
//
// public Dish(Long id,String name){
// this.id = id;
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/producers/OrderProducer.java
// @Pid(value = "PID_MEICANYUN" , ordered = true)
// public enum OrderProducer {
// @To(topic = "MEICANYUN_SHARDING",tag = "send.mail")
// SEND_MAIL;
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/producers/TestProducer.java
// @Pid(value = "PID_MEICANYUN")
// public enum TestProducer {
// @To(topic = "MEICANYUN", tag = "dish.add")
// DISH_ADD,
//
// @To(topic = "WEBSOCKET", tag = "dish.update")
// DISH_UPDATE,
//
// @To(topic = "WEBSOCKET", tag = "dish.del")
// DISH_DEL
// }
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/Application.java
import com.aliyun.openservices.ons.api.SendResult;
import com.github.mq.producer.ProducerFactory;
import com.mq.aliyun.example.model.Dish;
import com.mq.aliyun.example.producers.OrderProducer;
import com.mq.aliyun.example.producers.TestProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
package com.mq.aliyun.example;
/**
* Created by wangziqing on 17/7/25.
*/
@SpringBootApplication
public class Application implements CommandLineRunner {
@Autowired
private ProducerFactory producerFactory;
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
@Override
public void run(String... args) throws Exception {
producerFactory.sendAsync(TestProducer.DISH_ADD, new Dish(1L, "name"));
// producerFactory.sendAsync(TestProducer.DISH_UPDATE,
// new Dish(2L, "name"),
// new DeliveryOption("key").setDeliverTime(System.currentTimeMillis() + 1000 * 60));
//
// producerFactory.sendAsync(TestProducer.DISH_DEL, 1L, new SendCallback() {
// @Override
// public void onSuccess(SendResult sendResult) {
// //send success
// //do some thing...
// }
//
// @Override
// public void onException(OnExceptionContext context) {
// //send fail
// //do some thing...
// }
// }); | SendResult sendResult = producerFactory.orderSend(OrderProducer.SEND_MAIL,"message","shardingKey"); |
onepiecex/mq-aliyun | mq-aliyun-example/src/main/java/com/mq/aliyun/example/consumers/TestConsumer.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Message.java
// public class Message extends com.aliyun.openservices.ons.api.Message {
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/Dish.java
// public class Dish {
// private Long id;
// private String name;
// public Dish(){}
//
// public Dish(Long id,String name){
// this.id = id;
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
| import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Message;
import com.github.mq.consumer.models.Reconsume;
import com.mq.aliyun.example.model.Dish;
import com.mq.aliyun.example.model.JackJson; | package com.mq.aliyun.example.consumers;
/**
* Created by wangziqing on 17/7/25.
*/
@Reconsume(5)
public class TestConsumer {
@Reconsume(3) | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Message.java
// public class Message extends com.aliyun.openservices.ons.api.Message {
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/Dish.java
// public class Dish {
// private Long id;
// private String name;
// public Dish(){}
//
// public Dish(Long id,String name){
// this.id = id;
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/consumers/TestConsumer.java
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Message;
import com.github.mq.consumer.models.Reconsume;
import com.mq.aliyun.example.model.Dish;
import com.mq.aliyun.example.model.JackJson;
package com.mq.aliyun.example.consumers;
/**
* Created by wangziqing on 17/7/25.
*/
@Reconsume(5)
public class TestConsumer {
@Reconsume(3) | public Action dishAdd(Dish dish){ |
onepiecex/mq-aliyun | mq-aliyun-example/src/main/java/com/mq/aliyun/example/consumers/TestConsumer.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Message.java
// public class Message extends com.aliyun.openservices.ons.api.Message {
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/Dish.java
// public class Dish {
// private Long id;
// private String name;
// public Dish(){}
//
// public Dish(Long id,String name){
// this.id = id;
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
| import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Message;
import com.github.mq.consumer.models.Reconsume;
import com.mq.aliyun.example.model.Dish;
import com.mq.aliyun.example.model.JackJson; | package com.mq.aliyun.example.consumers;
/**
* Created by wangziqing on 17/7/25.
*/
@Reconsume(5)
public class TestConsumer {
@Reconsume(3) | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Message.java
// public class Message extends com.aliyun.openservices.ons.api.Message {
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/Dish.java
// public class Dish {
// private Long id;
// private String name;
// public Dish(){}
//
// public Dish(Long id,String name){
// this.id = id;
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/consumers/TestConsumer.java
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Message;
import com.github.mq.consumer.models.Reconsume;
import com.mq.aliyun.example.model.Dish;
import com.mq.aliyun.example.model.JackJson;
package com.mq.aliyun.example.consumers;
/**
* Created by wangziqing on 17/7/25.
*/
@Reconsume(5)
public class TestConsumer {
@Reconsume(3) | public Action dishAdd(Dish dish){ |
onepiecex/mq-aliyun | mq-aliyun-example/src/main/java/com/mq/aliyun/example/consumers/TestConsumer.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Message.java
// public class Message extends com.aliyun.openservices.ons.api.Message {
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/Dish.java
// public class Dish {
// private Long id;
// private String name;
// public Dish(){}
//
// public Dish(Long id,String name){
// this.id = id;
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
| import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Message;
import com.github.mq.consumer.models.Reconsume;
import com.mq.aliyun.example.model.Dish;
import com.mq.aliyun.example.model.JackJson; | package com.mq.aliyun.example.consumers;
/**
* Created by wangziqing on 17/7/25.
*/
@Reconsume(5)
public class TestConsumer {
@Reconsume(3)
public Action dishAdd(Dish dish){
//do some thine
return Action.commit;
}
| // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Message.java
// public class Message extends com.aliyun.openservices.ons.api.Message {
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/Dish.java
// public class Dish {
// private Long id;
// private String name;
// public Dish(){}
//
// public Dish(Long id,String name){
// this.id = id;
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/consumers/TestConsumer.java
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Message;
import com.github.mq.consumer.models.Reconsume;
import com.mq.aliyun.example.model.Dish;
import com.mq.aliyun.example.model.JackJson;
package com.mq.aliyun.example.consumers;
/**
* Created by wangziqing on 17/7/25.
*/
@Reconsume(5)
public class TestConsumer {
@Reconsume(3)
public Action dishAdd(Dish dish){
//do some thine
return Action.commit;
}
| public Action dishDel(Long dishId, Message message){ |
onepiecex/mq-aliyun | mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractors.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/DefaultArgumentExtractor.java
// public interface DefaultArgumentExtractor<T> extends ArgumentExtractor<T> {
//
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Result.java
// public class Result<T> {
// private T result;
// private Action action;
//
// public Result(T result) {
// this.result = result;
// }
//
// public Result(Action action) {
// this.action = action;
// }
//
// public Object getResult() {
// return result;
// }
//
// public Action getAction() {
// return action;
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Results.java
// public class Results {
//
// public static <T> Result<T> next(T result){
// return new Result(result);
// }
//
// public static Result end(Action action){
// return new Result(action);
// }
// }
| import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONException;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONObject;
import com.google.common.collect.ImmutableMap;
import com.github.mq.consumer.DefaultArgumentExtractor;
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Result;
import com.github.mq.consumer.models.Results;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
import java.util.ServiceLoader; | package com.github.mq.consumer.parms;
/**
* Created by wangziqing on 17/7/17.
*/
public class ArgumentExtractors {
private static final Logger logger = LoggerFactory.getLogger(ArgumentExtractors.class);
public static ArgumentExtractor defaultExtractor;
static { | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/DefaultArgumentExtractor.java
// public interface DefaultArgumentExtractor<T> extends ArgumentExtractor<T> {
//
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Result.java
// public class Result<T> {
// private T result;
// private Action action;
//
// public Result(T result) {
// this.result = result;
// }
//
// public Result(Action action) {
// this.action = action;
// }
//
// public Object getResult() {
// return result;
// }
//
// public Action getAction() {
// return action;
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Results.java
// public class Results {
//
// public static <T> Result<T> next(T result){
// return new Result(result);
// }
//
// public static Result end(Action action){
// return new Result(action);
// }
// }
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractors.java
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONException;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONObject;
import com.google.common.collect.ImmutableMap;
import com.github.mq.consumer.DefaultArgumentExtractor;
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Result;
import com.github.mq.consumer.models.Results;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
import java.util.ServiceLoader;
package com.github.mq.consumer.parms;
/**
* Created by wangziqing on 17/7/17.
*/
public class ArgumentExtractors {
private static final Logger logger = LoggerFactory.getLogger(ArgumentExtractors.class);
public static ArgumentExtractor defaultExtractor;
static { | Iterator<DefaultArgumentExtractor> producerServiceLoader = ServiceLoader.load(DefaultArgumentExtractor.class).iterator(); |
onepiecex/mq-aliyun | mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractors.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/DefaultArgumentExtractor.java
// public interface DefaultArgumentExtractor<T> extends ArgumentExtractor<T> {
//
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Result.java
// public class Result<T> {
// private T result;
// private Action action;
//
// public Result(T result) {
// this.result = result;
// }
//
// public Result(Action action) {
// this.action = action;
// }
//
// public Object getResult() {
// return result;
// }
//
// public Action getAction() {
// return action;
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Results.java
// public class Results {
//
// public static <T> Result<T> next(T result){
// return new Result(result);
// }
//
// public static Result end(Action action){
// return new Result(action);
// }
// }
| import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONException;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONObject;
import com.google.common.collect.ImmutableMap;
import com.github.mq.consumer.DefaultArgumentExtractor;
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Result;
import com.github.mq.consumer.models.Results;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
import java.util.ServiceLoader; | // extractor.init(annotation, parameterClass);
// return extractor;
// }
// }
// }
// return extractor;
// }
public static <T> T instantiateComponent(DefaultListableBeanFactory beanFactory, Class<T> cls, Annotation annotation) {
T extractor;
try {
extractor = beanFactory.getBean(cls);
} catch (BeansException e) {
try {
extractor = (T) beanFactory.getBean(cls.getName());
} catch (BeansException e1) {
BeanDefinitionBuilder beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(cls.getName());
beanFactory.registerBeanDefinition(cls.getName(), beanDefinition.getBeanDefinition());
extractor = (T) beanFactory.getBean(cls.getName());
}
}
return extractor;
}
public static class FastJsonExtractor implements ArgumentExtractor {
@Override | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/DefaultArgumentExtractor.java
// public interface DefaultArgumentExtractor<T> extends ArgumentExtractor<T> {
//
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Result.java
// public class Result<T> {
// private T result;
// private Action action;
//
// public Result(T result) {
// this.result = result;
// }
//
// public Result(Action action) {
// this.action = action;
// }
//
// public Object getResult() {
// return result;
// }
//
// public Action getAction() {
// return action;
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Results.java
// public class Results {
//
// public static <T> Result<T> next(T result){
// return new Result(result);
// }
//
// public static Result end(Action action){
// return new Result(action);
// }
// }
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractors.java
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONException;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONObject;
import com.google.common.collect.ImmutableMap;
import com.github.mq.consumer.DefaultArgumentExtractor;
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Result;
import com.github.mq.consumer.models.Results;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
import java.util.ServiceLoader;
// extractor.init(annotation, parameterClass);
// return extractor;
// }
// }
// }
// return extractor;
// }
public static <T> T instantiateComponent(DefaultListableBeanFactory beanFactory, Class<T> cls, Annotation annotation) {
T extractor;
try {
extractor = beanFactory.getBean(cls);
} catch (BeansException e) {
try {
extractor = (T) beanFactory.getBean(cls.getName());
} catch (BeansException e1) {
BeanDefinitionBuilder beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(cls.getName());
beanFactory.registerBeanDefinition(cls.getName(), beanDefinition.getBeanDefinition());
extractor = (T) beanFactory.getBean(cls.getName());
}
}
return extractor;
}
public static class FastJsonExtractor implements ArgumentExtractor {
@Override | public Result extract(Message message,Class parameterClass, Annotation annotation) { |
onepiecex/mq-aliyun | mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractors.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/DefaultArgumentExtractor.java
// public interface DefaultArgumentExtractor<T> extends ArgumentExtractor<T> {
//
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Result.java
// public class Result<T> {
// private T result;
// private Action action;
//
// public Result(T result) {
// this.result = result;
// }
//
// public Result(Action action) {
// this.action = action;
// }
//
// public Object getResult() {
// return result;
// }
//
// public Action getAction() {
// return action;
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Results.java
// public class Results {
//
// public static <T> Result<T> next(T result){
// return new Result(result);
// }
//
// public static Result end(Action action){
// return new Result(action);
// }
// }
| import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONException;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONObject;
import com.google.common.collect.ImmutableMap;
import com.github.mq.consumer.DefaultArgumentExtractor;
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Result;
import com.github.mq.consumer.models.Results;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
import java.util.ServiceLoader; | public static <T> T instantiateComponent(DefaultListableBeanFactory beanFactory, Class<T> cls, Annotation annotation) {
T extractor;
try {
extractor = beanFactory.getBean(cls);
} catch (BeansException e) {
try {
extractor = (T) beanFactory.getBean(cls.getName());
} catch (BeansException e1) {
BeanDefinitionBuilder beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(cls.getName());
beanFactory.registerBeanDefinition(cls.getName(), beanDefinition.getBeanDefinition());
extractor = (T) beanFactory.getBean(cls.getName());
}
}
return extractor;
}
public static class FastJsonExtractor implements ArgumentExtractor {
@Override
public Result extract(Message message,Class parameterClass, Annotation annotation) {
Object object;
try {
object = JSONObject.parseObject(message.getBody(), parameterClass);
} catch (JSONException e) {
e.printStackTrace();
logger.error(String.format("%s 反序列化失败 by : %s",
parameterClass, JSONObject.parseObject(message.getBody(), Object.class))); | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/DefaultArgumentExtractor.java
// public interface DefaultArgumentExtractor<T> extends ArgumentExtractor<T> {
//
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Result.java
// public class Result<T> {
// private T result;
// private Action action;
//
// public Result(T result) {
// this.result = result;
// }
//
// public Result(Action action) {
// this.action = action;
// }
//
// public Object getResult() {
// return result;
// }
//
// public Action getAction() {
// return action;
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Results.java
// public class Results {
//
// public static <T> Result<T> next(T result){
// return new Result(result);
// }
//
// public static Result end(Action action){
// return new Result(action);
// }
// }
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractors.java
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONException;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONObject;
import com.google.common.collect.ImmutableMap;
import com.github.mq.consumer.DefaultArgumentExtractor;
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Result;
import com.github.mq.consumer.models.Results;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
import java.util.ServiceLoader;
public static <T> T instantiateComponent(DefaultListableBeanFactory beanFactory, Class<T> cls, Annotation annotation) {
T extractor;
try {
extractor = beanFactory.getBean(cls);
} catch (BeansException e) {
try {
extractor = (T) beanFactory.getBean(cls.getName());
} catch (BeansException e1) {
BeanDefinitionBuilder beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(cls.getName());
beanFactory.registerBeanDefinition(cls.getName(), beanDefinition.getBeanDefinition());
extractor = (T) beanFactory.getBean(cls.getName());
}
}
return extractor;
}
public static class FastJsonExtractor implements ArgumentExtractor {
@Override
public Result extract(Message message,Class parameterClass, Annotation annotation) {
Object object;
try {
object = JSONObject.parseObject(message.getBody(), parameterClass);
} catch (JSONException e) {
e.printStackTrace();
logger.error(String.format("%s 反序列化失败 by : %s",
parameterClass, JSONObject.parseObject(message.getBody(), Object.class))); | return Results.end(Action.commit); |
onepiecex/mq-aliyun | mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractors.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/DefaultArgumentExtractor.java
// public interface DefaultArgumentExtractor<T> extends ArgumentExtractor<T> {
//
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Result.java
// public class Result<T> {
// private T result;
// private Action action;
//
// public Result(T result) {
// this.result = result;
// }
//
// public Result(Action action) {
// this.action = action;
// }
//
// public Object getResult() {
// return result;
// }
//
// public Action getAction() {
// return action;
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Results.java
// public class Results {
//
// public static <T> Result<T> next(T result){
// return new Result(result);
// }
//
// public static Result end(Action action){
// return new Result(action);
// }
// }
| import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONException;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONObject;
import com.google.common.collect.ImmutableMap;
import com.github.mq.consumer.DefaultArgumentExtractor;
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Result;
import com.github.mq.consumer.models.Results;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
import java.util.ServiceLoader; | public static <T> T instantiateComponent(DefaultListableBeanFactory beanFactory, Class<T> cls, Annotation annotation) {
T extractor;
try {
extractor = beanFactory.getBean(cls);
} catch (BeansException e) {
try {
extractor = (T) beanFactory.getBean(cls.getName());
} catch (BeansException e1) {
BeanDefinitionBuilder beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(cls.getName());
beanFactory.registerBeanDefinition(cls.getName(), beanDefinition.getBeanDefinition());
extractor = (T) beanFactory.getBean(cls.getName());
}
}
return extractor;
}
public static class FastJsonExtractor implements ArgumentExtractor {
@Override
public Result extract(Message message,Class parameterClass, Annotation annotation) {
Object object;
try {
object = JSONObject.parseObject(message.getBody(), parameterClass);
} catch (JSONException e) {
e.printStackTrace();
logger.error(String.format("%s 反序列化失败 by : %s",
parameterClass, JSONObject.parseObject(message.getBody(), Object.class))); | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/DefaultArgumentExtractor.java
// public interface DefaultArgumentExtractor<T> extends ArgumentExtractor<T> {
//
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Result.java
// public class Result<T> {
// private T result;
// private Action action;
//
// public Result(T result) {
// this.result = result;
// }
//
// public Result(Action action) {
// this.action = action;
// }
//
// public Object getResult() {
// return result;
// }
//
// public Action getAction() {
// return action;
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Results.java
// public class Results {
//
// public static <T> Result<T> next(T result){
// return new Result(result);
// }
//
// public static Result end(Action action){
// return new Result(action);
// }
// }
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractors.java
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONException;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONObject;
import com.google.common.collect.ImmutableMap;
import com.github.mq.consumer.DefaultArgumentExtractor;
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Result;
import com.github.mq.consumer.models.Results;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
import java.util.ServiceLoader;
public static <T> T instantiateComponent(DefaultListableBeanFactory beanFactory, Class<T> cls, Annotation annotation) {
T extractor;
try {
extractor = beanFactory.getBean(cls);
} catch (BeansException e) {
try {
extractor = (T) beanFactory.getBean(cls.getName());
} catch (BeansException e1) {
BeanDefinitionBuilder beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(cls.getName());
beanFactory.registerBeanDefinition(cls.getName(), beanDefinition.getBeanDefinition());
extractor = (T) beanFactory.getBean(cls.getName());
}
}
return extractor;
}
public static class FastJsonExtractor implements ArgumentExtractor {
@Override
public Result extract(Message message,Class parameterClass, Annotation annotation) {
Object object;
try {
object = JSONObject.parseObject(message.getBody(), parameterClass);
} catch (JSONException e) {
e.printStackTrace();
logger.error(String.format("%s 反序列化失败 by : %s",
parameterClass, JSONObject.parseObject(message.getBody(), Object.class))); | return Results.end(Action.commit); |
onepiecex/mq-aliyun | mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java | // Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/DeliveryOption.java
// public class DeliveryOption {
// private String key;
// private Long deliverTime;
// public String getKey() {
// return key;
// }
//
// public DeliveryOption(){}
// public DeliveryOption(String key){
// this.key = key;
// }
//
// public DeliveryOption setKey(String key) {
// this.key = key;
// return this;
// }
//
// public Long getDeliverTime() {
// return deliverTime;
// }
//
// public DeliveryOption setDeliverTime(Long deliverTime) {
// this.deliverTime = deliverTime;
// return this;
// }
// }
| import com.aliyun.openservices.ons.api.Producer;
import com.aliyun.openservices.ons.api.SendCallback;
import com.aliyun.openservices.ons.api.SendResult;
import com.aliyun.openservices.ons.api.order.OrderProducer;
import com.github.mq.producer.models.DeliveryOption; | package com.github.mq.producer;
/**
* Created by wangziqing on 17/7/17.
*/
public interface ProducerFactory {
void sendAsync(final Enum address,final Object message); | // Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/DeliveryOption.java
// public class DeliveryOption {
// private String key;
// private Long deliverTime;
// public String getKey() {
// return key;
// }
//
// public DeliveryOption(){}
// public DeliveryOption(String key){
// this.key = key;
// }
//
// public DeliveryOption setKey(String key) {
// this.key = key;
// return this;
// }
//
// public Long getDeliverTime() {
// return deliverTime;
// }
//
// public DeliveryOption setDeliverTime(Long deliverTime) {
// this.deliverTime = deliverTime;
// return this;
// }
// }
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
import com.aliyun.openservices.ons.api.Producer;
import com.aliyun.openservices.ons.api.SendCallback;
import com.aliyun.openservices.ons.api.SendResult;
import com.aliyun.openservices.ons.api.order.OrderProducer;
import com.github.mq.producer.models.DeliveryOption;
package com.github.mq.producer;
/**
* Created by wangziqing on 17/7/17.
*/
public interface ProducerFactory {
void sendAsync(final Enum address,final Object message); | void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption); |
onepiecex/mq-aliyun | mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/Ons.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/ConsumerOptional.java
// public class ConsumerOptional {
// //消费线程数
// private Integer consumeThread;
// //消费模式(集群 : CLUSTERING, 广播 : BROADCASTING)
// private String consumerModel;
// //消息消费失败时的最大重试次数
// private Integer maxReconsume;
// //顺序消息消费失败进行重试前的等待时间 单位(毫秒)
// private Integer suspendTime;
//
// public ConsumerOptional(){}
//
// public ConsumerOptional(Integer consumeThread){
// this.consumeThread = consumeThread;
// }
//
// public ConsumerOptional(Integer consumeThread,Integer maxReconsume){
// this.consumeThread = consumeThread;
// this.maxReconsume = maxReconsume;
// }
//
// public Integer getConsumeThread() {
// return consumeThread;
// }
//
// public ConsumerOptional setConsumeThread(Integer consumeThread) {
// this.consumeThread = consumeThread;
// return this;
// }
//
// public String getConsumerModel() {
// return consumerModel;
// }
//
// public ConsumerOptional setConsumerModel(String consumerModel) {
// this.consumerModel = consumerModel;
// return this;
// }
//
// public Integer getMaxReconsume() {
// return maxReconsume;
// }
//
// public ConsumerOptional setMaxReconsume(Integer maxReconsume) {
// this.maxReconsume = maxReconsume;
// return this;
// }
//
// public Integer getSuspendTime() {
// return suspendTime;
// }
//
// public ConsumerOptional setSuspendTime(Integer suspendTime) {
// this.suspendTime = suspendTime;
// return this;
// }
// }
| import com.github.mq.consumer.models.ConsumerOptional; | package com.github.mq.consumer;
/**
* Created by wangziqing on 17/7/13.
*/
public interface Ons {
void defaultTopic(String topic);
ConsumerBuild consumer(String cid); | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/ConsumerOptional.java
// public class ConsumerOptional {
// //消费线程数
// private Integer consumeThread;
// //消费模式(集群 : CLUSTERING, 广播 : BROADCASTING)
// private String consumerModel;
// //消息消费失败时的最大重试次数
// private Integer maxReconsume;
// //顺序消息消费失败进行重试前的等待时间 单位(毫秒)
// private Integer suspendTime;
//
// public ConsumerOptional(){}
//
// public ConsumerOptional(Integer consumeThread){
// this.consumeThread = consumeThread;
// }
//
// public ConsumerOptional(Integer consumeThread,Integer maxReconsume){
// this.consumeThread = consumeThread;
// this.maxReconsume = maxReconsume;
// }
//
// public Integer getConsumeThread() {
// return consumeThread;
// }
//
// public ConsumerOptional setConsumeThread(Integer consumeThread) {
// this.consumeThread = consumeThread;
// return this;
// }
//
// public String getConsumerModel() {
// return consumerModel;
// }
//
// public ConsumerOptional setConsumerModel(String consumerModel) {
// this.consumerModel = consumerModel;
// return this;
// }
//
// public Integer getMaxReconsume() {
// return maxReconsume;
// }
//
// public ConsumerOptional setMaxReconsume(Integer maxReconsume) {
// this.maxReconsume = maxReconsume;
// return this;
// }
//
// public Integer getSuspendTime() {
// return suspendTime;
// }
//
// public ConsumerOptional setSuspendTime(Integer suspendTime) {
// this.suspendTime = suspendTime;
// return this;
// }
// }
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/Ons.java
import com.github.mq.consumer.models.ConsumerOptional;
package com.github.mq.consumer;
/**
* Created by wangziqing on 17/7/13.
*/
public interface Ons {
void defaultTopic(String topic);
ConsumerBuild consumer(String cid); | ConsumerBuild consumer(String cid, ConsumerOptional consumerOptional); |
onepiecex/mq-aliyun | mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/impls/ProducerFactoryImpl.java | // Path: mq-aliyun-core/src/main/java/com/github/mq/core/scan/constant/MqConstant.java
// public interface MqConstant {
// String ACCESS_KEY = "aliyun.accessKey";
// String SECRET_KEY = "aliyun.secretKey";
// String MQ_SUFFIX = "aliyun.mq.suffix";
//
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
// public interface ProducerFactory {
// void sendAsync(final Enum address,final Object message);
// void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption);
// void sendAsync(final Enum address,final Object message, final SendCallback sendCallback);
// void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption, final SendCallback sendCallback);
//
// SendResult orderSend(final Enum address, final Object message, final String shardingKey);
// SendResult orderSend(final Enum address, final Object message, final String shardingKey,final DeliveryOption deliveryOption);
//
// Producer getProducer(String pid);
// OrderProducer getOrderProducer(String pid);
// void addProducer(String pid);
// void addOrdereProducer(String pid);
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerSerialize.java
// public interface ProducerSerialize {
//
// byte[] objToBytes(Object object);
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/DeliveryOption.java
// public class DeliveryOption {
// private String key;
// private Long deliverTime;
// public String getKey() {
// return key;
// }
//
// public DeliveryOption(){}
// public DeliveryOption(String key){
// this.key = key;
// }
//
// public DeliveryOption setKey(String key) {
// this.key = key;
// return this;
// }
//
// public Long getDeliverTime() {
// return deliverTime;
// }
//
// public DeliveryOption setDeliverTime(Long deliverTime) {
// this.deliverTime = deliverTime;
// return this;
// }
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/PendingMsg.java
// public class PendingMsg {
// private Enum anEnum;
// private Object message;
// private DeliveryOption deliveryOption;
// private SendCallback sendCallback;
//
// public PendingMsg(){}
//
// public PendingMsg(Enum anEnum,Object message,DeliveryOption deliveryOption,SendCallback sendCallback){
// this.anEnum =anEnum;
// this.message = message;
// this.deliveryOption = deliveryOption;
// this.sendCallback = sendCallback;
// }
//
//
// public Enum getAnEnum() {
// return anEnum;
// }
//
// public void setAnEnum(Enum anEnum) {
// this.anEnum = anEnum;
// }
//
// public Object getMessage() {
// return message;
// }
//
// public void setMessage(Object message) {
// this.message = message;
// }
//
// public DeliveryOption getDeliveryOption() {
// return deliveryOption;
// }
//
// public void setDeliveryOption(DeliveryOption deliveryOption) {
// this.deliveryOption = deliveryOption;
// }
//
// public SendCallback getSendCallback() {
// return sendCallback;
// }
//
// public void setSendCallback(SendCallback sendCallback) {
// this.sendCallback = sendCallback;
// }
// }
| import com.aliyun.openservices.ons.api.*;
import com.aliyun.openservices.ons.api.order.OrderProducer;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONObject;
import com.github.mq.core.scan.constant.MqConstant;
import com.github.mq.producer.ProducerFactory;
import com.github.mq.producer.ProducerSerialize;
import com.github.mq.producer.models.DeliveryOption;
import com.github.mq.producer.models.PendingMsg;
import com.github.mq.producer.models.Pid;
import com.github.mq.producer.models.To;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import java.util.*;
import static java.lang.Thread.sleep; | package com.github.mq.producer.impls;
/**
* Created by wangziqing on 17/7/19.
*/
public class ProducerFactoryImpl implements ProducerFactory {
private final static Logger logger = LoggerFactory.getLogger(ProducerFactoryImpl.class);
public static final String MQ_PRODUCER_SEND_MSG_TIMEOUT = "aliyun.mq.producer.sendTimeOut";
public static final String MQ_PRODUCER_PACKAGES = "aliyun.mq.producer.packages";
private static volatile Map<String, Producer> producerMap = Maps.newConcurrentMap();
private static volatile Map<String, OrderProducer> orderProducerMap = Maps.newConcurrentMap();
private static volatile Map<String, Boolean> checkStart = Maps.newConcurrentMap(); | // Path: mq-aliyun-core/src/main/java/com/github/mq/core/scan/constant/MqConstant.java
// public interface MqConstant {
// String ACCESS_KEY = "aliyun.accessKey";
// String SECRET_KEY = "aliyun.secretKey";
// String MQ_SUFFIX = "aliyun.mq.suffix";
//
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
// public interface ProducerFactory {
// void sendAsync(final Enum address,final Object message);
// void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption);
// void sendAsync(final Enum address,final Object message, final SendCallback sendCallback);
// void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption, final SendCallback sendCallback);
//
// SendResult orderSend(final Enum address, final Object message, final String shardingKey);
// SendResult orderSend(final Enum address, final Object message, final String shardingKey,final DeliveryOption deliveryOption);
//
// Producer getProducer(String pid);
// OrderProducer getOrderProducer(String pid);
// void addProducer(String pid);
// void addOrdereProducer(String pid);
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerSerialize.java
// public interface ProducerSerialize {
//
// byte[] objToBytes(Object object);
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/DeliveryOption.java
// public class DeliveryOption {
// private String key;
// private Long deliverTime;
// public String getKey() {
// return key;
// }
//
// public DeliveryOption(){}
// public DeliveryOption(String key){
// this.key = key;
// }
//
// public DeliveryOption setKey(String key) {
// this.key = key;
// return this;
// }
//
// public Long getDeliverTime() {
// return deliverTime;
// }
//
// public DeliveryOption setDeliverTime(Long deliverTime) {
// this.deliverTime = deliverTime;
// return this;
// }
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/PendingMsg.java
// public class PendingMsg {
// private Enum anEnum;
// private Object message;
// private DeliveryOption deliveryOption;
// private SendCallback sendCallback;
//
// public PendingMsg(){}
//
// public PendingMsg(Enum anEnum,Object message,DeliveryOption deliveryOption,SendCallback sendCallback){
// this.anEnum =anEnum;
// this.message = message;
// this.deliveryOption = deliveryOption;
// this.sendCallback = sendCallback;
// }
//
//
// public Enum getAnEnum() {
// return anEnum;
// }
//
// public void setAnEnum(Enum anEnum) {
// this.anEnum = anEnum;
// }
//
// public Object getMessage() {
// return message;
// }
//
// public void setMessage(Object message) {
// this.message = message;
// }
//
// public DeliveryOption getDeliveryOption() {
// return deliveryOption;
// }
//
// public void setDeliveryOption(DeliveryOption deliveryOption) {
// this.deliveryOption = deliveryOption;
// }
//
// public SendCallback getSendCallback() {
// return sendCallback;
// }
//
// public void setSendCallback(SendCallback sendCallback) {
// this.sendCallback = sendCallback;
// }
// }
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/impls/ProducerFactoryImpl.java
import com.aliyun.openservices.ons.api.*;
import com.aliyun.openservices.ons.api.order.OrderProducer;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONObject;
import com.github.mq.core.scan.constant.MqConstant;
import com.github.mq.producer.ProducerFactory;
import com.github.mq.producer.ProducerSerialize;
import com.github.mq.producer.models.DeliveryOption;
import com.github.mq.producer.models.PendingMsg;
import com.github.mq.producer.models.Pid;
import com.github.mq.producer.models.To;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import java.util.*;
import static java.lang.Thread.sleep;
package com.github.mq.producer.impls;
/**
* Created by wangziqing on 17/7/19.
*/
public class ProducerFactoryImpl implements ProducerFactory {
private final static Logger logger = LoggerFactory.getLogger(ProducerFactoryImpl.class);
public static final String MQ_PRODUCER_SEND_MSG_TIMEOUT = "aliyun.mq.producer.sendTimeOut";
public static final String MQ_PRODUCER_PACKAGES = "aliyun.mq.producer.packages";
private static volatile Map<String, Producer> producerMap = Maps.newConcurrentMap();
private static volatile Map<String, OrderProducer> orderProducerMap = Maps.newConcurrentMap();
private static volatile Map<String, Boolean> checkStart = Maps.newConcurrentMap(); | private static volatile Map<String, List<PendingMsg>> pendding = Maps.newConcurrentMap(); |
onepiecex/mq-aliyun | mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/impls/ProducerFactoryImpl.java | // Path: mq-aliyun-core/src/main/java/com/github/mq/core/scan/constant/MqConstant.java
// public interface MqConstant {
// String ACCESS_KEY = "aliyun.accessKey";
// String SECRET_KEY = "aliyun.secretKey";
// String MQ_SUFFIX = "aliyun.mq.suffix";
//
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
// public interface ProducerFactory {
// void sendAsync(final Enum address,final Object message);
// void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption);
// void sendAsync(final Enum address,final Object message, final SendCallback sendCallback);
// void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption, final SendCallback sendCallback);
//
// SendResult orderSend(final Enum address, final Object message, final String shardingKey);
// SendResult orderSend(final Enum address, final Object message, final String shardingKey,final DeliveryOption deliveryOption);
//
// Producer getProducer(String pid);
// OrderProducer getOrderProducer(String pid);
// void addProducer(String pid);
// void addOrdereProducer(String pid);
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerSerialize.java
// public interface ProducerSerialize {
//
// byte[] objToBytes(Object object);
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/DeliveryOption.java
// public class DeliveryOption {
// private String key;
// private Long deliverTime;
// public String getKey() {
// return key;
// }
//
// public DeliveryOption(){}
// public DeliveryOption(String key){
// this.key = key;
// }
//
// public DeliveryOption setKey(String key) {
// this.key = key;
// return this;
// }
//
// public Long getDeliverTime() {
// return deliverTime;
// }
//
// public DeliveryOption setDeliverTime(Long deliverTime) {
// this.deliverTime = deliverTime;
// return this;
// }
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/PendingMsg.java
// public class PendingMsg {
// private Enum anEnum;
// private Object message;
// private DeliveryOption deliveryOption;
// private SendCallback sendCallback;
//
// public PendingMsg(){}
//
// public PendingMsg(Enum anEnum,Object message,DeliveryOption deliveryOption,SendCallback sendCallback){
// this.anEnum =anEnum;
// this.message = message;
// this.deliveryOption = deliveryOption;
// this.sendCallback = sendCallback;
// }
//
//
// public Enum getAnEnum() {
// return anEnum;
// }
//
// public void setAnEnum(Enum anEnum) {
// this.anEnum = anEnum;
// }
//
// public Object getMessage() {
// return message;
// }
//
// public void setMessage(Object message) {
// this.message = message;
// }
//
// public DeliveryOption getDeliveryOption() {
// return deliveryOption;
// }
//
// public void setDeliveryOption(DeliveryOption deliveryOption) {
// this.deliveryOption = deliveryOption;
// }
//
// public SendCallback getSendCallback() {
// return sendCallback;
// }
//
// public void setSendCallback(SendCallback sendCallback) {
// this.sendCallback = sendCallback;
// }
// }
| import com.aliyun.openservices.ons.api.*;
import com.aliyun.openservices.ons.api.order.OrderProducer;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONObject;
import com.github.mq.core.scan.constant.MqConstant;
import com.github.mq.producer.ProducerFactory;
import com.github.mq.producer.ProducerSerialize;
import com.github.mq.producer.models.DeliveryOption;
import com.github.mq.producer.models.PendingMsg;
import com.github.mq.producer.models.Pid;
import com.github.mq.producer.models.To;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import java.util.*;
import static java.lang.Thread.sleep; | package com.github.mq.producer.impls;
/**
* Created by wangziqing on 17/7/19.
*/
public class ProducerFactoryImpl implements ProducerFactory {
private final static Logger logger = LoggerFactory.getLogger(ProducerFactoryImpl.class);
public static final String MQ_PRODUCER_SEND_MSG_TIMEOUT = "aliyun.mq.producer.sendTimeOut";
public static final String MQ_PRODUCER_PACKAGES = "aliyun.mq.producer.packages";
private static volatile Map<String, Producer> producerMap = Maps.newConcurrentMap();
private static volatile Map<String, OrderProducer> orderProducerMap = Maps.newConcurrentMap();
private static volatile Map<String, Boolean> checkStart = Maps.newConcurrentMap();
private static volatile Map<String, List<PendingMsg>> pendding = Maps.newConcurrentMap();
private String suffix;
private String accessKey;
private String secretKey;
private String sendTimeOut = "3000";
private String[] packages;
| // Path: mq-aliyun-core/src/main/java/com/github/mq/core/scan/constant/MqConstant.java
// public interface MqConstant {
// String ACCESS_KEY = "aliyun.accessKey";
// String SECRET_KEY = "aliyun.secretKey";
// String MQ_SUFFIX = "aliyun.mq.suffix";
//
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
// public interface ProducerFactory {
// void sendAsync(final Enum address,final Object message);
// void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption);
// void sendAsync(final Enum address,final Object message, final SendCallback sendCallback);
// void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption, final SendCallback sendCallback);
//
// SendResult orderSend(final Enum address, final Object message, final String shardingKey);
// SendResult orderSend(final Enum address, final Object message, final String shardingKey,final DeliveryOption deliveryOption);
//
// Producer getProducer(String pid);
// OrderProducer getOrderProducer(String pid);
// void addProducer(String pid);
// void addOrdereProducer(String pid);
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerSerialize.java
// public interface ProducerSerialize {
//
// byte[] objToBytes(Object object);
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/DeliveryOption.java
// public class DeliveryOption {
// private String key;
// private Long deliverTime;
// public String getKey() {
// return key;
// }
//
// public DeliveryOption(){}
// public DeliveryOption(String key){
// this.key = key;
// }
//
// public DeliveryOption setKey(String key) {
// this.key = key;
// return this;
// }
//
// public Long getDeliverTime() {
// return deliverTime;
// }
//
// public DeliveryOption setDeliverTime(Long deliverTime) {
// this.deliverTime = deliverTime;
// return this;
// }
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/PendingMsg.java
// public class PendingMsg {
// private Enum anEnum;
// private Object message;
// private DeliveryOption deliveryOption;
// private SendCallback sendCallback;
//
// public PendingMsg(){}
//
// public PendingMsg(Enum anEnum,Object message,DeliveryOption deliveryOption,SendCallback sendCallback){
// this.anEnum =anEnum;
// this.message = message;
// this.deliveryOption = deliveryOption;
// this.sendCallback = sendCallback;
// }
//
//
// public Enum getAnEnum() {
// return anEnum;
// }
//
// public void setAnEnum(Enum anEnum) {
// this.anEnum = anEnum;
// }
//
// public Object getMessage() {
// return message;
// }
//
// public void setMessage(Object message) {
// this.message = message;
// }
//
// public DeliveryOption getDeliveryOption() {
// return deliveryOption;
// }
//
// public void setDeliveryOption(DeliveryOption deliveryOption) {
// this.deliveryOption = deliveryOption;
// }
//
// public SendCallback getSendCallback() {
// return sendCallback;
// }
//
// public void setSendCallback(SendCallback sendCallback) {
// this.sendCallback = sendCallback;
// }
// }
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/impls/ProducerFactoryImpl.java
import com.aliyun.openservices.ons.api.*;
import com.aliyun.openservices.ons.api.order.OrderProducer;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONObject;
import com.github.mq.core.scan.constant.MqConstant;
import com.github.mq.producer.ProducerFactory;
import com.github.mq.producer.ProducerSerialize;
import com.github.mq.producer.models.DeliveryOption;
import com.github.mq.producer.models.PendingMsg;
import com.github.mq.producer.models.Pid;
import com.github.mq.producer.models.To;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import java.util.*;
import static java.lang.Thread.sleep;
package com.github.mq.producer.impls;
/**
* Created by wangziqing on 17/7/19.
*/
public class ProducerFactoryImpl implements ProducerFactory {
private final static Logger logger = LoggerFactory.getLogger(ProducerFactoryImpl.class);
public static final String MQ_PRODUCER_SEND_MSG_TIMEOUT = "aliyun.mq.producer.sendTimeOut";
public static final String MQ_PRODUCER_PACKAGES = "aliyun.mq.producer.packages";
private static volatile Map<String, Producer> producerMap = Maps.newConcurrentMap();
private static volatile Map<String, OrderProducer> orderProducerMap = Maps.newConcurrentMap();
private static volatile Map<String, Boolean> checkStart = Maps.newConcurrentMap();
private static volatile Map<String, List<PendingMsg>> pendding = Maps.newConcurrentMap();
private String suffix;
private String accessKey;
private String secretKey;
private String sendTimeOut = "3000";
private String[] packages;
| private static final ProducerSerialize producerSerialize; |
onepiecex/mq-aliyun | mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/impls/ProducerFactoryImpl.java | // Path: mq-aliyun-core/src/main/java/com/github/mq/core/scan/constant/MqConstant.java
// public interface MqConstant {
// String ACCESS_KEY = "aliyun.accessKey";
// String SECRET_KEY = "aliyun.secretKey";
// String MQ_SUFFIX = "aliyun.mq.suffix";
//
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
// public interface ProducerFactory {
// void sendAsync(final Enum address,final Object message);
// void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption);
// void sendAsync(final Enum address,final Object message, final SendCallback sendCallback);
// void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption, final SendCallback sendCallback);
//
// SendResult orderSend(final Enum address, final Object message, final String shardingKey);
// SendResult orderSend(final Enum address, final Object message, final String shardingKey,final DeliveryOption deliveryOption);
//
// Producer getProducer(String pid);
// OrderProducer getOrderProducer(String pid);
// void addProducer(String pid);
// void addOrdereProducer(String pid);
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerSerialize.java
// public interface ProducerSerialize {
//
// byte[] objToBytes(Object object);
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/DeliveryOption.java
// public class DeliveryOption {
// private String key;
// private Long deliverTime;
// public String getKey() {
// return key;
// }
//
// public DeliveryOption(){}
// public DeliveryOption(String key){
// this.key = key;
// }
//
// public DeliveryOption setKey(String key) {
// this.key = key;
// return this;
// }
//
// public Long getDeliverTime() {
// return deliverTime;
// }
//
// public DeliveryOption setDeliverTime(Long deliverTime) {
// this.deliverTime = deliverTime;
// return this;
// }
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/PendingMsg.java
// public class PendingMsg {
// private Enum anEnum;
// private Object message;
// private DeliveryOption deliveryOption;
// private SendCallback sendCallback;
//
// public PendingMsg(){}
//
// public PendingMsg(Enum anEnum,Object message,DeliveryOption deliveryOption,SendCallback sendCallback){
// this.anEnum =anEnum;
// this.message = message;
// this.deliveryOption = deliveryOption;
// this.sendCallback = sendCallback;
// }
//
//
// public Enum getAnEnum() {
// return anEnum;
// }
//
// public void setAnEnum(Enum anEnum) {
// this.anEnum = anEnum;
// }
//
// public Object getMessage() {
// return message;
// }
//
// public void setMessage(Object message) {
// this.message = message;
// }
//
// public DeliveryOption getDeliveryOption() {
// return deliveryOption;
// }
//
// public void setDeliveryOption(DeliveryOption deliveryOption) {
// this.deliveryOption = deliveryOption;
// }
//
// public SendCallback getSendCallback() {
// return sendCallback;
// }
//
// public void setSendCallback(SendCallback sendCallback) {
// this.sendCallback = sendCallback;
// }
// }
| import com.aliyun.openservices.ons.api.*;
import com.aliyun.openservices.ons.api.order.OrderProducer;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONObject;
import com.github.mq.core.scan.constant.MqConstant;
import com.github.mq.producer.ProducerFactory;
import com.github.mq.producer.ProducerSerialize;
import com.github.mq.producer.models.DeliveryOption;
import com.github.mq.producer.models.PendingMsg;
import com.github.mq.producer.models.Pid;
import com.github.mq.producer.models.To;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import java.util.*;
import static java.lang.Thread.sleep; | package com.github.mq.producer.impls;
/**
* Created by wangziqing on 17/7/19.
*/
public class ProducerFactoryImpl implements ProducerFactory {
private final static Logger logger = LoggerFactory.getLogger(ProducerFactoryImpl.class);
public static final String MQ_PRODUCER_SEND_MSG_TIMEOUT = "aliyun.mq.producer.sendTimeOut";
public static final String MQ_PRODUCER_PACKAGES = "aliyun.mq.producer.packages";
private static volatile Map<String, Producer> producerMap = Maps.newConcurrentMap();
private static volatile Map<String, OrderProducer> orderProducerMap = Maps.newConcurrentMap();
private static volatile Map<String, Boolean> checkStart = Maps.newConcurrentMap();
private static volatile Map<String, List<PendingMsg>> pendding = Maps.newConcurrentMap();
private String suffix;
private String accessKey;
private String secretKey;
private String sendTimeOut = "3000";
private String[] packages;
private static final ProducerSerialize producerSerialize;
static {
Iterator<ProducerSerialize> producerServiceLoader = ServiceLoader.load(ProducerSerialize.class).iterator();
if (producerServiceLoader.hasNext()) {
producerSerialize = producerServiceLoader.next();
} else {
producerSerialize = object -> JSONObject.toJSONBytes(object);
}
}
@Override
public void sendAsync(final Enum address, final Object message) {
sendAsync(address, message, null, null);
}
@Override | // Path: mq-aliyun-core/src/main/java/com/github/mq/core/scan/constant/MqConstant.java
// public interface MqConstant {
// String ACCESS_KEY = "aliyun.accessKey";
// String SECRET_KEY = "aliyun.secretKey";
// String MQ_SUFFIX = "aliyun.mq.suffix";
//
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
// public interface ProducerFactory {
// void sendAsync(final Enum address,final Object message);
// void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption);
// void sendAsync(final Enum address,final Object message, final SendCallback sendCallback);
// void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption, final SendCallback sendCallback);
//
// SendResult orderSend(final Enum address, final Object message, final String shardingKey);
// SendResult orderSend(final Enum address, final Object message, final String shardingKey,final DeliveryOption deliveryOption);
//
// Producer getProducer(String pid);
// OrderProducer getOrderProducer(String pid);
// void addProducer(String pid);
// void addOrdereProducer(String pid);
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerSerialize.java
// public interface ProducerSerialize {
//
// byte[] objToBytes(Object object);
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/DeliveryOption.java
// public class DeliveryOption {
// private String key;
// private Long deliverTime;
// public String getKey() {
// return key;
// }
//
// public DeliveryOption(){}
// public DeliveryOption(String key){
// this.key = key;
// }
//
// public DeliveryOption setKey(String key) {
// this.key = key;
// return this;
// }
//
// public Long getDeliverTime() {
// return deliverTime;
// }
//
// public DeliveryOption setDeliverTime(Long deliverTime) {
// this.deliverTime = deliverTime;
// return this;
// }
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/PendingMsg.java
// public class PendingMsg {
// private Enum anEnum;
// private Object message;
// private DeliveryOption deliveryOption;
// private SendCallback sendCallback;
//
// public PendingMsg(){}
//
// public PendingMsg(Enum anEnum,Object message,DeliveryOption deliveryOption,SendCallback sendCallback){
// this.anEnum =anEnum;
// this.message = message;
// this.deliveryOption = deliveryOption;
// this.sendCallback = sendCallback;
// }
//
//
// public Enum getAnEnum() {
// return anEnum;
// }
//
// public void setAnEnum(Enum anEnum) {
// this.anEnum = anEnum;
// }
//
// public Object getMessage() {
// return message;
// }
//
// public void setMessage(Object message) {
// this.message = message;
// }
//
// public DeliveryOption getDeliveryOption() {
// return deliveryOption;
// }
//
// public void setDeliveryOption(DeliveryOption deliveryOption) {
// this.deliveryOption = deliveryOption;
// }
//
// public SendCallback getSendCallback() {
// return sendCallback;
// }
//
// public void setSendCallback(SendCallback sendCallback) {
// this.sendCallback = sendCallback;
// }
// }
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/impls/ProducerFactoryImpl.java
import com.aliyun.openservices.ons.api.*;
import com.aliyun.openservices.ons.api.order.OrderProducer;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONObject;
import com.github.mq.core.scan.constant.MqConstant;
import com.github.mq.producer.ProducerFactory;
import com.github.mq.producer.ProducerSerialize;
import com.github.mq.producer.models.DeliveryOption;
import com.github.mq.producer.models.PendingMsg;
import com.github.mq.producer.models.Pid;
import com.github.mq.producer.models.To;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import java.util.*;
import static java.lang.Thread.sleep;
package com.github.mq.producer.impls;
/**
* Created by wangziqing on 17/7/19.
*/
public class ProducerFactoryImpl implements ProducerFactory {
private final static Logger logger = LoggerFactory.getLogger(ProducerFactoryImpl.class);
public static final String MQ_PRODUCER_SEND_MSG_TIMEOUT = "aliyun.mq.producer.sendTimeOut";
public static final String MQ_PRODUCER_PACKAGES = "aliyun.mq.producer.packages";
private static volatile Map<String, Producer> producerMap = Maps.newConcurrentMap();
private static volatile Map<String, OrderProducer> orderProducerMap = Maps.newConcurrentMap();
private static volatile Map<String, Boolean> checkStart = Maps.newConcurrentMap();
private static volatile Map<String, List<PendingMsg>> pendding = Maps.newConcurrentMap();
private String suffix;
private String accessKey;
private String secretKey;
private String sendTimeOut = "3000";
private String[] packages;
private static final ProducerSerialize producerSerialize;
static {
Iterator<ProducerSerialize> producerServiceLoader = ServiceLoader.load(ProducerSerialize.class).iterator();
if (producerServiceLoader.hasNext()) {
producerSerialize = producerServiceLoader.next();
} else {
producerSerialize = object -> JSONObject.toJSONBytes(object);
}
}
@Override
public void sendAsync(final Enum address, final Object message) {
sendAsync(address, message, null, null);
}
@Override | public void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption) { |
onepiecex/mq-aliyun | mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/impls/ProducerFactoryImpl.java | // Path: mq-aliyun-core/src/main/java/com/github/mq/core/scan/constant/MqConstant.java
// public interface MqConstant {
// String ACCESS_KEY = "aliyun.accessKey";
// String SECRET_KEY = "aliyun.secretKey";
// String MQ_SUFFIX = "aliyun.mq.suffix";
//
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
// public interface ProducerFactory {
// void sendAsync(final Enum address,final Object message);
// void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption);
// void sendAsync(final Enum address,final Object message, final SendCallback sendCallback);
// void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption, final SendCallback sendCallback);
//
// SendResult orderSend(final Enum address, final Object message, final String shardingKey);
// SendResult orderSend(final Enum address, final Object message, final String shardingKey,final DeliveryOption deliveryOption);
//
// Producer getProducer(String pid);
// OrderProducer getOrderProducer(String pid);
// void addProducer(String pid);
// void addOrdereProducer(String pid);
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerSerialize.java
// public interface ProducerSerialize {
//
// byte[] objToBytes(Object object);
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/DeliveryOption.java
// public class DeliveryOption {
// private String key;
// private Long deliverTime;
// public String getKey() {
// return key;
// }
//
// public DeliveryOption(){}
// public DeliveryOption(String key){
// this.key = key;
// }
//
// public DeliveryOption setKey(String key) {
// this.key = key;
// return this;
// }
//
// public Long getDeliverTime() {
// return deliverTime;
// }
//
// public DeliveryOption setDeliverTime(Long deliverTime) {
// this.deliverTime = deliverTime;
// return this;
// }
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/PendingMsg.java
// public class PendingMsg {
// private Enum anEnum;
// private Object message;
// private DeliveryOption deliveryOption;
// private SendCallback sendCallback;
//
// public PendingMsg(){}
//
// public PendingMsg(Enum anEnum,Object message,DeliveryOption deliveryOption,SendCallback sendCallback){
// this.anEnum =anEnum;
// this.message = message;
// this.deliveryOption = deliveryOption;
// this.sendCallback = sendCallback;
// }
//
//
// public Enum getAnEnum() {
// return anEnum;
// }
//
// public void setAnEnum(Enum anEnum) {
// this.anEnum = anEnum;
// }
//
// public Object getMessage() {
// return message;
// }
//
// public void setMessage(Object message) {
// this.message = message;
// }
//
// public DeliveryOption getDeliveryOption() {
// return deliveryOption;
// }
//
// public void setDeliveryOption(DeliveryOption deliveryOption) {
// this.deliveryOption = deliveryOption;
// }
//
// public SendCallback getSendCallback() {
// return sendCallback;
// }
//
// public void setSendCallback(SendCallback sendCallback) {
// this.sendCallback = sendCallback;
// }
// }
| import com.aliyun.openservices.ons.api.*;
import com.aliyun.openservices.ons.api.order.OrderProducer;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONObject;
import com.github.mq.core.scan.constant.MqConstant;
import com.github.mq.producer.ProducerFactory;
import com.github.mq.producer.ProducerSerialize;
import com.github.mq.producer.models.DeliveryOption;
import com.github.mq.producer.models.PendingMsg;
import com.github.mq.producer.models.Pid;
import com.github.mq.producer.models.To;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import java.util.*;
import static java.lang.Thread.sleep; | Message msg = new Message(
to.topic() + suffix,
// 可理解为Gmail中的标签,对消息进行再归类,方便Consumer指定过滤条件在ONS服务器过滤
to.tag().trim(),
// Message Body
// 任何二进制形式的数据, ONS不做任何干预,
// 需要Producer与Consumer协商好一致的序列化和反序列化方式
producerSerialize.objToBytes(message));
if (null != deliveryOption) {
String key = deliveryOption.getKey();
if (!Strings.isNullOrEmpty(key)) {
msg.setKey(key);
}
Long deliverTime = deliveryOption.getDeliverTime();
if (null != deliverTime && 0 != deliverTime)
msg.setStartDeliverTime(deliverTime);
}
return new MessageBuild(pid.value(), msg);
}
public void init(Environment env) {
String package_ = env.getProperty(MQ_PRODUCER_PACKAGES);
if (null == package_) {
throw new RuntimeException(String.format("mq生产者 启动失败, %s is require", MQ_PRODUCER_PACKAGES));
}
packages = package_.split(",");
| // Path: mq-aliyun-core/src/main/java/com/github/mq/core/scan/constant/MqConstant.java
// public interface MqConstant {
// String ACCESS_KEY = "aliyun.accessKey";
// String SECRET_KEY = "aliyun.secretKey";
// String MQ_SUFFIX = "aliyun.mq.suffix";
//
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerFactory.java
// public interface ProducerFactory {
// void sendAsync(final Enum address,final Object message);
// void sendAsync(final Enum address,final Object message, final DeliveryOption deliveryOption);
// void sendAsync(final Enum address,final Object message, final SendCallback sendCallback);
// void sendAsync(final Enum address, final Object message, final DeliveryOption deliveryOption, final SendCallback sendCallback);
//
// SendResult orderSend(final Enum address, final Object message, final String shardingKey);
// SendResult orderSend(final Enum address, final Object message, final String shardingKey,final DeliveryOption deliveryOption);
//
// Producer getProducer(String pid);
// OrderProducer getOrderProducer(String pid);
// void addProducer(String pid);
// void addOrdereProducer(String pid);
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/ProducerSerialize.java
// public interface ProducerSerialize {
//
// byte[] objToBytes(Object object);
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/DeliveryOption.java
// public class DeliveryOption {
// private String key;
// private Long deliverTime;
// public String getKey() {
// return key;
// }
//
// public DeliveryOption(){}
// public DeliveryOption(String key){
// this.key = key;
// }
//
// public DeliveryOption setKey(String key) {
// this.key = key;
// return this;
// }
//
// public Long getDeliverTime() {
// return deliverTime;
// }
//
// public DeliveryOption setDeliverTime(Long deliverTime) {
// this.deliverTime = deliverTime;
// return this;
// }
// }
//
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/models/PendingMsg.java
// public class PendingMsg {
// private Enum anEnum;
// private Object message;
// private DeliveryOption deliveryOption;
// private SendCallback sendCallback;
//
// public PendingMsg(){}
//
// public PendingMsg(Enum anEnum,Object message,DeliveryOption deliveryOption,SendCallback sendCallback){
// this.anEnum =anEnum;
// this.message = message;
// this.deliveryOption = deliveryOption;
// this.sendCallback = sendCallback;
// }
//
//
// public Enum getAnEnum() {
// return anEnum;
// }
//
// public void setAnEnum(Enum anEnum) {
// this.anEnum = anEnum;
// }
//
// public Object getMessage() {
// return message;
// }
//
// public void setMessage(Object message) {
// this.message = message;
// }
//
// public DeliveryOption getDeliveryOption() {
// return deliveryOption;
// }
//
// public void setDeliveryOption(DeliveryOption deliveryOption) {
// this.deliveryOption = deliveryOption;
// }
//
// public SendCallback getSendCallback() {
// return sendCallback;
// }
//
// public void setSendCallback(SendCallback sendCallback) {
// this.sendCallback = sendCallback;
// }
// }
// Path: mq-aliyun-producer-spring-boot-starter/src/main/java/com/github/mq/producer/impls/ProducerFactoryImpl.java
import com.aliyun.openservices.ons.api.*;
import com.aliyun.openservices.ons.api.order.OrderProducer;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.shade.com.alibaba.fastjson.JSONObject;
import com.github.mq.core.scan.constant.MqConstant;
import com.github.mq.producer.ProducerFactory;
import com.github.mq.producer.ProducerSerialize;
import com.github.mq.producer.models.DeliveryOption;
import com.github.mq.producer.models.PendingMsg;
import com.github.mq.producer.models.Pid;
import com.github.mq.producer.models.To;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import java.util.*;
import static java.lang.Thread.sleep;
Message msg = new Message(
to.topic() + suffix,
// 可理解为Gmail中的标签,对消息进行再归类,方便Consumer指定过滤条件在ONS服务器过滤
to.tag().trim(),
// Message Body
// 任何二进制形式的数据, ONS不做任何干预,
// 需要Producer与Consumer协商好一致的序列化和反序列化方式
producerSerialize.objToBytes(message));
if (null != deliveryOption) {
String key = deliveryOption.getKey();
if (!Strings.isNullOrEmpty(key)) {
msg.setKey(key);
}
Long deliverTime = deliveryOption.getDeliverTime();
if (null != deliverTime && 0 != deliverTime)
msg.setStartDeliverTime(deliverTime);
}
return new MessageBuild(pid.value(), msg);
}
public void init(Environment env) {
String package_ = env.getProperty(MQ_PRODUCER_PACKAGES);
if (null == package_) {
throw new RuntimeException(String.format("mq生产者 启动失败, %s is require", MQ_PRODUCER_PACKAGES));
}
packages = package_.split(",");
| accessKey = env.getProperty(MqConstant.ACCESS_KEY); |
onepiecex/mq-aliyun | mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Tag.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractorWrapper.java
// public class ArgumentExtractorWrapper {
// private ArgumentExtractor<?> argumentExtractor;
// private Annotation annotation;
// private Class<?> parameterClass;
//
//
// public Result excuteExtract(Message message){
// return argumentExtractor.extract(message,parameterClass,annotation);
// }
//
// public static ArgumentExtractorWrapper build(ArgumentExtractor argumentExtractor,Annotation annotation,Class<?> parameterClass){
// ArgumentExtractorWrapper extractorWrapper = new ArgumentExtractorWrapper();
// extractorWrapper.setArgumentExtractor(argumentExtractor);
// extractorWrapper.setAnnotation(annotation);
// extractorWrapper.setParameterClass(parameterClass);
// return extractorWrapper;
// }
//
// public ArgumentExtractor<?> getArgumentExtractor() {
// return argumentExtractor;
// }
//
// public void setArgumentExtractor(ArgumentExtractor<?> argumentExtractor) {
// this.argumentExtractor = argumentExtractor;
// }
//
// public Annotation getAnnotation() {
// return annotation;
// }
//
// public void setAnnotation(Annotation annotation) {
// this.annotation = annotation;
// }
//
// public Class<?> getParameterClass() {
// return parameterClass;
// }
//
// public void setParameterClass(Class<?> parameterClass) {
// this.parameterClass = parameterClass;
// }
// }
| import com.esotericsoftware.reflectasm.MethodAccess;
import com.github.mq.consumer.parms.ArgumentExtractorWrapper; | package com.github.mq.consumer.models;
/**
* Created by wangziqing on 17/7/13.
*/
public class Tag {
private MethodAccess methodAccess;
private Object invokeObject;
private Class invokeCls;
private String methodName;
private Integer reconsume;
| // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractorWrapper.java
// public class ArgumentExtractorWrapper {
// private ArgumentExtractor<?> argumentExtractor;
// private Annotation annotation;
// private Class<?> parameterClass;
//
//
// public Result excuteExtract(Message message){
// return argumentExtractor.extract(message,parameterClass,annotation);
// }
//
// public static ArgumentExtractorWrapper build(ArgumentExtractor argumentExtractor,Annotation annotation,Class<?> parameterClass){
// ArgumentExtractorWrapper extractorWrapper = new ArgumentExtractorWrapper();
// extractorWrapper.setArgumentExtractor(argumentExtractor);
// extractorWrapper.setAnnotation(annotation);
// extractorWrapper.setParameterClass(parameterClass);
// return extractorWrapper;
// }
//
// public ArgumentExtractor<?> getArgumentExtractor() {
// return argumentExtractor;
// }
//
// public void setArgumentExtractor(ArgumentExtractor<?> argumentExtractor) {
// this.argumentExtractor = argumentExtractor;
// }
//
// public Annotation getAnnotation() {
// return annotation;
// }
//
// public void setAnnotation(Annotation annotation) {
// this.annotation = annotation;
// }
//
// public Class<?> getParameterClass() {
// return parameterClass;
// }
//
// public void setParameterClass(Class<?> parameterClass) {
// this.parameterClass = parameterClass;
// }
// }
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Tag.java
import com.esotericsoftware.reflectasm.MethodAccess;
import com.github.mq.consumer.parms.ArgumentExtractorWrapper;
package com.github.mq.consumer.models;
/**
* Created by wangziqing on 17/7/13.
*/
public class Tag {
private MethodAccess methodAccess;
private Object invokeObject;
private Class invokeCls;
private String methodName;
private Integer reconsume;
| private ArgumentExtractorWrapper[] argumentExtractors; |
onepiecex/mq-aliyun | mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/JackArgumentExtractor.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Result.java
// public class Result<T> {
// private T result;
// private Action action;
//
// public Result(T result) {
// this.result = result;
// }
//
// public Result(Action action) {
// this.action = action;
// }
//
// public Object getResult() {
// return result;
// }
//
// public Action getAction() {
// return action;
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Results.java
// public class Results {
//
// public static <T> Result<T> next(T result){
// return new Result(result);
// }
//
// public static Result end(Action action){
// return new Result(action);
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractor.java
// public interface ArgumentExtractor<T> {
// Result<T> extract(Message message, Class<?> parameterClass, Annotation annotation);
//
// }
| import com.aliyun.openservices.ons.api.Message;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Result;
import com.github.mq.consumer.models.Results;
import com.github.mq.consumer.parms.ArgumentExtractor;
import java.io.IOException;
import java.lang.annotation.Annotation; | package com.mq.aliyun.example.model;
/**
* Created by wangziqing on 17/7/25.
*/
public class JackArgumentExtractor implements ArgumentExtractor {
private static final ObjectMapper mapper = new ObjectMapper();
@Override | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Result.java
// public class Result<T> {
// private T result;
// private Action action;
//
// public Result(T result) {
// this.result = result;
// }
//
// public Result(Action action) {
// this.action = action;
// }
//
// public Object getResult() {
// return result;
// }
//
// public Action getAction() {
// return action;
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Results.java
// public class Results {
//
// public static <T> Result<T> next(T result){
// return new Result(result);
// }
//
// public static Result end(Action action){
// return new Result(action);
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractor.java
// public interface ArgumentExtractor<T> {
// Result<T> extract(Message message, Class<?> parameterClass, Annotation annotation);
//
// }
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/JackArgumentExtractor.java
import com.aliyun.openservices.ons.api.Message;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Result;
import com.github.mq.consumer.models.Results;
import com.github.mq.consumer.parms.ArgumentExtractor;
import java.io.IOException;
import java.lang.annotation.Annotation;
package com.mq.aliyun.example.model;
/**
* Created by wangziqing on 17/7/25.
*/
public class JackArgumentExtractor implements ArgumentExtractor {
private static final ObjectMapper mapper = new ObjectMapper();
@Override | public Result extract(Message message, Class parameterClass, Annotation annotation) { |
onepiecex/mq-aliyun | mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/JackArgumentExtractor.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Result.java
// public class Result<T> {
// private T result;
// private Action action;
//
// public Result(T result) {
// this.result = result;
// }
//
// public Result(Action action) {
// this.action = action;
// }
//
// public Object getResult() {
// return result;
// }
//
// public Action getAction() {
// return action;
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Results.java
// public class Results {
//
// public static <T> Result<T> next(T result){
// return new Result(result);
// }
//
// public static Result end(Action action){
// return new Result(action);
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractor.java
// public interface ArgumentExtractor<T> {
// Result<T> extract(Message message, Class<?> parameterClass, Annotation annotation);
//
// }
| import com.aliyun.openservices.ons.api.Message;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Result;
import com.github.mq.consumer.models.Results;
import com.github.mq.consumer.parms.ArgumentExtractor;
import java.io.IOException;
import java.lang.annotation.Annotation; | package com.mq.aliyun.example.model;
/**
* Created by wangziqing on 17/7/25.
*/
public class JackArgumentExtractor implements ArgumentExtractor {
private static final ObjectMapper mapper = new ObjectMapper();
@Override
public Result extract(Message message, Class parameterClass, Annotation annotation) {
byte[] body = message.getBody();
try { | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Result.java
// public class Result<T> {
// private T result;
// private Action action;
//
// public Result(T result) {
// this.result = result;
// }
//
// public Result(Action action) {
// this.action = action;
// }
//
// public Object getResult() {
// return result;
// }
//
// public Action getAction() {
// return action;
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Results.java
// public class Results {
//
// public static <T> Result<T> next(T result){
// return new Result(result);
// }
//
// public static Result end(Action action){
// return new Result(action);
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractor.java
// public interface ArgumentExtractor<T> {
// Result<T> extract(Message message, Class<?> parameterClass, Annotation annotation);
//
// }
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/JackArgumentExtractor.java
import com.aliyun.openservices.ons.api.Message;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Result;
import com.github.mq.consumer.models.Results;
import com.github.mq.consumer.parms.ArgumentExtractor;
import java.io.IOException;
import java.lang.annotation.Annotation;
package com.mq.aliyun.example.model;
/**
* Created by wangziqing on 17/7/25.
*/
public class JackArgumentExtractor implements ArgumentExtractor {
private static final ObjectMapper mapper = new ObjectMapper();
@Override
public Result extract(Message message, Class parameterClass, Annotation annotation) {
byte[] body = message.getBody();
try { | return Results.next( mapper.readValue(body,parameterClass)); |
onepiecex/mq-aliyun | mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/JackArgumentExtractor.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Result.java
// public class Result<T> {
// private T result;
// private Action action;
//
// public Result(T result) {
// this.result = result;
// }
//
// public Result(Action action) {
// this.action = action;
// }
//
// public Object getResult() {
// return result;
// }
//
// public Action getAction() {
// return action;
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Results.java
// public class Results {
//
// public static <T> Result<T> next(T result){
// return new Result(result);
// }
//
// public static Result end(Action action){
// return new Result(action);
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractor.java
// public interface ArgumentExtractor<T> {
// Result<T> extract(Message message, Class<?> parameterClass, Annotation annotation);
//
// }
| import com.aliyun.openservices.ons.api.Message;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Result;
import com.github.mq.consumer.models.Results;
import com.github.mq.consumer.parms.ArgumentExtractor;
import java.io.IOException;
import java.lang.annotation.Annotation; | package com.mq.aliyun.example.model;
/**
* Created by wangziqing on 17/7/25.
*/
public class JackArgumentExtractor implements ArgumentExtractor {
private static final ObjectMapper mapper = new ObjectMapper();
@Override
public Result extract(Message message, Class parameterClass, Annotation annotation) {
byte[] body = message.getBody();
try {
return Results.next( mapper.readValue(body,parameterClass));
} catch (IOException e) {
e.printStackTrace();
} | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Action.java
// public enum Action {
// commit,
// reconsume;
// Action(){}
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Result.java
// public class Result<T> {
// private T result;
// private Action action;
//
// public Result(T result) {
// this.result = result;
// }
//
// public Result(Action action) {
// this.action = action;
// }
//
// public Object getResult() {
// return result;
// }
//
// public Action getAction() {
// return action;
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Results.java
// public class Results {
//
// public static <T> Result<T> next(T result){
// return new Result(result);
// }
//
// public static Result end(Action action){
// return new Result(action);
// }
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractor.java
// public interface ArgumentExtractor<T> {
// Result<T> extract(Message message, Class<?> parameterClass, Annotation annotation);
//
// }
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/model/JackArgumentExtractor.java
import com.aliyun.openservices.ons.api.Message;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.mq.consumer.models.Action;
import com.github.mq.consumer.models.Result;
import com.github.mq.consumer.models.Results;
import com.github.mq.consumer.parms.ArgumentExtractor;
import java.io.IOException;
import java.lang.annotation.Annotation;
package com.mq.aliyun.example.model;
/**
* Created by wangziqing on 17/7/25.
*/
public class JackArgumentExtractor implements ArgumentExtractor {
private static final ObjectMapper mapper = new ObjectMapper();
@Override
public Result extract(Message message, Class parameterClass, Annotation annotation) {
byte[] body = message.getBody();
try {
return Results.next( mapper.readValue(body,parameterClass));
} catch (IOException e) {
e.printStackTrace();
} | return Results.end(Action.commit); |
onepiecex/mq-aliyun | mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/impls/ConsumerRun.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractorWrapper.java
// public class ArgumentExtractorWrapper {
// private ArgumentExtractor<?> argumentExtractor;
// private Annotation annotation;
// private Class<?> parameterClass;
//
//
// public Result excuteExtract(Message message){
// return argumentExtractor.extract(message,parameterClass,annotation);
// }
//
// public static ArgumentExtractorWrapper build(ArgumentExtractor argumentExtractor,Annotation annotation,Class<?> parameterClass){
// ArgumentExtractorWrapper extractorWrapper = new ArgumentExtractorWrapper();
// extractorWrapper.setArgumentExtractor(argumentExtractor);
// extractorWrapper.setAnnotation(annotation);
// extractorWrapper.setParameterClass(parameterClass);
// return extractorWrapper;
// }
//
// public ArgumentExtractor<?> getArgumentExtractor() {
// return argumentExtractor;
// }
//
// public void setArgumentExtractor(ArgumentExtractor<?> argumentExtractor) {
// this.argumentExtractor = argumentExtractor;
// }
//
// public Annotation getAnnotation() {
// return annotation;
// }
//
// public void setAnnotation(Annotation annotation) {
// this.annotation = annotation;
// }
//
// public Class<?> getParameterClass() {
// return parameterClass;
// }
//
// public void setParameterClass(Class<?> parameterClass) {
// this.parameterClass = parameterClass;
// }
// }
| import com.aliyun.openservices.ons.api.Consumer;
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.ONSFactory;
import com.aliyun.openservices.ons.api.PropertyKeyConst;
import com.aliyun.openservices.ons.api.order.OrderAction;
import com.aliyun.openservices.ons.api.order.OrderConsumer;
import com.github.mq.consumer.models.*;
import com.github.mq.consumer.parms.ArgumentExtractorWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Properties; | dispatch(consumerId, message, consumerOptional.getMaxReconsume()).equals(Action.commit)?
OrderAction.Success : OrderAction.Suspend
));
orderConsumer.start();
} else {
Consumer consumer = ONSFactory.createConsumer(properties);
consumer.subscribe(topic, tags, (message, context) ->
dispatch(consumerId, message, consumerOptional.getMaxReconsume()).equals(Action.commit)?
com.aliyun.openservices.ons.api.Action.CommitMessage : com.aliyun.openservices.ons.api.Action.ReconsumeLater
);
consumer.start();
}
logger.info("消费者启动成功: {}({}) , 消费模式: {} , 消费线程数: {} , 最大重试次数: {} {} , 订阅 TOPIC: {} TAG: {}",
cid, consumerId.isOrdered()?"有序":"无序",
consumerOptional.getConsumerModel(), consumerOptional.getConsumeThread(), consumerOptional.getMaxReconsume(),
consumerId.isOrdered()?", 重试前的等待时间:"+consumerOptional.getSuspendTime()+"毫秒":"",topic,tags);
}
private static Action dispatch(ConsumerId consumerId, Message message, int defaultReconsume) {
Tag tag = consumerId.getTagMap().get(message.getTag());
if (null == tag) {
throw new RuntimeException(String.format("%s 没有注册 请检查MqConsumer的init配置", message.getTag()));
}
int reconsume = tag.getReconsume() == null ? defaultReconsume : tag.getReconsume();
if (message.getReconsumeTimes() > reconsume) {
logger.warn("超过允许的最大重试次数。 允许的重试次数: {}, 当前重试次数: {} MessageId: {} topic: {} , tag: {}",
reconsume, message.getReconsumeTimes(),message.getMsgID(),message.getTopic(),message.getTag()) ;
return Action.commit;
} | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractorWrapper.java
// public class ArgumentExtractorWrapper {
// private ArgumentExtractor<?> argumentExtractor;
// private Annotation annotation;
// private Class<?> parameterClass;
//
//
// public Result excuteExtract(Message message){
// return argumentExtractor.extract(message,parameterClass,annotation);
// }
//
// public static ArgumentExtractorWrapper build(ArgumentExtractor argumentExtractor,Annotation annotation,Class<?> parameterClass){
// ArgumentExtractorWrapper extractorWrapper = new ArgumentExtractorWrapper();
// extractorWrapper.setArgumentExtractor(argumentExtractor);
// extractorWrapper.setAnnotation(annotation);
// extractorWrapper.setParameterClass(parameterClass);
// return extractorWrapper;
// }
//
// public ArgumentExtractor<?> getArgumentExtractor() {
// return argumentExtractor;
// }
//
// public void setArgumentExtractor(ArgumentExtractor<?> argumentExtractor) {
// this.argumentExtractor = argumentExtractor;
// }
//
// public Annotation getAnnotation() {
// return annotation;
// }
//
// public void setAnnotation(Annotation annotation) {
// this.annotation = annotation;
// }
//
// public Class<?> getParameterClass() {
// return parameterClass;
// }
//
// public void setParameterClass(Class<?> parameterClass) {
// this.parameterClass = parameterClass;
// }
// }
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/impls/ConsumerRun.java
import com.aliyun.openservices.ons.api.Consumer;
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.ONSFactory;
import com.aliyun.openservices.ons.api.PropertyKeyConst;
import com.aliyun.openservices.ons.api.order.OrderAction;
import com.aliyun.openservices.ons.api.order.OrderConsumer;
import com.github.mq.consumer.models.*;
import com.github.mq.consumer.parms.ArgumentExtractorWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Properties;
dispatch(consumerId, message, consumerOptional.getMaxReconsume()).equals(Action.commit)?
OrderAction.Success : OrderAction.Suspend
));
orderConsumer.start();
} else {
Consumer consumer = ONSFactory.createConsumer(properties);
consumer.subscribe(topic, tags, (message, context) ->
dispatch(consumerId, message, consumerOptional.getMaxReconsume()).equals(Action.commit)?
com.aliyun.openservices.ons.api.Action.CommitMessage : com.aliyun.openservices.ons.api.Action.ReconsumeLater
);
consumer.start();
}
logger.info("消费者启动成功: {}({}) , 消费模式: {} , 消费线程数: {} , 最大重试次数: {} {} , 订阅 TOPIC: {} TAG: {}",
cid, consumerId.isOrdered()?"有序":"无序",
consumerOptional.getConsumerModel(), consumerOptional.getConsumeThread(), consumerOptional.getMaxReconsume(),
consumerId.isOrdered()?", 重试前的等待时间:"+consumerOptional.getSuspendTime()+"毫秒":"",topic,tags);
}
private static Action dispatch(ConsumerId consumerId, Message message, int defaultReconsume) {
Tag tag = consumerId.getTagMap().get(message.getTag());
if (null == tag) {
throw new RuntimeException(String.format("%s 没有注册 请检查MqConsumer的init配置", message.getTag()));
}
int reconsume = tag.getReconsume() == null ? defaultReconsume : tag.getReconsume();
if (message.getReconsumeTimes() > reconsume) {
logger.warn("超过允许的最大重试次数。 允许的重试次数: {}, 当前重试次数: {} MessageId: {} topic: {} , tag: {}",
reconsume, message.getReconsumeTimes(),message.getMsgID(),message.getTopic(),message.getTag()) ;
return Action.commit;
} | ArgumentExtractorWrapper[] extractors = tag.getArgumentExtractors(); |
onepiecex/mq-aliyun | mq-aliyun-consumer-spring-boot-starter/src/test/java/com/github/mq/App.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/ConsumerAble.java
// public interface ConsumerAble {
// String BROADCASTING = "BROADCASTING";
// String CLUSTERING = "CLUSTERING";
//
// void init(Ons ons);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/Ons.java
// public interface Ons {
// void defaultTopic(String topic);
// ConsumerBuild consumer(String cid);
// ConsumerBuild consumer(String cid, ConsumerOptional consumerOptional);
//
// ConsumerBuild consumerOrdered(String cid);
// ConsumerBuild consumerOrdered(String cid, ConsumerOptional consumerOptional);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/ConsumerOptional.java
// public class ConsumerOptional {
// //消费线程数
// private Integer consumeThread;
// //消费模式(集群 : CLUSTERING, 广播 : BROADCASTING)
// private String consumerModel;
// //消息消费失败时的最大重试次数
// private Integer maxReconsume;
// //顺序消息消费失败进行重试前的等待时间 单位(毫秒)
// private Integer suspendTime;
//
// public ConsumerOptional(){}
//
// public ConsumerOptional(Integer consumeThread){
// this.consumeThread = consumeThread;
// }
//
// public ConsumerOptional(Integer consumeThread,Integer maxReconsume){
// this.consumeThread = consumeThread;
// this.maxReconsume = maxReconsume;
// }
//
// public Integer getConsumeThread() {
// return consumeThread;
// }
//
// public ConsumerOptional setConsumeThread(Integer consumeThread) {
// this.consumeThread = consumeThread;
// return this;
// }
//
// public String getConsumerModel() {
// return consumerModel;
// }
//
// public ConsumerOptional setConsumerModel(String consumerModel) {
// this.consumerModel = consumerModel;
// return this;
// }
//
// public Integer getMaxReconsume() {
// return maxReconsume;
// }
//
// public ConsumerOptional setMaxReconsume(Integer maxReconsume) {
// this.maxReconsume = maxReconsume;
// return this;
// }
//
// public Integer getSuspendTime() {
// return suspendTime;
// }
//
// public ConsumerOptional setSuspendTime(Integer suspendTime) {
// this.suspendTime = suspendTime;
// return this;
// }
// }
| import com.github.mq.consumer.ConsumerAble;
import com.github.mq.consumer.Ons;
import com.github.mq.consumer.models.ConsumerOptional;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; | package com.github.mq;
/**
* Created by wangziqing on 17/7/20.
*/
@SpringBootApplication
public class App implements ConsumerAble{
@Override | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/ConsumerAble.java
// public interface ConsumerAble {
// String BROADCASTING = "BROADCASTING";
// String CLUSTERING = "CLUSTERING";
//
// void init(Ons ons);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/Ons.java
// public interface Ons {
// void defaultTopic(String topic);
// ConsumerBuild consumer(String cid);
// ConsumerBuild consumer(String cid, ConsumerOptional consumerOptional);
//
// ConsumerBuild consumerOrdered(String cid);
// ConsumerBuild consumerOrdered(String cid, ConsumerOptional consumerOptional);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/ConsumerOptional.java
// public class ConsumerOptional {
// //消费线程数
// private Integer consumeThread;
// //消费模式(集群 : CLUSTERING, 广播 : BROADCASTING)
// private String consumerModel;
// //消息消费失败时的最大重试次数
// private Integer maxReconsume;
// //顺序消息消费失败进行重试前的等待时间 单位(毫秒)
// private Integer suspendTime;
//
// public ConsumerOptional(){}
//
// public ConsumerOptional(Integer consumeThread){
// this.consumeThread = consumeThread;
// }
//
// public ConsumerOptional(Integer consumeThread,Integer maxReconsume){
// this.consumeThread = consumeThread;
// this.maxReconsume = maxReconsume;
// }
//
// public Integer getConsumeThread() {
// return consumeThread;
// }
//
// public ConsumerOptional setConsumeThread(Integer consumeThread) {
// this.consumeThread = consumeThread;
// return this;
// }
//
// public String getConsumerModel() {
// return consumerModel;
// }
//
// public ConsumerOptional setConsumerModel(String consumerModel) {
// this.consumerModel = consumerModel;
// return this;
// }
//
// public Integer getMaxReconsume() {
// return maxReconsume;
// }
//
// public ConsumerOptional setMaxReconsume(Integer maxReconsume) {
// this.maxReconsume = maxReconsume;
// return this;
// }
//
// public Integer getSuspendTime() {
// return suspendTime;
// }
//
// public ConsumerOptional setSuspendTime(Integer suspendTime) {
// this.suspendTime = suspendTime;
// return this;
// }
// }
// Path: mq-aliyun-consumer-spring-boot-starter/src/test/java/com/github/mq/App.java
import com.github.mq.consumer.ConsumerAble;
import com.github.mq.consumer.Ons;
import com.github.mq.consumer.models.ConsumerOptional;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
package com.github.mq;
/**
* Created by wangziqing on 17/7/20.
*/
@SpringBootApplication
public class App implements ConsumerAble{
@Override | public void init(Ons ons) { |
onepiecex/mq-aliyun | mq-aliyun-consumer-spring-boot-starter/src/test/java/com/github/mq/App.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/ConsumerAble.java
// public interface ConsumerAble {
// String BROADCASTING = "BROADCASTING";
// String CLUSTERING = "CLUSTERING";
//
// void init(Ons ons);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/Ons.java
// public interface Ons {
// void defaultTopic(String topic);
// ConsumerBuild consumer(String cid);
// ConsumerBuild consumer(String cid, ConsumerOptional consumerOptional);
//
// ConsumerBuild consumerOrdered(String cid);
// ConsumerBuild consumerOrdered(String cid, ConsumerOptional consumerOptional);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/ConsumerOptional.java
// public class ConsumerOptional {
// //消费线程数
// private Integer consumeThread;
// //消费模式(集群 : CLUSTERING, 广播 : BROADCASTING)
// private String consumerModel;
// //消息消费失败时的最大重试次数
// private Integer maxReconsume;
// //顺序消息消费失败进行重试前的等待时间 单位(毫秒)
// private Integer suspendTime;
//
// public ConsumerOptional(){}
//
// public ConsumerOptional(Integer consumeThread){
// this.consumeThread = consumeThread;
// }
//
// public ConsumerOptional(Integer consumeThread,Integer maxReconsume){
// this.consumeThread = consumeThread;
// this.maxReconsume = maxReconsume;
// }
//
// public Integer getConsumeThread() {
// return consumeThread;
// }
//
// public ConsumerOptional setConsumeThread(Integer consumeThread) {
// this.consumeThread = consumeThread;
// return this;
// }
//
// public String getConsumerModel() {
// return consumerModel;
// }
//
// public ConsumerOptional setConsumerModel(String consumerModel) {
// this.consumerModel = consumerModel;
// return this;
// }
//
// public Integer getMaxReconsume() {
// return maxReconsume;
// }
//
// public ConsumerOptional setMaxReconsume(Integer maxReconsume) {
// this.maxReconsume = maxReconsume;
// return this;
// }
//
// public Integer getSuspendTime() {
// return suspendTime;
// }
//
// public ConsumerOptional setSuspendTime(Integer suspendTime) {
// this.suspendTime = suspendTime;
// return this;
// }
// }
| import com.github.mq.consumer.ConsumerAble;
import com.github.mq.consumer.Ons;
import com.github.mq.consumer.models.ConsumerOptional;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; | package com.github.mq;
/**
* Created by wangziqing on 17/7/20.
*/
@SpringBootApplication
public class App implements ConsumerAble{
@Override
public void init(Ons ons) {
ons.defaultTopic("ww");
ons.consumer("CID").subscribeTag("tag1",TestConsumer::test);
ons.consumer("CID").subscribeTag("tag2",TestConsumer::test);
| // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/ConsumerAble.java
// public interface ConsumerAble {
// String BROADCASTING = "BROADCASTING";
// String CLUSTERING = "CLUSTERING";
//
// void init(Ons ons);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/Ons.java
// public interface Ons {
// void defaultTopic(String topic);
// ConsumerBuild consumer(String cid);
// ConsumerBuild consumer(String cid, ConsumerOptional consumerOptional);
//
// ConsumerBuild consumerOrdered(String cid);
// ConsumerBuild consumerOrdered(String cid, ConsumerOptional consumerOptional);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/ConsumerOptional.java
// public class ConsumerOptional {
// //消费线程数
// private Integer consumeThread;
// //消费模式(集群 : CLUSTERING, 广播 : BROADCASTING)
// private String consumerModel;
// //消息消费失败时的最大重试次数
// private Integer maxReconsume;
// //顺序消息消费失败进行重试前的等待时间 单位(毫秒)
// private Integer suspendTime;
//
// public ConsumerOptional(){}
//
// public ConsumerOptional(Integer consumeThread){
// this.consumeThread = consumeThread;
// }
//
// public ConsumerOptional(Integer consumeThread,Integer maxReconsume){
// this.consumeThread = consumeThread;
// this.maxReconsume = maxReconsume;
// }
//
// public Integer getConsumeThread() {
// return consumeThread;
// }
//
// public ConsumerOptional setConsumeThread(Integer consumeThread) {
// this.consumeThread = consumeThread;
// return this;
// }
//
// public String getConsumerModel() {
// return consumerModel;
// }
//
// public ConsumerOptional setConsumerModel(String consumerModel) {
// this.consumerModel = consumerModel;
// return this;
// }
//
// public Integer getMaxReconsume() {
// return maxReconsume;
// }
//
// public ConsumerOptional setMaxReconsume(Integer maxReconsume) {
// this.maxReconsume = maxReconsume;
// return this;
// }
//
// public Integer getSuspendTime() {
// return suspendTime;
// }
//
// public ConsumerOptional setSuspendTime(Integer suspendTime) {
// this.suspendTime = suspendTime;
// return this;
// }
// }
// Path: mq-aliyun-consumer-spring-boot-starter/src/test/java/com/github/mq/App.java
import com.github.mq.consumer.ConsumerAble;
import com.github.mq.consumer.Ons;
import com.github.mq.consumer.models.ConsumerOptional;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
package com.github.mq;
/**
* Created by wangziqing on 17/7/20.
*/
@SpringBootApplication
public class App implements ConsumerAble{
@Override
public void init(Ons ons) {
ons.defaultTopic("ww");
ons.consumer("CID").subscribeTag("tag1",TestConsumer::test);
ons.consumer("CID").subscribeTag("tag2",TestConsumer::test);
| ons.consumerOrdered("CID2",new ConsumerOptional(10,30)).subscribeTag("tag_a || tab_c",TestConsumer::test); |
Trolldad/Reddit-Headlines | Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/reddit/RedditClient.java | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/RedditHeadlinesApplication.java
// @EApplication
// public class RedditHeadlinesApplication extends Application {
// public static final String TAG = "RedditHeadlinesApplication";
// private static RedditHeadlinesApplication mInstance;
//
// @Override
// public void onCreate() {
// super.onCreate();
// EasyTracker.getInstance(this);
// Thread.UncaughtExceptionHandler uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
// if (uncaughtExceptionHandler instanceof ExceptionReporter) {
// ExceptionReporter exceptionReporter = (ExceptionReporter) uncaughtExceptionHandler;
// exceptionReporter.setExceptionParser(new AnalyticsExceptionParser());
// }
// mInstance = this;
// }
//
// public static Context getContext() {
// return mInstance;
// }
//
// public static void toast(String message) {
// mInstance.makeToast(message);
// }
//
// @UiThread
// void makeToast(String message) {
// Toast.makeText(getContext(), message, Toast.LENGTH_LONG).show();
// }
// }
| import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import net.trolldad.dashclock.redditheadlines.R;
import net.trolldad.dashclock.redditheadlines.RedditHeadlinesApplication;
import net.trolldad.dashclock.redditheadlines.preferences.MyPrefs_;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.res.StringRes;
import org.androidannotations.annotations.sharedpreferences.Pref;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.net.URLEncoder;
import retrofit.RequestInterceptor;
import retrofit.RestAdapter;
import retrofit.converter.GsonConverter; | package net.trolldad.dashclock.redditheadlines.reddit;
/**
* Created by jacob-tabak on 1/19/14.
*/
@EBean
public class RedditClient {
@StringRes(R.string.reddit_base_url) String mRedditApiUrl;
@Pref
MyPrefs_ mPrefs;
public RedditService getService() {
RestAdapter restAdapter = new RestAdapter.Builder()
.setServer(mRedditApiUrl)
.setRequestInterceptor(new RedditServiceInterceptor())
.setConverter(new GsonConverter(getGson()))
.setLog(new RedditLog())
.setLogLevel(RestAdapter.LogLevel.FULL)
.build();
return restAdapter.create(RedditService.class);
}
class RedditLog implements RestAdapter.Log {
@Override
public void log(String s) {
Log.d("RedditLog", s);
}
}
class RedditServiceInterceptor implements RequestInterceptor {
@Override
public void intercept(RequestFacade requestFacade) {
try {
requestFacade.addHeader("cookie", "reddit_session=" + URLEncoder.encode(mPrefs.cookie().get(), "UTF-8"));
requestFacade.addHeader("X-Modhash", URLEncoder.encode(mPrefs.modHash().get(), "UTF-8"));
} catch (UnsupportedEncodingException e) { | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/RedditHeadlinesApplication.java
// @EApplication
// public class RedditHeadlinesApplication extends Application {
// public static final String TAG = "RedditHeadlinesApplication";
// private static RedditHeadlinesApplication mInstance;
//
// @Override
// public void onCreate() {
// super.onCreate();
// EasyTracker.getInstance(this);
// Thread.UncaughtExceptionHandler uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
// if (uncaughtExceptionHandler instanceof ExceptionReporter) {
// ExceptionReporter exceptionReporter = (ExceptionReporter) uncaughtExceptionHandler;
// exceptionReporter.setExceptionParser(new AnalyticsExceptionParser());
// }
// mInstance = this;
// }
//
// public static Context getContext() {
// return mInstance;
// }
//
// public static void toast(String message) {
// mInstance.makeToast(message);
// }
//
// @UiThread
// void makeToast(String message) {
// Toast.makeText(getContext(), message, Toast.LENGTH_LONG).show();
// }
// }
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/reddit/RedditClient.java
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import net.trolldad.dashclock.redditheadlines.R;
import net.trolldad.dashclock.redditheadlines.RedditHeadlinesApplication;
import net.trolldad.dashclock.redditheadlines.preferences.MyPrefs_;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.res.StringRes;
import org.androidannotations.annotations.sharedpreferences.Pref;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.net.URLEncoder;
import retrofit.RequestInterceptor;
import retrofit.RestAdapter;
import retrofit.converter.GsonConverter;
package net.trolldad.dashclock.redditheadlines.reddit;
/**
* Created by jacob-tabak on 1/19/14.
*/
@EBean
public class RedditClient {
@StringRes(R.string.reddit_base_url) String mRedditApiUrl;
@Pref
MyPrefs_ mPrefs;
public RedditService getService() {
RestAdapter restAdapter = new RestAdapter.Builder()
.setServer(mRedditApiUrl)
.setRequestInterceptor(new RedditServiceInterceptor())
.setConverter(new GsonConverter(getGson()))
.setLog(new RedditLog())
.setLogLevel(RestAdapter.LogLevel.FULL)
.build();
return restAdapter.create(RedditService.class);
}
class RedditLog implements RestAdapter.Log {
@Override
public void log(String s) {
Log.d("RedditLog", s);
}
}
class RedditServiceInterceptor implements RequestInterceptor {
@Override
public void intercept(RequestFacade requestFacade) {
try {
requestFacade.addHeader("cookie", "reddit_session=" + URLEncoder.encode(mPrefs.cookie().get(), "UTF-8"));
requestFacade.addHeader("X-Modhash", URLEncoder.encode(mPrefs.modHash().get(), "UTF-8"));
} catch (UnsupportedEncodingException e) { | Log.e(RedditHeadlinesApplication.TAG, Log.getStackTraceString(e)); |
Trolldad/Reddit-Headlines | Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/view/FakeActionBarIcon.java | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/RedditHeadlinesApplication.java
// @EApplication
// public class RedditHeadlinesApplication extends Application {
// public static final String TAG = "RedditHeadlinesApplication";
// private static RedditHeadlinesApplication mInstance;
//
// @Override
// public void onCreate() {
// super.onCreate();
// EasyTracker.getInstance(this);
// Thread.UncaughtExceptionHandler uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
// if (uncaughtExceptionHandler instanceof ExceptionReporter) {
// ExceptionReporter exceptionReporter = (ExceptionReporter) uncaughtExceptionHandler;
// exceptionReporter.setExceptionParser(new AnalyticsExceptionParser());
// }
// mInstance = this;
// }
//
// public static Context getContext() {
// return mInstance;
// }
//
// public static void toast(String message) {
// mInstance.makeToast(message);
// }
//
// @UiThread
// void makeToast(String message) {
// Toast.makeText(getContext(), message, Toast.LENGTH_LONG).show();
// }
// }
| import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import net.trolldad.dashclock.redditheadlines.R;
import net.trolldad.dashclock.redditheadlines.RedditHeadlinesApplication; | package net.trolldad.dashclock.redditheadlines.view;
/**
* Created by jacob-tabak on 1/25/14.
*/
public class FakeActionBarIcon extends ImageView implements View.OnLongClickListener {
public FakeActionBarIcon(Context context, AttributeSet attrs) {
super(context, attrs);
int pixels = (int) getResources().getDimension(R.dimen.fake_actionbar_icon_padding);
setPadding(pixels, 0, pixels, 0);
setOnLongClickListener(this);
}
@Override
public boolean onLongClick(View v) { | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/RedditHeadlinesApplication.java
// @EApplication
// public class RedditHeadlinesApplication extends Application {
// public static final String TAG = "RedditHeadlinesApplication";
// private static RedditHeadlinesApplication mInstance;
//
// @Override
// public void onCreate() {
// super.onCreate();
// EasyTracker.getInstance(this);
// Thread.UncaughtExceptionHandler uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
// if (uncaughtExceptionHandler instanceof ExceptionReporter) {
// ExceptionReporter exceptionReporter = (ExceptionReporter) uncaughtExceptionHandler;
// exceptionReporter.setExceptionParser(new AnalyticsExceptionParser());
// }
// mInstance = this;
// }
//
// public static Context getContext() {
// return mInstance;
// }
//
// public static void toast(String message) {
// mInstance.makeToast(message);
// }
//
// @UiThread
// void makeToast(String message) {
// Toast.makeText(getContext(), message, Toast.LENGTH_LONG).show();
// }
// }
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/view/FakeActionBarIcon.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import net.trolldad.dashclock.redditheadlines.R;
import net.trolldad.dashclock.redditheadlines.RedditHeadlinesApplication;
package net.trolldad.dashclock.redditheadlines.view;
/**
* Created by jacob-tabak on 1/25/14.
*/
public class FakeActionBarIcon extends ImageView implements View.OnLongClickListener {
public FakeActionBarIcon(Context context, AttributeSet attrs) {
super(context, attrs);
int pixels = (int) getResources().getDimension(R.dimen.fake_actionbar_icon_padding);
setPadding(pixels, 0, pixels, 0);
setOnLongClickListener(this);
}
@Override
public boolean onLongClick(View v) { | RedditHeadlinesApplication.toast(getContentDescription().toString()); |
Trolldad/Reddit-Headlines | Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/fragment/ImgurAlbumFragment.java | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurAlbum.java
// public class ImgurAlbum implements Serializable {
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String cover;
// public String account_url;
// public String privacy;
// public String layout;
// public long views;
// public String link;
// public String deletehash;
// public int images_count;
// public ImgurImage[] images;
// }
//
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurImage.java
// public class ImgurImage implements Serializable {
// public static final String THUMB_SIZE_HUGE = "h";
// public static final String ORIGINAL_SIZE = "";
// public static final int MAX_WIDTH_OR_HEIGHT = 2048;
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String type;
// public boolean animated;
// public int width;
// public int height;
// public long size;
// public long views;
// public long bandwidth;
// public String deletehash;
// public String section;
// public String link;
//
// /**
// * Gets a thumb, more info here: http://api.imgur.com/models/image
// *
// * @param suffix
// * @return
// */
// public String getResizedImage(String suffix) {
// // if they don't want a thumb, make sure the image is small enough to display
// if (suffix.length() == 0 && (width > MAX_WIDTH_OR_HEIGHT || height > MAX_WIDTH_OR_HEIGHT)) {
// suffix = THUMB_SIZE_HUGE;
// }
// int dotPosition = link.lastIndexOf(".");
// StringBuilder thumbBuilder = new StringBuilder(link.substring(0, dotPosition));
// thumbBuilder.append(suffix);
// thumbBuilder.append(link.substring(dotPosition));
// return thumbBuilder.toString();
// }
//
// public boolean isHighQualityAvailable(int thumbDimension) {
// return (width > thumbDimension || height > thumbDimension);
// }
// }
| import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.v13.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import com.viewpagerindicator.UnderlinePageIndicator;
import net.trolldad.dashclock.redditheadlines.R;
import net.trolldad.dashclock.redditheadlines.imgur.ImgurAlbum;
import net.trolldad.dashclock.redditheadlines.imgur.ImgurImage;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.FragmentArg;
import org.androidannotations.annotations.InstanceState;
import org.androidannotations.annotations.UiThread;
import org.androidannotations.annotations.ViewById; | package net.trolldad.dashclock.redditheadlines.fragment;
/**
* Created by jacob-tabak on 1/19/14.
*/
@EFragment(R.layout.fragment_album_viewpager)
public class ImgurAlbumFragment extends Fragment {
@FragmentArg | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurAlbum.java
// public class ImgurAlbum implements Serializable {
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String cover;
// public String account_url;
// public String privacy;
// public String layout;
// public long views;
// public String link;
// public String deletehash;
// public int images_count;
// public ImgurImage[] images;
// }
//
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurImage.java
// public class ImgurImage implements Serializable {
// public static final String THUMB_SIZE_HUGE = "h";
// public static final String ORIGINAL_SIZE = "";
// public static final int MAX_WIDTH_OR_HEIGHT = 2048;
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String type;
// public boolean animated;
// public int width;
// public int height;
// public long size;
// public long views;
// public long bandwidth;
// public String deletehash;
// public String section;
// public String link;
//
// /**
// * Gets a thumb, more info here: http://api.imgur.com/models/image
// *
// * @param suffix
// * @return
// */
// public String getResizedImage(String suffix) {
// // if they don't want a thumb, make sure the image is small enough to display
// if (suffix.length() == 0 && (width > MAX_WIDTH_OR_HEIGHT || height > MAX_WIDTH_OR_HEIGHT)) {
// suffix = THUMB_SIZE_HUGE;
// }
// int dotPosition = link.lastIndexOf(".");
// StringBuilder thumbBuilder = new StringBuilder(link.substring(0, dotPosition));
// thumbBuilder.append(suffix);
// thumbBuilder.append(link.substring(dotPosition));
// return thumbBuilder.toString();
// }
//
// public boolean isHighQualityAvailable(int thumbDimension) {
// return (width > thumbDimension || height > thumbDimension);
// }
// }
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/fragment/ImgurAlbumFragment.java
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.v13.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import com.viewpagerindicator.UnderlinePageIndicator;
import net.trolldad.dashclock.redditheadlines.R;
import net.trolldad.dashclock.redditheadlines.imgur.ImgurAlbum;
import net.trolldad.dashclock.redditheadlines.imgur.ImgurImage;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.FragmentArg;
import org.androidannotations.annotations.InstanceState;
import org.androidannotations.annotations.UiThread;
import org.androidannotations.annotations.ViewById;
package net.trolldad.dashclock.redditheadlines.fragment;
/**
* Created by jacob-tabak on 1/19/14.
*/
@EFragment(R.layout.fragment_album_viewpager)
public class ImgurAlbumFragment extends Fragment {
@FragmentArg | ImgurAlbum mAlbum; |
Trolldad/Reddit-Headlines | Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/fragment/ImgurAlbumFragment.java | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurAlbum.java
// public class ImgurAlbum implements Serializable {
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String cover;
// public String account_url;
// public String privacy;
// public String layout;
// public long views;
// public String link;
// public String deletehash;
// public int images_count;
// public ImgurImage[] images;
// }
//
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurImage.java
// public class ImgurImage implements Serializable {
// public static final String THUMB_SIZE_HUGE = "h";
// public static final String ORIGINAL_SIZE = "";
// public static final int MAX_WIDTH_OR_HEIGHT = 2048;
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String type;
// public boolean animated;
// public int width;
// public int height;
// public long size;
// public long views;
// public long bandwidth;
// public String deletehash;
// public String section;
// public String link;
//
// /**
// * Gets a thumb, more info here: http://api.imgur.com/models/image
// *
// * @param suffix
// * @return
// */
// public String getResizedImage(String suffix) {
// // if they don't want a thumb, make sure the image is small enough to display
// if (suffix.length() == 0 && (width > MAX_WIDTH_OR_HEIGHT || height > MAX_WIDTH_OR_HEIGHT)) {
// suffix = THUMB_SIZE_HUGE;
// }
// int dotPosition = link.lastIndexOf(".");
// StringBuilder thumbBuilder = new StringBuilder(link.substring(0, dotPosition));
// thumbBuilder.append(suffix);
// thumbBuilder.append(link.substring(dotPosition));
// return thumbBuilder.toString();
// }
//
// public boolean isHighQualityAvailable(int thumbDimension) {
// return (width > thumbDimension || height > thumbDimension);
// }
// }
| import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.v13.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import com.viewpagerindicator.UnderlinePageIndicator;
import net.trolldad.dashclock.redditheadlines.R;
import net.trolldad.dashclock.redditheadlines.imgur.ImgurAlbum;
import net.trolldad.dashclock.redditheadlines.imgur.ImgurImage;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.FragmentArg;
import org.androidannotations.annotations.InstanceState;
import org.androidannotations.annotations.UiThread;
import org.androidannotations.annotations.ViewById; | package net.trolldad.dashclock.redditheadlines.fragment;
/**
* Created by jacob-tabak on 1/19/14.
*/
@EFragment(R.layout.fragment_album_viewpager)
public class ImgurAlbumFragment extends Fragment {
@FragmentArg
ImgurAlbum mAlbum;
@ViewById(R.id.album_placeholder)
ImageView mPlaceholder;
@ViewById(R.id.album_viewpager)
ViewPager mPager;
@ViewById(R.id.album_line_page_indicator)
UnderlinePageIndicator mIndicator;
@InstanceState
int mCurrentPage;
private AlbumAdapter mAdapter;
@AfterViews
void init() {
mAdapter = new AlbumAdapter(getChildFragmentManager());
mPager.setAdapter(mAdapter);
mIndicator.setViewPager(mPager, mCurrentPage);
mIndicator.setFades(false);
updateImages(mAlbum.images);
}
@UiThread | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurAlbum.java
// public class ImgurAlbum implements Serializable {
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String cover;
// public String account_url;
// public String privacy;
// public String layout;
// public long views;
// public String link;
// public String deletehash;
// public int images_count;
// public ImgurImage[] images;
// }
//
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurImage.java
// public class ImgurImage implements Serializable {
// public static final String THUMB_SIZE_HUGE = "h";
// public static final String ORIGINAL_SIZE = "";
// public static final int MAX_WIDTH_OR_HEIGHT = 2048;
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String type;
// public boolean animated;
// public int width;
// public int height;
// public long size;
// public long views;
// public long bandwidth;
// public String deletehash;
// public String section;
// public String link;
//
// /**
// * Gets a thumb, more info here: http://api.imgur.com/models/image
// *
// * @param suffix
// * @return
// */
// public String getResizedImage(String suffix) {
// // if they don't want a thumb, make sure the image is small enough to display
// if (suffix.length() == 0 && (width > MAX_WIDTH_OR_HEIGHT || height > MAX_WIDTH_OR_HEIGHT)) {
// suffix = THUMB_SIZE_HUGE;
// }
// int dotPosition = link.lastIndexOf(".");
// StringBuilder thumbBuilder = new StringBuilder(link.substring(0, dotPosition));
// thumbBuilder.append(suffix);
// thumbBuilder.append(link.substring(dotPosition));
// return thumbBuilder.toString();
// }
//
// public boolean isHighQualityAvailable(int thumbDimension) {
// return (width > thumbDimension || height > thumbDimension);
// }
// }
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/fragment/ImgurAlbumFragment.java
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.v13.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import com.viewpagerindicator.UnderlinePageIndicator;
import net.trolldad.dashclock.redditheadlines.R;
import net.trolldad.dashclock.redditheadlines.imgur.ImgurAlbum;
import net.trolldad.dashclock.redditheadlines.imgur.ImgurImage;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.FragmentArg;
import org.androidannotations.annotations.InstanceState;
import org.androidannotations.annotations.UiThread;
import org.androidannotations.annotations.ViewById;
package net.trolldad.dashclock.redditheadlines.fragment;
/**
* Created by jacob-tabak on 1/19/14.
*/
@EFragment(R.layout.fragment_album_viewpager)
public class ImgurAlbumFragment extends Fragment {
@FragmentArg
ImgurAlbum mAlbum;
@ViewById(R.id.album_placeholder)
ImageView mPlaceholder;
@ViewById(R.id.album_viewpager)
ViewPager mPager;
@ViewById(R.id.album_line_page_indicator)
UnderlinePageIndicator mIndicator;
@InstanceState
int mCurrentPage;
private AlbumAdapter mAdapter;
@AfterViews
void init() {
mAdapter = new AlbumAdapter(getChildFragmentManager());
mPager.setAdapter(mAdapter);
mIndicator.setViewPager(mPager, mCurrentPage);
mIndicator.setFades(false);
updateImages(mAlbum.images);
}
@UiThread | void updateImages(ImgurImage[] images) { |
Trolldad/Reddit-Headlines | Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/otto/UpdateService.java | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/RedditHeadlinesApplication.java
// @EApplication
// public class RedditHeadlinesApplication extends Application {
// public static final String TAG = "RedditHeadlinesApplication";
// private static RedditHeadlinesApplication mInstance;
//
// @Override
// public void onCreate() {
// super.onCreate();
// EasyTracker.getInstance(this);
// Thread.UncaughtExceptionHandler uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
// if (uncaughtExceptionHandler instanceof ExceptionReporter) {
// ExceptionReporter exceptionReporter = (ExceptionReporter) uncaughtExceptionHandler;
// exceptionReporter.setExceptionParser(new AnalyticsExceptionParser());
// }
// mInstance = this;
// }
//
// public static Context getContext() {
// return mInstance;
// }
//
// public static void toast(String message) {
// mInstance.makeToast(message);
// }
//
// @UiThread
// void makeToast(String message) {
// Toast.makeText(getContext(), message, Toast.LENGTH_LONG).show();
// }
// }
| import android.util.Log;
import com.squareup.otto.Produce;
import net.trolldad.dashclock.redditheadlines.RedditHeadlinesApplication;
import org.androidannotations.annotations.AfterInject;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.UiThread; | package net.trolldad.dashclock.redditheadlines.otto;
/**
* Created by jacob-tabak on 1/29/14.
*/
@EBean(scope = EBean.Scope.Singleton)
public class UpdateService {
@Bean
MyBus mBus;
@AfterInject
void init() {
mBus.register(this);
}
@UiThread
public void onUpdateDashClock() { | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/RedditHeadlinesApplication.java
// @EApplication
// public class RedditHeadlinesApplication extends Application {
// public static final String TAG = "RedditHeadlinesApplication";
// private static RedditHeadlinesApplication mInstance;
//
// @Override
// public void onCreate() {
// super.onCreate();
// EasyTracker.getInstance(this);
// Thread.UncaughtExceptionHandler uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
// if (uncaughtExceptionHandler instanceof ExceptionReporter) {
// ExceptionReporter exceptionReporter = (ExceptionReporter) uncaughtExceptionHandler;
// exceptionReporter.setExceptionParser(new AnalyticsExceptionParser());
// }
// mInstance = this;
// }
//
// public static Context getContext() {
// return mInstance;
// }
//
// public static void toast(String message) {
// mInstance.makeToast(message);
// }
//
// @UiThread
// void makeToast(String message) {
// Toast.makeText(getContext(), message, Toast.LENGTH_LONG).show();
// }
// }
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/otto/UpdateService.java
import android.util.Log;
import com.squareup.otto.Produce;
import net.trolldad.dashclock.redditheadlines.RedditHeadlinesApplication;
import org.androidannotations.annotations.AfterInject;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.UiThread;
package net.trolldad.dashclock.redditheadlines.otto;
/**
* Created by jacob-tabak on 1/29/14.
*/
@EBean(scope = EBean.Scope.Singleton)
public class UpdateService {
@Bean
MyBus mBus;
@AfterInject
void init() {
mBus.register(this);
}
@UiThread
public void onUpdateDashClock() { | Log.d(RedditHeadlinesApplication.TAG, "Posting update event to service"); |
Trolldad/Reddit-Headlines | Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/RedditHeadlinesApplication.java | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/analytics/AnalyticsExceptionParser.java
// public class AnalyticsExceptionParser implements ExceptionParser {
// public String getDescription(String thread, Throwable throwable) {
// return "Thread: " + thread + ", Exception: " + Log.getStackTraceString(throwable);
// }
// }
| import android.app.Application;
import android.content.Context;
import android.widget.Toast;
import com.google.analytics.tracking.android.EasyTracker;
import com.google.analytics.tracking.android.ExceptionReporter;
import net.trolldad.dashclock.redditheadlines.analytics.AnalyticsExceptionParser;
import org.androidannotations.annotations.EApplication;
import org.androidannotations.annotations.UiThread; | package net.trolldad.dashclock.redditheadlines;
/**
* Created by jacob-tabak on 1/3/14.
*/
@EApplication
public class RedditHeadlinesApplication extends Application {
public static final String TAG = "RedditHeadlinesApplication";
private static RedditHeadlinesApplication mInstance;
@Override
public void onCreate() {
super.onCreate();
EasyTracker.getInstance(this);
Thread.UncaughtExceptionHandler uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
if (uncaughtExceptionHandler instanceof ExceptionReporter) {
ExceptionReporter exceptionReporter = (ExceptionReporter) uncaughtExceptionHandler; | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/analytics/AnalyticsExceptionParser.java
// public class AnalyticsExceptionParser implements ExceptionParser {
// public String getDescription(String thread, Throwable throwable) {
// return "Thread: " + thread + ", Exception: " + Log.getStackTraceString(throwable);
// }
// }
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/RedditHeadlinesApplication.java
import android.app.Application;
import android.content.Context;
import android.widget.Toast;
import com.google.analytics.tracking.android.EasyTracker;
import com.google.analytics.tracking.android.ExceptionReporter;
import net.trolldad.dashclock.redditheadlines.analytics.AnalyticsExceptionParser;
import org.androidannotations.annotations.EApplication;
import org.androidannotations.annotations.UiThread;
package net.trolldad.dashclock.redditheadlines;
/**
* Created by jacob-tabak on 1/3/14.
*/
@EApplication
public class RedditHeadlinesApplication extends Application {
public static final String TAG = "RedditHeadlinesApplication";
private static RedditHeadlinesApplication mInstance;
@Override
public void onCreate() {
super.onCreate();
EasyTracker.getInstance(this);
Thread.UncaughtExceptionHandler uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
if (uncaughtExceptionHandler instanceof ExceptionReporter) {
ExceptionReporter exceptionReporter = (ExceptionReporter) uncaughtExceptionHandler; | exceptionReporter.setExceptionParser(new AnalyticsExceptionParser()); |
Trolldad/Reddit-Headlines | Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/cache/ContentCache.java | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurAlbum.java
// public class ImgurAlbum implements Serializable {
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String cover;
// public String account_url;
// public String privacy;
// public String layout;
// public long views;
// public String link;
// public String deletehash;
// public int images_count;
// public ImgurImage[] images;
// }
//
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurImage.java
// public class ImgurImage implements Serializable {
// public static final String THUMB_SIZE_HUGE = "h";
// public static final String ORIGINAL_SIZE = "";
// public static final int MAX_WIDTH_OR_HEIGHT = 2048;
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String type;
// public boolean animated;
// public int width;
// public int height;
// public long size;
// public long views;
// public long bandwidth;
// public String deletehash;
// public String section;
// public String link;
//
// /**
// * Gets a thumb, more info here: http://api.imgur.com/models/image
// *
// * @param suffix
// * @return
// */
// public String getResizedImage(String suffix) {
// // if they don't want a thumb, make sure the image is small enough to display
// if (suffix.length() == 0 && (width > MAX_WIDTH_OR_HEIGHT || height > MAX_WIDTH_OR_HEIGHT)) {
// suffix = THUMB_SIZE_HUGE;
// }
// int dotPosition = link.lastIndexOf(".");
// StringBuilder thumbBuilder = new StringBuilder(link.substring(0, dotPosition));
// thumbBuilder.append(suffix);
// thumbBuilder.append(link.substring(dotPosition));
// return thumbBuilder.toString();
// }
//
// public boolean isHighQualityAvailable(int thumbDimension) {
// return (width > thumbDimension || height > thumbDimension);
// }
// }
//
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/reddit/RedditLink.java
// public class RedditLink extends RedditListing implements Serializable {
// public String id;
// public String name;
// public String domain;
// public String subreddit;
// public String selftext;
// public String selftext_html;
// public String author;
// public String score;
// public String ups;
// public String downs;
// public Boolean saved;
// public Boolean is_self;
// public Boolean likes;
// public String permalink;
// public DateTime created_utc;
// public String url;
// public String title;
// public Boolean hidden;
// }
| import net.trolldad.dashclock.redditheadlines.imgur.ImgurAlbum;
import net.trolldad.dashclock.redditheadlines.imgur.ImgurImage;
import net.trolldad.dashclock.redditheadlines.reddit.RedditLink;
import org.androidannotations.annotations.EBean; | package net.trolldad.dashclock.redditheadlines.cache;
/**
* Created by jacob-tabak on 2/1/14.
*/
@EBean(scope = EBean.Scope.Singleton)
public class ContentCache {
| // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurAlbum.java
// public class ImgurAlbum implements Serializable {
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String cover;
// public String account_url;
// public String privacy;
// public String layout;
// public long views;
// public String link;
// public String deletehash;
// public int images_count;
// public ImgurImage[] images;
// }
//
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurImage.java
// public class ImgurImage implements Serializable {
// public static final String THUMB_SIZE_HUGE = "h";
// public static final String ORIGINAL_SIZE = "";
// public static final int MAX_WIDTH_OR_HEIGHT = 2048;
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String type;
// public boolean animated;
// public int width;
// public int height;
// public long size;
// public long views;
// public long bandwidth;
// public String deletehash;
// public String section;
// public String link;
//
// /**
// * Gets a thumb, more info here: http://api.imgur.com/models/image
// *
// * @param suffix
// * @return
// */
// public String getResizedImage(String suffix) {
// // if they don't want a thumb, make sure the image is small enough to display
// if (suffix.length() == 0 && (width > MAX_WIDTH_OR_HEIGHT || height > MAX_WIDTH_OR_HEIGHT)) {
// suffix = THUMB_SIZE_HUGE;
// }
// int dotPosition = link.lastIndexOf(".");
// StringBuilder thumbBuilder = new StringBuilder(link.substring(0, dotPosition));
// thumbBuilder.append(suffix);
// thumbBuilder.append(link.substring(dotPosition));
// return thumbBuilder.toString();
// }
//
// public boolean isHighQualityAvailable(int thumbDimension) {
// return (width > thumbDimension || height > thumbDimension);
// }
// }
//
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/reddit/RedditLink.java
// public class RedditLink extends RedditListing implements Serializable {
// public String id;
// public String name;
// public String domain;
// public String subreddit;
// public String selftext;
// public String selftext_html;
// public String author;
// public String score;
// public String ups;
// public String downs;
// public Boolean saved;
// public Boolean is_self;
// public Boolean likes;
// public String permalink;
// public DateTime created_utc;
// public String url;
// public String title;
// public Boolean hidden;
// }
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/cache/ContentCache.java
import net.trolldad.dashclock.redditheadlines.imgur.ImgurAlbum;
import net.trolldad.dashclock.redditheadlines.imgur.ImgurImage;
import net.trolldad.dashclock.redditheadlines.reddit.RedditLink;
import org.androidannotations.annotations.EBean;
package net.trolldad.dashclock.redditheadlines.cache;
/**
* Created by jacob-tabak on 2/1/14.
*/
@EBean(scope = EBean.Scope.Singleton)
public class ContentCache {
| public ImgurImage image; |
Trolldad/Reddit-Headlines | Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/cache/ContentCache.java | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurAlbum.java
// public class ImgurAlbum implements Serializable {
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String cover;
// public String account_url;
// public String privacy;
// public String layout;
// public long views;
// public String link;
// public String deletehash;
// public int images_count;
// public ImgurImage[] images;
// }
//
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurImage.java
// public class ImgurImage implements Serializable {
// public static final String THUMB_SIZE_HUGE = "h";
// public static final String ORIGINAL_SIZE = "";
// public static final int MAX_WIDTH_OR_HEIGHT = 2048;
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String type;
// public boolean animated;
// public int width;
// public int height;
// public long size;
// public long views;
// public long bandwidth;
// public String deletehash;
// public String section;
// public String link;
//
// /**
// * Gets a thumb, more info here: http://api.imgur.com/models/image
// *
// * @param suffix
// * @return
// */
// public String getResizedImage(String suffix) {
// // if they don't want a thumb, make sure the image is small enough to display
// if (suffix.length() == 0 && (width > MAX_WIDTH_OR_HEIGHT || height > MAX_WIDTH_OR_HEIGHT)) {
// suffix = THUMB_SIZE_HUGE;
// }
// int dotPosition = link.lastIndexOf(".");
// StringBuilder thumbBuilder = new StringBuilder(link.substring(0, dotPosition));
// thumbBuilder.append(suffix);
// thumbBuilder.append(link.substring(dotPosition));
// return thumbBuilder.toString();
// }
//
// public boolean isHighQualityAvailable(int thumbDimension) {
// return (width > thumbDimension || height > thumbDimension);
// }
// }
//
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/reddit/RedditLink.java
// public class RedditLink extends RedditListing implements Serializable {
// public String id;
// public String name;
// public String domain;
// public String subreddit;
// public String selftext;
// public String selftext_html;
// public String author;
// public String score;
// public String ups;
// public String downs;
// public Boolean saved;
// public Boolean is_self;
// public Boolean likes;
// public String permalink;
// public DateTime created_utc;
// public String url;
// public String title;
// public Boolean hidden;
// }
| import net.trolldad.dashclock.redditheadlines.imgur.ImgurAlbum;
import net.trolldad.dashclock.redditheadlines.imgur.ImgurImage;
import net.trolldad.dashclock.redditheadlines.reddit.RedditLink;
import org.androidannotations.annotations.EBean; | package net.trolldad.dashclock.redditheadlines.cache;
/**
* Created by jacob-tabak on 2/1/14.
*/
@EBean(scope = EBean.Scope.Singleton)
public class ContentCache {
public ImgurImage image; | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurAlbum.java
// public class ImgurAlbum implements Serializable {
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String cover;
// public String account_url;
// public String privacy;
// public String layout;
// public long views;
// public String link;
// public String deletehash;
// public int images_count;
// public ImgurImage[] images;
// }
//
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurImage.java
// public class ImgurImage implements Serializable {
// public static final String THUMB_SIZE_HUGE = "h";
// public static final String ORIGINAL_SIZE = "";
// public static final int MAX_WIDTH_OR_HEIGHT = 2048;
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String type;
// public boolean animated;
// public int width;
// public int height;
// public long size;
// public long views;
// public long bandwidth;
// public String deletehash;
// public String section;
// public String link;
//
// /**
// * Gets a thumb, more info here: http://api.imgur.com/models/image
// *
// * @param suffix
// * @return
// */
// public String getResizedImage(String suffix) {
// // if they don't want a thumb, make sure the image is small enough to display
// if (suffix.length() == 0 && (width > MAX_WIDTH_OR_HEIGHT || height > MAX_WIDTH_OR_HEIGHT)) {
// suffix = THUMB_SIZE_HUGE;
// }
// int dotPosition = link.lastIndexOf(".");
// StringBuilder thumbBuilder = new StringBuilder(link.substring(0, dotPosition));
// thumbBuilder.append(suffix);
// thumbBuilder.append(link.substring(dotPosition));
// return thumbBuilder.toString();
// }
//
// public boolean isHighQualityAvailable(int thumbDimension) {
// return (width > thumbDimension || height > thumbDimension);
// }
// }
//
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/reddit/RedditLink.java
// public class RedditLink extends RedditListing implements Serializable {
// public String id;
// public String name;
// public String domain;
// public String subreddit;
// public String selftext;
// public String selftext_html;
// public String author;
// public String score;
// public String ups;
// public String downs;
// public Boolean saved;
// public Boolean is_self;
// public Boolean likes;
// public String permalink;
// public DateTime created_utc;
// public String url;
// public String title;
// public Boolean hidden;
// }
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/cache/ContentCache.java
import net.trolldad.dashclock.redditheadlines.imgur.ImgurAlbum;
import net.trolldad.dashclock.redditheadlines.imgur.ImgurImage;
import net.trolldad.dashclock.redditheadlines.reddit.RedditLink;
import org.androidannotations.annotations.EBean;
package net.trolldad.dashclock.redditheadlines.cache;
/**
* Created by jacob-tabak on 2/1/14.
*/
@EBean(scope = EBean.Scope.Singleton)
public class ContentCache {
public ImgurImage image; | public ImgurAlbum album; |
Trolldad/Reddit-Headlines | Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/cache/ContentCache.java | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurAlbum.java
// public class ImgurAlbum implements Serializable {
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String cover;
// public String account_url;
// public String privacy;
// public String layout;
// public long views;
// public String link;
// public String deletehash;
// public int images_count;
// public ImgurImage[] images;
// }
//
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurImage.java
// public class ImgurImage implements Serializable {
// public static final String THUMB_SIZE_HUGE = "h";
// public static final String ORIGINAL_SIZE = "";
// public static final int MAX_WIDTH_OR_HEIGHT = 2048;
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String type;
// public boolean animated;
// public int width;
// public int height;
// public long size;
// public long views;
// public long bandwidth;
// public String deletehash;
// public String section;
// public String link;
//
// /**
// * Gets a thumb, more info here: http://api.imgur.com/models/image
// *
// * @param suffix
// * @return
// */
// public String getResizedImage(String suffix) {
// // if they don't want a thumb, make sure the image is small enough to display
// if (suffix.length() == 0 && (width > MAX_WIDTH_OR_HEIGHT || height > MAX_WIDTH_OR_HEIGHT)) {
// suffix = THUMB_SIZE_HUGE;
// }
// int dotPosition = link.lastIndexOf(".");
// StringBuilder thumbBuilder = new StringBuilder(link.substring(0, dotPosition));
// thumbBuilder.append(suffix);
// thumbBuilder.append(link.substring(dotPosition));
// return thumbBuilder.toString();
// }
//
// public boolean isHighQualityAvailable(int thumbDimension) {
// return (width > thumbDimension || height > thumbDimension);
// }
// }
//
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/reddit/RedditLink.java
// public class RedditLink extends RedditListing implements Serializable {
// public String id;
// public String name;
// public String domain;
// public String subreddit;
// public String selftext;
// public String selftext_html;
// public String author;
// public String score;
// public String ups;
// public String downs;
// public Boolean saved;
// public Boolean is_self;
// public Boolean likes;
// public String permalink;
// public DateTime created_utc;
// public String url;
// public String title;
// public Boolean hidden;
// }
| import net.trolldad.dashclock.redditheadlines.imgur.ImgurAlbum;
import net.trolldad.dashclock.redditheadlines.imgur.ImgurImage;
import net.trolldad.dashclock.redditheadlines.reddit.RedditLink;
import org.androidannotations.annotations.EBean; | package net.trolldad.dashclock.redditheadlines.cache;
/**
* Created by jacob-tabak on 2/1/14.
*/
@EBean(scope = EBean.Scope.Singleton)
public class ContentCache {
public ImgurImage image;
public ImgurAlbum album; | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurAlbum.java
// public class ImgurAlbum implements Serializable {
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String cover;
// public String account_url;
// public String privacy;
// public String layout;
// public long views;
// public String link;
// public String deletehash;
// public int images_count;
// public ImgurImage[] images;
// }
//
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/imgur/ImgurImage.java
// public class ImgurImage implements Serializable {
// public static final String THUMB_SIZE_HUGE = "h";
// public static final String ORIGINAL_SIZE = "";
// public static final int MAX_WIDTH_OR_HEIGHT = 2048;
// public String id;
// public String title;
// public String description;
// public DateTime datetime;
// public String type;
// public boolean animated;
// public int width;
// public int height;
// public long size;
// public long views;
// public long bandwidth;
// public String deletehash;
// public String section;
// public String link;
//
// /**
// * Gets a thumb, more info here: http://api.imgur.com/models/image
// *
// * @param suffix
// * @return
// */
// public String getResizedImage(String suffix) {
// // if they don't want a thumb, make sure the image is small enough to display
// if (suffix.length() == 0 && (width > MAX_WIDTH_OR_HEIGHT || height > MAX_WIDTH_OR_HEIGHT)) {
// suffix = THUMB_SIZE_HUGE;
// }
// int dotPosition = link.lastIndexOf(".");
// StringBuilder thumbBuilder = new StringBuilder(link.substring(0, dotPosition));
// thumbBuilder.append(suffix);
// thumbBuilder.append(link.substring(dotPosition));
// return thumbBuilder.toString();
// }
//
// public boolean isHighQualityAvailable(int thumbDimension) {
// return (width > thumbDimension || height > thumbDimension);
// }
// }
//
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/reddit/RedditLink.java
// public class RedditLink extends RedditListing implements Serializable {
// public String id;
// public String name;
// public String domain;
// public String subreddit;
// public String selftext;
// public String selftext_html;
// public String author;
// public String score;
// public String ups;
// public String downs;
// public Boolean saved;
// public Boolean is_self;
// public Boolean likes;
// public String permalink;
// public DateTime created_utc;
// public String url;
// public String title;
// public Boolean hidden;
// }
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/cache/ContentCache.java
import net.trolldad.dashclock.redditheadlines.imgur.ImgurAlbum;
import net.trolldad.dashclock.redditheadlines.imgur.ImgurImage;
import net.trolldad.dashclock.redditheadlines.reddit.RedditLink;
import org.androidannotations.annotations.EBean;
package net.trolldad.dashclock.redditheadlines.cache;
/**
* Created by jacob-tabak on 2/1/14.
*/
@EBean(scope = EBean.Scope.Singleton)
public class ContentCache {
public ImgurImage image;
public ImgurAlbum album; | public RedditLink link; |
Trolldad/Reddit-Headlines | Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/activity/AboutActivity.java | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/view/FontHelper.java
// public class FontHelper {
// private static Typeface regular;
// private static Typeface bold;
// private static Typeface light;
//
// public static final String TAG_NORMAL = "regular";
// public static final String TAG_BOLD = "bold";
// public static final String TAG_LIGHT = "light";
//
// public static void setCustomFont(View topView, AssetManager assetsManager) {
// if (regular == null || bold == null || light == null) {
// regular = Typeface.createFromAsset(assetsManager, "Roboto-Regular.ttf");
// bold = Typeface.createFromAsset(assetsManager, "Roboto-Bold.ttf");
// light = Typeface.createFromAsset(assetsManager, "Roboto-Light.ttf");
// }
//
// if (topView instanceof ViewGroup) {
// processViewGroup((ViewGroup) topView);
// } else if (topView instanceof TextView) {
// setCustomFont((TextView) topView);
// }
// }
//
// private static void processViewGroup(ViewGroup viewGroup) {
// for (int i = 0; i < viewGroup.getChildCount(); i++) {
// final View c = viewGroup.getChildAt(i);
// if (c instanceof TextView) {
// setCustomFont((TextView) c);
// } else if (c instanceof ViewGroup) {
// processViewGroup((ViewGroup) c);
// }
// }
// }
//
// private static void setCustomFont(TextView textView) {
// Object tag = textView.getTag();
// if (tag instanceof String) {
// if (tag.equals(TAG_BOLD)) {
// textView.setTypeface(bold);
// return;
// }
// else if (tag.equals(TAG_NORMAL)) {
// textView.setTypeface(regular);
// }
// else {
// textView.setTypeface(light);
// }
// }
// else {
// textView.setTypeface(light);
// }
//
// }
// }
| import android.app.Activity;
import android.text.method.LinkMovementMethod;
import android.widget.TextView;
import com.google.analytics.tracking.android.EasyTracker;
import net.trolldad.dashclock.redditheadlines.R;
import net.trolldad.dashclock.redditheadlines.view.FontHelper;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.FromHtml;
import org.androidannotations.annotations.ViewById; | package net.trolldad.dashclock.redditheadlines.activity;
/**
* Created by jacob-tabak on 1/26/14.
*/
@EActivity(R.layout.activity_about)
public class AboutActivity extends Activity {
@ViewById(R.id.about_textview)
@FromHtml(R.string.about_html)
TextView mAboutTextView;
@Override
protected void onStart() {
super.onStart();
EasyTracker.getInstance(this).activityStart(this);
}
@Override
protected void onStop() {
super.onStop();
EasyTracker.getInstance(this).activityStop(this);
}
@AfterViews
void setFont() { | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/view/FontHelper.java
// public class FontHelper {
// private static Typeface regular;
// private static Typeface bold;
// private static Typeface light;
//
// public static final String TAG_NORMAL = "regular";
// public static final String TAG_BOLD = "bold";
// public static final String TAG_LIGHT = "light";
//
// public static void setCustomFont(View topView, AssetManager assetsManager) {
// if (regular == null || bold == null || light == null) {
// regular = Typeface.createFromAsset(assetsManager, "Roboto-Regular.ttf");
// bold = Typeface.createFromAsset(assetsManager, "Roboto-Bold.ttf");
// light = Typeface.createFromAsset(assetsManager, "Roboto-Light.ttf");
// }
//
// if (topView instanceof ViewGroup) {
// processViewGroup((ViewGroup) topView);
// } else if (topView instanceof TextView) {
// setCustomFont((TextView) topView);
// }
// }
//
// private static void processViewGroup(ViewGroup viewGroup) {
// for (int i = 0; i < viewGroup.getChildCount(); i++) {
// final View c = viewGroup.getChildAt(i);
// if (c instanceof TextView) {
// setCustomFont((TextView) c);
// } else if (c instanceof ViewGroup) {
// processViewGroup((ViewGroup) c);
// }
// }
// }
//
// private static void setCustomFont(TextView textView) {
// Object tag = textView.getTag();
// if (tag instanceof String) {
// if (tag.equals(TAG_BOLD)) {
// textView.setTypeface(bold);
// return;
// }
// else if (tag.equals(TAG_NORMAL)) {
// textView.setTypeface(regular);
// }
// else {
// textView.setTypeface(light);
// }
// }
// else {
// textView.setTypeface(light);
// }
//
// }
// }
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/activity/AboutActivity.java
import android.app.Activity;
import android.text.method.LinkMovementMethod;
import android.widget.TextView;
import com.google.analytics.tracking.android.EasyTracker;
import net.trolldad.dashclock.redditheadlines.R;
import net.trolldad.dashclock.redditheadlines.view.FontHelper;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.FromHtml;
import org.androidannotations.annotations.ViewById;
package net.trolldad.dashclock.redditheadlines.activity;
/**
* Created by jacob-tabak on 1/26/14.
*/
@EActivity(R.layout.activity_about)
public class AboutActivity extends Activity {
@ViewById(R.id.about_textview)
@FromHtml(R.string.about_html)
TextView mAboutTextView;
@Override
protected void onStart() {
super.onStart();
EasyTracker.getInstance(this).activityStart(this);
}
@Override
protected void onStop() {
super.onStop();
EasyTracker.getInstance(this).activityStop(this);
}
@AfterViews
void setFont() { | FontHelper.setCustomFont(mAboutTextView, getAssets()); |
Trolldad/Reddit-Headlines | Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/fragment/ShareDialogFragment.java | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/reddit/RedditLink.java
// public class RedditLink extends RedditListing implements Serializable {
// public String id;
// public String name;
// public String domain;
// public String subreddit;
// public String selftext;
// public String selftext_html;
// public String author;
// public String score;
// public String ups;
// public String downs;
// public Boolean saved;
// public Boolean is_self;
// public Boolean likes;
// public String permalink;
// public DateTime created_utc;
// public String url;
// public String title;
// public Boolean hidden;
// }
| import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import net.trolldad.dashclock.redditheadlines.R;
import net.trolldad.dashclock.redditheadlines.reddit.RedditLink;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.FragmentArg;
import org.androidannotations.annotations.res.StringArrayRes;
import org.androidannotations.annotations.res.StringRes; | package net.trolldad.dashclock.redditheadlines.fragment;
/**
* Created by jacob-tabak on 1/28/14.
*/
@EFragment
public class ShareDialogFragment extends DialogFragment implements AdapterView.OnItemClickListener {
private ArrayAdapter<String> mArrayAdapter;
private ListView mListView;
private AlertDialog mDialog;
@StringArrayRes(R.array.share_methods)
String[] mSharedMethods;
@StringRes(R.string.share_link)
String mShareLink;
@StringRes(R.string.share_comments)
String mShareComments;
@StringRes(R.string.share_app)
String mShareApp;
@StringRes(R.string.reddit_base_url)
String mRedditUrl;
@StringRes(R.string.play_store_url)
String mPlayStoreLink;
@FragmentArg | // Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/reddit/RedditLink.java
// public class RedditLink extends RedditListing implements Serializable {
// public String id;
// public String name;
// public String domain;
// public String subreddit;
// public String selftext;
// public String selftext_html;
// public String author;
// public String score;
// public String ups;
// public String downs;
// public Boolean saved;
// public Boolean is_self;
// public Boolean likes;
// public String permalink;
// public DateTime created_utc;
// public String url;
// public String title;
// public Boolean hidden;
// }
// Path: Reddit Headlines for DashClock/src/main/java/net/trolldad/dashclock/redditheadlines/fragment/ShareDialogFragment.java
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import net.trolldad.dashclock.redditheadlines.R;
import net.trolldad.dashclock.redditheadlines.reddit.RedditLink;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.FragmentArg;
import org.androidannotations.annotations.res.StringArrayRes;
import org.androidannotations.annotations.res.StringRes;
package net.trolldad.dashclock.redditheadlines.fragment;
/**
* Created by jacob-tabak on 1/28/14.
*/
@EFragment
public class ShareDialogFragment extends DialogFragment implements AdapterView.OnItemClickListener {
private ArrayAdapter<String> mArrayAdapter;
private ListView mListView;
private AlertDialog mDialog;
@StringArrayRes(R.array.share_methods)
String[] mSharedMethods;
@StringRes(R.string.share_link)
String mShareLink;
@StringRes(R.string.share_comments)
String mShareComments;
@StringRes(R.string.share_app)
String mShareApp;
@StringRes(R.string.reddit_base_url)
String mRedditUrl;
@StringRes(R.string.play_store_url)
String mPlayStoreLink;
@FragmentArg | RedditLink mLink; |
waratek/spiracle | src/main/java/com/waratek/spiracle/init/SpiracleInit.java | // Path: src/main/java/com/waratek/spiracle/sql/util/Constants.java
// public class Constants {
//
// public static final String DEFAULT_CONNECTION = "default.connection";
// public static final String C3P0_POOL_SIZE = "c3p0.maxPoolSize";
// public static final String JDBC_FETCH_SIZE = "jdbc.fetchsize";
//
// public static final String C3P0_ORACLE = "c3p0.oracle";
// public static final String C3P0_MYSQL = "c3p0.mysql";
// public static final String C3P0_MSSQL = "c3p0.mssql";
// public static final String C3P0_DB2 = "c3p0.db2";
// public static final String C3P0_SYBASE = "c3p0.sybase";
// public static final String C3P0_POSTGRES = "c3p0.postgres";
//
// public static final String C3P0_ORACLE_CLASSNAME = "c3p0.oracle.classname";
// public static final String C3P0_MYSQL_CLASSNAME = "c3p0.mysql.classname";
// public static final String C3P0_MSSQL_CLASSNAME = "c3p0.mssql.classname";
// public static final String C3P0_DB2_CLASSNAME = "c3p0.db2.classname";
// public static final String C3P0_SYBASE_CLASSNAME = "c3p0.sybase.classname";
// public static final String C3P0_POSTGRES_CLASSNAME = "c3p0.postgres.classname";
//
// public static final String ORACLE = "oracle";
// public static final String MYSQL = "mysql";
// public static final String MSSQL = "mssql";
// public static final String DB2 = "db2";
// public static final String SYBASE = "sybase";
// public static final String POSTGRES = "postgres";
//
// public static final String ORACLE_CONNECTION_POOL = "oracleConnectionPool";
// public static final String MYSQL_CONNECTION_POOL = "mysqlConnectionPool";
// public static final String MSSQL_CONNECTION_POOL = "mssqlConnectionPool";
// public static final String DB2_CONNECTION_POOL = "db2ConnectionPool";
// public static final String SYBASE_CONNECTION_POOL = "sybaseConnectionPool";
// public static final String POSTGRES_CONNECTION_POOL = "postgresConnectionPool";
//
// public final static String ORACLE_CONNECTION_DATA = "oracleConnectionData";
// public final static String MYSQL_CONNECTION_DATA = "mysqlConnectionData";
// public final static String MSSQL_CONNECTION_DATA = "mssqlConnectionData";
// public final static String DB2_CONNECTION_DATA = "db2ConnectionData";
// public final static String SYBASE_CONNECTION_DATA = "sybaseConnectionData";
// public final static String POSTGRES_CONNECTION_DATA = "postgresConnectionData";
// }
| import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.waratek.spiracle.sql.util.Constants;
import java.text.MessageFormat;
import java.beans.PropertyVetoException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator; | /*
* Copyright 2014 Waratek Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.waratek.spiracle.init;
@WebListener
public class SpiracleInit implements ServletContextListener {
private static final Logger logger = Logger.getLogger(SpiracleInit.class);
public void contextDestroyed(ServletContextEvent arg0) {
ServletContext application = arg0.getServletContext(); | // Path: src/main/java/com/waratek/spiracle/sql/util/Constants.java
// public class Constants {
//
// public static final String DEFAULT_CONNECTION = "default.connection";
// public static final String C3P0_POOL_SIZE = "c3p0.maxPoolSize";
// public static final String JDBC_FETCH_SIZE = "jdbc.fetchsize";
//
// public static final String C3P0_ORACLE = "c3p0.oracle";
// public static final String C3P0_MYSQL = "c3p0.mysql";
// public static final String C3P0_MSSQL = "c3p0.mssql";
// public static final String C3P0_DB2 = "c3p0.db2";
// public static final String C3P0_SYBASE = "c3p0.sybase";
// public static final String C3P0_POSTGRES = "c3p0.postgres";
//
// public static final String C3P0_ORACLE_CLASSNAME = "c3p0.oracle.classname";
// public static final String C3P0_MYSQL_CLASSNAME = "c3p0.mysql.classname";
// public static final String C3P0_MSSQL_CLASSNAME = "c3p0.mssql.classname";
// public static final String C3P0_DB2_CLASSNAME = "c3p0.db2.classname";
// public static final String C3P0_SYBASE_CLASSNAME = "c3p0.sybase.classname";
// public static final String C3P0_POSTGRES_CLASSNAME = "c3p0.postgres.classname";
//
// public static final String ORACLE = "oracle";
// public static final String MYSQL = "mysql";
// public static final String MSSQL = "mssql";
// public static final String DB2 = "db2";
// public static final String SYBASE = "sybase";
// public static final String POSTGRES = "postgres";
//
// public static final String ORACLE_CONNECTION_POOL = "oracleConnectionPool";
// public static final String MYSQL_CONNECTION_POOL = "mysqlConnectionPool";
// public static final String MSSQL_CONNECTION_POOL = "mssqlConnectionPool";
// public static final String DB2_CONNECTION_POOL = "db2ConnectionPool";
// public static final String SYBASE_CONNECTION_POOL = "sybaseConnectionPool";
// public static final String POSTGRES_CONNECTION_POOL = "postgresConnectionPool";
//
// public final static String ORACLE_CONNECTION_DATA = "oracleConnectionData";
// public final static String MYSQL_CONNECTION_DATA = "mysqlConnectionData";
// public final static String MSSQL_CONNECTION_DATA = "mssqlConnectionData";
// public final static String DB2_CONNECTION_DATA = "db2ConnectionData";
// public final static String SYBASE_CONNECTION_DATA = "sybaseConnectionData";
// public final static String POSTGRES_CONNECTION_DATA = "postgresConnectionData";
// }
// Path: src/main/java/com/waratek/spiracle/init/SpiracleInit.java
import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.waratek.spiracle.sql.util.Constants;
import java.text.MessageFormat;
import java.beans.PropertyVetoException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
/*
* Copyright 2014 Waratek Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.waratek.spiracle.init;
@WebListener
public class SpiracleInit implements ServletContextListener {
private static final Logger logger = Logger.getLogger(SpiracleInit.class);
public void contextDestroyed(ServletContextEvent arg0) {
ServletContext application = arg0.getServletContext(); | ((ComboPooledDataSource) application.getAttribute(Constants.ORACLE_CONNECTION_POOL)).close(); |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementScrollPanelOverlay.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import modpacktweaks.client.gui.library.gui.IGuiBase;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11; | package modpacktweaks.client.gui.library.gui.element;
public class ElementScrollPanelOverlay extends ElementScrollPanel
{
ResourceLocation overlayTexture;
int paddingSize;
boolean top = true, bottom = true, left = true, right = true;
| // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementScrollPanelOverlay.java
import modpacktweaks.client.gui.library.gui.IGuiBase;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
package modpacktweaks.client.gui.library.gui.element;
public class ElementScrollPanelOverlay extends ElementScrollPanel
{
ResourceLocation overlayTexture;
int paddingSize;
boolean top = true, bottom = true, left = true, right = true;
| public ElementScrollPanelOverlay(IGuiBase parent, int x, int y, int w, int h, ResourceLocation tex, int padding) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementButton.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import java.util.ArrayList;
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11; | package modpacktweaks.client.gui.library.gui.element;
public class ElementButton extends ElementBase
{
protected String ID, displayText, hoverString;
| // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementButton.java
import java.util.ArrayList;
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
package modpacktweaks.client.gui.library.gui.element;
public class ElementButton extends ElementBase
{
protected String ID, displayText, hoverString;
| public ElementButton(IGuiBase parent, int x, int y, int w, String id, String text) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementItemIconWithCount.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import modpacktweaks.client.gui.library.gui.IGuiBase;
import net.minecraft.item.ItemStack; | package modpacktweaks.client.gui.library.gui.element;
public class ElementItemIconWithCount extends ElementItemIcon
{ | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementItemIconWithCount.java
import modpacktweaks.client.gui.library.gui.IGuiBase;
import net.minecraft.item.ItemStack;
package modpacktweaks.client.gui.library.gui.element;
public class ElementItemIconWithCount extends ElementItemIcon
{ | public ElementItemIconWithCount(IGuiBase parent, int x, int y, ItemStack stack) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/proxy/CommonProxy.java | // Path: src/main/java/modpacktweaks/client/gui/ModDownload.java
// public class ModDownload
// {
// public String name, url, modid;
//
// public ModDownload(String name, String url, String modid)
// {
// this.name = name;
// this.url = url;
// this.modid = modid;
// }
// }
| import modpacktweaks.client.gui.ModDownload; | package modpacktweaks.proxy;
public class CommonProxy
{ | // Path: src/main/java/modpacktweaks/client/gui/ModDownload.java
// public class ModDownload
// {
// public String name, url, modid;
//
// public ModDownload(String name, String url, String modid)
// {
// this.name = name;
// this.url = url;
// this.modid = modid;
// }
// }
// Path: src/main/java/modpacktweaks/proxy/CommonProxy.java
import modpacktweaks.client.gui.ModDownload;
package modpacktweaks.proxy;
public class CommonProxy
{ | public void addJsonToGUI(ModDownload fromJson) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementScrollPanel.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11; | package modpacktweaks.client.gui.library.gui.element;
public class ElementScrollPanel extends ElementBaseContainer
{
protected float scrollX, scrollY;
protected int contentHeight, contentWidth, oldMouseX, oldMouseY;
protected boolean isMouseButtonDown = false;
| // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementScrollPanel.java
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
package modpacktweaks.client.gui.library.gui.element;
public class ElementScrollPanel extends ElementBaseContainer
{
protected float scrollX, scrollY;
protected int contentHeight, contentWidth, oldMouseX, oldMouseY;
protected boolean isMouseButtonDown = false;
| public ElementScrollPanel(IGuiBase parent, int x, int y, int w, int h) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementBaseContainer.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
//
// Path: src/main/java/modpacktweaks/client/gui/library/gui/Parser.java
// public class Parser
// {
// FontRenderer fontRenderer;
// IGuiBase parentGui;
// ArrayList<ElementBase> parsedElements;
// int maxWidth, currentX, currentY;
//
// public Parser(IGuiBase parent)
// {
// parsedElements = new ArrayList<ElementBase>();
// parentGui = parent;
// maxWidth = -1;
// currentX = currentY = 0;
// fontRenderer = Minecraft.getMinecraft().fontRenderer;
// }
//
// public ArrayList<ElementBase> parse(String string)
// {
// // testing, for now
// parsedElements.add(new ElementCrafting(parentGui, maxWidth / 2 - 5, currentY, 0).addAllGridSlots(new ItemStack[] { new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, null, null, null }).addOutputSlot(new ItemStack(Blocks.stonebrick)));
// parsedElements.add(new ElementCrafting(parentGui, 0, currentY, 1).addBothFurnaceSlots(new ItemStack[] { new ItemStack(Blocks.cobblestone), new ItemStack(Items.coal) }).addOutputSlot(new ItemStack(Blocks.stone)));
// currentY += parsedElements.get(parsedElements.size() - 1).getHeight() + 5;
// parseText(string);
// currentY += 5;
// parsedElements.add(new ElementCrafting(parentGui, maxWidth / 2 - 5, currentY, 0).addAllGridSlots(new ItemStack[] { new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, null, null, null }).addOutputSlot(new ItemStack(Blocks.stonebrick)));
// parsedElements.add(new ElementCrafting(parentGui, 0, currentY, 1).addBothFurnaceSlots(new ItemStack[] { new ItemStack(Blocks.cobblestone), new ItemStack(Items.coal) }).addOutputSlot(new ItemStack(Blocks.stone)));
// currentY += parsedElements.get(parsedElements.size() - 1).getHeight() + 5;
// parseText("And that's how you make Stone Bricks!");
//
// return parsedElements;
// }
//
// @SuppressWarnings("unchecked")
// private void parseText(String string)
// {
// if (maxWidth != -1 && fontRenderer.getStringWidth(string) > maxWidth)
// {
// List<String> list = fontRenderer.listFormattedStringToWidth(string, maxWidth);
//
// for (Iterator<String> iterator = list.iterator(); iterator.hasNext(); currentY += fontRenderer.FONT_HEIGHT)
// {
// parsedElements.add(new ElementText(parentGui, currentX, currentY, iterator.next(), null, 0xFFFFFF, false));
// }
// }
// else
// {
// parsedElements.add(new ElementText(parentGui, currentX, currentY, string, null, 0xFFFFFF, false));
// currentX += fontRenderer.getStringWidth(string);
// }
// }
//
// public Parser setMaxWidth(int width)
// {
// maxWidth = width;
// return this;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import modpacktweaks.client.gui.library.gui.Parser;
import org.lwjgl.opengl.GL11; | package modpacktweaks.client.gui.library.gui.element;
public abstract class ElementBaseContainer extends ElementBase
{
protected ArrayList<ElementBase> elements;
| // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
//
// Path: src/main/java/modpacktweaks/client/gui/library/gui/Parser.java
// public class Parser
// {
// FontRenderer fontRenderer;
// IGuiBase parentGui;
// ArrayList<ElementBase> parsedElements;
// int maxWidth, currentX, currentY;
//
// public Parser(IGuiBase parent)
// {
// parsedElements = new ArrayList<ElementBase>();
// parentGui = parent;
// maxWidth = -1;
// currentX = currentY = 0;
// fontRenderer = Minecraft.getMinecraft().fontRenderer;
// }
//
// public ArrayList<ElementBase> parse(String string)
// {
// // testing, for now
// parsedElements.add(new ElementCrafting(parentGui, maxWidth / 2 - 5, currentY, 0).addAllGridSlots(new ItemStack[] { new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, null, null, null }).addOutputSlot(new ItemStack(Blocks.stonebrick)));
// parsedElements.add(new ElementCrafting(parentGui, 0, currentY, 1).addBothFurnaceSlots(new ItemStack[] { new ItemStack(Blocks.cobblestone), new ItemStack(Items.coal) }).addOutputSlot(new ItemStack(Blocks.stone)));
// currentY += parsedElements.get(parsedElements.size() - 1).getHeight() + 5;
// parseText(string);
// currentY += 5;
// parsedElements.add(new ElementCrafting(parentGui, maxWidth / 2 - 5, currentY, 0).addAllGridSlots(new ItemStack[] { new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, null, null, null }).addOutputSlot(new ItemStack(Blocks.stonebrick)));
// parsedElements.add(new ElementCrafting(parentGui, 0, currentY, 1).addBothFurnaceSlots(new ItemStack[] { new ItemStack(Blocks.cobblestone), new ItemStack(Items.coal) }).addOutputSlot(new ItemStack(Blocks.stone)));
// currentY += parsedElements.get(parsedElements.size() - 1).getHeight() + 5;
// parseText("And that's how you make Stone Bricks!");
//
// return parsedElements;
// }
//
// @SuppressWarnings("unchecked")
// private void parseText(String string)
// {
// if (maxWidth != -1 && fontRenderer.getStringWidth(string) > maxWidth)
// {
// List<String> list = fontRenderer.listFormattedStringToWidth(string, maxWidth);
//
// for (Iterator<String> iterator = list.iterator(); iterator.hasNext(); currentY += fontRenderer.FONT_HEIGHT)
// {
// parsedElements.add(new ElementText(parentGui, currentX, currentY, iterator.next(), null, 0xFFFFFF, false));
// }
// }
// else
// {
// parsedElements.add(new ElementText(parentGui, currentX, currentY, string, null, 0xFFFFFF, false));
// currentX += fontRenderer.getStringWidth(string);
// }
// }
//
// public Parser setMaxWidth(int width)
// {
// maxWidth = width;
// return this;
// }
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementBaseContainer.java
import java.util.ArrayList;
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import modpacktweaks.client.gui.library.gui.Parser;
import org.lwjgl.opengl.GL11;
package modpacktweaks.client.gui.library.gui.element;
public abstract class ElementBaseContainer extends ElementBase
{
protected ArrayList<ElementBase> elements;
| public ElementBaseContainer(IGuiBase parent, int x, int y, int w, int h) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementBaseContainer.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
//
// Path: src/main/java/modpacktweaks/client/gui/library/gui/Parser.java
// public class Parser
// {
// FontRenderer fontRenderer;
// IGuiBase parentGui;
// ArrayList<ElementBase> parsedElements;
// int maxWidth, currentX, currentY;
//
// public Parser(IGuiBase parent)
// {
// parsedElements = new ArrayList<ElementBase>();
// parentGui = parent;
// maxWidth = -1;
// currentX = currentY = 0;
// fontRenderer = Minecraft.getMinecraft().fontRenderer;
// }
//
// public ArrayList<ElementBase> parse(String string)
// {
// // testing, for now
// parsedElements.add(new ElementCrafting(parentGui, maxWidth / 2 - 5, currentY, 0).addAllGridSlots(new ItemStack[] { new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, null, null, null }).addOutputSlot(new ItemStack(Blocks.stonebrick)));
// parsedElements.add(new ElementCrafting(parentGui, 0, currentY, 1).addBothFurnaceSlots(new ItemStack[] { new ItemStack(Blocks.cobblestone), new ItemStack(Items.coal) }).addOutputSlot(new ItemStack(Blocks.stone)));
// currentY += parsedElements.get(parsedElements.size() - 1).getHeight() + 5;
// parseText(string);
// currentY += 5;
// parsedElements.add(new ElementCrafting(parentGui, maxWidth / 2 - 5, currentY, 0).addAllGridSlots(new ItemStack[] { new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, null, null, null }).addOutputSlot(new ItemStack(Blocks.stonebrick)));
// parsedElements.add(new ElementCrafting(parentGui, 0, currentY, 1).addBothFurnaceSlots(new ItemStack[] { new ItemStack(Blocks.cobblestone), new ItemStack(Items.coal) }).addOutputSlot(new ItemStack(Blocks.stone)));
// currentY += parsedElements.get(parsedElements.size() - 1).getHeight() + 5;
// parseText("And that's how you make Stone Bricks!");
//
// return parsedElements;
// }
//
// @SuppressWarnings("unchecked")
// private void parseText(String string)
// {
// if (maxWidth != -1 && fontRenderer.getStringWidth(string) > maxWidth)
// {
// List<String> list = fontRenderer.listFormattedStringToWidth(string, maxWidth);
//
// for (Iterator<String> iterator = list.iterator(); iterator.hasNext(); currentY += fontRenderer.FONT_HEIGHT)
// {
// parsedElements.add(new ElementText(parentGui, currentX, currentY, iterator.next(), null, 0xFFFFFF, false));
// }
// }
// else
// {
// parsedElements.add(new ElementText(parentGui, currentX, currentY, string, null, 0xFFFFFF, false));
// currentX += fontRenderer.getStringWidth(string);
// }
// }
//
// public Parser setMaxWidth(int width)
// {
// maxWidth = width;
// return this;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import modpacktweaks.client.gui.library.gui.Parser;
import org.lwjgl.opengl.GL11; | element.draw(posX + element.getRelativeX(), posY + element.getRelativeY());
GL11.glDisable(GL11.GL_LIGHTING);
}
}
}
public ArrayList<ElementBase> getElements()
{
return elements;
}
@Override
public boolean handleMouseClicked(int x, int y, int mouseButton)
{
for (ElementBase element : elements)
{
if (element.isVisible() && element.intersectsWith(x, y))
{
if (element.handleMouseClicked(x, y, mouseButton))
{
return true;
}
}
}
return false;
}
public ElementBaseContainer parseElements(String string)
{ | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
//
// Path: src/main/java/modpacktweaks/client/gui/library/gui/Parser.java
// public class Parser
// {
// FontRenderer fontRenderer;
// IGuiBase parentGui;
// ArrayList<ElementBase> parsedElements;
// int maxWidth, currentX, currentY;
//
// public Parser(IGuiBase parent)
// {
// parsedElements = new ArrayList<ElementBase>();
// parentGui = parent;
// maxWidth = -1;
// currentX = currentY = 0;
// fontRenderer = Minecraft.getMinecraft().fontRenderer;
// }
//
// public ArrayList<ElementBase> parse(String string)
// {
// // testing, for now
// parsedElements.add(new ElementCrafting(parentGui, maxWidth / 2 - 5, currentY, 0).addAllGridSlots(new ItemStack[] { new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, null, null, null }).addOutputSlot(new ItemStack(Blocks.stonebrick)));
// parsedElements.add(new ElementCrafting(parentGui, 0, currentY, 1).addBothFurnaceSlots(new ItemStack[] { new ItemStack(Blocks.cobblestone), new ItemStack(Items.coal) }).addOutputSlot(new ItemStack(Blocks.stone)));
// currentY += parsedElements.get(parsedElements.size() - 1).getHeight() + 5;
// parseText(string);
// currentY += 5;
// parsedElements.add(new ElementCrafting(parentGui, maxWidth / 2 - 5, currentY, 0).addAllGridSlots(new ItemStack[] { new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, null, null, null }).addOutputSlot(new ItemStack(Blocks.stonebrick)));
// parsedElements.add(new ElementCrafting(parentGui, 0, currentY, 1).addBothFurnaceSlots(new ItemStack[] { new ItemStack(Blocks.cobblestone), new ItemStack(Items.coal) }).addOutputSlot(new ItemStack(Blocks.stone)));
// currentY += parsedElements.get(parsedElements.size() - 1).getHeight() + 5;
// parseText("And that's how you make Stone Bricks!");
//
// return parsedElements;
// }
//
// @SuppressWarnings("unchecked")
// private void parseText(String string)
// {
// if (maxWidth != -1 && fontRenderer.getStringWidth(string) > maxWidth)
// {
// List<String> list = fontRenderer.listFormattedStringToWidth(string, maxWidth);
//
// for (Iterator<String> iterator = list.iterator(); iterator.hasNext(); currentY += fontRenderer.FONT_HEIGHT)
// {
// parsedElements.add(new ElementText(parentGui, currentX, currentY, iterator.next(), null, 0xFFFFFF, false));
// }
// }
// else
// {
// parsedElements.add(new ElementText(parentGui, currentX, currentY, string, null, 0xFFFFFF, false));
// currentX += fontRenderer.getStringWidth(string);
// }
// }
//
// public Parser setMaxWidth(int width)
// {
// maxWidth = width;
// return this;
// }
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementBaseContainer.java
import java.util.ArrayList;
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import modpacktweaks.client.gui.library.gui.Parser;
import org.lwjgl.opengl.GL11;
element.draw(posX + element.getRelativeX(), posY + element.getRelativeY());
GL11.glDisable(GL11.GL_LIGHTING);
}
}
}
public ArrayList<ElementBase> getElements()
{
return elements;
}
@Override
public boolean handleMouseClicked(int x, int y, int mouseButton)
{
for (ElementBase element : elements)
{
if (element.isVisible() && element.intersectsWith(x, y))
{
if (element.handleMouseClicked(x, y, mouseButton))
{
return true;
}
}
}
return false;
}
public ElementBaseContainer parseElements(String string)
{ | for (ElementBase element : new Parser(gui).setMaxWidth(sizeX).parse(string)) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementProgressBar.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.opengl.GL11; | package modpacktweaks.client.gui.library.gui.element;
public class ElementProgressBar extends ElementBase
{
protected int currentProgress, maxProgress, autoIncrement;
| // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementProgressBar.java
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.opengl.GL11;
package modpacktweaks.client.gui.library.gui.element;
public class ElementProgressBar extends ElementBase
{
protected int currentProgress, maxProgress, autoIncrement;
| public ElementProgressBar(IGuiBase parent, int x, int y, int max) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementRedstoneFlux.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.opengl.GL11; | package modpacktweaks.client.gui.library.gui.element;
public class ElementRedstoneFlux extends ElementProgressBar
{ | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementRedstoneFlux.java
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.opengl.GL11;
package modpacktweaks.client.gui.library.gui.element;
public class ElementRedstoneFlux extends ElementProgressBar
{ | public ElementRedstoneFlux(IGuiBase parent, int x, int y, int max) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/RestartGui.java | // Path: src/main/java/modpacktweaks/ModpackTweaks.java
// @Mod(modid = ModpackTweaks.MODID, name = ModpackTweaks.NAME, version = ModpackTweaks.VERSION, dependencies = ModpackTweaks.DEPEND)
// public class ModpackTweaks
// {
// public static final String MODID = "modpackTweaks";
// public static final String NAME = "ModpackTweaks";
// public static final String DEPEND = "required-after:endercore;after:ThermalExpansion";
// public static final String VERSION = "@VERSION@";
// public static final String CHANNEL = "modpacktweaks";
//
// @Instance
// public static ModpackTweaks instance;
//
// @SidedProxy(clientSide = "modpacktweaks.proxy.ClientProxy", serverSide = "modpacktweaks.proxy.CommonProxy")
// public static CommonProxy proxy;
//
// public static BookHandler bookHandler;
//
// public static final Logger logger = LogManager.getLogger("ModpackTweaks");
//
// public static CreativeTabs creativeTab = new CreativeTabs("tabMT")
// {
// @Override
// public Item getTabIconItem()
// {
// return ModItems.book;
// }
// };
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// ConfigurationHandler.init(new File(event.getModConfigurationDirectory().getAbsolutePath() + "/modpackTweaks/modpackTweaks.cfg"));
// ConfigurationHandler.loadClientsideJson();
//
// try
// {
// FileLoader.init(ConfigurationHandler.cfg, 0);
// }
// catch (IOException e)
// {
// e.printStackTrace();
// }
//
// ConfigurationHandler.loadGuideText(FileLoader.getGuideText());
// ConfigurationHandler.loadChangelogText(FileLoader.getChangelogText());
//
// CommandMT.initValidCommandArguments(FileLoader.getSupportedModsFile());
//
// ModItems.initItems();
//
// bookHandler = new BookHandler();
// FMLCommonHandler.instance().bus().register(bookHandler);
//
// MinecraftForge.EVENT_BUS.register(new ModEventHandler());
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event)
// {
// ModItems.registerRecipes();
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// if (FMLCommonHandler.instance().getSide().isClient())
// {
// try
// {
// GuiHelper.initMap();
// }
// catch (FileNotFoundException e)
// {
// e.printStackTrace();
// }
// }
// }
//
// @EventHandler
// public void onFMLServerStart(FMLServerStartingEvent event)
// {
// event.registerServerCommand(new CommandMT());
// }
// }
| import cpw.mods.fml.common.FMLCommonHandler;
import modpacktweaks.ModpackTweaks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen; | package modpacktweaks.client.gui;
public class RestartGui extends GuiScreen
{
@SuppressWarnings("unchecked")
@Override
public void initGui()
{
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 2, 200, 20, "Exit the game"));
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 2 + 30, 200, 20, "Don't exit (mods will not be loaded)"));
}
@Override
public void drawScreen(int par1, int par2, float par3)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRendererObj, "You have installed all desired mods!", this.width / 2, this.height / 2 - 40, 0xFFFFFF);
this.drawCenteredString(this.fontRendererObj, "However, you must restart Minecraft for your changes to take effect.", this.width / 2, this.height / 2 - 20, 0xFFFFFF);
super.drawScreen(par1, par2, par3);
}
@Override
protected void actionPerformed(GuiButton button)
{
if (button.id == 0)
{
Minecraft.getMinecraft().shutdown();
}
else
{ | // Path: src/main/java/modpacktweaks/ModpackTweaks.java
// @Mod(modid = ModpackTweaks.MODID, name = ModpackTweaks.NAME, version = ModpackTweaks.VERSION, dependencies = ModpackTweaks.DEPEND)
// public class ModpackTweaks
// {
// public static final String MODID = "modpackTweaks";
// public static final String NAME = "ModpackTweaks";
// public static final String DEPEND = "required-after:endercore;after:ThermalExpansion";
// public static final String VERSION = "@VERSION@";
// public static final String CHANNEL = "modpacktweaks";
//
// @Instance
// public static ModpackTweaks instance;
//
// @SidedProxy(clientSide = "modpacktweaks.proxy.ClientProxy", serverSide = "modpacktweaks.proxy.CommonProxy")
// public static CommonProxy proxy;
//
// public static BookHandler bookHandler;
//
// public static final Logger logger = LogManager.getLogger("ModpackTweaks");
//
// public static CreativeTabs creativeTab = new CreativeTabs("tabMT")
// {
// @Override
// public Item getTabIconItem()
// {
// return ModItems.book;
// }
// };
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// ConfigurationHandler.init(new File(event.getModConfigurationDirectory().getAbsolutePath() + "/modpackTweaks/modpackTweaks.cfg"));
// ConfigurationHandler.loadClientsideJson();
//
// try
// {
// FileLoader.init(ConfigurationHandler.cfg, 0);
// }
// catch (IOException e)
// {
// e.printStackTrace();
// }
//
// ConfigurationHandler.loadGuideText(FileLoader.getGuideText());
// ConfigurationHandler.loadChangelogText(FileLoader.getChangelogText());
//
// CommandMT.initValidCommandArguments(FileLoader.getSupportedModsFile());
//
// ModItems.initItems();
//
// bookHandler = new BookHandler();
// FMLCommonHandler.instance().bus().register(bookHandler);
//
// MinecraftForge.EVENT_BUS.register(new ModEventHandler());
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event)
// {
// ModItems.registerRecipes();
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// if (FMLCommonHandler.instance().getSide().isClient())
// {
// try
// {
// GuiHelper.initMap();
// }
// catch (FileNotFoundException e)
// {
// e.printStackTrace();
// }
// }
// }
//
// @EventHandler
// public void onFMLServerStart(FMLServerStartingEvent event)
// {
// event.registerServerCommand(new CommandMT());
// }
// }
// Path: src/main/java/modpacktweaks/client/gui/RestartGui.java
import cpw.mods.fml.common.FMLCommonHandler;
import modpacktweaks.ModpackTweaks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
package modpacktweaks.client.gui;
public class RestartGui extends GuiScreen
{
@SuppressWarnings("unchecked")
@Override
public void initGui()
{
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 2, 200, 20, "Exit the game"));
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 2 + 30, 200, 20, "Don't exit (mods will not be loaded)"));
}
@Override
public void drawScreen(int par1, int par2, float par3)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRendererObj, "You have installed all desired mods!", this.width / 2, this.height / 2 - 40, 0xFFFFFF);
this.drawCenteredString(this.fontRendererObj, "However, you must restart Minecraft for your changes to take effect.", this.width / 2, this.height / 2 - 20, 0xFFFFFF);
super.drawScreen(par1, par2, par3);
}
@Override
protected void actionPerformed(GuiButton button)
{
if (button.id == 0)
{
Minecraft.getMinecraft().shutdown();
}
else
{ | ModpackTweaks.logger.info("Mod installations finished! Restart minecraft for your changes to take effect."); |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementPlus.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.opengl.GL11; | package modpacktweaks.client.gui.library.gui.element;
public class ElementPlus extends ElementProgressBar
{
boolean showTooltip, horizontal;
| // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementPlus.java
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.opengl.GL11;
package modpacktweaks.client.gui.library.gui.element;
public class ElementPlus extends ElementProgressBar
{
boolean showTooltip, horizontal;
| public ElementPlus(IGuiBase parent, int x, int y) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementCrafting.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import modpacktweaks.client.gui.library.gui.IGuiBase;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11; | package modpacktweaks.client.gui.library.gui.element;
public class ElementCrafting extends ElementBaseContainer
{
int type;
/**
*
* @param parent
* @param x
* @param y
* @param t
* 0 = 3x3 Crafting Grid, 1 = Furnace, 2 = Potion
*/ | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementCrafting.java
import modpacktweaks.client.gui.library.gui.IGuiBase;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
package modpacktweaks.client.gui.library.gui.element;
public class ElementCrafting extends ElementBaseContainer
{
int type;
/**
*
* @param parent
* @param x
* @param y
* @param t
* 0 = 3x3 Crafting Grid, 1 = Furnace, 2 = Potion
*/ | public ElementCrafting(IGuiBase parent, int x, int y, int t) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementTextBox.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase; | package modpacktweaks.client.gui.library.gui.element;
public class ElementTextBox extends ElementText
{
List<String> textStrings;
| // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementTextBox.java
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
package modpacktweaks.client.gui.library.gui.element;
public class ElementTextBox extends ElementText
{
List<String> textStrings;
| public ElementTextBox(IGuiBase parent, int x, int y, String text, int width) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementItemStackPanel.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase; | package modpacktweaks.client.gui.library.gui.element;
public class ElementItemStackPanel extends ElementBaseContainer
{
int lastX = 0, lastY = 0, highestRow = 0;
| // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementItemStackPanel.java
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
package modpacktweaks.client.gui.library.gui.element;
public class ElementItemStackPanel extends ElementBaseContainer
{
int lastX = 0, lastY = 0, highestRow = 0;
| public ElementItemStackPanel(IGuiBase parent, int x, int y, int w, int h) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/network/PacketHandler.java | // Path: src/main/java/modpacktweaks/ModpackTweaks.java
// @Mod(modid = ModpackTweaks.MODID, name = ModpackTweaks.NAME, version = ModpackTweaks.VERSION, dependencies = ModpackTweaks.DEPEND)
// public class ModpackTweaks
// {
// public static final String MODID = "modpackTweaks";
// public static final String NAME = "ModpackTweaks";
// public static final String DEPEND = "required-after:endercore;after:ThermalExpansion";
// public static final String VERSION = "@VERSION@";
// public static final String CHANNEL = "modpacktweaks";
//
// @Instance
// public static ModpackTweaks instance;
//
// @SidedProxy(clientSide = "modpacktweaks.proxy.ClientProxy", serverSide = "modpacktweaks.proxy.CommonProxy")
// public static CommonProxy proxy;
//
// public static BookHandler bookHandler;
//
// public static final Logger logger = LogManager.getLogger("ModpackTweaks");
//
// public static CreativeTabs creativeTab = new CreativeTabs("tabMT")
// {
// @Override
// public Item getTabIconItem()
// {
// return ModItems.book;
// }
// };
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// ConfigurationHandler.init(new File(event.getModConfigurationDirectory().getAbsolutePath() + "/modpackTweaks/modpackTweaks.cfg"));
// ConfigurationHandler.loadClientsideJson();
//
// try
// {
// FileLoader.init(ConfigurationHandler.cfg, 0);
// }
// catch (IOException e)
// {
// e.printStackTrace();
// }
//
// ConfigurationHandler.loadGuideText(FileLoader.getGuideText());
// ConfigurationHandler.loadChangelogText(FileLoader.getChangelogText());
//
// CommandMT.initValidCommandArguments(FileLoader.getSupportedModsFile());
//
// ModItems.initItems();
//
// bookHandler = new BookHandler();
// FMLCommonHandler.instance().bus().register(bookHandler);
//
// MinecraftForge.EVENT_BUS.register(new ModEventHandler());
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event)
// {
// ModItems.registerRecipes();
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// if (FMLCommonHandler.instance().getSide().isClient())
// {
// try
// {
// GuiHelper.initMap();
// }
// catch (FileNotFoundException e)
// {
// e.printStackTrace();
// }
// }
// }
//
// @EventHandler
// public void onFMLServerStart(FMLServerStartingEvent event)
// {
// event.registerServerCommand(new CommandMT());
// }
// }
//
// Path: src/main/java/modpacktweaks/network/message/MessageShowDownloadGUI.java
// public class MessageShowDownloadGUI implements IMessage, IMessageHandler<MessageShowDownloadGUI, IMessage>
// {
// public MessageShowDownloadGUI() {}
//
// @Override
// public void fromBytes(ByteBuf buf)
// {}
//
// @Override
// public void toBytes(ByteBuf buf)
// {}
//
// @Override
// public IMessage onMessage(MessageShowDownloadGUI message, MessageContext ctx)
// {
// GuiHelper.doDownloaderGUI();
// return null;
// }
// }
| import modpacktweaks.ModpackTweaks;
import modpacktweaks.network.message.MessageShowDownloadGUI;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side; | package modpacktweaks.network;
public class PacketHandler
{ | // Path: src/main/java/modpacktweaks/ModpackTweaks.java
// @Mod(modid = ModpackTweaks.MODID, name = ModpackTweaks.NAME, version = ModpackTweaks.VERSION, dependencies = ModpackTweaks.DEPEND)
// public class ModpackTweaks
// {
// public static final String MODID = "modpackTweaks";
// public static final String NAME = "ModpackTweaks";
// public static final String DEPEND = "required-after:endercore;after:ThermalExpansion";
// public static final String VERSION = "@VERSION@";
// public static final String CHANNEL = "modpacktweaks";
//
// @Instance
// public static ModpackTweaks instance;
//
// @SidedProxy(clientSide = "modpacktweaks.proxy.ClientProxy", serverSide = "modpacktweaks.proxy.CommonProxy")
// public static CommonProxy proxy;
//
// public static BookHandler bookHandler;
//
// public static final Logger logger = LogManager.getLogger("ModpackTweaks");
//
// public static CreativeTabs creativeTab = new CreativeTabs("tabMT")
// {
// @Override
// public Item getTabIconItem()
// {
// return ModItems.book;
// }
// };
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// ConfigurationHandler.init(new File(event.getModConfigurationDirectory().getAbsolutePath() + "/modpackTweaks/modpackTweaks.cfg"));
// ConfigurationHandler.loadClientsideJson();
//
// try
// {
// FileLoader.init(ConfigurationHandler.cfg, 0);
// }
// catch (IOException e)
// {
// e.printStackTrace();
// }
//
// ConfigurationHandler.loadGuideText(FileLoader.getGuideText());
// ConfigurationHandler.loadChangelogText(FileLoader.getChangelogText());
//
// CommandMT.initValidCommandArguments(FileLoader.getSupportedModsFile());
//
// ModItems.initItems();
//
// bookHandler = new BookHandler();
// FMLCommonHandler.instance().bus().register(bookHandler);
//
// MinecraftForge.EVENT_BUS.register(new ModEventHandler());
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event)
// {
// ModItems.registerRecipes();
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// if (FMLCommonHandler.instance().getSide().isClient())
// {
// try
// {
// GuiHelper.initMap();
// }
// catch (FileNotFoundException e)
// {
// e.printStackTrace();
// }
// }
// }
//
// @EventHandler
// public void onFMLServerStart(FMLServerStartingEvent event)
// {
// event.registerServerCommand(new CommandMT());
// }
// }
//
// Path: src/main/java/modpacktweaks/network/message/MessageShowDownloadGUI.java
// public class MessageShowDownloadGUI implements IMessage, IMessageHandler<MessageShowDownloadGUI, IMessage>
// {
// public MessageShowDownloadGUI() {}
//
// @Override
// public void fromBytes(ByteBuf buf)
// {}
//
// @Override
// public void toBytes(ByteBuf buf)
// {}
//
// @Override
// public IMessage onMessage(MessageShowDownloadGUI message, MessageContext ctx)
// {
// GuiHelper.doDownloaderGUI();
// return null;
// }
// }
// Path: src/main/java/modpacktweaks/network/PacketHandler.java
import modpacktweaks.ModpackTweaks;
import modpacktweaks.network.message.MessageShowDownloadGUI;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;
package modpacktweaks.network;
public class PacketHandler
{ | public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(ModpackTweaks.CHANNEL); |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/network/PacketHandler.java | // Path: src/main/java/modpacktweaks/ModpackTweaks.java
// @Mod(modid = ModpackTweaks.MODID, name = ModpackTweaks.NAME, version = ModpackTweaks.VERSION, dependencies = ModpackTweaks.DEPEND)
// public class ModpackTweaks
// {
// public static final String MODID = "modpackTweaks";
// public static final String NAME = "ModpackTweaks";
// public static final String DEPEND = "required-after:endercore;after:ThermalExpansion";
// public static final String VERSION = "@VERSION@";
// public static final String CHANNEL = "modpacktweaks";
//
// @Instance
// public static ModpackTweaks instance;
//
// @SidedProxy(clientSide = "modpacktweaks.proxy.ClientProxy", serverSide = "modpacktweaks.proxy.CommonProxy")
// public static CommonProxy proxy;
//
// public static BookHandler bookHandler;
//
// public static final Logger logger = LogManager.getLogger("ModpackTweaks");
//
// public static CreativeTabs creativeTab = new CreativeTabs("tabMT")
// {
// @Override
// public Item getTabIconItem()
// {
// return ModItems.book;
// }
// };
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// ConfigurationHandler.init(new File(event.getModConfigurationDirectory().getAbsolutePath() + "/modpackTweaks/modpackTweaks.cfg"));
// ConfigurationHandler.loadClientsideJson();
//
// try
// {
// FileLoader.init(ConfigurationHandler.cfg, 0);
// }
// catch (IOException e)
// {
// e.printStackTrace();
// }
//
// ConfigurationHandler.loadGuideText(FileLoader.getGuideText());
// ConfigurationHandler.loadChangelogText(FileLoader.getChangelogText());
//
// CommandMT.initValidCommandArguments(FileLoader.getSupportedModsFile());
//
// ModItems.initItems();
//
// bookHandler = new BookHandler();
// FMLCommonHandler.instance().bus().register(bookHandler);
//
// MinecraftForge.EVENT_BUS.register(new ModEventHandler());
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event)
// {
// ModItems.registerRecipes();
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// if (FMLCommonHandler.instance().getSide().isClient())
// {
// try
// {
// GuiHelper.initMap();
// }
// catch (FileNotFoundException e)
// {
// e.printStackTrace();
// }
// }
// }
//
// @EventHandler
// public void onFMLServerStart(FMLServerStartingEvent event)
// {
// event.registerServerCommand(new CommandMT());
// }
// }
//
// Path: src/main/java/modpacktweaks/network/message/MessageShowDownloadGUI.java
// public class MessageShowDownloadGUI implements IMessage, IMessageHandler<MessageShowDownloadGUI, IMessage>
// {
// public MessageShowDownloadGUI() {}
//
// @Override
// public void fromBytes(ByteBuf buf)
// {}
//
// @Override
// public void toBytes(ByteBuf buf)
// {}
//
// @Override
// public IMessage onMessage(MessageShowDownloadGUI message, MessageContext ctx)
// {
// GuiHelper.doDownloaderGUI();
// return null;
// }
// }
| import modpacktweaks.ModpackTweaks;
import modpacktweaks.network.message.MessageShowDownloadGUI;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side; | package modpacktweaks.network;
public class PacketHandler
{
public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(ModpackTweaks.CHANNEL);
private static int id = 0;
public static void init()
{ | // Path: src/main/java/modpacktweaks/ModpackTweaks.java
// @Mod(modid = ModpackTweaks.MODID, name = ModpackTweaks.NAME, version = ModpackTweaks.VERSION, dependencies = ModpackTweaks.DEPEND)
// public class ModpackTweaks
// {
// public static final String MODID = "modpackTweaks";
// public static final String NAME = "ModpackTweaks";
// public static final String DEPEND = "required-after:endercore;after:ThermalExpansion";
// public static final String VERSION = "@VERSION@";
// public static final String CHANNEL = "modpacktweaks";
//
// @Instance
// public static ModpackTweaks instance;
//
// @SidedProxy(clientSide = "modpacktweaks.proxy.ClientProxy", serverSide = "modpacktweaks.proxy.CommonProxy")
// public static CommonProxy proxy;
//
// public static BookHandler bookHandler;
//
// public static final Logger logger = LogManager.getLogger("ModpackTweaks");
//
// public static CreativeTabs creativeTab = new CreativeTabs("tabMT")
// {
// @Override
// public Item getTabIconItem()
// {
// return ModItems.book;
// }
// };
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// ConfigurationHandler.init(new File(event.getModConfigurationDirectory().getAbsolutePath() + "/modpackTweaks/modpackTweaks.cfg"));
// ConfigurationHandler.loadClientsideJson();
//
// try
// {
// FileLoader.init(ConfigurationHandler.cfg, 0);
// }
// catch (IOException e)
// {
// e.printStackTrace();
// }
//
// ConfigurationHandler.loadGuideText(FileLoader.getGuideText());
// ConfigurationHandler.loadChangelogText(FileLoader.getChangelogText());
//
// CommandMT.initValidCommandArguments(FileLoader.getSupportedModsFile());
//
// ModItems.initItems();
//
// bookHandler = new BookHandler();
// FMLCommonHandler.instance().bus().register(bookHandler);
//
// MinecraftForge.EVENT_BUS.register(new ModEventHandler());
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event)
// {
// ModItems.registerRecipes();
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// if (FMLCommonHandler.instance().getSide().isClient())
// {
// try
// {
// GuiHelper.initMap();
// }
// catch (FileNotFoundException e)
// {
// e.printStackTrace();
// }
// }
// }
//
// @EventHandler
// public void onFMLServerStart(FMLServerStartingEvent event)
// {
// event.registerServerCommand(new CommandMT());
// }
// }
//
// Path: src/main/java/modpacktweaks/network/message/MessageShowDownloadGUI.java
// public class MessageShowDownloadGUI implements IMessage, IMessageHandler<MessageShowDownloadGUI, IMessage>
// {
// public MessageShowDownloadGUI() {}
//
// @Override
// public void fromBytes(ByteBuf buf)
// {}
//
// @Override
// public void toBytes(ByteBuf buf)
// {}
//
// @Override
// public IMessage onMessage(MessageShowDownloadGUI message, MessageContext ctx)
// {
// GuiHelper.doDownloaderGUI();
// return null;
// }
// }
// Path: src/main/java/modpacktweaks/network/PacketHandler.java
import modpacktweaks.ModpackTweaks;
import modpacktweaks.network.message.MessageShowDownloadGUI;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;
package modpacktweaks.network;
public class PacketHandler
{
public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(ModpackTweaks.CHANNEL);
private static int id = 0;
public static void init()
{ | INSTANCE.registerMessage(MessageShowDownloadGUI.class, MessageShowDownloadGUI.class, id++, Side.CLIENT); |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementIcon.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.opengl.GL11; | package modpacktweaks.client.gui.library.gui.element;
public class ElementIcon extends ElementBase
{
int texU, texV;
| // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementIcon.java
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.opengl.GL11;
package modpacktweaks.client.gui.library.gui.element;
public class ElementIcon extends ElementBase
{
int texU, texV;
| public ElementIcon(IGuiBase parent, int x, int y, int icon) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementBubbles.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.opengl.GL11; | package modpacktweaks.client.gui.library.gui.element;
public class ElementBubbles extends ElementProgressBar
{
boolean showTooltip;
| // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementBubbles.java
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.opengl.GL11;
package modpacktweaks.client.gui.library.gui.element;
public class ElementBubbles extends ElementProgressBar
{
boolean showTooltip;
| public ElementBubbles(IGuiBase parent, int x, int y) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementText.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase; | package modpacktweaks.client.gui.library.gui.element;
public class ElementText extends ElementBase
{
int colour;
String displayText, hoverText;
boolean shadow;
| // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementText.java
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
package modpacktweaks.client.gui.library.gui.element;
public class ElementText extends ElementBase
{
int colour;
String displayText, hoverText;
boolean shadow;
| public ElementText(IGuiBase parent, int x, int y, String text, String hover) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementFire.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.opengl.GL11; | package modpacktweaks.client.gui.library.gui.element;
public class ElementFire extends ElementProgressBar
{
boolean showTooltip;
| // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementFire.java
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.opengl.GL11;
package modpacktweaks.client.gui.library.gui.element;
public class ElementFire extends ElementProgressBar
{
boolean showTooltip;
| public ElementFire(IGuiBase parent, int x, int y) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/util/DesktopApi.java | // Path: src/main/java/modpacktweaks/ModpackTweaks.java
// @Mod(modid = ModpackTweaks.MODID, name = ModpackTweaks.NAME, version = ModpackTweaks.VERSION, dependencies = ModpackTweaks.DEPEND)
// public class ModpackTweaks
// {
// public static final String MODID = "modpackTweaks";
// public static final String NAME = "ModpackTweaks";
// public static final String DEPEND = "required-after:endercore;after:ThermalExpansion";
// public static final String VERSION = "@VERSION@";
// public static final String CHANNEL = "modpacktweaks";
//
// @Instance
// public static ModpackTweaks instance;
//
// @SidedProxy(clientSide = "modpacktweaks.proxy.ClientProxy", serverSide = "modpacktweaks.proxy.CommonProxy")
// public static CommonProxy proxy;
//
// public static BookHandler bookHandler;
//
// public static final Logger logger = LogManager.getLogger("ModpackTweaks");
//
// public static CreativeTabs creativeTab = new CreativeTabs("tabMT")
// {
// @Override
// public Item getTabIconItem()
// {
// return ModItems.book;
// }
// };
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// ConfigurationHandler.init(new File(event.getModConfigurationDirectory().getAbsolutePath() + "/modpackTweaks/modpackTweaks.cfg"));
// ConfigurationHandler.loadClientsideJson();
//
// try
// {
// FileLoader.init(ConfigurationHandler.cfg, 0);
// }
// catch (IOException e)
// {
// e.printStackTrace();
// }
//
// ConfigurationHandler.loadGuideText(FileLoader.getGuideText());
// ConfigurationHandler.loadChangelogText(FileLoader.getChangelogText());
//
// CommandMT.initValidCommandArguments(FileLoader.getSupportedModsFile());
//
// ModItems.initItems();
//
// bookHandler = new BookHandler();
// FMLCommonHandler.instance().bus().register(bookHandler);
//
// MinecraftForge.EVENT_BUS.register(new ModEventHandler());
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event)
// {
// ModItems.registerRecipes();
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// if (FMLCommonHandler.instance().getSide().isClient())
// {
// try
// {
// GuiHelper.initMap();
// }
// catch (FileNotFoundException e)
// {
// e.printStackTrace();
// }
// }
// }
//
// @EventHandler
// public void onFMLServerStart(FMLServerStartingEvent event)
// {
// event.registerServerCommand(new CommandMT());
// }
// }
| import java.awt.Desktop;
import java.net.URI;
import modpacktweaks.ModpackTweaks; | package modpacktweaks.util;
public class DesktopApi {
public static boolean browse(URI uri) {
if (browseDESKTOP(uri))
return true;
return false;
}
private static boolean browseDESKTOP(URI uri) {
logOut("Trying to use Desktop.getDesktop().browse() with "
+ uri.toString());
try {
if (!Desktop.isDesktopSupported()) {
logErr("Platform is not supported.");
return false;
}
if (!Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
logErr("BORWSE is not supported.");
return false;
}
Desktop.getDesktop().browse(uri);
return true;
} catch (Throwable t) {
logErr("Error using desktop browse.", t);
return false;
}
}
private static void logErr(String msg, Throwable t) { | // Path: src/main/java/modpacktweaks/ModpackTweaks.java
// @Mod(modid = ModpackTweaks.MODID, name = ModpackTweaks.NAME, version = ModpackTweaks.VERSION, dependencies = ModpackTweaks.DEPEND)
// public class ModpackTweaks
// {
// public static final String MODID = "modpackTweaks";
// public static final String NAME = "ModpackTweaks";
// public static final String DEPEND = "required-after:endercore;after:ThermalExpansion";
// public static final String VERSION = "@VERSION@";
// public static final String CHANNEL = "modpacktweaks";
//
// @Instance
// public static ModpackTweaks instance;
//
// @SidedProxy(clientSide = "modpacktweaks.proxy.ClientProxy", serverSide = "modpacktweaks.proxy.CommonProxy")
// public static CommonProxy proxy;
//
// public static BookHandler bookHandler;
//
// public static final Logger logger = LogManager.getLogger("ModpackTweaks");
//
// public static CreativeTabs creativeTab = new CreativeTabs("tabMT")
// {
// @Override
// public Item getTabIconItem()
// {
// return ModItems.book;
// }
// };
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// ConfigurationHandler.init(new File(event.getModConfigurationDirectory().getAbsolutePath() + "/modpackTweaks/modpackTweaks.cfg"));
// ConfigurationHandler.loadClientsideJson();
//
// try
// {
// FileLoader.init(ConfigurationHandler.cfg, 0);
// }
// catch (IOException e)
// {
// e.printStackTrace();
// }
//
// ConfigurationHandler.loadGuideText(FileLoader.getGuideText());
// ConfigurationHandler.loadChangelogText(FileLoader.getChangelogText());
//
// CommandMT.initValidCommandArguments(FileLoader.getSupportedModsFile());
//
// ModItems.initItems();
//
// bookHandler = new BookHandler();
// FMLCommonHandler.instance().bus().register(bookHandler);
//
// MinecraftForge.EVENT_BUS.register(new ModEventHandler());
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event)
// {
// ModItems.registerRecipes();
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// if (FMLCommonHandler.instance().getSide().isClient())
// {
// try
// {
// GuiHelper.initMap();
// }
// catch (FileNotFoundException e)
// {
// e.printStackTrace();
// }
// }
// }
//
// @EventHandler
// public void onFMLServerStart(FMLServerStartingEvent event)
// {
// event.registerServerCommand(new CommandMT());
// }
// }
// Path: src/main/java/modpacktweaks/util/DesktopApi.java
import java.awt.Desktop;
import java.net.URI;
import modpacktweaks.ModpackTweaks;
package modpacktweaks.util;
public class DesktopApi {
public static boolean browse(URI uri) {
if (browseDESKTOP(uri))
return true;
return false;
}
private static boolean browseDESKTOP(URI uri) {
logOut("Trying to use Desktop.getDesktop().browse() with "
+ uri.toString());
try {
if (!Desktop.isDesktopSupported()) {
logErr("Platform is not supported.");
return false;
}
if (!Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
logErr("BORWSE is not supported.");
return false;
}
Desktop.getDesktop().browse(uri);
return true;
} catch (Throwable t) {
logErr("Error using desktop browse.", t);
return false;
}
}
private static void logErr(String msg, Throwable t) { | ModpackTweaks.logger.error(msg); |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementScrollBar.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import modpacktweaks.client.gui.library.gui.IGuiBase;
import net.minecraft.client.gui.Gui;
import org.lwjgl.input.Mouse; | package modpacktweaks.client.gui.library.gui.element;
public class ElementScrollBar extends ElementBase
{
ElementScrollPanel panel;
int barSize;
boolean isMouseButtonDown;
float scroll, oldMouse;
| // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementScrollBar.java
import modpacktweaks.client.gui.library.gui.IGuiBase;
import net.minecraft.client.gui.Gui;
import org.lwjgl.input.Mouse;
package modpacktweaks.client.gui.library.gui.element;
public class ElementScrollBar extends ElementBase
{
ElementScrollPanel panel;
int barSize;
boolean isMouseButtonDown;
float scroll, oldMouse;
| public ElementScrollBar(IGuiBase parent, int x, int y, int w, int h, ElementScrollPanel scroll) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementRightArrow.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.opengl.GL11; | package modpacktweaks.client.gui.library.gui.element;
public class ElementRightArrow extends ElementProgressBar
{
boolean showTooltip;
| // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementRightArrow.java
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.opengl.GL11;
package modpacktweaks.client.gui.library.gui.element;
public class ElementRightArrow extends ElementProgressBar
{
boolean showTooltip;
| public ElementRightArrow(IGuiBase parent, int x, int y) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementItemText.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting; | package modpacktweaks.client.gui.library.gui.element;
public class ElementItemText extends ElementText
{
ItemStack item;
| // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementItemText.java
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
package modpacktweaks.client.gui.library.gui.element;
public class ElementItemText extends ElementText
{
ItemStack item;
| public ElementItemText(IGuiBase parent, int x, int y, ItemStack stack) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/proxy/ClientProxy.java | // Path: src/main/java/modpacktweaks/client/gui/ModDownload.java
// public class ModDownload
// {
// public String name, url, modid;
//
// public ModDownload(String name, String url, String modid)
// {
// this.name = name;
// this.url = url;
// this.modid = modid;
// }
// }
//
// Path: src/main/java/modpacktweaks/client/gui/UpdateGui.java
// @SideOnly(Side.CLIENT)
// public class UpdateGui extends GuiScreen
// {
// protected GuiScreen parentScreen;
// private boolean noShow = true, firstTime;
//
// private static List<InstructionsGui> modScreens = new ArrayList<InstructionsGui>();
//
// private Iterator<InstructionsGui> iterator;
//
// public static void addModDownload(ModDownload mod)
// {
// modScreens.add(new InstructionsGui(mod));
// }
//
// public UpdateGui(GuiScreen parentScreen, boolean firstTime)
// {
// this.parentScreen = parentScreen;
//
// iterator = modScreens.iterator();
//
// if (modScreens.isEmpty() && !firstTime)
// Minecraft.getMinecraft().thePlayer.sendChatMessage("You have all optional mods installed!");
//
// for (InstructionsGui g : modScreens)
// {
// if (!Loader.isModLoaded(g.mod.modid))
// noShow = false;
// }
//
// this.firstTime = firstTime;
//
// GuiHelper.updateGui = this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void initGui()
// {
// if (noShow)
// {
// ModpackTweaks.logger.info("not opening GUI");
// this.mc.displayGuiScreen(this.parentScreen);
// return;
// }
//
// // Unsure exactly what this does but...it seems necessary
// Keyboard.enableRepeatEvents(true);
//
// this.buttonList.clear();
//
// this.buttonList.add(new GuiButton(-1, this.width / 2 - 150, this.height / 2 + 75, 300, 20, "Continue"));
// this.buttonList.add(new GuiButton(11, this.width / 2 - 150, this.height / 2 + 96, 300, 20, "Skip the downloads completely"));
// }
//
// @Override
// public void onGuiClosed()
// {
// Keyboard.enableRepeatEvents(false);
// }
//
// @Override
// protected void actionPerformed(GuiButton button)
// {
// if (button.enabled)
// {
// if (button.id == 11)
// this.mc.displayGuiScreen(this.parentScreen);
// else
// {
// try
// {
// if (iterator.hasNext())
// {
// this.mc.displayGuiScreen(iterator.next());
// }
// /*
// else if (configGui != null)
// {
// File file=new File("config/modpackTweaks/config/hardconfig.zip");
// if (file.exists()) this.mc.displayGuiScreen(configGui);
// configGui = null;
// }
// */
// else if (modScreens.size() > 0)
// {
// this.mc.displayGuiScreen(new RestartGui());
// }
// else
// {
// this.mc.displayGuiScreen(this.parentScreen);
// }
// }
// catch (Exception e)
// {
// ModpackTweaks.logger.error("Error opening webpage, please contact your modpack author.");
// e.printStackTrace();
// }
// }
// }
// }
//
// @Override
// public void drawScreen(int par1, int par2, float par3)
// {
// drawScreen(par1, par2, par3, true);
// }
//
// @SuppressWarnings("unchecked")
// public void drawScreen(int par1, int par2, float par3, boolean draw)
// {
// if (draw)
// {
// this.drawDefaultBackground();
//
// int heightLoc = 100;
//
// String[] lines = replaceTextCodes(ConfigurationHandler.downloadGuiText).split("\n");
// for (String s : lines) {
//
// List<String> info = fontRendererObj.listFormattedStringToWidth(s, this.width - 40);
// for (String infoCut : info) {
// drawCenteredString(this.fontRendererObj, infoCut, this.width / 2, this.height / 2 - heightLoc, 0xFFFFFF);
// heightLoc = heightLoc - 12;
// }
// }
// }
//
// super.drawScreen(par1, par2, par3);
// }
//
// private static String replaceTextCodes(String toReplace) {
// return toReplace
// .replace("\\n", "\n")
// .replace("%name%", ConfigurationHandler.packName)
// .replace("%acro%", ConfigurationHandler.packAcronym)
// .replace("%version%", ConfigurationHandler.packVersion);
// }
// }
| import modpacktweaks.client.gui.ModDownload;
import modpacktweaks.client.gui.UpdateGui; | package modpacktweaks.proxy;
public class ClientProxy extends CommonProxy
{
@Override | // Path: src/main/java/modpacktweaks/client/gui/ModDownload.java
// public class ModDownload
// {
// public String name, url, modid;
//
// public ModDownload(String name, String url, String modid)
// {
// this.name = name;
// this.url = url;
// this.modid = modid;
// }
// }
//
// Path: src/main/java/modpacktweaks/client/gui/UpdateGui.java
// @SideOnly(Side.CLIENT)
// public class UpdateGui extends GuiScreen
// {
// protected GuiScreen parentScreen;
// private boolean noShow = true, firstTime;
//
// private static List<InstructionsGui> modScreens = new ArrayList<InstructionsGui>();
//
// private Iterator<InstructionsGui> iterator;
//
// public static void addModDownload(ModDownload mod)
// {
// modScreens.add(new InstructionsGui(mod));
// }
//
// public UpdateGui(GuiScreen parentScreen, boolean firstTime)
// {
// this.parentScreen = parentScreen;
//
// iterator = modScreens.iterator();
//
// if (modScreens.isEmpty() && !firstTime)
// Minecraft.getMinecraft().thePlayer.sendChatMessage("You have all optional mods installed!");
//
// for (InstructionsGui g : modScreens)
// {
// if (!Loader.isModLoaded(g.mod.modid))
// noShow = false;
// }
//
// this.firstTime = firstTime;
//
// GuiHelper.updateGui = this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void initGui()
// {
// if (noShow)
// {
// ModpackTweaks.logger.info("not opening GUI");
// this.mc.displayGuiScreen(this.parentScreen);
// return;
// }
//
// // Unsure exactly what this does but...it seems necessary
// Keyboard.enableRepeatEvents(true);
//
// this.buttonList.clear();
//
// this.buttonList.add(new GuiButton(-1, this.width / 2 - 150, this.height / 2 + 75, 300, 20, "Continue"));
// this.buttonList.add(new GuiButton(11, this.width / 2 - 150, this.height / 2 + 96, 300, 20, "Skip the downloads completely"));
// }
//
// @Override
// public void onGuiClosed()
// {
// Keyboard.enableRepeatEvents(false);
// }
//
// @Override
// protected void actionPerformed(GuiButton button)
// {
// if (button.enabled)
// {
// if (button.id == 11)
// this.mc.displayGuiScreen(this.parentScreen);
// else
// {
// try
// {
// if (iterator.hasNext())
// {
// this.mc.displayGuiScreen(iterator.next());
// }
// /*
// else if (configGui != null)
// {
// File file=new File("config/modpackTweaks/config/hardconfig.zip");
// if (file.exists()) this.mc.displayGuiScreen(configGui);
// configGui = null;
// }
// */
// else if (modScreens.size() > 0)
// {
// this.mc.displayGuiScreen(new RestartGui());
// }
// else
// {
// this.mc.displayGuiScreen(this.parentScreen);
// }
// }
// catch (Exception e)
// {
// ModpackTweaks.logger.error("Error opening webpage, please contact your modpack author.");
// e.printStackTrace();
// }
// }
// }
// }
//
// @Override
// public void drawScreen(int par1, int par2, float par3)
// {
// drawScreen(par1, par2, par3, true);
// }
//
// @SuppressWarnings("unchecked")
// public void drawScreen(int par1, int par2, float par3, boolean draw)
// {
// if (draw)
// {
// this.drawDefaultBackground();
//
// int heightLoc = 100;
//
// String[] lines = replaceTextCodes(ConfigurationHandler.downloadGuiText).split("\n");
// for (String s : lines) {
//
// List<String> info = fontRendererObj.listFormattedStringToWidth(s, this.width - 40);
// for (String infoCut : info) {
// drawCenteredString(this.fontRendererObj, infoCut, this.width / 2, this.height / 2 - heightLoc, 0xFFFFFF);
// heightLoc = heightLoc - 12;
// }
// }
// }
//
// super.drawScreen(par1, par2, par3);
// }
//
// private static String replaceTextCodes(String toReplace) {
// return toReplace
// .replace("\\n", "\n")
// .replace("%name%", ConfigurationHandler.packName)
// .replace("%acro%", ConfigurationHandler.packAcronym)
// .replace("%version%", ConfigurationHandler.packVersion);
// }
// }
// Path: src/main/java/modpacktweaks/proxy/ClientProxy.java
import modpacktweaks.client.gui.ModDownload;
import modpacktweaks.client.gui.UpdateGui;
package modpacktweaks.proxy;
public class ClientProxy extends CommonProxy
{
@Override | public void addJsonToGUI(ModDownload fromJson) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/proxy/ClientProxy.java | // Path: src/main/java/modpacktweaks/client/gui/ModDownload.java
// public class ModDownload
// {
// public String name, url, modid;
//
// public ModDownload(String name, String url, String modid)
// {
// this.name = name;
// this.url = url;
// this.modid = modid;
// }
// }
//
// Path: src/main/java/modpacktweaks/client/gui/UpdateGui.java
// @SideOnly(Side.CLIENT)
// public class UpdateGui extends GuiScreen
// {
// protected GuiScreen parentScreen;
// private boolean noShow = true, firstTime;
//
// private static List<InstructionsGui> modScreens = new ArrayList<InstructionsGui>();
//
// private Iterator<InstructionsGui> iterator;
//
// public static void addModDownload(ModDownload mod)
// {
// modScreens.add(new InstructionsGui(mod));
// }
//
// public UpdateGui(GuiScreen parentScreen, boolean firstTime)
// {
// this.parentScreen = parentScreen;
//
// iterator = modScreens.iterator();
//
// if (modScreens.isEmpty() && !firstTime)
// Minecraft.getMinecraft().thePlayer.sendChatMessage("You have all optional mods installed!");
//
// for (InstructionsGui g : modScreens)
// {
// if (!Loader.isModLoaded(g.mod.modid))
// noShow = false;
// }
//
// this.firstTime = firstTime;
//
// GuiHelper.updateGui = this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void initGui()
// {
// if (noShow)
// {
// ModpackTweaks.logger.info("not opening GUI");
// this.mc.displayGuiScreen(this.parentScreen);
// return;
// }
//
// // Unsure exactly what this does but...it seems necessary
// Keyboard.enableRepeatEvents(true);
//
// this.buttonList.clear();
//
// this.buttonList.add(new GuiButton(-1, this.width / 2 - 150, this.height / 2 + 75, 300, 20, "Continue"));
// this.buttonList.add(new GuiButton(11, this.width / 2 - 150, this.height / 2 + 96, 300, 20, "Skip the downloads completely"));
// }
//
// @Override
// public void onGuiClosed()
// {
// Keyboard.enableRepeatEvents(false);
// }
//
// @Override
// protected void actionPerformed(GuiButton button)
// {
// if (button.enabled)
// {
// if (button.id == 11)
// this.mc.displayGuiScreen(this.parentScreen);
// else
// {
// try
// {
// if (iterator.hasNext())
// {
// this.mc.displayGuiScreen(iterator.next());
// }
// /*
// else if (configGui != null)
// {
// File file=new File("config/modpackTweaks/config/hardconfig.zip");
// if (file.exists()) this.mc.displayGuiScreen(configGui);
// configGui = null;
// }
// */
// else if (modScreens.size() > 0)
// {
// this.mc.displayGuiScreen(new RestartGui());
// }
// else
// {
// this.mc.displayGuiScreen(this.parentScreen);
// }
// }
// catch (Exception e)
// {
// ModpackTweaks.logger.error("Error opening webpage, please contact your modpack author.");
// e.printStackTrace();
// }
// }
// }
// }
//
// @Override
// public void drawScreen(int par1, int par2, float par3)
// {
// drawScreen(par1, par2, par3, true);
// }
//
// @SuppressWarnings("unchecked")
// public void drawScreen(int par1, int par2, float par3, boolean draw)
// {
// if (draw)
// {
// this.drawDefaultBackground();
//
// int heightLoc = 100;
//
// String[] lines = replaceTextCodes(ConfigurationHandler.downloadGuiText).split("\n");
// for (String s : lines) {
//
// List<String> info = fontRendererObj.listFormattedStringToWidth(s, this.width - 40);
// for (String infoCut : info) {
// drawCenteredString(this.fontRendererObj, infoCut, this.width / 2, this.height / 2 - heightLoc, 0xFFFFFF);
// heightLoc = heightLoc - 12;
// }
// }
// }
//
// super.drawScreen(par1, par2, par3);
// }
//
// private static String replaceTextCodes(String toReplace) {
// return toReplace
// .replace("\\n", "\n")
// .replace("%name%", ConfigurationHandler.packName)
// .replace("%acro%", ConfigurationHandler.packAcronym)
// .replace("%version%", ConfigurationHandler.packVersion);
// }
// }
| import modpacktweaks.client.gui.ModDownload;
import modpacktweaks.client.gui.UpdateGui; | package modpacktweaks.proxy;
public class ClientProxy extends CommonProxy
{
@Override
public void addJsonToGUI(ModDownload fromJson)
{ | // Path: src/main/java/modpacktweaks/client/gui/ModDownload.java
// public class ModDownload
// {
// public String name, url, modid;
//
// public ModDownload(String name, String url, String modid)
// {
// this.name = name;
// this.url = url;
// this.modid = modid;
// }
// }
//
// Path: src/main/java/modpacktweaks/client/gui/UpdateGui.java
// @SideOnly(Side.CLIENT)
// public class UpdateGui extends GuiScreen
// {
// protected GuiScreen parentScreen;
// private boolean noShow = true, firstTime;
//
// private static List<InstructionsGui> modScreens = new ArrayList<InstructionsGui>();
//
// private Iterator<InstructionsGui> iterator;
//
// public static void addModDownload(ModDownload mod)
// {
// modScreens.add(new InstructionsGui(mod));
// }
//
// public UpdateGui(GuiScreen parentScreen, boolean firstTime)
// {
// this.parentScreen = parentScreen;
//
// iterator = modScreens.iterator();
//
// if (modScreens.isEmpty() && !firstTime)
// Minecraft.getMinecraft().thePlayer.sendChatMessage("You have all optional mods installed!");
//
// for (InstructionsGui g : modScreens)
// {
// if (!Loader.isModLoaded(g.mod.modid))
// noShow = false;
// }
//
// this.firstTime = firstTime;
//
// GuiHelper.updateGui = this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void initGui()
// {
// if (noShow)
// {
// ModpackTweaks.logger.info("not opening GUI");
// this.mc.displayGuiScreen(this.parentScreen);
// return;
// }
//
// // Unsure exactly what this does but...it seems necessary
// Keyboard.enableRepeatEvents(true);
//
// this.buttonList.clear();
//
// this.buttonList.add(new GuiButton(-1, this.width / 2 - 150, this.height / 2 + 75, 300, 20, "Continue"));
// this.buttonList.add(new GuiButton(11, this.width / 2 - 150, this.height / 2 + 96, 300, 20, "Skip the downloads completely"));
// }
//
// @Override
// public void onGuiClosed()
// {
// Keyboard.enableRepeatEvents(false);
// }
//
// @Override
// protected void actionPerformed(GuiButton button)
// {
// if (button.enabled)
// {
// if (button.id == 11)
// this.mc.displayGuiScreen(this.parentScreen);
// else
// {
// try
// {
// if (iterator.hasNext())
// {
// this.mc.displayGuiScreen(iterator.next());
// }
// /*
// else if (configGui != null)
// {
// File file=new File("config/modpackTweaks/config/hardconfig.zip");
// if (file.exists()) this.mc.displayGuiScreen(configGui);
// configGui = null;
// }
// */
// else if (modScreens.size() > 0)
// {
// this.mc.displayGuiScreen(new RestartGui());
// }
// else
// {
// this.mc.displayGuiScreen(this.parentScreen);
// }
// }
// catch (Exception e)
// {
// ModpackTweaks.logger.error("Error opening webpage, please contact your modpack author.");
// e.printStackTrace();
// }
// }
// }
// }
//
// @Override
// public void drawScreen(int par1, int par2, float par3)
// {
// drawScreen(par1, par2, par3, true);
// }
//
// @SuppressWarnings("unchecked")
// public void drawScreen(int par1, int par2, float par3, boolean draw)
// {
// if (draw)
// {
// this.drawDefaultBackground();
//
// int heightLoc = 100;
//
// String[] lines = replaceTextCodes(ConfigurationHandler.downloadGuiText).split("\n");
// for (String s : lines) {
//
// List<String> info = fontRendererObj.listFormattedStringToWidth(s, this.width - 40);
// for (String infoCut : info) {
// drawCenteredString(this.fontRendererObj, infoCut, this.width / 2, this.height / 2 - heightLoc, 0xFFFFFF);
// heightLoc = heightLoc - 12;
// }
// }
// }
//
// super.drawScreen(par1, par2, par3);
// }
//
// private static String replaceTextCodes(String toReplace) {
// return toReplace
// .replace("\\n", "\n")
// .replace("%name%", ConfigurationHandler.packName)
// .replace("%acro%", ConfigurationHandler.packAcronym)
// .replace("%version%", ConfigurationHandler.packVersion);
// }
// }
// Path: src/main/java/modpacktweaks/proxy/ClientProxy.java
import modpacktweaks.client.gui.ModDownload;
import modpacktweaks.client.gui.UpdateGui;
package modpacktweaks.proxy;
public class ClientProxy extends CommonProxy
{
@Override
public void addJsonToGUI(ModDownload fromJson)
{ | UpdateGui.addModDownload(fromJson); |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/element/ElementDownArrow.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.opengl.GL11; | package modpacktweaks.client.gui.library.gui.element;
public class ElementDownArrow extends ElementProgressBar
{
boolean showTooltip;
| // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/element/ElementDownArrow.java
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import org.lwjgl.opengl.GL11;
package modpacktweaks.client.gui.library.gui.element;
public class ElementDownArrow extends ElementProgressBar
{
boolean showTooltip;
| public ElementDownArrow(IGuiBase parent, int x, int y) |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/network/message/MessageShowDownloadGUI.java | // Path: src/main/java/modpacktweaks/client/gui/GuiHelper.java
// public class GuiHelper
// {
// @SideOnly(Side.CLIENT)
// public static UpdateGui updateGui;
//
// public static void doDownloaderGUI()
// {
// Minecraft.getMinecraft().displayGuiScreen((updateGui = new UpdateGui(Minecraft.getMinecraft().currentScreen, false)));
// }
//
// public static void doGuideGUI()
// {
// Minecraft.getMinecraft().displayGuiScreen(new GuiGuideBase());
// }
//
// public static void initMap() throws FileNotFoundException
// {
// GuiGuideBase.initMap();
// }
//
// public static void doBookGUI(EntityPlayer player, ItemStack stack, boolean par3)
// {
// Minecraft.getMinecraft().displayGuiScreen(new GuiScreenBook(player, stack, par3));
// }
// }
| import modpacktweaks.client.gui.GuiHelper;
import io.netty.buffer.ByteBuf;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext; | package modpacktweaks.network.message;
public class MessageShowDownloadGUI implements IMessage, IMessageHandler<MessageShowDownloadGUI, IMessage>
{
public MessageShowDownloadGUI() {}
@Override
public void fromBytes(ByteBuf buf)
{}
@Override
public void toBytes(ByteBuf buf)
{}
@Override
public IMessage onMessage(MessageShowDownloadGUI message, MessageContext ctx)
{ | // Path: src/main/java/modpacktweaks/client/gui/GuiHelper.java
// public class GuiHelper
// {
// @SideOnly(Side.CLIENT)
// public static UpdateGui updateGui;
//
// public static void doDownloaderGUI()
// {
// Minecraft.getMinecraft().displayGuiScreen((updateGui = new UpdateGui(Minecraft.getMinecraft().currentScreen, false)));
// }
//
// public static void doGuideGUI()
// {
// Minecraft.getMinecraft().displayGuiScreen(new GuiGuideBase());
// }
//
// public static void initMap() throws FileNotFoundException
// {
// GuiGuideBase.initMap();
// }
//
// public static void doBookGUI(EntityPlayer player, ItemStack stack, boolean par3)
// {
// Minecraft.getMinecraft().displayGuiScreen(new GuiScreenBook(player, stack, par3));
// }
// }
// Path: src/main/java/modpacktweaks/network/message/MessageShowDownloadGUI.java
import modpacktweaks.client.gui.GuiHelper;
import io.netty.buffer.ByteBuf;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
package modpacktweaks.network.message;
public class MessageShowDownloadGUI implements IMessage, IMessageHandler<MessageShowDownloadGUI, IMessage>
{
public MessageShowDownloadGUI() {}
@Override
public void fromBytes(ByteBuf buf)
{}
@Override
public void toBytes(ByteBuf buf)
{}
@Override
public IMessage onMessage(MessageShowDownloadGUI message, MessageContext ctx)
{ | GuiHelper.doDownloaderGUI(); |
TPPIDev/Modpack-Tweaks | src/main/java/modpacktweaks/client/gui/library/gui/utils/GuiUtils.java | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
| import java.util.Iterator;
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12; | package modpacktweaks.client.gui.library.gui.utils;
public class GuiUtils extends Gui
{
public static GuiUtils instance = new GuiUtils();
/**
* Simple method used to draw a fluid of arbitrary size.
*/ | // Path: src/main/java/modpacktweaks/client/gui/library/gui/IGuiBase.java
// public interface IGuiBase
// {
// public ElementBase addElement(ElementBase element);
//
// public void addElements();
//
// public void addTabs();
//
// public void drawBackgroundTexture();
//
// public void drawElements();
//
// public ElementBase getElementAtPosition(int mouseX, int mouseY);
//
// public FontRenderer getFontRenderer();
//
// public int getGuiLeft();
//
// public int getGuiTop();
//
// public int getHeight();
//
// public RenderItem getItemRenderer();
//
// public Minecraft getMinecraft();
//
// public int getMouseX();
//
// public int getMouseY();
//
// public TextureManager getTextureManager();
//
// public int getWidth();
//
// public float getZLevel();
//
// public void handleElementButtonClick(String buttonName, int mouseButton);
//
// public void handleElementFakeSlotItemChange(ElementFakeItemSlot slot);
//
// public boolean isItemStackAllowedInFakeSlot(ElementFakeItemSlot slot, ItemStack stack);
//
// public void setZLevel(float zlevel);
// }
// Path: src/main/java/modpacktweaks/client/gui/library/gui/utils/GuiUtils.java
import java.util.Iterator;
import java.util.List;
import modpacktweaks.client.gui.library.gui.IGuiBase;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
package modpacktweaks.client.gui.library.gui.utils;
public class GuiUtils extends Gui
{
public static GuiUtils instance = new GuiUtils();
/**
* Simple method used to draw a fluid of arbitrary size.
*/ | public static void drawFluid(IGuiBase gui, int x, int y, FluidStack fluid, int width, int height) |
matt-allen/repay-android | repay/src/main/java/com/repay/android/adddebt/ChoosePersonAdapter.java | // Path: repay/src/main/java/com/repay/android/Application.java
// public class Application extends android.app.Application {
//
// private static final String TAG = Application.class.getSimpleName();
//
// private static DisplayImageOptions mImageOptions;
// private ImageLoaderConfiguration mLoadConfig;
//
// @Override
// public void onCreate()
// {
// super.onCreate();
// Log.d(TAG, "Image options now being set");
// mImageOptions = new DisplayImageOptions.Builder().resetViewBeforeLoading(true)
// .cacheInMemory(true).cacheOnDisk(true)
// .imageScaleType(ImageScaleType.NONE)
// .showImageOnLoading(R.drawable.friend_image_light)
// .showImageForEmptyUri(R.drawable.friend_image_light)
// .build();
// mLoadConfig = new ImageLoaderConfiguration.Builder(this).imageDownloader(new MyImageDownloader(this)).build();
// ImageLoader.getInstance().init(mLoadConfig);
// }
//
// public static DisplayImageOptions getImageOptions()
// {
// return mImageOptions;
// }
// }
//
// Path: repay/src/main/java/com/repay/android/model/Friend.java
// public class Friend implements Comparable<Friend>, Serializable {
//
// public static final String REPAYID = "repayID";
// public static final String LOOKUPURI = "lookupUri";
// public static final String NAME = "name";
// public static final String AMOUNT = "amount";
//
// private String name, repayID;
// private BigDecimal debt;
// private String lookupURI;
//
// public Friend(String repayID, String lookupURI, String name, BigDecimal debt) {
// super();
// this.lookupURI = lookupURI;
// this.name = name;
// this.repayID = repayID;
// this.debt = debt;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getRepayID() {
// return repayID;
// }
//
// public String getLookupURI() {
// return lookupURI;
// }
//
// public BigDecimal getDebt() {
// return debt;
// }
//
// public void setDebt(BigDecimal debt) {
// this.debt = debt;
// }
//
// @Override
// public int compareTo(Friend another) {
// return another.getDebt().compareTo(debt);
// }
//
// @Override
// public boolean equals(Object o) {
// return (o.getClass() == Friend.class && ((Friend) o).getRepayID().equals(repayID));
// }
// }
| import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.repay.android.Application;
import com.repay.android.R;
import com.repay.android.model.Friend;
import java.util.ArrayList; | notifyDataSetChanged();
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View v = convertView;
if (v == null)
{
LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(mLayoutID, null);
}
Friend friend = mFriends.get(position);
TextView name = (TextView)v.findViewById(R.id.activity_friendchooser_name);
final ImageView pic = (ImageView)v.findViewById(R.id.activity_friendchooser_pic);
if (friend != null)
{
v.setTag(friend); // Stored as a tag to be retrieved later for OnItemClickListener
// Colour the list item based on whether it is in the 'selected' list
if (mSelectedFriends.contains(friend))
{
v.setBackgroundColor(SELECTED_COLOUR);
}
else
{
v.setBackgroundColor(DESELECTED_COLOUR);
}
} | // Path: repay/src/main/java/com/repay/android/Application.java
// public class Application extends android.app.Application {
//
// private static final String TAG = Application.class.getSimpleName();
//
// private static DisplayImageOptions mImageOptions;
// private ImageLoaderConfiguration mLoadConfig;
//
// @Override
// public void onCreate()
// {
// super.onCreate();
// Log.d(TAG, "Image options now being set");
// mImageOptions = new DisplayImageOptions.Builder().resetViewBeforeLoading(true)
// .cacheInMemory(true).cacheOnDisk(true)
// .imageScaleType(ImageScaleType.NONE)
// .showImageOnLoading(R.drawable.friend_image_light)
// .showImageForEmptyUri(R.drawable.friend_image_light)
// .build();
// mLoadConfig = new ImageLoaderConfiguration.Builder(this).imageDownloader(new MyImageDownloader(this)).build();
// ImageLoader.getInstance().init(mLoadConfig);
// }
//
// public static DisplayImageOptions getImageOptions()
// {
// return mImageOptions;
// }
// }
//
// Path: repay/src/main/java/com/repay/android/model/Friend.java
// public class Friend implements Comparable<Friend>, Serializable {
//
// public static final String REPAYID = "repayID";
// public static final String LOOKUPURI = "lookupUri";
// public static final String NAME = "name";
// public static final String AMOUNT = "amount";
//
// private String name, repayID;
// private BigDecimal debt;
// private String lookupURI;
//
// public Friend(String repayID, String lookupURI, String name, BigDecimal debt) {
// super();
// this.lookupURI = lookupURI;
// this.name = name;
// this.repayID = repayID;
// this.debt = debt;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getRepayID() {
// return repayID;
// }
//
// public String getLookupURI() {
// return lookupURI;
// }
//
// public BigDecimal getDebt() {
// return debt;
// }
//
// public void setDebt(BigDecimal debt) {
// this.debt = debt;
// }
//
// @Override
// public int compareTo(Friend another) {
// return another.getDebt().compareTo(debt);
// }
//
// @Override
// public boolean equals(Object o) {
// return (o.getClass() == Friend.class && ((Friend) o).getRepayID().equals(repayID));
// }
// }
// Path: repay/src/main/java/com/repay/android/adddebt/ChoosePersonAdapter.java
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.repay.android.Application;
import com.repay.android.R;
import com.repay.android.model.Friend;
import java.util.ArrayList;
notifyDataSetChanged();
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View v = convertView;
if (v == null)
{
LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(mLayoutID, null);
}
Friend friend = mFriends.get(position);
TextView name = (TextView)v.findViewById(R.id.activity_friendchooser_name);
final ImageView pic = (ImageView)v.findViewById(R.id.activity_friendchooser_pic);
if (friend != null)
{
v.setTag(friend); // Stored as a tag to be retrieved later for OnItemClickListener
// Colour the list item based on whether it is in the 'selected' list
if (mSelectedFriends.contains(friend))
{
v.setBackgroundColor(SELECTED_COLOUR);
}
else
{
v.setBackgroundColor(DESELECTED_COLOUR);
}
} | ImageLoader.getInstance().displayImage(friend.getLookupURI(), pic, Application.getImageOptions()); |
matt-allen/repay-android | repay/src/main/java/com/repay/android/adddebt/AddDebtActivity.java | // Path: repay/src/main/java/com/repay/android/settings/SettingsActivity.java
// public class SettingsActivity extends Activity
// {
// @Override
// protected void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
//
// getActionBar().setDisplayShowTitleEnabled(false);
// getActionBar().setDisplayHomeAsUpEnabled(true);
//
// setContentView(R.layout.settings_activity);
//
// getFragmentManager().beginTransaction().replace(R.id.settings_FrameLayout, new SettingsFragment()).commit();
// }
// }
| import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.repay.android.R;
import com.repay.android.settings.SettingsActivity;
import java.math.BigDecimal; | getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setDisplayShowTitleEnabled(true);
getActionBar().setSubtitle(R.string.choose_people);
setContentView(R.layout.activity_adddebt);
mFrame = R.id.activity_adddebt_framelayout;
if (getFragmentManager().findFragmentById(mFrame) == null)
{
// Show the first fragment
getFragmentManager().beginTransaction().replace(mFrame, new ChoosePersonFragment()).commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.adddebt, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case R.id.action_settings:
Intent intent = new Intent(); | // Path: repay/src/main/java/com/repay/android/settings/SettingsActivity.java
// public class SettingsActivity extends Activity
// {
// @Override
// protected void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
//
// getActionBar().setDisplayShowTitleEnabled(false);
// getActionBar().setDisplayHomeAsUpEnabled(true);
//
// setContentView(R.layout.settings_activity);
//
// getFragmentManager().beginTransaction().replace(R.id.settings_FrameLayout, new SettingsFragment()).commit();
// }
// }
// Path: repay/src/main/java/com/repay/android/adddebt/AddDebtActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.repay.android.R;
import com.repay.android.settings.SettingsActivity;
import java.math.BigDecimal;
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setDisplayShowTitleEnabled(true);
getActionBar().setSubtitle(R.string.choose_people);
setContentView(R.layout.activity_adddebt);
mFrame = R.id.activity_adddebt_framelayout;
if (getFragmentManager().findFragmentById(mFrame) == null)
{
// Show the first fragment
getFragmentManager().beginTransaction().replace(mFrame, new ChoosePersonFragment()).commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.adddebt, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case R.id.action_settings:
Intent intent = new Intent(); | intent.setClass(this, SettingsActivity.class); |
matt-allen/repay-android | repay/src/main/java/com/repay/android/frienddetails/OnFriendUpdatedListener.java | // Path: repay/src/main/java/com/repay/android/model/Friend.java
// public class Friend implements Comparable<Friend>, Serializable {
//
// public static final String REPAYID = "repayID";
// public static final String LOOKUPURI = "lookupUri";
// public static final String NAME = "name";
// public static final String AMOUNT = "amount";
//
// private String name, repayID;
// private BigDecimal debt;
// private String lookupURI;
//
// public Friend(String repayID, String lookupURI, String name, BigDecimal debt) {
// super();
// this.lookupURI = lookupURI;
// this.name = name;
// this.repayID = repayID;
// this.debt = debt;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getRepayID() {
// return repayID;
// }
//
// public String getLookupURI() {
// return lookupURI;
// }
//
// public BigDecimal getDebt() {
// return debt;
// }
//
// public void setDebt(BigDecimal debt) {
// this.debt = debt;
// }
//
// @Override
// public int compareTo(Friend another) {
// return another.getDebt().compareTo(debt);
// }
//
// @Override
// public boolean equals(Object o) {
// return (o.getClass() == Friend.class && ((Friend) o).getRepayID().equals(repayID));
// }
// }
| import com.repay.android.model.Friend; | package com.repay.android.frienddetails;
/**
* Created by Matt Allen
* http://mattallensoftware.co.uk
* [email protected]
* <p/>
* 17/08/2014.
*/
public interface OnFriendUpdatedListener
{ | // Path: repay/src/main/java/com/repay/android/model/Friend.java
// public class Friend implements Comparable<Friend>, Serializable {
//
// public static final String REPAYID = "repayID";
// public static final String LOOKUPURI = "lookupUri";
// public static final String NAME = "name";
// public static final String AMOUNT = "amount";
//
// private String name, repayID;
// private BigDecimal debt;
// private String lookupURI;
//
// public Friend(String repayID, String lookupURI, String name, BigDecimal debt) {
// super();
// this.lookupURI = lookupURI;
// this.name = name;
// this.repayID = repayID;
// this.debt = debt;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getRepayID() {
// return repayID;
// }
//
// public String getLookupURI() {
// return lookupURI;
// }
//
// public BigDecimal getDebt() {
// return debt;
// }
//
// public void setDebt(BigDecimal debt) {
// this.debt = debt;
// }
//
// @Override
// public int compareTo(Friend another) {
// return another.getDebt().compareTo(debt);
// }
//
// @Override
// public boolean equals(Object o) {
// return (o.getClass() == Friend.class && ((Friend) o).getRepayID().equals(repayID));
// }
// }
// Path: repay/src/main/java/com/repay/android/frienddetails/OnFriendUpdatedListener.java
import com.repay.android.model.Friend;
package com.repay.android.frienddetails;
/**
* Created by Matt Allen
* http://mattallensoftware.co.uk
* [email protected]
* <p/>
* 17/08/2014.
*/
public interface OnFriendUpdatedListener
{ | public void onFriendUpdated(Friend mFriend); |
matt-allen/repay-android | repay/src/main/java/com/repay/android/database/DatabaseHandler.java | // Path: repay/src/main/java/com/repay/android/model/Debt.java
// public class Debt implements Comparable<Debt>, Serializable {
//
// private Date date;
// private BigDecimal amount;
// private String repayID, description;
// private int debtID;
//
// public Debt(int debtID, String repayID, Date date, BigDecimal amount, String description) {
// super();
// this.date = date;
// this.debtID = debtID;
// this.amount = amount;
// this.repayID = repayID;
// this.description = description;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public BigDecimal getAmount() {
// return amount;
// }
//
// public void setAmount(BigDecimal amount) {
// this.amount = amount;
// }
//
// public String getRepayID() {
// return repayID;
// }
//
// public void setRepayID(String repayID) {
// this.repayID = repayID;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public int getDebtID(){
// return debtID;
// }
//
// @Override
// public int compareTo(Debt another) {
// return another.getDate().compareTo(date);
// }
// }
//
// Path: repay/src/main/java/com/repay/android/model/Friend.java
// public class Friend implements Comparable<Friend>, Serializable {
//
// public static final String REPAYID = "repayID";
// public static final String LOOKUPURI = "lookupUri";
// public static final String NAME = "name";
// public static final String AMOUNT = "amount";
//
// private String name, repayID;
// private BigDecimal debt;
// private String lookupURI;
//
// public Friend(String repayID, String lookupURI, String name, BigDecimal debt) {
// super();
// this.lookupURI = lookupURI;
// this.name = name;
// this.repayID = repayID;
// this.debt = debt;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getRepayID() {
// return repayID;
// }
//
// public String getLookupURI() {
// return lookupURI;
// }
//
// public BigDecimal getDebt() {
// return debt;
// }
//
// public void setDebt(BigDecimal debt) {
// this.debt = debt;
// }
//
// @Override
// public int compareTo(Friend another) {
// return another.getDebt().compareTo(debt);
// }
//
// @Override
// public boolean equals(Object o) {
// return (o.getClass() == Friend.class && ((Friend) o).getRepayID().equals(repayID));
// }
// }
| import java.math.BigDecimal;
import java.security.SecureRandom;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import com.repay.android.model.Debt;
import com.repay.android.model.Friend;
import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.CursorIndexOutOfBoundsException;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.net.Uri;
import android.util.Log; | super(context, DB_NAME, null, DB_VERSION);
}
/**
* Generate an ID for entering into the database as a primary key
* @return String representation of the Repay ID
*/
public static String generateRepayID() {
long rand = new SecureRandom().nextLong();
return String.valueOf(rand);
}
@Override
public void onCreate(SQLiteDatabase db) {
// Create Friends table
db.execSQL(String.format("CREATE TABLE %s (%s TEXT PRIMARY KEY, %s TEXT, %s TEXT, %s TEXT)",
Names.F_TABLENAME, Names.F_REPAYID, Names.F_LOOKUPURI, Names.F_NAME, Names.F_DEBT));
// Create Debts table
db.execSQL(String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY AUTOINCREMENT, %s TEXT NOT NULL, "
+ "%s TEXT, %s TEXT, %s TEXT, FOREIGN KEY(%s) REFERENCES %s(%s))", Names.D_TABLENAME,
Names.D_DEBTID, Names.D_REPAYID, Names.D_DATE, Names.D_AMOUNT,
Names.D_DESCRIPTION, Names.D_REPAYID, Names.F_TABLENAME, Names.F_REPAYID));
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (oldVersion==1 && newVersion==2){
// Change to include a debtID
try{ | // Path: repay/src/main/java/com/repay/android/model/Debt.java
// public class Debt implements Comparable<Debt>, Serializable {
//
// private Date date;
// private BigDecimal amount;
// private String repayID, description;
// private int debtID;
//
// public Debt(int debtID, String repayID, Date date, BigDecimal amount, String description) {
// super();
// this.date = date;
// this.debtID = debtID;
// this.amount = amount;
// this.repayID = repayID;
// this.description = description;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public BigDecimal getAmount() {
// return amount;
// }
//
// public void setAmount(BigDecimal amount) {
// this.amount = amount;
// }
//
// public String getRepayID() {
// return repayID;
// }
//
// public void setRepayID(String repayID) {
// this.repayID = repayID;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public int getDebtID(){
// return debtID;
// }
//
// @Override
// public int compareTo(Debt another) {
// return another.getDate().compareTo(date);
// }
// }
//
// Path: repay/src/main/java/com/repay/android/model/Friend.java
// public class Friend implements Comparable<Friend>, Serializable {
//
// public static final String REPAYID = "repayID";
// public static final String LOOKUPURI = "lookupUri";
// public static final String NAME = "name";
// public static final String AMOUNT = "amount";
//
// private String name, repayID;
// private BigDecimal debt;
// private String lookupURI;
//
// public Friend(String repayID, String lookupURI, String name, BigDecimal debt) {
// super();
// this.lookupURI = lookupURI;
// this.name = name;
// this.repayID = repayID;
// this.debt = debt;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getRepayID() {
// return repayID;
// }
//
// public String getLookupURI() {
// return lookupURI;
// }
//
// public BigDecimal getDebt() {
// return debt;
// }
//
// public void setDebt(BigDecimal debt) {
// this.debt = debt;
// }
//
// @Override
// public int compareTo(Friend another) {
// return another.getDebt().compareTo(debt);
// }
//
// @Override
// public boolean equals(Object o) {
// return (o.getClass() == Friend.class && ((Friend) o).getRepayID().equals(repayID));
// }
// }
// Path: repay/src/main/java/com/repay/android/database/DatabaseHandler.java
import java.math.BigDecimal;
import java.security.SecureRandom;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import com.repay.android.model.Debt;
import com.repay.android.model.Friend;
import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.CursorIndexOutOfBoundsException;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.net.Uri;
import android.util.Log;
super(context, DB_NAME, null, DB_VERSION);
}
/**
* Generate an ID for entering into the database as a primary key
* @return String representation of the Repay ID
*/
public static String generateRepayID() {
long rand = new SecureRandom().nextLong();
return String.valueOf(rand);
}
@Override
public void onCreate(SQLiteDatabase db) {
// Create Friends table
db.execSQL(String.format("CREATE TABLE %s (%s TEXT PRIMARY KEY, %s TEXT, %s TEXT, %s TEXT)",
Names.F_TABLENAME, Names.F_REPAYID, Names.F_LOOKUPURI, Names.F_NAME, Names.F_DEBT));
// Create Debts table
db.execSQL(String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY AUTOINCREMENT, %s TEXT NOT NULL, "
+ "%s TEXT, %s TEXT, %s TEXT, FOREIGN KEY(%s) REFERENCES %s(%s))", Names.D_TABLENAME,
Names.D_DEBTID, Names.D_REPAYID, Names.D_DATE, Names.D_AMOUNT,
Names.D_DESCRIPTION, Names.D_REPAYID, Names.F_TABLENAME, Names.F_REPAYID));
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (oldVersion==1 && newVersion==2){
// Change to include a debtID
try{ | ArrayList<Debt> debts = new ArrayList<Debt>(); |
matt-allen/repay-android | repay/src/main/java/com/repay/android/database/DatabaseHandler.java | // Path: repay/src/main/java/com/repay/android/model/Debt.java
// public class Debt implements Comparable<Debt>, Serializable {
//
// private Date date;
// private BigDecimal amount;
// private String repayID, description;
// private int debtID;
//
// public Debt(int debtID, String repayID, Date date, BigDecimal amount, String description) {
// super();
// this.date = date;
// this.debtID = debtID;
// this.amount = amount;
// this.repayID = repayID;
// this.description = description;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public BigDecimal getAmount() {
// return amount;
// }
//
// public void setAmount(BigDecimal amount) {
// this.amount = amount;
// }
//
// public String getRepayID() {
// return repayID;
// }
//
// public void setRepayID(String repayID) {
// this.repayID = repayID;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public int getDebtID(){
// return debtID;
// }
//
// @Override
// public int compareTo(Debt another) {
// return another.getDate().compareTo(date);
// }
// }
//
// Path: repay/src/main/java/com/repay/android/model/Friend.java
// public class Friend implements Comparable<Friend>, Serializable {
//
// public static final String REPAYID = "repayID";
// public static final String LOOKUPURI = "lookupUri";
// public static final String NAME = "name";
// public static final String AMOUNT = "amount";
//
// private String name, repayID;
// private BigDecimal debt;
// private String lookupURI;
//
// public Friend(String repayID, String lookupURI, String name, BigDecimal debt) {
// super();
// this.lookupURI = lookupURI;
// this.name = name;
// this.repayID = repayID;
// this.debt = debt;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getRepayID() {
// return repayID;
// }
//
// public String getLookupURI() {
// return lookupURI;
// }
//
// public BigDecimal getDebt() {
// return debt;
// }
//
// public void setDebt(BigDecimal debt) {
// this.debt = debt;
// }
//
// @Override
// public int compareTo(Friend another) {
// return another.getDebt().compareTo(debt);
// }
//
// @Override
// public boolean equals(Object o) {
// return (o.getClass() == Friend.class && ((Friend) o).getRepayID().equals(repayID));
// }
// }
| import java.math.BigDecimal;
import java.security.SecureRandom;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import com.repay.android.model.Debt;
import com.repay.android.model.Friend;
import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.CursorIndexOutOfBoundsException;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.net.Uri;
import android.util.Log; | } while (c.moveToNext());
// Drop old table and create new one
db.execSQL(String.format("ALTER TABLE %s RENAME TO oldDebts", Names.D_TABLENAME));
db.execSQL(String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY AUTOINCREMENT, %s TEXT NOT NULL, "
+ "%s TEXT, %s TEXT, %s TEXT, FOREIGN KEY(%s) REFERENCES %s(%s))", Names.D_TABLENAME,
Names.D_DEBTID, Names.D_REPAYID, Names.D_DATE, Names.D_AMOUNT,
Names.D_DESCRIPTION, Names.D_REPAYID, Names.F_TABLENAME, Names.F_REPAYID));
// Add data back in new format
ContentValues values;
for(int i=0;i<=debts.size()-1;i++){
values = new ContentValues();
values.put(Names.D_REPAYID, debts.get(i).getRepayID());
values.put(Names.D_AMOUNT, debts.get(i).getAmount().toString());
values.put(Names.D_DATE, debts.get(i).getDate().toString());
values.put(Names.D_DESCRIPTION, debts.get(i).getDescription());
db.insert(Names.D_TABLENAME, null, values);
}
} catch (Exception e){
Log.e(TAG, e.getMessage());
e.printStackTrace();
}
}
}
/**
* @return All friends stored in the database as ArrayList
* @throws android.database.SQLException
*/ | // Path: repay/src/main/java/com/repay/android/model/Debt.java
// public class Debt implements Comparable<Debt>, Serializable {
//
// private Date date;
// private BigDecimal amount;
// private String repayID, description;
// private int debtID;
//
// public Debt(int debtID, String repayID, Date date, BigDecimal amount, String description) {
// super();
// this.date = date;
// this.debtID = debtID;
// this.amount = amount;
// this.repayID = repayID;
// this.description = description;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public BigDecimal getAmount() {
// return amount;
// }
//
// public void setAmount(BigDecimal amount) {
// this.amount = amount;
// }
//
// public String getRepayID() {
// return repayID;
// }
//
// public void setRepayID(String repayID) {
// this.repayID = repayID;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public int getDebtID(){
// return debtID;
// }
//
// @Override
// public int compareTo(Debt another) {
// return another.getDate().compareTo(date);
// }
// }
//
// Path: repay/src/main/java/com/repay/android/model/Friend.java
// public class Friend implements Comparable<Friend>, Serializable {
//
// public static final String REPAYID = "repayID";
// public static final String LOOKUPURI = "lookupUri";
// public static final String NAME = "name";
// public static final String AMOUNT = "amount";
//
// private String name, repayID;
// private BigDecimal debt;
// private String lookupURI;
//
// public Friend(String repayID, String lookupURI, String name, BigDecimal debt) {
// super();
// this.lookupURI = lookupURI;
// this.name = name;
// this.repayID = repayID;
// this.debt = debt;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getRepayID() {
// return repayID;
// }
//
// public String getLookupURI() {
// return lookupURI;
// }
//
// public BigDecimal getDebt() {
// return debt;
// }
//
// public void setDebt(BigDecimal debt) {
// this.debt = debt;
// }
//
// @Override
// public int compareTo(Friend another) {
// return another.getDebt().compareTo(debt);
// }
//
// @Override
// public boolean equals(Object o) {
// return (o.getClass() == Friend.class && ((Friend) o).getRepayID().equals(repayID));
// }
// }
// Path: repay/src/main/java/com/repay/android/database/DatabaseHandler.java
import java.math.BigDecimal;
import java.security.SecureRandom;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import com.repay.android.model.Debt;
import com.repay.android.model.Friend;
import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.CursorIndexOutOfBoundsException;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.net.Uri;
import android.util.Log;
} while (c.moveToNext());
// Drop old table and create new one
db.execSQL(String.format("ALTER TABLE %s RENAME TO oldDebts", Names.D_TABLENAME));
db.execSQL(String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY AUTOINCREMENT, %s TEXT NOT NULL, "
+ "%s TEXT, %s TEXT, %s TEXT, FOREIGN KEY(%s) REFERENCES %s(%s))", Names.D_TABLENAME,
Names.D_DEBTID, Names.D_REPAYID, Names.D_DATE, Names.D_AMOUNT,
Names.D_DESCRIPTION, Names.D_REPAYID, Names.F_TABLENAME, Names.F_REPAYID));
// Add data back in new format
ContentValues values;
for(int i=0;i<=debts.size()-1;i++){
values = new ContentValues();
values.put(Names.D_REPAYID, debts.get(i).getRepayID());
values.put(Names.D_AMOUNT, debts.get(i).getAmount().toString());
values.put(Names.D_DATE, debts.get(i).getDate().toString());
values.put(Names.D_DESCRIPTION, debts.get(i).getDescription());
db.insert(Names.D_TABLENAME, null, values);
}
} catch (Exception e){
Log.e(TAG, e.getMessage());
e.printStackTrace();
}
}
}
/**
* @return All friends stored in the database as ArrayList
* @throws android.database.SQLException
*/ | public ArrayList<Friend> getAllFriends() throws SQLException, NullPointerException, CursorIndexOutOfBoundsException{ |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/controller/KafkaExceptionHandler.java | // Path: src/main/java/com/homeadvisor/kafdrop/service/NotInitializedException.java
// public class NotInitializedException extends RuntimeException
// {
// public NotInitializedException()
// {
// }
// }
| import com.homeadvisor.kafdrop.service.NotInitializedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; | /*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.controller;
@ControllerAdvice
public class KafkaExceptionHandler
{ | // Path: src/main/java/com/homeadvisor/kafdrop/service/NotInitializedException.java
// public class NotInitializedException extends RuntimeException
// {
// public NotInitializedException()
// {
// }
// }
// Path: src/main/java/com/homeadvisor/kafdrop/controller/KafkaExceptionHandler.java
import com.homeadvisor.kafdrop.service.NotInitializedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
/*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.controller;
@ControllerAdvice
public class KafkaExceptionHandler
{ | @ExceptionHandler(NotInitializedException.class) |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/service/CuratorKafkaMonitorProperties.java | // Path: src/main/java/com/homeadvisor/kafdrop/config/ZookeeperProperties.java
// public class ZookeeperProperties
// {
// public static final Pattern CONNECT_SEPARATOR = Pattern.compile("\\s*,\\s*");
// @NotBlank
// private String connect;
//
// private int sessionTimeoutMillis = (int) TimeUnit.SECONDS.toMillis(5);
// private int connectTimeoutMillis = (int) TimeUnit.SECONDS.toMillis(15);
//
// private int retryMillis = (int) TimeUnit.SECONDS.toMillis(5);
// private int maxRetries = Integer.MAX_VALUE;
//
//
// public String getConnect()
// {
// return connect;
// }
//
// public void setConnect(String connect)
// {
// this.connect = connect;
// }
//
// public List<String> getConnectList()
// {
// return CONNECT_SEPARATOR.splitAsStream(this.connect)
// .map(String::trim)
// .filter(s -> s.length() > 0)
// .collect(Collectors.toList());
// }
//
// public int getRetryMillis()
// {
// return retryMillis;
// }
//
// public void setRetryMillis(int retryMillis)
// {
// this.retryMillis = retryMillis;
// }
//
// public int getMaxRetries()
// {
// return maxRetries;
// }
//
// public void setMaxRetries(int maxRetries)
// {
// this.maxRetries = maxRetries;
// }
//
// public int getSessionTimeoutMillis()
// {
// return sessionTimeoutMillis;
// }
//
// public void setSessionTimeoutMillis(int sessionTimeoutMillis)
// {
// this.sessionTimeoutMillis = sessionTimeoutMillis;
// }
//
// public int getConnectTimeoutMillis()
// {
// return connectTimeoutMillis;
// }
//
// public void setConnectTimeoutMillis(int connectTimeoutMillis)
// {
// this.connectTimeoutMillis = connectTimeoutMillis;
// }
// }
| import com.homeadvisor.kafdrop.config.ZookeeperProperties;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import javax.validation.constraints.Min; | /*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.service;
@Component
@ConfigurationProperties(prefix = "kafdrop.monitor")
public class CuratorKafkaMonitorProperties
{
private String clientId = "Kafdrop";
@Min(1)
private int threadPoolSize = 10;
private RetryProperties retry = new RetryProperties();
@NotBlank
private String kafkaVersion = "0.8.2.2";
| // Path: src/main/java/com/homeadvisor/kafdrop/config/ZookeeperProperties.java
// public class ZookeeperProperties
// {
// public static final Pattern CONNECT_SEPARATOR = Pattern.compile("\\s*,\\s*");
// @NotBlank
// private String connect;
//
// private int sessionTimeoutMillis = (int) TimeUnit.SECONDS.toMillis(5);
// private int connectTimeoutMillis = (int) TimeUnit.SECONDS.toMillis(15);
//
// private int retryMillis = (int) TimeUnit.SECONDS.toMillis(5);
// private int maxRetries = Integer.MAX_VALUE;
//
//
// public String getConnect()
// {
// return connect;
// }
//
// public void setConnect(String connect)
// {
// this.connect = connect;
// }
//
// public List<String> getConnectList()
// {
// return CONNECT_SEPARATOR.splitAsStream(this.connect)
// .map(String::trim)
// .filter(s -> s.length() > 0)
// .collect(Collectors.toList());
// }
//
// public int getRetryMillis()
// {
// return retryMillis;
// }
//
// public void setRetryMillis(int retryMillis)
// {
// this.retryMillis = retryMillis;
// }
//
// public int getMaxRetries()
// {
// return maxRetries;
// }
//
// public void setMaxRetries(int maxRetries)
// {
// this.maxRetries = maxRetries;
// }
//
// public int getSessionTimeoutMillis()
// {
// return sessionTimeoutMillis;
// }
//
// public void setSessionTimeoutMillis(int sessionTimeoutMillis)
// {
// this.sessionTimeoutMillis = sessionTimeoutMillis;
// }
//
// public int getConnectTimeoutMillis()
// {
// return connectTimeoutMillis;
// }
//
// public void setConnectTimeoutMillis(int connectTimeoutMillis)
// {
// this.connectTimeoutMillis = connectTimeoutMillis;
// }
// }
// Path: src/main/java/com/homeadvisor/kafdrop/service/CuratorKafkaMonitorProperties.java
import com.homeadvisor.kafdrop.config.ZookeeperProperties;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import javax.validation.constraints.Min;
/*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.service;
@Component
@ConfigurationProperties(prefix = "kafdrop.monitor")
public class CuratorKafkaMonitorProperties
{
private String clientId = "Kafdrop";
@Min(1)
private int threadPoolSize = 10;
private RetryProperties retry = new RetryProperties();
@NotBlank
private String kafkaVersion = "0.8.2.2";
| private ZookeeperProperties zookeeper = new ZookeeperProperties(); |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/controller/ConsumerController.java | // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerVO.java
// public class ConsumerVO implements Comparable<ConsumerVO>
// {
// private String groupId;
// private Map<String, ConsumerTopicVO> topics = new TreeMap<>();
// private List<ConsumerRegistrationVO> activeInstances = new ArrayList<>();
// private boolean legacy = false;
//
// public ConsumerVO(String groupId)
// {
// Validate.notEmpty("groupId is required");
// this.groupId = groupId;
// }
//
// public boolean isLegacy()
// {
// return legacy;
// }
//
// public void setLegacy(boolean legacy)
// {
// this.legacy = legacy;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public void setGroupId(String groupId)
// {
// this.groupId = groupId;
// }
//
// public void addActiveInstance(ConsumerRegistrationVO id)
// {
// activeInstances.add(id);
// }
//
// public List<ConsumerRegistrationVO> getActiveInstances()
// {
// return activeInstances;
// }
//
// public List<ConsumerRegistrationVO> getActiveInstancesForTopic(String topic)
// {
// return activeInstances.stream()
// .filter(registration -> registration.subscribesToTopic(topic))
// .collect(Collectors.toList());
// }
//
// public void addTopic(ConsumerTopicVO topic)
// {
// topics.put(topic.getTopic(), topic);
// }
//
// public ConsumerTopicVO getTopic(String topic)
// {
// return topics.get(topic);
// }
//
// public ConsumerTopicVO getOrCreateTopic(String topic)
// {
// ConsumerTopicVO consumerTopic = getTopic(topic);
// if (consumerTopic == null)
// {
// consumerTopic = new ConsumerTopicVO(topic, groupId);
// addTopic(consumerTopic);
// }
// return consumerTopic;
// }
//
// public Collection<ConsumerTopicVO> getTopics()
// {
// return topics.values();
// }
//
// public int getActiveTopicCount()
// {
// return topics.values().stream()
// .map(t -> t.getAssignedPartitionCount() > 0 ? 1 : 0)
// .reduce(0, Integer::sum);
// }
//
// @Override
// public int compareTo(ConsumerVO that)
// {
// return this.groupId.compareTo(that.groupId);
// }
//
// @Override
// public boolean equals(Object o)
// {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// ConsumerVO vo = (ConsumerVO) o;
//
// if (!groupId.equals(vo.groupId)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode()
// {
// return groupId.hashCode();
// }
//
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerNotFoundException.java
// @ResponseStatus(HttpStatus.NOT_FOUND)
// public class ConsumerNotFoundException extends RuntimeException
// {
// public ConsumerNotFoundException(String message)
// {
// super(message);
// }
//
// public ConsumerNotFoundException()
// {
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/KafkaMonitor.java
// public interface KafkaMonitor
// {
// List<BrokerVO> getBrokers();
//
// Optional<BrokerVO> getBroker(int id);
//
// default Optional<BrokerConfigurationVO> getBrokerConfiguration(int id)
// {
// return Optional.empty();
// }
//
// List<TopicVO> getTopics();
//
// Optional<TopicVO> getTopic(String topic);
//
// ClusterSummaryVO getClusterSummary(Collection<TopicVO> topics);
//
// List<ConsumerVO> getConsumers(TopicVO topic);
//
// Optional<ConsumerVO> getConsumer(String groupId);
//
// Optional<ConsumerVO> getConsumerByTopic(String groupId, TopicVO topic);
// }
| import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Optional;
import com.homeadvisor.kafdrop.model.ConsumerVO;
import com.homeadvisor.kafdrop.service.ConsumerNotFoundException;
import com.homeadvisor.kafdrop.service.KafkaMonitor;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable; | /*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.controller;
@Controller
@RequestMapping("/consumer")
public class ConsumerController
{ | // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerVO.java
// public class ConsumerVO implements Comparable<ConsumerVO>
// {
// private String groupId;
// private Map<String, ConsumerTopicVO> topics = new TreeMap<>();
// private List<ConsumerRegistrationVO> activeInstances = new ArrayList<>();
// private boolean legacy = false;
//
// public ConsumerVO(String groupId)
// {
// Validate.notEmpty("groupId is required");
// this.groupId = groupId;
// }
//
// public boolean isLegacy()
// {
// return legacy;
// }
//
// public void setLegacy(boolean legacy)
// {
// this.legacy = legacy;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public void setGroupId(String groupId)
// {
// this.groupId = groupId;
// }
//
// public void addActiveInstance(ConsumerRegistrationVO id)
// {
// activeInstances.add(id);
// }
//
// public List<ConsumerRegistrationVO> getActiveInstances()
// {
// return activeInstances;
// }
//
// public List<ConsumerRegistrationVO> getActiveInstancesForTopic(String topic)
// {
// return activeInstances.stream()
// .filter(registration -> registration.subscribesToTopic(topic))
// .collect(Collectors.toList());
// }
//
// public void addTopic(ConsumerTopicVO topic)
// {
// topics.put(topic.getTopic(), topic);
// }
//
// public ConsumerTopicVO getTopic(String topic)
// {
// return topics.get(topic);
// }
//
// public ConsumerTopicVO getOrCreateTopic(String topic)
// {
// ConsumerTopicVO consumerTopic = getTopic(topic);
// if (consumerTopic == null)
// {
// consumerTopic = new ConsumerTopicVO(topic, groupId);
// addTopic(consumerTopic);
// }
// return consumerTopic;
// }
//
// public Collection<ConsumerTopicVO> getTopics()
// {
// return topics.values();
// }
//
// public int getActiveTopicCount()
// {
// return topics.values().stream()
// .map(t -> t.getAssignedPartitionCount() > 0 ? 1 : 0)
// .reduce(0, Integer::sum);
// }
//
// @Override
// public int compareTo(ConsumerVO that)
// {
// return this.groupId.compareTo(that.groupId);
// }
//
// @Override
// public boolean equals(Object o)
// {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// ConsumerVO vo = (ConsumerVO) o;
//
// if (!groupId.equals(vo.groupId)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode()
// {
// return groupId.hashCode();
// }
//
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerNotFoundException.java
// @ResponseStatus(HttpStatus.NOT_FOUND)
// public class ConsumerNotFoundException extends RuntimeException
// {
// public ConsumerNotFoundException(String message)
// {
// super(message);
// }
//
// public ConsumerNotFoundException()
// {
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/KafkaMonitor.java
// public interface KafkaMonitor
// {
// List<BrokerVO> getBrokers();
//
// Optional<BrokerVO> getBroker(int id);
//
// default Optional<BrokerConfigurationVO> getBrokerConfiguration(int id)
// {
// return Optional.empty();
// }
//
// List<TopicVO> getTopics();
//
// Optional<TopicVO> getTopic(String topic);
//
// ClusterSummaryVO getClusterSummary(Collection<TopicVO> topics);
//
// List<ConsumerVO> getConsumers(TopicVO topic);
//
// Optional<ConsumerVO> getConsumer(String groupId);
//
// Optional<ConsumerVO> getConsumerByTopic(String groupId, TopicVO topic);
// }
// Path: src/main/java/com/homeadvisor/kafdrop/controller/ConsumerController.java
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Optional;
import com.homeadvisor.kafdrop.model.ConsumerVO;
import com.homeadvisor.kafdrop.service.ConsumerNotFoundException;
import com.homeadvisor.kafdrop.service.KafkaMonitor;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
/*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.controller;
@Controller
@RequestMapping("/consumer")
public class ConsumerController
{ | private final KafkaMonitor kafkaMonitor; |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/controller/ConsumerController.java | // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerVO.java
// public class ConsumerVO implements Comparable<ConsumerVO>
// {
// private String groupId;
// private Map<String, ConsumerTopicVO> topics = new TreeMap<>();
// private List<ConsumerRegistrationVO> activeInstances = new ArrayList<>();
// private boolean legacy = false;
//
// public ConsumerVO(String groupId)
// {
// Validate.notEmpty("groupId is required");
// this.groupId = groupId;
// }
//
// public boolean isLegacy()
// {
// return legacy;
// }
//
// public void setLegacy(boolean legacy)
// {
// this.legacy = legacy;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public void setGroupId(String groupId)
// {
// this.groupId = groupId;
// }
//
// public void addActiveInstance(ConsumerRegistrationVO id)
// {
// activeInstances.add(id);
// }
//
// public List<ConsumerRegistrationVO> getActiveInstances()
// {
// return activeInstances;
// }
//
// public List<ConsumerRegistrationVO> getActiveInstancesForTopic(String topic)
// {
// return activeInstances.stream()
// .filter(registration -> registration.subscribesToTopic(topic))
// .collect(Collectors.toList());
// }
//
// public void addTopic(ConsumerTopicVO topic)
// {
// topics.put(topic.getTopic(), topic);
// }
//
// public ConsumerTopicVO getTopic(String topic)
// {
// return topics.get(topic);
// }
//
// public ConsumerTopicVO getOrCreateTopic(String topic)
// {
// ConsumerTopicVO consumerTopic = getTopic(topic);
// if (consumerTopic == null)
// {
// consumerTopic = new ConsumerTopicVO(topic, groupId);
// addTopic(consumerTopic);
// }
// return consumerTopic;
// }
//
// public Collection<ConsumerTopicVO> getTopics()
// {
// return topics.values();
// }
//
// public int getActiveTopicCount()
// {
// return topics.values().stream()
// .map(t -> t.getAssignedPartitionCount() > 0 ? 1 : 0)
// .reduce(0, Integer::sum);
// }
//
// @Override
// public int compareTo(ConsumerVO that)
// {
// return this.groupId.compareTo(that.groupId);
// }
//
// @Override
// public boolean equals(Object o)
// {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// ConsumerVO vo = (ConsumerVO) o;
//
// if (!groupId.equals(vo.groupId)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode()
// {
// return groupId.hashCode();
// }
//
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerNotFoundException.java
// @ResponseStatus(HttpStatus.NOT_FOUND)
// public class ConsumerNotFoundException extends RuntimeException
// {
// public ConsumerNotFoundException(String message)
// {
// super(message);
// }
//
// public ConsumerNotFoundException()
// {
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/KafkaMonitor.java
// public interface KafkaMonitor
// {
// List<BrokerVO> getBrokers();
//
// Optional<BrokerVO> getBroker(int id);
//
// default Optional<BrokerConfigurationVO> getBrokerConfiguration(int id)
// {
// return Optional.empty();
// }
//
// List<TopicVO> getTopics();
//
// Optional<TopicVO> getTopic(String topic);
//
// ClusterSummaryVO getClusterSummary(Collection<TopicVO> topics);
//
// List<ConsumerVO> getConsumers(TopicVO topic);
//
// Optional<ConsumerVO> getConsumer(String groupId);
//
// Optional<ConsumerVO> getConsumerByTopic(String groupId, TopicVO topic);
// }
| import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Optional;
import com.homeadvisor.kafdrop.model.ConsumerVO;
import com.homeadvisor.kafdrop.service.ConsumerNotFoundException;
import com.homeadvisor.kafdrop.service.KafkaMonitor;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable; | /*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.controller;
@Controller
@RequestMapping("/consumer")
public class ConsumerController
{
private final KafkaMonitor kafkaMonitor;
public ConsumerController(KafkaMonitor kafkaMonitor)
{
this.kafkaMonitor = kafkaMonitor;
}
@RequestMapping("{groupId:.+}")
public String consumerDetail(@PathVariable("groupId") String groupId, Model model)
{
model.addAttribute("consumer", kafkaMonitor.getConsumer(groupId) | // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerVO.java
// public class ConsumerVO implements Comparable<ConsumerVO>
// {
// private String groupId;
// private Map<String, ConsumerTopicVO> topics = new TreeMap<>();
// private List<ConsumerRegistrationVO> activeInstances = new ArrayList<>();
// private boolean legacy = false;
//
// public ConsumerVO(String groupId)
// {
// Validate.notEmpty("groupId is required");
// this.groupId = groupId;
// }
//
// public boolean isLegacy()
// {
// return legacy;
// }
//
// public void setLegacy(boolean legacy)
// {
// this.legacy = legacy;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public void setGroupId(String groupId)
// {
// this.groupId = groupId;
// }
//
// public void addActiveInstance(ConsumerRegistrationVO id)
// {
// activeInstances.add(id);
// }
//
// public List<ConsumerRegistrationVO> getActiveInstances()
// {
// return activeInstances;
// }
//
// public List<ConsumerRegistrationVO> getActiveInstancesForTopic(String topic)
// {
// return activeInstances.stream()
// .filter(registration -> registration.subscribesToTopic(topic))
// .collect(Collectors.toList());
// }
//
// public void addTopic(ConsumerTopicVO topic)
// {
// topics.put(topic.getTopic(), topic);
// }
//
// public ConsumerTopicVO getTopic(String topic)
// {
// return topics.get(topic);
// }
//
// public ConsumerTopicVO getOrCreateTopic(String topic)
// {
// ConsumerTopicVO consumerTopic = getTopic(topic);
// if (consumerTopic == null)
// {
// consumerTopic = new ConsumerTopicVO(topic, groupId);
// addTopic(consumerTopic);
// }
// return consumerTopic;
// }
//
// public Collection<ConsumerTopicVO> getTopics()
// {
// return topics.values();
// }
//
// public int getActiveTopicCount()
// {
// return topics.values().stream()
// .map(t -> t.getAssignedPartitionCount() > 0 ? 1 : 0)
// .reduce(0, Integer::sum);
// }
//
// @Override
// public int compareTo(ConsumerVO that)
// {
// return this.groupId.compareTo(that.groupId);
// }
//
// @Override
// public boolean equals(Object o)
// {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// ConsumerVO vo = (ConsumerVO) o;
//
// if (!groupId.equals(vo.groupId)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode()
// {
// return groupId.hashCode();
// }
//
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerNotFoundException.java
// @ResponseStatus(HttpStatus.NOT_FOUND)
// public class ConsumerNotFoundException extends RuntimeException
// {
// public ConsumerNotFoundException(String message)
// {
// super(message);
// }
//
// public ConsumerNotFoundException()
// {
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/KafkaMonitor.java
// public interface KafkaMonitor
// {
// List<BrokerVO> getBrokers();
//
// Optional<BrokerVO> getBroker(int id);
//
// default Optional<BrokerConfigurationVO> getBrokerConfiguration(int id)
// {
// return Optional.empty();
// }
//
// List<TopicVO> getTopics();
//
// Optional<TopicVO> getTopic(String topic);
//
// ClusterSummaryVO getClusterSummary(Collection<TopicVO> topics);
//
// List<ConsumerVO> getConsumers(TopicVO topic);
//
// Optional<ConsumerVO> getConsumer(String groupId);
//
// Optional<ConsumerVO> getConsumerByTopic(String groupId, TopicVO topic);
// }
// Path: src/main/java/com/homeadvisor/kafdrop/controller/ConsumerController.java
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Optional;
import com.homeadvisor.kafdrop.model.ConsumerVO;
import com.homeadvisor.kafdrop.service.ConsumerNotFoundException;
import com.homeadvisor.kafdrop.service.KafkaMonitor;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
/*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.controller;
@Controller
@RequestMapping("/consumer")
public class ConsumerController
{
private final KafkaMonitor kafkaMonitor;
public ConsumerController(KafkaMonitor kafkaMonitor)
{
this.kafkaMonitor = kafkaMonitor;
}
@RequestMapping("{groupId:.+}")
public String consumerDetail(@PathVariable("groupId") String groupId, Model model)
{
model.addAttribute("consumer", kafkaMonitor.getConsumer(groupId) | .orElseThrow(() -> new ConsumerNotFoundException(groupId))); |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/controller/ConsumerController.java | // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerVO.java
// public class ConsumerVO implements Comparable<ConsumerVO>
// {
// private String groupId;
// private Map<String, ConsumerTopicVO> topics = new TreeMap<>();
// private List<ConsumerRegistrationVO> activeInstances = new ArrayList<>();
// private boolean legacy = false;
//
// public ConsumerVO(String groupId)
// {
// Validate.notEmpty("groupId is required");
// this.groupId = groupId;
// }
//
// public boolean isLegacy()
// {
// return legacy;
// }
//
// public void setLegacy(boolean legacy)
// {
// this.legacy = legacy;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public void setGroupId(String groupId)
// {
// this.groupId = groupId;
// }
//
// public void addActiveInstance(ConsumerRegistrationVO id)
// {
// activeInstances.add(id);
// }
//
// public List<ConsumerRegistrationVO> getActiveInstances()
// {
// return activeInstances;
// }
//
// public List<ConsumerRegistrationVO> getActiveInstancesForTopic(String topic)
// {
// return activeInstances.stream()
// .filter(registration -> registration.subscribesToTopic(topic))
// .collect(Collectors.toList());
// }
//
// public void addTopic(ConsumerTopicVO topic)
// {
// topics.put(topic.getTopic(), topic);
// }
//
// public ConsumerTopicVO getTopic(String topic)
// {
// return topics.get(topic);
// }
//
// public ConsumerTopicVO getOrCreateTopic(String topic)
// {
// ConsumerTopicVO consumerTopic = getTopic(topic);
// if (consumerTopic == null)
// {
// consumerTopic = new ConsumerTopicVO(topic, groupId);
// addTopic(consumerTopic);
// }
// return consumerTopic;
// }
//
// public Collection<ConsumerTopicVO> getTopics()
// {
// return topics.values();
// }
//
// public int getActiveTopicCount()
// {
// return topics.values().stream()
// .map(t -> t.getAssignedPartitionCount() > 0 ? 1 : 0)
// .reduce(0, Integer::sum);
// }
//
// @Override
// public int compareTo(ConsumerVO that)
// {
// return this.groupId.compareTo(that.groupId);
// }
//
// @Override
// public boolean equals(Object o)
// {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// ConsumerVO vo = (ConsumerVO) o;
//
// if (!groupId.equals(vo.groupId)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode()
// {
// return groupId.hashCode();
// }
//
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerNotFoundException.java
// @ResponseStatus(HttpStatus.NOT_FOUND)
// public class ConsumerNotFoundException extends RuntimeException
// {
// public ConsumerNotFoundException(String message)
// {
// super(message);
// }
//
// public ConsumerNotFoundException()
// {
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/KafkaMonitor.java
// public interface KafkaMonitor
// {
// List<BrokerVO> getBrokers();
//
// Optional<BrokerVO> getBroker(int id);
//
// default Optional<BrokerConfigurationVO> getBrokerConfiguration(int id)
// {
// return Optional.empty();
// }
//
// List<TopicVO> getTopics();
//
// Optional<TopicVO> getTopic(String topic);
//
// ClusterSummaryVO getClusterSummary(Collection<TopicVO> topics);
//
// List<ConsumerVO> getConsumers(TopicVO topic);
//
// Optional<ConsumerVO> getConsumer(String groupId);
//
// Optional<ConsumerVO> getConsumerByTopic(String groupId, TopicVO topic);
// }
| import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Optional;
import com.homeadvisor.kafdrop.model.ConsumerVO;
import com.homeadvisor.kafdrop.service.ConsumerNotFoundException;
import com.homeadvisor.kafdrop.service.KafkaMonitor;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable; | /*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.controller;
@Controller
@RequestMapping("/consumer")
public class ConsumerController
{
private final KafkaMonitor kafkaMonitor;
public ConsumerController(KafkaMonitor kafkaMonitor)
{
this.kafkaMonitor = kafkaMonitor;
}
@RequestMapping("{groupId:.+}")
public String consumerDetail(@PathVariable("groupId") String groupId, Model model)
{
model.addAttribute("consumer", kafkaMonitor.getConsumer(groupId)
.orElseThrow(() -> new ConsumerNotFoundException(groupId)));
return "consumer-detail";
}
@RequestMapping("{groupId:.+}/{topic:.+}")
public String consumerDetail(@PathVariable("groupId") String groupId,
@PathVariable("topic") String topic,
Model model)
{
| // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerVO.java
// public class ConsumerVO implements Comparable<ConsumerVO>
// {
// private String groupId;
// private Map<String, ConsumerTopicVO> topics = new TreeMap<>();
// private List<ConsumerRegistrationVO> activeInstances = new ArrayList<>();
// private boolean legacy = false;
//
// public ConsumerVO(String groupId)
// {
// Validate.notEmpty("groupId is required");
// this.groupId = groupId;
// }
//
// public boolean isLegacy()
// {
// return legacy;
// }
//
// public void setLegacy(boolean legacy)
// {
// this.legacy = legacy;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public void setGroupId(String groupId)
// {
// this.groupId = groupId;
// }
//
// public void addActiveInstance(ConsumerRegistrationVO id)
// {
// activeInstances.add(id);
// }
//
// public List<ConsumerRegistrationVO> getActiveInstances()
// {
// return activeInstances;
// }
//
// public List<ConsumerRegistrationVO> getActiveInstancesForTopic(String topic)
// {
// return activeInstances.stream()
// .filter(registration -> registration.subscribesToTopic(topic))
// .collect(Collectors.toList());
// }
//
// public void addTopic(ConsumerTopicVO topic)
// {
// topics.put(topic.getTopic(), topic);
// }
//
// public ConsumerTopicVO getTopic(String topic)
// {
// return topics.get(topic);
// }
//
// public ConsumerTopicVO getOrCreateTopic(String topic)
// {
// ConsumerTopicVO consumerTopic = getTopic(topic);
// if (consumerTopic == null)
// {
// consumerTopic = new ConsumerTopicVO(topic, groupId);
// addTopic(consumerTopic);
// }
// return consumerTopic;
// }
//
// public Collection<ConsumerTopicVO> getTopics()
// {
// return topics.values();
// }
//
// public int getActiveTopicCount()
// {
// return topics.values().stream()
// .map(t -> t.getAssignedPartitionCount() > 0 ? 1 : 0)
// .reduce(0, Integer::sum);
// }
//
// @Override
// public int compareTo(ConsumerVO that)
// {
// return this.groupId.compareTo(that.groupId);
// }
//
// @Override
// public boolean equals(Object o)
// {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// ConsumerVO vo = (ConsumerVO) o;
//
// if (!groupId.equals(vo.groupId)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode()
// {
// return groupId.hashCode();
// }
//
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerNotFoundException.java
// @ResponseStatus(HttpStatus.NOT_FOUND)
// public class ConsumerNotFoundException extends RuntimeException
// {
// public ConsumerNotFoundException(String message)
// {
// super(message);
// }
//
// public ConsumerNotFoundException()
// {
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/KafkaMonitor.java
// public interface KafkaMonitor
// {
// List<BrokerVO> getBrokers();
//
// Optional<BrokerVO> getBroker(int id);
//
// default Optional<BrokerConfigurationVO> getBrokerConfiguration(int id)
// {
// return Optional.empty();
// }
//
// List<TopicVO> getTopics();
//
// Optional<TopicVO> getTopic(String topic);
//
// ClusterSummaryVO getClusterSummary(Collection<TopicVO> topics);
//
// List<ConsumerVO> getConsumers(TopicVO topic);
//
// Optional<ConsumerVO> getConsumer(String groupId);
//
// Optional<ConsumerVO> getConsumerByTopic(String groupId, TopicVO topic);
// }
// Path: src/main/java/com/homeadvisor/kafdrop/controller/ConsumerController.java
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Optional;
import com.homeadvisor.kafdrop.model.ConsumerVO;
import com.homeadvisor.kafdrop.service.ConsumerNotFoundException;
import com.homeadvisor.kafdrop.service.KafkaMonitor;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
/*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.controller;
@Controller
@RequestMapping("/consumer")
public class ConsumerController
{
private final KafkaMonitor kafkaMonitor;
public ConsumerController(KafkaMonitor kafkaMonitor)
{
this.kafkaMonitor = kafkaMonitor;
}
@RequestMapping("{groupId:.+}")
public String consumerDetail(@PathVariable("groupId") String groupId, Model model)
{
model.addAttribute("consumer", kafkaMonitor.getConsumer(groupId)
.orElseThrow(() -> new ConsumerNotFoundException(groupId)));
return "consumer-detail";
}
@RequestMapping("{groupId:.+}/{topic:.+}")
public String consumerDetail(@PathVariable("groupId") String groupId,
@PathVariable("topic") String topic,
Model model)
{
| ConsumerVO consumer = kafkaMonitor.getTopic(topic) |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/service/CuratorBrokerRegistry.java | // Path: src/main/java/com/homeadvisor/kafdrop/model/BrokerVO.java
// public class BrokerVO
// {
// private int id;
// private String host;
// private int port;
// private int jmxPort;
// private int version;
// private boolean controller;
// private Date timestamp;
// private String rack;
//
// public BrokerVO()
// {
// }
//
// public int getId()
// {
// return id;
// }
//
// public void setId(int id)
// {
// this.id = id;
// }
//
// public String getHost()
// {
// return host;
// }
//
// public void setHost(String host)
// {
// this.host = host;
// }
//
// public int getPort()
// {
// return port;
// }
//
// public void setPort(int port)
// {
// this.port = port;
// }
//
// public int getJmxPort()
// {
// return jmxPort;
// }
//
// @JsonProperty("jmx_port")
// public void setJmxPort(int jmxPort)
// {
// this.jmxPort = jmxPort;
// }
//
// public int getVersion()
// {
// return version;
// }
//
// public void setVersion(int version)
// {
// this.version = version;
// }
//
// public Date getTimestamp()
// {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp)
// {
// this.timestamp = timestamp;
// }
//
// public boolean isController()
// {
// return controller;
// }
//
// public void setController(boolean controller)
// {
// this.controller = controller;
// }
//
// public String getRack()
// {
// return rack;
// }
//
// public void setRack(String rack)
// {
// this.rack = rack;
// }
// }
| import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Throwables;
import com.homeadvisor.kafdrop.model.BrokerVO;
import kafka.utils.ZkUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.ChildData;
import org.apache.curator.framework.recipes.cache.PathChildrenCache;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; | /*
* Copyright 2019 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.service;
@Service
public class CuratorBrokerRegistry implements BrokerRegistry
{
private final Logger LOG = LoggerFactory.getLogger(getClass());
private PathChildrenCache brokerPathCache; | // Path: src/main/java/com/homeadvisor/kafdrop/model/BrokerVO.java
// public class BrokerVO
// {
// private int id;
// private String host;
// private int port;
// private int jmxPort;
// private int version;
// private boolean controller;
// private Date timestamp;
// private String rack;
//
// public BrokerVO()
// {
// }
//
// public int getId()
// {
// return id;
// }
//
// public void setId(int id)
// {
// this.id = id;
// }
//
// public String getHost()
// {
// return host;
// }
//
// public void setHost(String host)
// {
// this.host = host;
// }
//
// public int getPort()
// {
// return port;
// }
//
// public void setPort(int port)
// {
// this.port = port;
// }
//
// public int getJmxPort()
// {
// return jmxPort;
// }
//
// @JsonProperty("jmx_port")
// public void setJmxPort(int jmxPort)
// {
// this.jmxPort = jmxPort;
// }
//
// public int getVersion()
// {
// return version;
// }
//
// public void setVersion(int version)
// {
// this.version = version;
// }
//
// public Date getTimestamp()
// {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp)
// {
// this.timestamp = timestamp;
// }
//
// public boolean isController()
// {
// return controller;
// }
//
// public void setController(boolean controller)
// {
// this.controller = controller;
// }
//
// public String getRack()
// {
// return rack;
// }
//
// public void setRack(String rack)
// {
// this.rack = rack;
// }
// }
// Path: src/main/java/com/homeadvisor/kafdrop/service/CuratorBrokerRegistry.java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Throwables;
import com.homeadvisor.kafdrop.model.BrokerVO;
import kafka.utils.ZkUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.ChildData;
import org.apache.curator.framework.recipes.cache.PathChildrenCache;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/*
* Copyright 2019 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.service;
@Service
public class CuratorBrokerRegistry implements BrokerRegistry
{
private final Logger LOG = LoggerFactory.getLogger(getClass());
private PathChildrenCache brokerPathCache; | private ConcurrentMap<Integer, BrokerVO> brokerCache = new ConcurrentHashMap<>(); |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/model/dto/ConsumerPartitionDTO.java | // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerPartitionVO.java
// public class ConsumerPartitionVO
// {
// private final String groupId;
// private final String topic;
// private final int partitionId;
// private ConsumerOffsetVO consumerOffset = new ConsumerOffsetVO(-1L , -1L);
// private long size;
// private long firstOffset;
// private String owner;
//
// public ConsumerPartitionVO(String groupId, String topic, int partitionId)
// {
// this.groupId = groupId;
// this.topic = topic;
// this.partitionId = partitionId;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public String getTopic()
// {
// return topic;
// }
//
// public int getPartitionId()
// {
// return partitionId;
// }
//
// public void setConsumerOffset(ConsumerOffsetVO offset)
// {
// this.consumerOffset = offset;
// }
//
// public ConsumerOffsetVO getConsumerOffset()
// {
// return consumerOffset;
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize(long size)
// {
// this.size = size;
// }
//
// public long getFirstOffset()
// {
// return firstOffset;
// }
//
// public void setFirstOffset(long firstOffset)
// {
// this.firstOffset = firstOffset;
// }
//
// public long getLag()
// {
// return getLag(getOffset());
// }
//
// public long getKafkaLag()
// {
// return getLag(getConsumerOffset().getKafkaOffset());
// }
//
// public long getZookeeperLag()
// {
// return getLag(getConsumerOffset().getZookeeperOffset());
// }
//
// private long getLag(long offset)
// {
// if (size < 0 || firstOffset < 0)
// {
// return 0;
// }
// else if (offset < firstOffset)
// {
// return size - firstOffset;
// }
// else
// {
// return size - offset;
// }
// }
//
// public void setOwner(String owner)
// {
// this.owner = owner;
// }
//
// public long getOffset()
// {
// return consumerOffset.getMaxOffset();
// }
//
// public String getOwner()
// {
// return owner;
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerLagReportingOffsetType.java
// public enum ConsumerLagReportingOffsetType
// {
// Kafka("kafka"), Zookeeper("zookeeper"), Both("both"), Minimum("minimum");
//
// private String type;
// private static final Map<String, ConsumerLagReportingOffsetType> typeLookup = new HashMap<>();
//
//
// ConsumerLagReportingOffsetType(String type)
// {
// this.type = type;
// }
//
//
// // Can't override valueOf(), so...use this instead.
// public static ConsumerLagReportingOffsetType enumValue(String type)
// {
// ConsumerLagReportingOffsetType value = typeLookup.get(StringUtils
// .trimToEmpty(type).toLowerCase());
// if (null == value)
// {
// return Minimum;
// }
// return value;
// }
//
// public String getValue()
// {
// return type;
// }
//
// static
// {
// for(ConsumerLagReportingOffsetType env : values())
// {
// typeLookup.put(env.getValue(), env);
// }
// }
// }
| import com.fasterxml.jackson.annotation.JsonInclude;
import com.homeadvisor.kafdrop.model.ConsumerPartitionVO;
import com.homeadvisor.kafdrop.service.ConsumerLagReportingOffsetType; | package com.homeadvisor.kafdrop.model.dto;
public class ConsumerPartitionDTO
{ | // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerPartitionVO.java
// public class ConsumerPartitionVO
// {
// private final String groupId;
// private final String topic;
// private final int partitionId;
// private ConsumerOffsetVO consumerOffset = new ConsumerOffsetVO(-1L , -1L);
// private long size;
// private long firstOffset;
// private String owner;
//
// public ConsumerPartitionVO(String groupId, String topic, int partitionId)
// {
// this.groupId = groupId;
// this.topic = topic;
// this.partitionId = partitionId;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public String getTopic()
// {
// return topic;
// }
//
// public int getPartitionId()
// {
// return partitionId;
// }
//
// public void setConsumerOffset(ConsumerOffsetVO offset)
// {
// this.consumerOffset = offset;
// }
//
// public ConsumerOffsetVO getConsumerOffset()
// {
// return consumerOffset;
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize(long size)
// {
// this.size = size;
// }
//
// public long getFirstOffset()
// {
// return firstOffset;
// }
//
// public void setFirstOffset(long firstOffset)
// {
// this.firstOffset = firstOffset;
// }
//
// public long getLag()
// {
// return getLag(getOffset());
// }
//
// public long getKafkaLag()
// {
// return getLag(getConsumerOffset().getKafkaOffset());
// }
//
// public long getZookeeperLag()
// {
// return getLag(getConsumerOffset().getZookeeperOffset());
// }
//
// private long getLag(long offset)
// {
// if (size < 0 || firstOffset < 0)
// {
// return 0;
// }
// else if (offset < firstOffset)
// {
// return size - firstOffset;
// }
// else
// {
// return size - offset;
// }
// }
//
// public void setOwner(String owner)
// {
// this.owner = owner;
// }
//
// public long getOffset()
// {
// return consumerOffset.getMaxOffset();
// }
//
// public String getOwner()
// {
// return owner;
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerLagReportingOffsetType.java
// public enum ConsumerLagReportingOffsetType
// {
// Kafka("kafka"), Zookeeper("zookeeper"), Both("both"), Minimum("minimum");
//
// private String type;
// private static final Map<String, ConsumerLagReportingOffsetType> typeLookup = new HashMap<>();
//
//
// ConsumerLagReportingOffsetType(String type)
// {
// this.type = type;
// }
//
//
// // Can't override valueOf(), so...use this instead.
// public static ConsumerLagReportingOffsetType enumValue(String type)
// {
// ConsumerLagReportingOffsetType value = typeLookup.get(StringUtils
// .trimToEmpty(type).toLowerCase());
// if (null == value)
// {
// return Minimum;
// }
// return value;
// }
//
// public String getValue()
// {
// return type;
// }
//
// static
// {
// for(ConsumerLagReportingOffsetType env : values())
// {
// typeLookup.put(env.getValue(), env);
// }
// }
// }
// Path: src/main/java/com/homeadvisor/kafdrop/model/dto/ConsumerPartitionDTO.java
import com.fasterxml.jackson.annotation.JsonInclude;
import com.homeadvisor.kafdrop.model.ConsumerPartitionVO;
import com.homeadvisor.kafdrop.service.ConsumerLagReportingOffsetType;
package com.homeadvisor.kafdrop.model.dto;
public class ConsumerPartitionDTO
{ | private ConsumerLagReportingOffsetType offsetType; |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/model/dto/ConsumerPartitionDTO.java | // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerPartitionVO.java
// public class ConsumerPartitionVO
// {
// private final String groupId;
// private final String topic;
// private final int partitionId;
// private ConsumerOffsetVO consumerOffset = new ConsumerOffsetVO(-1L , -1L);
// private long size;
// private long firstOffset;
// private String owner;
//
// public ConsumerPartitionVO(String groupId, String topic, int partitionId)
// {
// this.groupId = groupId;
// this.topic = topic;
// this.partitionId = partitionId;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public String getTopic()
// {
// return topic;
// }
//
// public int getPartitionId()
// {
// return partitionId;
// }
//
// public void setConsumerOffset(ConsumerOffsetVO offset)
// {
// this.consumerOffset = offset;
// }
//
// public ConsumerOffsetVO getConsumerOffset()
// {
// return consumerOffset;
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize(long size)
// {
// this.size = size;
// }
//
// public long getFirstOffset()
// {
// return firstOffset;
// }
//
// public void setFirstOffset(long firstOffset)
// {
// this.firstOffset = firstOffset;
// }
//
// public long getLag()
// {
// return getLag(getOffset());
// }
//
// public long getKafkaLag()
// {
// return getLag(getConsumerOffset().getKafkaOffset());
// }
//
// public long getZookeeperLag()
// {
// return getLag(getConsumerOffset().getZookeeperOffset());
// }
//
// private long getLag(long offset)
// {
// if (size < 0 || firstOffset < 0)
// {
// return 0;
// }
// else if (offset < firstOffset)
// {
// return size - firstOffset;
// }
// else
// {
// return size - offset;
// }
// }
//
// public void setOwner(String owner)
// {
// this.owner = owner;
// }
//
// public long getOffset()
// {
// return consumerOffset.getMaxOffset();
// }
//
// public String getOwner()
// {
// return owner;
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerLagReportingOffsetType.java
// public enum ConsumerLagReportingOffsetType
// {
// Kafka("kafka"), Zookeeper("zookeeper"), Both("both"), Minimum("minimum");
//
// private String type;
// private static final Map<String, ConsumerLagReportingOffsetType> typeLookup = new HashMap<>();
//
//
// ConsumerLagReportingOffsetType(String type)
// {
// this.type = type;
// }
//
//
// // Can't override valueOf(), so...use this instead.
// public static ConsumerLagReportingOffsetType enumValue(String type)
// {
// ConsumerLagReportingOffsetType value = typeLookup.get(StringUtils
// .trimToEmpty(type).toLowerCase());
// if (null == value)
// {
// return Minimum;
// }
// return value;
// }
//
// public String getValue()
// {
// return type;
// }
//
// static
// {
// for(ConsumerLagReportingOffsetType env : values())
// {
// typeLookup.put(env.getValue(), env);
// }
// }
// }
| import com.fasterxml.jackson.annotation.JsonInclude;
import com.homeadvisor.kafdrop.model.ConsumerPartitionVO;
import com.homeadvisor.kafdrop.service.ConsumerLagReportingOffsetType; | package com.homeadvisor.kafdrop.model.dto;
public class ConsumerPartitionDTO
{
private ConsumerLagReportingOffsetType offsetType;
private Long kafkaLag;
private Long zookeeperLag;
| // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerPartitionVO.java
// public class ConsumerPartitionVO
// {
// private final String groupId;
// private final String topic;
// private final int partitionId;
// private ConsumerOffsetVO consumerOffset = new ConsumerOffsetVO(-1L , -1L);
// private long size;
// private long firstOffset;
// private String owner;
//
// public ConsumerPartitionVO(String groupId, String topic, int partitionId)
// {
// this.groupId = groupId;
// this.topic = topic;
// this.partitionId = partitionId;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public String getTopic()
// {
// return topic;
// }
//
// public int getPartitionId()
// {
// return partitionId;
// }
//
// public void setConsumerOffset(ConsumerOffsetVO offset)
// {
// this.consumerOffset = offset;
// }
//
// public ConsumerOffsetVO getConsumerOffset()
// {
// return consumerOffset;
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize(long size)
// {
// this.size = size;
// }
//
// public long getFirstOffset()
// {
// return firstOffset;
// }
//
// public void setFirstOffset(long firstOffset)
// {
// this.firstOffset = firstOffset;
// }
//
// public long getLag()
// {
// return getLag(getOffset());
// }
//
// public long getKafkaLag()
// {
// return getLag(getConsumerOffset().getKafkaOffset());
// }
//
// public long getZookeeperLag()
// {
// return getLag(getConsumerOffset().getZookeeperOffset());
// }
//
// private long getLag(long offset)
// {
// if (size < 0 || firstOffset < 0)
// {
// return 0;
// }
// else if (offset < firstOffset)
// {
// return size - firstOffset;
// }
// else
// {
// return size - offset;
// }
// }
//
// public void setOwner(String owner)
// {
// this.owner = owner;
// }
//
// public long getOffset()
// {
// return consumerOffset.getMaxOffset();
// }
//
// public String getOwner()
// {
// return owner;
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerLagReportingOffsetType.java
// public enum ConsumerLagReportingOffsetType
// {
// Kafka("kafka"), Zookeeper("zookeeper"), Both("both"), Minimum("minimum");
//
// private String type;
// private static final Map<String, ConsumerLagReportingOffsetType> typeLookup = new HashMap<>();
//
//
// ConsumerLagReportingOffsetType(String type)
// {
// this.type = type;
// }
//
//
// // Can't override valueOf(), so...use this instead.
// public static ConsumerLagReportingOffsetType enumValue(String type)
// {
// ConsumerLagReportingOffsetType value = typeLookup.get(StringUtils
// .trimToEmpty(type).toLowerCase());
// if (null == value)
// {
// return Minimum;
// }
// return value;
// }
//
// public String getValue()
// {
// return type;
// }
//
// static
// {
// for(ConsumerLagReportingOffsetType env : values())
// {
// typeLookup.put(env.getValue(), env);
// }
// }
// }
// Path: src/main/java/com/homeadvisor/kafdrop/model/dto/ConsumerPartitionDTO.java
import com.fasterxml.jackson.annotation.JsonInclude;
import com.homeadvisor.kafdrop.model.ConsumerPartitionVO;
import com.homeadvisor.kafdrop.service.ConsumerLagReportingOffsetType;
package com.homeadvisor.kafdrop.model.dto;
public class ConsumerPartitionDTO
{
private ConsumerLagReportingOffsetType offsetType;
private Long kafkaLag;
private Long zookeeperLag;
| ConsumerPartitionDTO(ConsumerPartitionVO partition, ConsumerLagReportingOffsetType offsetType) |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/controller/BrokerController.java | // Path: src/main/java/com/homeadvisor/kafdrop/model/BrokerVO.java
// public class BrokerVO
// {
// private int id;
// private String host;
// private int port;
// private int jmxPort;
// private int version;
// private boolean controller;
// private Date timestamp;
// private String rack;
//
// public BrokerVO()
// {
// }
//
// public int getId()
// {
// return id;
// }
//
// public void setId(int id)
// {
// this.id = id;
// }
//
// public String getHost()
// {
// return host;
// }
//
// public void setHost(String host)
// {
// this.host = host;
// }
//
// public int getPort()
// {
// return port;
// }
//
// public void setPort(int port)
// {
// this.port = port;
// }
//
// public int getJmxPort()
// {
// return jmxPort;
// }
//
// @JsonProperty("jmx_port")
// public void setJmxPort(int jmxPort)
// {
// this.jmxPort = jmxPort;
// }
//
// public int getVersion()
// {
// return version;
// }
//
// public void setVersion(int version)
// {
// this.version = version;
// }
//
// public Date getTimestamp()
// {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp)
// {
// this.timestamp = timestamp;
// }
//
// public boolean isController()
// {
// return controller;
// }
//
// public void setController(boolean controller)
// {
// this.controller = controller;
// }
//
// public String getRack()
// {
// return rack;
// }
//
// public void setRack(String rack)
// {
// this.rack = rack;
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/BrokerNotFoundException.java
// @ResponseStatus(HttpStatus.NOT_FOUND)
// public class BrokerNotFoundException extends RuntimeException
// {
// public BrokerNotFoundException()
// {
// }
//
// public BrokerNotFoundException(String message)
// {
// super(message);
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/KafkaMonitor.java
// public interface KafkaMonitor
// {
// List<BrokerVO> getBrokers();
//
// Optional<BrokerVO> getBroker(int id);
//
// default Optional<BrokerConfigurationVO> getBrokerConfiguration(int id)
// {
// return Optional.empty();
// }
//
// List<TopicVO> getTopics();
//
// Optional<TopicVO> getTopic(String topic);
//
// ClusterSummaryVO getClusterSummary(Collection<TopicVO> topics);
//
// List<ConsumerVO> getConsumers(TopicVO topic);
//
// Optional<ConsumerVO> getConsumer(String groupId);
//
// Optional<ConsumerVO> getConsumerByTopic(String groupId, TopicVO topic);
// }
| import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import com.homeadvisor.kafdrop.model.BrokerVO;
import com.homeadvisor.kafdrop.service.BrokerNotFoundException;
import com.homeadvisor.kafdrop.service.KafkaMonitor;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; | /*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.controller;
@Controller
public class BrokerController
{
@Autowired | // Path: src/main/java/com/homeadvisor/kafdrop/model/BrokerVO.java
// public class BrokerVO
// {
// private int id;
// private String host;
// private int port;
// private int jmxPort;
// private int version;
// private boolean controller;
// private Date timestamp;
// private String rack;
//
// public BrokerVO()
// {
// }
//
// public int getId()
// {
// return id;
// }
//
// public void setId(int id)
// {
// this.id = id;
// }
//
// public String getHost()
// {
// return host;
// }
//
// public void setHost(String host)
// {
// this.host = host;
// }
//
// public int getPort()
// {
// return port;
// }
//
// public void setPort(int port)
// {
// this.port = port;
// }
//
// public int getJmxPort()
// {
// return jmxPort;
// }
//
// @JsonProperty("jmx_port")
// public void setJmxPort(int jmxPort)
// {
// this.jmxPort = jmxPort;
// }
//
// public int getVersion()
// {
// return version;
// }
//
// public void setVersion(int version)
// {
// this.version = version;
// }
//
// public Date getTimestamp()
// {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp)
// {
// this.timestamp = timestamp;
// }
//
// public boolean isController()
// {
// return controller;
// }
//
// public void setController(boolean controller)
// {
// this.controller = controller;
// }
//
// public String getRack()
// {
// return rack;
// }
//
// public void setRack(String rack)
// {
// this.rack = rack;
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/BrokerNotFoundException.java
// @ResponseStatus(HttpStatus.NOT_FOUND)
// public class BrokerNotFoundException extends RuntimeException
// {
// public BrokerNotFoundException()
// {
// }
//
// public BrokerNotFoundException(String message)
// {
// super(message);
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/KafkaMonitor.java
// public interface KafkaMonitor
// {
// List<BrokerVO> getBrokers();
//
// Optional<BrokerVO> getBroker(int id);
//
// default Optional<BrokerConfigurationVO> getBrokerConfiguration(int id)
// {
// return Optional.empty();
// }
//
// List<TopicVO> getTopics();
//
// Optional<TopicVO> getTopic(String topic);
//
// ClusterSummaryVO getClusterSummary(Collection<TopicVO> topics);
//
// List<ConsumerVO> getConsumers(TopicVO topic);
//
// Optional<ConsumerVO> getConsumer(String groupId);
//
// Optional<ConsumerVO> getConsumerByTopic(String groupId, TopicVO topic);
// }
// Path: src/main/java/com/homeadvisor/kafdrop/controller/BrokerController.java
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import com.homeadvisor.kafdrop.model.BrokerVO;
import com.homeadvisor.kafdrop.service.BrokerNotFoundException;
import com.homeadvisor.kafdrop.service.KafkaMonitor;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
/*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.controller;
@Controller
public class BrokerController
{
@Autowired | private KafkaMonitor kafkaMonitor; |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/controller/BrokerController.java | // Path: src/main/java/com/homeadvisor/kafdrop/model/BrokerVO.java
// public class BrokerVO
// {
// private int id;
// private String host;
// private int port;
// private int jmxPort;
// private int version;
// private boolean controller;
// private Date timestamp;
// private String rack;
//
// public BrokerVO()
// {
// }
//
// public int getId()
// {
// return id;
// }
//
// public void setId(int id)
// {
// this.id = id;
// }
//
// public String getHost()
// {
// return host;
// }
//
// public void setHost(String host)
// {
// this.host = host;
// }
//
// public int getPort()
// {
// return port;
// }
//
// public void setPort(int port)
// {
// this.port = port;
// }
//
// public int getJmxPort()
// {
// return jmxPort;
// }
//
// @JsonProperty("jmx_port")
// public void setJmxPort(int jmxPort)
// {
// this.jmxPort = jmxPort;
// }
//
// public int getVersion()
// {
// return version;
// }
//
// public void setVersion(int version)
// {
// this.version = version;
// }
//
// public Date getTimestamp()
// {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp)
// {
// this.timestamp = timestamp;
// }
//
// public boolean isController()
// {
// return controller;
// }
//
// public void setController(boolean controller)
// {
// this.controller = controller;
// }
//
// public String getRack()
// {
// return rack;
// }
//
// public void setRack(String rack)
// {
// this.rack = rack;
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/BrokerNotFoundException.java
// @ResponseStatus(HttpStatus.NOT_FOUND)
// public class BrokerNotFoundException extends RuntimeException
// {
// public BrokerNotFoundException()
// {
// }
//
// public BrokerNotFoundException(String message)
// {
// super(message);
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/KafkaMonitor.java
// public interface KafkaMonitor
// {
// List<BrokerVO> getBrokers();
//
// Optional<BrokerVO> getBroker(int id);
//
// default Optional<BrokerConfigurationVO> getBrokerConfiguration(int id)
// {
// return Optional.empty();
// }
//
// List<TopicVO> getTopics();
//
// Optional<TopicVO> getTopic(String topic);
//
// ClusterSummaryVO getClusterSummary(Collection<TopicVO> topics);
//
// List<ConsumerVO> getConsumers(TopicVO topic);
//
// Optional<ConsumerVO> getConsumer(String groupId);
//
// Optional<ConsumerVO> getConsumerByTopic(String groupId, TopicVO topic);
// }
| import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import com.homeadvisor.kafdrop.model.BrokerVO;
import com.homeadvisor.kafdrop.service.BrokerNotFoundException;
import com.homeadvisor.kafdrop.service.KafkaMonitor;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; | /*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.controller;
@Controller
public class BrokerController
{
@Autowired
private KafkaMonitor kafkaMonitor;
@RequestMapping("/broker/{id}")
public String brokerDetails(@PathVariable("id") int brokerId, Model model)
{
model.addAttribute("broker", kafkaMonitor.getBroker(brokerId) | // Path: src/main/java/com/homeadvisor/kafdrop/model/BrokerVO.java
// public class BrokerVO
// {
// private int id;
// private String host;
// private int port;
// private int jmxPort;
// private int version;
// private boolean controller;
// private Date timestamp;
// private String rack;
//
// public BrokerVO()
// {
// }
//
// public int getId()
// {
// return id;
// }
//
// public void setId(int id)
// {
// this.id = id;
// }
//
// public String getHost()
// {
// return host;
// }
//
// public void setHost(String host)
// {
// this.host = host;
// }
//
// public int getPort()
// {
// return port;
// }
//
// public void setPort(int port)
// {
// this.port = port;
// }
//
// public int getJmxPort()
// {
// return jmxPort;
// }
//
// @JsonProperty("jmx_port")
// public void setJmxPort(int jmxPort)
// {
// this.jmxPort = jmxPort;
// }
//
// public int getVersion()
// {
// return version;
// }
//
// public void setVersion(int version)
// {
// this.version = version;
// }
//
// public Date getTimestamp()
// {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp)
// {
// this.timestamp = timestamp;
// }
//
// public boolean isController()
// {
// return controller;
// }
//
// public void setController(boolean controller)
// {
// this.controller = controller;
// }
//
// public String getRack()
// {
// return rack;
// }
//
// public void setRack(String rack)
// {
// this.rack = rack;
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/BrokerNotFoundException.java
// @ResponseStatus(HttpStatus.NOT_FOUND)
// public class BrokerNotFoundException extends RuntimeException
// {
// public BrokerNotFoundException()
// {
// }
//
// public BrokerNotFoundException(String message)
// {
// super(message);
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/KafkaMonitor.java
// public interface KafkaMonitor
// {
// List<BrokerVO> getBrokers();
//
// Optional<BrokerVO> getBroker(int id);
//
// default Optional<BrokerConfigurationVO> getBrokerConfiguration(int id)
// {
// return Optional.empty();
// }
//
// List<TopicVO> getTopics();
//
// Optional<TopicVO> getTopic(String topic);
//
// ClusterSummaryVO getClusterSummary(Collection<TopicVO> topics);
//
// List<ConsumerVO> getConsumers(TopicVO topic);
//
// Optional<ConsumerVO> getConsumer(String groupId);
//
// Optional<ConsumerVO> getConsumerByTopic(String groupId, TopicVO topic);
// }
// Path: src/main/java/com/homeadvisor/kafdrop/controller/BrokerController.java
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import com.homeadvisor.kafdrop.model.BrokerVO;
import com.homeadvisor.kafdrop.service.BrokerNotFoundException;
import com.homeadvisor.kafdrop.service.KafkaMonitor;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
/*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.controller;
@Controller
public class BrokerController
{
@Autowired
private KafkaMonitor kafkaMonitor;
@RequestMapping("/broker/{id}")
public String brokerDetails(@PathVariable("id") int brokerId, Model model)
{
model.addAttribute("broker", kafkaMonitor.getBroker(brokerId) | .orElseThrow(() -> new BrokerNotFoundException(String.valueOf(brokerId)))); |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/controller/BrokerController.java | // Path: src/main/java/com/homeadvisor/kafdrop/model/BrokerVO.java
// public class BrokerVO
// {
// private int id;
// private String host;
// private int port;
// private int jmxPort;
// private int version;
// private boolean controller;
// private Date timestamp;
// private String rack;
//
// public BrokerVO()
// {
// }
//
// public int getId()
// {
// return id;
// }
//
// public void setId(int id)
// {
// this.id = id;
// }
//
// public String getHost()
// {
// return host;
// }
//
// public void setHost(String host)
// {
// this.host = host;
// }
//
// public int getPort()
// {
// return port;
// }
//
// public void setPort(int port)
// {
// this.port = port;
// }
//
// public int getJmxPort()
// {
// return jmxPort;
// }
//
// @JsonProperty("jmx_port")
// public void setJmxPort(int jmxPort)
// {
// this.jmxPort = jmxPort;
// }
//
// public int getVersion()
// {
// return version;
// }
//
// public void setVersion(int version)
// {
// this.version = version;
// }
//
// public Date getTimestamp()
// {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp)
// {
// this.timestamp = timestamp;
// }
//
// public boolean isController()
// {
// return controller;
// }
//
// public void setController(boolean controller)
// {
// this.controller = controller;
// }
//
// public String getRack()
// {
// return rack;
// }
//
// public void setRack(String rack)
// {
// this.rack = rack;
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/BrokerNotFoundException.java
// @ResponseStatus(HttpStatus.NOT_FOUND)
// public class BrokerNotFoundException extends RuntimeException
// {
// public BrokerNotFoundException()
// {
// }
//
// public BrokerNotFoundException(String message)
// {
// super(message);
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/KafkaMonitor.java
// public interface KafkaMonitor
// {
// List<BrokerVO> getBrokers();
//
// Optional<BrokerVO> getBroker(int id);
//
// default Optional<BrokerConfigurationVO> getBrokerConfiguration(int id)
// {
// return Optional.empty();
// }
//
// List<TopicVO> getTopics();
//
// Optional<TopicVO> getTopic(String topic);
//
// ClusterSummaryVO getClusterSummary(Collection<TopicVO> topics);
//
// List<ConsumerVO> getConsumers(TopicVO topic);
//
// Optional<ConsumerVO> getConsumer(String groupId);
//
// Optional<ConsumerVO> getConsumerByTopic(String groupId, TopicVO topic);
// }
| import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import com.homeadvisor.kafdrop.model.BrokerVO;
import com.homeadvisor.kafdrop.service.BrokerNotFoundException;
import com.homeadvisor.kafdrop.service.KafkaMonitor;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; | /*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.controller;
@Controller
public class BrokerController
{
@Autowired
private KafkaMonitor kafkaMonitor;
@RequestMapping("/broker/{id}")
public String brokerDetails(@PathVariable("id") int brokerId, Model model)
{
model.addAttribute("broker", kafkaMonitor.getBroker(brokerId)
.orElseThrow(() -> new BrokerNotFoundException(String.valueOf(brokerId))));
model.addAttribute("topics", kafkaMonitor.getTopics());
kafkaMonitor.getBrokerConfiguration(brokerId)
.ifPresent(config -> model.addAttribute("brokerConfig", config));
return "broker-detail";
}
@ApiOperation(value = "getBroker", notes = "Get details for a specific Kafka broker")
@ApiResponses(value = { | // Path: src/main/java/com/homeadvisor/kafdrop/model/BrokerVO.java
// public class BrokerVO
// {
// private int id;
// private String host;
// private int port;
// private int jmxPort;
// private int version;
// private boolean controller;
// private Date timestamp;
// private String rack;
//
// public BrokerVO()
// {
// }
//
// public int getId()
// {
// return id;
// }
//
// public void setId(int id)
// {
// this.id = id;
// }
//
// public String getHost()
// {
// return host;
// }
//
// public void setHost(String host)
// {
// this.host = host;
// }
//
// public int getPort()
// {
// return port;
// }
//
// public void setPort(int port)
// {
// this.port = port;
// }
//
// public int getJmxPort()
// {
// return jmxPort;
// }
//
// @JsonProperty("jmx_port")
// public void setJmxPort(int jmxPort)
// {
// this.jmxPort = jmxPort;
// }
//
// public int getVersion()
// {
// return version;
// }
//
// public void setVersion(int version)
// {
// this.version = version;
// }
//
// public Date getTimestamp()
// {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp)
// {
// this.timestamp = timestamp;
// }
//
// public boolean isController()
// {
// return controller;
// }
//
// public void setController(boolean controller)
// {
// this.controller = controller;
// }
//
// public String getRack()
// {
// return rack;
// }
//
// public void setRack(String rack)
// {
// this.rack = rack;
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/BrokerNotFoundException.java
// @ResponseStatus(HttpStatus.NOT_FOUND)
// public class BrokerNotFoundException extends RuntimeException
// {
// public BrokerNotFoundException()
// {
// }
//
// public BrokerNotFoundException(String message)
// {
// super(message);
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/KafkaMonitor.java
// public interface KafkaMonitor
// {
// List<BrokerVO> getBrokers();
//
// Optional<BrokerVO> getBroker(int id);
//
// default Optional<BrokerConfigurationVO> getBrokerConfiguration(int id)
// {
// return Optional.empty();
// }
//
// List<TopicVO> getTopics();
//
// Optional<TopicVO> getTopic(String topic);
//
// ClusterSummaryVO getClusterSummary(Collection<TopicVO> topics);
//
// List<ConsumerVO> getConsumers(TopicVO topic);
//
// Optional<ConsumerVO> getConsumer(String groupId);
//
// Optional<ConsumerVO> getConsumerByTopic(String groupId, TopicVO topic);
// }
// Path: src/main/java/com/homeadvisor/kafdrop/controller/BrokerController.java
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import com.homeadvisor.kafdrop.model.BrokerVO;
import com.homeadvisor.kafdrop.service.BrokerNotFoundException;
import com.homeadvisor.kafdrop.service.KafkaMonitor;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
/*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.controller;
@Controller
public class BrokerController
{
@Autowired
private KafkaMonitor kafkaMonitor;
@RequestMapping("/broker/{id}")
public String brokerDetails(@PathVariable("id") int brokerId, Model model)
{
model.addAttribute("broker", kafkaMonitor.getBroker(brokerId)
.orElseThrow(() -> new BrokerNotFoundException(String.valueOf(brokerId))));
model.addAttribute("topics", kafkaMonitor.getTopics());
kafkaMonitor.getBrokerConfiguration(brokerId)
.ifPresent(config -> model.addAttribute("brokerConfig", config));
return "broker-detail";
}
@ApiOperation(value = "getBroker", notes = "Get details for a specific Kafka broker")
@ApiResponses(value = { | @ApiResponse(code = 200, message = "Success", response = BrokerVO.class), |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/config/MessageFormatConfiguration.java | // Path: src/main/java/com/homeadvisor/kafdrop/util/MessageFormat.java
// public enum MessageFormat {
// DEFAULT, AVRO;
// }
| import javax.annotation.PostConstruct;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import com.homeadvisor.kafdrop.util.MessageFormat; | package com.homeadvisor.kafdrop.config;
@Configuration
public class MessageFormatConfiguration {
@Component
@ConfigurationProperties(prefix = "message")
public static class MessageFormatProperties
{
| // Path: src/main/java/com/homeadvisor/kafdrop/util/MessageFormat.java
// public enum MessageFormat {
// DEFAULT, AVRO;
// }
// Path: src/main/java/com/homeadvisor/kafdrop/config/MessageFormatConfiguration.java
import javax.annotation.PostConstruct;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import com.homeadvisor.kafdrop.util.MessageFormat;
package com.homeadvisor.kafdrop.config;
@Configuration
public class MessageFormatConfiguration {
@Component
@ConfigurationProperties(prefix = "message")
public static class MessageFormatProperties
{
| private MessageFormat format; |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/controller/LegacyConsumerController.java | // Path: src/main/java/com/homeadvisor/kafdrop/service/KafkaMonitor.java
// public interface KafkaMonitor
// {
// List<BrokerVO> getBrokers();
//
// Optional<BrokerVO> getBroker(int id);
//
// default Optional<BrokerConfigurationVO> getBrokerConfiguration(int id)
// {
// return Optional.empty();
// }
//
// List<TopicVO> getTopics();
//
// Optional<TopicVO> getTopic(String topic);
//
// ClusterSummaryVO getClusterSummary(Collection<TopicVO> topics);
//
// List<ConsumerVO> getConsumers(TopicVO topic);
//
// Optional<ConsumerVO> getConsumer(String groupId);
//
// Optional<ConsumerVO> getConsumerByTopic(String groupId, TopicVO topic);
// }
| import com.homeadvisor.kafdrop.service.KafkaMonitor;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; | /*
* Copyright 2019 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.controller;
@Controller
@RequestMapping("/legacy/consumer")
@ConditionalOnProperty(name = "kafka.legacyConsumer.enabled", havingValue = "true", matchIfMissing = true)
public class LegacyConsumerController extends ConsumerController
{
| // Path: src/main/java/com/homeadvisor/kafdrop/service/KafkaMonitor.java
// public interface KafkaMonitor
// {
// List<BrokerVO> getBrokers();
//
// Optional<BrokerVO> getBroker(int id);
//
// default Optional<BrokerConfigurationVO> getBrokerConfiguration(int id)
// {
// return Optional.empty();
// }
//
// List<TopicVO> getTopics();
//
// Optional<TopicVO> getTopic(String topic);
//
// ClusterSummaryVO getClusterSummary(Collection<TopicVO> topics);
//
// List<ConsumerVO> getConsumers(TopicVO topic);
//
// Optional<ConsumerVO> getConsumer(String groupId);
//
// Optional<ConsumerVO> getConsumerByTopic(String groupId, TopicVO topic);
// }
// Path: src/main/java/com/homeadvisor/kafdrop/controller/LegacyConsumerController.java
import com.homeadvisor.kafdrop.service.KafkaMonitor;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/*
* Copyright 2019 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.controller;
@Controller
@RequestMapping("/legacy/consumer")
@ConditionalOnProperty(name = "kafka.legacyConsumer.enabled", havingValue = "true", matchIfMissing = true)
public class LegacyConsumerController extends ConsumerController
{
| public LegacyConsumerController(@Qualifier("curator") KafkaMonitor kafkaMonitor) |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/model/dto/BaseLagDTO.java | // Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerLagReportingOffsetType.java
// public enum ConsumerLagReportingOffsetType
// {
// Kafka("kafka"), Zookeeper("zookeeper"), Both("both"), Minimum("minimum");
//
// private String type;
// private static final Map<String, ConsumerLagReportingOffsetType> typeLookup = new HashMap<>();
//
//
// ConsumerLagReportingOffsetType(String type)
// {
// this.type = type;
// }
//
//
// // Can't override valueOf(), so...use this instead.
// public static ConsumerLagReportingOffsetType enumValue(String type)
// {
// ConsumerLagReportingOffsetType value = typeLookup.get(StringUtils
// .trimToEmpty(type).toLowerCase());
// if (null == value)
// {
// return Minimum;
// }
// return value;
// }
//
// public String getValue()
// {
// return type;
// }
//
// static
// {
// for(ConsumerLagReportingOffsetType env : values())
// {
// typeLookup.put(env.getValue(), env);
// }
// }
// }
| import com.fasterxml.jackson.annotation.JsonInclude;
import com.homeadvisor.kafdrop.service.ConsumerLagReportingOffsetType;
import java.util.function.Function; | package com.homeadvisor.kafdrop.model.dto;
public abstract class BaseLagDTO
{ | // Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerLagReportingOffsetType.java
// public enum ConsumerLagReportingOffsetType
// {
// Kafka("kafka"), Zookeeper("zookeeper"), Both("both"), Minimum("minimum");
//
// private String type;
// private static final Map<String, ConsumerLagReportingOffsetType> typeLookup = new HashMap<>();
//
//
// ConsumerLagReportingOffsetType(String type)
// {
// this.type = type;
// }
//
//
// // Can't override valueOf(), so...use this instead.
// public static ConsumerLagReportingOffsetType enumValue(String type)
// {
// ConsumerLagReportingOffsetType value = typeLookup.get(StringUtils
// .trimToEmpty(type).toLowerCase());
// if (null == value)
// {
// return Minimum;
// }
// return value;
// }
//
// public String getValue()
// {
// return type;
// }
//
// static
// {
// for(ConsumerLagReportingOffsetType env : values())
// {
// typeLookup.put(env.getValue(), env);
// }
// }
// }
// Path: src/main/java/com/homeadvisor/kafdrop/model/dto/BaseLagDTO.java
import com.fasterxml.jackson.annotation.JsonInclude;
import com.homeadvisor.kafdrop.service.ConsumerLagReportingOffsetType;
import java.util.function.Function;
package com.homeadvisor.kafdrop.model.dto;
public abstract class BaseLagDTO
{ | protected ConsumerLagReportingOffsetType offsetType; |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/service/BrokerRegistry.java | // Path: src/main/java/com/homeadvisor/kafdrop/model/BrokerVO.java
// public class BrokerVO
// {
// private int id;
// private String host;
// private int port;
// private int jmxPort;
// private int version;
// private boolean controller;
// private Date timestamp;
// private String rack;
//
// public BrokerVO()
// {
// }
//
// public int getId()
// {
// return id;
// }
//
// public void setId(int id)
// {
// this.id = id;
// }
//
// public String getHost()
// {
// return host;
// }
//
// public void setHost(String host)
// {
// this.host = host;
// }
//
// public int getPort()
// {
// return port;
// }
//
// public void setPort(int port)
// {
// this.port = port;
// }
//
// public int getJmxPort()
// {
// return jmxPort;
// }
//
// @JsonProperty("jmx_port")
// public void setJmxPort(int jmxPort)
// {
// this.jmxPort = jmxPort;
// }
//
// public int getVersion()
// {
// return version;
// }
//
// public void setVersion(int version)
// {
// this.version = version;
// }
//
// public Date getTimestamp()
// {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp)
// {
// this.timestamp = timestamp;
// }
//
// public boolean isController()
// {
// return controller;
// }
//
// public void setController(boolean controller)
// {
// this.controller = controller;
// }
//
// public String getRack()
// {
// return rack;
// }
//
// public void setRack(String rack)
// {
// this.rack = rack;
// }
// }
| import com.homeadvisor.kafdrop.model.BrokerVO;
import java.util.Map; | /*
* Copyright 2019 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.service;
public interface BrokerRegistry
{ | // Path: src/main/java/com/homeadvisor/kafdrop/model/BrokerVO.java
// public class BrokerVO
// {
// private int id;
// private String host;
// private int port;
// private int jmxPort;
// private int version;
// private boolean controller;
// private Date timestamp;
// private String rack;
//
// public BrokerVO()
// {
// }
//
// public int getId()
// {
// return id;
// }
//
// public void setId(int id)
// {
// this.id = id;
// }
//
// public String getHost()
// {
// return host;
// }
//
// public void setHost(String host)
// {
// this.host = host;
// }
//
// public int getPort()
// {
// return port;
// }
//
// public void setPort(int port)
// {
// this.port = port;
// }
//
// public int getJmxPort()
// {
// return jmxPort;
// }
//
// @JsonProperty("jmx_port")
// public void setJmxPort(int jmxPort)
// {
// this.jmxPort = jmxPort;
// }
//
// public int getVersion()
// {
// return version;
// }
//
// public void setVersion(int version)
// {
// this.version = version;
// }
//
// public Date getTimestamp()
// {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp)
// {
// this.timestamp = timestamp;
// }
//
// public boolean isController()
// {
// return controller;
// }
//
// public void setController(boolean controller)
// {
// this.controller = controller;
// }
//
// public String getRack()
// {
// return rack;
// }
//
// public void setRack(String rack)
// {
// this.rack = rack;
// }
// }
// Path: src/main/java/com/homeadvisor/kafdrop/service/BrokerRegistry.java
import com.homeadvisor.kafdrop.model.BrokerVO;
import java.util.Map;
/*
* Copyright 2019 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.homeadvisor.kafdrop.service;
public interface BrokerRegistry
{ | Map<Integer, BrokerVO> getBrokers(); |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/service/ConsumerLagService.java | // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerTopicVO.java
// public class ConsumerTopicVO
// {
// private final String topic;
// private final String groupId;
// private final Map<Integer, ConsumerPartitionVO> offsets = new TreeMap<>();
//
// public ConsumerTopicVO(String topic, String groupId)
// {
// this.topic = topic;
// this.groupId = groupId;
// }
//
// public String getTopic()
// {
// return topic;
// }
//
// public void addOffset(ConsumerPartitionVO offset)
// {
// offsets.put(offset.getPartitionId(), offset);
// }
//
// public long getLag()
// {
// return offsets.values().stream()
// .map(ConsumerPartitionVO::getLag)
// .filter(lag -> lag >= 0)
// .reduce(0L, Long::sum);
// }
//
// public long getMaxLag()
// {
// return offsets.values().stream()
// .map(ConsumerPartitionVO::getLag)
// .filter(lag -> lag >= 0)
// .reduce(0L, Long::max);
// }
//
// public Collection<ConsumerPartitionVO> getPartitions()
// {
// return offsets.values();
// }
//
// public ConsumerPartitionVO getPartition(int partitionId)
// {
// return offsets.get(partitionId);
// }
//
// public ConsumerPartitionVO getOrCreatePartition(int partitionId)
// {
// return offsets.computeIfAbsent(partitionId, id -> new ConsumerPartitionVO(groupId, topic, id));
// }
//
// public double getCoveragePercent()
// {
// return (offsets.size() > 0) ? ((double)getAssignedPartitionCount()) / offsets.size() : 0.0;
// }
//
// public int getAssignedPartitionCount()
// {
// return (int) offsets.values().stream()
// .filter(p -> p.getOwner() != null)
// .count();
// }
//
// public int getOwnerCount()
// {
// return (int)offsets.values().stream()
// .map(ConsumerPartitionVO::getOwner)
// .filter(Objects::nonNull)
// .distinct()
// .count();
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerVO.java
// public class ConsumerVO implements Comparable<ConsumerVO>
// {
// private String groupId;
// private Map<String, ConsumerTopicVO> topics = new TreeMap<>();
// private List<ConsumerRegistrationVO> activeInstances = new ArrayList<>();
// private boolean legacy = false;
//
// public ConsumerVO(String groupId)
// {
// Validate.notEmpty("groupId is required");
// this.groupId = groupId;
// }
//
// public boolean isLegacy()
// {
// return legacy;
// }
//
// public void setLegacy(boolean legacy)
// {
// this.legacy = legacy;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public void setGroupId(String groupId)
// {
// this.groupId = groupId;
// }
//
// public void addActiveInstance(ConsumerRegistrationVO id)
// {
// activeInstances.add(id);
// }
//
// public List<ConsumerRegistrationVO> getActiveInstances()
// {
// return activeInstances;
// }
//
// public List<ConsumerRegistrationVO> getActiveInstancesForTopic(String topic)
// {
// return activeInstances.stream()
// .filter(registration -> registration.subscribesToTopic(topic))
// .collect(Collectors.toList());
// }
//
// public void addTopic(ConsumerTopicVO topic)
// {
// topics.put(topic.getTopic(), topic);
// }
//
// public ConsumerTopicVO getTopic(String topic)
// {
// return topics.get(topic);
// }
//
// public ConsumerTopicVO getOrCreateTopic(String topic)
// {
// ConsumerTopicVO consumerTopic = getTopic(topic);
// if (consumerTopic == null)
// {
// consumerTopic = new ConsumerTopicVO(topic, groupId);
// addTopic(consumerTopic);
// }
// return consumerTopic;
// }
//
// public Collection<ConsumerTopicVO> getTopics()
// {
// return topics.values();
// }
//
// public int getActiveTopicCount()
// {
// return topics.values().stream()
// .map(t -> t.getAssignedPartitionCount() > 0 ? 1 : 0)
// .reduce(0, Integer::sum);
// }
//
// @Override
// public int compareTo(ConsumerVO that)
// {
// return this.groupId.compareTo(that.groupId);
// }
//
// @Override
// public boolean equals(Object o)
// {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// ConsumerVO vo = (ConsumerVO) o;
//
// if (!groupId.equals(vo.groupId)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode()
// {
// return groupId.hashCode();
// }
//
// }
| import com.homeadvisor.kafdrop.model.ConsumerTopicVO;
import com.homeadvisor.kafdrop.model.ConsumerVO;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.Collections; | package com.homeadvisor.kafdrop.service;
@Service
public class ConsumerLagService
{
private final KafkaMonitor kafkaMonitor;
@Autowired
public ConsumerLagService(CuratorKafkaMonitor kafkaMonitor)
{
this.kafkaMonitor = kafkaMonitor;
}
| // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerTopicVO.java
// public class ConsumerTopicVO
// {
// private final String topic;
// private final String groupId;
// private final Map<Integer, ConsumerPartitionVO> offsets = new TreeMap<>();
//
// public ConsumerTopicVO(String topic, String groupId)
// {
// this.topic = topic;
// this.groupId = groupId;
// }
//
// public String getTopic()
// {
// return topic;
// }
//
// public void addOffset(ConsumerPartitionVO offset)
// {
// offsets.put(offset.getPartitionId(), offset);
// }
//
// public long getLag()
// {
// return offsets.values().stream()
// .map(ConsumerPartitionVO::getLag)
// .filter(lag -> lag >= 0)
// .reduce(0L, Long::sum);
// }
//
// public long getMaxLag()
// {
// return offsets.values().stream()
// .map(ConsumerPartitionVO::getLag)
// .filter(lag -> lag >= 0)
// .reduce(0L, Long::max);
// }
//
// public Collection<ConsumerPartitionVO> getPartitions()
// {
// return offsets.values();
// }
//
// public ConsumerPartitionVO getPartition(int partitionId)
// {
// return offsets.get(partitionId);
// }
//
// public ConsumerPartitionVO getOrCreatePartition(int partitionId)
// {
// return offsets.computeIfAbsent(partitionId, id -> new ConsumerPartitionVO(groupId, topic, id));
// }
//
// public double getCoveragePercent()
// {
// return (offsets.size() > 0) ? ((double)getAssignedPartitionCount()) / offsets.size() : 0.0;
// }
//
// public int getAssignedPartitionCount()
// {
// return (int) offsets.values().stream()
// .filter(p -> p.getOwner() != null)
// .count();
// }
//
// public int getOwnerCount()
// {
// return (int)offsets.values().stream()
// .map(ConsumerPartitionVO::getOwner)
// .filter(Objects::nonNull)
// .distinct()
// .count();
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerVO.java
// public class ConsumerVO implements Comparable<ConsumerVO>
// {
// private String groupId;
// private Map<String, ConsumerTopicVO> topics = new TreeMap<>();
// private List<ConsumerRegistrationVO> activeInstances = new ArrayList<>();
// private boolean legacy = false;
//
// public ConsumerVO(String groupId)
// {
// Validate.notEmpty("groupId is required");
// this.groupId = groupId;
// }
//
// public boolean isLegacy()
// {
// return legacy;
// }
//
// public void setLegacy(boolean legacy)
// {
// this.legacy = legacy;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public void setGroupId(String groupId)
// {
// this.groupId = groupId;
// }
//
// public void addActiveInstance(ConsumerRegistrationVO id)
// {
// activeInstances.add(id);
// }
//
// public List<ConsumerRegistrationVO> getActiveInstances()
// {
// return activeInstances;
// }
//
// public List<ConsumerRegistrationVO> getActiveInstancesForTopic(String topic)
// {
// return activeInstances.stream()
// .filter(registration -> registration.subscribesToTopic(topic))
// .collect(Collectors.toList());
// }
//
// public void addTopic(ConsumerTopicVO topic)
// {
// topics.put(topic.getTopic(), topic);
// }
//
// public ConsumerTopicVO getTopic(String topic)
// {
// return topics.get(topic);
// }
//
// public ConsumerTopicVO getOrCreateTopic(String topic)
// {
// ConsumerTopicVO consumerTopic = getTopic(topic);
// if (consumerTopic == null)
// {
// consumerTopic = new ConsumerTopicVO(topic, groupId);
// addTopic(consumerTopic);
// }
// return consumerTopic;
// }
//
// public Collection<ConsumerTopicVO> getTopics()
// {
// return topics.values();
// }
//
// public int getActiveTopicCount()
// {
// return topics.values().stream()
// .map(t -> t.getAssignedPartitionCount() > 0 ? 1 : 0)
// .reduce(0, Integer::sum);
// }
//
// @Override
// public int compareTo(ConsumerVO that)
// {
// return this.groupId.compareTo(that.groupId);
// }
//
// @Override
// public boolean equals(Object o)
// {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// ConsumerVO vo = (ConsumerVO) o;
//
// if (!groupId.equals(vo.groupId)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode()
// {
// return groupId.hashCode();
// }
//
// }
// Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerLagService.java
import com.homeadvisor.kafdrop.model.ConsumerTopicVO;
import com.homeadvisor.kafdrop.model.ConsumerVO;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.Collections;
package com.homeadvisor.kafdrop.service;
@Service
public class ConsumerLagService
{
private final KafkaMonitor kafkaMonitor;
@Autowired
public ConsumerLagService(CuratorKafkaMonitor kafkaMonitor)
{
this.kafkaMonitor = kafkaMonitor;
}
| public Collection<ConsumerTopicVO> computeConsumerGroupLag(String groupId, ConsumerLagReportingOffsetType offsetType) |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/service/ConsumerLagService.java | // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerTopicVO.java
// public class ConsumerTopicVO
// {
// private final String topic;
// private final String groupId;
// private final Map<Integer, ConsumerPartitionVO> offsets = new TreeMap<>();
//
// public ConsumerTopicVO(String topic, String groupId)
// {
// this.topic = topic;
// this.groupId = groupId;
// }
//
// public String getTopic()
// {
// return topic;
// }
//
// public void addOffset(ConsumerPartitionVO offset)
// {
// offsets.put(offset.getPartitionId(), offset);
// }
//
// public long getLag()
// {
// return offsets.values().stream()
// .map(ConsumerPartitionVO::getLag)
// .filter(lag -> lag >= 0)
// .reduce(0L, Long::sum);
// }
//
// public long getMaxLag()
// {
// return offsets.values().stream()
// .map(ConsumerPartitionVO::getLag)
// .filter(lag -> lag >= 0)
// .reduce(0L, Long::max);
// }
//
// public Collection<ConsumerPartitionVO> getPartitions()
// {
// return offsets.values();
// }
//
// public ConsumerPartitionVO getPartition(int partitionId)
// {
// return offsets.get(partitionId);
// }
//
// public ConsumerPartitionVO getOrCreatePartition(int partitionId)
// {
// return offsets.computeIfAbsent(partitionId, id -> new ConsumerPartitionVO(groupId, topic, id));
// }
//
// public double getCoveragePercent()
// {
// return (offsets.size() > 0) ? ((double)getAssignedPartitionCount()) / offsets.size() : 0.0;
// }
//
// public int getAssignedPartitionCount()
// {
// return (int) offsets.values().stream()
// .filter(p -> p.getOwner() != null)
// .count();
// }
//
// public int getOwnerCount()
// {
// return (int)offsets.values().stream()
// .map(ConsumerPartitionVO::getOwner)
// .filter(Objects::nonNull)
// .distinct()
// .count();
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerVO.java
// public class ConsumerVO implements Comparable<ConsumerVO>
// {
// private String groupId;
// private Map<String, ConsumerTopicVO> topics = new TreeMap<>();
// private List<ConsumerRegistrationVO> activeInstances = new ArrayList<>();
// private boolean legacy = false;
//
// public ConsumerVO(String groupId)
// {
// Validate.notEmpty("groupId is required");
// this.groupId = groupId;
// }
//
// public boolean isLegacy()
// {
// return legacy;
// }
//
// public void setLegacy(boolean legacy)
// {
// this.legacy = legacy;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public void setGroupId(String groupId)
// {
// this.groupId = groupId;
// }
//
// public void addActiveInstance(ConsumerRegistrationVO id)
// {
// activeInstances.add(id);
// }
//
// public List<ConsumerRegistrationVO> getActiveInstances()
// {
// return activeInstances;
// }
//
// public List<ConsumerRegistrationVO> getActiveInstancesForTopic(String topic)
// {
// return activeInstances.stream()
// .filter(registration -> registration.subscribesToTopic(topic))
// .collect(Collectors.toList());
// }
//
// public void addTopic(ConsumerTopicVO topic)
// {
// topics.put(topic.getTopic(), topic);
// }
//
// public ConsumerTopicVO getTopic(String topic)
// {
// return topics.get(topic);
// }
//
// public ConsumerTopicVO getOrCreateTopic(String topic)
// {
// ConsumerTopicVO consumerTopic = getTopic(topic);
// if (consumerTopic == null)
// {
// consumerTopic = new ConsumerTopicVO(topic, groupId);
// addTopic(consumerTopic);
// }
// return consumerTopic;
// }
//
// public Collection<ConsumerTopicVO> getTopics()
// {
// return topics.values();
// }
//
// public int getActiveTopicCount()
// {
// return topics.values().stream()
// .map(t -> t.getAssignedPartitionCount() > 0 ? 1 : 0)
// .reduce(0, Integer::sum);
// }
//
// @Override
// public int compareTo(ConsumerVO that)
// {
// return this.groupId.compareTo(that.groupId);
// }
//
// @Override
// public boolean equals(Object o)
// {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// ConsumerVO vo = (ConsumerVO) o;
//
// if (!groupId.equals(vo.groupId)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode()
// {
// return groupId.hashCode();
// }
//
// }
| import com.homeadvisor.kafdrop.model.ConsumerTopicVO;
import com.homeadvisor.kafdrop.model.ConsumerVO;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.Collections; | package com.homeadvisor.kafdrop.service;
@Service
public class ConsumerLagService
{
private final KafkaMonitor kafkaMonitor;
@Autowired
public ConsumerLagService(CuratorKafkaMonitor kafkaMonitor)
{
this.kafkaMonitor = kafkaMonitor;
}
public Collection<ConsumerTopicVO> computeConsumerGroupLag(String groupId, ConsumerLagReportingOffsetType offsetType)
{
return computeConsumerGroupLag(groupId, offsetType, null);
}
public Collection<ConsumerTopicVO> computeConsumerGroupLag(String groupId, ConsumerLagReportingOffsetType offsetType, String topicId)
{ | // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerTopicVO.java
// public class ConsumerTopicVO
// {
// private final String topic;
// private final String groupId;
// private final Map<Integer, ConsumerPartitionVO> offsets = new TreeMap<>();
//
// public ConsumerTopicVO(String topic, String groupId)
// {
// this.topic = topic;
// this.groupId = groupId;
// }
//
// public String getTopic()
// {
// return topic;
// }
//
// public void addOffset(ConsumerPartitionVO offset)
// {
// offsets.put(offset.getPartitionId(), offset);
// }
//
// public long getLag()
// {
// return offsets.values().stream()
// .map(ConsumerPartitionVO::getLag)
// .filter(lag -> lag >= 0)
// .reduce(0L, Long::sum);
// }
//
// public long getMaxLag()
// {
// return offsets.values().stream()
// .map(ConsumerPartitionVO::getLag)
// .filter(lag -> lag >= 0)
// .reduce(0L, Long::max);
// }
//
// public Collection<ConsumerPartitionVO> getPartitions()
// {
// return offsets.values();
// }
//
// public ConsumerPartitionVO getPartition(int partitionId)
// {
// return offsets.get(partitionId);
// }
//
// public ConsumerPartitionVO getOrCreatePartition(int partitionId)
// {
// return offsets.computeIfAbsent(partitionId, id -> new ConsumerPartitionVO(groupId, topic, id));
// }
//
// public double getCoveragePercent()
// {
// return (offsets.size() > 0) ? ((double)getAssignedPartitionCount()) / offsets.size() : 0.0;
// }
//
// public int getAssignedPartitionCount()
// {
// return (int) offsets.values().stream()
// .filter(p -> p.getOwner() != null)
// .count();
// }
//
// public int getOwnerCount()
// {
// return (int)offsets.values().stream()
// .map(ConsumerPartitionVO::getOwner)
// .filter(Objects::nonNull)
// .distinct()
// .count();
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerVO.java
// public class ConsumerVO implements Comparable<ConsumerVO>
// {
// private String groupId;
// private Map<String, ConsumerTopicVO> topics = new TreeMap<>();
// private List<ConsumerRegistrationVO> activeInstances = new ArrayList<>();
// private boolean legacy = false;
//
// public ConsumerVO(String groupId)
// {
// Validate.notEmpty("groupId is required");
// this.groupId = groupId;
// }
//
// public boolean isLegacy()
// {
// return legacy;
// }
//
// public void setLegacy(boolean legacy)
// {
// this.legacy = legacy;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public void setGroupId(String groupId)
// {
// this.groupId = groupId;
// }
//
// public void addActiveInstance(ConsumerRegistrationVO id)
// {
// activeInstances.add(id);
// }
//
// public List<ConsumerRegistrationVO> getActiveInstances()
// {
// return activeInstances;
// }
//
// public List<ConsumerRegistrationVO> getActiveInstancesForTopic(String topic)
// {
// return activeInstances.stream()
// .filter(registration -> registration.subscribesToTopic(topic))
// .collect(Collectors.toList());
// }
//
// public void addTopic(ConsumerTopicVO topic)
// {
// topics.put(topic.getTopic(), topic);
// }
//
// public ConsumerTopicVO getTopic(String topic)
// {
// return topics.get(topic);
// }
//
// public ConsumerTopicVO getOrCreateTopic(String topic)
// {
// ConsumerTopicVO consumerTopic = getTopic(topic);
// if (consumerTopic == null)
// {
// consumerTopic = new ConsumerTopicVO(topic, groupId);
// addTopic(consumerTopic);
// }
// return consumerTopic;
// }
//
// public Collection<ConsumerTopicVO> getTopics()
// {
// return topics.values();
// }
//
// public int getActiveTopicCount()
// {
// return topics.values().stream()
// .map(t -> t.getAssignedPartitionCount() > 0 ? 1 : 0)
// .reduce(0, Integer::sum);
// }
//
// @Override
// public int compareTo(ConsumerVO that)
// {
// return this.groupId.compareTo(that.groupId);
// }
//
// @Override
// public boolean equals(Object o)
// {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// ConsumerVO vo = (ConsumerVO) o;
//
// if (!groupId.equals(vo.groupId)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode()
// {
// return groupId.hashCode();
// }
//
// }
// Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerLagService.java
import com.homeadvisor.kafdrop.model.ConsumerTopicVO;
import com.homeadvisor.kafdrop.model.ConsumerVO;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.Collections;
package com.homeadvisor.kafdrop.service;
@Service
public class ConsumerLagService
{
private final KafkaMonitor kafkaMonitor;
@Autowired
public ConsumerLagService(CuratorKafkaMonitor kafkaMonitor)
{
this.kafkaMonitor = kafkaMonitor;
}
public Collection<ConsumerTopicVO> computeConsumerGroupLag(String groupId, ConsumerLagReportingOffsetType offsetType)
{
return computeConsumerGroupLag(groupId, offsetType, null);
}
public Collection<ConsumerTopicVO> computeConsumerGroupLag(String groupId, ConsumerLagReportingOffsetType offsetType, String topicId)
{ | final ConsumerVO consumer = kafkaMonitor |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/config/ServiceDiscoveryConfiguration.java | // Path: src/main/java/com/homeadvisor/kafdrop/util/JmxUtils.java
// public abstract class JmxUtils
// {
// public static final String JMX_PORT_PROPERTY = "com.sun.management.jmxremote.port";
//
// public static int getJmxPort(final Environment environment)
// {
// Optional<Integer> jmxPort = Optional.empty();
//
// final Properties managementProperties = Agent.getManagementProperties();
// if (managementProperties != null)
// {
// final String portProperty = managementProperties.getProperty(JMX_PORT_PROPERTY);
// if (portProperty != null)
// {
// final Optional<Integer> port = Optional.ofNullable(Ints.tryParse(portProperty));
// jmxPort = port;
// }
// }
// return jmxPort.orElse(0);
// }
// }
| import com.google.common.base.Throwables;
import com.homeadvisor.kafdrop.util.JmxUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryNTimes;
import org.apache.curator.x.discovery.*;
import org.apache.curator.x.discovery.details.JsonInstanceSerializer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.info.InfoEndpoint;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.context.WebServerApplicationContext;
import org.springframework.boot.web.server.WebServer;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils;
import java.beans.Introspector;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream; | .build();
}
public Map<String, Object> serviceDetails(Integer serverPort)
{
Map<String, Object> details = new LinkedHashMap<>();
Optional.ofNullable(infoEndpoint.info())
.ifPresent(infoMap -> Optional.ofNullable((Map<String, Object>) infoMap.get("build"))
.ifPresent(buildInfo -> {
details.put("serviceName", buildInfo.get("artifact"));
details.put("serviceDescription", buildInfo.get("description"));
details.put("serviceVersion", buildInfo.get("version"));
}));
final String name = (String) details.getOrDefault("serviceName", "kafdrop");
String host = null;
try
{
host = InetAddress.getLocalHost().getHostName();
}
catch (UnknownHostException e)
{
host = "<unknown>";
}
details.put("id", Stream.of(name, host, UUID.randomUUID().toString()).collect(Collectors.joining("_")));
details.put("name", name);
details.put("host", host); | // Path: src/main/java/com/homeadvisor/kafdrop/util/JmxUtils.java
// public abstract class JmxUtils
// {
// public static final String JMX_PORT_PROPERTY = "com.sun.management.jmxremote.port";
//
// public static int getJmxPort(final Environment environment)
// {
// Optional<Integer> jmxPort = Optional.empty();
//
// final Properties managementProperties = Agent.getManagementProperties();
// if (managementProperties != null)
// {
// final String portProperty = managementProperties.getProperty(JMX_PORT_PROPERTY);
// if (portProperty != null)
// {
// final Optional<Integer> port = Optional.ofNullable(Ints.tryParse(portProperty));
// jmxPort = port;
// }
// }
// return jmxPort.orElse(0);
// }
// }
// Path: src/main/java/com/homeadvisor/kafdrop/config/ServiceDiscoveryConfiguration.java
import com.google.common.base.Throwables;
import com.homeadvisor.kafdrop.util.JmxUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryNTimes;
import org.apache.curator.x.discovery.*;
import org.apache.curator.x.discovery.details.JsonInstanceSerializer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.info.InfoEndpoint;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.context.WebServerApplicationContext;
import org.springframework.boot.web.server.WebServer;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils;
import java.beans.Introspector;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
.build();
}
public Map<String, Object> serviceDetails(Integer serverPort)
{
Map<String, Object> details = new LinkedHashMap<>();
Optional.ofNullable(infoEndpoint.info())
.ifPresent(infoMap -> Optional.ofNullable((Map<String, Object>) infoMap.get("build"))
.ifPresent(buildInfo -> {
details.put("serviceName", buildInfo.get("artifact"));
details.put("serviceDescription", buildInfo.get("description"));
details.put("serviceVersion", buildInfo.get("version"));
}));
final String name = (String) details.getOrDefault("serviceName", "kafdrop");
String host = null;
try
{
host = InetAddress.getLocalHost().getHostName();
}
catch (UnknownHostException e)
{
host = "<unknown>";
}
details.put("id", Stream.of(name, host, UUID.randomUUID().toString()).collect(Collectors.joining("_")));
details.put("name", name);
details.put("host", host); | details.put("jmxPort", JmxUtils.getJmxPort(environment)); |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/model/dto/ConsumerTopicDTO.java | // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerPartitionVO.java
// public class ConsumerPartitionVO
// {
// private final String groupId;
// private final String topic;
// private final int partitionId;
// private ConsumerOffsetVO consumerOffset = new ConsumerOffsetVO(-1L , -1L);
// private long size;
// private long firstOffset;
// private String owner;
//
// public ConsumerPartitionVO(String groupId, String topic, int partitionId)
// {
// this.groupId = groupId;
// this.topic = topic;
// this.partitionId = partitionId;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public String getTopic()
// {
// return topic;
// }
//
// public int getPartitionId()
// {
// return partitionId;
// }
//
// public void setConsumerOffset(ConsumerOffsetVO offset)
// {
// this.consumerOffset = offset;
// }
//
// public ConsumerOffsetVO getConsumerOffset()
// {
// return consumerOffset;
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize(long size)
// {
// this.size = size;
// }
//
// public long getFirstOffset()
// {
// return firstOffset;
// }
//
// public void setFirstOffset(long firstOffset)
// {
// this.firstOffset = firstOffset;
// }
//
// public long getLag()
// {
// return getLag(getOffset());
// }
//
// public long getKafkaLag()
// {
// return getLag(getConsumerOffset().getKafkaOffset());
// }
//
// public long getZookeeperLag()
// {
// return getLag(getConsumerOffset().getZookeeperOffset());
// }
//
// private long getLag(long offset)
// {
// if (size < 0 || firstOffset < 0)
// {
// return 0;
// }
// else if (offset < firstOffset)
// {
// return size - firstOffset;
// }
// else
// {
// return size - offset;
// }
// }
//
// public void setOwner(String owner)
// {
// this.owner = owner;
// }
//
// public long getOffset()
// {
// return consumerOffset.getMaxOffset();
// }
//
// public String getOwner()
// {
// return owner;
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerTopicVO.java
// public class ConsumerTopicVO
// {
// private final String topic;
// private final String groupId;
// private final Map<Integer, ConsumerPartitionVO> offsets = new TreeMap<>();
//
// public ConsumerTopicVO(String topic, String groupId)
// {
// this.topic = topic;
// this.groupId = groupId;
// }
//
// public String getTopic()
// {
// return topic;
// }
//
// public void addOffset(ConsumerPartitionVO offset)
// {
// offsets.put(offset.getPartitionId(), offset);
// }
//
// public long getLag()
// {
// return offsets.values().stream()
// .map(ConsumerPartitionVO::getLag)
// .filter(lag -> lag >= 0)
// .reduce(0L, Long::sum);
// }
//
// public long getMaxLag()
// {
// return offsets.values().stream()
// .map(ConsumerPartitionVO::getLag)
// .filter(lag -> lag >= 0)
// .reduce(0L, Long::max);
// }
//
// public Collection<ConsumerPartitionVO> getPartitions()
// {
// return offsets.values();
// }
//
// public ConsumerPartitionVO getPartition(int partitionId)
// {
// return offsets.get(partitionId);
// }
//
// public ConsumerPartitionVO getOrCreatePartition(int partitionId)
// {
// return offsets.computeIfAbsent(partitionId, id -> new ConsumerPartitionVO(groupId, topic, id));
// }
//
// public double getCoveragePercent()
// {
// return (offsets.size() > 0) ? ((double)getAssignedPartitionCount()) / offsets.size() : 0.0;
// }
//
// public int getAssignedPartitionCount()
// {
// return (int) offsets.values().stream()
// .filter(p -> p.getOwner() != null)
// .count();
// }
//
// public int getOwnerCount()
// {
// return (int)offsets.values().stream()
// .map(ConsumerPartitionVO::getOwner)
// .filter(Objects::nonNull)
// .distinct()
// .count();
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerLagReportingOffsetType.java
// public enum ConsumerLagReportingOffsetType
// {
// Kafka("kafka"), Zookeeper("zookeeper"), Both("both"), Minimum("minimum");
//
// private String type;
// private static final Map<String, ConsumerLagReportingOffsetType> typeLookup = new HashMap<>();
//
//
// ConsumerLagReportingOffsetType(String type)
// {
// this.type = type;
// }
//
//
// // Can't override valueOf(), so...use this instead.
// public static ConsumerLagReportingOffsetType enumValue(String type)
// {
// ConsumerLagReportingOffsetType value = typeLookup.get(StringUtils
// .trimToEmpty(type).toLowerCase());
// if (null == value)
// {
// return Minimum;
// }
// return value;
// }
//
// public String getValue()
// {
// return type;
// }
//
// static
// {
// for(ConsumerLagReportingOffsetType env : values())
// {
// typeLookup.put(env.getValue(), env);
// }
// }
// }
| import com.homeadvisor.kafdrop.model.ConsumerPartitionVO;
import com.homeadvisor.kafdrop.model.ConsumerTopicVO;
import com.homeadvisor.kafdrop.service.ConsumerLagReportingOffsetType;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors; | package com.homeadvisor.kafdrop.model.dto;
public class ConsumerTopicDTO extends BaseLagDTO
{
private Map<Integer, ConsumerPartitionDTO> partitions = new HashMap<>();
| // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerPartitionVO.java
// public class ConsumerPartitionVO
// {
// private final String groupId;
// private final String topic;
// private final int partitionId;
// private ConsumerOffsetVO consumerOffset = new ConsumerOffsetVO(-1L , -1L);
// private long size;
// private long firstOffset;
// private String owner;
//
// public ConsumerPartitionVO(String groupId, String topic, int partitionId)
// {
// this.groupId = groupId;
// this.topic = topic;
// this.partitionId = partitionId;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public String getTopic()
// {
// return topic;
// }
//
// public int getPartitionId()
// {
// return partitionId;
// }
//
// public void setConsumerOffset(ConsumerOffsetVO offset)
// {
// this.consumerOffset = offset;
// }
//
// public ConsumerOffsetVO getConsumerOffset()
// {
// return consumerOffset;
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize(long size)
// {
// this.size = size;
// }
//
// public long getFirstOffset()
// {
// return firstOffset;
// }
//
// public void setFirstOffset(long firstOffset)
// {
// this.firstOffset = firstOffset;
// }
//
// public long getLag()
// {
// return getLag(getOffset());
// }
//
// public long getKafkaLag()
// {
// return getLag(getConsumerOffset().getKafkaOffset());
// }
//
// public long getZookeeperLag()
// {
// return getLag(getConsumerOffset().getZookeeperOffset());
// }
//
// private long getLag(long offset)
// {
// if (size < 0 || firstOffset < 0)
// {
// return 0;
// }
// else if (offset < firstOffset)
// {
// return size - firstOffset;
// }
// else
// {
// return size - offset;
// }
// }
//
// public void setOwner(String owner)
// {
// this.owner = owner;
// }
//
// public long getOffset()
// {
// return consumerOffset.getMaxOffset();
// }
//
// public String getOwner()
// {
// return owner;
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerTopicVO.java
// public class ConsumerTopicVO
// {
// private final String topic;
// private final String groupId;
// private final Map<Integer, ConsumerPartitionVO> offsets = new TreeMap<>();
//
// public ConsumerTopicVO(String topic, String groupId)
// {
// this.topic = topic;
// this.groupId = groupId;
// }
//
// public String getTopic()
// {
// return topic;
// }
//
// public void addOffset(ConsumerPartitionVO offset)
// {
// offsets.put(offset.getPartitionId(), offset);
// }
//
// public long getLag()
// {
// return offsets.values().stream()
// .map(ConsumerPartitionVO::getLag)
// .filter(lag -> lag >= 0)
// .reduce(0L, Long::sum);
// }
//
// public long getMaxLag()
// {
// return offsets.values().stream()
// .map(ConsumerPartitionVO::getLag)
// .filter(lag -> lag >= 0)
// .reduce(0L, Long::max);
// }
//
// public Collection<ConsumerPartitionVO> getPartitions()
// {
// return offsets.values();
// }
//
// public ConsumerPartitionVO getPartition(int partitionId)
// {
// return offsets.get(partitionId);
// }
//
// public ConsumerPartitionVO getOrCreatePartition(int partitionId)
// {
// return offsets.computeIfAbsent(partitionId, id -> new ConsumerPartitionVO(groupId, topic, id));
// }
//
// public double getCoveragePercent()
// {
// return (offsets.size() > 0) ? ((double)getAssignedPartitionCount()) / offsets.size() : 0.0;
// }
//
// public int getAssignedPartitionCount()
// {
// return (int) offsets.values().stream()
// .filter(p -> p.getOwner() != null)
// .count();
// }
//
// public int getOwnerCount()
// {
// return (int)offsets.values().stream()
// .map(ConsumerPartitionVO::getOwner)
// .filter(Objects::nonNull)
// .distinct()
// .count();
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerLagReportingOffsetType.java
// public enum ConsumerLagReportingOffsetType
// {
// Kafka("kafka"), Zookeeper("zookeeper"), Both("both"), Minimum("minimum");
//
// private String type;
// private static final Map<String, ConsumerLagReportingOffsetType> typeLookup = new HashMap<>();
//
//
// ConsumerLagReportingOffsetType(String type)
// {
// this.type = type;
// }
//
//
// // Can't override valueOf(), so...use this instead.
// public static ConsumerLagReportingOffsetType enumValue(String type)
// {
// ConsumerLagReportingOffsetType value = typeLookup.get(StringUtils
// .trimToEmpty(type).toLowerCase());
// if (null == value)
// {
// return Minimum;
// }
// return value;
// }
//
// public String getValue()
// {
// return type;
// }
//
// static
// {
// for(ConsumerLagReportingOffsetType env : values())
// {
// typeLookup.put(env.getValue(), env);
// }
// }
// }
// Path: src/main/java/com/homeadvisor/kafdrop/model/dto/ConsumerTopicDTO.java
import com.homeadvisor.kafdrop.model.ConsumerPartitionVO;
import com.homeadvisor.kafdrop.model.ConsumerTopicVO;
import com.homeadvisor.kafdrop.service.ConsumerLagReportingOffsetType;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
package com.homeadvisor.kafdrop.model.dto;
public class ConsumerTopicDTO extends BaseLagDTO
{
private Map<Integer, ConsumerPartitionDTO> partitions = new HashMap<>();
| ConsumerTopicDTO(ConsumerTopicVO topic, ConsumerLagReportingOffsetType offsetType) |
HomeAdvisor/Kafdrop | src/main/java/com/homeadvisor/kafdrop/model/dto/ConsumerTopicDTO.java | // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerPartitionVO.java
// public class ConsumerPartitionVO
// {
// private final String groupId;
// private final String topic;
// private final int partitionId;
// private ConsumerOffsetVO consumerOffset = new ConsumerOffsetVO(-1L , -1L);
// private long size;
// private long firstOffset;
// private String owner;
//
// public ConsumerPartitionVO(String groupId, String topic, int partitionId)
// {
// this.groupId = groupId;
// this.topic = topic;
// this.partitionId = partitionId;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public String getTopic()
// {
// return topic;
// }
//
// public int getPartitionId()
// {
// return partitionId;
// }
//
// public void setConsumerOffset(ConsumerOffsetVO offset)
// {
// this.consumerOffset = offset;
// }
//
// public ConsumerOffsetVO getConsumerOffset()
// {
// return consumerOffset;
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize(long size)
// {
// this.size = size;
// }
//
// public long getFirstOffset()
// {
// return firstOffset;
// }
//
// public void setFirstOffset(long firstOffset)
// {
// this.firstOffset = firstOffset;
// }
//
// public long getLag()
// {
// return getLag(getOffset());
// }
//
// public long getKafkaLag()
// {
// return getLag(getConsumerOffset().getKafkaOffset());
// }
//
// public long getZookeeperLag()
// {
// return getLag(getConsumerOffset().getZookeeperOffset());
// }
//
// private long getLag(long offset)
// {
// if (size < 0 || firstOffset < 0)
// {
// return 0;
// }
// else if (offset < firstOffset)
// {
// return size - firstOffset;
// }
// else
// {
// return size - offset;
// }
// }
//
// public void setOwner(String owner)
// {
// this.owner = owner;
// }
//
// public long getOffset()
// {
// return consumerOffset.getMaxOffset();
// }
//
// public String getOwner()
// {
// return owner;
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerTopicVO.java
// public class ConsumerTopicVO
// {
// private final String topic;
// private final String groupId;
// private final Map<Integer, ConsumerPartitionVO> offsets = new TreeMap<>();
//
// public ConsumerTopicVO(String topic, String groupId)
// {
// this.topic = topic;
// this.groupId = groupId;
// }
//
// public String getTopic()
// {
// return topic;
// }
//
// public void addOffset(ConsumerPartitionVO offset)
// {
// offsets.put(offset.getPartitionId(), offset);
// }
//
// public long getLag()
// {
// return offsets.values().stream()
// .map(ConsumerPartitionVO::getLag)
// .filter(lag -> lag >= 0)
// .reduce(0L, Long::sum);
// }
//
// public long getMaxLag()
// {
// return offsets.values().stream()
// .map(ConsumerPartitionVO::getLag)
// .filter(lag -> lag >= 0)
// .reduce(0L, Long::max);
// }
//
// public Collection<ConsumerPartitionVO> getPartitions()
// {
// return offsets.values();
// }
//
// public ConsumerPartitionVO getPartition(int partitionId)
// {
// return offsets.get(partitionId);
// }
//
// public ConsumerPartitionVO getOrCreatePartition(int partitionId)
// {
// return offsets.computeIfAbsent(partitionId, id -> new ConsumerPartitionVO(groupId, topic, id));
// }
//
// public double getCoveragePercent()
// {
// return (offsets.size() > 0) ? ((double)getAssignedPartitionCount()) / offsets.size() : 0.0;
// }
//
// public int getAssignedPartitionCount()
// {
// return (int) offsets.values().stream()
// .filter(p -> p.getOwner() != null)
// .count();
// }
//
// public int getOwnerCount()
// {
// return (int)offsets.values().stream()
// .map(ConsumerPartitionVO::getOwner)
// .filter(Objects::nonNull)
// .distinct()
// .count();
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerLagReportingOffsetType.java
// public enum ConsumerLagReportingOffsetType
// {
// Kafka("kafka"), Zookeeper("zookeeper"), Both("both"), Minimum("minimum");
//
// private String type;
// private static final Map<String, ConsumerLagReportingOffsetType> typeLookup = new HashMap<>();
//
//
// ConsumerLagReportingOffsetType(String type)
// {
// this.type = type;
// }
//
//
// // Can't override valueOf(), so...use this instead.
// public static ConsumerLagReportingOffsetType enumValue(String type)
// {
// ConsumerLagReportingOffsetType value = typeLookup.get(StringUtils
// .trimToEmpty(type).toLowerCase());
// if (null == value)
// {
// return Minimum;
// }
// return value;
// }
//
// public String getValue()
// {
// return type;
// }
//
// static
// {
// for(ConsumerLagReportingOffsetType env : values())
// {
// typeLookup.put(env.getValue(), env);
// }
// }
// }
| import com.homeadvisor.kafdrop.model.ConsumerPartitionVO;
import com.homeadvisor.kafdrop.model.ConsumerTopicVO;
import com.homeadvisor.kafdrop.service.ConsumerLagReportingOffsetType;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors; | package com.homeadvisor.kafdrop.model.dto;
public class ConsumerTopicDTO extends BaseLagDTO
{
private Map<Integer, ConsumerPartitionDTO> partitions = new HashMap<>();
| // Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerPartitionVO.java
// public class ConsumerPartitionVO
// {
// private final String groupId;
// private final String topic;
// private final int partitionId;
// private ConsumerOffsetVO consumerOffset = new ConsumerOffsetVO(-1L , -1L);
// private long size;
// private long firstOffset;
// private String owner;
//
// public ConsumerPartitionVO(String groupId, String topic, int partitionId)
// {
// this.groupId = groupId;
// this.topic = topic;
// this.partitionId = partitionId;
// }
//
// public String getGroupId()
// {
// return groupId;
// }
//
// public String getTopic()
// {
// return topic;
// }
//
// public int getPartitionId()
// {
// return partitionId;
// }
//
// public void setConsumerOffset(ConsumerOffsetVO offset)
// {
// this.consumerOffset = offset;
// }
//
// public ConsumerOffsetVO getConsumerOffset()
// {
// return consumerOffset;
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize(long size)
// {
// this.size = size;
// }
//
// public long getFirstOffset()
// {
// return firstOffset;
// }
//
// public void setFirstOffset(long firstOffset)
// {
// this.firstOffset = firstOffset;
// }
//
// public long getLag()
// {
// return getLag(getOffset());
// }
//
// public long getKafkaLag()
// {
// return getLag(getConsumerOffset().getKafkaOffset());
// }
//
// public long getZookeeperLag()
// {
// return getLag(getConsumerOffset().getZookeeperOffset());
// }
//
// private long getLag(long offset)
// {
// if (size < 0 || firstOffset < 0)
// {
// return 0;
// }
// else if (offset < firstOffset)
// {
// return size - firstOffset;
// }
// else
// {
// return size - offset;
// }
// }
//
// public void setOwner(String owner)
// {
// this.owner = owner;
// }
//
// public long getOffset()
// {
// return consumerOffset.getMaxOffset();
// }
//
// public String getOwner()
// {
// return owner;
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/model/ConsumerTopicVO.java
// public class ConsumerTopicVO
// {
// private final String topic;
// private final String groupId;
// private final Map<Integer, ConsumerPartitionVO> offsets = new TreeMap<>();
//
// public ConsumerTopicVO(String topic, String groupId)
// {
// this.topic = topic;
// this.groupId = groupId;
// }
//
// public String getTopic()
// {
// return topic;
// }
//
// public void addOffset(ConsumerPartitionVO offset)
// {
// offsets.put(offset.getPartitionId(), offset);
// }
//
// public long getLag()
// {
// return offsets.values().stream()
// .map(ConsumerPartitionVO::getLag)
// .filter(lag -> lag >= 0)
// .reduce(0L, Long::sum);
// }
//
// public long getMaxLag()
// {
// return offsets.values().stream()
// .map(ConsumerPartitionVO::getLag)
// .filter(lag -> lag >= 0)
// .reduce(0L, Long::max);
// }
//
// public Collection<ConsumerPartitionVO> getPartitions()
// {
// return offsets.values();
// }
//
// public ConsumerPartitionVO getPartition(int partitionId)
// {
// return offsets.get(partitionId);
// }
//
// public ConsumerPartitionVO getOrCreatePartition(int partitionId)
// {
// return offsets.computeIfAbsent(partitionId, id -> new ConsumerPartitionVO(groupId, topic, id));
// }
//
// public double getCoveragePercent()
// {
// return (offsets.size() > 0) ? ((double)getAssignedPartitionCount()) / offsets.size() : 0.0;
// }
//
// public int getAssignedPartitionCount()
// {
// return (int) offsets.values().stream()
// .filter(p -> p.getOwner() != null)
// .count();
// }
//
// public int getOwnerCount()
// {
// return (int)offsets.values().stream()
// .map(ConsumerPartitionVO::getOwner)
// .filter(Objects::nonNull)
// .distinct()
// .count();
// }
// }
//
// Path: src/main/java/com/homeadvisor/kafdrop/service/ConsumerLagReportingOffsetType.java
// public enum ConsumerLagReportingOffsetType
// {
// Kafka("kafka"), Zookeeper("zookeeper"), Both("both"), Minimum("minimum");
//
// private String type;
// private static final Map<String, ConsumerLagReportingOffsetType> typeLookup = new HashMap<>();
//
//
// ConsumerLagReportingOffsetType(String type)
// {
// this.type = type;
// }
//
//
// // Can't override valueOf(), so...use this instead.
// public static ConsumerLagReportingOffsetType enumValue(String type)
// {
// ConsumerLagReportingOffsetType value = typeLookup.get(StringUtils
// .trimToEmpty(type).toLowerCase());
// if (null == value)
// {
// return Minimum;
// }
// return value;
// }
//
// public String getValue()
// {
// return type;
// }
//
// static
// {
// for(ConsumerLagReportingOffsetType env : values())
// {
// typeLookup.put(env.getValue(), env);
// }
// }
// }
// Path: src/main/java/com/homeadvisor/kafdrop/model/dto/ConsumerTopicDTO.java
import com.homeadvisor.kafdrop.model.ConsumerPartitionVO;
import com.homeadvisor.kafdrop.model.ConsumerTopicVO;
import com.homeadvisor.kafdrop.service.ConsumerLagReportingOffsetType;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
package com.homeadvisor.kafdrop.model.dto;
public class ConsumerTopicDTO extends BaseLagDTO
{
private Map<Integer, ConsumerPartitionDTO> partitions = new HashMap<>();
| ConsumerTopicDTO(ConsumerTopicVO topic, ConsumerLagReportingOffsetType offsetType) |
popo1379/popomusic | app/src/main/java/com/popomusic/MyApplication.java | // Path: app/src/main/java/com/popomusic/bean/DaoMaster.java
// public class DaoMaster extends AbstractDaoMaster {
// public static final int SCHEMA_VERSION = 1;
//
// /** Creates underlying database table using DAOs. */
// public static void createAllTables(Database db, boolean ifNotExists) {
// MusicBeanDao.createTable(db, ifNotExists);
// SearchNameBeanDao.createTable(db, ifNotExists);
// VideoBeanDao.createTable(db, ifNotExists);
// }
//
// /** Drops underlying database table using DAOs. */
// public static void dropAllTables(Database db, boolean ifExists) {
// MusicBeanDao.dropTable(db, ifExists);
// SearchNameBeanDao.dropTable(db, ifExists);
// VideoBeanDao.dropTable(db, ifExists);
// }
//
// /**
// * WARNING: Drops all table on Upgrade! Use only during development.
// * Convenience method using a {@link DevOpenHelper}.
// */
// public static DaoSession newDevSession(Context context, String name) {
// Database db = new DevOpenHelper(context, name).getWritableDb();
// DaoMaster daoMaster = new DaoMaster(db);
// return daoMaster.newSession();
// }
//
// public DaoMaster(SQLiteDatabase db) {
// this(new StandardDatabase(db));
// }
//
// public DaoMaster(Database db) {
// super(db, SCHEMA_VERSION);
// registerDaoClass(MusicBeanDao.class);
// registerDaoClass(SearchNameBeanDao.class);
// registerDaoClass(VideoBeanDao.class);
// }
//
// public DaoSession newSession() {
// return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
// }
//
// public DaoSession newSession(IdentityScopeType type) {
// return new DaoSession(db, type, daoConfigMap);
// }
//
// /**
// * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} -
// */
// public static abstract class OpenHelper extends DatabaseOpenHelper {
// public OpenHelper(Context context, String name) {
// super(context, name, SCHEMA_VERSION);
// }
//
// public OpenHelper(Context context, String name, CursorFactory factory) {
// super(context, name, factory, SCHEMA_VERSION);
// }
//
// @Override
// public void onCreate(Database db) {
// Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
// createAllTables(db, false);
// }
// }
//
// /** WARNING: Drops all table on Upgrade! Use only during development. */
// public static class DevOpenHelper extends OpenHelper {
// public DevOpenHelper(Context context, String name) {
// super(context, name);
// }
//
// public DevOpenHelper(Context context, String name, CursorFactory factory) {
// super(context, name, factory);
// }
//
// @Override
// public void onUpgrade(Database db, int oldVersion, int newVersion) {
// Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
// dropAllTables(db, true);
// onCreate(db);
// }
// }
//
// }
//
// Path: app/src/main/java/com/popomusic/bean/DaoSession.java
// public class DaoSession extends AbstractDaoSession {
//
// private final DaoConfig musicBeanDaoConfig;
// private final DaoConfig searchNameBeanDaoConfig;
// private final DaoConfig videoBeanDaoConfig;
//
// private final MusicBeanDao musicBeanDao;
// private final SearchNameBeanDao searchNameBeanDao;
// private final VideoBeanDao videoBeanDao;
//
// public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
// daoConfigMap) {
// super(db);
//
// musicBeanDaoConfig = daoConfigMap.get(MusicBeanDao.class).clone();
// musicBeanDaoConfig.initIdentityScope(type);
//
// searchNameBeanDaoConfig = daoConfigMap.get(SearchNameBeanDao.class).clone();
// searchNameBeanDaoConfig.initIdentityScope(type);
//
// videoBeanDaoConfig = daoConfigMap.get(VideoBeanDao.class).clone();
// videoBeanDaoConfig.initIdentityScope(type);
//
// musicBeanDao = new MusicBeanDao(musicBeanDaoConfig, this);
// searchNameBeanDao = new SearchNameBeanDao(searchNameBeanDaoConfig, this);
// videoBeanDao = new VideoBeanDao(videoBeanDaoConfig, this);
//
// registerDao(MusicBean.class, musicBeanDao);
// registerDao(SearchNameBean.class, searchNameBeanDao);
// registerDao(VideoBean.class, videoBeanDao);
// }
//
// public void clear() {
// musicBeanDaoConfig.clearIdentityScope();
// searchNameBeanDaoConfig.clearIdentityScope();
// videoBeanDaoConfig.clearIdentityScope();
// }
//
// public MusicBeanDao getMusicBeanDao() {
// return musicBeanDao;
// }
//
// public SearchNameBeanDao getSearchNameBeanDao() {
// return searchNameBeanDao;
// }
//
// public VideoBeanDao getVideoBeanDao() {
// return videoBeanDao;
// }
//
// }
| import android.app.Application;
import android.content.Context;
import com.liulishuo.filedownloader.FileDownloader;
import com.popomusic.bean.DaoMaster;
import com.popomusic.bean.DaoSession;
import org.greenrobot.greendao.database.Database; | package com.popomusic;
/**
* Created by popo on 2017/4/6 0006.
*/
public class MyApplication extends Application {
public static DaoSession mDaoSession;
public static DaoSession searchDaoSession;
public static DaoSession videoDaoSession;
public static Context mContext;
// private static RefWatcher mRefWatcher;
@Override
public void onCreate() {
super.onCreate();
this.mContext = this.getApplicationContext();
initGreenDao();
initdown();
}
//初始化数据库
private void initGreenDao() { | // Path: app/src/main/java/com/popomusic/bean/DaoMaster.java
// public class DaoMaster extends AbstractDaoMaster {
// public static final int SCHEMA_VERSION = 1;
//
// /** Creates underlying database table using DAOs. */
// public static void createAllTables(Database db, boolean ifNotExists) {
// MusicBeanDao.createTable(db, ifNotExists);
// SearchNameBeanDao.createTable(db, ifNotExists);
// VideoBeanDao.createTable(db, ifNotExists);
// }
//
// /** Drops underlying database table using DAOs. */
// public static void dropAllTables(Database db, boolean ifExists) {
// MusicBeanDao.dropTable(db, ifExists);
// SearchNameBeanDao.dropTable(db, ifExists);
// VideoBeanDao.dropTable(db, ifExists);
// }
//
// /**
// * WARNING: Drops all table on Upgrade! Use only during development.
// * Convenience method using a {@link DevOpenHelper}.
// */
// public static DaoSession newDevSession(Context context, String name) {
// Database db = new DevOpenHelper(context, name).getWritableDb();
// DaoMaster daoMaster = new DaoMaster(db);
// return daoMaster.newSession();
// }
//
// public DaoMaster(SQLiteDatabase db) {
// this(new StandardDatabase(db));
// }
//
// public DaoMaster(Database db) {
// super(db, SCHEMA_VERSION);
// registerDaoClass(MusicBeanDao.class);
// registerDaoClass(SearchNameBeanDao.class);
// registerDaoClass(VideoBeanDao.class);
// }
//
// public DaoSession newSession() {
// return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
// }
//
// public DaoSession newSession(IdentityScopeType type) {
// return new DaoSession(db, type, daoConfigMap);
// }
//
// /**
// * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} -
// */
// public static abstract class OpenHelper extends DatabaseOpenHelper {
// public OpenHelper(Context context, String name) {
// super(context, name, SCHEMA_VERSION);
// }
//
// public OpenHelper(Context context, String name, CursorFactory factory) {
// super(context, name, factory, SCHEMA_VERSION);
// }
//
// @Override
// public void onCreate(Database db) {
// Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
// createAllTables(db, false);
// }
// }
//
// /** WARNING: Drops all table on Upgrade! Use only during development. */
// public static class DevOpenHelper extends OpenHelper {
// public DevOpenHelper(Context context, String name) {
// super(context, name);
// }
//
// public DevOpenHelper(Context context, String name, CursorFactory factory) {
// super(context, name, factory);
// }
//
// @Override
// public void onUpgrade(Database db, int oldVersion, int newVersion) {
// Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
// dropAllTables(db, true);
// onCreate(db);
// }
// }
//
// }
//
// Path: app/src/main/java/com/popomusic/bean/DaoSession.java
// public class DaoSession extends AbstractDaoSession {
//
// private final DaoConfig musicBeanDaoConfig;
// private final DaoConfig searchNameBeanDaoConfig;
// private final DaoConfig videoBeanDaoConfig;
//
// private final MusicBeanDao musicBeanDao;
// private final SearchNameBeanDao searchNameBeanDao;
// private final VideoBeanDao videoBeanDao;
//
// public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
// daoConfigMap) {
// super(db);
//
// musicBeanDaoConfig = daoConfigMap.get(MusicBeanDao.class).clone();
// musicBeanDaoConfig.initIdentityScope(type);
//
// searchNameBeanDaoConfig = daoConfigMap.get(SearchNameBeanDao.class).clone();
// searchNameBeanDaoConfig.initIdentityScope(type);
//
// videoBeanDaoConfig = daoConfigMap.get(VideoBeanDao.class).clone();
// videoBeanDaoConfig.initIdentityScope(type);
//
// musicBeanDao = new MusicBeanDao(musicBeanDaoConfig, this);
// searchNameBeanDao = new SearchNameBeanDao(searchNameBeanDaoConfig, this);
// videoBeanDao = new VideoBeanDao(videoBeanDaoConfig, this);
//
// registerDao(MusicBean.class, musicBeanDao);
// registerDao(SearchNameBean.class, searchNameBeanDao);
// registerDao(VideoBean.class, videoBeanDao);
// }
//
// public void clear() {
// musicBeanDaoConfig.clearIdentityScope();
// searchNameBeanDaoConfig.clearIdentityScope();
// videoBeanDaoConfig.clearIdentityScope();
// }
//
// public MusicBeanDao getMusicBeanDao() {
// return musicBeanDao;
// }
//
// public SearchNameBeanDao getSearchNameBeanDao() {
// return searchNameBeanDao;
// }
//
// public VideoBeanDao getVideoBeanDao() {
// return videoBeanDao;
// }
//
// }
// Path: app/src/main/java/com/popomusic/MyApplication.java
import android.app.Application;
import android.content.Context;
import com.liulishuo.filedownloader.FileDownloader;
import com.popomusic.bean.DaoMaster;
import com.popomusic.bean.DaoSession;
import org.greenrobot.greendao.database.Database;
package com.popomusic;
/**
* Created by popo on 2017/4/6 0006.
*/
public class MyApplication extends Application {
public static DaoSession mDaoSession;
public static DaoSession searchDaoSession;
public static DaoSession videoDaoSession;
public static Context mContext;
// private static RefWatcher mRefWatcher;
@Override
public void onCreate() {
super.onCreate();
this.mContext = this.getApplicationContext();
initGreenDao();
initdown();
}
//初始化数据库
private void initGreenDao() { | DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this,"music_db",null); |
popo1379/popomusic | app/src/main/java/com/popomusic/api/PicApi.java | // Path: app/src/main/java/com/popomusic/picBean/Example.java
// public class Example {
//
// @SerializedName("showapi_res_code")
// @Expose
// private Integer showapiResCode;
// @SerializedName("showapi_res_error")
// @Expose
// private String showapiResError;
// @SerializedName("showapi_res_body")
// @Expose
// private ShowapiResBody showapiResBody;
//
// public Integer getShowapiResCode() {
// return showapiResCode;
// }
//
// public void setShowapiResCode(Integer showapiResCode) {
// this.showapiResCode = showapiResCode;
// }
//
// public String getShowapiResError() {
// return showapiResError;
// }
//
// public void setShowapiResError(String showapiResError) {
// this.showapiResError = showapiResError;
// }
//
// public ShowapiResBody getShowapiResBody() {
// return showapiResBody;
// }
//
// public void setShowapiResBody(ShowapiResBody showapiResBody) {
// this.showapiResBody = showapiResBody;
// }
// }
| import com.popomusic.picBean.Example;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Query; | package com.popomusic.api;
/**
* Created by Administrator on 2017/5/31 0031.
*/
public interface PicApi {
@GET("852-2") | // Path: app/src/main/java/com/popomusic/picBean/Example.java
// public class Example {
//
// @SerializedName("showapi_res_code")
// @Expose
// private Integer showapiResCode;
// @SerializedName("showapi_res_error")
// @Expose
// private String showapiResError;
// @SerializedName("showapi_res_body")
// @Expose
// private ShowapiResBody showapiResBody;
//
// public Integer getShowapiResCode() {
// return showapiResCode;
// }
//
// public void setShowapiResCode(Integer showapiResCode) {
// this.showapiResCode = showapiResCode;
// }
//
// public String getShowapiResError() {
// return showapiResError;
// }
//
// public void setShowapiResError(String showapiResError) {
// this.showapiResError = showapiResError;
// }
//
// public ShowapiResBody getShowapiResBody() {
// return showapiResBody;
// }
//
// public void setShowapiResBody(ShowapiResBody showapiResBody) {
// this.showapiResBody = showapiResBody;
// }
// }
// Path: app/src/main/java/com/popomusic/api/PicApi.java
import com.popomusic.picBean.Example;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Query;
package com.popomusic.api;
/**
* Created by Administrator on 2017/5/31 0031.
*/
public interface PicApi {
@GET("852-2") | Observable<Example> |
popo1379/popomusic | app/src/main/java/com/popomusic/activity/BaseActivity.java | // Path: app/src/main/java/com/popomusic/util/UIcollector.java
// @SuppressWarnings("ALL")
// public class UIcollector {
//
//
// public static Context getContext() {
// return BaseActivity.getContext();
// }
//
// public static Activity getActivity() {
// return BaseActivity.getActivity();
// }
//
//
// public static Drawable getDrawable(int id) {
// return getContext().getResources().getDrawable(id);
// }
//
// public static int getColor(int id) {
// return getContext().getResources().getColor(id);
// }
//
// public static String getString(int id) {
// return getContext().getResources().getString(id);
// }
//
//
// public static String[] getStringArray(int id) {
// return getContext().getResources().getStringArray(id);
// }
// }
| import android.app.Activity;
import android.content.Context;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;
import com.popomusic.util.UIcollector;
import butterknife.ButterKnife; | package com.popomusic.activity;
/**
* Created by popo1379 on 2017/4/6 0006.
*/
public abstract class BaseActivity extends AppCompatActivity {
private static Context context;
private static Activity activity;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
init(savedInstanceState);//初始化view之前,进行的操作
super.onCreate(savedInstanceState);
setContentView(setLayoutResourceID());
context = getApplicationContext();
activity = this;
ButterKnife.bind(this);
initView();
initListener();
initData();
}
public void init(Bundle savedInstanceState){}
public abstract int setLayoutResourceID();
public abstract void initView();
public void initListener(){}
public abstract void initData();
public static Context getContext() {
return context;
}
public static Activity getActivity() {
return activity;
}
void Toast(String content) { | // Path: app/src/main/java/com/popomusic/util/UIcollector.java
// @SuppressWarnings("ALL")
// public class UIcollector {
//
//
// public static Context getContext() {
// return BaseActivity.getContext();
// }
//
// public static Activity getActivity() {
// return BaseActivity.getActivity();
// }
//
//
// public static Drawable getDrawable(int id) {
// return getContext().getResources().getDrawable(id);
// }
//
// public static int getColor(int id) {
// return getContext().getResources().getColor(id);
// }
//
// public static String getString(int id) {
// return getContext().getResources().getString(id);
// }
//
//
// public static String[] getStringArray(int id) {
// return getContext().getResources().getStringArray(id);
// }
// }
// Path: app/src/main/java/com/popomusic/activity/BaseActivity.java
import android.app.Activity;
import android.content.Context;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;
import com.popomusic.util.UIcollector;
import butterknife.ButterKnife;
package com.popomusic.activity;
/**
* Created by popo1379 on 2017/4/6 0006.
*/
public abstract class BaseActivity extends AppCompatActivity {
private static Context context;
private static Activity activity;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
init(savedInstanceState);//初始化view之前,进行的操作
super.onCreate(savedInstanceState);
setContentView(setLayoutResourceID());
context = getApplicationContext();
activity = this;
ButterKnife.bind(this);
initView();
initListener();
initData();
}
public void init(Bundle savedInstanceState){}
public abstract int setLayoutResourceID();
public abstract void initView();
public void initListener(){}
public abstract void initData();
public static Context getContext() {
return context;
}
public static Activity getActivity() {
return activity;
}
void Toast(String content) { | Toast.makeText(UIcollector.getContext(), content, Toast.LENGTH_LONG).show(); |
popo1379/popomusic | app/src/main/java/com/popomusic/adapter/SearchAdapter.java | // Path: app/src/main/java/com/popomusic/bean/SearchBean.java
// public class SearchBean extends BaseBean{
//
// /**
// * m4a : http://ws.stream.qqmusic.qq.com/108554761.m4a?fromtag=46
// * media_mid : 002WyF5y4Rk1jW
// * songid : 108554761
// * singerid : 6370
// * albumname : 蒙面唱将猜猜猜 第1期
// * downUrl : http://dl.stream.qqmusic.qq.com/108554761.mp3?vkey=36792B0E9B4D62913A85D2340FFBFADF66CF898EC1BB6672EFBB1718ED537262CFB6AADC08B4DD6A448C0305D14434E0EC1DDB9942591186&guid=2718671044
// * singername : 谭晶
// * songname : 海阔天空 (Live)
// * strMediaMid : 002WyF5y4Rk1jW
// * albummid : 001LjNh61tMDJ1
// * songmid : 002WyF5y4Rk1jW
// * albumpic_big : http://i.gtimg.cn/music/photo/mid_album_300/J/1/001LjNh61tMDJ1.jpg
// * albumpic_small : http://i.gtimg.cn/music/photo/mid_album_90/J/1/001LjNh61tMDJ1.jpg
// * albumid : 1608672
// */
//
// private String m4a;
// private String media_mid;
// private int songid;
// private int singerid;
// private String albumname;
// private String downUrl;
// private String singername;
// private String songname;
// private String strMediaMid;
// private String albummid;
// private String songmid;
// private String albumpic_big;
// private String albumpic_small;
// private int albumid;
//
// public String getM4a() {
// return m4a;
// }
//
// public void setM4a(String m4a) {
// this.m4a = m4a;
// }
//
// public String getMedia_mid() {
// return media_mid;
// }
//
// public void setMedia_mid(String media_mid) {
// this.media_mid = media_mid;
// }
//
// public int getSongid() {
// return songid;
// }
//
// public void setSongid(int songid) {
// this.songid = songid;
// }
//
// public int getSingerid() {
// return singerid;
// }
//
// public void setSingerid(int singerid) {
// this.singerid = singerid;
// }
//
// public String getAlbumname() {
// return albumname;
// }
//
// public void setAlbumname(String albumname) {
// this.albumname = albumname;
// }
//
// public String getDownUrl() {
// return downUrl;
// }
//
// public void setDownUrl(String downUrl) {
// this.downUrl = downUrl;
// }
//
// public String getSingername() {
// return singername;
// }
//
// public void setSingername(String singername) {
// this.singername = singername;
// }
//
// public String getSongname() {
// return songname;
// }
//
// public void setSongname(String songname) {
// this.songname = songname;
// }
//
// public String getStrMediaMid() {
// return strMediaMid;
// }
//
// public void setStrMediaMid(String strMediaMid) {
// this.strMediaMid = strMediaMid;
// }
//
// public String getAlbummid() {
// return albummid;
// }
//
// public void setAlbummid(String albummid) {
// this.albummid = albummid;
// }
//
// public String getSongmid() {
// return songmid;
// }
//
// public void setSongmid(String songmid) {
// this.songmid = songmid;
// }
//
// public String getAlbumpic_big() {
// return albumpic_big;
// }
//
// public void setAlbumpic_big(String albumpic_big) {
// this.albumpic_big = albumpic_big;
// }
//
// public String getAlbumpic_small() {
// return albumpic_small;
// }
//
// public void setAlbumpic_small(String albumpic_small) {
// this.albumpic_small = albumpic_small;
// }
//
// public int getAlbumid() {
// return albumid;
// }
//
// public void setAlbumid(int albumid) {
// this.albumid = albumid;
// }
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.popo.popomusic.R;
import com.popomusic.bean.SearchBean;
import java.util.List; | package com.popomusic.adapter;
/**
* Created by dingmouren on 2017/2/10.
*/
public class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.ViewHolder> {
private static final String TAG = SearchAdapter.class.getName();
private Context mContext; | // Path: app/src/main/java/com/popomusic/bean/SearchBean.java
// public class SearchBean extends BaseBean{
//
// /**
// * m4a : http://ws.stream.qqmusic.qq.com/108554761.m4a?fromtag=46
// * media_mid : 002WyF5y4Rk1jW
// * songid : 108554761
// * singerid : 6370
// * albumname : 蒙面唱将猜猜猜 第1期
// * downUrl : http://dl.stream.qqmusic.qq.com/108554761.mp3?vkey=36792B0E9B4D62913A85D2340FFBFADF66CF898EC1BB6672EFBB1718ED537262CFB6AADC08B4DD6A448C0305D14434E0EC1DDB9942591186&guid=2718671044
// * singername : 谭晶
// * songname : 海阔天空 (Live)
// * strMediaMid : 002WyF5y4Rk1jW
// * albummid : 001LjNh61tMDJ1
// * songmid : 002WyF5y4Rk1jW
// * albumpic_big : http://i.gtimg.cn/music/photo/mid_album_300/J/1/001LjNh61tMDJ1.jpg
// * albumpic_small : http://i.gtimg.cn/music/photo/mid_album_90/J/1/001LjNh61tMDJ1.jpg
// * albumid : 1608672
// */
//
// private String m4a;
// private String media_mid;
// private int songid;
// private int singerid;
// private String albumname;
// private String downUrl;
// private String singername;
// private String songname;
// private String strMediaMid;
// private String albummid;
// private String songmid;
// private String albumpic_big;
// private String albumpic_small;
// private int albumid;
//
// public String getM4a() {
// return m4a;
// }
//
// public void setM4a(String m4a) {
// this.m4a = m4a;
// }
//
// public String getMedia_mid() {
// return media_mid;
// }
//
// public void setMedia_mid(String media_mid) {
// this.media_mid = media_mid;
// }
//
// public int getSongid() {
// return songid;
// }
//
// public void setSongid(int songid) {
// this.songid = songid;
// }
//
// public int getSingerid() {
// return singerid;
// }
//
// public void setSingerid(int singerid) {
// this.singerid = singerid;
// }
//
// public String getAlbumname() {
// return albumname;
// }
//
// public void setAlbumname(String albumname) {
// this.albumname = albumname;
// }
//
// public String getDownUrl() {
// return downUrl;
// }
//
// public void setDownUrl(String downUrl) {
// this.downUrl = downUrl;
// }
//
// public String getSingername() {
// return singername;
// }
//
// public void setSingername(String singername) {
// this.singername = singername;
// }
//
// public String getSongname() {
// return songname;
// }
//
// public void setSongname(String songname) {
// this.songname = songname;
// }
//
// public String getStrMediaMid() {
// return strMediaMid;
// }
//
// public void setStrMediaMid(String strMediaMid) {
// this.strMediaMid = strMediaMid;
// }
//
// public String getAlbummid() {
// return albummid;
// }
//
// public void setAlbummid(String albummid) {
// this.albummid = albummid;
// }
//
// public String getSongmid() {
// return songmid;
// }
//
// public void setSongmid(String songmid) {
// this.songmid = songmid;
// }
//
// public String getAlbumpic_big() {
// return albumpic_big;
// }
//
// public void setAlbumpic_big(String albumpic_big) {
// this.albumpic_big = albumpic_big;
// }
//
// public String getAlbumpic_small() {
// return albumpic_small;
// }
//
// public void setAlbumpic_small(String albumpic_small) {
// this.albumpic_small = albumpic_small;
// }
//
// public int getAlbumid() {
// return albumid;
// }
//
// public void setAlbumid(int albumid) {
// this.albumid = albumid;
// }
// }
// Path: app/src/main/java/com/popomusic/adapter/SearchAdapter.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.popo.popomusic.R;
import com.popomusic.bean.SearchBean;
import java.util.List;
package com.popomusic.adapter;
/**
* Created by dingmouren on 2017/2/10.
*/
public class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.ViewHolder> {
private static final String TAG = SearchAdapter.class.getName();
private Context mContext; | private List<SearchBean> mList; |
popo1379/popomusic | app/src/main/java/com/popomusic/api/VideoApi.java | // Path: app/src/main/java/com/popomusic/videoModel/Find.java
// public class Find {
//
// public CategoryInfo categoryInfo;
// public List<SectionList> sectionList;
//
// }
//
// Path: app/src/main/java/com/popomusic/videoModel/Interesting.java
// public class Interesting {
//
// public List<ItemList> itemList;
//
// }
| import com.popomusic.videoModel.Find;
import com.popomusic.videoModel.Interesting;
import io.reactivex.Flowable;
import retrofit2.http.GET;
import retrofit2.http.Query; | package com.popomusic.api;
/**
* Created by kaiyan on 2017/5/20 0020.
*/
public interface VideoApi {
@GET("v3/videos?num=10") | // Path: app/src/main/java/com/popomusic/videoModel/Find.java
// public class Find {
//
// public CategoryInfo categoryInfo;
// public List<SectionList> sectionList;
//
// }
//
// Path: app/src/main/java/com/popomusic/videoModel/Interesting.java
// public class Interesting {
//
// public List<ItemList> itemList;
//
// }
// Path: app/src/main/java/com/popomusic/api/VideoApi.java
import com.popomusic.videoModel.Find;
import com.popomusic.videoModel.Interesting;
import io.reactivex.Flowable;
import retrofit2.http.GET;
import retrofit2.http.Query;
package com.popomusic.api;
/**
* Created by kaiyan on 2017/5/20 0020.
*/
public interface VideoApi {
@GET("v3/videos?num=10") | Flowable<Interesting> getInteresting( |
popo1379/popomusic | app/src/main/java/com/popomusic/api/VideoApi.java | // Path: app/src/main/java/com/popomusic/videoModel/Find.java
// public class Find {
//
// public CategoryInfo categoryInfo;
// public List<SectionList> sectionList;
//
// }
//
// Path: app/src/main/java/com/popomusic/videoModel/Interesting.java
// public class Interesting {
//
// public List<ItemList> itemList;
//
// }
| import com.popomusic.videoModel.Find;
import com.popomusic.videoModel.Interesting;
import io.reactivex.Flowable;
import retrofit2.http.GET;
import retrofit2.http.Query; | package com.popomusic.api;
/**
* Created by kaiyan on 2017/5/20 0020.
*/
public interface VideoApi {
@GET("v3/videos?num=10")
Flowable<Interesting> getInteresting(
@Query("start") int start, @Query("categoryId") int categoryId,
@Query("strategy") String strategy);
@GET("v3/tag/videos")
Flowable<Interesting> related(
@Query("start") int start, @Query("tagId") int id,
@Query("strategy") String strategy);
@GET("v3/pgc/videos")
Flowable<Interesting> relatedHeader(
@Query("start") int start, @Query("pgcId") int id,
@Query("strategy") String strategy);
@GET("v3/categories/detail") | // Path: app/src/main/java/com/popomusic/videoModel/Find.java
// public class Find {
//
// public CategoryInfo categoryInfo;
// public List<SectionList> sectionList;
//
// }
//
// Path: app/src/main/java/com/popomusic/videoModel/Interesting.java
// public class Interesting {
//
// public List<ItemList> itemList;
//
// }
// Path: app/src/main/java/com/popomusic/api/VideoApi.java
import com.popomusic.videoModel.Find;
import com.popomusic.videoModel.Interesting;
import io.reactivex.Flowable;
import retrofit2.http.GET;
import retrofit2.http.Query;
package com.popomusic.api;
/**
* Created by kaiyan on 2017/5/20 0020.
*/
public interface VideoApi {
@GET("v3/videos?num=10")
Flowable<Interesting> getInteresting(
@Query("start") int start, @Query("categoryId") int categoryId,
@Query("strategy") String strategy);
@GET("v3/tag/videos")
Flowable<Interesting> related(
@Query("start") int start, @Query("tagId") int id,
@Query("strategy") String strategy);
@GET("v3/pgc/videos")
Flowable<Interesting> relatedHeader(
@Query("start") int start, @Query("pgcId") int id,
@Query("strategy") String strategy);
@GET("v3/categories/detail") | Flowable<Find> findVideo(@Query("id") int id); |
popo1379/popomusic | app/src/main/java/com/popomusic/ui/ViewPagerIndicate.java | // Path: app/src/main/java/com/popomusic/fragment/VideoPagerFragment.java
// public class VideoPagerFragment extends BaseFragment implements VideoData.View,SwipeRefreshLayout.OnRefreshListener{
// VideoAdapter videoadapter;
// private static int id=34;
// protected boolean isNull = false;
//
// @BindView(R.id.list)
// RecyclerView listView;
// @BindView(R.id.indicate)
// ViewPagerIndicate tabPageIndicator;
// VideoPresenter mPresent;
// @BindView(R.id.srf_layout)
// SwipeRefreshLayout srfLayout;
//
// @Override
// protected View initView() {
// view = View.inflate(UIcollector.getActivity(), R.layout.fragment_video_pager, null);
// return view;
// }
// @Override
// protected void initData() {
// listView.setHasFixedSize(true);
// listView.setLayoutManager(new StaggeredGridLayoutManager(1, LinearLayoutManager.VERTICAL));
// List<ItemList> lists=new ArrayList<ItemList>();
// initViewPagerIndicate();
// mPresent=new VideoPresenter((VideoData.View) this);
// videoadapter=new VideoAdapter(lists);
// listView.setAdapter(videoadapter);
//
// srfLayout.setOnRefreshListener(this);
// srfLayout.post(() -> onRefresh());
// }
// @Override
// public void setData(List<ItemList>list){
// if (list.isEmpty()) {
// isNull = true;
// }else {
// LogUtils.d("VideoPagerFragment","数据测试"+list.get(0).data.playUrl);
// videoadapter.addAll(list);
// }
//
// }
// @Override
// public void onRefresh() {
// videoadapter.removeAll();
// mPresent.requestData(id);
// LogUtils.d("VideoPagerFragment-刷新","id="+id);
// }
// //刷新开关:开
// @Override
// public void showProgress() {
// if (!srfLayout.isRefreshing()) {
// srfLayout.setRefreshing(true);
// }
// }
//
// //刷新开关:关
// @Override
// public void hideProgress() {
// if (srfLayout.isRefreshing()) {
// srfLayout.setRefreshing(false);
// }
// }
//
// //初始化顶部滑动
// private void initViewPagerIndicate() {
// int[] mTextColors = {0xFFA0A0A0, 0xFF000000};
// int mUnderlineColor = 0xFF168EFF;
// String[] mTitles = new String[] {
// "锦集", "搞笑", "游戏", "科普","萌宠","生活","音乐","综艺","预告","广告","记录","剧情"
// };
// tabPageIndicator.resetText(R.layout.viewpagerindicate_item, mTitles, mTextColors);
// //设置下划线粗细和颜色
// tabPageIndicator.resetUnderline(4, mUnderlineColor);
// //设置初始化完成
// tabPageIndicator.setOk();
// }
//
// public void indicateClickEvent(int pos){
// switch (pos){
// case 0:
// this.id=34;
// break;
// case 1:
// this.id=28;
//
// break;
// case 2:
// this.id=30;
// break;
// case 3:
// this.id=32;
// break;
// case 4:
// this.id=26;
// break;
// case 5:
// id = 36;
// break;
// case 6:
// this.id=20;
// break;
// case 7:
// this.id=38;
// break;
// case 8:
// this.id=8;
// break;
// case 9:
// this.id=14;
// break;
// case 10:
// this.id=22;
// break;
// case 11:
// this.id=12;
// break;
// }
// LogUtils.d("VideoFragment","+选择的id:"+id);
//
// }
//
// public void onDestroy() {
// super.onDestroy();
// JCVideoPlayer.releaseAllVideos();
// }
// }
| import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.popomusic.fragment.VideoPagerFragment;
import java.util.ArrayList; | package com.popomusic.ui;
/**
* Created by Administrator on 2017/2/10 0010.
* 因需求将该控件简单修改,不再服务ViewPager
*/
public class ViewPagerIndicate extends HorizontalScrollView implements View.OnClickListener {
private Context mContext;
private LayoutInflater mInflater;
private ViewPager mViewPager;
//onMeasure是否准备完成
private boolean isMeasureOk;
//是否可以绘制下划线
private boolean isDrawOK;
//HorizontalScrollView只能有1个子View(这里用线性布局)
private LinearLayout mWapper;
//标签
private ArrayList<TextView> mTextViews;
//标签正常颜色和高亮颜色
private int mTextNormalColor, mTextHighlightColor;
//总宽度
private int mTotalWidth;
//1个标签的宽和高
private int mTabWidth, mTabHeight;
private Paint mPaint;
//下划线的位置
private float mTranslateX;
| // Path: app/src/main/java/com/popomusic/fragment/VideoPagerFragment.java
// public class VideoPagerFragment extends BaseFragment implements VideoData.View,SwipeRefreshLayout.OnRefreshListener{
// VideoAdapter videoadapter;
// private static int id=34;
// protected boolean isNull = false;
//
// @BindView(R.id.list)
// RecyclerView listView;
// @BindView(R.id.indicate)
// ViewPagerIndicate tabPageIndicator;
// VideoPresenter mPresent;
// @BindView(R.id.srf_layout)
// SwipeRefreshLayout srfLayout;
//
// @Override
// protected View initView() {
// view = View.inflate(UIcollector.getActivity(), R.layout.fragment_video_pager, null);
// return view;
// }
// @Override
// protected void initData() {
// listView.setHasFixedSize(true);
// listView.setLayoutManager(new StaggeredGridLayoutManager(1, LinearLayoutManager.VERTICAL));
// List<ItemList> lists=new ArrayList<ItemList>();
// initViewPagerIndicate();
// mPresent=new VideoPresenter((VideoData.View) this);
// videoadapter=new VideoAdapter(lists);
// listView.setAdapter(videoadapter);
//
// srfLayout.setOnRefreshListener(this);
// srfLayout.post(() -> onRefresh());
// }
// @Override
// public void setData(List<ItemList>list){
// if (list.isEmpty()) {
// isNull = true;
// }else {
// LogUtils.d("VideoPagerFragment","数据测试"+list.get(0).data.playUrl);
// videoadapter.addAll(list);
// }
//
// }
// @Override
// public void onRefresh() {
// videoadapter.removeAll();
// mPresent.requestData(id);
// LogUtils.d("VideoPagerFragment-刷新","id="+id);
// }
// //刷新开关:开
// @Override
// public void showProgress() {
// if (!srfLayout.isRefreshing()) {
// srfLayout.setRefreshing(true);
// }
// }
//
// //刷新开关:关
// @Override
// public void hideProgress() {
// if (srfLayout.isRefreshing()) {
// srfLayout.setRefreshing(false);
// }
// }
//
// //初始化顶部滑动
// private void initViewPagerIndicate() {
// int[] mTextColors = {0xFFA0A0A0, 0xFF000000};
// int mUnderlineColor = 0xFF168EFF;
// String[] mTitles = new String[] {
// "锦集", "搞笑", "游戏", "科普","萌宠","生活","音乐","综艺","预告","广告","记录","剧情"
// };
// tabPageIndicator.resetText(R.layout.viewpagerindicate_item, mTitles, mTextColors);
// //设置下划线粗细和颜色
// tabPageIndicator.resetUnderline(4, mUnderlineColor);
// //设置初始化完成
// tabPageIndicator.setOk();
// }
//
// public void indicateClickEvent(int pos){
// switch (pos){
// case 0:
// this.id=34;
// break;
// case 1:
// this.id=28;
//
// break;
// case 2:
// this.id=30;
// break;
// case 3:
// this.id=32;
// break;
// case 4:
// this.id=26;
// break;
// case 5:
// id = 36;
// break;
// case 6:
// this.id=20;
// break;
// case 7:
// this.id=38;
// break;
// case 8:
// this.id=8;
// break;
// case 9:
// this.id=14;
// break;
// case 10:
// this.id=22;
// break;
// case 11:
// this.id=12;
// break;
// }
// LogUtils.d("VideoFragment","+选择的id:"+id);
//
// }
//
// public void onDestroy() {
// super.onDestroy();
// JCVideoPlayer.releaseAllVideos();
// }
// }
// Path: app/src/main/java/com/popomusic/ui/ViewPagerIndicate.java
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.popomusic.fragment.VideoPagerFragment;
import java.util.ArrayList;
package com.popomusic.ui;
/**
* Created by Administrator on 2017/2/10 0010.
* 因需求将该控件简单修改,不再服务ViewPager
*/
public class ViewPagerIndicate extends HorizontalScrollView implements View.OnClickListener {
private Context mContext;
private LayoutInflater mInflater;
private ViewPager mViewPager;
//onMeasure是否准备完成
private boolean isMeasureOk;
//是否可以绘制下划线
private boolean isDrawOK;
//HorizontalScrollView只能有1个子View(这里用线性布局)
private LinearLayout mWapper;
//标签
private ArrayList<TextView> mTextViews;
//标签正常颜色和高亮颜色
private int mTextNormalColor, mTextHighlightColor;
//总宽度
private int mTotalWidth;
//1个标签的宽和高
private int mTabWidth, mTabHeight;
private Paint mPaint;
//下划线的位置
private float mTranslateX;
| private VideoPagerFragment videoPagerFragment; |
popo1379/popomusic | app/src/main/java/com/popomusic/data/SearchData.java | // Path: app/src/main/java/com/popomusic/bean/SearchBean.java
// public class SearchBean extends BaseBean{
//
// /**
// * m4a : http://ws.stream.qqmusic.qq.com/108554761.m4a?fromtag=46
// * media_mid : 002WyF5y4Rk1jW
// * songid : 108554761
// * singerid : 6370
// * albumname : 蒙面唱将猜猜猜 第1期
// * downUrl : http://dl.stream.qqmusic.qq.com/108554761.mp3?vkey=36792B0E9B4D62913A85D2340FFBFADF66CF898EC1BB6672EFBB1718ED537262CFB6AADC08B4DD6A448C0305D14434E0EC1DDB9942591186&guid=2718671044
// * singername : 谭晶
// * songname : 海阔天空 (Live)
// * strMediaMid : 002WyF5y4Rk1jW
// * albummid : 001LjNh61tMDJ1
// * songmid : 002WyF5y4Rk1jW
// * albumpic_big : http://i.gtimg.cn/music/photo/mid_album_300/J/1/001LjNh61tMDJ1.jpg
// * albumpic_small : http://i.gtimg.cn/music/photo/mid_album_90/J/1/001LjNh61tMDJ1.jpg
// * albumid : 1608672
// */
//
// private String m4a;
// private String media_mid;
// private int songid;
// private int singerid;
// private String albumname;
// private String downUrl;
// private String singername;
// private String songname;
// private String strMediaMid;
// private String albummid;
// private String songmid;
// private String albumpic_big;
// private String albumpic_small;
// private int albumid;
//
// public String getM4a() {
// return m4a;
// }
//
// public void setM4a(String m4a) {
// this.m4a = m4a;
// }
//
// public String getMedia_mid() {
// return media_mid;
// }
//
// public void setMedia_mid(String media_mid) {
// this.media_mid = media_mid;
// }
//
// public int getSongid() {
// return songid;
// }
//
// public void setSongid(int songid) {
// this.songid = songid;
// }
//
// public int getSingerid() {
// return singerid;
// }
//
// public void setSingerid(int singerid) {
// this.singerid = singerid;
// }
//
// public String getAlbumname() {
// return albumname;
// }
//
// public void setAlbumname(String albumname) {
// this.albumname = albumname;
// }
//
// public String getDownUrl() {
// return downUrl;
// }
//
// public void setDownUrl(String downUrl) {
// this.downUrl = downUrl;
// }
//
// public String getSingername() {
// return singername;
// }
//
// public void setSingername(String singername) {
// this.singername = singername;
// }
//
// public String getSongname() {
// return songname;
// }
//
// public void setSongname(String songname) {
// this.songname = songname;
// }
//
// public String getStrMediaMid() {
// return strMediaMid;
// }
//
// public void setStrMediaMid(String strMediaMid) {
// this.strMediaMid = strMediaMid;
// }
//
// public String getAlbummid() {
// return albummid;
// }
//
// public void setAlbummid(String albummid) {
// this.albummid = albummid;
// }
//
// public String getSongmid() {
// return songmid;
// }
//
// public void setSongmid(String songmid) {
// this.songmid = songmid;
// }
//
// public String getAlbumpic_big() {
// return albumpic_big;
// }
//
// public void setAlbumpic_big(String albumpic_big) {
// this.albumpic_big = albumpic_big;
// }
//
// public String getAlbumpic_small() {
// return albumpic_small;
// }
//
// public void setAlbumpic_small(String albumpic_small) {
// this.albumpic_small = albumpic_small;
// }
//
// public int getAlbumid() {
// return albumid;
// }
//
// public void setAlbumid(int albumid) {
// this.albumid = albumid;
// }
// }
//
// Path: app/src/main/java/com/popomusic/view/BaseView.java
// public interface BaseView {
// }
| import com.popomusic.bean.SearchBean;
import com.popomusic.view.BaseView;
import java.util.List; | package com.popomusic.data;
/**
* Created by popo on 2017/4/20 0020.
*/
public interface SearchData {
interface View extends BaseView { | // Path: app/src/main/java/com/popomusic/bean/SearchBean.java
// public class SearchBean extends BaseBean{
//
// /**
// * m4a : http://ws.stream.qqmusic.qq.com/108554761.m4a?fromtag=46
// * media_mid : 002WyF5y4Rk1jW
// * songid : 108554761
// * singerid : 6370
// * albumname : 蒙面唱将猜猜猜 第1期
// * downUrl : http://dl.stream.qqmusic.qq.com/108554761.mp3?vkey=36792B0E9B4D62913A85D2340FFBFADF66CF898EC1BB6672EFBB1718ED537262CFB6AADC08B4DD6A448C0305D14434E0EC1DDB9942591186&guid=2718671044
// * singername : 谭晶
// * songname : 海阔天空 (Live)
// * strMediaMid : 002WyF5y4Rk1jW
// * albummid : 001LjNh61tMDJ1
// * songmid : 002WyF5y4Rk1jW
// * albumpic_big : http://i.gtimg.cn/music/photo/mid_album_300/J/1/001LjNh61tMDJ1.jpg
// * albumpic_small : http://i.gtimg.cn/music/photo/mid_album_90/J/1/001LjNh61tMDJ1.jpg
// * albumid : 1608672
// */
//
// private String m4a;
// private String media_mid;
// private int songid;
// private int singerid;
// private String albumname;
// private String downUrl;
// private String singername;
// private String songname;
// private String strMediaMid;
// private String albummid;
// private String songmid;
// private String albumpic_big;
// private String albumpic_small;
// private int albumid;
//
// public String getM4a() {
// return m4a;
// }
//
// public void setM4a(String m4a) {
// this.m4a = m4a;
// }
//
// public String getMedia_mid() {
// return media_mid;
// }
//
// public void setMedia_mid(String media_mid) {
// this.media_mid = media_mid;
// }
//
// public int getSongid() {
// return songid;
// }
//
// public void setSongid(int songid) {
// this.songid = songid;
// }
//
// public int getSingerid() {
// return singerid;
// }
//
// public void setSingerid(int singerid) {
// this.singerid = singerid;
// }
//
// public String getAlbumname() {
// return albumname;
// }
//
// public void setAlbumname(String albumname) {
// this.albumname = albumname;
// }
//
// public String getDownUrl() {
// return downUrl;
// }
//
// public void setDownUrl(String downUrl) {
// this.downUrl = downUrl;
// }
//
// public String getSingername() {
// return singername;
// }
//
// public void setSingername(String singername) {
// this.singername = singername;
// }
//
// public String getSongname() {
// return songname;
// }
//
// public void setSongname(String songname) {
// this.songname = songname;
// }
//
// public String getStrMediaMid() {
// return strMediaMid;
// }
//
// public void setStrMediaMid(String strMediaMid) {
// this.strMediaMid = strMediaMid;
// }
//
// public String getAlbummid() {
// return albummid;
// }
//
// public void setAlbummid(String albummid) {
// this.albummid = albummid;
// }
//
// public String getSongmid() {
// return songmid;
// }
//
// public void setSongmid(String songmid) {
// this.songmid = songmid;
// }
//
// public String getAlbumpic_big() {
// return albumpic_big;
// }
//
// public void setAlbumpic_big(String albumpic_big) {
// this.albumpic_big = albumpic_big;
// }
//
// public String getAlbumpic_small() {
// return albumpic_small;
// }
//
// public void setAlbumpic_small(String albumpic_small) {
// this.albumpic_small = albumpic_small;
// }
//
// public int getAlbumid() {
// return albumid;
// }
//
// public void setAlbumid(int albumid) {
// this.albumid = albumid;
// }
// }
//
// Path: app/src/main/java/com/popomusic/view/BaseView.java
// public interface BaseView {
// }
// Path: app/src/main/java/com/popomusic/data/SearchData.java
import com.popomusic.bean.SearchBean;
import com.popomusic.view.BaseView;
import java.util.List;
package com.popomusic.data;
/**
* Created by popo on 2017/4/20 0020.
*/
public interface SearchData {
interface View extends BaseView { | void setData(List<SearchBean> list); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.