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
uustory/u8updateserver
src/com/u8/server/service/UUpdateLogManager.java
// Path: src/com/u8/server/common/Page.java // public class Page<T> // { // private PageParameter pageParameter; // private List<T> resultList = null; // private int totalCount = -1; // // public Page() // { // this.pageParameter = new PageParameter(1, 10, false); // } // // public Page(PageParameter params) // { // this.pageParameter = params; // } // // public int getTotalPages() // { // if (this.totalCount == -1) // return -1; // int i = this.totalCount / this.pageParameter.getPageSize(); // if (this.totalCount % this.pageParameter.getPageSize() > 0) // i++; // return i; // } // // public List<T> getResultList() // { // return this.resultList; // } // // public void setResultList(List<T> paramList) // { // this.resultList = paramList; // } // // public int getTotalCount() // { // return this.totalCount; // } // // public void setTotalCount(int paramInt) // { // this.totalCount = paramInt; // } // // public PageParameter getPageParameter() // { // return this.pageParameter; // } // // public void setPageParameter(PageParameter params) // { // this.pageParameter = params; // } // } // // Path: src/com/u8/server/dao/UUpdateLogDao.java // @Repository("updateLogDao") // public class UUpdateLogDao extends UHibernateTemplate<UUpdateLog, Long>{ // // public void saveChannel(UUpdateLog log){ // super.save(log); // } // // public UUpdateLog queryChannel(long id){ // // return super.get(id); // } // } // // Path: src/com/u8/server/data/UUpdateLog.java // @Entity // @Table(name="uupdatelog") // public class UUpdateLog { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // private Long id; // // private Integer userID; //更新者 // // private String userName; //更新者姓名 // // private String name; //更新的组件名称 // // private String fileName; //文件名称 // // private Date updateTime; //更新时间 // // private String ipAddr; //IP地址 // // public JSONObject toJSON(){ // // JSONObject json = new JSONObject(); // json.put("id", id); // json.put("userID", userID); // json.put("userName", userName); // json.put("name", name); // json.put("fileName", fileName); // json.put("updateTime", TimeFormater.format_default(updateTime)); // json.put("ipAddr", ipAddr); // // return json; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Integer getUserID() { // return userID; // } // // public void setUserID(Integer userID) { // this.userID = userID; // } // // public String getUserName() { // return userName; // } // // public void setUserName(String userName) { // this.userName = userName; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getFileName() { // return fileName; // } // // public void setFileName(String fileName) { // this.fileName = fileName; // } // // public Date getUpdateTime() { // return updateTime; // } // // public void setUpdateTime(Date updateTime) { // this.updateTime = updateTime; // } // // public String getIpAddr() { // return ipAddr; // } // // public void setIpAddr(String ipAddr) { // this.ipAddr = ipAddr; // } // }
import com.u8.server.common.OrderParameter; import com.u8.server.common.OrderParameters; import com.u8.server.common.Page; import com.u8.server.common.PageParameter; import com.u8.server.dao.UUpdateLogDao; import com.u8.server.data.UUpdateLog; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;
package com.u8.server.service; /** */ @Service("updateLogManager") public class UUpdateLogManager { @Autowired private UUpdateLogDao updateLogDao; //分页查找
// Path: src/com/u8/server/common/Page.java // public class Page<T> // { // private PageParameter pageParameter; // private List<T> resultList = null; // private int totalCount = -1; // // public Page() // { // this.pageParameter = new PageParameter(1, 10, false); // } // // public Page(PageParameter params) // { // this.pageParameter = params; // } // // public int getTotalPages() // { // if (this.totalCount == -1) // return -1; // int i = this.totalCount / this.pageParameter.getPageSize(); // if (this.totalCount % this.pageParameter.getPageSize() > 0) // i++; // return i; // } // // public List<T> getResultList() // { // return this.resultList; // } // // public void setResultList(List<T> paramList) // { // this.resultList = paramList; // } // // public int getTotalCount() // { // return this.totalCount; // } // // public void setTotalCount(int paramInt) // { // this.totalCount = paramInt; // } // // public PageParameter getPageParameter() // { // return this.pageParameter; // } // // public void setPageParameter(PageParameter params) // { // this.pageParameter = params; // } // } // // Path: src/com/u8/server/dao/UUpdateLogDao.java // @Repository("updateLogDao") // public class UUpdateLogDao extends UHibernateTemplate<UUpdateLog, Long>{ // // public void saveChannel(UUpdateLog log){ // super.save(log); // } // // public UUpdateLog queryChannel(long id){ // // return super.get(id); // } // } // // Path: src/com/u8/server/data/UUpdateLog.java // @Entity // @Table(name="uupdatelog") // public class UUpdateLog { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // private Long id; // // private Integer userID; //更新者 // // private String userName; //更新者姓名 // // private String name; //更新的组件名称 // // private String fileName; //文件名称 // // private Date updateTime; //更新时间 // // private String ipAddr; //IP地址 // // public JSONObject toJSON(){ // // JSONObject json = new JSONObject(); // json.put("id", id); // json.put("userID", userID); // json.put("userName", userName); // json.put("name", name); // json.put("fileName", fileName); // json.put("updateTime", TimeFormater.format_default(updateTime)); // json.put("ipAddr", ipAddr); // // return json; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Integer getUserID() { // return userID; // } // // public void setUserID(Integer userID) { // this.userID = userID; // } // // public String getUserName() { // return userName; // } // // public void setUserName(String userName) { // this.userName = userName; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getFileName() { // return fileName; // } // // public void setFileName(String fileName) { // this.fileName = fileName; // } // // public Date getUpdateTime() { // return updateTime; // } // // public void setUpdateTime(Date updateTime) { // this.updateTime = updateTime; // } // // public String getIpAddr() { // return ipAddr; // } // // public void setIpAddr(String ipAddr) { // this.ipAddr = ipAddr; // } // } // Path: src/com/u8/server/service/UUpdateLogManager.java import com.u8.server.common.OrderParameter; import com.u8.server.common.OrderParameters; import com.u8.server.common.Page; import com.u8.server.common.PageParameter; import com.u8.server.dao.UUpdateLogDao; import com.u8.server.data.UUpdateLog; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; package com.u8.server.service; /** */ @Service("updateLogManager") public class UUpdateLogManager { @Autowired private UUpdateLogDao updateLogDao; //分页查找
public Page<UUpdateLog> queryPage(int currPage, int num){
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/summary/SummaryChart.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/FollowerSummary.java // public class FollowerSummary extends JavaScriptObject { // protected FollowerSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<FollowerSummary> getFollowerSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/TweetSummary.java // public class TweetSummary extends JavaScriptObject { // protected TweetSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native TweetValue getValue() /*-{ return this.value }-*/; // public final native JsArray<TweetSummary> getTweetSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.AreaChart; import com.googlecode.gwt.charts.client.corechart.AreaChartOptions; import com.googlecode.gwt.charts.client.options.*; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.FollowerSummary; import gov.wa.wsdot.apps.analytics.shared.TweetSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import java.util.ArrayList; import java.util.Date;
MaterialLink followersTab; @UiField static MaterialCardAction tweetLabel; @UiField static MaterialLabel followersLabel; @UiField static MaterialIcon followersIcon; @UiField static MaterialPreLoader tweetsLoader; @UiField static MaterialPreLoader followersLoader; @UiField static MaterialCardContent tweetContent; @UiField static MaterialCardContent followerContent;
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/FollowerSummary.java // public class FollowerSummary extends JavaScriptObject { // protected FollowerSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<FollowerSummary> getFollowerSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/TweetSummary.java // public class TweetSummary extends JavaScriptObject { // protected TweetSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native TweetValue getValue() /*-{ return this.value }-*/; // public final native JsArray<TweetSummary> getTweetSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/summary/SummaryChart.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.AreaChart; import com.googlecode.gwt.charts.client.corechart.AreaChartOptions; import com.googlecode.gwt.charts.client.options.*; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.FollowerSummary; import gov.wa.wsdot.apps.analytics.shared.TweetSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import java.util.ArrayList; import java.util.Date; MaterialLink followersTab; @UiField static MaterialCardAction tweetLabel; @UiField static MaterialLabel followersLabel; @UiField static MaterialIcon followersIcon; @UiField static MaterialPreLoader tweetsLoader; @UiField static MaterialPreLoader followersLoader; @UiField static MaterialCardContent tweetContent; @UiField static MaterialCardContent followerContent;
final Resources res;
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/summary/SummaryChart.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/FollowerSummary.java // public class FollowerSummary extends JavaScriptObject { // protected FollowerSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<FollowerSummary> getFollowerSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/TweetSummary.java // public class TweetSummary extends JavaScriptObject { // protected TweetSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native TweetValue getValue() /*-{ return this.value }-*/; // public final native JsArray<TweetSummary> getTweetSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.AreaChart; import com.googlecode.gwt.charts.client.corechart.AreaChartOptions; import com.googlecode.gwt.charts.client.options.*; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.FollowerSummary; import gov.wa.wsdot.apps.analytics.shared.TweetSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import java.util.ArrayList; import java.util.Date;
@UiField static MaterialLabel followersLabel; @UiField static MaterialIcon followersIcon; @UiField static MaterialPreLoader tweetsLoader; @UiField static MaterialPreLoader followersLoader; @UiField static MaterialCardContent tweetContent; @UiField static MaterialCardContent followerContent; final Resources res; private static AreaChart tweetsChart; private static AreaChart followersChart; private static String dateRange = "";
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/FollowerSummary.java // public class FollowerSummary extends JavaScriptObject { // protected FollowerSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<FollowerSummary> getFollowerSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/TweetSummary.java // public class TweetSummary extends JavaScriptObject { // protected TweetSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native TweetValue getValue() /*-{ return this.value }-*/; // public final native JsArray<TweetSummary> getTweetSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/summary/SummaryChart.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.AreaChart; import com.googlecode.gwt.charts.client.corechart.AreaChartOptions; import com.googlecode.gwt.charts.client.options.*; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.FollowerSummary; import gov.wa.wsdot.apps.analytics.shared.TweetSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import java.util.ArrayList; import java.util.Date; @UiField static MaterialLabel followersLabel; @UiField static MaterialIcon followersIcon; @UiField static MaterialPreLoader tweetsLoader; @UiField static MaterialPreLoader followersLoader; @UiField static MaterialCardContent tweetContent; @UiField static MaterialCardContent followerContent; final Resources res; private static AreaChart tweetsChart; private static AreaChart followersChart; private static String dateRange = "";
private static String account = Consts.DEFAULT_ACCOUNT;
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/summary/SummaryChart.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/FollowerSummary.java // public class FollowerSummary extends JavaScriptObject { // protected FollowerSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<FollowerSummary> getFollowerSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/TweetSummary.java // public class TweetSummary extends JavaScriptObject { // protected TweetSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native TweetValue getValue() /*-{ return this.value }-*/; // public final native JsArray<TweetSummary> getTweetSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.AreaChart; import com.googlecode.gwt.charts.client.corechart.AreaChartOptions; import com.googlecode.gwt.charts.client.options.*; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.FollowerSummary; import gov.wa.wsdot.apps.analytics.shared.TweetSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import java.util.ArrayList; import java.util.Date;
@UiField static MaterialIcon followersIcon; @UiField static MaterialPreLoader tweetsLoader; @UiField static MaterialPreLoader followersLoader; @UiField static MaterialCardContent tweetContent; @UiField static MaterialCardContent followerContent; final Resources res; private static AreaChart tweetsChart; private static AreaChart followersChart; private static String dateRange = ""; private static String account = Consts.DEFAULT_ACCOUNT; private static final String JSON_URL = Consts.HOST_URL + "/summary";
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/FollowerSummary.java // public class FollowerSummary extends JavaScriptObject { // protected FollowerSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<FollowerSummary> getFollowerSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/TweetSummary.java // public class TweetSummary extends JavaScriptObject { // protected TweetSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native TweetValue getValue() /*-{ return this.value }-*/; // public final native JsArray<TweetSummary> getTweetSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/summary/SummaryChart.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.AreaChart; import com.googlecode.gwt.charts.client.corechart.AreaChartOptions; import com.googlecode.gwt.charts.client.options.*; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.FollowerSummary; import gov.wa.wsdot.apps.analytics.shared.TweetSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import java.util.ArrayList; import java.util.Date; @UiField static MaterialIcon followersIcon; @UiField static MaterialPreLoader tweetsLoader; @UiField static MaterialPreLoader followersLoader; @UiField static MaterialCardContent tweetContent; @UiField static MaterialCardContent followerContent; final Resources res; private static AreaChart tweetsChart; private static AreaChart followersChart; private static String dateRange = ""; private static String account = Consts.DEFAULT_ACCOUNT; private static final String JSON_URL = Consts.HOST_URL + "/summary";
static JsArray<TweetSummary> tweetSummary;
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/summary/SummaryChart.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/FollowerSummary.java // public class FollowerSummary extends JavaScriptObject { // protected FollowerSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<FollowerSummary> getFollowerSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/TweetSummary.java // public class TweetSummary extends JavaScriptObject { // protected TweetSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native TweetValue getValue() /*-{ return this.value }-*/; // public final native JsArray<TweetSummary> getTweetSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.AreaChart; import com.googlecode.gwt.charts.client.corechart.AreaChartOptions; import com.googlecode.gwt.charts.client.options.*; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.FollowerSummary; import gov.wa.wsdot.apps.analytics.shared.TweetSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import java.util.ArrayList; import java.util.Date;
@UiField static MaterialIcon followersIcon; @UiField static MaterialPreLoader tweetsLoader; @UiField static MaterialPreLoader followersLoader; @UiField static MaterialCardContent tweetContent; @UiField static MaterialCardContent followerContent; final Resources res; private static AreaChart tweetsChart; private static AreaChart followersChart; private static String dateRange = ""; private static String account = Consts.DEFAULT_ACCOUNT; private static final String JSON_URL = Consts.HOST_URL + "/summary"; static JsArray<TweetSummary> tweetSummary;
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/FollowerSummary.java // public class FollowerSummary extends JavaScriptObject { // protected FollowerSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<FollowerSummary> getFollowerSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/TweetSummary.java // public class TweetSummary extends JavaScriptObject { // protected TweetSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native TweetValue getValue() /*-{ return this.value }-*/; // public final native JsArray<TweetSummary> getTweetSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/summary/SummaryChart.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.AreaChart; import com.googlecode.gwt.charts.client.corechart.AreaChartOptions; import com.googlecode.gwt.charts.client.options.*; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.FollowerSummary; import gov.wa.wsdot.apps.analytics.shared.TweetSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import java.util.ArrayList; import java.util.Date; @UiField static MaterialIcon followersIcon; @UiField static MaterialPreLoader tweetsLoader; @UiField static MaterialPreLoader followersLoader; @UiField static MaterialCardContent tweetContent; @UiField static MaterialCardContent followerContent; final Resources res; private static AreaChart tweetsChart; private static AreaChart followersChart; private static String dateRange = ""; private static String account = Consts.DEFAULT_ACCOUNT; private static final String JSON_URL = Consts.HOST_URL + "/summary"; static JsArray<TweetSummary> tweetSummary;
static JsArray<FollowerSummary> followerSummary;
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/summary/SummaryChart.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/FollowerSummary.java // public class FollowerSummary extends JavaScriptObject { // protected FollowerSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<FollowerSummary> getFollowerSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/TweetSummary.java // public class TweetSummary extends JavaScriptObject { // protected TweetSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native TweetValue getValue() /*-{ return this.value }-*/; // public final native JsArray<TweetSummary> getTweetSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.AreaChart; import com.googlecode.gwt.charts.client.corechart.AreaChartOptions; import com.googlecode.gwt.charts.client.options.*; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.FollowerSummary; import gov.wa.wsdot.apps.analytics.shared.TweetSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import java.util.ArrayList; import java.util.Date;
static MaterialPreLoader tweetsLoader; @UiField static MaterialPreLoader followersLoader; @UiField static MaterialCardContent tweetContent; @UiField static MaterialCardContent followerContent; final Resources res; private static AreaChart tweetsChart; private static AreaChart followersChart; private static String dateRange = ""; private static String account = Consts.DEFAULT_ACCOUNT; private static final String JSON_URL = Consts.HOST_URL + "/summary"; static JsArray<TweetSummary> tweetSummary; static JsArray<FollowerSummary> followerSummary; static ArrayList<String> dateArrayList = new ArrayList<String>(); private static String defaultDateRange = "";
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/FollowerSummary.java // public class FollowerSummary extends JavaScriptObject { // protected FollowerSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<FollowerSummary> getFollowerSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/TweetSummary.java // public class TweetSummary extends JavaScriptObject { // protected TweetSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native TweetValue getValue() /*-{ return this.value }-*/; // public final native JsArray<TweetSummary> getTweetSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/summary/SummaryChart.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.AreaChart; import com.googlecode.gwt.charts.client.corechart.AreaChartOptions; import com.googlecode.gwt.charts.client.options.*; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.FollowerSummary; import gov.wa.wsdot.apps.analytics.shared.TweetSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import java.util.ArrayList; import java.util.Date; static MaterialPreLoader tweetsLoader; @UiField static MaterialPreLoader followersLoader; @UiField static MaterialCardContent tweetContent; @UiField static MaterialCardContent followerContent; final Resources res; private static AreaChart tweetsChart; private static AreaChart followersChart; private static String dateRange = ""; private static String account = Consts.DEFAULT_ACCOUNT; private static final String JSON_URL = Consts.HOST_URL + "/summary"; static JsArray<TweetSummary> tweetSummary; static JsArray<FollowerSummary> followerSummary; static ArrayList<String> dateArrayList = new ArrayList<String>(); private static String defaultDateRange = "";
private static ClientFactory clientFactory;
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/summary/SummaryChart.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/FollowerSummary.java // public class FollowerSummary extends JavaScriptObject { // protected FollowerSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<FollowerSummary> getFollowerSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/TweetSummary.java // public class TweetSummary extends JavaScriptObject { // protected TweetSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native TweetValue getValue() /*-{ return this.value }-*/; // public final native JsArray<TweetSummary> getTweetSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.AreaChart; import com.googlecode.gwt.charts.client.corechart.AreaChartOptions; import com.googlecode.gwt.charts.client.options.*; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.FollowerSummary; import gov.wa.wsdot.apps.analytics.shared.TweetSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import java.util.ArrayList; import java.util.Date;
final Resources res; private static AreaChart tweetsChart; private static AreaChart followersChart; private static String dateRange = ""; private static String account = Consts.DEFAULT_ACCOUNT; private static final String JSON_URL = Consts.HOST_URL + "/summary"; static JsArray<TweetSummary> tweetSummary; static JsArray<FollowerSummary> followerSummary; static ArrayList<String> dateArrayList = new ArrayList<String>(); private static String defaultDateRange = ""; private static ClientFactory clientFactory; public SummaryChart(ClientFactory clientFactory){ this.clientFactory = clientFactory; res = GWT.create(Resources.class); res.css().ensureInjected(); eventBinder.bindEventHandlers(this, clientFactory.getEventBus()); initWidget(uiBinder.createAndBindUi(this)); } @EventHandler
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/FollowerSummary.java // public class FollowerSummary extends JavaScriptObject { // protected FollowerSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<FollowerSummary> getFollowerSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/TweetSummary.java // public class TweetSummary extends JavaScriptObject { // protected TweetSummary() {} // // public final native double getId() /*-{ return this._id }-*/; // public final native TweetValue getValue() /*-{ return this.value }-*/; // public final native JsArray<TweetSummary> getTweetSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/summary/SummaryChart.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.AreaChart; import com.googlecode.gwt.charts.client.corechart.AreaChartOptions; import com.googlecode.gwt.charts.client.options.*; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.FollowerSummary; import gov.wa.wsdot.apps.analytics.shared.TweetSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import java.util.ArrayList; import java.util.Date; final Resources res; private static AreaChart tweetsChart; private static AreaChart followersChart; private static String dateRange = ""; private static String account = Consts.DEFAULT_ACCOUNT; private static final String JSON_URL = Consts.HOST_URL + "/summary"; static JsArray<TweetSummary> tweetSummary; static JsArray<FollowerSummary> followerSummary; static ArrayList<String> dateArrayList = new ArrayList<String>(); private static String defaultDateRange = ""; private static ClientFactory clientFactory; public SummaryChart(ClientFactory clientFactory){ this.clientFactory = clientFactory; res = GWT.create(Resources.class); res.css().ensureInjected(); eventBinder.bindEventHandlers(this, clientFactory.getEventBus()); initWidget(uiBinder.createAndBindUi(this)); } @EventHandler
void onDateSubmit(DateSubmitEvent event){
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/sentiment/SentimentPieChart.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/SentimentDisplayEvent.java // public class SentimentDisplayEvent extends GenericEvent { // // String sentiment; // // public SentimentDisplayEvent(String sentiment){ // this.sentiment = sentiment; // } // // public String getSentiment(){ // return sentiment; // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/SentimentSummary.java // public class SentimentSummary extends JavaScriptObject { // protected SentimentSummary() {} // // public final native String getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<SentimentSummary> getSentimentSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.*; import com.googlecode.gwt.charts.client.corechart.PieChart; import com.googlecode.gwt.charts.client.corechart.PieChartOptions; import com.googlecode.gwt.charts.client.event.SelectEvent; import com.googlecode.gwt.charts.client.event.SelectHandler; import com.googlecode.gwt.charts.client.options.ChartArea; import com.googlecode.gwt.charts.client.options.Legend; import com.googlecode.gwt.charts.client.options.LegendPosition; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.activities.events.SentimentDisplayEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.SentimentSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.ui.MaterialCardContent; import gwt.material.design.client.ui.MaterialPreLoader;
/* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter.view.sentiment; /** * Custom widget for displaying tweet sentiment data. * * Listens for DateSubmitEvents */ public class SentimentPieChart extends Composite { interface MyEventBinder extends EventBinder<SentimentPieChart> {} private final MyEventBinder eventBinder = GWT.create(MyEventBinder.class); private static SentimentPieChartUiBinder uiBinder = GWT .create(SentimentPieChartUiBinder.class); interface SentimentPieChartUiBinder extends UiBinder<Widget, SentimentPieChart> { } @UiField static MaterialCardContent cardContent; @UiField static MaterialPreLoader sentimentLoader;
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/SentimentDisplayEvent.java // public class SentimentDisplayEvent extends GenericEvent { // // String sentiment; // // public SentimentDisplayEvent(String sentiment){ // this.sentiment = sentiment; // } // // public String getSentiment(){ // return sentiment; // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/SentimentSummary.java // public class SentimentSummary extends JavaScriptObject { // protected SentimentSummary() {} // // public final native String getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<SentimentSummary> getSentimentSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/sentiment/SentimentPieChart.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.*; import com.googlecode.gwt.charts.client.corechart.PieChart; import com.googlecode.gwt.charts.client.corechart.PieChartOptions; import com.googlecode.gwt.charts.client.event.SelectEvent; import com.googlecode.gwt.charts.client.event.SelectHandler; import com.googlecode.gwt.charts.client.options.ChartArea; import com.googlecode.gwt.charts.client.options.Legend; import com.googlecode.gwt.charts.client.options.LegendPosition; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.activities.events.SentimentDisplayEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.SentimentSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.ui.MaterialCardContent; import gwt.material.design.client.ui.MaterialPreLoader; /* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter.view.sentiment; /** * Custom widget for displaying tweet sentiment data. * * Listens for DateSubmitEvents */ public class SentimentPieChart extends Composite { interface MyEventBinder extends EventBinder<SentimentPieChart> {} private final MyEventBinder eventBinder = GWT.create(MyEventBinder.class); private static SentimentPieChartUiBinder uiBinder = GWT .create(SentimentPieChartUiBinder.class); interface SentimentPieChartUiBinder extends UiBinder<Widget, SentimentPieChart> { } @UiField static MaterialCardContent cardContent; @UiField static MaterialPreLoader sentimentLoader;
final Resources res;
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/sentiment/SentimentPieChart.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/SentimentDisplayEvent.java // public class SentimentDisplayEvent extends GenericEvent { // // String sentiment; // // public SentimentDisplayEvent(String sentiment){ // this.sentiment = sentiment; // } // // public String getSentiment(){ // return sentiment; // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/SentimentSummary.java // public class SentimentSummary extends JavaScriptObject { // protected SentimentSummary() {} // // public final native String getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<SentimentSummary> getSentimentSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.*; import com.googlecode.gwt.charts.client.corechart.PieChart; import com.googlecode.gwt.charts.client.corechart.PieChartOptions; import com.googlecode.gwt.charts.client.event.SelectEvent; import com.googlecode.gwt.charts.client.event.SelectHandler; import com.googlecode.gwt.charts.client.options.ChartArea; import com.googlecode.gwt.charts.client.options.Legend; import com.googlecode.gwt.charts.client.options.LegendPosition; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.activities.events.SentimentDisplayEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.SentimentSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.ui.MaterialCardContent; import gwt.material.design.client.ui.MaterialPreLoader;
/* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter.view.sentiment; /** * Custom widget for displaying tweet sentiment data. * * Listens for DateSubmitEvents */ public class SentimentPieChart extends Composite { interface MyEventBinder extends EventBinder<SentimentPieChart> {} private final MyEventBinder eventBinder = GWT.create(MyEventBinder.class); private static SentimentPieChartUiBinder uiBinder = GWT .create(SentimentPieChartUiBinder.class); interface SentimentPieChartUiBinder extends UiBinder<Widget, SentimentPieChart> { } @UiField static MaterialCardContent cardContent; @UiField static MaterialPreLoader sentimentLoader; final Resources res;
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/SentimentDisplayEvent.java // public class SentimentDisplayEvent extends GenericEvent { // // String sentiment; // // public SentimentDisplayEvent(String sentiment){ // this.sentiment = sentiment; // } // // public String getSentiment(){ // return sentiment; // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/SentimentSummary.java // public class SentimentSummary extends JavaScriptObject { // protected SentimentSummary() {} // // public final native String getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<SentimentSummary> getSentimentSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/sentiment/SentimentPieChart.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.*; import com.googlecode.gwt.charts.client.corechart.PieChart; import com.googlecode.gwt.charts.client.corechart.PieChartOptions; import com.googlecode.gwt.charts.client.event.SelectEvent; import com.googlecode.gwt.charts.client.event.SelectHandler; import com.googlecode.gwt.charts.client.options.ChartArea; import com.googlecode.gwt.charts.client.options.Legend; import com.googlecode.gwt.charts.client.options.LegendPosition; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.activities.events.SentimentDisplayEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.SentimentSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.ui.MaterialCardContent; import gwt.material.design.client.ui.MaterialPreLoader; /* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter.view.sentiment; /** * Custom widget for displaying tweet sentiment data. * * Listens for DateSubmitEvents */ public class SentimentPieChart extends Composite { interface MyEventBinder extends EventBinder<SentimentPieChart> {} private final MyEventBinder eventBinder = GWT.create(MyEventBinder.class); private static SentimentPieChartUiBinder uiBinder = GWT .create(SentimentPieChartUiBinder.class); interface SentimentPieChartUiBinder extends UiBinder<Widget, SentimentPieChart> { } @UiField static MaterialCardContent cardContent; @UiField static MaterialPreLoader sentimentLoader; final Resources res;
static ClientFactory clientFactory;
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/sentiment/SentimentPieChart.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/SentimentDisplayEvent.java // public class SentimentDisplayEvent extends GenericEvent { // // String sentiment; // // public SentimentDisplayEvent(String sentiment){ // this.sentiment = sentiment; // } // // public String getSentiment(){ // return sentiment; // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/SentimentSummary.java // public class SentimentSummary extends JavaScriptObject { // protected SentimentSummary() {} // // public final native String getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<SentimentSummary> getSentimentSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.*; import com.googlecode.gwt.charts.client.corechart.PieChart; import com.googlecode.gwt.charts.client.corechart.PieChartOptions; import com.googlecode.gwt.charts.client.event.SelectEvent; import com.googlecode.gwt.charts.client.event.SelectHandler; import com.googlecode.gwt.charts.client.options.ChartArea; import com.googlecode.gwt.charts.client.options.Legend; import com.googlecode.gwt.charts.client.options.LegendPosition; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.activities.events.SentimentDisplayEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.SentimentSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.ui.MaterialCardContent; import gwt.material.design.client.ui.MaterialPreLoader;
PieChartOptions options = PieChartOptions.create(); options.setWidth(500); options.setHeight(400); ChartArea area = ChartArea.create(); area.setTop(50); area.setLeft(25); options.setChartArea(area); options.setLegend(legend); options.setColors("BDBDBD", "26A69A", "FF6E40"); pieChart.draw(data, options); } private static Widget getPieChart() { if (pieChart == null) { pieChart = new PieChart(); pieChart.addSelectHandler(new SelectHandler() { @Override public void onSelect(SelectEvent event) { // May be multiple selections. JsArray<Selection> selections = pieChart.getSelection(); for (int i = 0; i < selections.length(); i++) { Selection selection = selections.get(i); int row = selection.getRow(); // Append the name of the callback function to the JSON URL if (row == 0) {
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/SentimentDisplayEvent.java // public class SentimentDisplayEvent extends GenericEvent { // // String sentiment; // // public SentimentDisplayEvent(String sentiment){ // this.sentiment = sentiment; // } // // public String getSentiment(){ // return sentiment; // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/SentimentSummary.java // public class SentimentSummary extends JavaScriptObject { // protected SentimentSummary() {} // // public final native String getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<SentimentSummary> getSentimentSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/sentiment/SentimentPieChart.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.*; import com.googlecode.gwt.charts.client.corechart.PieChart; import com.googlecode.gwt.charts.client.corechart.PieChartOptions; import com.googlecode.gwt.charts.client.event.SelectEvent; import com.googlecode.gwt.charts.client.event.SelectHandler; import com.googlecode.gwt.charts.client.options.ChartArea; import com.googlecode.gwt.charts.client.options.Legend; import com.googlecode.gwt.charts.client.options.LegendPosition; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.activities.events.SentimentDisplayEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.SentimentSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.ui.MaterialCardContent; import gwt.material.design.client.ui.MaterialPreLoader; PieChartOptions options = PieChartOptions.create(); options.setWidth(500); options.setHeight(400); ChartArea area = ChartArea.create(); area.setTop(50); area.setLeft(25); options.setChartArea(area); options.setLegend(legend); options.setColors("BDBDBD", "26A69A", "FF6E40"); pieChart.draw(data, options); } private static Widget getPieChart() { if (pieChart == null) { pieChart = new PieChart(); pieChart.addSelectHandler(new SelectHandler() { @Override public void onSelect(SelectEvent event) { // May be multiple selections. JsArray<Selection> selections = pieChart.getSelection(); for (int i = 0; i < selections.length(); i++) { Selection selection = selections.get(i); int row = selection.getRow(); // Append the name of the callback function to the JSON URL if (row == 0) {
clientFactory.getEventBus().fireEvent(new SentimentDisplayEvent("neutral"));
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/AppActivityMapper.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/AnalyticsActivity.java // public class AnalyticsActivity extends AbstractActivity implements AnalyticsView.Presenter { // // private final ClientFactory clientFactory; // private String name; // // private AnalyticsView view; // // public AnalyticsActivity(AnalyticsPlace place, ClientFactory clientFactory) { // this.name = place.getAnalyticsName(); // this.clientFactory = clientFactory; // } // // @Override // public void start(AcceptsOneWidget panel, EventBus eventBus) { // view = clientFactory.getAnalyticsView(); // view.setPresenter(this); // panel.setWidget(view.asWidget()); // // } // // @Override // public void onDateSubmit(Date startDate, Date endDate, String account) { // // DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d"); // // if (startDate.getTime() > endDate.getTime()) { // // MaterialToast.fireToast("Whoops! Invalid date range.", 1000); // } else { // String fromDate = fmt.format(startDate); // String toDate = fmt.format(endDate); // String dateRange = fromDate + toDate; // // clientFactory.getEventBus().fireEvent(new DateSubmitEvent(dateRange, startDate, endDate, account)); // } // // } // // @Override // public EventBus getEventBus() { // return clientFactory.getEventBus(); // } // // // // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/AnalyticsPlace.java // public class AnalyticsPlace extends Place { // private String AnalyticsName; // // public AnalyticsPlace(String token) { // this.AnalyticsName = token; // } // // public String getAnalyticsName() { // return AnalyticsName; // } // // public static class AnalyticsPlaceTokenizer implements PlaceTokenizer<AnalyticsPlace> { // // @Override // public String getToken(AnalyticsPlace place) { // return place.getAnalyticsName(); // } // // @Override // public AnalyticsPlace getPlace(String token) { // return new AnalyticsPlace(token); // } // } // }
import com.google.gwt.activity.shared.Activity; import com.google.gwt.activity.shared.ActivityMapper; import com.google.gwt.place.shared.Place; import gov.wa.wsdot.apps.analytics.client.activities.twitter.AnalyticsActivity; import gov.wa.wsdot.apps.analytics.client.activities.twitter.AnalyticsPlace;
/* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client; public class AppActivityMapper implements ActivityMapper { private ClientFactory clientFactory; public AppActivityMapper(ClientFactory clientFactory) { super(); this.clientFactory = clientFactory; } @Override public Activity getActivity(Place place) {
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/AnalyticsActivity.java // public class AnalyticsActivity extends AbstractActivity implements AnalyticsView.Presenter { // // private final ClientFactory clientFactory; // private String name; // // private AnalyticsView view; // // public AnalyticsActivity(AnalyticsPlace place, ClientFactory clientFactory) { // this.name = place.getAnalyticsName(); // this.clientFactory = clientFactory; // } // // @Override // public void start(AcceptsOneWidget panel, EventBus eventBus) { // view = clientFactory.getAnalyticsView(); // view.setPresenter(this); // panel.setWidget(view.asWidget()); // // } // // @Override // public void onDateSubmit(Date startDate, Date endDate, String account) { // // DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d"); // // if (startDate.getTime() > endDate.getTime()) { // // MaterialToast.fireToast("Whoops! Invalid date range.", 1000); // } else { // String fromDate = fmt.format(startDate); // String toDate = fmt.format(endDate); // String dateRange = fromDate + toDate; // // clientFactory.getEventBus().fireEvent(new DateSubmitEvent(dateRange, startDate, endDate, account)); // } // // } // // @Override // public EventBus getEventBus() { // return clientFactory.getEventBus(); // } // // // // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/AnalyticsPlace.java // public class AnalyticsPlace extends Place { // private String AnalyticsName; // // public AnalyticsPlace(String token) { // this.AnalyticsName = token; // } // // public String getAnalyticsName() { // return AnalyticsName; // } // // public static class AnalyticsPlaceTokenizer implements PlaceTokenizer<AnalyticsPlace> { // // @Override // public String getToken(AnalyticsPlace place) { // return place.getAnalyticsName(); // } // // @Override // public AnalyticsPlace getPlace(String token) { // return new AnalyticsPlace(token); // } // } // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/AppActivityMapper.java import com.google.gwt.activity.shared.Activity; import com.google.gwt.activity.shared.ActivityMapper; import com.google.gwt.place.shared.Place; import gov.wa.wsdot.apps.analytics.client.activities.twitter.AnalyticsActivity; import gov.wa.wsdot.apps.analytics.client.activities.twitter.AnalyticsPlace; /* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client; public class AppActivityMapper implements ActivityMapper { private ClientFactory clientFactory; public AppActivityMapper(ClientFactory clientFactory) { super(); this.clientFactory = clientFactory; } @Override public Activity getActivity(Place place) {
if (place instanceof AnalyticsPlace)
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/AppActivityMapper.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/AnalyticsActivity.java // public class AnalyticsActivity extends AbstractActivity implements AnalyticsView.Presenter { // // private final ClientFactory clientFactory; // private String name; // // private AnalyticsView view; // // public AnalyticsActivity(AnalyticsPlace place, ClientFactory clientFactory) { // this.name = place.getAnalyticsName(); // this.clientFactory = clientFactory; // } // // @Override // public void start(AcceptsOneWidget panel, EventBus eventBus) { // view = clientFactory.getAnalyticsView(); // view.setPresenter(this); // panel.setWidget(view.asWidget()); // // } // // @Override // public void onDateSubmit(Date startDate, Date endDate, String account) { // // DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d"); // // if (startDate.getTime() > endDate.getTime()) { // // MaterialToast.fireToast("Whoops! Invalid date range.", 1000); // } else { // String fromDate = fmt.format(startDate); // String toDate = fmt.format(endDate); // String dateRange = fromDate + toDate; // // clientFactory.getEventBus().fireEvent(new DateSubmitEvent(dateRange, startDate, endDate, account)); // } // // } // // @Override // public EventBus getEventBus() { // return clientFactory.getEventBus(); // } // // // // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/AnalyticsPlace.java // public class AnalyticsPlace extends Place { // private String AnalyticsName; // // public AnalyticsPlace(String token) { // this.AnalyticsName = token; // } // // public String getAnalyticsName() { // return AnalyticsName; // } // // public static class AnalyticsPlaceTokenizer implements PlaceTokenizer<AnalyticsPlace> { // // @Override // public String getToken(AnalyticsPlace place) { // return place.getAnalyticsName(); // } // // @Override // public AnalyticsPlace getPlace(String token) { // return new AnalyticsPlace(token); // } // } // }
import com.google.gwt.activity.shared.Activity; import com.google.gwt.activity.shared.ActivityMapper; import com.google.gwt.place.shared.Place; import gov.wa.wsdot.apps.analytics.client.activities.twitter.AnalyticsActivity; import gov.wa.wsdot.apps.analytics.client.activities.twitter.AnalyticsPlace;
/* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client; public class AppActivityMapper implements ActivityMapper { private ClientFactory clientFactory; public AppActivityMapper(ClientFactory clientFactory) { super(); this.clientFactory = clientFactory; } @Override public Activity getActivity(Place place) { if (place instanceof AnalyticsPlace)
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/AnalyticsActivity.java // public class AnalyticsActivity extends AbstractActivity implements AnalyticsView.Presenter { // // private final ClientFactory clientFactory; // private String name; // // private AnalyticsView view; // // public AnalyticsActivity(AnalyticsPlace place, ClientFactory clientFactory) { // this.name = place.getAnalyticsName(); // this.clientFactory = clientFactory; // } // // @Override // public void start(AcceptsOneWidget panel, EventBus eventBus) { // view = clientFactory.getAnalyticsView(); // view.setPresenter(this); // panel.setWidget(view.asWidget()); // // } // // @Override // public void onDateSubmit(Date startDate, Date endDate, String account) { // // DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d"); // // if (startDate.getTime() > endDate.getTime()) { // // MaterialToast.fireToast("Whoops! Invalid date range.", 1000); // } else { // String fromDate = fmt.format(startDate); // String toDate = fmt.format(endDate); // String dateRange = fromDate + toDate; // // clientFactory.getEventBus().fireEvent(new DateSubmitEvent(dateRange, startDate, endDate, account)); // } // // } // // @Override // public EventBus getEventBus() { // return clientFactory.getEventBus(); // } // // // // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/AnalyticsPlace.java // public class AnalyticsPlace extends Place { // private String AnalyticsName; // // public AnalyticsPlace(String token) { // this.AnalyticsName = token; // } // // public String getAnalyticsName() { // return AnalyticsName; // } // // public static class AnalyticsPlaceTokenizer implements PlaceTokenizer<AnalyticsPlace> { // // @Override // public String getToken(AnalyticsPlace place) { // return place.getAnalyticsName(); // } // // @Override // public AnalyticsPlace getPlace(String token) { // return new AnalyticsPlace(token); // } // } // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/AppActivityMapper.java import com.google.gwt.activity.shared.Activity; import com.google.gwt.activity.shared.ActivityMapper; import com.google.gwt.place.shared.Place; import gov.wa.wsdot.apps.analytics.client.activities.twitter.AnalyticsActivity; import gov.wa.wsdot.apps.analytics.client.activities.twitter.AnalyticsPlace; /* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client; public class AppActivityMapper implements ActivityMapper { private ClientFactory clientFactory; public AppActivityMapper(ClientFactory clientFactory) { super(); this.clientFactory = clientFactory; } @Override public Activity getActivity(Place place) { if (place instanceof AnalyticsPlace)
return new AnalyticsActivity((AnalyticsPlace) place, clientFactory);
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/ranking/RankingView.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/Mention.java // public class Mention extends JavaScriptObject { // protected Mention() {} // // public final native String getText() /*-{ return this.text }-*/; // public final native String getProfileImageUrl() /*-{ return this.profile_image_url }-*/; // public final native String getToUserIdStr() /*-{ return this.to_user_id_str }-*/; // public final native String getFromUser() /*-{ return this.from_user }-*/; // public final native int getFromUserId() /*-{ return this.from_user_id }-*/; // public final native int getToUserId() /*-{ return this.to_user_id }-*/; // public final native String getGeo() /*-{ return this.geo }-*/; // public final native double getId() /*-{ return this.id }-*/; // public final native String getIsoLanguageCode() /*-{ return this.iso_language_code }-*/; // public final native String getFromUserIdStr() /*-{ return this.from_user_id_str }-*/; // public final native String getSource() /*-{ return this.source }-*/; // public final native String getIdStr() /*-{ return this.id_str }-*/; // public final native String getCreatedAt() /*-{ return this.created_at }-*/; // public final native String getSentiment() /*-{ return this.sentiment }-*/; // public final native Entities getEntities() /*-{ return this.entities }-*/; // public final native JsArray<Mention> getMentions() /*-{ return this }-*/; // public final native User getUser() /*-{ return this.user }-*/; // public final native int getRetweet() /*-{ return this.retweet_count }-*/; // public final native int getFavorited() /*-{ return this.favorite_count }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.dom.client.Style; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.Mention; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import java.util.Date;
@UiField static MaterialPreLoader loader; @UiField static MaterialCollection mostRetweet; @UiField static MaterialCollection mostLiked; @UiField static MaterialCollection leastRetweet; @UiField static MaterialCollection leastLiked; @UiField static MaterialLink retweetTab; @UiField static MaterialLink likeTab; final Resources res;
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/Mention.java // public class Mention extends JavaScriptObject { // protected Mention() {} // // public final native String getText() /*-{ return this.text }-*/; // public final native String getProfileImageUrl() /*-{ return this.profile_image_url }-*/; // public final native String getToUserIdStr() /*-{ return this.to_user_id_str }-*/; // public final native String getFromUser() /*-{ return this.from_user }-*/; // public final native int getFromUserId() /*-{ return this.from_user_id }-*/; // public final native int getToUserId() /*-{ return this.to_user_id }-*/; // public final native String getGeo() /*-{ return this.geo }-*/; // public final native double getId() /*-{ return this.id }-*/; // public final native String getIsoLanguageCode() /*-{ return this.iso_language_code }-*/; // public final native String getFromUserIdStr() /*-{ return this.from_user_id_str }-*/; // public final native String getSource() /*-{ return this.source }-*/; // public final native String getIdStr() /*-{ return this.id_str }-*/; // public final native String getCreatedAt() /*-{ return this.created_at }-*/; // public final native String getSentiment() /*-{ return this.sentiment }-*/; // public final native Entities getEntities() /*-{ return this.entities }-*/; // public final native JsArray<Mention> getMentions() /*-{ return this }-*/; // public final native User getUser() /*-{ return this.user }-*/; // public final native int getRetweet() /*-{ return this.retweet_count }-*/; // public final native int getFavorited() /*-{ return this.favorite_count }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/ranking/RankingView.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.dom.client.Style; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.Mention; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import java.util.Date; @UiField static MaterialPreLoader loader; @UiField static MaterialCollection mostRetweet; @UiField static MaterialCollection mostLiked; @UiField static MaterialCollection leastRetweet; @UiField static MaterialCollection leastLiked; @UiField static MaterialLink retweetTab; @UiField static MaterialLink likeTab; final Resources res;
public RankingView(ClientFactory clientFactory) {
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/ranking/RankingView.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/Mention.java // public class Mention extends JavaScriptObject { // protected Mention() {} // // public final native String getText() /*-{ return this.text }-*/; // public final native String getProfileImageUrl() /*-{ return this.profile_image_url }-*/; // public final native String getToUserIdStr() /*-{ return this.to_user_id_str }-*/; // public final native String getFromUser() /*-{ return this.from_user }-*/; // public final native int getFromUserId() /*-{ return this.from_user_id }-*/; // public final native int getToUserId() /*-{ return this.to_user_id }-*/; // public final native String getGeo() /*-{ return this.geo }-*/; // public final native double getId() /*-{ return this.id }-*/; // public final native String getIsoLanguageCode() /*-{ return this.iso_language_code }-*/; // public final native String getFromUserIdStr() /*-{ return this.from_user_id_str }-*/; // public final native String getSource() /*-{ return this.source }-*/; // public final native String getIdStr() /*-{ return this.id_str }-*/; // public final native String getCreatedAt() /*-{ return this.created_at }-*/; // public final native String getSentiment() /*-{ return this.sentiment }-*/; // public final native Entities getEntities() /*-{ return this.entities }-*/; // public final native JsArray<Mention> getMentions() /*-{ return this }-*/; // public final native User getUser() /*-{ return this.user }-*/; // public final native int getRetweet() /*-{ return this.retweet_count }-*/; // public final native int getFavorited() /*-{ return this.favorite_count }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.dom.client.Style; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.Mention; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import java.util.Date;
@UiField static MaterialCollection mostLiked; @UiField static MaterialCollection leastRetweet; @UiField static MaterialCollection leastLiked; @UiField static MaterialLink retweetTab; @UiField static MaterialLink likeTab; final Resources res; public RankingView(ClientFactory clientFactory) { res = GWT.create(Resources.class); res.css().ensureInjected(); eventBinder.bindEventHandlers(this, clientFactory.getEventBus()); initWidget(uiBinder.createAndBindUi(this)); } @EventHandler
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/Mention.java // public class Mention extends JavaScriptObject { // protected Mention() {} // // public final native String getText() /*-{ return this.text }-*/; // public final native String getProfileImageUrl() /*-{ return this.profile_image_url }-*/; // public final native String getToUserIdStr() /*-{ return this.to_user_id_str }-*/; // public final native String getFromUser() /*-{ return this.from_user }-*/; // public final native int getFromUserId() /*-{ return this.from_user_id }-*/; // public final native int getToUserId() /*-{ return this.to_user_id }-*/; // public final native String getGeo() /*-{ return this.geo }-*/; // public final native double getId() /*-{ return this.id }-*/; // public final native String getIsoLanguageCode() /*-{ return this.iso_language_code }-*/; // public final native String getFromUserIdStr() /*-{ return this.from_user_id_str }-*/; // public final native String getSource() /*-{ return this.source }-*/; // public final native String getIdStr() /*-{ return this.id_str }-*/; // public final native String getCreatedAt() /*-{ return this.created_at }-*/; // public final native String getSentiment() /*-{ return this.sentiment }-*/; // public final native Entities getEntities() /*-{ return this.entities }-*/; // public final native JsArray<Mention> getMentions() /*-{ return this }-*/; // public final native User getUser() /*-{ return this.user }-*/; // public final native int getRetweet() /*-{ return this.retweet_count }-*/; // public final native int getFavorited() /*-{ return this.favorite_count }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/ranking/RankingView.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.dom.client.Style; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.Mention; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import java.util.Date; @UiField static MaterialCollection mostLiked; @UiField static MaterialCollection leastRetweet; @UiField static MaterialCollection leastLiked; @UiField static MaterialLink retweetTab; @UiField static MaterialLink likeTab; final Resources res; public RankingView(ClientFactory clientFactory) { res = GWT.create(Resources.class); res.css().ensureInjected(); eventBinder.bindEventHandlers(this, clientFactory.getEventBus()); initWidget(uiBinder.createAndBindUi(this)); } @EventHandler
void onDateSubmit(DateSubmitEvent event){
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/sources/SourcesPieChart.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/SourceSummary.java // public class SourceSummary extends JavaScriptObject { // protected SourceSummary() {} // // public final native String getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<SourceSummary> getSourceSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.PieChart; import com.googlecode.gwt.charts.client.corechart.PieChartOptions; import com.googlecode.gwt.charts.client.options.ChartArea; import com.googlecode.gwt.charts.client.options.Legend; import com.googlecode.gwt.charts.client.options.LegendPosition; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.SourceSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.ui.MaterialCardContent; import gwt.material.design.client.ui.MaterialPreLoader;
/* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter.view.sources; /** * Custom widget for displaying tweet sources data. * * Listens for DateSubmitEvents */ public class SourcesPieChart extends Composite{ interface MyEventBinder extends EventBinder<SourcesPieChart> {} private final MyEventBinder eventBinder = GWT.create(MyEventBinder.class); private static SourcesPieChartUiBinder uiBinder = GWT .create(SourcesPieChartUiBinder.class); interface SourcesPieChartUiBinder extends UiBinder<Widget, SourcesPieChart> { } @UiField static MaterialCardContent cardContent; @UiField static MaterialPreLoader sourcesLoader;
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/SourceSummary.java // public class SourceSummary extends JavaScriptObject { // protected SourceSummary() {} // // public final native String getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<SourceSummary> getSourceSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/sources/SourcesPieChart.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.PieChart; import com.googlecode.gwt.charts.client.corechart.PieChartOptions; import com.googlecode.gwt.charts.client.options.ChartArea; import com.googlecode.gwt.charts.client.options.Legend; import com.googlecode.gwt.charts.client.options.LegendPosition; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.SourceSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.ui.MaterialCardContent; import gwt.material.design.client.ui.MaterialPreLoader; /* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter.view.sources; /** * Custom widget for displaying tweet sources data. * * Listens for DateSubmitEvents */ public class SourcesPieChart extends Composite{ interface MyEventBinder extends EventBinder<SourcesPieChart> {} private final MyEventBinder eventBinder = GWT.create(MyEventBinder.class); private static SourcesPieChartUiBinder uiBinder = GWT .create(SourcesPieChartUiBinder.class); interface SourcesPieChartUiBinder extends UiBinder<Widget, SourcesPieChart> { } @UiField static MaterialCardContent cardContent; @UiField static MaterialPreLoader sourcesLoader;
final Resources res;
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/sources/SourcesPieChart.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/SourceSummary.java // public class SourceSummary extends JavaScriptObject { // protected SourceSummary() {} // // public final native String getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<SourceSummary> getSourceSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.PieChart; import com.googlecode.gwt.charts.client.corechart.PieChartOptions; import com.googlecode.gwt.charts.client.options.ChartArea; import com.googlecode.gwt.charts.client.options.Legend; import com.googlecode.gwt.charts.client.options.LegendPosition; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.SourceSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.ui.MaterialCardContent; import gwt.material.design.client.ui.MaterialPreLoader;
/* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter.view.sources; /** * Custom widget for displaying tweet sources data. * * Listens for DateSubmitEvents */ public class SourcesPieChart extends Composite{ interface MyEventBinder extends EventBinder<SourcesPieChart> {} private final MyEventBinder eventBinder = GWT.create(MyEventBinder.class); private static SourcesPieChartUiBinder uiBinder = GWT .create(SourcesPieChartUiBinder.class); interface SourcesPieChartUiBinder extends UiBinder<Widget, SourcesPieChart> { } @UiField static MaterialCardContent cardContent; @UiField static MaterialPreLoader sourcesLoader; final Resources res;
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/SourceSummary.java // public class SourceSummary extends JavaScriptObject { // protected SourceSummary() {} // // public final native String getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<SourceSummary> getSourceSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/sources/SourcesPieChart.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.PieChart; import com.googlecode.gwt.charts.client.corechart.PieChartOptions; import com.googlecode.gwt.charts.client.options.ChartArea; import com.googlecode.gwt.charts.client.options.Legend; import com.googlecode.gwt.charts.client.options.LegendPosition; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.SourceSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.ui.MaterialCardContent; import gwt.material.design.client.ui.MaterialPreLoader; /* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter.view.sources; /** * Custom widget for displaying tweet sources data. * * Listens for DateSubmitEvents */ public class SourcesPieChart extends Composite{ interface MyEventBinder extends EventBinder<SourcesPieChart> {} private final MyEventBinder eventBinder = GWT.create(MyEventBinder.class); private static SourcesPieChartUiBinder uiBinder = GWT .create(SourcesPieChartUiBinder.class); interface SourcesPieChartUiBinder extends UiBinder<Widget, SourcesPieChart> { } @UiField static MaterialCardContent cardContent; @UiField static MaterialPreLoader sourcesLoader; final Resources res;
private static final String JSON_URL = Consts.HOST_URL + "/mentions/source";
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/sources/SourcesPieChart.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/SourceSummary.java // public class SourceSummary extends JavaScriptObject { // protected SourceSummary() {} // // public final native String getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<SourceSummary> getSourceSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.PieChart; import com.googlecode.gwt.charts.client.corechart.PieChartOptions; import com.googlecode.gwt.charts.client.options.ChartArea; import com.googlecode.gwt.charts.client.options.Legend; import com.googlecode.gwt.charts.client.options.LegendPosition; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.SourceSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.ui.MaterialCardContent; import gwt.material.design.client.ui.MaterialPreLoader;
/* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter.view.sources; /** * Custom widget for displaying tweet sources data. * * Listens for DateSubmitEvents */ public class SourcesPieChart extends Composite{ interface MyEventBinder extends EventBinder<SourcesPieChart> {} private final MyEventBinder eventBinder = GWT.create(MyEventBinder.class); private static SourcesPieChartUiBinder uiBinder = GWT .create(SourcesPieChartUiBinder.class); interface SourcesPieChartUiBinder extends UiBinder<Widget, SourcesPieChart> { } @UiField static MaterialCardContent cardContent; @UiField static MaterialPreLoader sourcesLoader; final Resources res; private static final String JSON_URL = Consts.HOST_URL + "/mentions/source";
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/SourceSummary.java // public class SourceSummary extends JavaScriptObject { // protected SourceSummary() {} // // public final native String getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<SourceSummary> getSourceSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/sources/SourcesPieChart.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.PieChart; import com.googlecode.gwt.charts.client.corechart.PieChartOptions; import com.googlecode.gwt.charts.client.options.ChartArea; import com.googlecode.gwt.charts.client.options.Legend; import com.googlecode.gwt.charts.client.options.LegendPosition; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.SourceSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.ui.MaterialCardContent; import gwt.material.design.client.ui.MaterialPreLoader; /* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter.view.sources; /** * Custom widget for displaying tweet sources data. * * Listens for DateSubmitEvents */ public class SourcesPieChart extends Composite{ interface MyEventBinder extends EventBinder<SourcesPieChart> {} private final MyEventBinder eventBinder = GWT.create(MyEventBinder.class); private static SourcesPieChartUiBinder uiBinder = GWT .create(SourcesPieChartUiBinder.class); interface SourcesPieChartUiBinder extends UiBinder<Widget, SourcesPieChart> { } @UiField static MaterialCardContent cardContent; @UiField static MaterialPreLoader sourcesLoader; final Resources res; private static final String JSON_URL = Consts.HOST_URL + "/mentions/source";
static JsArray<SourceSummary> sourceSummary;
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/sources/SourcesPieChart.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/SourceSummary.java // public class SourceSummary extends JavaScriptObject { // protected SourceSummary() {} // // public final native String getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<SourceSummary> getSourceSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.PieChart; import com.googlecode.gwt.charts.client.corechart.PieChartOptions; import com.googlecode.gwt.charts.client.options.ChartArea; import com.googlecode.gwt.charts.client.options.Legend; import com.googlecode.gwt.charts.client.options.LegendPosition; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.SourceSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.ui.MaterialCardContent; import gwt.material.design.client.ui.MaterialPreLoader;
/* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter.view.sources; /** * Custom widget for displaying tweet sources data. * * Listens for DateSubmitEvents */ public class SourcesPieChart extends Composite{ interface MyEventBinder extends EventBinder<SourcesPieChart> {} private final MyEventBinder eventBinder = GWT.create(MyEventBinder.class); private static SourcesPieChartUiBinder uiBinder = GWT .create(SourcesPieChartUiBinder.class); interface SourcesPieChartUiBinder extends UiBinder<Widget, SourcesPieChart> { } @UiField static MaterialCardContent cardContent; @UiField static MaterialPreLoader sourcesLoader; final Resources res; private static final String JSON_URL = Consts.HOST_URL + "/mentions/source"; static JsArray<SourceSummary> sourceSummary; private static PieChart pieChart;
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/SourceSummary.java // public class SourceSummary extends JavaScriptObject { // protected SourceSummary() {} // // public final native String getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<SourceSummary> getSourceSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/sources/SourcesPieChart.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.PieChart; import com.googlecode.gwt.charts.client.corechart.PieChartOptions; import com.googlecode.gwt.charts.client.options.ChartArea; import com.googlecode.gwt.charts.client.options.Legend; import com.googlecode.gwt.charts.client.options.LegendPosition; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.SourceSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.ui.MaterialCardContent; import gwt.material.design.client.ui.MaterialPreLoader; /* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter.view.sources; /** * Custom widget for displaying tweet sources data. * * Listens for DateSubmitEvents */ public class SourcesPieChart extends Composite{ interface MyEventBinder extends EventBinder<SourcesPieChart> {} private final MyEventBinder eventBinder = GWT.create(MyEventBinder.class); private static SourcesPieChartUiBinder uiBinder = GWT .create(SourcesPieChartUiBinder.class); interface SourcesPieChartUiBinder extends UiBinder<Widget, SourcesPieChart> { } @UiField static MaterialCardContent cardContent; @UiField static MaterialPreLoader sourcesLoader; final Resources res; private static final String JSON_URL = Consts.HOST_URL + "/mentions/source"; static JsArray<SourceSummary> sourceSummary; private static PieChart pieChart;
public SourcesPieChart(ClientFactory clientFactory) {
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/sources/SourcesPieChart.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/SourceSummary.java // public class SourceSummary extends JavaScriptObject { // protected SourceSummary() {} // // public final native String getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<SourceSummary> getSourceSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.PieChart; import com.googlecode.gwt.charts.client.corechart.PieChartOptions; import com.googlecode.gwt.charts.client.options.ChartArea; import com.googlecode.gwt.charts.client.options.Legend; import com.googlecode.gwt.charts.client.options.LegendPosition; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.SourceSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.ui.MaterialCardContent; import gwt.material.design.client.ui.MaterialPreLoader;
/* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter.view.sources; /** * Custom widget for displaying tweet sources data. * * Listens for DateSubmitEvents */ public class SourcesPieChart extends Composite{ interface MyEventBinder extends EventBinder<SourcesPieChart> {} private final MyEventBinder eventBinder = GWT.create(MyEventBinder.class); private static SourcesPieChartUiBinder uiBinder = GWT .create(SourcesPieChartUiBinder.class); interface SourcesPieChartUiBinder extends UiBinder<Widget, SourcesPieChart> { } @UiField static MaterialCardContent cardContent; @UiField static MaterialPreLoader sourcesLoader; final Resources res; private static final String JSON_URL = Consts.HOST_URL + "/mentions/source"; static JsArray<SourceSummary> sourceSummary; private static PieChart pieChart; public SourcesPieChart(ClientFactory clientFactory) { res = GWT.create(Resources.class); res.css().ensureInjected(); eventBinder.bindEventHandlers(this, clientFactory.getEventBus()); initWidget(uiBinder.createAndBindUi(this)); } @EventHandler
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/resources/Resources.java // public interface Resources extends ClientBundle { // public static final Resources INSTANCE = GWT.create(Resources.class); // // @Source("GlobalStyles.css") // public Styles css(); // // @Source("WSDOTacronymWhite.png") // ImageResource tacronymWhiteLogoPNG(); // // public interface Styles extends CssResource { // // CSS classes // // String loader(); // // String logo(); // // // Graph // String graphBlock(); // String overflowHidden(); // } // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/SourceSummary.java // public class SourceSummary extends JavaScriptObject { // protected SourceSummary() {} // // public final native String getId() /*-{ return this._id }-*/; // public final native int getValue() /*-{ return this.value }-*/; // public final native JsArray<SourceSummary> getSourceSummary() /*-{ return this }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/sources/SourcesPieChart.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import com.google.web.bindery.event.shared.binder.EventHandler; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.corechart.PieChart; import com.googlecode.gwt.charts.client.corechart.PieChartOptions; import com.googlecode.gwt.charts.client.options.ChartArea; import com.googlecode.gwt.charts.client.options.Legend; import com.googlecode.gwt.charts.client.options.LegendPosition; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gov.wa.wsdot.apps.analytics.client.resources.Resources; import gov.wa.wsdot.apps.analytics.shared.SourceSummary; import gov.wa.wsdot.apps.analytics.util.Consts; import gwt.material.design.client.ui.MaterialCardContent; import gwt.material.design.client.ui.MaterialPreLoader; /* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter.view.sources; /** * Custom widget for displaying tweet sources data. * * Listens for DateSubmitEvents */ public class SourcesPieChart extends Composite{ interface MyEventBinder extends EventBinder<SourcesPieChart> {} private final MyEventBinder eventBinder = GWT.create(MyEventBinder.class); private static SourcesPieChartUiBinder uiBinder = GWT .create(SourcesPieChartUiBinder.class); interface SourcesPieChartUiBinder extends UiBinder<Widget, SourcesPieChart> { } @UiField static MaterialCardContent cardContent; @UiField static MaterialPreLoader sourcesLoader; final Resources res; private static final String JSON_URL = Consts.HOST_URL + "/mentions/source"; static JsArray<SourceSummary> sourceSummary; private static PieChart pieChart; public SourcesPieChart(ClientFactory clientFactory) { res = GWT.create(Resources.class); res.css().ensureInjected(); eventBinder.bindEventHandlers(this, clientFactory.getEventBus()); initWidget(uiBinder.createAndBindUi(this)); } @EventHandler
void onDateSubmit(DateSubmitEvent event){
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/tweet/TweetView.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/Mention.java // public class Mention extends JavaScriptObject { // protected Mention() {} // // public final native String getText() /*-{ return this.text }-*/; // public final native String getProfileImageUrl() /*-{ return this.profile_image_url }-*/; // public final native String getToUserIdStr() /*-{ return this.to_user_id_str }-*/; // public final native String getFromUser() /*-{ return this.from_user }-*/; // public final native int getFromUserId() /*-{ return this.from_user_id }-*/; // public final native int getToUserId() /*-{ return this.to_user_id }-*/; // public final native String getGeo() /*-{ return this.geo }-*/; // public final native double getId() /*-{ return this.id }-*/; // public final native String getIsoLanguageCode() /*-{ return this.iso_language_code }-*/; // public final native String getFromUserIdStr() /*-{ return this.from_user_id_str }-*/; // public final native String getSource() /*-{ return this.source }-*/; // public final native String getIdStr() /*-{ return this.id_str }-*/; // public final native String getCreatedAt() /*-{ return this.created_at }-*/; // public final native String getSentiment() /*-{ return this.sentiment }-*/; // public final native Entities getEntities() /*-{ return this.entities }-*/; // public final native JsArray<Mention> getMentions() /*-{ return this }-*/; // public final native User getUser() /*-{ return this.user }-*/; // public final native int getRetweet() /*-{ return this.retweet_count }-*/; // public final native int getFavorited() /*-{ return this.favorite_count }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import gwt.material.design.addins.client.pathanimator.MaterialPathAnimator; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import gov.wa.wsdot.apps.analytics.shared.Mention; import gov.wa.wsdot.apps.analytics.util.Consts;
/* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter.view.tweet; /** * A custom view for a tweet. Uses a MaterialCard as a base. Besides displaying content for the tweet has logic for * editing a tweets sentiment value. * * Is used by TweetsView */ public class TweetView extends Composite { private static TweetViewUiBinder uiBinder = GWT .create(TweetViewUiBinder.class); interface TweetViewUiBinder extends UiBinder<Widget, TweetView> { } @UiField MaterialImage image; @UiField MaterialLabel title; @UiField MaterialLabel content; @UiField MaterialLink updated; @UiField MaterialLink sentiment; @UiField MaterialCard sentimentDialog; @UiField MaterialLink positive; @UiField MaterialLink negative; @UiField MaterialLink neutral; @UiField MaterialButton btnClose;
// Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/Mention.java // public class Mention extends JavaScriptObject { // protected Mention() {} // // public final native String getText() /*-{ return this.text }-*/; // public final native String getProfileImageUrl() /*-{ return this.profile_image_url }-*/; // public final native String getToUserIdStr() /*-{ return this.to_user_id_str }-*/; // public final native String getFromUser() /*-{ return this.from_user }-*/; // public final native int getFromUserId() /*-{ return this.from_user_id }-*/; // public final native int getToUserId() /*-{ return this.to_user_id }-*/; // public final native String getGeo() /*-{ return this.geo }-*/; // public final native double getId() /*-{ return this.id }-*/; // public final native String getIsoLanguageCode() /*-{ return this.iso_language_code }-*/; // public final native String getFromUserIdStr() /*-{ return this.from_user_id_str }-*/; // public final native String getSource() /*-{ return this.source }-*/; // public final native String getIdStr() /*-{ return this.id_str }-*/; // public final native String getCreatedAt() /*-{ return this.created_at }-*/; // public final native String getSentiment() /*-{ return this.sentiment }-*/; // public final native Entities getEntities() /*-{ return this.entities }-*/; // public final native JsArray<Mention> getMentions() /*-{ return this }-*/; // public final native User getUser() /*-{ return this.user }-*/; // public final native int getRetweet() /*-{ return this.retweet_count }-*/; // public final native int getFavorited() /*-{ return this.favorite_count }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/tweet/TweetView.java import gwt.material.design.addins.client.pathanimator.MaterialPathAnimator; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import gov.wa.wsdot.apps.analytics.shared.Mention; import gov.wa.wsdot.apps.analytics.util.Consts; /* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter.view.tweet; /** * A custom view for a tweet. Uses a MaterialCard as a base. Besides displaying content for the tweet has logic for * editing a tweets sentiment value. * * Is used by TweetsView */ public class TweetView extends Composite { private static TweetViewUiBinder uiBinder = GWT .create(TweetViewUiBinder.class); interface TweetViewUiBinder extends UiBinder<Widget, TweetView> { } @UiField MaterialImage image; @UiField MaterialLabel title; @UiField MaterialLabel content; @UiField MaterialLink updated; @UiField MaterialLink sentiment; @UiField MaterialCard sentimentDialog; @UiField MaterialLink positive; @UiField MaterialLink negative; @UiField MaterialLink neutral; @UiField MaterialButton btnClose;
private static final String JSON_URL = Consts.HOST_URL + "/mentions/sentiment/edit/";
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/tweet/TweetView.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/Mention.java // public class Mention extends JavaScriptObject { // protected Mention() {} // // public final native String getText() /*-{ return this.text }-*/; // public final native String getProfileImageUrl() /*-{ return this.profile_image_url }-*/; // public final native String getToUserIdStr() /*-{ return this.to_user_id_str }-*/; // public final native String getFromUser() /*-{ return this.from_user }-*/; // public final native int getFromUserId() /*-{ return this.from_user_id }-*/; // public final native int getToUserId() /*-{ return this.to_user_id }-*/; // public final native String getGeo() /*-{ return this.geo }-*/; // public final native double getId() /*-{ return this.id }-*/; // public final native String getIsoLanguageCode() /*-{ return this.iso_language_code }-*/; // public final native String getFromUserIdStr() /*-{ return this.from_user_id_str }-*/; // public final native String getSource() /*-{ return this.source }-*/; // public final native String getIdStr() /*-{ return this.id_str }-*/; // public final native String getCreatedAt() /*-{ return this.created_at }-*/; // public final native String getSentiment() /*-{ return this.sentiment }-*/; // public final native Entities getEntities() /*-{ return this.entities }-*/; // public final native JsArray<Mention> getMentions() /*-{ return this }-*/; // public final native User getUser() /*-{ return this.user }-*/; // public final native int getRetweet() /*-{ return this.retweet_count }-*/; // public final native int getFavorited() /*-{ return this.favorite_count }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import gwt.material.design.addins.client.pathanimator.MaterialPathAnimator; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import gov.wa.wsdot.apps.analytics.shared.Mention; import gov.wa.wsdot.apps.analytics.util.Consts;
updateSentiment("positive"); } @UiHandler("negative") public void onNegClick(ClickEvent e){ MaterialPathAnimator.reverseAnimate(sentiment.getElement(), sentimentDialog.getElement()); sentimentDialog.setVisible(false); updateSentiment("negative"); } @UiHandler("neutral") public void onNeuClick(ClickEvent e){ MaterialPathAnimator.reverseAnimate(sentiment.getElement(), sentimentDialog.getElement()); sentimentDialog.setVisible(false); updateSentiment("neutral"); } @UiHandler("btnClose") public void onClose(ClickEvent e){ MaterialPathAnimator.reverseAnimate(sentiment.getElement(), sentimentDialog.getElement()); sentimentDialog.setVisible(false); } private void updateSentiment(final String sentimentType){ String url = JSON_URL + this.id + "/" + sentimentType; JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); // Set timeout for 30 seconds (30000 milliseconds) jsonp.setTimeout(30000);
// Path: src/main/java/gov/wa/wsdot/apps/analytics/shared/Mention.java // public class Mention extends JavaScriptObject { // protected Mention() {} // // public final native String getText() /*-{ return this.text }-*/; // public final native String getProfileImageUrl() /*-{ return this.profile_image_url }-*/; // public final native String getToUserIdStr() /*-{ return this.to_user_id_str }-*/; // public final native String getFromUser() /*-{ return this.from_user }-*/; // public final native int getFromUserId() /*-{ return this.from_user_id }-*/; // public final native int getToUserId() /*-{ return this.to_user_id }-*/; // public final native String getGeo() /*-{ return this.geo }-*/; // public final native double getId() /*-{ return this.id }-*/; // public final native String getIsoLanguageCode() /*-{ return this.iso_language_code }-*/; // public final native String getFromUserIdStr() /*-{ return this.from_user_id_str }-*/; // public final native String getSource() /*-{ return this.source }-*/; // public final native String getIdStr() /*-{ return this.id_str }-*/; // public final native String getCreatedAt() /*-{ return this.created_at }-*/; // public final native String getSentiment() /*-{ return this.sentiment }-*/; // public final native Entities getEntities() /*-{ return this.entities }-*/; // public final native JsArray<Mention> getMentions() /*-{ return this }-*/; // public final native User getUser() /*-{ return this.user }-*/; // public final native int getRetweet() /*-{ return this.retweet_count }-*/; // public final native int getFavorited() /*-{ return this.favorite_count }-*/; // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/tweet/TweetView.java import gwt.material.design.addins.client.pathanimator.MaterialPathAnimator; import gwt.material.design.client.constants.IconType; import gwt.material.design.client.ui.*; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.jsonp.client.JsonpRequestBuilder; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import gov.wa.wsdot.apps.analytics.shared.Mention; import gov.wa.wsdot.apps.analytics.util.Consts; updateSentiment("positive"); } @UiHandler("negative") public void onNegClick(ClickEvent e){ MaterialPathAnimator.reverseAnimate(sentiment.getElement(), sentimentDialog.getElement()); sentimentDialog.setVisible(false); updateSentiment("negative"); } @UiHandler("neutral") public void onNeuClick(ClickEvent e){ MaterialPathAnimator.reverseAnimate(sentiment.getElement(), sentimentDialog.getElement()); sentimentDialog.setVisible(false); updateSentiment("neutral"); } @UiHandler("btnClose") public void onClose(ClickEvent e){ MaterialPathAnimator.reverseAnimate(sentiment.getElement(), sentimentDialog.getElement()); sentimentDialog.setVisible(false); } private void updateSentiment(final String sentimentType){ String url = JSON_URL + this.id + "/" + sentimentType; JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); // Set timeout for 30 seconds (30000 milliseconds) jsonp.setTimeout(30000);
jsonp.requestObject(url, new AsyncCallback<Mention>() {
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/AnalyticsActivity.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // }
import com.google.gwt.activity.shared.AbstractActivity; import com.google.gwt.event.shared.EventBus; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.ui.AcceptsOneWidget; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gwt.material.design.client.ui.MaterialToast; import java.util.Date;
/* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter; /** * Main twitter analytics activity */ public class AnalyticsActivity extends AbstractActivity implements AnalyticsView.Presenter { private final ClientFactory clientFactory; private String name; private AnalyticsView view; public AnalyticsActivity(AnalyticsPlace place, ClientFactory clientFactory) { this.name = place.getAnalyticsName(); this.clientFactory = clientFactory; } @Override public void start(AcceptsOneWidget panel, EventBus eventBus) { view = clientFactory.getAnalyticsView(); view.setPresenter(this); panel.setWidget(view.asWidget()); } @Override public void onDateSubmit(Date startDate, Date endDate, String account) { DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d"); if (startDate.getTime() > endDate.getTime()) { MaterialToast.fireToast("Whoops! Invalid date range.", 1000); } else { String fromDate = fmt.format(startDate); String toDate = fmt.format(endDate); String dateRange = fromDate + toDate;
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/DateSubmitEvent.java // public class DateSubmitEvent extends GenericEvent { // // // private final String dateRange; // private final String account; // private final Date startDate; // private final Date endDate; // // public DateSubmitEvent(String dateRange, Date startDate, Date endDate, String account) { // this.dateRange = dateRange; // this.account = account; // this.startDate = startDate; // this.endDate = endDate; // } // // public String getDateRange() { // return this.dateRange; // } // // public String getAccount() { // return this.account; // } // // public Date getStartDate(){ return this.startDate;} // // public Date getEndDate(){ return this.endDate;} // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/AnalyticsActivity.java import com.google.gwt.activity.shared.AbstractActivity; import com.google.gwt.event.shared.EventBus; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.ui.AcceptsOneWidget; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.DateSubmitEvent; import gwt.material.design.client.ui.MaterialToast; import java.util.Date; /* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client.activities.twitter; /** * Main twitter analytics activity */ public class AnalyticsActivity extends AbstractActivity implements AnalyticsView.Presenter { private final ClientFactory clientFactory; private String name; private AnalyticsView view; public AnalyticsActivity(AnalyticsPlace place, ClientFactory clientFactory) { this.name = place.getAnalyticsName(); this.clientFactory = clientFactory; } @Override public void start(AcceptsOneWidget panel, EventBus eventBus) { view = clientFactory.getAnalyticsView(); view.setPresenter(this); panel.setWidget(view.asWidget()); } @Override public void onDateSubmit(Date startDate, Date endDate, String account) { DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d"); if (startDate.getTime() > endDate.getTime()) { MaterialToast.fireToast("Whoops! Invalid date range.", 1000); } else { String fromDate = fmt.format(startDate); String toDate = fmt.format(endDate); String dateRange = fromDate + toDate;
clientFactory.getEventBus().fireEvent(new DateSubmitEvent(dateRange, startDate, endDate, account));
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/AnalyticsView.java // public interface AnalyticsView extends IsWidget { // // void setPresenter(Presenter presenter); // // public interface Presenter { // // public void onDateSubmit(Date start, Date end, String account); // // public EventBus getEventBus(); // } // // }
import com.google.gwt.event.shared.EventBus; import com.google.gwt.place.shared.PlaceController; import gov.wa.wsdot.apps.analytics.client.activities.twitter.AnalyticsView;
/* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client; public interface ClientFactory { EventBus getEventBus(); PlaceController getPlaceController();
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/AnalyticsView.java // public interface AnalyticsView extends IsWidget { // // void setPresenter(Presenter presenter); // // public interface Presenter { // // public void onDateSubmit(Date start, Date end, String account); // // public EventBus getEventBus(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java import com.google.gwt.event.shared.EventBus; import com.google.gwt.place.shared.PlaceController; import gov.wa.wsdot.apps.analytics.client.activities.twitter.AnalyticsView; /* * Copyright (c) 2016 Washington State Department of Transportation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package gov.wa.wsdot.apps.analytics.client; public interface ClientFactory { EventBus getEventBus(); PlaceController getPlaceController();
AnalyticsView getAnalyticsView();
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/search/AdvSearchView.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/SearchEvent.java // public class SearchEvent extends GenericEvent { // // private String searchText; // private String account = "All"; // private int searchType = 0; // private String startDate = null; // private String endDate = null; // private int mediaOnly = 0; // // public SearchEvent(String text) { // this.searchText = text; // } // // public SearchEvent(String text, int type, String account, int mediaOnly, String startDate, String endDate) { // this.searchText = text; // this.searchType = type; // this.account = account; // this.mediaOnly = mediaOnly; // this.startDate = startDate; // this.endDate = endDate; // } // // public int getSearchType(){ // return this.searchType; // } // // public String getAccount(){ // return this.account; // } // // public int getMediaOnly() { // return this.mediaOnly; // } // // public String getEndDate(){ // return this.endDate; // } // // public String getStartDate(){ // return this.startDate; // } // // public String getSearchText() { // return this.searchText;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import gwt.material.design.client.ui.*; import java.util.Date; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.SearchEvent; import gov.wa.wsdot.apps.analytics.util.Consts;
MaterialListBox searchAccountPicker; @UiField static MaterialListBox searchTypePicker; @UiField static MaterialDatePicker searchdpStart; @UiField static MaterialDatePicker searchdpEnd; @UiField static MaterialTextBox advSearchTextBox; @UiField static MaterialCheckBox mediaOnly; @UiField static MaterialButton closeAdvSearchBtn; @UiField static MaterialButton clearAdvSearchBtn;
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/SearchEvent.java // public class SearchEvent extends GenericEvent { // // private String searchText; // private String account = "All"; // private int searchType = 0; // private String startDate = null; // private String endDate = null; // private int mediaOnly = 0; // // public SearchEvent(String text) { // this.searchText = text; // } // // public SearchEvent(String text, int type, String account, int mediaOnly, String startDate, String endDate) { // this.searchText = text; // this.searchType = type; // this.account = account; // this.mediaOnly = mediaOnly; // this.startDate = startDate; // this.endDate = endDate; // } // // public int getSearchType(){ // return this.searchType; // } // // public String getAccount(){ // return this.account; // } // // public int getMediaOnly() { // return this.mediaOnly; // } // // public String getEndDate(){ // return this.endDate; // } // // public String getStartDate(){ // return this.startDate; // } // // public String getSearchText() { // return this.searchText;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/search/AdvSearchView.java import gwt.material.design.client.ui.*; import java.util.Date; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.SearchEvent; import gov.wa.wsdot.apps.analytics.util.Consts; MaterialListBox searchAccountPicker; @UiField static MaterialListBox searchTypePicker; @UiField static MaterialDatePicker searchdpStart; @UiField static MaterialDatePicker searchdpEnd; @UiField static MaterialTextBox advSearchTextBox; @UiField static MaterialCheckBox mediaOnly; @UiField static MaterialButton closeAdvSearchBtn; @UiField static MaterialButton clearAdvSearchBtn;
private static final String JSON_URL_SUGGESTION = Consts.HOST_URL + "/search/suggest/";
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/search/AdvSearchView.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/SearchEvent.java // public class SearchEvent extends GenericEvent { // // private String searchText; // private String account = "All"; // private int searchType = 0; // private String startDate = null; // private String endDate = null; // private int mediaOnly = 0; // // public SearchEvent(String text) { // this.searchText = text; // } // // public SearchEvent(String text, int type, String account, int mediaOnly, String startDate, String endDate) { // this.searchText = text; // this.searchType = type; // this.account = account; // this.mediaOnly = mediaOnly; // this.startDate = startDate; // this.endDate = endDate; // } // // public int getSearchType(){ // return this.searchType; // } // // public String getAccount(){ // return this.account; // } // // public int getMediaOnly() { // return this.mediaOnly; // } // // public String getEndDate(){ // return this.endDate; // } // // public String getStartDate(){ // return this.startDate; // } // // public String getSearchText() { // return this.searchText;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import gwt.material.design.client.ui.*; import java.util.Date; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.SearchEvent; import gov.wa.wsdot.apps.analytics.util.Consts;
static MaterialListBox searchTypePicker; @UiField static MaterialDatePicker searchdpStart; @UiField static MaterialDatePicker searchdpEnd; @UiField static MaterialTextBox advSearchTextBox; @UiField static MaterialCheckBox mediaOnly; @UiField static MaterialButton closeAdvSearchBtn; @UiField static MaterialButton clearAdvSearchBtn; private static final String JSON_URL_SUGGESTION = Consts.HOST_URL + "/search/suggest/"; private static int pageNum = 1; private static String searchText = "";
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/SearchEvent.java // public class SearchEvent extends GenericEvent { // // private String searchText; // private String account = "All"; // private int searchType = 0; // private String startDate = null; // private String endDate = null; // private int mediaOnly = 0; // // public SearchEvent(String text) { // this.searchText = text; // } // // public SearchEvent(String text, int type, String account, int mediaOnly, String startDate, String endDate) { // this.searchText = text; // this.searchType = type; // this.account = account; // this.mediaOnly = mediaOnly; // this.startDate = startDate; // this.endDate = endDate; // } // // public int getSearchType(){ // return this.searchType; // } // // public String getAccount(){ // return this.account; // } // // public int getMediaOnly() { // return this.mediaOnly; // } // // public String getEndDate(){ // return this.endDate; // } // // public String getStartDate(){ // return this.startDate; // } // // public String getSearchText() { // return this.searchText;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/search/AdvSearchView.java import gwt.material.design.client.ui.*; import java.util.Date; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.SearchEvent; import gov.wa.wsdot.apps.analytics.util.Consts; static MaterialListBox searchTypePicker; @UiField static MaterialDatePicker searchdpStart; @UiField static MaterialDatePicker searchdpEnd; @UiField static MaterialTextBox advSearchTextBox; @UiField static MaterialCheckBox mediaOnly; @UiField static MaterialButton closeAdvSearchBtn; @UiField static MaterialButton clearAdvSearchBtn; private static final String JSON_URL_SUGGESTION = Consts.HOST_URL + "/search/suggest/"; private static int pageNum = 1; private static String searchText = "";
private static ClientFactory clientFactory;
WSDOT/social-analytics
src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/search/AdvSearchView.java
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/SearchEvent.java // public class SearchEvent extends GenericEvent { // // private String searchText; // private String account = "All"; // private int searchType = 0; // private String startDate = null; // private String endDate = null; // private int mediaOnly = 0; // // public SearchEvent(String text) { // this.searchText = text; // } // // public SearchEvent(String text, int type, String account, int mediaOnly, String startDate, String endDate) { // this.searchText = text; // this.searchType = type; // this.account = account; // this.mediaOnly = mediaOnly; // this.startDate = startDate; // this.endDate = endDate; // } // // public int getSearchType(){ // return this.searchType; // } // // public String getAccount(){ // return this.account; // } // // public int getMediaOnly() { // return this.mediaOnly; // } // // public String getEndDate(){ // return this.endDate; // } // // public String getStartDate(){ // return this.startDate; // } // // public String getSearchText() { // return this.searchText;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // }
import gwt.material.design.client.ui.*; import java.util.Date; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.SearchEvent; import gov.wa.wsdot.apps.analytics.util.Consts;
initWidget(uiBinder.createAndBindUi(this)); this.clientFactory = clientFactory; } @UiHandler("searchBtn") void onSearch(ClickEvent e){ if (advSearchTextBox.getText().equalsIgnoreCase("")){ advSearchTextBox.setText(" "); } DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d"); String endDate = null; String startDate = null; if (searchdpStart.getDate() != null) { startDate = fmt.format(searchdpStart.getDate()); } if (searchdpEnd.getDate() != null) { endDate = fmt.format(searchdpEnd.getDate()); } String account = searchAccountPicker.getSelectedItemText(); int searchType = Integer.valueOf(searchTypePicker.getSelectedValue()); String searchTerm = advSearchTextBox.getText(); int media = (mediaOnly.getValue() ? 1 : 0);
// Path: src/main/java/gov/wa/wsdot/apps/analytics/client/ClientFactory.java // public interface ClientFactory { // EventBus getEventBus(); // PlaceController getPlaceController(); // AnalyticsView getAnalyticsView(); // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/events/SearchEvent.java // public class SearchEvent extends GenericEvent { // // private String searchText; // private String account = "All"; // private int searchType = 0; // private String startDate = null; // private String endDate = null; // private int mediaOnly = 0; // // public SearchEvent(String text) { // this.searchText = text; // } // // public SearchEvent(String text, int type, String account, int mediaOnly, String startDate, String endDate) { // this.searchText = text; // this.searchType = type; // this.account = account; // this.mediaOnly = mediaOnly; // this.startDate = startDate; // this.endDate = endDate; // } // // public int getSearchType(){ // return this.searchType; // } // // public String getAccount(){ // return this.account; // } // // public int getMediaOnly() { // return this.mediaOnly; // } // // public String getEndDate(){ // return this.endDate; // } // // public String getStartDate(){ // return this.startDate; // } // // public String getSearchText() { // return this.searchText;} // } // // Path: src/main/java/gov/wa/wsdot/apps/analytics/util/Consts.java // public final class Consts { // // public static final String HOST_URL = "http://127.0.0.1:3001"; // // public static final String DEFAULT_ACCOUNT = "wsdot"; // // /** // * The caller references the constants using <tt>Consts.EMPTY_STRING</tt>, // * and so on. Thus, the caller should be prevented from constructing objects of // * this class, by declaring this private constructor. // */ // private Consts() { // //this prevents even the native class from // //calling this ctor as well : // throw new AssertionError(); // } // // } // Path: src/main/java/gov/wa/wsdot/apps/analytics/client/activities/twitter/view/search/AdvSearchView.java import gwt.material.design.client.ui.*; import java.util.Date; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.binder.EventBinder; import gov.wa.wsdot.apps.analytics.client.ClientFactory; import gov.wa.wsdot.apps.analytics.client.activities.events.SearchEvent; import gov.wa.wsdot.apps.analytics.util.Consts; initWidget(uiBinder.createAndBindUi(this)); this.clientFactory = clientFactory; } @UiHandler("searchBtn") void onSearch(ClickEvent e){ if (advSearchTextBox.getText().equalsIgnoreCase("")){ advSearchTextBox.setText(" "); } DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d"); String endDate = null; String startDate = null; if (searchdpStart.getDate() != null) { startDate = fmt.format(searchdpStart.getDate()); } if (searchdpEnd.getDate() != null) { endDate = fmt.format(searchdpEnd.getDate()); } String account = searchAccountPicker.getSelectedItemText(); int searchType = Integer.valueOf(searchTypePicker.getSelectedValue()); String searchTerm = advSearchTextBox.getText(); int media = (mediaOnly.getValue() ? 1 : 0);
SearchEvent searchEvent = new SearchEvent(searchTerm, searchType, account, media, startDate, endDate);
mdht/mdht
cda/plugins/org.openhealthtools.mdht.uml.cda.ui/src/org/openhealthtools/mdht/uml/cda/ui/wizards/NewCDAModelProjectWizard.java
// Path: cda/plugins/org.openhealthtools.mdht.uml.cda.core/src/org/openhealthtools/mdht/uml/cda/core/util/CDAModelUtil.java // public static class FindResourcesByNameVisitor implements IResourceVisitor { // // private String resourceName; // // private ArrayList<IResource> resources = new ArrayList<IResource>(); // // /** // * @return the resources // */ // public ArrayList<IResource> getResources() { // return resources; // } // // /** // * @param resourceName // */ // public FindResourcesByNameVisitor(String resourceName) { // super(); // this.resourceName = resourceName; // } // // /* // * (non-Javadoc) // * // * @see org.eclipse.core.resources.IResourceVisitor#visit(org.eclipse.core.resources.IResource) // */ // public boolean visit(IResource arg0) throws CoreException { // // if (resourceName != null && resourceName.equals(arg0.getName())) { // resources.add(arg0); // } // return true; // } // // }
import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.jar.Attributes; import java.util.jar.Manifest; import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.plugin.EcorePlugin; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.pde.internal.ui.wizards.IProjectProvider; import org.eclipse.pde.internal.ui.wizards.plugin.NewProjectCreationOperation; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.CopyFilesAndFoldersOperation; import org.eclipse.ui.ide.IDE; import org.eclipse.uml2.uml.Class; import org.eclipse.uml2.uml.Package; import org.eclipse.uml2.uml.Type; import org.eclipse.uml2.uml.UMLPackage; import org.eclipse.uml2.uml.resource.UML22UMLResource; import org.openhealthtools.mdht.uml.cda.core.profile.CDATemplate; import org.openhealthtools.mdht.uml.cda.core.profile.CodegenSupport; import org.openhealthtools.mdht.uml.cda.core.util.CDAModelUtil.FindResourcesByNameVisitor; import org.openhealthtools.mdht.uml.cda.ui.internal.Activator; import org.openhealthtools.mdht.uml.cda.ui.internal.Logger; import org.openhealthtools.mdht.uml.cda.ui.util.CDAUIUtil; import org.osgi.framework.Bundle;
Class cdaClass = templatePackage.createOwnedClass(newCDATemplatePage.getCDADocumentName(), false); CDATemplate template = (CDATemplate) cdaClass.applyStereotype( cdaClass.getApplicableStereotype("CDA::CDATemplate")); template.setBase_Class(cdaClass); template.setTemplateId(newCDATemplatePage.getTemplateId()); template.setAssigningAuthorityName(newCDATemplatePage.getTemplateAssigningAuthority()); Type t = cdaDocuments.get(newCDATemplatePage.getCDADocument()); if (t instanceof Class) { Class documentClass = (Class) t; cdaClass.createGeneralization(documentClass); Package documentPackage = documentClass.getNearestPackage(); EcoreUtil.resolveAll(documentPackage); templatePackage.createPackageImport(documentClass.getNearestPackage()); } templatePackage.createPackageImport(vocabPackage); templatePackage.eResource().save(options); } void createTransformation(IProject project, String modelName) throws Exception {
// Path: cda/plugins/org.openhealthtools.mdht.uml.cda.core/src/org/openhealthtools/mdht/uml/cda/core/util/CDAModelUtil.java // public static class FindResourcesByNameVisitor implements IResourceVisitor { // // private String resourceName; // // private ArrayList<IResource> resources = new ArrayList<IResource>(); // // /** // * @return the resources // */ // public ArrayList<IResource> getResources() { // return resources; // } // // /** // * @param resourceName // */ // public FindResourcesByNameVisitor(String resourceName) { // super(); // this.resourceName = resourceName; // } // // /* // * (non-Javadoc) // * // * @see org.eclipse.core.resources.IResourceVisitor#visit(org.eclipse.core.resources.IResource) // */ // public boolean visit(IResource arg0) throws CoreException { // // if (resourceName != null && resourceName.equals(arg0.getName())) { // resources.add(arg0); // } // return true; // } // // } // Path: cda/plugins/org.openhealthtools.mdht.uml.cda.ui/src/org/openhealthtools/mdht/uml/cda/ui/wizards/NewCDAModelProjectWizard.java import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.jar.Attributes; import java.util.jar.Manifest; import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.plugin.EcorePlugin; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.pde.internal.ui.wizards.IProjectProvider; import org.eclipse.pde.internal.ui.wizards.plugin.NewProjectCreationOperation; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.CopyFilesAndFoldersOperation; import org.eclipse.ui.ide.IDE; import org.eclipse.uml2.uml.Class; import org.eclipse.uml2.uml.Package; import org.eclipse.uml2.uml.Type; import org.eclipse.uml2.uml.UMLPackage; import org.eclipse.uml2.uml.resource.UML22UMLResource; import org.openhealthtools.mdht.uml.cda.core.profile.CDATemplate; import org.openhealthtools.mdht.uml.cda.core.profile.CodegenSupport; import org.openhealthtools.mdht.uml.cda.core.util.CDAModelUtil.FindResourcesByNameVisitor; import org.openhealthtools.mdht.uml.cda.ui.internal.Activator; import org.openhealthtools.mdht.uml.cda.ui.internal.Logger; import org.openhealthtools.mdht.uml.cda.ui.util.CDAUIUtil; import org.osgi.framework.Bundle; Class cdaClass = templatePackage.createOwnedClass(newCDATemplatePage.getCDADocumentName(), false); CDATemplate template = (CDATemplate) cdaClass.applyStereotype( cdaClass.getApplicableStereotype("CDA::CDATemplate")); template.setBase_Class(cdaClass); template.setTemplateId(newCDATemplatePage.getTemplateId()); template.setAssigningAuthorityName(newCDATemplatePage.getTemplateAssigningAuthority()); Type t = cdaDocuments.get(newCDATemplatePage.getCDADocument()); if (t instanceof Class) { Class documentClass = (Class) t; cdaClass.createGeneralization(documentClass); Package documentPackage = documentClass.getNearestPackage(); EcoreUtil.resolveAll(documentPackage); templatePackage.createPackageImport(documentClass.getNearestPackage()); } templatePackage.createPackageImport(vocabPackage); templatePackage.eResource().save(options); } void createTransformation(IProject project, String modelName) throws Exception {
FindResourcesByNameVisitor visitor = new FindResourcesByNameVisitor("transform-common.xml");
checkstyle/sonar-checkstyle
src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperScannerImpl.java
// Path: src/main/java/org/sonar/plugins/checkstyle/CheckstyleSeverityUtils.java // public final class CheckstyleSeverityUtils { // // private static final Logger LOG = LoggerFactory.getLogger(CheckstyleSeverityUtils.class); // // private CheckstyleSeverityUtils() { // // only static methods // } // // public static String toSeverity(RulePriority priority) { // return toSeverity(priority.name()); // } // // public static String toSeverity(String priority) { // final String result; // // switch (priority) { // case "BLOCKER": // case "CRITICAL": // result = SeverityLevel.ERROR.getName(); // break; // case "MAJOR": // result = SeverityLevel.WARNING.getName(); // break; // case "MINOR": // case "INFO": // result = SeverityLevel.INFO.getName(); // break; // default: // throw new IllegalArgumentException("Priority not supported: " + priority); // } // // return result; // } // // public static RulePriority fromSeverity(String severity) { // RulePriority result = null; // // try { // final SeverityLevel severityLevel = SeverityLevel.getInstance(severity); // // switch (severityLevel) { // case ERROR: // result = RulePriority.BLOCKER; // break; // case WARNING: // result = RulePriority.MAJOR; // break; // case INFO: // case IGNORE: // result = RulePriority.INFO; // break; // default: // } // } // catch (Exception exc) { // LOG.warn("Smth wrong severity", exc); // } // // return result; // } // }
import org.sonar.plugins.checkstyle.CheckstyleSeverityUtils; import java.util.Map; import org.sonar.api.batch.rule.ActiveRule;
//////////////////////////////////////////////////////////////////////////////// // checkstyle: Checks Java source code for adherence to a set of rules. // Copyright (C) 2001-2022 the original author or authors. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //////////////////////////////////////////////////////////////////////////////// package org.sonar.plugins.checkstyle.rule; /** * Wrapper as per {@link ActiveRuleWrapper} for the new scanner side {@link ActiveRule}. */ public class ActiveRuleWrapperScannerImpl implements ActiveRuleWrapper { private final ActiveRule activeRule; public ActiveRuleWrapperScannerImpl(ActiveRule activeRule) { this.activeRule = activeRule; } @Override public String getInternalKey() { return activeRule.internalKey(); } @Override public String getRuleKey() { return activeRule.ruleKey().rule(); } @Override public String getTemplateRuleKey() { return activeRule.templateRuleKey(); } @Override public String getSeverity() {
// Path: src/main/java/org/sonar/plugins/checkstyle/CheckstyleSeverityUtils.java // public final class CheckstyleSeverityUtils { // // private static final Logger LOG = LoggerFactory.getLogger(CheckstyleSeverityUtils.class); // // private CheckstyleSeverityUtils() { // // only static methods // } // // public static String toSeverity(RulePriority priority) { // return toSeverity(priority.name()); // } // // public static String toSeverity(String priority) { // final String result; // // switch (priority) { // case "BLOCKER": // case "CRITICAL": // result = SeverityLevel.ERROR.getName(); // break; // case "MAJOR": // result = SeverityLevel.WARNING.getName(); // break; // case "MINOR": // case "INFO": // result = SeverityLevel.INFO.getName(); // break; // default: // throw new IllegalArgumentException("Priority not supported: " + priority); // } // // return result; // } // // public static RulePriority fromSeverity(String severity) { // RulePriority result = null; // // try { // final SeverityLevel severityLevel = SeverityLevel.getInstance(severity); // // switch (severityLevel) { // case ERROR: // result = RulePriority.BLOCKER; // break; // case WARNING: // result = RulePriority.MAJOR; // break; // case INFO: // case IGNORE: // result = RulePriority.INFO; // break; // default: // } // } // catch (Exception exc) { // LOG.warn("Smth wrong severity", exc); // } // // return result; // } // } // Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperScannerImpl.java import org.sonar.plugins.checkstyle.CheckstyleSeverityUtils; import java.util.Map; import org.sonar.api.batch.rule.ActiveRule; //////////////////////////////////////////////////////////////////////////////// // checkstyle: Checks Java source code for adherence to a set of rules. // Copyright (C) 2001-2022 the original author or authors. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //////////////////////////////////////////////////////////////////////////////// package org.sonar.plugins.checkstyle.rule; /** * Wrapper as per {@link ActiveRuleWrapper} for the new scanner side {@link ActiveRule}. */ public class ActiveRuleWrapperScannerImpl implements ActiveRuleWrapper { private final ActiveRule activeRule; public ActiveRuleWrapperScannerImpl(ActiveRule activeRule) { this.activeRule = activeRule; } @Override public String getInternalKey() { return activeRule.internalKey(); } @Override public String getRuleKey() { return activeRule.ruleKey().rule(); } @Override public String getTemplateRuleKey() { return activeRule.templateRuleKey(); } @Override public String getSeverity() {
return CheckstyleSeverityUtils.toSeverity(activeRule.severity());
checkstyle/sonar-checkstyle
src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperServerImpl.java
// Path: src/main/java/org/sonar/plugins/checkstyle/CheckstyleSeverityUtils.java // public final class CheckstyleSeverityUtils { // // private static final Logger LOG = LoggerFactory.getLogger(CheckstyleSeverityUtils.class); // // private CheckstyleSeverityUtils() { // // only static methods // } // // public static String toSeverity(RulePriority priority) { // return toSeverity(priority.name()); // } // // public static String toSeverity(String priority) { // final String result; // // switch (priority) { // case "BLOCKER": // case "CRITICAL": // result = SeverityLevel.ERROR.getName(); // break; // case "MAJOR": // result = SeverityLevel.WARNING.getName(); // break; // case "MINOR": // case "INFO": // result = SeverityLevel.INFO.getName(); // break; // default: // throw new IllegalArgumentException("Priority not supported: " + priority); // } // // return result; // } // // public static RulePriority fromSeverity(String severity) { // RulePriority result = null; // // try { // final SeverityLevel severityLevel = SeverityLevel.getInstance(severity); // // switch (severityLevel) { // case ERROR: // result = RulePriority.BLOCKER; // break; // case WARNING: // result = RulePriority.MAJOR; // break; // case INFO: // case IGNORE: // result = RulePriority.INFO; // break; // default: // } // } // catch (Exception exc) { // LOG.warn("Smth wrong severity", exc); // } // // return result; // } // }
import java.util.HashMap; import java.util.Map; import java.util.Objects; import org.apache.commons.lang.StringUtils; import org.sonar.api.rules.ActiveRule; import org.sonar.api.rules.RuleParam; import org.sonar.plugins.checkstyle.CheckstyleSeverityUtils;
//////////////////////////////////////////////////////////////////////////////// // checkstyle: Checks Java source code for adherence to a set of rules. // Copyright (C) 2001-2022 the original author or authors. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //////////////////////////////////////////////////////////////////////////////// package org.sonar.plugins.checkstyle.rule; /** * Wrapper as per {@link ActiveRuleWrapper} for the server side {@link ActiveRule}. */ public class ActiveRuleWrapperServerImpl implements ActiveRuleWrapper { private final ActiveRule activeRule; public ActiveRuleWrapperServerImpl(ActiveRule activeRule) { this.activeRule = activeRule; } @Override public String getInternalKey() { return activeRule.getConfigKey(); } @Override public String getRuleKey() { return activeRule.getRuleKey(); } @Override public String getTemplateRuleKey() { String result = null; if (Objects.nonNull(activeRule.getRule().getTemplate())) { result = activeRule.getRule().getTemplate().getKey(); } return result; } @Override public String getSeverity() {
// Path: src/main/java/org/sonar/plugins/checkstyle/CheckstyleSeverityUtils.java // public final class CheckstyleSeverityUtils { // // private static final Logger LOG = LoggerFactory.getLogger(CheckstyleSeverityUtils.class); // // private CheckstyleSeverityUtils() { // // only static methods // } // // public static String toSeverity(RulePriority priority) { // return toSeverity(priority.name()); // } // // public static String toSeverity(String priority) { // final String result; // // switch (priority) { // case "BLOCKER": // case "CRITICAL": // result = SeverityLevel.ERROR.getName(); // break; // case "MAJOR": // result = SeverityLevel.WARNING.getName(); // break; // case "MINOR": // case "INFO": // result = SeverityLevel.INFO.getName(); // break; // default: // throw new IllegalArgumentException("Priority not supported: " + priority); // } // // return result; // } // // public static RulePriority fromSeverity(String severity) { // RulePriority result = null; // // try { // final SeverityLevel severityLevel = SeverityLevel.getInstance(severity); // // switch (severityLevel) { // case ERROR: // result = RulePriority.BLOCKER; // break; // case WARNING: // result = RulePriority.MAJOR; // break; // case INFO: // case IGNORE: // result = RulePriority.INFO; // break; // default: // } // } // catch (Exception exc) { // LOG.warn("Smth wrong severity", exc); // } // // return result; // } // } // Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperServerImpl.java import java.util.HashMap; import java.util.Map; import java.util.Objects; import org.apache.commons.lang.StringUtils; import org.sonar.api.rules.ActiveRule; import org.sonar.api.rules.RuleParam; import org.sonar.plugins.checkstyle.CheckstyleSeverityUtils; //////////////////////////////////////////////////////////////////////////////// // checkstyle: Checks Java source code for adherence to a set of rules. // Copyright (C) 2001-2022 the original author or authors. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //////////////////////////////////////////////////////////////////////////////// package org.sonar.plugins.checkstyle.rule; /** * Wrapper as per {@link ActiveRuleWrapper} for the server side {@link ActiveRule}. */ public class ActiveRuleWrapperServerImpl implements ActiveRuleWrapper { private final ActiveRule activeRule; public ActiveRuleWrapperServerImpl(ActiveRule activeRule) { this.activeRule = activeRule; } @Override public String getInternalKey() { return activeRule.getConfigKey(); } @Override public String getRuleKey() { return activeRule.getRuleKey(); } @Override public String getTemplateRuleKey() { String result = null; if (Objects.nonNull(activeRule.getRule().getTemplate())) { result = activeRule.getRule().getTemplate().getKey(); } return result; } @Override public String getSeverity() {
return CheckstyleSeverityUtils.toSeverity(activeRule.getSeverity());
checkstyle/sonar-checkstyle
src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporter.java
// Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapper.java // public interface ActiveRuleWrapper { // String getInternalKey(); // // String getRuleKey(); // // String getTemplateRuleKey(); // // String getSeverity(); // // Map<String, String> getParams(); // } // // Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperScannerImpl.java // public class ActiveRuleWrapperScannerImpl implements ActiveRuleWrapper { // private final ActiveRule activeRule; // // public ActiveRuleWrapperScannerImpl(ActiveRule activeRule) { // this.activeRule = activeRule; // } // // @Override // public String getInternalKey() { // return activeRule.internalKey(); // } // // @Override // public String getRuleKey() { // return activeRule.ruleKey().rule(); // } // // @Override // public String getTemplateRuleKey() { // return activeRule.templateRuleKey(); // } // // @Override // public String getSeverity() { // return CheckstyleSeverityUtils.toSeverity(activeRule.severity()); // } // // @Override // public Map<String, String> getParams() { // return activeRule.params(); // } // } // // Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperServerImpl.java // public class ActiveRuleWrapperServerImpl implements ActiveRuleWrapper { // private final ActiveRule activeRule; // // public ActiveRuleWrapperServerImpl(ActiveRule activeRule) { // this.activeRule = activeRule; // } // // @Override // public String getInternalKey() { // return activeRule.getConfigKey(); // } // // @Override // public String getRuleKey() { // return activeRule.getRuleKey(); // } // // @Override // public String getTemplateRuleKey() { // String result = null; // if (Objects.nonNull(activeRule.getRule().getTemplate())) { // result = activeRule.getRule().getTemplate().getKey(); // } // return result; // } // // @Override // public String getSeverity() { // return CheckstyleSeverityUtils.toSeverity(activeRule.getSeverity()); // } // // @Override // public Map<String, String> getParams() { // final Map<String, String> result = new HashMap<>(); // for (RuleParam param : activeRule.getRule().getParams()) { // final String value = activeRule.getParameter(param.getKey()); // if (StringUtils.isNotBlank(value)) { // result.put(param.getKey(), value); // } // } // return result; // } // }
import java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Nullable; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.sonar.api.ExtensionPoint; import org.sonar.api.batch.ScannerSide; import org.sonar.api.batch.rule.ActiveRules; import org.sonar.api.config.Configuration; import org.sonar.api.profiles.ProfileExporter; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.rules.ActiveRule; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapper; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapperScannerImpl; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapperServerImpl; import com.google.common.annotations.VisibleForTesting;
//////////////////////////////////////////////////////////////////////////////// // checkstyle: Checks Java source code for adherence to a set of rules. // Copyright (C) 2001-2022 the original author or authors. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //////////////////////////////////////////////////////////////////////////////// package org.sonar.plugins.checkstyle; @ExtensionPoint @ScannerSide public class CheckstyleProfileExporter extends ProfileExporter { public static final String DOCTYPE_DECLARATION = "<!DOCTYPE module PUBLIC \"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN\" " + "\"https://checkstyle.org/dtds/configuration_1_3.dtd\">"; private static final String CLOSE_MODULE = "</module>"; private final Configuration configuration; public CheckstyleProfileExporter(Configuration configuration) { super(CheckstyleConstants.REPOSITORY_KEY, CheckstyleConstants.PLUGIN_NAME); this.configuration = configuration; setSupportedLanguages(CheckstyleConstants.JAVA_KEY); setMimeType("application/xml"); } @Override public void exportProfile(RulesProfile profile, Writer writer) { try { final List<ActiveRule> activeRules = profile .getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY); if (activeRules != null) {
// Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapper.java // public interface ActiveRuleWrapper { // String getInternalKey(); // // String getRuleKey(); // // String getTemplateRuleKey(); // // String getSeverity(); // // Map<String, String> getParams(); // } // // Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperScannerImpl.java // public class ActiveRuleWrapperScannerImpl implements ActiveRuleWrapper { // private final ActiveRule activeRule; // // public ActiveRuleWrapperScannerImpl(ActiveRule activeRule) { // this.activeRule = activeRule; // } // // @Override // public String getInternalKey() { // return activeRule.internalKey(); // } // // @Override // public String getRuleKey() { // return activeRule.ruleKey().rule(); // } // // @Override // public String getTemplateRuleKey() { // return activeRule.templateRuleKey(); // } // // @Override // public String getSeverity() { // return CheckstyleSeverityUtils.toSeverity(activeRule.severity()); // } // // @Override // public Map<String, String> getParams() { // return activeRule.params(); // } // } // // Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperServerImpl.java // public class ActiveRuleWrapperServerImpl implements ActiveRuleWrapper { // private final ActiveRule activeRule; // // public ActiveRuleWrapperServerImpl(ActiveRule activeRule) { // this.activeRule = activeRule; // } // // @Override // public String getInternalKey() { // return activeRule.getConfigKey(); // } // // @Override // public String getRuleKey() { // return activeRule.getRuleKey(); // } // // @Override // public String getTemplateRuleKey() { // String result = null; // if (Objects.nonNull(activeRule.getRule().getTemplate())) { // result = activeRule.getRule().getTemplate().getKey(); // } // return result; // } // // @Override // public String getSeverity() { // return CheckstyleSeverityUtils.toSeverity(activeRule.getSeverity()); // } // // @Override // public Map<String, String> getParams() { // final Map<String, String> result = new HashMap<>(); // for (RuleParam param : activeRule.getRule().getParams()) { // final String value = activeRule.getParameter(param.getKey()); // if (StringUtils.isNotBlank(value)) { // result.put(param.getKey(), value); // } // } // return result; // } // } // Path: src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporter.java import java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Nullable; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.sonar.api.ExtensionPoint; import org.sonar.api.batch.ScannerSide; import org.sonar.api.batch.rule.ActiveRules; import org.sonar.api.config.Configuration; import org.sonar.api.profiles.ProfileExporter; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.rules.ActiveRule; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapper; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapperScannerImpl; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapperServerImpl; import com.google.common.annotations.VisibleForTesting; //////////////////////////////////////////////////////////////////////////////// // checkstyle: Checks Java source code for adherence to a set of rules. // Copyright (C) 2001-2022 the original author or authors. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //////////////////////////////////////////////////////////////////////////////// package org.sonar.plugins.checkstyle; @ExtensionPoint @ScannerSide public class CheckstyleProfileExporter extends ProfileExporter { public static final String DOCTYPE_DECLARATION = "<!DOCTYPE module PUBLIC \"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN\" " + "\"https://checkstyle.org/dtds/configuration_1_3.dtd\">"; private static final String CLOSE_MODULE = "</module>"; private final Configuration configuration; public CheckstyleProfileExporter(Configuration configuration) { super(CheckstyleConstants.REPOSITORY_KEY, CheckstyleConstants.PLUGIN_NAME); this.configuration = configuration; setSupportedLanguages(CheckstyleConstants.JAVA_KEY); setMimeType("application/xml"); } @Override public void exportProfile(RulesProfile profile, Writer writer) { try { final List<ActiveRule> activeRules = profile .getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY); if (activeRules != null) {
final List<ActiveRuleWrapper> activeRuleWrappers = new ArrayList<>();
checkstyle/sonar-checkstyle
src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporter.java
// Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapper.java // public interface ActiveRuleWrapper { // String getInternalKey(); // // String getRuleKey(); // // String getTemplateRuleKey(); // // String getSeverity(); // // Map<String, String> getParams(); // } // // Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperScannerImpl.java // public class ActiveRuleWrapperScannerImpl implements ActiveRuleWrapper { // private final ActiveRule activeRule; // // public ActiveRuleWrapperScannerImpl(ActiveRule activeRule) { // this.activeRule = activeRule; // } // // @Override // public String getInternalKey() { // return activeRule.internalKey(); // } // // @Override // public String getRuleKey() { // return activeRule.ruleKey().rule(); // } // // @Override // public String getTemplateRuleKey() { // return activeRule.templateRuleKey(); // } // // @Override // public String getSeverity() { // return CheckstyleSeverityUtils.toSeverity(activeRule.severity()); // } // // @Override // public Map<String, String> getParams() { // return activeRule.params(); // } // } // // Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperServerImpl.java // public class ActiveRuleWrapperServerImpl implements ActiveRuleWrapper { // private final ActiveRule activeRule; // // public ActiveRuleWrapperServerImpl(ActiveRule activeRule) { // this.activeRule = activeRule; // } // // @Override // public String getInternalKey() { // return activeRule.getConfigKey(); // } // // @Override // public String getRuleKey() { // return activeRule.getRuleKey(); // } // // @Override // public String getTemplateRuleKey() { // String result = null; // if (Objects.nonNull(activeRule.getRule().getTemplate())) { // result = activeRule.getRule().getTemplate().getKey(); // } // return result; // } // // @Override // public String getSeverity() { // return CheckstyleSeverityUtils.toSeverity(activeRule.getSeverity()); // } // // @Override // public Map<String, String> getParams() { // final Map<String, String> result = new HashMap<>(); // for (RuleParam param : activeRule.getRule().getParams()) { // final String value = activeRule.getParameter(param.getKey()); // if (StringUtils.isNotBlank(value)) { // result.put(param.getKey(), value); // } // } // return result; // } // }
import java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Nullable; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.sonar.api.ExtensionPoint; import org.sonar.api.batch.ScannerSide; import org.sonar.api.batch.rule.ActiveRules; import org.sonar.api.config.Configuration; import org.sonar.api.profiles.ProfileExporter; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.rules.ActiveRule; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapper; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapperScannerImpl; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapperServerImpl; import com.google.common.annotations.VisibleForTesting;
//////////////////////////////////////////////////////////////////////////////// // checkstyle: Checks Java source code for adherence to a set of rules. // Copyright (C) 2001-2022 the original author or authors. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //////////////////////////////////////////////////////////////////////////////// package org.sonar.plugins.checkstyle; @ExtensionPoint @ScannerSide public class CheckstyleProfileExporter extends ProfileExporter { public static final String DOCTYPE_DECLARATION = "<!DOCTYPE module PUBLIC \"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN\" " + "\"https://checkstyle.org/dtds/configuration_1_3.dtd\">"; private static final String CLOSE_MODULE = "</module>"; private final Configuration configuration; public CheckstyleProfileExporter(Configuration configuration) { super(CheckstyleConstants.REPOSITORY_KEY, CheckstyleConstants.PLUGIN_NAME); this.configuration = configuration; setSupportedLanguages(CheckstyleConstants.JAVA_KEY); setMimeType("application/xml"); } @Override public void exportProfile(RulesProfile profile, Writer writer) { try { final List<ActiveRule> activeRules = profile .getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY); if (activeRules != null) { final List<ActiveRuleWrapper> activeRuleWrappers = new ArrayList<>(); for (ActiveRule activeRule : activeRules) {
// Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapper.java // public interface ActiveRuleWrapper { // String getInternalKey(); // // String getRuleKey(); // // String getTemplateRuleKey(); // // String getSeverity(); // // Map<String, String> getParams(); // } // // Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperScannerImpl.java // public class ActiveRuleWrapperScannerImpl implements ActiveRuleWrapper { // private final ActiveRule activeRule; // // public ActiveRuleWrapperScannerImpl(ActiveRule activeRule) { // this.activeRule = activeRule; // } // // @Override // public String getInternalKey() { // return activeRule.internalKey(); // } // // @Override // public String getRuleKey() { // return activeRule.ruleKey().rule(); // } // // @Override // public String getTemplateRuleKey() { // return activeRule.templateRuleKey(); // } // // @Override // public String getSeverity() { // return CheckstyleSeverityUtils.toSeverity(activeRule.severity()); // } // // @Override // public Map<String, String> getParams() { // return activeRule.params(); // } // } // // Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperServerImpl.java // public class ActiveRuleWrapperServerImpl implements ActiveRuleWrapper { // private final ActiveRule activeRule; // // public ActiveRuleWrapperServerImpl(ActiveRule activeRule) { // this.activeRule = activeRule; // } // // @Override // public String getInternalKey() { // return activeRule.getConfigKey(); // } // // @Override // public String getRuleKey() { // return activeRule.getRuleKey(); // } // // @Override // public String getTemplateRuleKey() { // String result = null; // if (Objects.nonNull(activeRule.getRule().getTemplate())) { // result = activeRule.getRule().getTemplate().getKey(); // } // return result; // } // // @Override // public String getSeverity() { // return CheckstyleSeverityUtils.toSeverity(activeRule.getSeverity()); // } // // @Override // public Map<String, String> getParams() { // final Map<String, String> result = new HashMap<>(); // for (RuleParam param : activeRule.getRule().getParams()) { // final String value = activeRule.getParameter(param.getKey()); // if (StringUtils.isNotBlank(value)) { // result.put(param.getKey(), value); // } // } // return result; // } // } // Path: src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporter.java import java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Nullable; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.sonar.api.ExtensionPoint; import org.sonar.api.batch.ScannerSide; import org.sonar.api.batch.rule.ActiveRules; import org.sonar.api.config.Configuration; import org.sonar.api.profiles.ProfileExporter; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.rules.ActiveRule; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapper; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapperScannerImpl; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapperServerImpl; import com.google.common.annotations.VisibleForTesting; //////////////////////////////////////////////////////////////////////////////// // checkstyle: Checks Java source code for adherence to a set of rules. // Copyright (C) 2001-2022 the original author or authors. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //////////////////////////////////////////////////////////////////////////////// package org.sonar.plugins.checkstyle; @ExtensionPoint @ScannerSide public class CheckstyleProfileExporter extends ProfileExporter { public static final String DOCTYPE_DECLARATION = "<!DOCTYPE module PUBLIC \"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN\" " + "\"https://checkstyle.org/dtds/configuration_1_3.dtd\">"; private static final String CLOSE_MODULE = "</module>"; private final Configuration configuration; public CheckstyleProfileExporter(Configuration configuration) { super(CheckstyleConstants.REPOSITORY_KEY, CheckstyleConstants.PLUGIN_NAME); this.configuration = configuration; setSupportedLanguages(CheckstyleConstants.JAVA_KEY); setMimeType("application/xml"); } @Override public void exportProfile(RulesProfile profile, Writer writer) { try { final List<ActiveRule> activeRules = profile .getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY); if (activeRules != null) { final List<ActiveRuleWrapper> activeRuleWrappers = new ArrayList<>(); for (ActiveRule activeRule : activeRules) {
activeRuleWrappers.add(new ActiveRuleWrapperServerImpl(activeRule));
checkstyle/sonar-checkstyle
src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporter.java
// Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapper.java // public interface ActiveRuleWrapper { // String getInternalKey(); // // String getRuleKey(); // // String getTemplateRuleKey(); // // String getSeverity(); // // Map<String, String> getParams(); // } // // Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperScannerImpl.java // public class ActiveRuleWrapperScannerImpl implements ActiveRuleWrapper { // private final ActiveRule activeRule; // // public ActiveRuleWrapperScannerImpl(ActiveRule activeRule) { // this.activeRule = activeRule; // } // // @Override // public String getInternalKey() { // return activeRule.internalKey(); // } // // @Override // public String getRuleKey() { // return activeRule.ruleKey().rule(); // } // // @Override // public String getTemplateRuleKey() { // return activeRule.templateRuleKey(); // } // // @Override // public String getSeverity() { // return CheckstyleSeverityUtils.toSeverity(activeRule.severity()); // } // // @Override // public Map<String, String> getParams() { // return activeRule.params(); // } // } // // Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperServerImpl.java // public class ActiveRuleWrapperServerImpl implements ActiveRuleWrapper { // private final ActiveRule activeRule; // // public ActiveRuleWrapperServerImpl(ActiveRule activeRule) { // this.activeRule = activeRule; // } // // @Override // public String getInternalKey() { // return activeRule.getConfigKey(); // } // // @Override // public String getRuleKey() { // return activeRule.getRuleKey(); // } // // @Override // public String getTemplateRuleKey() { // String result = null; // if (Objects.nonNull(activeRule.getRule().getTemplate())) { // result = activeRule.getRule().getTemplate().getKey(); // } // return result; // } // // @Override // public String getSeverity() { // return CheckstyleSeverityUtils.toSeverity(activeRule.getSeverity()); // } // // @Override // public Map<String, String> getParams() { // final Map<String, String> result = new HashMap<>(); // for (RuleParam param : activeRule.getRule().getParams()) { // final String value = activeRule.getParameter(param.getKey()); // if (StringUtils.isNotBlank(value)) { // result.put(param.getKey(), value); // } // } // return result; // } // }
import java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Nullable; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.sonar.api.ExtensionPoint; import org.sonar.api.batch.ScannerSide; import org.sonar.api.batch.rule.ActiveRules; import org.sonar.api.config.Configuration; import org.sonar.api.profiles.ProfileExporter; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.rules.ActiveRule; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapper; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapperScannerImpl; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapperServerImpl; import com.google.common.annotations.VisibleForTesting;
this.configuration = configuration; setSupportedLanguages(CheckstyleConstants.JAVA_KEY); setMimeType("application/xml"); } @Override public void exportProfile(RulesProfile profile, Writer writer) { try { final List<ActiveRule> activeRules = profile .getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY); if (activeRules != null) { final List<ActiveRuleWrapper> activeRuleWrappers = new ArrayList<>(); for (ActiveRule activeRule : activeRules) { activeRuleWrappers.add(new ActiveRuleWrapperServerImpl(activeRule)); } final Map<String, List<ActiveRuleWrapper>> activeRulesByConfigKey = arrangeByConfigKey(activeRuleWrappers); generateXml(writer, activeRulesByConfigKey); } } catch (IOException ex) { throw new IllegalStateException("Fail to export the profile " + profile, ex); } } public void exportProfile(ActiveRules activeRules, Writer writer) { try { final List<ActiveRuleWrapper> activeRuleWrappers = new ArrayList<>(); for (org.sonar.api.batch.rule.ActiveRule activeRule : activeRules .findByRepository(CheckstyleConstants.REPOSITORY_KEY)) {
// Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapper.java // public interface ActiveRuleWrapper { // String getInternalKey(); // // String getRuleKey(); // // String getTemplateRuleKey(); // // String getSeverity(); // // Map<String, String> getParams(); // } // // Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperScannerImpl.java // public class ActiveRuleWrapperScannerImpl implements ActiveRuleWrapper { // private final ActiveRule activeRule; // // public ActiveRuleWrapperScannerImpl(ActiveRule activeRule) { // this.activeRule = activeRule; // } // // @Override // public String getInternalKey() { // return activeRule.internalKey(); // } // // @Override // public String getRuleKey() { // return activeRule.ruleKey().rule(); // } // // @Override // public String getTemplateRuleKey() { // return activeRule.templateRuleKey(); // } // // @Override // public String getSeverity() { // return CheckstyleSeverityUtils.toSeverity(activeRule.severity()); // } // // @Override // public Map<String, String> getParams() { // return activeRule.params(); // } // } // // Path: src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperServerImpl.java // public class ActiveRuleWrapperServerImpl implements ActiveRuleWrapper { // private final ActiveRule activeRule; // // public ActiveRuleWrapperServerImpl(ActiveRule activeRule) { // this.activeRule = activeRule; // } // // @Override // public String getInternalKey() { // return activeRule.getConfigKey(); // } // // @Override // public String getRuleKey() { // return activeRule.getRuleKey(); // } // // @Override // public String getTemplateRuleKey() { // String result = null; // if (Objects.nonNull(activeRule.getRule().getTemplate())) { // result = activeRule.getRule().getTemplate().getKey(); // } // return result; // } // // @Override // public String getSeverity() { // return CheckstyleSeverityUtils.toSeverity(activeRule.getSeverity()); // } // // @Override // public Map<String, String> getParams() { // final Map<String, String> result = new HashMap<>(); // for (RuleParam param : activeRule.getRule().getParams()) { // final String value = activeRule.getParameter(param.getKey()); // if (StringUtils.isNotBlank(value)) { // result.put(param.getKey(), value); // } // } // return result; // } // } // Path: src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporter.java import java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Nullable; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.sonar.api.ExtensionPoint; import org.sonar.api.batch.ScannerSide; import org.sonar.api.batch.rule.ActiveRules; import org.sonar.api.config.Configuration; import org.sonar.api.profiles.ProfileExporter; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.rules.ActiveRule; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapper; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapperScannerImpl; import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapperServerImpl; import com.google.common.annotations.VisibleForTesting; this.configuration = configuration; setSupportedLanguages(CheckstyleConstants.JAVA_KEY); setMimeType("application/xml"); } @Override public void exportProfile(RulesProfile profile, Writer writer) { try { final List<ActiveRule> activeRules = profile .getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY); if (activeRules != null) { final List<ActiveRuleWrapper> activeRuleWrappers = new ArrayList<>(); for (ActiveRule activeRule : activeRules) { activeRuleWrappers.add(new ActiveRuleWrapperServerImpl(activeRule)); } final Map<String, List<ActiveRuleWrapper>> activeRulesByConfigKey = arrangeByConfigKey(activeRuleWrappers); generateXml(writer, activeRulesByConfigKey); } } catch (IOException ex) { throw new IllegalStateException("Fail to export the profile " + profile, ex); } } public void exportProfile(ActiveRules activeRules, Writer writer) { try { final List<ActiveRuleWrapper> activeRuleWrappers = new ArrayList<>(); for (org.sonar.api.batch.rule.ActiveRule activeRule : activeRules .findByRepository(CheckstyleConstants.REPOSITORY_KEY)) {
activeRuleWrappers.add(new ActiveRuleWrapperScannerImpl(activeRule));
dominiks/uristmapsj
src/main/java/org/uristmaps/BmpConverter.java
// Path: src/main/java/org/uristmaps/Uristmaps.java // public static Wini conf;
import com.esotericsoftware.minlog.Log; import org.apache.commons.io.FilenameUtils; import org.uristmaps.util.*; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import static org.uristmaps.Uristmaps.conf;
package org.uristmaps; /** * DOCME */ public class BmpConverter { /** * DOCME */ public static void convert() { Log.debug("BmpConverter", "Started");
// Path: src/main/java/org/uristmaps/Uristmaps.java // public static Wini conf; // Path: src/main/java/org/uristmaps/BmpConverter.java import com.esotericsoftware.minlog.Log; import org.apache.commons.io.FilenameUtils; import org.uristmaps.util.*; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import static org.uristmaps.Uristmaps.conf; package org.uristmaps; /** * DOCME */ public class BmpConverter { /** * DOCME */ public static void convert() { Log.debug("BmpConverter", "Started");
File[] bmps = new File(conf.fetch("Paths", "export")).listFiles(
dominiks/uristmapsj
src/main/java/org/uristmaps/StructureInfo.java
// Path: src/main/java/org/uristmaps/util/ExportFiles.java // public class ExportFiles { // // /** // * The timestamp of the world export found in filenames. // */ // private static String timeStamp; // // /** // * Retrieve the population report file. // * The site is named "`region_name`-*-world_sites_and_pops.txt". // * Does not check if the file exists! // * @return A file reference to the file // */ // public static File getPopulationFile() { // File result = new File(conf.fetch("Paths", "export"), // String.format("%s-%s-world_sites_and_pops.txt", conf.get("Paths", "region_name"), // getDate())); // return result; // } // // /** // * Find the date of the export files. Either this is set in the config or the latest date // * is resolved using the legends.xml file with the latest date. // * @return // */ // public static String getDate() { // if (timeStamp == null) { // String config = conf.get("Paths", "region_date"); // if (config.equals("@LATEST")) { // // Find all *-legends.xml files // File[] populationFiles = new File(conf.fetch("Paths", "export")).listFiles( // (dir, name) -> name.startsWith(conf.get("Paths", "region_name")) // && name.endsWith("-legends.xml")); // // // Find the maximum date string within these filenames // String maxDate = "00000-00-00"; // for (File popFile : populationFiles) { // String fileName = popFile.getName(); // String date = fileName.replace(conf.get("Paths", "region_name") + "-", "").replace("-legends.xml", ""); // if (maxDate.compareTo(date) < 0) maxDate = date; // } // timeStamp = maxDate; // Log.info("ExportFiles", "Resolved date to " + maxDate); // } else { // // Use the config as provided // timeStamp = config; // } // } // return timeStamp; // } // // /** // * Resolve the path to the legends xml file. // * @return File reference to where this file should be. // */ // public static File getLegendsXML() { // File result = new File(conf.fetch("Paths", "export"), // String.format("%s-%s-legends.xml", conf.get("Paths", "region_name"), // getDate())); // return result; // } // // /** // * Resolve the path to the biome map image. // * Does not check if the file exists! // * @return File reference to where this file should be. // */ // public static File getBiomeMap() { // File result = new File(conf.fetch("Paths", "export"), // String.format("%s-%s-bm.png", conf.get("Paths", "region_name"), // getDate())); // return result; // } // // /** // * Construct the path to the world_history.txt file. // * Does not check if the file exists! // * @return // */ // public static File getWorldHistory() { // File result = new File(conf.fetch("Paths", "export"), // String.format("%s-%s-world_history.txt", conf.get("Paths", "region_name"), // getDate())); // return result; // } // // /** // * Construct the path to the structures map image file. // * @return File reference to where this file should be. // */ // public static File getStructuresMap() { // File result = new File(conf.fetch("Paths", "export"), // String.format("%s-%s-str.png", conf.get("Paths", "region_name"), // getDate())); // return result; // } // // /** // * Construct the path to the hydro map image file. // * @return File reference to where this file should be. // */ // public static File getHydroMap() { // File result = new File(conf.fetch("Paths", "export"), // String.format("%s-%s-hyd.png", conf.get("Paths", "region_name"), // getDate())); // return result; // } // // /** // * Find all detailed site maps for the current region & date. // * @return File reference to where this file should be. // */ // public static File[] getAllSitemaps() { // return new File(conf.fetch("Paths", "export")).listFiles((dir, name) -> name.startsWith( // String.format("%s-%s-site_map-", conf.get("Paths", "region_name"), getDate())) // && name.endsWith(".png") // ); // } // // /** // * Construct the path to the detailed site map for a given site. // * Does not check if the file exists! // * @param id The id of the site. // * @return // */ // public static File getSiteMap(int id) { // File result = new File(conf.fetch("Paths", "export"), // String.format("%s-%s-site_map-%d.png", conf.get("Paths", "region_name"), // getDate(), id)); // return result; // } // } // // Path: src/main/java/org/uristmaps/util/Util.java // public static int makeColor(int R, int G, int B) { // R = (R << 16) & 0x00FF0000; // G = (G << 8) & 0x0000FF00; // B = B & 0x000000FF; // return 0xFF000000 | R | G | B; // }
import com.esotericsoftware.minlog.Log; import org.uristmaps.util.ExportFiles; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.IOException; import java.util.*; import static org.uristmaps.util.Util.makeColor;
package org.uristmaps; /** * Processes structure position data from the str-map. */ public class StructureInfo { /** * DOCME */ private static Map<Integer, String> colorTranslation; /** * DOCME */ private static Map<Integer, String> hydroColors; /** * DOCME */ private static BufferedImage structImage; /** * DOCME */ private static BufferedImage hydroImage; /** * DOCME */ private static String[][] structures; private static Map<String, Set<String>> connectors; static { colorTranslation = new HashMap<>();
// Path: src/main/java/org/uristmaps/util/ExportFiles.java // public class ExportFiles { // // /** // * The timestamp of the world export found in filenames. // */ // private static String timeStamp; // // /** // * Retrieve the population report file. // * The site is named "`region_name`-*-world_sites_and_pops.txt". // * Does not check if the file exists! // * @return A file reference to the file // */ // public static File getPopulationFile() { // File result = new File(conf.fetch("Paths", "export"), // String.format("%s-%s-world_sites_and_pops.txt", conf.get("Paths", "region_name"), // getDate())); // return result; // } // // /** // * Find the date of the export files. Either this is set in the config or the latest date // * is resolved using the legends.xml file with the latest date. // * @return // */ // public static String getDate() { // if (timeStamp == null) { // String config = conf.get("Paths", "region_date"); // if (config.equals("@LATEST")) { // // Find all *-legends.xml files // File[] populationFiles = new File(conf.fetch("Paths", "export")).listFiles( // (dir, name) -> name.startsWith(conf.get("Paths", "region_name")) // && name.endsWith("-legends.xml")); // // // Find the maximum date string within these filenames // String maxDate = "00000-00-00"; // for (File popFile : populationFiles) { // String fileName = popFile.getName(); // String date = fileName.replace(conf.get("Paths", "region_name") + "-", "").replace("-legends.xml", ""); // if (maxDate.compareTo(date) < 0) maxDate = date; // } // timeStamp = maxDate; // Log.info("ExportFiles", "Resolved date to " + maxDate); // } else { // // Use the config as provided // timeStamp = config; // } // } // return timeStamp; // } // // /** // * Resolve the path to the legends xml file. // * @return File reference to where this file should be. // */ // public static File getLegendsXML() { // File result = new File(conf.fetch("Paths", "export"), // String.format("%s-%s-legends.xml", conf.get("Paths", "region_name"), // getDate())); // return result; // } // // /** // * Resolve the path to the biome map image. // * Does not check if the file exists! // * @return File reference to where this file should be. // */ // public static File getBiomeMap() { // File result = new File(conf.fetch("Paths", "export"), // String.format("%s-%s-bm.png", conf.get("Paths", "region_name"), // getDate())); // return result; // } // // /** // * Construct the path to the world_history.txt file. // * Does not check if the file exists! // * @return // */ // public static File getWorldHistory() { // File result = new File(conf.fetch("Paths", "export"), // String.format("%s-%s-world_history.txt", conf.get("Paths", "region_name"), // getDate())); // return result; // } // // /** // * Construct the path to the structures map image file. // * @return File reference to where this file should be. // */ // public static File getStructuresMap() { // File result = new File(conf.fetch("Paths", "export"), // String.format("%s-%s-str.png", conf.get("Paths", "region_name"), // getDate())); // return result; // } // // /** // * Construct the path to the hydro map image file. // * @return File reference to where this file should be. // */ // public static File getHydroMap() { // File result = new File(conf.fetch("Paths", "export"), // String.format("%s-%s-hyd.png", conf.get("Paths", "region_name"), // getDate())); // return result; // } // // /** // * Find all detailed site maps for the current region & date. // * @return File reference to where this file should be. // */ // public static File[] getAllSitemaps() { // return new File(conf.fetch("Paths", "export")).listFiles((dir, name) -> name.startsWith( // String.format("%s-%s-site_map-", conf.get("Paths", "region_name"), getDate())) // && name.endsWith(".png") // ); // } // // /** // * Construct the path to the detailed site map for a given site. // * Does not check if the file exists! // * @param id The id of the site. // * @return // */ // public static File getSiteMap(int id) { // File result = new File(conf.fetch("Paths", "export"), // String.format("%s-%s-site_map-%d.png", conf.get("Paths", "region_name"), // getDate(), id)); // return result; // } // } // // Path: src/main/java/org/uristmaps/util/Util.java // public static int makeColor(int R, int G, int B) { // R = (R << 16) & 0x00FF0000; // G = (G << 8) & 0x0000FF00; // B = B & 0x000000FF; // return 0xFF000000 | R | G | B; // } // Path: src/main/java/org/uristmaps/StructureInfo.java import com.esotericsoftware.minlog.Log; import org.uristmaps.util.ExportFiles; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.IOException; import java.util.*; import static org.uristmaps.util.Util.makeColor; package org.uristmaps; /** * Processes structure position data from the str-map. */ public class StructureInfo { /** * DOCME */ private static Map<Integer, String> colorTranslation; /** * DOCME */ private static Map<Integer, String> hydroColors; /** * DOCME */ private static BufferedImage structImage; /** * DOCME */ private static BufferedImage hydroImage; /** * DOCME */ private static String[][] structures; private static Map<String, Set<String>> connectors; static { colorTranslation = new HashMap<>();
colorTranslation.put(makeColor(128, 128, 128), "castle");
dominiks/uristmapsj
src/main/java/org/uristmaps/util/ExportFiles.java
// Path: src/main/java/org/uristmaps/Uristmaps.java // public static Wini conf;
import com.esotericsoftware.minlog.Log; import java.io.File; import static org.uristmaps.Uristmaps.conf;
package org.uristmaps.util; /** * Provides easy access to resource files. */ public class ExportFiles { /** * The timestamp of the world export found in filenames. */ private static String timeStamp; /** * Retrieve the population report file. * The site is named "`region_name`-*-world_sites_and_pops.txt". * Does not check if the file exists! * @return A file reference to the file */ public static File getPopulationFile() {
// Path: src/main/java/org/uristmaps/Uristmaps.java // public static Wini conf; // Path: src/main/java/org/uristmaps/util/ExportFiles.java import com.esotericsoftware.minlog.Log; import java.io.File; import static org.uristmaps.Uristmaps.conf; package org.uristmaps.util; /** * Provides easy access to resource files. */ public class ExportFiles { /** * The timestamp of the world export found in filenames. */ private static String timeStamp; /** * Retrieve the population report file. * The site is named "`region_name`-*-world_sites_and_pops.txt". * Does not check if the file exists! * @return A file reference to the file */ public static File getPopulationFile() {
File result = new File(conf.fetch("Paths", "export"),
dominiks/uristmapsj
src/main/java/org/uristmaps/util/Util.java
// Path: src/main/java/org/uristmaps/data/Coord2.java // public class Coord2 { // // protected int x; // protected int y; // // public Coord2() {} // // /** // * Create a new value pair. // * @param x // * @param y // */ // public Coord2(int x, int y) { // this.x = x; // this.y = y; // } // // /** // * Get the x value. // * @return // */ // public int X() { // return x; // } // // /** // * Get the y value. // * @return // */ // public int Y() { // return y; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // // if (!(obj instanceof Coord2)) { // return false; // } // // Coord2 other = (Coord2) obj; // return (x == other.x && y == other.y); // } // // @Override // public int hashCode() { // return 31 * x + y; // } // // @Override // public String toString() { // return X() + "," + Y(); // } // }
import org.apache.commons.lang.StringEscapeUtils; import org.uristmaps.data.Coord2;
package org.uristmaps.util; /** * Some utility stuff that gathered for the project. */ public class Util { public static final String ANSI_RESET = "\u001B[0m"; public static final String ANSI_BLACK = "\u001B[30m"; public static final String ANSI_RED = "\u001B[31m"; public static final String ANSI_GREEN = "\u001B[32m"; public static final String ANSI_YELLOW = "\u001B[33m"; public static final String ANSI_BLUE = "\u001B[34m"; public static final String ANSI_PURPLE = "\u001B[35m"; public static final String ANSI_CYAN = "\u001B[36m"; public static final String ANSI_WHITE = "\u001B[37m"; /** * Transform world tile to unit coordinates. * The site-coordinates are specified in world tiles which are 16x16 units big. * @param world * @return The top left unit-coordinate of the world tile. */
// Path: src/main/java/org/uristmaps/data/Coord2.java // public class Coord2 { // // protected int x; // protected int y; // // public Coord2() {} // // /** // * Create a new value pair. // * @param x // * @param y // */ // public Coord2(int x, int y) { // this.x = x; // this.y = y; // } // // /** // * Get the x value. // * @return // */ // public int X() { // return x; // } // // /** // * Get the y value. // * @return // */ // public int Y() { // return y; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // // if (!(obj instanceof Coord2)) { // return false; // } // // Coord2 other = (Coord2) obj; // return (x == other.x && y == other.y); // } // // @Override // public int hashCode() { // return 31 * x + y; // } // // @Override // public String toString() { // return X() + "," + Y(); // } // } // Path: src/main/java/org/uristmaps/util/Util.java import org.apache.commons.lang.StringEscapeUtils; import org.uristmaps.data.Coord2; package org.uristmaps.util; /** * Some utility stuff that gathered for the project. */ public class Util { public static final String ANSI_RESET = "\u001B[0m"; public static final String ANSI_BLACK = "\u001B[30m"; public static final String ANSI_RED = "\u001B[31m"; public static final String ANSI_GREEN = "\u001B[32m"; public static final String ANSI_YELLOW = "\u001B[33m"; public static final String ANSI_BLUE = "\u001B[34m"; public static final String ANSI_PURPLE = "\u001B[35m"; public static final String ANSI_CYAN = "\u001B[36m"; public static final String ANSI_WHITE = "\u001B[37m"; /** * Transform world tile to unit coordinates. * The site-coordinates are specified in world tiles which are 16x16 units big. * @param world * @return The top left unit-coordinate of the world tile. */
public static Coord2 worldToUnit(Coord2 world) {
igoticecream/Snorlax
app/src/main/java/com/icecream/snorlax/module/feature/mitm/MitmProvider.java
// Path: app/src/main/java/com/icecream/snorlax/module/Log.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Log { // // public static void d(String format, Object... args) { // XposedBridge.log(String.format(Locale.US, format, args)); // } // // public static void e(Throwable throwable) { // XposedBridge.log(throwable); // } // // public static void e(Throwable throwable, String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args), throwable)); // } // // public static void e(String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args))); // } // // private Log() { // throw new AssertionError("No instances"); // } // }
import static POGOProtos.Networking.Requests.RequestOuterClass.Request; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import android.util.LongSparseArray; import com.google.protobuf.InvalidProtocolBufferException; import com.icecream.snorlax.module.Log; import static POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope; import static POGOProtos.Networking.Envelopes.ResponseEnvelopeOuterClass.ResponseEnvelope;
mListeners.add(listener); } } public void removeListenerResponse(MitmListener listener) { if (listener != null) { mListeners.remove(listener); } } ByteBuffer processOutboundPackage(ByteBuffer roData, boolean connectionOk) { if (!connectionOk) return null; roData.rewind(); try { byte[] buffer = new byte[roData.remaining()]; roData.get(buffer); synchronized (MitmProvider.class) { RequestEnvelope envelope = RequestEnvelope.parseFrom(buffer); MitmRelay.getInstance().call(envelope); setRequests(envelope); } } catch (InvalidProtocolBufferException ignored) { } catch (Throwable throwable) {
// Path: app/src/main/java/com/icecream/snorlax/module/Log.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Log { // // public static void d(String format, Object... args) { // XposedBridge.log(String.format(Locale.US, format, args)); // } // // public static void e(Throwable throwable) { // XposedBridge.log(throwable); // } // // public static void e(Throwable throwable, String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args), throwable)); // } // // public static void e(String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args))); // } // // private Log() { // throw new AssertionError("No instances"); // } // } // Path: app/src/main/java/com/icecream/snorlax/module/feature/mitm/MitmProvider.java import static POGOProtos.Networking.Requests.RequestOuterClass.Request; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import android.util.LongSparseArray; import com.google.protobuf.InvalidProtocolBufferException; import com.icecream.snorlax.module.Log; import static POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope; import static POGOProtos.Networking.Envelopes.ResponseEnvelopeOuterClass.ResponseEnvelope; mListeners.add(listener); } } public void removeListenerResponse(MitmListener listener) { if (listener != null) { mListeners.remove(listener); } } ByteBuffer processOutboundPackage(ByteBuffer roData, boolean connectionOk) { if (!connectionOk) return null; roData.rewind(); try { byte[] buffer = new byte[roData.remaining()]; roData.get(buffer); synchronized (MitmProvider.class) { RequestEnvelope envelope = RequestEnvelope.parseFrom(buffer); MitmRelay.getInstance().call(envelope); setRequests(envelope); } } catch (InvalidProtocolBufferException ignored) { } catch (Throwable throwable) {
Log.e(throwable);
igoticecream/Snorlax
app/src/main/java/com/icecream/snorlax/module/feature/encounter/EncounterNotification.java
// Path: app/src/main/java/com/icecream/snorlax/common/Strings.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Strings { // // public static final String EMPTY = ""; // public static final String DOT = "."; // public static final String COLON = ":"; // public static final String SPACE = " "; // // public static String nullToEmpty(String string) { // return (string == null) ? EMPTY : string; // } // // public static String emptyToNull(String string) { // return isNullOrEmpty(string) ? null : string; // } // // public static boolean isNullOrEmpty(String string) { // return isNull(string) || isEmpty(string); // } // // public static boolean isNull(String string) { // return string == null; // } // // public static boolean isEmpty(String string) { // return string.trim().length() == 0; // } // // public static String valueOrDefault(String string, String defaultString) { // return isNullOrEmpty(string) ? defaultString : string; // } // // public static String truncateAt(String string, int length) { // return (string.length() > length) ? string.substring(0, length) : string; // } // // public static String padEnd(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // sb.append(string); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // return sb.toString(); // } // // public static String padStart(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // sb.append(string); // return sb.toString(); // } // // public static String capitalize(String[] string) { // if (string == null) { // return null; // } // StringBuilder builder = new StringBuilder(); // for (String sub : string) { // builder // .append(capitalize(sub)) // .append(" "); // } // return builder.toString().trim(); // } // // public static String capitalize(String string) { // if (isNullOrEmpty(string) || string.trim().length() < 2) { // return string; // } // return String.valueOf(string.charAt(0)).toUpperCase(Locale.US) + string.substring(1).toLowerCase(Locale.US); // } // // private Strings() { // throw new AssertionError("No instances"); // } // } // // Path: app/src/main/java/com/icecream/snorlax/module/pokemon/PokemonType.java // public enum PokemonType { // NONE, // GRASS, // FIRE, // WATER, // BUG, // ELECTRIC, // POISON, // FAIRY, // NORMAL, // PSYCHIC, // FIGHTING, // DRAGON, // FLYING, // ICE, // ROCK, // GROUND, // GHOST, // STEEL, // DARK; // // @Override // public String toString() { // return Strings.capitalize(name().split("_")); // } // }
import java.util.Locale; import javax.inject.Inject; import javax.inject.Singleton; import android.app.Notification; import android.app.NotificationManager; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Typeface; import android.os.Handler; import android.os.Looper; import android.support.annotation.DrawableRes; import android.support.v4.content.ContextCompat; import android.support.v7.app.NotificationCompat; import android.text.Spannable; import android.text.SpannableString; import android.text.style.StyleSpan; import android.view.View; import com.icecream.snorlax.R; import com.icecream.snorlax.common.Strings; import com.icecream.snorlax.module.context.pokemongo.PokemonGo; import com.icecream.snorlax.module.context.snorlax.Snorlax; import com.icecream.snorlax.module.pokemon.PokemonType;
hideIcon(notification); mNotificationManager.notify(NOTIFICATION_ID, notification); }); } @DrawableRes private int getPokemonResourceId(int pokemonNumber) { return mResources.getIdentifier("pokemon_" + Strings.padStart(String.valueOf(pokemonNumber), 3, '0'), "drawable", mContext.getPackageName()); } private int getLargeIconWidth() { return mResources.getDimensionPixelSize(android.R.dimen.notification_large_icon_width); } private int getLargeIconHeight() { return mResources.getDimensionPixelSize(android.R.dimen.notification_large_icon_height); } private Spannable getBoldSpannable(String text) { Spannable spannable = new SpannableString(text); spannable.setSpan(new StyleSpan(Typeface.BOLD), 0, spannable.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); return spannable; } @SuppressWarnings("StringBufferReplaceableByString") private String getFooter(String type1, String type2, String pokemonClass) { return new StringBuilder() .append(type1)
// Path: app/src/main/java/com/icecream/snorlax/common/Strings.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Strings { // // public static final String EMPTY = ""; // public static final String DOT = "."; // public static final String COLON = ":"; // public static final String SPACE = " "; // // public static String nullToEmpty(String string) { // return (string == null) ? EMPTY : string; // } // // public static String emptyToNull(String string) { // return isNullOrEmpty(string) ? null : string; // } // // public static boolean isNullOrEmpty(String string) { // return isNull(string) || isEmpty(string); // } // // public static boolean isNull(String string) { // return string == null; // } // // public static boolean isEmpty(String string) { // return string.trim().length() == 0; // } // // public static String valueOrDefault(String string, String defaultString) { // return isNullOrEmpty(string) ? defaultString : string; // } // // public static String truncateAt(String string, int length) { // return (string.length() > length) ? string.substring(0, length) : string; // } // // public static String padEnd(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // sb.append(string); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // return sb.toString(); // } // // public static String padStart(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // sb.append(string); // return sb.toString(); // } // // public static String capitalize(String[] string) { // if (string == null) { // return null; // } // StringBuilder builder = new StringBuilder(); // for (String sub : string) { // builder // .append(capitalize(sub)) // .append(" "); // } // return builder.toString().trim(); // } // // public static String capitalize(String string) { // if (isNullOrEmpty(string) || string.trim().length() < 2) { // return string; // } // return String.valueOf(string.charAt(0)).toUpperCase(Locale.US) + string.substring(1).toLowerCase(Locale.US); // } // // private Strings() { // throw new AssertionError("No instances"); // } // } // // Path: app/src/main/java/com/icecream/snorlax/module/pokemon/PokemonType.java // public enum PokemonType { // NONE, // GRASS, // FIRE, // WATER, // BUG, // ELECTRIC, // POISON, // FAIRY, // NORMAL, // PSYCHIC, // FIGHTING, // DRAGON, // FLYING, // ICE, // ROCK, // GROUND, // GHOST, // STEEL, // DARK; // // @Override // public String toString() { // return Strings.capitalize(name().split("_")); // } // } // Path: app/src/main/java/com/icecream/snorlax/module/feature/encounter/EncounterNotification.java import java.util.Locale; import javax.inject.Inject; import javax.inject.Singleton; import android.app.Notification; import android.app.NotificationManager; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Typeface; import android.os.Handler; import android.os.Looper; import android.support.annotation.DrawableRes; import android.support.v4.content.ContextCompat; import android.support.v7.app.NotificationCompat; import android.text.Spannable; import android.text.SpannableString; import android.text.style.StyleSpan; import android.view.View; import com.icecream.snorlax.R; import com.icecream.snorlax.common.Strings; import com.icecream.snorlax.module.context.pokemongo.PokemonGo; import com.icecream.snorlax.module.context.snorlax.Snorlax; import com.icecream.snorlax.module.pokemon.PokemonType; hideIcon(notification); mNotificationManager.notify(NOTIFICATION_ID, notification); }); } @DrawableRes private int getPokemonResourceId(int pokemonNumber) { return mResources.getIdentifier("pokemon_" + Strings.padStart(String.valueOf(pokemonNumber), 3, '0'), "drawable", mContext.getPackageName()); } private int getLargeIconWidth() { return mResources.getDimensionPixelSize(android.R.dimen.notification_large_icon_width); } private int getLargeIconHeight() { return mResources.getDimensionPixelSize(android.R.dimen.notification_large_icon_height); } private Spannable getBoldSpannable(String text) { Spannable spannable = new SpannableString(text); spannable.setSpan(new StyleSpan(Typeface.BOLD), 0, spannable.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); return spannable; } @SuppressWarnings("StringBufferReplaceableByString") private String getFooter(String type1, String type2, String pokemonClass) { return new StringBuilder() .append(type1)
.append(type2.equalsIgnoreCase(PokemonType.NONE.toString()) ? Strings.EMPTY : String.format(Locale.US, "/%s", type2))
igoticecream/Snorlax
app/src/main/java/com/icecream/snorlax/module/SnorlaxModule.java
// Path: app/src/main/java/com/icecream/snorlax/common/rx/RxBus.java // @SuppressWarnings({"unused", "WeakerAccess", "FieldCanBeLocal"}) // public final class RxBus { // // private static volatile RxBus sInstance = null; // // public static RxBus getInstance() { // if (sInstance == null) { // synchronized (RxBus.class) { // if (sInstance == null) { // sInstance = new RxBus(); // } // } // } // return sInstance; // } // // private final SerializedRelay<Object, Object> mSubject; // // private RxBus() { // mSubject = PublishRelay.create().toSerialized(); // } // // public void post(Object event) { // mSubject.call(event); // } // // public <T> Subscription receive(final Class<T> klass, Action1<T> onNext) { // return receive(klass).subscribe(onNext); // } // // public <T> Observable<T> receive(final Class<T> klass) { // return receive().ofType(klass); // } // // public Observable<Object> receive() { // return mSubject; // } // } // // Path: app/src/main/java/com/icecream/snorlax/module/feature/mitm/MitmRelay.java // public final class MitmRelay { // // private static volatile MitmRelay sInstance = null; // // public static MitmRelay getInstance() { // if (sInstance == null) { // synchronized (MitmRelay.class) { // if (sInstance == null) { // sInstance = new MitmRelay(); // } // } // } // return sInstance; // } // // private final SerializedRelay<RequestEnvelope, RequestEnvelope> mRelayRequest; // private final SerializedRelay<ResponseEnvelope, ResponseEnvelope> mRelayResponse; // private final Observable<MitmEnvelope> mEnvelope; // // private MitmRelay() { // mRelayRequest = PublishRelay.<RequestEnvelope>create().toSerialized(); // mRelayResponse = PublishRelay.<ResponseEnvelope>create().toSerialized(); // // mEnvelope = Observable // .fromEmitter(emitter -> mRelayRequest.asObservable().subscribe(emitter::onNext), Emitter.BackpressureMode.BUFFER) // .cast(RequestEnvelope.class) // .flatMap(request -> Observable // .fromEmitter(emitter -> mRelayResponse.asObservable().subscribe(emitter::onNext), Emitter.BackpressureMode.BUFFER) // .cast(ResponseEnvelope.class) // .filter(response -> Objects.equals(request.getRequestId(), response.getRequestId())) // .map(response -> MitmEnvelope.create(request, response)) // ) // .share(); // } // // void call(RequestEnvelope envelope) { // mRelayRequest.call(envelope); // } // // void call(ResponseEnvelope envelope) { // mRelayResponse.call(envelope); // } // // public Observable<MitmEnvelope> getObservable() { // return mEnvelope; // } // }
import static POGOProtos.Networking.Requests.RequestOuterClass.Request; import java.util.List; import javax.inject.Singleton; import android.app.Application; import android.util.LongSparseArray; import com.icecream.snorlax.common.rx.RxBus; import com.icecream.snorlax.module.feature.mitm.MitmRelay; import dagger.Module; import dagger.Provides; import de.robv.android.xposed.XSharedPreferences;
/* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module; @Module final class SnorlaxModule { private final Application mApplication; private final ClassLoader mClassLoader; private final XSharedPreferences mXSharedPreferences; SnorlaxModule(Application application, ClassLoader classLoader, XSharedPreferences xSharedPreferences) { mApplication = application; mClassLoader = classLoader; mXSharedPreferences = xSharedPreferences; } @Provides ClassLoader provideClassLoader() { return mClassLoader; } @Provides XSharedPreferences provideXSharedPreferences() { return mXSharedPreferences; } @Provides Application provideAppliction() { return mApplication; } @Provides @Singleton
// Path: app/src/main/java/com/icecream/snorlax/common/rx/RxBus.java // @SuppressWarnings({"unused", "WeakerAccess", "FieldCanBeLocal"}) // public final class RxBus { // // private static volatile RxBus sInstance = null; // // public static RxBus getInstance() { // if (sInstance == null) { // synchronized (RxBus.class) { // if (sInstance == null) { // sInstance = new RxBus(); // } // } // } // return sInstance; // } // // private final SerializedRelay<Object, Object> mSubject; // // private RxBus() { // mSubject = PublishRelay.create().toSerialized(); // } // // public void post(Object event) { // mSubject.call(event); // } // // public <T> Subscription receive(final Class<T> klass, Action1<T> onNext) { // return receive(klass).subscribe(onNext); // } // // public <T> Observable<T> receive(final Class<T> klass) { // return receive().ofType(klass); // } // // public Observable<Object> receive() { // return mSubject; // } // } // // Path: app/src/main/java/com/icecream/snorlax/module/feature/mitm/MitmRelay.java // public final class MitmRelay { // // private static volatile MitmRelay sInstance = null; // // public static MitmRelay getInstance() { // if (sInstance == null) { // synchronized (MitmRelay.class) { // if (sInstance == null) { // sInstance = new MitmRelay(); // } // } // } // return sInstance; // } // // private final SerializedRelay<RequestEnvelope, RequestEnvelope> mRelayRequest; // private final SerializedRelay<ResponseEnvelope, ResponseEnvelope> mRelayResponse; // private final Observable<MitmEnvelope> mEnvelope; // // private MitmRelay() { // mRelayRequest = PublishRelay.<RequestEnvelope>create().toSerialized(); // mRelayResponse = PublishRelay.<ResponseEnvelope>create().toSerialized(); // // mEnvelope = Observable // .fromEmitter(emitter -> mRelayRequest.asObservable().subscribe(emitter::onNext), Emitter.BackpressureMode.BUFFER) // .cast(RequestEnvelope.class) // .flatMap(request -> Observable // .fromEmitter(emitter -> mRelayResponse.asObservable().subscribe(emitter::onNext), Emitter.BackpressureMode.BUFFER) // .cast(ResponseEnvelope.class) // .filter(response -> Objects.equals(request.getRequestId(), response.getRequestId())) // .map(response -> MitmEnvelope.create(request, response)) // ) // .share(); // } // // void call(RequestEnvelope envelope) { // mRelayRequest.call(envelope); // } // // void call(ResponseEnvelope envelope) { // mRelayResponse.call(envelope); // } // // public Observable<MitmEnvelope> getObservable() { // return mEnvelope; // } // } // Path: app/src/main/java/com/icecream/snorlax/module/SnorlaxModule.java import static POGOProtos.Networking.Requests.RequestOuterClass.Request; import java.util.List; import javax.inject.Singleton; import android.app.Application; import android.util.LongSparseArray; import com.icecream.snorlax.common.rx.RxBus; import com.icecream.snorlax.module.feature.mitm.MitmRelay; import dagger.Module; import dagger.Provides; import de.robv.android.xposed.XSharedPreferences; /* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module; @Module final class SnorlaxModule { private final Application mApplication; private final ClassLoader mClassLoader; private final XSharedPreferences mXSharedPreferences; SnorlaxModule(Application application, ClassLoader classLoader, XSharedPreferences xSharedPreferences) { mApplication = application; mClassLoader = classLoader; mXSharedPreferences = xSharedPreferences; } @Provides ClassLoader provideClassLoader() { return mClassLoader; } @Provides XSharedPreferences provideXSharedPreferences() { return mXSharedPreferences; } @Provides Application provideAppliction() { return mApplication; } @Provides @Singleton
MitmRelay provideMitmRelay() {
igoticecream/Snorlax
app/src/main/java/com/icecream/snorlax/module/SnorlaxModule.java
// Path: app/src/main/java/com/icecream/snorlax/common/rx/RxBus.java // @SuppressWarnings({"unused", "WeakerAccess", "FieldCanBeLocal"}) // public final class RxBus { // // private static volatile RxBus sInstance = null; // // public static RxBus getInstance() { // if (sInstance == null) { // synchronized (RxBus.class) { // if (sInstance == null) { // sInstance = new RxBus(); // } // } // } // return sInstance; // } // // private final SerializedRelay<Object, Object> mSubject; // // private RxBus() { // mSubject = PublishRelay.create().toSerialized(); // } // // public void post(Object event) { // mSubject.call(event); // } // // public <T> Subscription receive(final Class<T> klass, Action1<T> onNext) { // return receive(klass).subscribe(onNext); // } // // public <T> Observable<T> receive(final Class<T> klass) { // return receive().ofType(klass); // } // // public Observable<Object> receive() { // return mSubject; // } // } // // Path: app/src/main/java/com/icecream/snorlax/module/feature/mitm/MitmRelay.java // public final class MitmRelay { // // private static volatile MitmRelay sInstance = null; // // public static MitmRelay getInstance() { // if (sInstance == null) { // synchronized (MitmRelay.class) { // if (sInstance == null) { // sInstance = new MitmRelay(); // } // } // } // return sInstance; // } // // private final SerializedRelay<RequestEnvelope, RequestEnvelope> mRelayRequest; // private final SerializedRelay<ResponseEnvelope, ResponseEnvelope> mRelayResponse; // private final Observable<MitmEnvelope> mEnvelope; // // private MitmRelay() { // mRelayRequest = PublishRelay.<RequestEnvelope>create().toSerialized(); // mRelayResponse = PublishRelay.<ResponseEnvelope>create().toSerialized(); // // mEnvelope = Observable // .fromEmitter(emitter -> mRelayRequest.asObservable().subscribe(emitter::onNext), Emitter.BackpressureMode.BUFFER) // .cast(RequestEnvelope.class) // .flatMap(request -> Observable // .fromEmitter(emitter -> mRelayResponse.asObservable().subscribe(emitter::onNext), Emitter.BackpressureMode.BUFFER) // .cast(ResponseEnvelope.class) // .filter(response -> Objects.equals(request.getRequestId(), response.getRequestId())) // .map(response -> MitmEnvelope.create(request, response)) // ) // .share(); // } // // void call(RequestEnvelope envelope) { // mRelayRequest.call(envelope); // } // // void call(ResponseEnvelope envelope) { // mRelayResponse.call(envelope); // } // // public Observable<MitmEnvelope> getObservable() { // return mEnvelope; // } // }
import static POGOProtos.Networking.Requests.RequestOuterClass.Request; import java.util.List; import javax.inject.Singleton; import android.app.Application; import android.util.LongSparseArray; import com.icecream.snorlax.common.rx.RxBus; import com.icecream.snorlax.module.feature.mitm.MitmRelay; import dagger.Module; import dagger.Provides; import de.robv.android.xposed.XSharedPreferences;
} @Provides ClassLoader provideClassLoader() { return mClassLoader; } @Provides XSharedPreferences provideXSharedPreferences() { return mXSharedPreferences; } @Provides Application provideAppliction() { return mApplication; } @Provides @Singleton MitmRelay provideMitmRelay() { return MitmRelay.getInstance(); } @Provides @Singleton LongSparseArray<List<Request>> provideLongSparseArray() { return new LongSparseArray<>(); } @Provides
// Path: app/src/main/java/com/icecream/snorlax/common/rx/RxBus.java // @SuppressWarnings({"unused", "WeakerAccess", "FieldCanBeLocal"}) // public final class RxBus { // // private static volatile RxBus sInstance = null; // // public static RxBus getInstance() { // if (sInstance == null) { // synchronized (RxBus.class) { // if (sInstance == null) { // sInstance = new RxBus(); // } // } // } // return sInstance; // } // // private final SerializedRelay<Object, Object> mSubject; // // private RxBus() { // mSubject = PublishRelay.create().toSerialized(); // } // // public void post(Object event) { // mSubject.call(event); // } // // public <T> Subscription receive(final Class<T> klass, Action1<T> onNext) { // return receive(klass).subscribe(onNext); // } // // public <T> Observable<T> receive(final Class<T> klass) { // return receive().ofType(klass); // } // // public Observable<Object> receive() { // return mSubject; // } // } // // Path: app/src/main/java/com/icecream/snorlax/module/feature/mitm/MitmRelay.java // public final class MitmRelay { // // private static volatile MitmRelay sInstance = null; // // public static MitmRelay getInstance() { // if (sInstance == null) { // synchronized (MitmRelay.class) { // if (sInstance == null) { // sInstance = new MitmRelay(); // } // } // } // return sInstance; // } // // private final SerializedRelay<RequestEnvelope, RequestEnvelope> mRelayRequest; // private final SerializedRelay<ResponseEnvelope, ResponseEnvelope> mRelayResponse; // private final Observable<MitmEnvelope> mEnvelope; // // private MitmRelay() { // mRelayRequest = PublishRelay.<RequestEnvelope>create().toSerialized(); // mRelayResponse = PublishRelay.<ResponseEnvelope>create().toSerialized(); // // mEnvelope = Observable // .fromEmitter(emitter -> mRelayRequest.asObservable().subscribe(emitter::onNext), Emitter.BackpressureMode.BUFFER) // .cast(RequestEnvelope.class) // .flatMap(request -> Observable // .fromEmitter(emitter -> mRelayResponse.asObservable().subscribe(emitter::onNext), Emitter.BackpressureMode.BUFFER) // .cast(ResponseEnvelope.class) // .filter(response -> Objects.equals(request.getRequestId(), response.getRequestId())) // .map(response -> MitmEnvelope.create(request, response)) // ) // .share(); // } // // void call(RequestEnvelope envelope) { // mRelayRequest.call(envelope); // } // // void call(ResponseEnvelope envelope) { // mRelayResponse.call(envelope); // } // // public Observable<MitmEnvelope> getObservable() { // return mEnvelope; // } // } // Path: app/src/main/java/com/icecream/snorlax/module/SnorlaxModule.java import static POGOProtos.Networking.Requests.RequestOuterClass.Request; import java.util.List; import javax.inject.Singleton; import android.app.Application; import android.util.LongSparseArray; import com.icecream.snorlax.common.rx.RxBus; import com.icecream.snorlax.module.feature.mitm.MitmRelay; import dagger.Module; import dagger.Provides; import de.robv.android.xposed.XSharedPreferences; } @Provides ClassLoader provideClassLoader() { return mClassLoader; } @Provides XSharedPreferences provideXSharedPreferences() { return mXSharedPreferences; } @Provides Application provideAppliction() { return mApplication; } @Provides @Singleton MitmRelay provideMitmRelay() { return MitmRelay.getInstance(); } @Provides @Singleton LongSparseArray<List<Request>> provideLongSparseArray() { return new LongSparseArray<>(); } @Provides
RxBus provideRxBus() {
igoticecream/Snorlax
app/src/main/java/com/icecream/snorlax/module/pokemon/MovementType.java
// Path: app/src/main/java/com/icecream/snorlax/common/Strings.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Strings { // // public static final String EMPTY = ""; // public static final String DOT = "."; // public static final String COLON = ":"; // public static final String SPACE = " "; // // public static String nullToEmpty(String string) { // return (string == null) ? EMPTY : string; // } // // public static String emptyToNull(String string) { // return isNullOrEmpty(string) ? null : string; // } // // public static boolean isNullOrEmpty(String string) { // return isNull(string) || isEmpty(string); // } // // public static boolean isNull(String string) { // return string == null; // } // // public static boolean isEmpty(String string) { // return string.trim().length() == 0; // } // // public static String valueOrDefault(String string, String defaultString) { // return isNullOrEmpty(string) ? defaultString : string; // } // // public static String truncateAt(String string, int length) { // return (string.length() > length) ? string.substring(0, length) : string; // } // // public static String padEnd(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // sb.append(string); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // return sb.toString(); // } // // public static String padStart(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // sb.append(string); // return sb.toString(); // } // // public static String capitalize(String[] string) { // if (string == null) { // return null; // } // StringBuilder builder = new StringBuilder(); // for (String sub : string) { // builder // .append(capitalize(sub)) // .append(" "); // } // return builder.toString().trim(); // } // // public static String capitalize(String string) { // if (isNullOrEmpty(string) || string.trim().length() < 2) { // return string; // } // return String.valueOf(string.charAt(0)).toUpperCase(Locale.US) + string.substring(1).toLowerCase(Locale.US); // } // // private Strings() { // throw new AssertionError("No instances"); // } // }
import com.icecream.snorlax.common.Strings;
/* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module.pokemon; @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) public enum MovementType { PSYCHIC, FLYING, ELETRIC, NORMAL, HOVERING, JUMP, ELECTRIC; @Override public String toString() {
// Path: app/src/main/java/com/icecream/snorlax/common/Strings.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Strings { // // public static final String EMPTY = ""; // public static final String DOT = "."; // public static final String COLON = ":"; // public static final String SPACE = " "; // // public static String nullToEmpty(String string) { // return (string == null) ? EMPTY : string; // } // // public static String emptyToNull(String string) { // return isNullOrEmpty(string) ? null : string; // } // // public static boolean isNullOrEmpty(String string) { // return isNull(string) || isEmpty(string); // } // // public static boolean isNull(String string) { // return string == null; // } // // public static boolean isEmpty(String string) { // return string.trim().length() == 0; // } // // public static String valueOrDefault(String string, String defaultString) { // return isNullOrEmpty(string) ? defaultString : string; // } // // public static String truncateAt(String string, int length) { // return (string.length() > length) ? string.substring(0, length) : string; // } // // public static String padEnd(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // sb.append(string); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // return sb.toString(); // } // // public static String padStart(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // sb.append(string); // return sb.toString(); // } // // public static String capitalize(String[] string) { // if (string == null) { // return null; // } // StringBuilder builder = new StringBuilder(); // for (String sub : string) { // builder // .append(capitalize(sub)) // .append(" "); // } // return builder.toString().trim(); // } // // public static String capitalize(String string) { // if (isNullOrEmpty(string) || string.trim().length() < 2) { // return string; // } // return String.valueOf(string.charAt(0)).toUpperCase(Locale.US) + string.substring(1).toLowerCase(Locale.US); // } // // private Strings() { // throw new AssertionError("No instances"); // } // } // Path: app/src/main/java/com/icecream/snorlax/module/pokemon/MovementType.java import com.icecream.snorlax.common.Strings; /* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module.pokemon; @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) public enum MovementType { PSYCHIC, FLYING, ELETRIC, NORMAL, HOVERING, JUMP, ELECTRIC; @Override public String toString() {
return Strings.capitalize(name().split("_"));
igoticecream/Snorlax
app/src/main/java/com/icecream/snorlax/module/feature/mock/Mock.java
// Path: app/src/main/java/com/icecream/snorlax/module/Log.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Log { // // public static void d(String format, Object... args) { // XposedBridge.log(String.format(Locale.US, format, args)); // } // // public static void e(Throwable throwable) { // XposedBridge.log(throwable); // } // // public static void e(Throwable throwable, String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args), throwable)); // } // // public static void e(String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args))); // } // // private Log() { // throw new AssertionError("No instances"); // } // } // // Path: app/src/main/java/com/icecream/snorlax/module/feature/Feature.java // public interface Feature { // // void subscribe() throws Exception; // // void unsubscribe() throws Exception; // }
import javax.inject.Inject; import javax.inject.Singleton; import android.content.ContentResolver; import android.os.Bundle; import android.provider.Settings; import com.icecream.snorlax.module.Log; import com.icecream.snorlax.module.feature.Feature; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers;
/* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module.feature.mock; @Singleton public final class Mock implements Feature { private final ClassLoader mClassLoader; private final MockPreferences mPreferences; private XC_MethodHook.Unhook mUnhookGetInt1; private XC_MethodHook.Unhook mUnhookGetInt2; private XC_MethodHook.Unhook mUnhookGetFloat1; private XC_MethodHook.Unhook mUnhookGetFloat2; private XC_MethodHook.Unhook mUnhookGetLong1; private XC_MethodHook.Unhook mUnhookGetLong2; private XC_MethodHook.Unhook mUnhookGetString; private XC_MethodHook.Unhook mUnhookGms; private XC_MethodHook.Unhook mUnhookMockProvider; @Inject Mock(ClassLoader classLoader, MockPreferences preferences) { mClassLoader = classLoader; mPreferences = preferences; } @Override public void subscribe() throws Exception { final Class<?> secure = XposedHelpers.findClass("android.provider.Settings.Secure", mClassLoader); if (secure == null) {
// Path: app/src/main/java/com/icecream/snorlax/module/Log.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Log { // // public static void d(String format, Object... args) { // XposedBridge.log(String.format(Locale.US, format, args)); // } // // public static void e(Throwable throwable) { // XposedBridge.log(throwable); // } // // public static void e(Throwable throwable, String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args), throwable)); // } // // public static void e(String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args))); // } // // private Log() { // throw new AssertionError("No instances"); // } // } // // Path: app/src/main/java/com/icecream/snorlax/module/feature/Feature.java // public interface Feature { // // void subscribe() throws Exception; // // void unsubscribe() throws Exception; // } // Path: app/src/main/java/com/icecream/snorlax/module/feature/mock/Mock.java import javax.inject.Inject; import javax.inject.Singleton; import android.content.ContentResolver; import android.os.Bundle; import android.provider.Settings; import com.icecream.snorlax.module.Log; import com.icecream.snorlax.module.feature.Feature; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; /* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module.feature.mock; @Singleton public final class Mock implements Feature { private final ClassLoader mClassLoader; private final MockPreferences mPreferences; private XC_MethodHook.Unhook mUnhookGetInt1; private XC_MethodHook.Unhook mUnhookGetInt2; private XC_MethodHook.Unhook mUnhookGetFloat1; private XC_MethodHook.Unhook mUnhookGetFloat2; private XC_MethodHook.Unhook mUnhookGetLong1; private XC_MethodHook.Unhook mUnhookGetLong2; private XC_MethodHook.Unhook mUnhookGetString; private XC_MethodHook.Unhook mUnhookGms; private XC_MethodHook.Unhook mUnhookMockProvider; @Inject Mock(ClassLoader classLoader, MockPreferences preferences) { mClassLoader = classLoader; mPreferences = preferences; } @Override public void subscribe() throws Exception { final Class<?> secure = XposedHelpers.findClass("android.provider.Settings.Secure", mClassLoader); if (secure == null) {
Log.e("Cannot find Secure class");
igoticecream/Snorlax
app/src/main/java/com/icecream/snorlax/module/feature/ui/Ui.java
// Path: app/src/main/java/com/icecream/snorlax/module/Log.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Log { // // public static void d(String format, Object... args) { // XposedBridge.log(String.format(Locale.US, format, args)); // } // // public static void e(Throwable throwable) { // XposedBridge.log(throwable); // } // // public static void e(Throwable throwable, String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args), throwable)); // } // // public static void e(String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args))); // } // // private Log() { // throw new AssertionError("No instances"); // } // } // // Path: app/src/main/java/com/icecream/snorlax/module/feature/Feature.java // public interface Feature { // // void subscribe() throws Exception; // // void unsubscribe() throws Exception; // }
import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import javax.inject.Inject; import javax.inject.Singleton; import android.content.ContextWrapper; import android.view.LayoutInflater; import android.view.View; import android.widget.FrameLayout; import android.widget.Toast; import com.icecream.snorlax.R; import com.icecream.snorlax.module.Log; import com.icecream.snorlax.module.context.snorlax.Snorlax; import com.icecream.snorlax.module.feature.Feature;
/* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module.feature.ui; @Singleton final class Ui implements Feature { private final ClassLoader mClassLoader; private final LayoutInflater mLayoutInflater; private XC_MethodHook.Unhook mUnhookUnity; @Inject Ui(ClassLoader classLoader, @Snorlax LayoutInflater layoutInflater) { mClassLoader = classLoader; mLayoutInflater = layoutInflater; } @Override public void subscribe() throws Exception { final Class<?> unity = XposedHelpers.findClass("com.unity3d.player.UnityPlayer", mClassLoader); if (unity == null) {
// Path: app/src/main/java/com/icecream/snorlax/module/Log.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Log { // // public static void d(String format, Object... args) { // XposedBridge.log(String.format(Locale.US, format, args)); // } // // public static void e(Throwable throwable) { // XposedBridge.log(throwable); // } // // public static void e(Throwable throwable, String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args), throwable)); // } // // public static void e(String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args))); // } // // private Log() { // throw new AssertionError("No instances"); // } // } // // Path: app/src/main/java/com/icecream/snorlax/module/feature/Feature.java // public interface Feature { // // void subscribe() throws Exception; // // void unsubscribe() throws Exception; // } // Path: app/src/main/java/com/icecream/snorlax/module/feature/ui/Ui.java import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import javax.inject.Inject; import javax.inject.Singleton; import android.content.ContextWrapper; import android.view.LayoutInflater; import android.view.View; import android.widget.FrameLayout; import android.widget.Toast; import com.icecream.snorlax.R; import com.icecream.snorlax.module.Log; import com.icecream.snorlax.module.context.snorlax.Snorlax; import com.icecream.snorlax.module.feature.Feature; /* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module.feature.ui; @Singleton final class Ui implements Feature { private final ClassLoader mClassLoader; private final LayoutInflater mLayoutInflater; private XC_MethodHook.Unhook mUnhookUnity; @Inject Ui(ClassLoader classLoader, @Snorlax LayoutInflater layoutInflater) { mClassLoader = classLoader; mLayoutInflater = layoutInflater; } @Override public void subscribe() throws Exception { final Class<?> unity = XposedHelpers.findClass("com.unity3d.player.UnityPlayer", mClassLoader); if (unity == null) {
Log.e("Cannot find UnityPlayer class");
igoticecream/Snorlax
app/src/main/java/com/icecream/snorlax/module/SnorlaxComponent.java
// Path: app/src/main/java/com/icecream/snorlax/module/context/pokemongo/PokemonGoContextModule.java // @Module // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class PokemonGoContextModule { // // @Provides // @PokemonGo // @Singleton // static Context provideContext(Application application) { // try { // return PokemonGoContextFactory.create(application); // } // catch (PackageManager.NameNotFoundException e) { // throw new RuntimeException("Pokemon Go package not found... Cannot continue"); // } // } // // @Provides // @PokemonGo // @Singleton // static NotificationManager provideNotificationManager(@PokemonGo Context context) { // return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // } // } // // Path: app/src/main/java/com/icecream/snorlax/module/context/snorlax/SnorlaxContextModule.java // @Module // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class SnorlaxContextModule { // // @Provides // @Snorlax // @Singleton // static Context provideContext(Application application) { // try { // return SnorlaxContextFactory.create(application); // } // catch (PackageManager.NameNotFoundException e) { // throw new RuntimeException("Snorlax package not found... Cannot continue"); // } // } // // @Provides // @Snorlax // @Singleton // static Resources provideResources(@Snorlax Context context) { // return context.getResources(); // } // // @Provides // @Snorlax // @Singleton // static LayoutInflater provideLayoutInflater(@Snorlax Context context) { // return LayoutInflater.from(context); // } // }
import javax.inject.Singleton; import com.icecream.snorlax.module.context.pokemongo.PokemonGoContextModule; import com.icecream.snorlax.module.context.snorlax.SnorlaxContextModule; import dagger.Component;
/* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module; @Singleton @Component(modules = { SnorlaxModule.class,
// Path: app/src/main/java/com/icecream/snorlax/module/context/pokemongo/PokemonGoContextModule.java // @Module // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class PokemonGoContextModule { // // @Provides // @PokemonGo // @Singleton // static Context provideContext(Application application) { // try { // return PokemonGoContextFactory.create(application); // } // catch (PackageManager.NameNotFoundException e) { // throw new RuntimeException("Pokemon Go package not found... Cannot continue"); // } // } // // @Provides // @PokemonGo // @Singleton // static NotificationManager provideNotificationManager(@PokemonGo Context context) { // return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // } // } // // Path: app/src/main/java/com/icecream/snorlax/module/context/snorlax/SnorlaxContextModule.java // @Module // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class SnorlaxContextModule { // // @Provides // @Snorlax // @Singleton // static Context provideContext(Application application) { // try { // return SnorlaxContextFactory.create(application); // } // catch (PackageManager.NameNotFoundException e) { // throw new RuntimeException("Snorlax package not found... Cannot continue"); // } // } // // @Provides // @Snorlax // @Singleton // static Resources provideResources(@Snorlax Context context) { // return context.getResources(); // } // // @Provides // @Snorlax // @Singleton // static LayoutInflater provideLayoutInflater(@Snorlax Context context) { // return LayoutInflater.from(context); // } // } // Path: app/src/main/java/com/icecream/snorlax/module/SnorlaxComponent.java import javax.inject.Singleton; import com.icecream.snorlax.module.context.pokemongo.PokemonGoContextModule; import com.icecream.snorlax.module.context.snorlax.SnorlaxContextModule; import dagger.Component; /* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module; @Singleton @Component(modules = { SnorlaxModule.class,
SnorlaxContextModule.class,
igoticecream/Snorlax
app/src/main/java/com/icecream/snorlax/module/SnorlaxComponent.java
// Path: app/src/main/java/com/icecream/snorlax/module/context/pokemongo/PokemonGoContextModule.java // @Module // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class PokemonGoContextModule { // // @Provides // @PokemonGo // @Singleton // static Context provideContext(Application application) { // try { // return PokemonGoContextFactory.create(application); // } // catch (PackageManager.NameNotFoundException e) { // throw new RuntimeException("Pokemon Go package not found... Cannot continue"); // } // } // // @Provides // @PokemonGo // @Singleton // static NotificationManager provideNotificationManager(@PokemonGo Context context) { // return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // } // } // // Path: app/src/main/java/com/icecream/snorlax/module/context/snorlax/SnorlaxContextModule.java // @Module // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class SnorlaxContextModule { // // @Provides // @Snorlax // @Singleton // static Context provideContext(Application application) { // try { // return SnorlaxContextFactory.create(application); // } // catch (PackageManager.NameNotFoundException e) { // throw new RuntimeException("Snorlax package not found... Cannot continue"); // } // } // // @Provides // @Snorlax // @Singleton // static Resources provideResources(@Snorlax Context context) { // return context.getResources(); // } // // @Provides // @Snorlax // @Singleton // static LayoutInflater provideLayoutInflater(@Snorlax Context context) { // return LayoutInflater.from(context); // } // }
import javax.inject.Singleton; import com.icecream.snorlax.module.context.pokemongo.PokemonGoContextModule; import com.icecream.snorlax.module.context.snorlax.SnorlaxContextModule; import dagger.Component;
/* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module; @Singleton @Component(modules = { SnorlaxModule.class, SnorlaxContextModule.class,
// Path: app/src/main/java/com/icecream/snorlax/module/context/pokemongo/PokemonGoContextModule.java // @Module // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class PokemonGoContextModule { // // @Provides // @PokemonGo // @Singleton // static Context provideContext(Application application) { // try { // return PokemonGoContextFactory.create(application); // } // catch (PackageManager.NameNotFoundException e) { // throw new RuntimeException("Pokemon Go package not found... Cannot continue"); // } // } // // @Provides // @PokemonGo // @Singleton // static NotificationManager provideNotificationManager(@PokemonGo Context context) { // return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // } // } // // Path: app/src/main/java/com/icecream/snorlax/module/context/snorlax/SnorlaxContextModule.java // @Module // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class SnorlaxContextModule { // // @Provides // @Snorlax // @Singleton // static Context provideContext(Application application) { // try { // return SnorlaxContextFactory.create(application); // } // catch (PackageManager.NameNotFoundException e) { // throw new RuntimeException("Snorlax package not found... Cannot continue"); // } // } // // @Provides // @Snorlax // @Singleton // static Resources provideResources(@Snorlax Context context) { // return context.getResources(); // } // // @Provides // @Snorlax // @Singleton // static LayoutInflater provideLayoutInflater(@Snorlax Context context) { // return LayoutInflater.from(context); // } // } // Path: app/src/main/java/com/icecream/snorlax/module/SnorlaxComponent.java import javax.inject.Singleton; import com.icecream.snorlax.module.context.pokemongo.PokemonGoContextModule; import com.icecream.snorlax.module.context.snorlax.SnorlaxContextModule; import dagger.Component; /* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module; @Singleton @Component(modules = { SnorlaxModule.class, SnorlaxContextModule.class,
PokemonGoContextModule.class
igoticecream/Snorlax
app/src/main/java/com/icecream/snorlax/module/feature/FeatureHelper.java
// Path: app/src/main/java/com/icecream/snorlax/module/Log.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Log { // // public static void d(String format, Object... args) { // XposedBridge.log(String.format(Locale.US, format, args)); // } // // public static void e(Throwable throwable) { // XposedBridge.log(throwable); // } // // public static void e(Throwable throwable, String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args), throwable)); // } // // public static void e(String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args))); // } // // private Log() { // throw new AssertionError("No instances"); // } // }
import com.icecream.snorlax.module.Log; import rx.Observable;
/* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module.feature; public final class FeatureHelper { public static void subscribe(Feature... features) { Observable .from(features) .filter(feature -> feature != null) .subscribe(feature -> { try { feature.subscribe(); } catch (Exception exception) {
// Path: app/src/main/java/com/icecream/snorlax/module/Log.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Log { // // public static void d(String format, Object... args) { // XposedBridge.log(String.format(Locale.US, format, args)); // } // // public static void e(Throwable throwable) { // XposedBridge.log(throwable); // } // // public static void e(Throwable throwable, String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args), throwable)); // } // // public static void e(String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args))); // } // // private Log() { // throw new AssertionError("No instances"); // } // } // Path: app/src/main/java/com/icecream/snorlax/module/feature/FeatureHelper.java import com.icecream.snorlax.module.Log; import rx.Observable; /* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module.feature; public final class FeatureHelper { public static void subscribe(Feature... features) { Observable .from(features) .filter(feature -> feature != null) .subscribe(feature -> { try { feature.subscribe(); } catch (Exception exception) {
Log.e(exception, "Cannot subscribe to feature");
igoticecream/Snorlax
app/src/main/java/com/icecream/snorlax/module/pokemon/PokemonType.java
// Path: app/src/main/java/com/icecream/snorlax/common/Strings.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Strings { // // public static final String EMPTY = ""; // public static final String DOT = "."; // public static final String COLON = ":"; // public static final String SPACE = " "; // // public static String nullToEmpty(String string) { // return (string == null) ? EMPTY : string; // } // // public static String emptyToNull(String string) { // return isNullOrEmpty(string) ? null : string; // } // // public static boolean isNullOrEmpty(String string) { // return isNull(string) || isEmpty(string); // } // // public static boolean isNull(String string) { // return string == null; // } // // public static boolean isEmpty(String string) { // return string.trim().length() == 0; // } // // public static String valueOrDefault(String string, String defaultString) { // return isNullOrEmpty(string) ? defaultString : string; // } // // public static String truncateAt(String string, int length) { // return (string.length() > length) ? string.substring(0, length) : string; // } // // public static String padEnd(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // sb.append(string); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // return sb.toString(); // } // // public static String padStart(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // sb.append(string); // return sb.toString(); // } // // public static String capitalize(String[] string) { // if (string == null) { // return null; // } // StringBuilder builder = new StringBuilder(); // for (String sub : string) { // builder // .append(capitalize(sub)) // .append(" "); // } // return builder.toString().trim(); // } // // public static String capitalize(String string) { // if (isNullOrEmpty(string) || string.trim().length() < 2) { // return string; // } // return String.valueOf(string.charAt(0)).toUpperCase(Locale.US) + string.substring(1).toLowerCase(Locale.US); // } // // private Strings() { // throw new AssertionError("No instances"); // } // }
import com.icecream.snorlax.common.Strings;
/* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module.pokemon; public enum PokemonType { NONE, GRASS, FIRE, WATER, BUG, ELECTRIC, POISON, FAIRY, NORMAL, PSYCHIC, FIGHTING, DRAGON, FLYING, ICE, ROCK, GROUND, GHOST, STEEL, DARK; @Override public String toString() {
// Path: app/src/main/java/com/icecream/snorlax/common/Strings.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Strings { // // public static final String EMPTY = ""; // public static final String DOT = "."; // public static final String COLON = ":"; // public static final String SPACE = " "; // // public static String nullToEmpty(String string) { // return (string == null) ? EMPTY : string; // } // // public static String emptyToNull(String string) { // return isNullOrEmpty(string) ? null : string; // } // // public static boolean isNullOrEmpty(String string) { // return isNull(string) || isEmpty(string); // } // // public static boolean isNull(String string) { // return string == null; // } // // public static boolean isEmpty(String string) { // return string.trim().length() == 0; // } // // public static String valueOrDefault(String string, String defaultString) { // return isNullOrEmpty(string) ? defaultString : string; // } // // public static String truncateAt(String string, int length) { // return (string.length() > length) ? string.substring(0, length) : string; // } // // public static String padEnd(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // sb.append(string); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // return sb.toString(); // } // // public static String padStart(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // sb.append(string); // return sb.toString(); // } // // public static String capitalize(String[] string) { // if (string == null) { // return null; // } // StringBuilder builder = new StringBuilder(); // for (String sub : string) { // builder // .append(capitalize(sub)) // .append(" "); // } // return builder.toString().trim(); // } // // public static String capitalize(String string) { // if (isNullOrEmpty(string) || string.trim().length() < 2) { // return string; // } // return String.valueOf(string.charAt(0)).toUpperCase(Locale.US) + string.substring(1).toLowerCase(Locale.US); // } // // private Strings() { // throw new AssertionError("No instances"); // } // } // Path: app/src/main/java/com/icecream/snorlax/module/pokemon/PokemonType.java import com.icecream.snorlax.common.Strings; /* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module.pokemon; public enum PokemonType { NONE, GRASS, FIRE, WATER, BUG, ELECTRIC, POISON, FAIRY, NORMAL, PSYCHIC, FIGHTING, DRAGON, FLYING, ICE, ROCK, GROUND, GHOST, STEEL, DARK; @Override public String toString() {
return Strings.capitalize(name().split("_"));
igoticecream/Snorlax
app/src/main/java/com/icecream/snorlax/module/pokemon/PokemonMoveMeta.java
// Path: app/src/main/java/com/icecream/snorlax/common/Strings.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Strings { // // public static final String EMPTY = ""; // public static final String DOT = "."; // public static final String COLON = ":"; // public static final String SPACE = " "; // // public static String nullToEmpty(String string) { // return (string == null) ? EMPTY : string; // } // // public static String emptyToNull(String string) { // return isNullOrEmpty(string) ? null : string; // } // // public static boolean isNullOrEmpty(String string) { // return isNull(string) || isEmpty(string); // } // // public static boolean isNull(String string) { // return string == null; // } // // public static boolean isEmpty(String string) { // return string.trim().length() == 0; // } // // public static String valueOrDefault(String string, String defaultString) { // return isNullOrEmpty(string) ? defaultString : string; // } // // public static String truncateAt(String string, int length) { // return (string.length() > length) ? string.substring(0, length) : string; // } // // public static String padEnd(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // sb.append(string); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // return sb.toString(); // } // // public static String padStart(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // sb.append(string); // return sb.toString(); // } // // public static String capitalize(String[] string) { // if (string == null) { // return null; // } // StringBuilder builder = new StringBuilder(); // for (String sub : string) { // builder // .append(capitalize(sub)) // .append(" "); // } // return builder.toString().trim(); // } // // public static String capitalize(String string) { // if (isNullOrEmpty(string) || string.trim().length() < 2) { // return string; // } // return String.valueOf(string.charAt(0)).toUpperCase(Locale.US) + string.substring(1).toLowerCase(Locale.US); // } // // private Strings() { // throw new AssertionError("No instances"); // } // }
import java.util.ArrayList; import java.util.List; import com.icecream.snorlax.common.Strings; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import static POGOProtos.Enums.PokemonMoveOuterClass.PokemonMove;
@Setter(AccessLevel.PACKAGE) private PokemonType mType; @Getter @Setter(AccessLevel.PACKAGE) private int mPower; @Getter @Setter(AccessLevel.PACKAGE) private int mAccuracy; @Getter @Setter(AccessLevel.PACKAGE) private double mCriticalChance; @Getter @Setter(AccessLevel.PACKAGE) private int mTime; @Getter @Setter(AccessLevel.PACKAGE) private int mEnergy; PokemonMoveMeta() { } @Override public String toString() { List<String> move = new ArrayList<>(); for (String string : getMove().name().split("_")) { if (!string.equalsIgnoreCase("FAST")) { move.add(string); } }
// Path: app/src/main/java/com/icecream/snorlax/common/Strings.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Strings { // // public static final String EMPTY = ""; // public static final String DOT = "."; // public static final String COLON = ":"; // public static final String SPACE = " "; // // public static String nullToEmpty(String string) { // return (string == null) ? EMPTY : string; // } // // public static String emptyToNull(String string) { // return isNullOrEmpty(string) ? null : string; // } // // public static boolean isNullOrEmpty(String string) { // return isNull(string) || isEmpty(string); // } // // public static boolean isNull(String string) { // return string == null; // } // // public static boolean isEmpty(String string) { // return string.trim().length() == 0; // } // // public static String valueOrDefault(String string, String defaultString) { // return isNullOrEmpty(string) ? defaultString : string; // } // // public static String truncateAt(String string, int length) { // return (string.length() > length) ? string.substring(0, length) : string; // } // // public static String padEnd(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // sb.append(string); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // return sb.toString(); // } // // public static String padStart(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // sb.append(string); // return sb.toString(); // } // // public static String capitalize(String[] string) { // if (string == null) { // return null; // } // StringBuilder builder = new StringBuilder(); // for (String sub : string) { // builder // .append(capitalize(sub)) // .append(" "); // } // return builder.toString().trim(); // } // // public static String capitalize(String string) { // if (isNullOrEmpty(string) || string.trim().length() < 2) { // return string; // } // return String.valueOf(string.charAt(0)).toUpperCase(Locale.US) + string.substring(1).toLowerCase(Locale.US); // } // // private Strings() { // throw new AssertionError("No instances"); // } // } // Path: app/src/main/java/com/icecream/snorlax/module/pokemon/PokemonMoveMeta.java import java.util.ArrayList; import java.util.List; import com.icecream.snorlax.common.Strings; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import static POGOProtos.Enums.PokemonMoveOuterClass.PokemonMove; @Setter(AccessLevel.PACKAGE) private PokemonType mType; @Getter @Setter(AccessLevel.PACKAGE) private int mPower; @Getter @Setter(AccessLevel.PACKAGE) private int mAccuracy; @Getter @Setter(AccessLevel.PACKAGE) private double mCriticalChance; @Getter @Setter(AccessLevel.PACKAGE) private int mTime; @Getter @Setter(AccessLevel.PACKAGE) private int mEnergy; PokemonMoveMeta() { } @Override public String toString() { List<String> move = new ArrayList<>(); for (String string : getMove().name().split("_")) { if (!string.equalsIgnoreCase("FAST")) { move.add(string); } }
return Strings.capitalize(move.toArray(new String[0]));
igoticecream/Snorlax
app/src/main/java/com/icecream/snorlax/module/pokemon/PokemonClass.java
// Path: app/src/main/java/com/icecream/snorlax/common/Strings.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Strings { // // public static final String EMPTY = ""; // public static final String DOT = "."; // public static final String COLON = ":"; // public static final String SPACE = " "; // // public static String nullToEmpty(String string) { // return (string == null) ? EMPTY : string; // } // // public static String emptyToNull(String string) { // return isNullOrEmpty(string) ? null : string; // } // // public static boolean isNullOrEmpty(String string) { // return isNull(string) || isEmpty(string); // } // // public static boolean isNull(String string) { // return string == null; // } // // public static boolean isEmpty(String string) { // return string.trim().length() == 0; // } // // public static String valueOrDefault(String string, String defaultString) { // return isNullOrEmpty(string) ? defaultString : string; // } // // public static String truncateAt(String string, int length) { // return (string.length() > length) ? string.substring(0, length) : string; // } // // public static String padEnd(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // sb.append(string); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // return sb.toString(); // } // // public static String padStart(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // sb.append(string); // return sb.toString(); // } // // public static String capitalize(String[] string) { // if (string == null) { // return null; // } // StringBuilder builder = new StringBuilder(); // for (String sub : string) { // builder // .append(capitalize(sub)) // .append(" "); // } // return builder.toString().trim(); // } // // public static String capitalize(String string) { // if (isNullOrEmpty(string) || string.trim().length() < 2) { // return string; // } // return String.valueOf(string.charAt(0)).toUpperCase(Locale.US) + string.substring(1).toLowerCase(Locale.US); // } // // private Strings() { // throw new AssertionError("No instances"); // } // }
import com.icecream.snorlax.common.Strings;
/* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module.pokemon; @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) public enum PokemonClass { NONE, VERY_COMMON, COMMON, UNCOMMON, RARE, VERY_RARE, EPIC, LEGENDARY, MYTHIC; @Override public String toString() {
// Path: app/src/main/java/com/icecream/snorlax/common/Strings.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Strings { // // public static final String EMPTY = ""; // public static final String DOT = "."; // public static final String COLON = ":"; // public static final String SPACE = " "; // // public static String nullToEmpty(String string) { // return (string == null) ? EMPTY : string; // } // // public static String emptyToNull(String string) { // return isNullOrEmpty(string) ? null : string; // } // // public static boolean isNullOrEmpty(String string) { // return isNull(string) || isEmpty(string); // } // // public static boolean isNull(String string) { // return string == null; // } // // public static boolean isEmpty(String string) { // return string.trim().length() == 0; // } // // public static String valueOrDefault(String string, String defaultString) { // return isNullOrEmpty(string) ? defaultString : string; // } // // public static String truncateAt(String string, int length) { // return (string.length() > length) ? string.substring(0, length) : string; // } // // public static String padEnd(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // sb.append(string); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // return sb.toString(); // } // // public static String padStart(String string, int minLength, char padChar) { // if (string.length() >= minLength) { // return string; // } // StringBuilder sb = new StringBuilder(minLength); // for (int i = string.length(); i < minLength; i++) { // sb.append(padChar); // } // sb.append(string); // return sb.toString(); // } // // public static String capitalize(String[] string) { // if (string == null) { // return null; // } // StringBuilder builder = new StringBuilder(); // for (String sub : string) { // builder // .append(capitalize(sub)) // .append(" "); // } // return builder.toString().trim(); // } // // public static String capitalize(String string) { // if (isNullOrEmpty(string) || string.trim().length() < 2) { // return string; // } // return String.valueOf(string.charAt(0)).toUpperCase(Locale.US) + string.substring(1).toLowerCase(Locale.US); // } // // private Strings() { // throw new AssertionError("No instances"); // } // } // Path: app/src/main/java/com/icecream/snorlax/module/pokemon/PokemonClass.java import com.icecream.snorlax.common.Strings; /* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module.pokemon; @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) public enum PokemonClass { NONE, VERY_COMMON, COMMON, UNCOMMON, RARE, VERY_RARE, EPIC, LEGENDARY, MYTHIC; @Override public String toString() {
return Strings.capitalize(name().split("_"));
igoticecream/Snorlax
app/src/main/java/com/icecream/snorlax/app/home/HomeActivity.java
// Path: app/src/main/java/com/icecream/snorlax/app/SnorlaxApp.java // public class SnorlaxApp extends Application { // // public static boolean isEnabled() { // return false; // } // // @Override // public void onCreate() { // super.onCreate(); // // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // } // } // // Path: app/src/main/java/com/icecream/snorlax/app/settings/SettingsFragment.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public class SettingsFragment extends PreferenceFragmentCompat { // // private SettingsReadable mSettingsReadable; // // @Override // public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { // addPreferencesFromResource(preferences); // } // // @Override // public void onActivityCreated(Bundle savedInstanceState) { // super.onActivityCreated(savedInstanceState); // // setDivider(new ColorDrawable(Color.TRANSPARENT)); // setDividerHeight(0); // // getListView().setPadding(0, 0, 0, getActivity().getResources().getDimensionPixelSize(R.dimen.padding_list_bottom)); // } // // @Override // public void onPause() { // super.onPause(); // SettingsReadable settingsReadable = new SettingsReadable( // getActivity().getApplicationInfo(), // getPreferenceManager() // ); // // settingsReadable // .setReadable() // .subscribe(Timber::d, throwable -> { // Timber.e(throwable); // showReadableError(); // }); // } // // private void showReadableError() { // if (getActivity() != null) { // Toast.makeText(getActivity(), R.string.error_readable, Toast.LENGTH_LONG).show(); // } // } // }
import java.util.concurrent.TimeUnit; import android.content.SharedPreferences; import android.os.Bundle; import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.support.v7.preference.PreferenceManager; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import com.icecream.snorlax.BuildConfig; import com.icecream.snorlax.R; import com.icecream.snorlax.app.SnorlaxApp; import com.icecream.snorlax.app.settings.SettingsFragment; import com.jakewharton.rxbinding.view.RxView; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; import rx.Observable; import static com.icecream.snorlax.R.xml.preferences;
/* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.app.home; public class HomeActivity extends AppCompatActivity { @BindView(R.id.coordinator) CoordinatorLayout mCoordinatorLayout; @BindView(R.id.toolbar) Toolbar mToolbar; @BindView(R.id.fab) FloatingActionButton mFab; private Unbinder mUnbinder; private AlertDialog mAboutDialog; private AlertDialog mFormatInfoDialog; private AlertDialog mDonationDialog; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_activity); mUnbinder = ButterKnife.bind(this); setupToolbar(); setupPreferences(); if (savedInstanceState == null) { Observable
// Path: app/src/main/java/com/icecream/snorlax/app/SnorlaxApp.java // public class SnorlaxApp extends Application { // // public static boolean isEnabled() { // return false; // } // // @Override // public void onCreate() { // super.onCreate(); // // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // } // } // // Path: app/src/main/java/com/icecream/snorlax/app/settings/SettingsFragment.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public class SettingsFragment extends PreferenceFragmentCompat { // // private SettingsReadable mSettingsReadable; // // @Override // public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { // addPreferencesFromResource(preferences); // } // // @Override // public void onActivityCreated(Bundle savedInstanceState) { // super.onActivityCreated(savedInstanceState); // // setDivider(new ColorDrawable(Color.TRANSPARENT)); // setDividerHeight(0); // // getListView().setPadding(0, 0, 0, getActivity().getResources().getDimensionPixelSize(R.dimen.padding_list_bottom)); // } // // @Override // public void onPause() { // super.onPause(); // SettingsReadable settingsReadable = new SettingsReadable( // getActivity().getApplicationInfo(), // getPreferenceManager() // ); // // settingsReadable // .setReadable() // .subscribe(Timber::d, throwable -> { // Timber.e(throwable); // showReadableError(); // }); // } // // private void showReadableError() { // if (getActivity() != null) { // Toast.makeText(getActivity(), R.string.error_readable, Toast.LENGTH_LONG).show(); // } // } // } // Path: app/src/main/java/com/icecream/snorlax/app/home/HomeActivity.java import java.util.concurrent.TimeUnit; import android.content.SharedPreferences; import android.os.Bundle; import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.support.v7.preference.PreferenceManager; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import com.icecream.snorlax.BuildConfig; import com.icecream.snorlax.R; import com.icecream.snorlax.app.SnorlaxApp; import com.icecream.snorlax.app.settings.SettingsFragment; import com.jakewharton.rxbinding.view.RxView; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; import rx.Observable; import static com.icecream.snorlax.R.xml.preferences; /* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.app.home; public class HomeActivity extends AppCompatActivity { @BindView(R.id.coordinator) CoordinatorLayout mCoordinatorLayout; @BindView(R.id.toolbar) Toolbar mToolbar; @BindView(R.id.fab) FloatingActionButton mFab; private Unbinder mUnbinder; private AlertDialog mAboutDialog; private AlertDialog mFormatInfoDialog; private AlertDialog mDonationDialog; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_activity); mUnbinder = ButterKnife.bind(this); setupToolbar(); setupPreferences(); if (savedInstanceState == null) { Observable
.just(SnorlaxApp.isEnabled())
igoticecream/Snorlax
app/src/main/java/com/icecream/snorlax/app/home/HomeActivity.java
// Path: app/src/main/java/com/icecream/snorlax/app/SnorlaxApp.java // public class SnorlaxApp extends Application { // // public static boolean isEnabled() { // return false; // } // // @Override // public void onCreate() { // super.onCreate(); // // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // } // } // // Path: app/src/main/java/com/icecream/snorlax/app/settings/SettingsFragment.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public class SettingsFragment extends PreferenceFragmentCompat { // // private SettingsReadable mSettingsReadable; // // @Override // public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { // addPreferencesFromResource(preferences); // } // // @Override // public void onActivityCreated(Bundle savedInstanceState) { // super.onActivityCreated(savedInstanceState); // // setDivider(new ColorDrawable(Color.TRANSPARENT)); // setDividerHeight(0); // // getListView().setPadding(0, 0, 0, getActivity().getResources().getDimensionPixelSize(R.dimen.padding_list_bottom)); // } // // @Override // public void onPause() { // super.onPause(); // SettingsReadable settingsReadable = new SettingsReadable( // getActivity().getApplicationInfo(), // getPreferenceManager() // ); // // settingsReadable // .setReadable() // .subscribe(Timber::d, throwable -> { // Timber.e(throwable); // showReadableError(); // }); // } // // private void showReadableError() { // if (getActivity() != null) { // Toast.makeText(getActivity(), R.string.error_readable, Toast.LENGTH_LONG).show(); // } // } // }
import java.util.concurrent.TimeUnit; import android.content.SharedPreferences; import android.os.Bundle; import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.support.v7.preference.PreferenceManager; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import com.icecream.snorlax.BuildConfig; import com.icecream.snorlax.R; import com.icecream.snorlax.app.SnorlaxApp; import com.icecream.snorlax.app.settings.SettingsFragment; import com.jakewharton.rxbinding.view.RxView; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; import rx.Observable; import static com.icecream.snorlax.R.xml.preferences;
return Snackbar.make(mFab, R.string.error_xposed_missing, Snackbar.LENGTH_LONG); } }) .subscribe(Snackbar::show); } RxView .clicks(mFab) .throttleFirst(3, TimeUnit.SECONDS) .map(click -> getPackageManager().getLaunchIntentForPackage(BuildConfig.POKEMON_GO_ID)) .doOnNext(intent -> { if (intent == null) { Snackbar.make(mFab, R.string.error_pokemon_missing, Snackbar.LENGTH_LONG).show(); } }) .filter(intent -> intent != null) .subscribe(this::startActivity); checkIfFirstTime(); } private void setupToolbar() { setSupportActionBar(mToolbar); } private void setupPreferences() { PreferenceManager.setDefaultValues(this, preferences, false); getSupportFragmentManager() .beginTransaction()
// Path: app/src/main/java/com/icecream/snorlax/app/SnorlaxApp.java // public class SnorlaxApp extends Application { // // public static boolean isEnabled() { // return false; // } // // @Override // public void onCreate() { // super.onCreate(); // // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // } // } // // Path: app/src/main/java/com/icecream/snorlax/app/settings/SettingsFragment.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public class SettingsFragment extends PreferenceFragmentCompat { // // private SettingsReadable mSettingsReadable; // // @Override // public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { // addPreferencesFromResource(preferences); // } // // @Override // public void onActivityCreated(Bundle savedInstanceState) { // super.onActivityCreated(savedInstanceState); // // setDivider(new ColorDrawable(Color.TRANSPARENT)); // setDividerHeight(0); // // getListView().setPadding(0, 0, 0, getActivity().getResources().getDimensionPixelSize(R.dimen.padding_list_bottom)); // } // // @Override // public void onPause() { // super.onPause(); // SettingsReadable settingsReadable = new SettingsReadable( // getActivity().getApplicationInfo(), // getPreferenceManager() // ); // // settingsReadable // .setReadable() // .subscribe(Timber::d, throwable -> { // Timber.e(throwable); // showReadableError(); // }); // } // // private void showReadableError() { // if (getActivity() != null) { // Toast.makeText(getActivity(), R.string.error_readable, Toast.LENGTH_LONG).show(); // } // } // } // Path: app/src/main/java/com/icecream/snorlax/app/home/HomeActivity.java import java.util.concurrent.TimeUnit; import android.content.SharedPreferences; import android.os.Bundle; import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.support.v7.preference.PreferenceManager; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import com.icecream.snorlax.BuildConfig; import com.icecream.snorlax.R; import com.icecream.snorlax.app.SnorlaxApp; import com.icecream.snorlax.app.settings.SettingsFragment; import com.jakewharton.rxbinding.view.RxView; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; import rx.Observable; import static com.icecream.snorlax.R.xml.preferences; return Snackbar.make(mFab, R.string.error_xposed_missing, Snackbar.LENGTH_LONG); } }) .subscribe(Snackbar::show); } RxView .clicks(mFab) .throttleFirst(3, TimeUnit.SECONDS) .map(click -> getPackageManager().getLaunchIntentForPackage(BuildConfig.POKEMON_GO_ID)) .doOnNext(intent -> { if (intent == null) { Snackbar.make(mFab, R.string.error_pokemon_missing, Snackbar.LENGTH_LONG).show(); } }) .filter(intent -> intent != null) .subscribe(this::startActivity); checkIfFirstTime(); } private void setupToolbar() { setSupportActionBar(mToolbar); } private void setupPreferences() { PreferenceManager.setDefaultValues(this, preferences, false); getSupportFragmentManager() .beginTransaction()
.replace(R.id.content, new SettingsFragment())
igoticecream/Snorlax
app/src/main/java/com/icecream/snorlax/module/feature/mitm/Mitm.java
// Path: app/src/main/java/com/icecream/snorlax/module/Log.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Log { // // public static void d(String format, Object... args) { // XposedBridge.log(String.format(Locale.US, format, args)); // } // // public static void e(Throwable throwable) { // XposedBridge.log(throwable); // } // // public static void e(Throwable throwable, String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args), throwable)); // } // // public static void e(String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args))); // } // // private Log() { // throw new AssertionError("No instances"); // } // } // // Path: app/src/main/java/com/icecream/snorlax/module/feature/Feature.java // public interface Feature { // // void subscribe() throws Exception; // // void unsubscribe() throws Exception; // }
import java.io.InputStream; import java.io.OutputStream; import javax.inject.Inject; import javax.inject.Singleton; import android.os.Build; import com.icecream.snorlax.module.Log; import com.icecream.snorlax.module.feature.Feature; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers;
/* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module.feature.mitm; @Singleton public final class Mitm implements Feature { private final ClassLoader mClassLoader; private final MitmInputStreamFactory mMitmInputStreamFactory; private final MitmOutputStreamFactory mMitmOutputStreamFactory; private XC_MethodHook.Unhook mUnhookInputStream; private XC_MethodHook.Unhook mUnhookOutputStream; @Inject Mitm(ClassLoader classLoader, MitmInputStreamFactory mitmInputStreamFactory, MitmOutputStreamFactory mitmOutputStreamFactory) { mClassLoader = classLoader; mMitmInputStreamFactory = mitmInputStreamFactory; mMitmOutputStreamFactory = mitmOutputStreamFactory; } @Override public void subscribe() throws Exception { final Class<?> http = XposedHelpers.findClass(getHttpUrlConnection(), mClassLoader); if (http == null) {
// Path: app/src/main/java/com/icecream/snorlax/module/Log.java // @SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) // public final class Log { // // public static void d(String format, Object... args) { // XposedBridge.log(String.format(Locale.US, format, args)); // } // // public static void e(Throwable throwable) { // XposedBridge.log(throwable); // } // // public static void e(Throwable throwable, String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args), throwable)); // } // // public static void e(String format, Object... args) { // XposedBridge.log(new Exception(String.format(Locale.US, format, args))); // } // // private Log() { // throw new AssertionError("No instances"); // } // } // // Path: app/src/main/java/com/icecream/snorlax/module/feature/Feature.java // public interface Feature { // // void subscribe() throws Exception; // // void unsubscribe() throws Exception; // } // Path: app/src/main/java/com/icecream/snorlax/module/feature/mitm/Mitm.java import java.io.InputStream; import java.io.OutputStream; import javax.inject.Inject; import javax.inject.Singleton; import android.os.Build; import com.icecream.snorlax.module.Log; import com.icecream.snorlax.module.feature.Feature; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; /* * Copyright (c) 2016. Pedro Diaz <[email protected]> * * 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.icecream.snorlax.module.feature.mitm; @Singleton public final class Mitm implements Feature { private final ClassLoader mClassLoader; private final MitmInputStreamFactory mMitmInputStreamFactory; private final MitmOutputStreamFactory mMitmOutputStreamFactory; private XC_MethodHook.Unhook mUnhookInputStream; private XC_MethodHook.Unhook mUnhookOutputStream; @Inject Mitm(ClassLoader classLoader, MitmInputStreamFactory mitmInputStreamFactory, MitmOutputStreamFactory mitmOutputStreamFactory) { mClassLoader = classLoader; mMitmInputStreamFactory = mitmInputStreamFactory; mMitmOutputStreamFactory = mitmOutputStreamFactory; } @Override public void subscribe() throws Exception { final Class<?> http = XposedHelpers.findClass(getHttpUrlConnection(), mClassLoader); if (http == null) {
Log.e("Cannot find HttpURLConnection implementation class");
valerio-bozzolan/bus-torino
src/it/reyboz/bustorino/backend/Palina.java
// Path: src/it/reyboz/bustorino/util/LinesNameSorter.java // public class LinesNameSorter implements Comparator<String> { // @Override // public int compare(String name1, String name2) { // // if(name1.length()>name2.length()) return 1; // if(name1.length()==name2.length()) { // try{ // int num1 = Integer.parseInt(name1.trim()); // int num2 = Integer.parseInt(name2.trim()); // return num1-num2; // } catch (NumberFormatException ex){ // //Log.d("BUSTO Compare lines","Cannot compare lines "+name1+" and "+name2); // return name1.compareTo(name2); // } // } // return -1; // // } // }
import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Comparator; import java.util.List; import it.reyboz.bustorino.util.LinesNameSorter;
/** * Adds a route to the timetable. * * @param routeID name * @param type bus, underground, railway, ... * @param destinazione end of line\terminus (underground stations have the same ID for both directions) * @return array index for this route */ public int addRoute(String routeID, String destinazione, Route.Type type) { return addRoute(new Route(routeID, destinazione, type, new ArrayList<>(6))); } public int addRoute(Route r){ this.routes.add(r); routesModified = true; buildRoutesString(); return this.routes.size()-1; // last inserted element and pray that direct access to ArrayList elements really is direct } public void setRoutes(List<Route> routeList){ routes = new ArrayList<>(routeList); } @Nullable @Override protected String buildRoutesString() { // no routes => no string if(routes == null || routes.size() == 0) { return ""; } final StringBuilder sb = new StringBuilder();
// Path: src/it/reyboz/bustorino/util/LinesNameSorter.java // public class LinesNameSorter implements Comparator<String> { // @Override // public int compare(String name1, String name2) { // // if(name1.length()>name2.length()) return 1; // if(name1.length()==name2.length()) { // try{ // int num1 = Integer.parseInt(name1.trim()); // int num2 = Integer.parseInt(name2.trim()); // return num1-num2; // } catch (NumberFormatException ex){ // //Log.d("BUSTO Compare lines","Cannot compare lines "+name1+" and "+name2); // return name1.compareTo(name2); // } // } // return -1; // // } // } // Path: src/it/reyboz/bustorino/backend/Palina.java import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Comparator; import java.util.List; import it.reyboz.bustorino.util.LinesNameSorter; /** * Adds a route to the timetable. * * @param routeID name * @param type bus, underground, railway, ... * @param destinazione end of line\terminus (underground stations have the same ID for both directions) * @return array index for this route */ public int addRoute(String routeID, String destinazione, Route.Type type) { return addRoute(new Route(routeID, destinazione, type, new ArrayList<>(6))); } public int addRoute(Route r){ this.routes.add(r); routesModified = true; buildRoutesString(); return this.routes.size()-1; // last inserted element and pray that direct access to ArrayList elements really is direct } public void setRoutes(List<Route> routeList){ routes = new ArrayList<>(routeList); } @Nullable @Override protected String buildRoutesString() { // no routes => no string if(routes == null || routes.size() == 0) { return ""; } final StringBuilder sb = new StringBuilder();
final LinesNameSorter nameSorter = new LinesNameSorter();
valerio-bozzolan/bus-torino
src/it/reyboz/bustorino/backend/FiveTAPIFetcher.java
// Path: src/it/reyboz/bustorino/data/GTTInfoInject.java // public abstract class GTTInfoInject { // // public static String findIDWhenMissingByName(String stopName){ // String stringSwitch = stopName.toUpperCase(Locale.ROOT).trim(); // //if (stringSwitch.contains("METRO")){ // String finalID; // switch (stringSwitch){ // case "METRO FERMI": // finalID="8210"; // break; // case "METRO PARADISO": // finalID="8211"; // break; // case "METRO MARCHE": // finalID="8212"; // break; // case "METRO MASSAUA": // finalID="8213"; // break; // case "METRO POZZO STRADA": // finalID="8214"; // break; // case "METRO MONTE GRAPPA": // finalID="8215"; // break; // case "METRO RIVOLI": // finalID="8216"; // break; // case "METRO RACCONIGI": // finalID="8217"; // break; // case "METRO BERNINI": // finalID="8218"; // break; // case "METRO PRINCIPI ACAJA": // finalID="8219"; // break; // case "METRO XVIII DICEMBRE": // finalID="8220"; // break; // case "METRO PORTA SUSA": // finalID="8221"; // break; // case "METRO VINZAGLIO": // finalID="8222"; // break; // case "METRO RE UMBERTO": // finalID="8223"; // break; // case "METRO PORTA NUOVA": // finalID="8224"; // break; // case "METRO MARCONI": // finalID="8225"; // break; // case "METRO NIZZA": // finalID="8226"; // break; // case "METRO DANTE": // finalID="8227"; // break; // case "METRO CARDUCCI": // finalID="8228"; // break; // case "METRO SPEZIA": // finalID="8229"; // break; // case "METRO LINGOTTO": // finalID="8230"; // break; // case "METRO ITALIA 61": // case "METRO ITALIA61": // finalID="8231"; // break; // case "METRO BENGASI": // finalID="8232"; // break; // default: // finalID=""; // } // return finalID; // } // }
import java.util.concurrent.atomic.AtomicReference; import androidx.annotation.Nullable; import android.util.Log; import it.reyboz.bustorino.data.GTTInfoInject; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; import java.util.*;
if(location.trim().equals("_")) location = null; String placeName = currentStop.getString("placeName"); if(placeName.trim().equals("_")) placeName = null; String[] lines = currentStop.getString("lines").split(","); for(int l = 0; l<lines.length;l++){ lines[l] = FiveTNormalizer.routeDisplayToInternal(lines[l]); } Route.Type t; switch (currentStop.getString("type")){ case "BUS": t = Route.Type.BUS; break; case "METRO": t = Route.Type.METRO; break; case "TRENO": t = Route.Type.RAILWAY; break; default: t = Route.Type.UNKNOWN; } String stopName = currentStop.getString("name"); String stopID; if(stopName.toLowerCase().contains("metro")) t= Route.Type.METRO; try { stopID = currentStop.getString("id"); } catch (JSONException exc){ // we don't have the ID //check if we have it already as hardcoded
// Path: src/it/reyboz/bustorino/data/GTTInfoInject.java // public abstract class GTTInfoInject { // // public static String findIDWhenMissingByName(String stopName){ // String stringSwitch = stopName.toUpperCase(Locale.ROOT).trim(); // //if (stringSwitch.contains("METRO")){ // String finalID; // switch (stringSwitch){ // case "METRO FERMI": // finalID="8210"; // break; // case "METRO PARADISO": // finalID="8211"; // break; // case "METRO MARCHE": // finalID="8212"; // break; // case "METRO MASSAUA": // finalID="8213"; // break; // case "METRO POZZO STRADA": // finalID="8214"; // break; // case "METRO MONTE GRAPPA": // finalID="8215"; // break; // case "METRO RIVOLI": // finalID="8216"; // break; // case "METRO RACCONIGI": // finalID="8217"; // break; // case "METRO BERNINI": // finalID="8218"; // break; // case "METRO PRINCIPI ACAJA": // finalID="8219"; // break; // case "METRO XVIII DICEMBRE": // finalID="8220"; // break; // case "METRO PORTA SUSA": // finalID="8221"; // break; // case "METRO VINZAGLIO": // finalID="8222"; // break; // case "METRO RE UMBERTO": // finalID="8223"; // break; // case "METRO PORTA NUOVA": // finalID="8224"; // break; // case "METRO MARCONI": // finalID="8225"; // break; // case "METRO NIZZA": // finalID="8226"; // break; // case "METRO DANTE": // finalID="8227"; // break; // case "METRO CARDUCCI": // finalID="8228"; // break; // case "METRO SPEZIA": // finalID="8229"; // break; // case "METRO LINGOTTO": // finalID="8230"; // break; // case "METRO ITALIA 61": // case "METRO ITALIA61": // finalID="8231"; // break; // case "METRO BENGASI": // finalID="8232"; // break; // default: // finalID=""; // } // return finalID; // } // } // Path: src/it/reyboz/bustorino/backend/FiveTAPIFetcher.java import java.util.concurrent.atomic.AtomicReference; import androidx.annotation.Nullable; import android.util.Log; import it.reyboz.bustorino.data.GTTInfoInject; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; import java.util.*; if(location.trim().equals("_")) location = null; String placeName = currentStop.getString("placeName"); if(placeName.trim().equals("_")) placeName = null; String[] lines = currentStop.getString("lines").split(","); for(int l = 0; l<lines.length;l++){ lines[l] = FiveTNormalizer.routeDisplayToInternal(lines[l]); } Route.Type t; switch (currentStop.getString("type")){ case "BUS": t = Route.Type.BUS; break; case "METRO": t = Route.Type.METRO; break; case "TRENO": t = Route.Type.RAILWAY; break; default: t = Route.Type.UNKNOWN; } String stopName = currentStop.getString("name"); String stopID; if(stopName.toLowerCase().contains("metro")) t= Route.Type.METRO; try { stopID = currentStop.getString("id"); } catch (JSONException exc){ // we don't have the ID //check if we have it already as hardcoded
stopID = GTTInfoInject.findIDWhenMissingByName(stopName);
valerio-bozzolan/bus-torino
src/it/reyboz/bustorino/data/DBUpdateWorker.java
// Path: src/it/reyboz/bustorino/backend/Fetcher.java // public interface Fetcher { // /** // * Status codes.<br> // *<br> // * OK: got a response, parsed correctly, obtained some data<br> // * CLIENT_OFFLINE: can't connect to the internet<br> // * SERVER_ERROR: the server replied anything other than HTTP 200, basically<br> // * for 404 special constant (see @FiveTAPIFetcher) // * PARSER_ERROR: the server replied something that can't be parsed, probably it's not the data we're looking for (e.g. "PHP: Fatal Error")<br> // * EMPTY_RESULT_SET: the response is valid and indicates there are no stops\routes\"passaggi"\results for your query<br> // * NOT_FOUND: response is valid, no parsing errors, but the desired stops/routes wasn't found // * QUERY_TOO_SHORT: input more characters and retry. // */ // enum Result { // OK, CLIENT_OFFLINE, SERVER_ERROR, SETUP_ERROR,PARSER_ERROR, EMPTY_RESULT_SET, QUERY_TOO_SHORT, SERVER_ERROR_404, // CONNECTION_ERROR, NOT_FOUND // } // } // // Path: src/it/reyboz/bustorino/backend/Notifications.java // public class Notifications { // public static final String DEFAULT_CHANNEL_ID ="Default"; // // public static void createDefaultNotificationChannel(Context context) { // // Create the NotificationChannel, but only on API 26+ because // // the NotificationChannel class is new and not in the support library // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // CharSequence name = context.getString(R.string.default_notification_channel); // String description = context.getString(R.string.default_notification_channel_description); // int importance = NotificationManager.IMPORTANCE_DEFAULT; // NotificationChannel channel = new NotificationChannel(DEFAULT_CHANNEL_ID, name, importance); // channel.setDescription(description); // // Register the channel with the system; you can't change the importance // // or other notification behaviors after this // NotificationManager notificationManager = context.getSystemService(NotificationManager.class); // notificationManager.createNotificationChannel(channel); // } // } // // /** // * Register a notification channel on Android Oreo and above // * @param con a Context // * @param name channel name // * @param description channel description // * @param importance channel importance (from NotificationManager) // * @param ID channel ID // */ // public static void createNotificationChannel(Context con, String name, String description, int importance, String ID){ // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // NotificationChannel channel = new NotificationChannel(ID, name, importance); // channel.setDescription(description); // // Register the channel with the system; you can't change the importance // // or other notification behaviors after this // NotificationManager notificationManager = con.getSystemService(NotificationManager.class); // notificationManager.createNotificationChannel(channel); // } // } // }
import java.util.concurrent.atomic.AtomicReference; import static android.content.Context.MODE_PRIVATE; import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; import android.util.Log; import androidx.annotation.NonNull; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; import androidx.work.*; import it.reyboz.bustorino.R; import it.reyboz.bustorino.backend.Fetcher; import it.reyboz.bustorino.backend.Notifications; import java.util.concurrent.TimeUnit;
/* BusTO - Data components Copyright (C) 2021 Fabio Mazza This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ package it.reyboz.bustorino.data; public class DBUpdateWorker extends Worker{ public static final String ERROR_CODE_KEY ="Error_Code"; public static final String ERROR_REASON_KEY = "ERROR_REASON"; public static final int ERROR_FETCHING_VERSION = 4; public static final int ERROR_DOWNLOADING_STOPS = 5; public static final int ERROR_DOWNLOADING_LINES = 6; public static final String SUCCESS_REASON_KEY = "SUCCESS_REASON"; public static final int SUCCESS_NO_ACTION_NEEDED = 9; public static final int SUCCESS_UPDATE_DONE = 1; private final int notifi_ID=62341; public static final String FORCED_UPDATE = "FORCED-UPDATE"; public static final String DEBUG_TAG = "Busto-UpdateWorker"; private static final long UPDATE_MIN_DELAY= 3*7*24*3600; //3 weeks public DBUpdateWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) { super(context, workerParams); } @SuppressLint("RestrictedApi") @NonNull @Override public Result doWork() { //register Notification channel final Context con = getApplicationContext();
// Path: src/it/reyboz/bustorino/backend/Fetcher.java // public interface Fetcher { // /** // * Status codes.<br> // *<br> // * OK: got a response, parsed correctly, obtained some data<br> // * CLIENT_OFFLINE: can't connect to the internet<br> // * SERVER_ERROR: the server replied anything other than HTTP 200, basically<br> // * for 404 special constant (see @FiveTAPIFetcher) // * PARSER_ERROR: the server replied something that can't be parsed, probably it's not the data we're looking for (e.g. "PHP: Fatal Error")<br> // * EMPTY_RESULT_SET: the response is valid and indicates there are no stops\routes\"passaggi"\results for your query<br> // * NOT_FOUND: response is valid, no parsing errors, but the desired stops/routes wasn't found // * QUERY_TOO_SHORT: input more characters and retry. // */ // enum Result { // OK, CLIENT_OFFLINE, SERVER_ERROR, SETUP_ERROR,PARSER_ERROR, EMPTY_RESULT_SET, QUERY_TOO_SHORT, SERVER_ERROR_404, // CONNECTION_ERROR, NOT_FOUND // } // } // // Path: src/it/reyboz/bustorino/backend/Notifications.java // public class Notifications { // public static final String DEFAULT_CHANNEL_ID ="Default"; // // public static void createDefaultNotificationChannel(Context context) { // // Create the NotificationChannel, but only on API 26+ because // // the NotificationChannel class is new and not in the support library // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // CharSequence name = context.getString(R.string.default_notification_channel); // String description = context.getString(R.string.default_notification_channel_description); // int importance = NotificationManager.IMPORTANCE_DEFAULT; // NotificationChannel channel = new NotificationChannel(DEFAULT_CHANNEL_ID, name, importance); // channel.setDescription(description); // // Register the channel with the system; you can't change the importance // // or other notification behaviors after this // NotificationManager notificationManager = context.getSystemService(NotificationManager.class); // notificationManager.createNotificationChannel(channel); // } // } // // /** // * Register a notification channel on Android Oreo and above // * @param con a Context // * @param name channel name // * @param description channel description // * @param importance channel importance (from NotificationManager) // * @param ID channel ID // */ // public static void createNotificationChannel(Context con, String name, String description, int importance, String ID){ // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // NotificationChannel channel = new NotificationChannel(ID, name, importance); // channel.setDescription(description); // // Register the channel with the system; you can't change the importance // // or other notification behaviors after this // NotificationManager notificationManager = con.getSystemService(NotificationManager.class); // notificationManager.createNotificationChannel(channel); // } // } // } // Path: src/it/reyboz/bustorino/data/DBUpdateWorker.java import java.util.concurrent.atomic.AtomicReference; import static android.content.Context.MODE_PRIVATE; import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; import android.util.Log; import androidx.annotation.NonNull; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; import androidx.work.*; import it.reyboz.bustorino.R; import it.reyboz.bustorino.backend.Fetcher; import it.reyboz.bustorino.backend.Notifications; import java.util.concurrent.TimeUnit; /* BusTO - Data components Copyright (C) 2021 Fabio Mazza This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ package it.reyboz.bustorino.data; public class DBUpdateWorker extends Worker{ public static final String ERROR_CODE_KEY ="Error_Code"; public static final String ERROR_REASON_KEY = "ERROR_REASON"; public static final int ERROR_FETCHING_VERSION = 4; public static final int ERROR_DOWNLOADING_STOPS = 5; public static final int ERROR_DOWNLOADING_LINES = 6; public static final String SUCCESS_REASON_KEY = "SUCCESS_REASON"; public static final int SUCCESS_NO_ACTION_NEEDED = 9; public static final int SUCCESS_UPDATE_DONE = 1; private final int notifi_ID=62341; public static final String FORCED_UPDATE = "FORCED-UPDATE"; public static final String DEBUG_TAG = "Busto-UpdateWorker"; private static final long UPDATE_MIN_DELAY= 3*7*24*3600; //3 weeks public DBUpdateWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) { super(context, workerParams); } @SuppressLint("RestrictedApi") @NonNull @Override public Result doWork() { //register Notification channel final Context con = getApplicationContext();
Notifications.createDefaultNotificationChannel(con);
valerio-bozzolan/bus-torino
src/it/reyboz/bustorino/data/DBUpdateWorker.java
// Path: src/it/reyboz/bustorino/backend/Fetcher.java // public interface Fetcher { // /** // * Status codes.<br> // *<br> // * OK: got a response, parsed correctly, obtained some data<br> // * CLIENT_OFFLINE: can't connect to the internet<br> // * SERVER_ERROR: the server replied anything other than HTTP 200, basically<br> // * for 404 special constant (see @FiveTAPIFetcher) // * PARSER_ERROR: the server replied something that can't be parsed, probably it's not the data we're looking for (e.g. "PHP: Fatal Error")<br> // * EMPTY_RESULT_SET: the response is valid and indicates there are no stops\routes\"passaggi"\results for your query<br> // * NOT_FOUND: response is valid, no parsing errors, but the desired stops/routes wasn't found // * QUERY_TOO_SHORT: input more characters and retry. // */ // enum Result { // OK, CLIENT_OFFLINE, SERVER_ERROR, SETUP_ERROR,PARSER_ERROR, EMPTY_RESULT_SET, QUERY_TOO_SHORT, SERVER_ERROR_404, // CONNECTION_ERROR, NOT_FOUND // } // } // // Path: src/it/reyboz/bustorino/backend/Notifications.java // public class Notifications { // public static final String DEFAULT_CHANNEL_ID ="Default"; // // public static void createDefaultNotificationChannel(Context context) { // // Create the NotificationChannel, but only on API 26+ because // // the NotificationChannel class is new and not in the support library // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // CharSequence name = context.getString(R.string.default_notification_channel); // String description = context.getString(R.string.default_notification_channel_description); // int importance = NotificationManager.IMPORTANCE_DEFAULT; // NotificationChannel channel = new NotificationChannel(DEFAULT_CHANNEL_ID, name, importance); // channel.setDescription(description); // // Register the channel with the system; you can't change the importance // // or other notification behaviors after this // NotificationManager notificationManager = context.getSystemService(NotificationManager.class); // notificationManager.createNotificationChannel(channel); // } // } // // /** // * Register a notification channel on Android Oreo and above // * @param con a Context // * @param name channel name // * @param description channel description // * @param importance channel importance (from NotificationManager) // * @param ID channel ID // */ // public static void createNotificationChannel(Context con, String name, String description, int importance, String ID){ // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // NotificationChannel channel = new NotificationChannel(ID, name, importance); // channel.setDescription(description); // // Register the channel with the system; you can't change the importance // // or other notification behaviors after this // NotificationManager notificationManager = con.getSystemService(NotificationManager.class); // notificationManager.createNotificationChannel(channel); // } // } // }
import java.util.concurrent.atomic.AtomicReference; import static android.content.Context.MODE_PRIVATE; import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; import android.util.Log; import androidx.annotation.NonNull; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; import androidx.work.*; import it.reyboz.bustorino.R; import it.reyboz.bustorino.backend.Fetcher; import it.reyboz.bustorino.backend.Notifications; import java.util.concurrent.TimeUnit;
final int new_DB_version = DatabaseUpdate.getNewVersion(); final boolean isUpdateCompulsory = getInputData().getBoolean(FORCED_UPDATE,false); final long lastDBUpdateTime = shPr.getLong(DatabaseUpdate.DB_LAST_UPDATE_KEY, 0); long currentTime = System.currentTimeMillis()/1000; final int notificationID = showNotification(); Log.d(DEBUG_TAG, "Have previous version: "+current_DB_version +" and new version "+new_DB_version); Log.d(DEBUG_TAG, "Update compulsory: "+isUpdateCompulsory); /* SKIP CHECK (Reason: The Old API might fail at any moment) if (new_DB_version < 0){ //there has been an error final Data out = new Data.Builder().putInt(ERROR_REASON_KEY, ERROR_FETCHING_VERSION) .putInt(ERROR_CODE_KEY,new_DB_version).build(); cancelNotification(notificationID); return ListenableWorker.Result.failure(out); } */ //we got a good version if (!(current_DB_version < new_DB_version || currentTime > lastDBUpdateTime + UPDATE_MIN_DELAY ) && !isUpdateCompulsory) { //don't need to update cancelNotification(notificationID); return ListenableWorker.Result.success(new Data.Builder(). putInt(SUCCESS_REASON_KEY, SUCCESS_NO_ACTION_NEEDED).build()); } //start the real update
// Path: src/it/reyboz/bustorino/backend/Fetcher.java // public interface Fetcher { // /** // * Status codes.<br> // *<br> // * OK: got a response, parsed correctly, obtained some data<br> // * CLIENT_OFFLINE: can't connect to the internet<br> // * SERVER_ERROR: the server replied anything other than HTTP 200, basically<br> // * for 404 special constant (see @FiveTAPIFetcher) // * PARSER_ERROR: the server replied something that can't be parsed, probably it's not the data we're looking for (e.g. "PHP: Fatal Error")<br> // * EMPTY_RESULT_SET: the response is valid and indicates there are no stops\routes\"passaggi"\results for your query<br> // * NOT_FOUND: response is valid, no parsing errors, but the desired stops/routes wasn't found // * QUERY_TOO_SHORT: input more characters and retry. // */ // enum Result { // OK, CLIENT_OFFLINE, SERVER_ERROR, SETUP_ERROR,PARSER_ERROR, EMPTY_RESULT_SET, QUERY_TOO_SHORT, SERVER_ERROR_404, // CONNECTION_ERROR, NOT_FOUND // } // } // // Path: src/it/reyboz/bustorino/backend/Notifications.java // public class Notifications { // public static final String DEFAULT_CHANNEL_ID ="Default"; // // public static void createDefaultNotificationChannel(Context context) { // // Create the NotificationChannel, but only on API 26+ because // // the NotificationChannel class is new and not in the support library // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // CharSequence name = context.getString(R.string.default_notification_channel); // String description = context.getString(R.string.default_notification_channel_description); // int importance = NotificationManager.IMPORTANCE_DEFAULT; // NotificationChannel channel = new NotificationChannel(DEFAULT_CHANNEL_ID, name, importance); // channel.setDescription(description); // // Register the channel with the system; you can't change the importance // // or other notification behaviors after this // NotificationManager notificationManager = context.getSystemService(NotificationManager.class); // notificationManager.createNotificationChannel(channel); // } // } // // /** // * Register a notification channel on Android Oreo and above // * @param con a Context // * @param name channel name // * @param description channel description // * @param importance channel importance (from NotificationManager) // * @param ID channel ID // */ // public static void createNotificationChannel(Context con, String name, String description, int importance, String ID){ // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // NotificationChannel channel = new NotificationChannel(ID, name, importance); // channel.setDescription(description); // // Register the channel with the system; you can't change the importance // // or other notification behaviors after this // NotificationManager notificationManager = con.getSystemService(NotificationManager.class); // notificationManager.createNotificationChannel(channel); // } // } // } // Path: src/it/reyboz/bustorino/data/DBUpdateWorker.java import java.util.concurrent.atomic.AtomicReference; import static android.content.Context.MODE_PRIVATE; import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; import android.util.Log; import androidx.annotation.NonNull; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; import androidx.work.*; import it.reyboz.bustorino.R; import it.reyboz.bustorino.backend.Fetcher; import it.reyboz.bustorino.backend.Notifications; import java.util.concurrent.TimeUnit; final int new_DB_version = DatabaseUpdate.getNewVersion(); final boolean isUpdateCompulsory = getInputData().getBoolean(FORCED_UPDATE,false); final long lastDBUpdateTime = shPr.getLong(DatabaseUpdate.DB_LAST_UPDATE_KEY, 0); long currentTime = System.currentTimeMillis()/1000; final int notificationID = showNotification(); Log.d(DEBUG_TAG, "Have previous version: "+current_DB_version +" and new version "+new_DB_version); Log.d(DEBUG_TAG, "Update compulsory: "+isUpdateCompulsory); /* SKIP CHECK (Reason: The Old API might fail at any moment) if (new_DB_version < 0){ //there has been an error final Data out = new Data.Builder().putInt(ERROR_REASON_KEY, ERROR_FETCHING_VERSION) .putInt(ERROR_CODE_KEY,new_DB_version).build(); cancelNotification(notificationID); return ListenableWorker.Result.failure(out); } */ //we got a good version if (!(current_DB_version < new_DB_version || currentTime > lastDBUpdateTime + UPDATE_MIN_DELAY ) && !isUpdateCompulsory) { //don't need to update cancelNotification(notificationID); return ListenableWorker.Result.success(new Data.Builder(). putInt(SUCCESS_REASON_KEY, SUCCESS_NO_ACTION_NEEDED).build()); } //start the real update
AtomicReference<Fetcher.Result> resultAtomicReference = new AtomicReference<>();
valerio-bozzolan/bus-torino
src/it/reyboz/bustorino/middleware/AppLocationManager.java
// Path: src/it/reyboz/bustorino/util/LocationCriteria.java // public class LocationCriteria extends Criteria { // private final float minAccuracy; // private final int timeInterval; // // /** // * Constructor // * @param minAccuracy in meters // * @param timeInterval in milliseconds // */ // public LocationCriteria(float minAccuracy,int timeInterval){ // this.minAccuracy = minAccuracy; // this.timeInterval = timeInterval; // } // // public float getMinAccuracy() { // return minAccuracy; // } // // // public int getTimeInterval() { // return timeInterval; // } // // } // // Path: src/it/reyboz/bustorino/util/Permissions.java // public class Permissions { // final static public String DEBUG_TAG = "BusTO -Permissions"; // // final static public int PERMISSION_REQUEST_POSITION = 33; // final static public String LOCATION_PERMISSION_GIVEN = "loc_permission"; // final static public int STORAGE_PERMISSION_REQ = 291; // // final static public int PERMISSION_OK = 0; // final static public int PERMISSION_ASKING = 11; // final static public int PERMISSION_NEG_CANNOT_ASK = -3; // // final static public String[] LOCATION_PERMISSIONS={Manifest.permission.ACCESS_COARSE_LOCATION, // Manifest.permission.ACCESS_FINE_LOCATION}; // // public static boolean anyLocationProviderMatchesCriteria(LocationManager mng, Criteria cr, boolean enabled) { // List<String> providers = mng.getProviders(cr, enabled); // Log.d(DEBUG_TAG, "Getting enabled location providers: "); // for (String s : providers) { // Log.d(DEBUG_TAG, "Provider " + s); // } // return providers.size() > 0; // } // public static boolean isPermissionGranted(Context con,String permission){ // return ContextCompat.checkSelfPermission(con, permission) == PackageManager.PERMISSION_GRANTED; // } // // public static boolean locationPermissionGranted(Context con){ // return isPermissionGranted(con, Manifest.permission.ACCESS_FINE_LOCATION) && // isPermissionGranted(con, Manifest.permission.ACCESS_COARSE_LOCATION); // } // // public static void assertLocationPermissions(Context con, Activity activity) { // if(!isPermissionGranted(con, Manifest.permission.ACCESS_FINE_LOCATION) || // !isPermissionGranted(con,Manifest.permission.ACCESS_COARSE_LOCATION)){ // ActivityCompat.requestPermissions(activity,new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSION_REQUEST_POSITION); // } // } // }
import it.reyboz.bustorino.util.LocationCriteria; import it.reyboz.bustorino.util.Permissions; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.ListIterator; import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; import android.location.Criteria; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.location.LocationProvider; import android.os.Bundle; import android.util.Log; import android.widget.Toast; import androidx.core.content.ContextCompat;
locMan.removeUpdates(this); } else { requestGPSPositionUpdates(); } } private void sendLocationStatusToAll(int status){ ListIterator<WeakReference<LocationRequester>> iter = requestersRef.listIterator(); while(iter.hasNext()){ final LocationRequester cReq = iter.next().get(); if(cReq==null) iter.remove(); else cReq.onLocationStatusChanged(status); } } public boolean isRequesterRegistered(LocationRequester requester){ for(WeakReference<LocationRequester> regRef: requestersRef){ if(regRef.get()!=null && regRef.get() ==requester) return true; } return false; } @Override public void onLocationChanged(Location location) { Log.d(DEBUG_TAG,"found location:\nlat: "+location.getLatitude()+" lon: "+location.getLongitude()+"\naccuracy: "+location.getAccuracy()); ListIterator<WeakReference<LocationRequester>> iter = requestersRef.listIterator(); int new_min_interval = Integer.MAX_VALUE; while(iter.hasNext()){ final LocationRequester requester = iter.next().get(); if(requester==null) iter.remove(); else{ final long timeNow = System.currentTimeMillis();
// Path: src/it/reyboz/bustorino/util/LocationCriteria.java // public class LocationCriteria extends Criteria { // private final float minAccuracy; // private final int timeInterval; // // /** // * Constructor // * @param minAccuracy in meters // * @param timeInterval in milliseconds // */ // public LocationCriteria(float minAccuracy,int timeInterval){ // this.minAccuracy = minAccuracy; // this.timeInterval = timeInterval; // } // // public float getMinAccuracy() { // return minAccuracy; // } // // // public int getTimeInterval() { // return timeInterval; // } // // } // // Path: src/it/reyboz/bustorino/util/Permissions.java // public class Permissions { // final static public String DEBUG_TAG = "BusTO -Permissions"; // // final static public int PERMISSION_REQUEST_POSITION = 33; // final static public String LOCATION_PERMISSION_GIVEN = "loc_permission"; // final static public int STORAGE_PERMISSION_REQ = 291; // // final static public int PERMISSION_OK = 0; // final static public int PERMISSION_ASKING = 11; // final static public int PERMISSION_NEG_CANNOT_ASK = -3; // // final static public String[] LOCATION_PERMISSIONS={Manifest.permission.ACCESS_COARSE_LOCATION, // Manifest.permission.ACCESS_FINE_LOCATION}; // // public static boolean anyLocationProviderMatchesCriteria(LocationManager mng, Criteria cr, boolean enabled) { // List<String> providers = mng.getProviders(cr, enabled); // Log.d(DEBUG_TAG, "Getting enabled location providers: "); // for (String s : providers) { // Log.d(DEBUG_TAG, "Provider " + s); // } // return providers.size() > 0; // } // public static boolean isPermissionGranted(Context con,String permission){ // return ContextCompat.checkSelfPermission(con, permission) == PackageManager.PERMISSION_GRANTED; // } // // public static boolean locationPermissionGranted(Context con){ // return isPermissionGranted(con, Manifest.permission.ACCESS_FINE_LOCATION) && // isPermissionGranted(con, Manifest.permission.ACCESS_COARSE_LOCATION); // } // // public static void assertLocationPermissions(Context con, Activity activity) { // if(!isPermissionGranted(con, Manifest.permission.ACCESS_FINE_LOCATION) || // !isPermissionGranted(con,Manifest.permission.ACCESS_COARSE_LOCATION)){ // ActivityCompat.requestPermissions(activity,new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSION_REQUEST_POSITION); // } // } // } // Path: src/it/reyboz/bustorino/middleware/AppLocationManager.java import it.reyboz.bustorino.util.LocationCriteria; import it.reyboz.bustorino.util.Permissions; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.ListIterator; import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; import android.location.Criteria; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.location.LocationProvider; import android.os.Bundle; import android.util.Log; import android.widget.Toast; import androidx.core.content.ContextCompat; locMan.removeUpdates(this); } else { requestGPSPositionUpdates(); } } private void sendLocationStatusToAll(int status){ ListIterator<WeakReference<LocationRequester>> iter = requestersRef.listIterator(); while(iter.hasNext()){ final LocationRequester cReq = iter.next().get(); if(cReq==null) iter.remove(); else cReq.onLocationStatusChanged(status); } } public boolean isRequesterRegistered(LocationRequester requester){ for(WeakReference<LocationRequester> regRef: requestersRef){ if(regRef.get()!=null && regRef.get() ==requester) return true; } return false; } @Override public void onLocationChanged(Location location) { Log.d(DEBUG_TAG,"found location:\nlat: "+location.getLatitude()+" lon: "+location.getLongitude()+"\naccuracy: "+location.getAccuracy()); ListIterator<WeakReference<LocationRequester>> iter = requestersRef.listIterator(); int new_min_interval = Integer.MAX_VALUE; while(iter.hasNext()){ final LocationRequester requester = iter.next().get(); if(requester==null) iter.remove(); else{ final long timeNow = System.currentTimeMillis();
final LocationCriteria criteria = requester.getLocationCriteria();
valerio-bozzolan/bus-torino
src/it/reyboz/bustorino/middleware/AppLocationManager.java
// Path: src/it/reyboz/bustorino/util/LocationCriteria.java // public class LocationCriteria extends Criteria { // private final float minAccuracy; // private final int timeInterval; // // /** // * Constructor // * @param minAccuracy in meters // * @param timeInterval in milliseconds // */ // public LocationCriteria(float minAccuracy,int timeInterval){ // this.minAccuracy = minAccuracy; // this.timeInterval = timeInterval; // } // // public float getMinAccuracy() { // return minAccuracy; // } // // // public int getTimeInterval() { // return timeInterval; // } // // } // // Path: src/it/reyboz/bustorino/util/Permissions.java // public class Permissions { // final static public String DEBUG_TAG = "BusTO -Permissions"; // // final static public int PERMISSION_REQUEST_POSITION = 33; // final static public String LOCATION_PERMISSION_GIVEN = "loc_permission"; // final static public int STORAGE_PERMISSION_REQ = 291; // // final static public int PERMISSION_OK = 0; // final static public int PERMISSION_ASKING = 11; // final static public int PERMISSION_NEG_CANNOT_ASK = -3; // // final static public String[] LOCATION_PERMISSIONS={Manifest.permission.ACCESS_COARSE_LOCATION, // Manifest.permission.ACCESS_FINE_LOCATION}; // // public static boolean anyLocationProviderMatchesCriteria(LocationManager mng, Criteria cr, boolean enabled) { // List<String> providers = mng.getProviders(cr, enabled); // Log.d(DEBUG_TAG, "Getting enabled location providers: "); // for (String s : providers) { // Log.d(DEBUG_TAG, "Provider " + s); // } // return providers.size() > 0; // } // public static boolean isPermissionGranted(Context con,String permission){ // return ContextCompat.checkSelfPermission(con, permission) == PackageManager.PERMISSION_GRANTED; // } // // public static boolean locationPermissionGranted(Context con){ // return isPermissionGranted(con, Manifest.permission.ACCESS_FINE_LOCATION) && // isPermissionGranted(con, Manifest.permission.ACCESS_COARSE_LOCATION); // } // // public static void assertLocationPermissions(Context con, Activity activity) { // if(!isPermissionGranted(con, Manifest.permission.ACCESS_FINE_LOCATION) || // !isPermissionGranted(con,Manifest.permission.ACCESS_COARSE_LOCATION)){ // ActivityCompat.requestPermissions(activity,new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSION_REQUEST_POSITION); // } // } // }
import it.reyboz.bustorino.util.LocationCriteria; import it.reyboz.bustorino.util.Permissions; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.ListIterator; import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; import android.location.Criteria; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.location.LocationProvider; import android.os.Bundle; import android.util.Log; import android.widget.Toast; import androidx.core.content.ContextCompat;
} oldGPSLocStatus = status; } Log.d(DEBUG_TAG, "Provider status changed: "+provider+" status: "+status); } @Override public void onProviderEnabled(String provider) { cleanAndUpdateRequesters(); requestGPSPositionUpdates(); Log.d(DEBUG_TAG, "Provider: "+provider+" enabled"); for(WeakReference<LocationRequester> req: requestersRef){ if(req.get()==null) continue; req.get().onLocationProviderAvailable(); } } @Override public void onProviderDisabled(String provider) { cleanAndUpdateRequesters(); for(WeakReference<LocationRequester> req: requestersRef){ if(req.get()==null) continue; req.get().onLocationDisabled(); } //locMan.removeUpdates(this); Log.d(DEBUG_TAG, "Provider: "+provider+" disabled"); } public boolean anyLocationProviderMatchesCriteria(Criteria cr) {
// Path: src/it/reyboz/bustorino/util/LocationCriteria.java // public class LocationCriteria extends Criteria { // private final float minAccuracy; // private final int timeInterval; // // /** // * Constructor // * @param minAccuracy in meters // * @param timeInterval in milliseconds // */ // public LocationCriteria(float minAccuracy,int timeInterval){ // this.minAccuracy = minAccuracy; // this.timeInterval = timeInterval; // } // // public float getMinAccuracy() { // return minAccuracy; // } // // // public int getTimeInterval() { // return timeInterval; // } // // } // // Path: src/it/reyboz/bustorino/util/Permissions.java // public class Permissions { // final static public String DEBUG_TAG = "BusTO -Permissions"; // // final static public int PERMISSION_REQUEST_POSITION = 33; // final static public String LOCATION_PERMISSION_GIVEN = "loc_permission"; // final static public int STORAGE_PERMISSION_REQ = 291; // // final static public int PERMISSION_OK = 0; // final static public int PERMISSION_ASKING = 11; // final static public int PERMISSION_NEG_CANNOT_ASK = -3; // // final static public String[] LOCATION_PERMISSIONS={Manifest.permission.ACCESS_COARSE_LOCATION, // Manifest.permission.ACCESS_FINE_LOCATION}; // // public static boolean anyLocationProviderMatchesCriteria(LocationManager mng, Criteria cr, boolean enabled) { // List<String> providers = mng.getProviders(cr, enabled); // Log.d(DEBUG_TAG, "Getting enabled location providers: "); // for (String s : providers) { // Log.d(DEBUG_TAG, "Provider " + s); // } // return providers.size() > 0; // } // public static boolean isPermissionGranted(Context con,String permission){ // return ContextCompat.checkSelfPermission(con, permission) == PackageManager.PERMISSION_GRANTED; // } // // public static boolean locationPermissionGranted(Context con){ // return isPermissionGranted(con, Manifest.permission.ACCESS_FINE_LOCATION) && // isPermissionGranted(con, Manifest.permission.ACCESS_COARSE_LOCATION); // } // // public static void assertLocationPermissions(Context con, Activity activity) { // if(!isPermissionGranted(con, Manifest.permission.ACCESS_FINE_LOCATION) || // !isPermissionGranted(con,Manifest.permission.ACCESS_COARSE_LOCATION)){ // ActivityCompat.requestPermissions(activity,new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSION_REQUEST_POSITION); // } // } // } // Path: src/it/reyboz/bustorino/middleware/AppLocationManager.java import it.reyboz.bustorino.util.LocationCriteria; import it.reyboz.bustorino.util.Permissions; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.ListIterator; import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; import android.location.Criteria; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.location.LocationProvider; import android.os.Bundle; import android.util.Log; import android.widget.Toast; import androidx.core.content.ContextCompat; } oldGPSLocStatus = status; } Log.d(DEBUG_TAG, "Provider status changed: "+provider+" status: "+status); } @Override public void onProviderEnabled(String provider) { cleanAndUpdateRequesters(); requestGPSPositionUpdates(); Log.d(DEBUG_TAG, "Provider: "+provider+" enabled"); for(WeakReference<LocationRequester> req: requestersRef){ if(req.get()==null) continue; req.get().onLocationProviderAvailable(); } } @Override public void onProviderDisabled(String provider) { cleanAndUpdateRequesters(); for(WeakReference<LocationRequester> req: requestersRef){ if(req.get()==null) continue; req.get().onLocationDisabled(); } //locMan.removeUpdates(this); Log.d(DEBUG_TAG, "Provider: "+provider+" disabled"); } public boolean anyLocationProviderMatchesCriteria(Criteria cr) {
return Permissions.anyLocationProviderMatchesCriteria(locMan, cr, true);
valerio-bozzolan/bus-torino
src/it/reyboz/bustorino/adapters/ArrivalsStopAdapter.java
// Path: src/it/reyboz/bustorino/fragments/FragmentListenerMain.java // public interface FragmentListenerMain extends CommonFragmentListener { // // void toggleSpinner(boolean state); // // /** // * Tell activity that we need to enable/disable the refreshLayout // * @param yes or no // */ // void enableRefreshLayout(boolean yes); // } // // Path: src/it/reyboz/bustorino/util/RoutePositionSorter.java // public class RoutePositionSorter implements Comparator<Pair<Stop, Route>> { // private final Location loc; // private final double minutialmetro = 6.0/100; //v = 5km/h // private final double distancemultiplier = 2./3; // public RoutePositionSorter(Location loc) { // this.loc = loc; // } // // @Override // public int compare(Pair<Stop, Route> pair1, Pair<Stop, Route> pair2) throws NullPointerException{ // int delta = 0; // final Stop stop1 = pair1.first, stop2 = pair2.first; // double dist1 = utils.measuredistanceBetween(loc.getLatitude(),loc.getLongitude(), // stop1.getLatitude(),stop1.getLongitude()); // double dist2 = utils.measuredistanceBetween(loc.getLatitude(),loc.getLongitude(), // stop2.getLatitude(),stop2.getLongitude()); // final List<Passaggio> passaggi1 = pair1.second.passaggi, // passaggi2 = pair2.second.passaggi; // if(passaggi1.size()<=0 || passaggi2.size()<=0){ // Log.e("ArrivalsStopAdapter","Cannot compare: No arrivals in one of the stops"); // } else { // Collections.sort(passaggi1); // Collections.sort(passaggi2); // int deltaOre = passaggi1.get(0).hh-passaggi2.get(0).hh; // if(deltaOre>12) // deltaOre -= 24; // else if (deltaOre<-12) // deltaOre += 24; // delta+=deltaOre*60 + passaggi1.get(0).mm-passaggi2.get(0).mm; // } // delta += (int)((dist1 -dist2)*minutialmetro*distancemultiplier); // return delta; // } // // @Override // public boolean equals(Object obj) { // return obj instanceof RoutePositionSorter; // } // } // // Path: src/it/reyboz/bustorino/util/StopSorterByDistance.java // public class StopSorterByDistance implements Comparator<Stop> { // private final Location locToCompare; // // public StopSorterByDistance(Location locToCompare) { // this.locToCompare = locToCompare; // } // // @Override // public int compare(Stop o1, Stop o2) { // return (int) (o1.getDistanceFromLocation(locToCompare)-o2.getDistanceFromLocation(locToCompare)); // } // }
import it.reyboz.bustorino.backend.*; import it.reyboz.bustorino.fragments.FragmentListenerMain; import it.reyboz.bustorino.util.RoutePositionSorter; import it.reyboz.bustorino.util.StopSorterByDistance; import java.util.*; import android.content.Context; import android.location.Location; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.util.Pair; import androidx.recyclerview.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import it.reyboz.bustorino.R;
/* BusTO - UI components Copyright (C) 2017 Fabio Mazza This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ package it.reyboz.bustorino.adapters; public class ArrivalsStopAdapter extends RecyclerView.Adapter<ArrivalsStopAdapter.ViewHolder> { private final static int layoutRes = R.layout.arrivals_nearby_card; //private List<Stop> stops; private @Nullable Location userPosition;
// Path: src/it/reyboz/bustorino/fragments/FragmentListenerMain.java // public interface FragmentListenerMain extends CommonFragmentListener { // // void toggleSpinner(boolean state); // // /** // * Tell activity that we need to enable/disable the refreshLayout // * @param yes or no // */ // void enableRefreshLayout(boolean yes); // } // // Path: src/it/reyboz/bustorino/util/RoutePositionSorter.java // public class RoutePositionSorter implements Comparator<Pair<Stop, Route>> { // private final Location loc; // private final double minutialmetro = 6.0/100; //v = 5km/h // private final double distancemultiplier = 2./3; // public RoutePositionSorter(Location loc) { // this.loc = loc; // } // // @Override // public int compare(Pair<Stop, Route> pair1, Pair<Stop, Route> pair2) throws NullPointerException{ // int delta = 0; // final Stop stop1 = pair1.first, stop2 = pair2.first; // double dist1 = utils.measuredistanceBetween(loc.getLatitude(),loc.getLongitude(), // stop1.getLatitude(),stop1.getLongitude()); // double dist2 = utils.measuredistanceBetween(loc.getLatitude(),loc.getLongitude(), // stop2.getLatitude(),stop2.getLongitude()); // final List<Passaggio> passaggi1 = pair1.second.passaggi, // passaggi2 = pair2.second.passaggi; // if(passaggi1.size()<=0 || passaggi2.size()<=0){ // Log.e("ArrivalsStopAdapter","Cannot compare: No arrivals in one of the stops"); // } else { // Collections.sort(passaggi1); // Collections.sort(passaggi2); // int deltaOre = passaggi1.get(0).hh-passaggi2.get(0).hh; // if(deltaOre>12) // deltaOre -= 24; // else if (deltaOre<-12) // deltaOre += 24; // delta+=deltaOre*60 + passaggi1.get(0).mm-passaggi2.get(0).mm; // } // delta += (int)((dist1 -dist2)*minutialmetro*distancemultiplier); // return delta; // } // // @Override // public boolean equals(Object obj) { // return obj instanceof RoutePositionSorter; // } // } // // Path: src/it/reyboz/bustorino/util/StopSorterByDistance.java // public class StopSorterByDistance implements Comparator<Stop> { // private final Location locToCompare; // // public StopSorterByDistance(Location locToCompare) { // this.locToCompare = locToCompare; // } // // @Override // public int compare(Stop o1, Stop o2) { // return (int) (o1.getDistanceFromLocation(locToCompare)-o2.getDistanceFromLocation(locToCompare)); // } // } // Path: src/it/reyboz/bustorino/adapters/ArrivalsStopAdapter.java import it.reyboz.bustorino.backend.*; import it.reyboz.bustorino.fragments.FragmentListenerMain; import it.reyboz.bustorino.util.RoutePositionSorter; import it.reyboz.bustorino.util.StopSorterByDistance; import java.util.*; import android.content.Context; import android.location.Location; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.util.Pair; import androidx.recyclerview.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import it.reyboz.bustorino.R; /* BusTO - UI components Copyright (C) 2017 Fabio Mazza This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ package it.reyboz.bustorino.adapters; public class ArrivalsStopAdapter extends RecyclerView.Adapter<ArrivalsStopAdapter.ViewHolder> { private final static int layoutRes = R.layout.arrivals_nearby_card; //private List<Stop> stops; private @Nullable Location userPosition;
private FragmentListenerMain listener;
valerio-bozzolan/bus-torino
src/it/reyboz/bustorino/adapters/ArrivalsStopAdapter.java
// Path: src/it/reyboz/bustorino/fragments/FragmentListenerMain.java // public interface FragmentListenerMain extends CommonFragmentListener { // // void toggleSpinner(boolean state); // // /** // * Tell activity that we need to enable/disable the refreshLayout // * @param yes or no // */ // void enableRefreshLayout(boolean yes); // } // // Path: src/it/reyboz/bustorino/util/RoutePositionSorter.java // public class RoutePositionSorter implements Comparator<Pair<Stop, Route>> { // private final Location loc; // private final double minutialmetro = 6.0/100; //v = 5km/h // private final double distancemultiplier = 2./3; // public RoutePositionSorter(Location loc) { // this.loc = loc; // } // // @Override // public int compare(Pair<Stop, Route> pair1, Pair<Stop, Route> pair2) throws NullPointerException{ // int delta = 0; // final Stop stop1 = pair1.first, stop2 = pair2.first; // double dist1 = utils.measuredistanceBetween(loc.getLatitude(),loc.getLongitude(), // stop1.getLatitude(),stop1.getLongitude()); // double dist2 = utils.measuredistanceBetween(loc.getLatitude(),loc.getLongitude(), // stop2.getLatitude(),stop2.getLongitude()); // final List<Passaggio> passaggi1 = pair1.second.passaggi, // passaggi2 = pair2.second.passaggi; // if(passaggi1.size()<=0 || passaggi2.size()<=0){ // Log.e("ArrivalsStopAdapter","Cannot compare: No arrivals in one of the stops"); // } else { // Collections.sort(passaggi1); // Collections.sort(passaggi2); // int deltaOre = passaggi1.get(0).hh-passaggi2.get(0).hh; // if(deltaOre>12) // deltaOre -= 24; // else if (deltaOre<-12) // deltaOre += 24; // delta+=deltaOre*60 + passaggi1.get(0).mm-passaggi2.get(0).mm; // } // delta += (int)((dist1 -dist2)*minutialmetro*distancemultiplier); // return delta; // } // // @Override // public boolean equals(Object obj) { // return obj instanceof RoutePositionSorter; // } // } // // Path: src/it/reyboz/bustorino/util/StopSorterByDistance.java // public class StopSorterByDistance implements Comparator<Stop> { // private final Location locToCompare; // // public StopSorterByDistance(Location locToCompare) { // this.locToCompare = locToCompare; // } // // @Override // public int compare(Stop o1, Stop o2) { // return (int) (o1.getDistanceFromLocation(locToCompare)-o2.getDistanceFromLocation(locToCompare)); // } // }
import it.reyboz.bustorino.backend.*; import it.reyboz.bustorino.fragments.FragmentListenerMain; import it.reyboz.bustorino.util.RoutePositionSorter; import it.reyboz.bustorino.util.StopSorterByDistance; import java.util.*; import android.content.Context; import android.location.Location; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.util.Pair; import androidx.recyclerview.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import it.reyboz.bustorino.R;
} class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { TextView lineNameTextView; TextView lineDirectionTextView; TextView stopNameView; TextView arrivalsDescriptionTextView; TextView arrivalsTextView; TextView distancetextView; String stopID; ViewHolder(View holdView){ super(holdView); holdView.setOnClickListener(this); lineNameTextView = (TextView) holdView.findViewById(R.id.lineNameTextView); lineDirectionTextView = (TextView) holdView.findViewById(R.id.lineDirectionTextView); stopNameView = (TextView) holdView.findViewById(R.id.arrivalStopName); arrivalsTextView = (TextView) holdView.findViewById(R.id.arrivalsTimeTextView); arrivalsDescriptionTextView = (TextView) holdView.findViewById(R.id.arrivalsDescriptionTextView); distancetextView = (TextView) holdView.findViewById(R.id.arrivalsDistanceTextView); } @Override public void onClick(View v) { listener.requestArrivalsForStopID(stopID); } } public void resetRoutesPairList(List<Palina> stopList){
// Path: src/it/reyboz/bustorino/fragments/FragmentListenerMain.java // public interface FragmentListenerMain extends CommonFragmentListener { // // void toggleSpinner(boolean state); // // /** // * Tell activity that we need to enable/disable the refreshLayout // * @param yes or no // */ // void enableRefreshLayout(boolean yes); // } // // Path: src/it/reyboz/bustorino/util/RoutePositionSorter.java // public class RoutePositionSorter implements Comparator<Pair<Stop, Route>> { // private final Location loc; // private final double minutialmetro = 6.0/100; //v = 5km/h // private final double distancemultiplier = 2./3; // public RoutePositionSorter(Location loc) { // this.loc = loc; // } // // @Override // public int compare(Pair<Stop, Route> pair1, Pair<Stop, Route> pair2) throws NullPointerException{ // int delta = 0; // final Stop stop1 = pair1.first, stop2 = pair2.first; // double dist1 = utils.measuredistanceBetween(loc.getLatitude(),loc.getLongitude(), // stop1.getLatitude(),stop1.getLongitude()); // double dist2 = utils.measuredistanceBetween(loc.getLatitude(),loc.getLongitude(), // stop2.getLatitude(),stop2.getLongitude()); // final List<Passaggio> passaggi1 = pair1.second.passaggi, // passaggi2 = pair2.second.passaggi; // if(passaggi1.size()<=0 || passaggi2.size()<=0){ // Log.e("ArrivalsStopAdapter","Cannot compare: No arrivals in one of the stops"); // } else { // Collections.sort(passaggi1); // Collections.sort(passaggi2); // int deltaOre = passaggi1.get(0).hh-passaggi2.get(0).hh; // if(deltaOre>12) // deltaOre -= 24; // else if (deltaOre<-12) // deltaOre += 24; // delta+=deltaOre*60 + passaggi1.get(0).mm-passaggi2.get(0).mm; // } // delta += (int)((dist1 -dist2)*minutialmetro*distancemultiplier); // return delta; // } // // @Override // public boolean equals(Object obj) { // return obj instanceof RoutePositionSorter; // } // } // // Path: src/it/reyboz/bustorino/util/StopSorterByDistance.java // public class StopSorterByDistance implements Comparator<Stop> { // private final Location locToCompare; // // public StopSorterByDistance(Location locToCompare) { // this.locToCompare = locToCompare; // } // // @Override // public int compare(Stop o1, Stop o2) { // return (int) (o1.getDistanceFromLocation(locToCompare)-o2.getDistanceFromLocation(locToCompare)); // } // } // Path: src/it/reyboz/bustorino/adapters/ArrivalsStopAdapter.java import it.reyboz.bustorino.backend.*; import it.reyboz.bustorino.fragments.FragmentListenerMain; import it.reyboz.bustorino.util.RoutePositionSorter; import it.reyboz.bustorino.util.StopSorterByDistance; import java.util.*; import android.content.Context; import android.location.Location; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.util.Pair; import androidx.recyclerview.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import it.reyboz.bustorino.R; } class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { TextView lineNameTextView; TextView lineDirectionTextView; TextView stopNameView; TextView arrivalsDescriptionTextView; TextView arrivalsTextView; TextView distancetextView; String stopID; ViewHolder(View holdView){ super(holdView); holdView.setOnClickListener(this); lineNameTextView = (TextView) holdView.findViewById(R.id.lineNameTextView); lineDirectionTextView = (TextView) holdView.findViewById(R.id.lineDirectionTextView); stopNameView = (TextView) holdView.findViewById(R.id.arrivalStopName); arrivalsTextView = (TextView) holdView.findViewById(R.id.arrivalsTimeTextView); arrivalsDescriptionTextView = (TextView) holdView.findViewById(R.id.arrivalsDescriptionTextView); distancetextView = (TextView) holdView.findViewById(R.id.arrivalsDistanceTextView); } @Override public void onClick(View v) { listener.requestArrivalsForStopID(stopID); } } public void resetRoutesPairList(List<Palina> stopList){
Collections.sort(stopList,new StopSorterByDistance(userPosition));
valerio-bozzolan/bus-torino
src/it/reyboz/bustorino/adapters/ArrivalsStopAdapter.java
// Path: src/it/reyboz/bustorino/fragments/FragmentListenerMain.java // public interface FragmentListenerMain extends CommonFragmentListener { // // void toggleSpinner(boolean state); // // /** // * Tell activity that we need to enable/disable the refreshLayout // * @param yes or no // */ // void enableRefreshLayout(boolean yes); // } // // Path: src/it/reyboz/bustorino/util/RoutePositionSorter.java // public class RoutePositionSorter implements Comparator<Pair<Stop, Route>> { // private final Location loc; // private final double minutialmetro = 6.0/100; //v = 5km/h // private final double distancemultiplier = 2./3; // public RoutePositionSorter(Location loc) { // this.loc = loc; // } // // @Override // public int compare(Pair<Stop, Route> pair1, Pair<Stop, Route> pair2) throws NullPointerException{ // int delta = 0; // final Stop stop1 = pair1.first, stop2 = pair2.first; // double dist1 = utils.measuredistanceBetween(loc.getLatitude(),loc.getLongitude(), // stop1.getLatitude(),stop1.getLongitude()); // double dist2 = utils.measuredistanceBetween(loc.getLatitude(),loc.getLongitude(), // stop2.getLatitude(),stop2.getLongitude()); // final List<Passaggio> passaggi1 = pair1.second.passaggi, // passaggi2 = pair2.second.passaggi; // if(passaggi1.size()<=0 || passaggi2.size()<=0){ // Log.e("ArrivalsStopAdapter","Cannot compare: No arrivals in one of the stops"); // } else { // Collections.sort(passaggi1); // Collections.sort(passaggi2); // int deltaOre = passaggi1.get(0).hh-passaggi2.get(0).hh; // if(deltaOre>12) // deltaOre -= 24; // else if (deltaOre<-12) // deltaOre += 24; // delta+=deltaOre*60 + passaggi1.get(0).mm-passaggi2.get(0).mm; // } // delta += (int)((dist1 -dist2)*minutialmetro*distancemultiplier); // return delta; // } // // @Override // public boolean equals(Object obj) { // return obj instanceof RoutePositionSorter; // } // } // // Path: src/it/reyboz/bustorino/util/StopSorterByDistance.java // public class StopSorterByDistance implements Comparator<Stop> { // private final Location locToCompare; // // public StopSorterByDistance(Location locToCompare) { // this.locToCompare = locToCompare; // } // // @Override // public int compare(Stop o1, Stop o2) { // return (int) (o1.getDistanceFromLocation(locToCompare)-o2.getDistanceFromLocation(locToCompare)); // } // }
import it.reyboz.bustorino.backend.*; import it.reyboz.bustorino.fragments.FragmentListenerMain; import it.reyboz.bustorino.util.RoutePositionSorter; import it.reyboz.bustorino.util.StopSorterByDistance; import java.util.*; import android.content.Context; import android.location.Location; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.util.Pair; import androidx.recyclerview.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import it.reyboz.bustorino.R;
//routesPairList.remove(posExisting.intValue()); //routesPairList.add(posIn,mRoutesPairList.get(posIn)); notifyItemMoved(posExisting, posIn); indexMapExisting.remove(pair); } else{ //INSERT IT //routesPairList.add(posIn,mRoutesPairList.get(posIn)); notifyItemInserted(posIn); } }// //REMOVE OLD STOPS for (Pair<String,String> pair: indexMapExisting.keySet()) { final Integer posExisting = indexMapExisting.get(pair); if (posExisting == null) continue; //routesPairList.remove(posExisting.intValue()); notifyItemRemoved(posExisting); } //*/notifyDataSetChanged(); } //remove and join the } } /** * Sort and remove the repetitions for the routesPairList */ private void resetListAndPosition(){
// Path: src/it/reyboz/bustorino/fragments/FragmentListenerMain.java // public interface FragmentListenerMain extends CommonFragmentListener { // // void toggleSpinner(boolean state); // // /** // * Tell activity that we need to enable/disable the refreshLayout // * @param yes or no // */ // void enableRefreshLayout(boolean yes); // } // // Path: src/it/reyboz/bustorino/util/RoutePositionSorter.java // public class RoutePositionSorter implements Comparator<Pair<Stop, Route>> { // private final Location loc; // private final double minutialmetro = 6.0/100; //v = 5km/h // private final double distancemultiplier = 2./3; // public RoutePositionSorter(Location loc) { // this.loc = loc; // } // // @Override // public int compare(Pair<Stop, Route> pair1, Pair<Stop, Route> pair2) throws NullPointerException{ // int delta = 0; // final Stop stop1 = pair1.first, stop2 = pair2.first; // double dist1 = utils.measuredistanceBetween(loc.getLatitude(),loc.getLongitude(), // stop1.getLatitude(),stop1.getLongitude()); // double dist2 = utils.measuredistanceBetween(loc.getLatitude(),loc.getLongitude(), // stop2.getLatitude(),stop2.getLongitude()); // final List<Passaggio> passaggi1 = pair1.second.passaggi, // passaggi2 = pair2.second.passaggi; // if(passaggi1.size()<=0 || passaggi2.size()<=0){ // Log.e("ArrivalsStopAdapter","Cannot compare: No arrivals in one of the stops"); // } else { // Collections.sort(passaggi1); // Collections.sort(passaggi2); // int deltaOre = passaggi1.get(0).hh-passaggi2.get(0).hh; // if(deltaOre>12) // deltaOre -= 24; // else if (deltaOre<-12) // deltaOre += 24; // delta+=deltaOre*60 + passaggi1.get(0).mm-passaggi2.get(0).mm; // } // delta += (int)((dist1 -dist2)*minutialmetro*distancemultiplier); // return delta; // } // // @Override // public boolean equals(Object obj) { // return obj instanceof RoutePositionSorter; // } // } // // Path: src/it/reyboz/bustorino/util/StopSorterByDistance.java // public class StopSorterByDistance implements Comparator<Stop> { // private final Location locToCompare; // // public StopSorterByDistance(Location locToCompare) { // this.locToCompare = locToCompare; // } // // @Override // public int compare(Stop o1, Stop o2) { // return (int) (o1.getDistanceFromLocation(locToCompare)-o2.getDistanceFromLocation(locToCompare)); // } // } // Path: src/it/reyboz/bustorino/adapters/ArrivalsStopAdapter.java import it.reyboz.bustorino.backend.*; import it.reyboz.bustorino.fragments.FragmentListenerMain; import it.reyboz.bustorino.util.RoutePositionSorter; import it.reyboz.bustorino.util.StopSorterByDistance; import java.util.*; import android.content.Context; import android.location.Location; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.util.Pair; import androidx.recyclerview.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import it.reyboz.bustorino.R; //routesPairList.remove(posExisting.intValue()); //routesPairList.add(posIn,mRoutesPairList.get(posIn)); notifyItemMoved(posExisting, posIn); indexMapExisting.remove(pair); } else{ //INSERT IT //routesPairList.add(posIn,mRoutesPairList.get(posIn)); notifyItemInserted(posIn); } }// //REMOVE OLD STOPS for (Pair<String,String> pair: indexMapExisting.keySet()) { final Integer posExisting = indexMapExisting.get(pair); if (posExisting == null) continue; //routesPairList.remove(posExisting.intValue()); notifyItemRemoved(posExisting); } //*/notifyDataSetChanged(); } //remove and join the } } /** * Sort and remove the repetitions for the routesPairList */ private void resetListAndPosition(){
Collections.sort(this.routesPairList,new RoutePositionSorter(userPosition));
valerio-bozzolan/bus-torino
src/it/reyboz/bustorino/backend/Stop.java
// Path: src/it/reyboz/bustorino/util/LinesNameSorter.java // public class LinesNameSorter implements Comparator<String> { // @Override // public int compare(String name1, String name2) { // // if(name1.length()>name2.length()) return 1; // if(name1.length()==name2.length()) { // try{ // int num1 = Integer.parseInt(name1.trim()); // int num2 = Integer.parseInt(name2.trim()); // return num1-num2; // } catch (NumberFormatException ex){ // //Log.d("BUSTO Compare lines","Cannot compare lines "+name1+" and "+name2); // return name1.compareTo(name2); // } // } // return -1; // // } // }
import android.location.Location; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import it.reyboz.bustorino.util.LinesNameSorter; import java.net.URLEncoder; import java.util.Collections; import java.util.List; import java.util.Locale;
@Nullable public String getAbsurdGTTPlaceName() { return absurdGTTPlaceName; } public void setAbsurdGTTPlaceName(@NonNull String absurdGTTPlaceName) { this.absurdGTTPlaceName = absurdGTTPlaceName; } public void setRoutesThatStopHere(@Nullable List<String> routesThatStopHere) { this.routesThatStopHere = routesThatStopHere; } protected void setRoutesThatStopHereString(String routesStopping){ this.routesThatStopHereString = routesStopping; } @Nullable protected List<String> getRoutesThatStopHere(){ return routesThatStopHere; } protected @Nullable String buildRoutesString() { // no routes => no string if(this.routesThatStopHere == null || this.routesThatStopHere.size() == 0) { return null; } StringBuilder sb = new StringBuilder();
// Path: src/it/reyboz/bustorino/util/LinesNameSorter.java // public class LinesNameSorter implements Comparator<String> { // @Override // public int compare(String name1, String name2) { // // if(name1.length()>name2.length()) return 1; // if(name1.length()==name2.length()) { // try{ // int num1 = Integer.parseInt(name1.trim()); // int num2 = Integer.parseInt(name2.trim()); // return num1-num2; // } catch (NumberFormatException ex){ // //Log.d("BUSTO Compare lines","Cannot compare lines "+name1+" and "+name2); // return name1.compareTo(name2); // } // } // return -1; // // } // } // Path: src/it/reyboz/bustorino/backend/Stop.java import android.location.Location; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import it.reyboz.bustorino.util.LinesNameSorter; import java.net.URLEncoder; import java.util.Collections; import java.util.List; import java.util.Locale; @Nullable public String getAbsurdGTTPlaceName() { return absurdGTTPlaceName; } public void setAbsurdGTTPlaceName(@NonNull String absurdGTTPlaceName) { this.absurdGTTPlaceName = absurdGTTPlaceName; } public void setRoutesThatStopHere(@Nullable List<String> routesThatStopHere) { this.routesThatStopHere = routesThatStopHere; } protected void setRoutesThatStopHereString(String routesStopping){ this.routesThatStopHereString = routesStopping; } @Nullable protected List<String> getRoutesThatStopHere(){ return routesThatStopHere; } protected @Nullable String buildRoutesString() { // no routes => no string if(this.routesThatStopHere == null || this.routesThatStopHere.size() == 0) { return null; } StringBuilder sb = new StringBuilder();
Collections.sort(routesThatStopHere,new LinesNameSorter());
valerio-bozzolan/bus-torino
src/it/reyboz/bustorino/ActivitySettings.java
// Path: src/it/reyboz/bustorino/fragments/SettingsFragment.java // public class SettingsFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener { // private static final String TAG = SettingsFragment.class.getName(); // // private static final String DIALOG_FRAGMENT_TAG = // "androidx.preference.PreferenceFragment.DIALOG"; // //private static final // Handler mHandler; // // @Override // public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // mHandler = new Handler(); // return super.onCreateView(inflater, container, savedInstanceState); // // } // // @Override // public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { // //getPreferenceManager().setSharedPreferencesName(getString(R.string.mainSharedPreferences)); // convertStringPrefToIntIfNeeded(getString(R.string.pref_key_num_recents), getContext()); // // getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); // setPreferencesFromResource(R.xml.preferences,rootKey); // /*EditTextPreference editPref = findPreference(getString(R.string.pref_key_num_recents)); // editPref.setOnBindEditTextListener(editText -> { // editText.setInputType(InputType.TYPE_CLASS_NUMBER); // editText.setSelection(0,editText.getText().length()); // }); // */ // // //ListPreference preference = findPreference(R.string.arrival_times) // // // } // // @Override // public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { // Preference pref = findPreference(key); // Log.d(TAG,"Preference key "+key+" changed"); // //sometimes this happens // if(getContext()==null) return; // /* // THIS CODE STAYS COMMENTED FOR FUTURE REFERENCES // if (key.equals(getString(R.string.pref_key_num_recents))){ // //check that is it an int // // String value = sharedPreferences.getString(key,""); // boolean valid = value.length() != 0; // try{ // Integer intValue = Integer.parseInt(value); // } catch (NumberFormatException ex){ // valid = false; // } // if (!valid){ // Toast.makeText(getContext(), R.string.invalid_number, Toast.LENGTH_SHORT).show(); // if(pref instanceof EditTextPreference){ // EditTextPreference prefEdit = (EditTextPreference) pref; // //Intent intent = prefEdit.getIntent(); // Log.d(TAG, "opening preference, dialog showing "+ // (getParentFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG)!=null) ); // //getPreferenceManager().showDialog(pref); // //onDisplayPreferenceDialog(prefEdit); // mHandler.postDelayed(new DelayedDisplay(prefEdit), 500); // } // // } // } // */ // // Log.d("BusTO Settings", "changed "+key+"\n "+sharedPreferences.getAll()); // // } // // private void convertStringPrefToIntIfNeeded(String preferenceKey, Context con){ // if (con == null) return; // SharedPreferences defaultSharedPref = PreferenceManager.getDefaultSharedPreferences(getContext()); // try{ // // Integer val = defaultSharedPref.getInt(preferenceKey, 0); // } catch (NumberFormatException | ClassCastException ex){ // //convert the preference // //final String preferenceNumRecents = getString(R.string.pref_key_num_recents); // Log.d("Preference - BusTO", "Converting to integer the string preference "+preferenceKey); // String currentValue = defaultSharedPref.getString(preferenceKey, "10"); // int newValue; // try{ // newValue = Integer.parseInt(currentValue); // } catch (NumberFormatException e){ // newValue = 10; // } // final SharedPreferences.Editor editor = defaultSharedPref.edit(); // editor.remove(preferenceKey); // editor.putInt(preferenceKey, newValue); // editor.apply(); // } // } // // class DelayedDisplay implements Runnable{ // private final WeakReference<DialogPreference> preferenceWeakReference; // // public DelayedDisplay(DialogPreference preference) { // this.preferenceWeakReference = new WeakReference<>(preference); // } // // @Override // public void run() { // if(preferenceWeakReference.get()==null) // return; // // getPreferenceManager().showDialog(preferenceWeakReference.get()); // } // } // }
import android.os.Bundle; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import android.util.Log; import it.reyboz.bustorino.fragments.SettingsFragment;
package it.reyboz.bustorino; public class ActivitySettings extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); ActionBar ab = getSupportActionBar(); if(ab!=null) { ab.setIcon(R.drawable.ic_launcher); ab.setDisplayHomeAsUpEnabled(true); } else { Log.e("SETTINGS_ACTIV","ACTION BAR IS NULL"); } FragmentManager framan = getSupportFragmentManager(); FragmentTransaction ft = framan.beginTransaction();
// Path: src/it/reyboz/bustorino/fragments/SettingsFragment.java // public class SettingsFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener { // private static final String TAG = SettingsFragment.class.getName(); // // private static final String DIALOG_FRAGMENT_TAG = // "androidx.preference.PreferenceFragment.DIALOG"; // //private static final // Handler mHandler; // // @Override // public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // mHandler = new Handler(); // return super.onCreateView(inflater, container, savedInstanceState); // // } // // @Override // public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { // //getPreferenceManager().setSharedPreferencesName(getString(R.string.mainSharedPreferences)); // convertStringPrefToIntIfNeeded(getString(R.string.pref_key_num_recents), getContext()); // // getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); // setPreferencesFromResource(R.xml.preferences,rootKey); // /*EditTextPreference editPref = findPreference(getString(R.string.pref_key_num_recents)); // editPref.setOnBindEditTextListener(editText -> { // editText.setInputType(InputType.TYPE_CLASS_NUMBER); // editText.setSelection(0,editText.getText().length()); // }); // */ // // //ListPreference preference = findPreference(R.string.arrival_times) // // // } // // @Override // public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { // Preference pref = findPreference(key); // Log.d(TAG,"Preference key "+key+" changed"); // //sometimes this happens // if(getContext()==null) return; // /* // THIS CODE STAYS COMMENTED FOR FUTURE REFERENCES // if (key.equals(getString(R.string.pref_key_num_recents))){ // //check that is it an int // // String value = sharedPreferences.getString(key,""); // boolean valid = value.length() != 0; // try{ // Integer intValue = Integer.parseInt(value); // } catch (NumberFormatException ex){ // valid = false; // } // if (!valid){ // Toast.makeText(getContext(), R.string.invalid_number, Toast.LENGTH_SHORT).show(); // if(pref instanceof EditTextPreference){ // EditTextPreference prefEdit = (EditTextPreference) pref; // //Intent intent = prefEdit.getIntent(); // Log.d(TAG, "opening preference, dialog showing "+ // (getParentFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG)!=null) ); // //getPreferenceManager().showDialog(pref); // //onDisplayPreferenceDialog(prefEdit); // mHandler.postDelayed(new DelayedDisplay(prefEdit), 500); // } // // } // } // */ // // Log.d("BusTO Settings", "changed "+key+"\n "+sharedPreferences.getAll()); // // } // // private void convertStringPrefToIntIfNeeded(String preferenceKey, Context con){ // if (con == null) return; // SharedPreferences defaultSharedPref = PreferenceManager.getDefaultSharedPreferences(getContext()); // try{ // // Integer val = defaultSharedPref.getInt(preferenceKey, 0); // } catch (NumberFormatException | ClassCastException ex){ // //convert the preference // //final String preferenceNumRecents = getString(R.string.pref_key_num_recents); // Log.d("Preference - BusTO", "Converting to integer the string preference "+preferenceKey); // String currentValue = defaultSharedPref.getString(preferenceKey, "10"); // int newValue; // try{ // newValue = Integer.parseInt(currentValue); // } catch (NumberFormatException e){ // newValue = 10; // } // final SharedPreferences.Editor editor = defaultSharedPref.edit(); // editor.remove(preferenceKey); // editor.putInt(preferenceKey, newValue); // editor.apply(); // } // } // // class DelayedDisplay implements Runnable{ // private final WeakReference<DialogPreference> preferenceWeakReference; // // public DelayedDisplay(DialogPreference preference) { // this.preferenceWeakReference = new WeakReference<>(preference); // } // // @Override // public void run() { // if(preferenceWeakReference.get()==null) // return; // // getPreferenceManager().showDialog(preferenceWeakReference.get()); // } // } // } // Path: src/it/reyboz/bustorino/ActivitySettings.java import android.os.Bundle; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import android.util.Log; import it.reyboz.bustorino.fragments.SettingsFragment; package it.reyboz.bustorino; public class ActivitySettings extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); ActionBar ab = getSupportActionBar(); if(ab!=null) { ab.setIcon(R.drawable.ic_launcher); ab.setDisplayHomeAsUpEnabled(true); } else { Log.e("SETTINGS_ACTIV","ACTION BAR IS NULL"); } FragmentManager framan = getSupportFragmentManager(); FragmentTransaction ft = framan.beginTransaction();
ft.replace(R.id.setting_container,new SettingsFragment());
ragnor-rs/sklad
lib/src/test/java/io/reist/sklad/CachedStorageTest.java
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void assertTestObject(Storage storage) throws IOException { // assertTestObject(storage, 0); // }
import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import java.io.ByteArrayInputStream; import java.io.EOFException; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okio.Buffer; import static io.reist.sklad.TestUtils.TEST_NAME_1; import static io.reist.sklad.TestUtils.assertTestObject; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify;
localStream.close(); assertTrue(storage.contains(TestUtils.TEST_NAME_2)); assertFalse(storage.contains(TestUtils.TEST_NAME_2_INVALID)); OutputStream remoteStream = storage.getRemote().openOutputStream(TestUtils.TEST_NAME_3); remoteStream.write(TestUtils.TEST_DATA_3); remoteStream.flush(); remoteStream.close(); assertTrue(storage.contains(TestUtils.TEST_NAME_3)); assertFalse(storage.contains(TestUtils.TEST_NAME_3_INVALID)); server.shutdown(); } @Test public final void testDownload() throws Exception { Buffer buffer = new Buffer(); buffer.readFrom(new ByteArrayInputStream(TestUtils.TEST_DATA_1)); MockWebServer server = new MockWebServer(); server.enqueue(new MockResponse().setBody(buffer)); server.start(); baseUrl = server.url("/"); CachedStorage storage = createStorage();
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void assertTestObject(Storage storage) throws IOException { // assertTestObject(storage, 0); // } // Path: lib/src/test/java/io/reist/sklad/CachedStorageTest.java import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import java.io.ByteArrayInputStream; import java.io.EOFException; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okio.Buffer; import static io.reist.sklad.TestUtils.TEST_NAME_1; import static io.reist.sklad.TestUtils.assertTestObject; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; localStream.close(); assertTrue(storage.contains(TestUtils.TEST_NAME_2)); assertFalse(storage.contains(TestUtils.TEST_NAME_2_INVALID)); OutputStream remoteStream = storage.getRemote().openOutputStream(TestUtils.TEST_NAME_3); remoteStream.write(TestUtils.TEST_DATA_3); remoteStream.flush(); remoteStream.close(); assertTrue(storage.contains(TestUtils.TEST_NAME_3)); assertFalse(storage.contains(TestUtils.TEST_NAME_3_INVALID)); server.shutdown(); } @Test public final void testDownload() throws Exception { Buffer buffer = new Buffer(); buffer.readFrom(new ByteArrayInputStream(TestUtils.TEST_DATA_1)); MockWebServer server = new MockWebServer(); server.enqueue(new MockResponse().setBody(buffer)); server.start(); baseUrl = server.url("/"); CachedStorage storage = createStorage();
storage.cache(TEST_NAME_1);
ragnor-rs/sklad
lib/src/test/java/io/reist/sklad/CachedStorageTest.java
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void assertTestObject(Storage storage) throws IOException { // assertTestObject(storage, 0); // }
import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import java.io.ByteArrayInputStream; import java.io.EOFException; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okio.Buffer; import static io.reist.sklad.TestUtils.TEST_NAME_1; import static io.reist.sklad.TestUtils.assertTestObject; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify;
assertTrue(storage.contains(TestUtils.TEST_NAME_2)); assertFalse(storage.contains(TestUtils.TEST_NAME_2_INVALID)); OutputStream remoteStream = storage.getRemote().openOutputStream(TestUtils.TEST_NAME_3); remoteStream.write(TestUtils.TEST_DATA_3); remoteStream.flush(); remoteStream.close(); assertTrue(storage.contains(TestUtils.TEST_NAME_3)); assertFalse(storage.contains(TestUtils.TEST_NAME_3_INVALID)); server.shutdown(); } @Test public final void testDownload() throws Exception { Buffer buffer = new Buffer(); buffer.readFrom(new ByteArrayInputStream(TestUtils.TEST_DATA_1)); MockWebServer server = new MockWebServer(); server.enqueue(new MockResponse().setBody(buffer)); server.start(); baseUrl = server.url("/"); CachedStorage storage = createStorage(); storage.cache(TEST_NAME_1);
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void assertTestObject(Storage storage) throws IOException { // assertTestObject(storage, 0); // } // Path: lib/src/test/java/io/reist/sklad/CachedStorageTest.java import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import java.io.ByteArrayInputStream; import java.io.EOFException; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okio.Buffer; import static io.reist.sklad.TestUtils.TEST_NAME_1; import static io.reist.sklad.TestUtils.assertTestObject; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; assertTrue(storage.contains(TestUtils.TEST_NAME_2)); assertFalse(storage.contains(TestUtils.TEST_NAME_2_INVALID)); OutputStream remoteStream = storage.getRemote().openOutputStream(TestUtils.TEST_NAME_3); remoteStream.write(TestUtils.TEST_DATA_3); remoteStream.flush(); remoteStream.close(); assertTrue(storage.contains(TestUtils.TEST_NAME_3)); assertFalse(storage.contains(TestUtils.TEST_NAME_3_INVALID)); server.shutdown(); } @Test public final void testDownload() throws Exception { Buffer buffer = new Buffer(); buffer.readFrom(new ByteArrayInputStream(TestUtils.TEST_DATA_1)); MockWebServer server = new MockWebServer(); server.enqueue(new MockResponse().setBody(buffer)); server.start(); baseUrl = server.url("/"); CachedStorage storage = createStorage(); storage.cache(TEST_NAME_1);
assertTestObject(storage.getLocal());
ragnor-rs/sklad
lib/src/test/java/io/reist/sklad/BaseStorageTest.java
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void assertTestObject(Storage storage) throws IOException { // assertTestObject(storage, 0); // } // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // }
import static org.junit.Assert.assertTrue; import android.support.annotation.CallSuper; import android.support.annotation.NonNull; import org.junit.Test; import java.io.IOException; import java.io.InterruptedIOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.assertTestObject; import static io.reist.sklad.TestUtils.saveTestObject; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull;
/* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ public abstract class BaseStorageTest<S extends Storage> { protected static final int WORKER_DURATION = 4000; private final Object testLock = new Object(); @Test @CallSuper public void testContains() throws Exception { S storage = createStorage(); assertFalse(storage.contains(TestUtils.TEST_NAME_1));
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void assertTestObject(Storage storage) throws IOException { // assertTestObject(storage, 0); // } // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // } // Path: lib/src/test/java/io/reist/sklad/BaseStorageTest.java import static org.junit.Assert.assertTrue; import android.support.annotation.CallSuper; import android.support.annotation.NonNull; import org.junit.Test; import java.io.IOException; import java.io.InterruptedIOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.assertTestObject; import static io.reist.sklad.TestUtils.saveTestObject; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; /* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ public abstract class BaseStorageTest<S extends Storage> { protected static final int WORKER_DURATION = 4000; private final Object testLock = new Object(); @Test @CallSuper public void testContains() throws Exception { S storage = createStorage(); assertFalse(storage.contains(TestUtils.TEST_NAME_1));
saveTestObject(storage);
ragnor-rs/sklad
lib/src/test/java/io/reist/sklad/BaseStorageTest.java
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void assertTestObject(Storage storage) throws IOException { // assertTestObject(storage, 0); // } // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // }
import static org.junit.Assert.assertTrue; import android.support.annotation.CallSuper; import android.support.annotation.NonNull; import org.junit.Test; import java.io.IOException; import java.io.InterruptedIOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.assertTestObject; import static io.reist.sklad.TestUtils.saveTestObject; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull;
/* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ public abstract class BaseStorageTest<S extends Storage> { protected static final int WORKER_DURATION = 4000; private final Object testLock = new Object(); @Test @CallSuper public void testContains() throws Exception { S storage = createStorage(); assertFalse(storage.contains(TestUtils.TEST_NAME_1)); saveTestObject(storage); assertTrue(storage.contains(TestUtils.TEST_NAME_1)); } @Test @CallSuper public void testStreams() throws Exception { S storage = createStorage(); saveTestObject(storage);
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void assertTestObject(Storage storage) throws IOException { // assertTestObject(storage, 0); // } // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // } // Path: lib/src/test/java/io/reist/sklad/BaseStorageTest.java import static org.junit.Assert.assertTrue; import android.support.annotation.CallSuper; import android.support.annotation.NonNull; import org.junit.Test; import java.io.IOException; import java.io.InterruptedIOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.assertTestObject; import static io.reist.sklad.TestUtils.saveTestObject; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; /* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ public abstract class BaseStorageTest<S extends Storage> { protected static final int WORKER_DURATION = 4000; private final Object testLock = new Object(); @Test @CallSuper public void testContains() throws Exception { S storage = createStorage(); assertFalse(storage.contains(TestUtils.TEST_NAME_1)); saveTestObject(storage); assertTrue(storage.contains(TestUtils.TEST_NAME_1)); } @Test @CallSuper public void testStreams() throws Exception { S storage = createStorage(); saveTestObject(storage);
assertTestObject(storage);
ragnor-rs/sklad
lib/src/test/java/io/reist/sklad/BaseStorageTest.java
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void assertTestObject(Storage storage) throws IOException { // assertTestObject(storage, 0); // } // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // }
import static org.junit.Assert.assertTrue; import android.support.annotation.CallSuper; import android.support.annotation.NonNull; import org.junit.Test; import java.io.IOException; import java.io.InterruptedIOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.assertTestObject; import static io.reist.sklad.TestUtils.saveTestObject; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull;
@NonNull protected abstract S createStorage() throws IOException; @Test @CallSuper public void testDelete() throws Exception { S storage = createStorage(); saveTestObject(storage); try { storage.delete(TestUtils.TEST_NAME_1); assertFalse(storage.contains(TestUtils.TEST_NAME_1)); } catch (UnsupportedOperationException ignored) {} } @Test @CallSuper public void testDeleteAll() throws Exception { S storage = createStorage(); saveTestObject(storage); try { storage.deleteAll(); assertFalse(storage.contains(TestUtils.TEST_NAME_1)); } catch (UnsupportedOperationException ignored) {} } @Test @CallSuper public void testSkip() throws Exception { S storage = createStorage(); saveTestObject(storage);
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void assertTestObject(Storage storage) throws IOException { // assertTestObject(storage, 0); // } // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // } // Path: lib/src/test/java/io/reist/sklad/BaseStorageTest.java import static org.junit.Assert.assertTrue; import android.support.annotation.CallSuper; import android.support.annotation.NonNull; import org.junit.Test; import java.io.IOException; import java.io.InterruptedIOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.assertTestObject; import static io.reist.sklad.TestUtils.saveTestObject; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @NonNull protected abstract S createStorage() throws IOException; @Test @CallSuper public void testDelete() throws Exception { S storage = createStorage(); saveTestObject(storage); try { storage.delete(TestUtils.TEST_NAME_1); assertFalse(storage.contains(TestUtils.TEST_NAME_1)); } catch (UnsupportedOperationException ignored) {} } @Test @CallSuper public void testDeleteAll() throws Exception { S storage = createStorage(); saveTestObject(storage); try { storage.deleteAll(); assertFalse(storage.contains(TestUtils.TEST_NAME_1)); } catch (UnsupportedOperationException ignored) {} } @Test @CallSuper public void testSkip() throws Exception { S storage = createStorage(); saveTestObject(storage);
assertTestObject(storage, TEST_DATA_1.length / 2);
ragnor-rs/sklad
lib/src/test/java/io/reist/sklad/CachedStorageStatesTest.java
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12";
import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.stubbing.OngoingStubbing; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.HashMap; import java.util.Map; import static io.reist.sklad.TestUtils.TEST_NAME_1; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when;
@Override public void setFullyCached(@NonNull Storage local, @NonNull String id, boolean fullyCached) throws IOException { stateMap.put(id, fullyCached); } @Override public boolean isFullyCached(@NonNull Storage local, @NonNull String id) { return Boolean.TRUE.equals(stateMap.get(id)); } }; } @SuppressWarnings({"ConstantConditions", "ResultOfMethodCallIgnored"}) private static void assertObjectJustCached( CachedStorageStates cachedStorageStates, Storage remote, InputStream remoteInputStream, Storage local, OutputStream localOutputStream, InputStream localInputStream, CachedStorage cachedStorage, boolean useCacheMethod, boolean readFully ) throws IOException { if (useCacheMethod) { try {
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // Path: lib/src/test/java/io/reist/sklad/CachedStorageStatesTest.java import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.stubbing.OngoingStubbing; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.HashMap; import java.util.Map; import static io.reist.sklad.TestUtils.TEST_NAME_1; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @Override public void setFullyCached(@NonNull Storage local, @NonNull String id, boolean fullyCached) throws IOException { stateMap.put(id, fullyCached); } @Override public boolean isFullyCached(@NonNull Storage local, @NonNull String id) { return Boolean.TRUE.equals(stateMap.get(id)); } }; } @SuppressWarnings({"ConstantConditions", "ResultOfMethodCallIgnored"}) private static void assertObjectJustCached( CachedStorageStates cachedStorageStates, Storage remote, InputStream remoteInputStream, Storage local, OutputStream localOutputStream, InputStream localInputStream, CachedStorage cachedStorage, boolean useCacheMethod, boolean readFully ) throws IOException { if (useCacheMethod) { try {
cachedStorage.cache(TEST_NAME_1);
ragnor-rs/sklad
lib/src/test/java/io/reist/sklad/LimitedStorageTest.java
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_2 = new byte[] {1, 2, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_3 = new byte[] {7, 5, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_2 = "123"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_3 = "qwe"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // }
import static io.reist.sklad.TestUtils.TEST_NAME_2; import static io.reist.sklad.TestUtils.TEST_NAME_3; import static io.reist.sklad.TestUtils.saveTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.io.IOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.TEST_DATA_2; import static io.reist.sklad.TestUtils.TEST_DATA_3; import static io.reist.sklad.TestUtils.TEST_NAME_1;
/* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ @RunWith(RobolectricTestRunner.class) @Config( constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP ) public class LimitedStorageTest extends BaseStorageTest<LimitedStorage> { @NonNull @Override protected LimitedStorage createStorage() throws IOException { return createLimitedStorage(new MemoryStorage()); } @NonNull static LimitedStorage createLimitedStorage(JournalingStorage journalingStorage) { return new LimitedStorage( journalingStorage,
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_2 = new byte[] {1, 2, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_3 = new byte[] {7, 5, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_2 = "123"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_3 = "qwe"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // } // Path: lib/src/test/java/io/reist/sklad/LimitedStorageTest.java import static io.reist.sklad.TestUtils.TEST_NAME_2; import static io.reist.sklad.TestUtils.TEST_NAME_3; import static io.reist.sklad.TestUtils.saveTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.io.IOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.TEST_DATA_2; import static io.reist.sklad.TestUtils.TEST_DATA_3; import static io.reist.sklad.TestUtils.TEST_NAME_1; /* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ @RunWith(RobolectricTestRunner.class) @Config( constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP ) public class LimitedStorageTest extends BaseStorageTest<LimitedStorage> { @NonNull @Override protected LimitedStorage createStorage() throws IOException { return createLimitedStorage(new MemoryStorage()); } @NonNull static LimitedStorage createLimitedStorage(JournalingStorage journalingStorage) { return new LimitedStorage( journalingStorage,
TEST_DATA_1.length + TEST_DATA_2.length
ragnor-rs/sklad
lib/src/test/java/io/reist/sklad/LimitedStorageTest.java
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_2 = new byte[] {1, 2, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_3 = new byte[] {7, 5, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_2 = "123"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_3 = "qwe"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // }
import static io.reist.sklad.TestUtils.TEST_NAME_2; import static io.reist.sklad.TestUtils.TEST_NAME_3; import static io.reist.sklad.TestUtils.saveTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.io.IOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.TEST_DATA_2; import static io.reist.sklad.TestUtils.TEST_DATA_3; import static io.reist.sklad.TestUtils.TEST_NAME_1;
/* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ @RunWith(RobolectricTestRunner.class) @Config( constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP ) public class LimitedStorageTest extends BaseStorageTest<LimitedStorage> { @NonNull @Override protected LimitedStorage createStorage() throws IOException { return createLimitedStorage(new MemoryStorage()); } @NonNull static LimitedStorage createLimitedStorage(JournalingStorage journalingStorage) { return new LimitedStorage( journalingStorage,
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_2 = new byte[] {1, 2, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_3 = new byte[] {7, 5, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_2 = "123"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_3 = "qwe"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // } // Path: lib/src/test/java/io/reist/sklad/LimitedStorageTest.java import static io.reist.sklad.TestUtils.TEST_NAME_2; import static io.reist.sklad.TestUtils.TEST_NAME_3; import static io.reist.sklad.TestUtils.saveTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.io.IOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.TEST_DATA_2; import static io.reist.sklad.TestUtils.TEST_DATA_3; import static io.reist.sklad.TestUtils.TEST_NAME_1; /* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ @RunWith(RobolectricTestRunner.class) @Config( constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP ) public class LimitedStorageTest extends BaseStorageTest<LimitedStorage> { @NonNull @Override protected LimitedStorage createStorage() throws IOException { return createLimitedStorage(new MemoryStorage()); } @NonNull static LimitedStorage createLimitedStorage(JournalingStorage journalingStorage) { return new LimitedStorage( journalingStorage,
TEST_DATA_1.length + TEST_DATA_2.length
ragnor-rs/sklad
lib/src/test/java/io/reist/sklad/LimitedStorageTest.java
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_2 = new byte[] {1, 2, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_3 = new byte[] {7, 5, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_2 = "123"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_3 = "qwe"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // }
import static io.reist.sklad.TestUtils.TEST_NAME_2; import static io.reist.sklad.TestUtils.TEST_NAME_3; import static io.reist.sklad.TestUtils.saveTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.io.IOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.TEST_DATA_2; import static io.reist.sklad.TestUtils.TEST_DATA_3; import static io.reist.sklad.TestUtils.TEST_NAME_1;
/* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ @RunWith(RobolectricTestRunner.class) @Config( constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP ) public class LimitedStorageTest extends BaseStorageTest<LimitedStorage> { @NonNull @Override protected LimitedStorage createStorage() throws IOException { return createLimitedStorage(new MemoryStorage()); } @NonNull static LimitedStorage createLimitedStorage(JournalingStorage journalingStorage) { return new LimitedStorage( journalingStorage, TEST_DATA_1.length + TEST_DATA_2.length ); } @Test public void testLimit() throws IOException { LimitedStorage storage = createStorage();
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_2 = new byte[] {1, 2, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_3 = new byte[] {7, 5, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_2 = "123"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_3 = "qwe"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // } // Path: lib/src/test/java/io/reist/sklad/LimitedStorageTest.java import static io.reist.sklad.TestUtils.TEST_NAME_2; import static io.reist.sklad.TestUtils.TEST_NAME_3; import static io.reist.sklad.TestUtils.saveTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.io.IOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.TEST_DATA_2; import static io.reist.sklad.TestUtils.TEST_DATA_3; import static io.reist.sklad.TestUtils.TEST_NAME_1; /* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ @RunWith(RobolectricTestRunner.class) @Config( constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP ) public class LimitedStorageTest extends BaseStorageTest<LimitedStorage> { @NonNull @Override protected LimitedStorage createStorage() throws IOException { return createLimitedStorage(new MemoryStorage()); } @NonNull static LimitedStorage createLimitedStorage(JournalingStorage journalingStorage) { return new LimitedStorage( journalingStorage, TEST_DATA_1.length + TEST_DATA_2.length ); } @Test public void testLimit() throws IOException { LimitedStorage storage = createStorage();
saveTestObject(storage, TEST_NAME_1, TEST_DATA_1);
ragnor-rs/sklad
lib/src/test/java/io/reist/sklad/LimitedStorageTest.java
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_2 = new byte[] {1, 2, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_3 = new byte[] {7, 5, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_2 = "123"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_3 = "qwe"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // }
import static io.reist.sklad.TestUtils.TEST_NAME_2; import static io.reist.sklad.TestUtils.TEST_NAME_3; import static io.reist.sklad.TestUtils.saveTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.io.IOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.TEST_DATA_2; import static io.reist.sklad.TestUtils.TEST_DATA_3; import static io.reist.sklad.TestUtils.TEST_NAME_1;
/* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ @RunWith(RobolectricTestRunner.class) @Config( constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP ) public class LimitedStorageTest extends BaseStorageTest<LimitedStorage> { @NonNull @Override protected LimitedStorage createStorage() throws IOException { return createLimitedStorage(new MemoryStorage()); } @NonNull static LimitedStorage createLimitedStorage(JournalingStorage journalingStorage) { return new LimitedStorage( journalingStorage, TEST_DATA_1.length + TEST_DATA_2.length ); } @Test public void testLimit() throws IOException { LimitedStorage storage = createStorage();
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_2 = new byte[] {1, 2, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_3 = new byte[] {7, 5, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_2 = "123"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_3 = "qwe"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // } // Path: lib/src/test/java/io/reist/sklad/LimitedStorageTest.java import static io.reist.sklad.TestUtils.TEST_NAME_2; import static io.reist.sklad.TestUtils.TEST_NAME_3; import static io.reist.sklad.TestUtils.saveTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.io.IOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.TEST_DATA_2; import static io.reist.sklad.TestUtils.TEST_DATA_3; import static io.reist.sklad.TestUtils.TEST_NAME_1; /* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ @RunWith(RobolectricTestRunner.class) @Config( constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP ) public class LimitedStorageTest extends BaseStorageTest<LimitedStorage> { @NonNull @Override protected LimitedStorage createStorage() throws IOException { return createLimitedStorage(new MemoryStorage()); } @NonNull static LimitedStorage createLimitedStorage(JournalingStorage journalingStorage) { return new LimitedStorage( journalingStorage, TEST_DATA_1.length + TEST_DATA_2.length ); } @Test public void testLimit() throws IOException { LimitedStorage storage = createStorage();
saveTestObject(storage, TEST_NAME_1, TEST_DATA_1);
ragnor-rs/sklad
lib/src/test/java/io/reist/sklad/LimitedStorageTest.java
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_2 = new byte[] {1, 2, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_3 = new byte[] {7, 5, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_2 = "123"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_3 = "qwe"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // }
import static io.reist.sklad.TestUtils.TEST_NAME_2; import static io.reist.sklad.TestUtils.TEST_NAME_3; import static io.reist.sklad.TestUtils.saveTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.io.IOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.TEST_DATA_2; import static io.reist.sklad.TestUtils.TEST_DATA_3; import static io.reist.sklad.TestUtils.TEST_NAME_1;
/* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ @RunWith(RobolectricTestRunner.class) @Config( constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP ) public class LimitedStorageTest extends BaseStorageTest<LimitedStorage> { @NonNull @Override protected LimitedStorage createStorage() throws IOException { return createLimitedStorage(new MemoryStorage()); } @NonNull static LimitedStorage createLimitedStorage(JournalingStorage journalingStorage) { return new LimitedStorage( journalingStorage, TEST_DATA_1.length + TEST_DATA_2.length ); } @Test public void testLimit() throws IOException { LimitedStorage storage = createStorage(); saveTestObject(storage, TEST_NAME_1, TEST_DATA_1);
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_2 = new byte[] {1, 2, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_3 = new byte[] {7, 5, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_2 = "123"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_3 = "qwe"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // } // Path: lib/src/test/java/io/reist/sklad/LimitedStorageTest.java import static io.reist.sklad.TestUtils.TEST_NAME_2; import static io.reist.sklad.TestUtils.TEST_NAME_3; import static io.reist.sklad.TestUtils.saveTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.io.IOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.TEST_DATA_2; import static io.reist.sklad.TestUtils.TEST_DATA_3; import static io.reist.sklad.TestUtils.TEST_NAME_1; /* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ @RunWith(RobolectricTestRunner.class) @Config( constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP ) public class LimitedStorageTest extends BaseStorageTest<LimitedStorage> { @NonNull @Override protected LimitedStorage createStorage() throws IOException { return createLimitedStorage(new MemoryStorage()); } @NonNull static LimitedStorage createLimitedStorage(JournalingStorage journalingStorage) { return new LimitedStorage( journalingStorage, TEST_DATA_1.length + TEST_DATA_2.length ); } @Test public void testLimit() throws IOException { LimitedStorage storage = createStorage(); saveTestObject(storage, TEST_NAME_1, TEST_DATA_1);
saveTestObject(storage, TEST_NAME_2, TEST_DATA_2);
ragnor-rs/sklad
lib/src/test/java/io/reist/sklad/LimitedStorageTest.java
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_2 = new byte[] {1, 2, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_3 = new byte[] {7, 5, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_2 = "123"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_3 = "qwe"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // }
import static io.reist.sklad.TestUtils.TEST_NAME_2; import static io.reist.sklad.TestUtils.TEST_NAME_3; import static io.reist.sklad.TestUtils.saveTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.io.IOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.TEST_DATA_2; import static io.reist.sklad.TestUtils.TEST_DATA_3; import static io.reist.sklad.TestUtils.TEST_NAME_1;
/* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ @RunWith(RobolectricTestRunner.class) @Config( constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP ) public class LimitedStorageTest extends BaseStorageTest<LimitedStorage> { @NonNull @Override protected LimitedStorage createStorage() throws IOException { return createLimitedStorage(new MemoryStorage()); } @NonNull static LimitedStorage createLimitedStorage(JournalingStorage journalingStorage) { return new LimitedStorage( journalingStorage, TEST_DATA_1.length + TEST_DATA_2.length ); } @Test public void testLimit() throws IOException { LimitedStorage storage = createStorage(); saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); saveTestObject(storage, TEST_NAME_2, TEST_DATA_2);
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_2 = new byte[] {1, 2, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_3 = new byte[] {7, 5, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_2 = "123"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_3 = "qwe"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // } // Path: lib/src/test/java/io/reist/sklad/LimitedStorageTest.java import static io.reist.sklad.TestUtils.TEST_NAME_2; import static io.reist.sklad.TestUtils.TEST_NAME_3; import static io.reist.sklad.TestUtils.saveTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.io.IOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.TEST_DATA_2; import static io.reist.sklad.TestUtils.TEST_DATA_3; import static io.reist.sklad.TestUtils.TEST_NAME_1; /* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ @RunWith(RobolectricTestRunner.class) @Config( constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP ) public class LimitedStorageTest extends BaseStorageTest<LimitedStorage> { @NonNull @Override protected LimitedStorage createStorage() throws IOException { return createLimitedStorage(new MemoryStorage()); } @NonNull static LimitedStorage createLimitedStorage(JournalingStorage journalingStorage) { return new LimitedStorage( journalingStorage, TEST_DATA_1.length + TEST_DATA_2.length ); } @Test public void testLimit() throws IOException { LimitedStorage storage = createStorage(); saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); saveTestObject(storage, TEST_NAME_2, TEST_DATA_2);
saveTestObject(storage, TEST_NAME_3, TEST_DATA_3);
ragnor-rs/sklad
lib/src/test/java/io/reist/sklad/LimitedStorageTest.java
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_2 = new byte[] {1, 2, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_3 = new byte[] {7, 5, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_2 = "123"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_3 = "qwe"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // }
import static io.reist.sklad.TestUtils.TEST_NAME_2; import static io.reist.sklad.TestUtils.TEST_NAME_3; import static io.reist.sklad.TestUtils.saveTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.io.IOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.TEST_DATA_2; import static io.reist.sklad.TestUtils.TEST_DATA_3; import static io.reist.sklad.TestUtils.TEST_NAME_1;
/* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ @RunWith(RobolectricTestRunner.class) @Config( constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP ) public class LimitedStorageTest extends BaseStorageTest<LimitedStorage> { @NonNull @Override protected LimitedStorage createStorage() throws IOException { return createLimitedStorage(new MemoryStorage()); } @NonNull static LimitedStorage createLimitedStorage(JournalingStorage journalingStorage) { return new LimitedStorage( journalingStorage, TEST_DATA_1.length + TEST_DATA_2.length ); } @Test public void testLimit() throws IOException { LimitedStorage storage = createStorage(); saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); saveTestObject(storage, TEST_NAME_2, TEST_DATA_2);
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_1 = new byte[] {17, 25, 33}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_2 = new byte[] {1, 2, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final byte[] TEST_DATA_3 = new byte[] {7, 5, 3}; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_2 = "123"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_3 = "qwe"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void saveTestObject(Storage storage) throws IOException { // saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); // } // Path: lib/src/test/java/io/reist/sklad/LimitedStorageTest.java import static io.reist.sklad.TestUtils.TEST_NAME_2; import static io.reist.sklad.TestUtils.TEST_NAME_3; import static io.reist.sklad.TestUtils.saveTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import android.os.Build; import android.support.annotation.NonNull; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.io.IOException; import static io.reist.sklad.TestUtils.TEST_DATA_1; import static io.reist.sklad.TestUtils.TEST_DATA_2; import static io.reist.sklad.TestUtils.TEST_DATA_3; import static io.reist.sklad.TestUtils.TEST_NAME_1; /* * Copyright (C) 2017 Renat Sarymsakov. * * 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 io.reist.sklad; /** * Created by Reist on 28.06.16. */ @RunWith(RobolectricTestRunner.class) @Config( constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP ) public class LimitedStorageTest extends BaseStorageTest<LimitedStorage> { @NonNull @Override protected LimitedStorage createStorage() throws IOException { return createLimitedStorage(new MemoryStorage()); } @NonNull static LimitedStorage createLimitedStorage(JournalingStorage journalingStorage) { return new LimitedStorage( journalingStorage, TEST_DATA_1.length + TEST_DATA_2.length ); } @Test public void testLimit() throws IOException { LimitedStorage storage = createStorage(); saveTestObject(storage, TEST_NAME_1, TEST_DATA_1); saveTestObject(storage, TEST_NAME_2, TEST_DATA_2);
saveTestObject(storage, TEST_NAME_3, TEST_DATA_3);
ragnor-rs/sklad
lib/src/test/java/io/reist/sklad/StorageIntegrationTest.java
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void assertTestObject(Storage storage) throws IOException { // assertTestObject(storage, 0); // }
import android.app.Application; import android.support.annotation.NonNull; import org.junit.Test; import org.robolectric.RuntimeEnvironment; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okio.Buffer; import static io.reist.sklad.TestUtils.TEST_NAME_1; import static io.reist.sklad.TestUtils.assertTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.fail;
} @NonNull private CachedStorage createCachedNetworkStorage(File cacheDir) throws IOException { return new CachedStorage( NetworkStorageTest.createNetworkStorage(baseUrl), LimitedStorageTest.createLimitedStorage( XorStorageTest.createXorStorage(cacheDir) ) ); } @Test public void testCachedWithDisabledLimitingStorage() throws IOException { Buffer buffer = new Buffer(); buffer.readFrom(new ByteArrayInputStream(TestUtils.TEST_DATA_1)); MockWebServer server = new MockWebServer(); server.enqueue(new MockResponse().setBody(buffer)); server.enqueue(new MockResponse().setBody(buffer)); server.start(); baseUrl = server.url("/"); CachedStorage cachedStorage = createCachedNetworkStorage(RuntimeEnvironment.application.getCacheDir()); LimitedStorage limitedStorage = (LimitedStorage) cachedStorage.getLocal(); limitedStorage.setCapacity(0); try {
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void assertTestObject(Storage storage) throws IOException { // assertTestObject(storage, 0); // } // Path: lib/src/test/java/io/reist/sklad/StorageIntegrationTest.java import android.app.Application; import android.support.annotation.NonNull; import org.junit.Test; import org.robolectric.RuntimeEnvironment; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okio.Buffer; import static io.reist.sklad.TestUtils.TEST_NAME_1; import static io.reist.sklad.TestUtils.assertTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.fail; } @NonNull private CachedStorage createCachedNetworkStorage(File cacheDir) throws IOException { return new CachedStorage( NetworkStorageTest.createNetworkStorage(baseUrl), LimitedStorageTest.createLimitedStorage( XorStorageTest.createXorStorage(cacheDir) ) ); } @Test public void testCachedWithDisabledLimitingStorage() throws IOException { Buffer buffer = new Buffer(); buffer.readFrom(new ByteArrayInputStream(TestUtils.TEST_DATA_1)); MockWebServer server = new MockWebServer(); server.enqueue(new MockResponse().setBody(buffer)); server.enqueue(new MockResponse().setBody(buffer)); server.start(); baseUrl = server.url("/"); CachedStorage cachedStorage = createCachedNetworkStorage(RuntimeEnvironment.application.getCacheDir()); LimitedStorage limitedStorage = (LimitedStorage) cachedStorage.getLocal(); limitedStorage.setCapacity(0); try {
cachedStorage.cache(TEST_NAME_1);
ragnor-rs/sklad
lib/src/test/java/io/reist/sklad/StorageIntegrationTest.java
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void assertTestObject(Storage storage) throws IOException { // assertTestObject(storage, 0); // }
import android.app.Application; import android.support.annotation.NonNull; import org.junit.Test; import org.robolectric.RuntimeEnvironment; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okio.Buffer; import static io.reist.sklad.TestUtils.TEST_NAME_1; import static io.reist.sklad.TestUtils.assertTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.fail;
return new CachedStorage( NetworkStorageTest.createNetworkStorage(baseUrl), LimitedStorageTest.createLimitedStorage( XorStorageTest.createXorStorage(cacheDir) ) ); } @Test public void testCachedWithDisabledLimitingStorage() throws IOException { Buffer buffer = new Buffer(); buffer.readFrom(new ByteArrayInputStream(TestUtils.TEST_DATA_1)); MockWebServer server = new MockWebServer(); server.enqueue(new MockResponse().setBody(buffer)); server.enqueue(new MockResponse().setBody(buffer)); server.start(); baseUrl = server.url("/"); CachedStorage cachedStorage = createCachedNetworkStorage(RuntimeEnvironment.application.getCacheDir()); LimitedStorage limitedStorage = (LimitedStorage) cachedStorage.getLocal(); limitedStorage.setCapacity(0); try { cachedStorage.cache(TEST_NAME_1); fail(); } catch (IOException ignored) {}
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static final String TEST_NAME_1 = "z12"; // // Path: lib/src/test/java/io/reist/sklad/TestUtils.java // static void assertTestObject(Storage storage) throws IOException { // assertTestObject(storage, 0); // } // Path: lib/src/test/java/io/reist/sklad/StorageIntegrationTest.java import android.app.Application; import android.support.annotation.NonNull; import org.junit.Test; import org.robolectric.RuntimeEnvironment; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okio.Buffer; import static io.reist.sklad.TestUtils.TEST_NAME_1; import static io.reist.sklad.TestUtils.assertTestObject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.fail; return new CachedStorage( NetworkStorageTest.createNetworkStorage(baseUrl), LimitedStorageTest.createLimitedStorage( XorStorageTest.createXorStorage(cacheDir) ) ); } @Test public void testCachedWithDisabledLimitingStorage() throws IOException { Buffer buffer = new Buffer(); buffer.readFrom(new ByteArrayInputStream(TestUtils.TEST_DATA_1)); MockWebServer server = new MockWebServer(); server.enqueue(new MockResponse().setBody(buffer)); server.enqueue(new MockResponse().setBody(buffer)); server.start(); baseUrl = server.url("/"); CachedStorage cachedStorage = createCachedNetworkStorage(RuntimeEnvironment.application.getCacheDir()); LimitedStorage limitedStorage = (LimitedStorage) cachedStorage.getLocal(); limitedStorage.setCapacity(0); try { cachedStorage.cache(TEST_NAME_1); fail(); } catch (IOException ignored) {}
assertTestObject(cachedStorage);
uyjulian/ControlPack
cp1.11/src/main/java/ctrlpack/ControlPackMain.java
// Path: cp1.9/src/main/java/ctrlpack/litemod/LiteModControlPack.java // public class LiteModControlPack implements LiteMod, Tickable, InitCompleteListener { // // @Override // public String getName() { // return "ControlPack"; // } // // @Override // public String getVersion() { // return "5.93-beta2"; // } // // public static void regKeys(KeyBinding[] keyArray) { // for (KeyBinding currentKey : keyArray) { // if (currentKey != null) { // LiteLoader.getInput().registerKeyBinding(currentKey); // } // } // } // // @Override // public void init(File configPath) { // try { // new ControlPackMain(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // @Override // public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) { // if (inGame) { // ControlPackMain.instance.tickInGame(); // } // } // // @Override // public void onInitCompleted(Minecraft minecraft, LiteLoader loader) { // ControlPackMain.instance.postMCInit(); // } // // @Override // public void upgradeSettings(String version, File configPath, File oldConfigPath) {} // // }
import ctrlpack.litemod.LiteModControlPack; import net.minecraft.block.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.resources.I18n; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.*; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult.Type; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.TextComponentString; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.GL11; import java.util.Properties;
/* Copyright (c) 2011-2017 Julian Uy, Dave Reed * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package ctrlpack; public class ControlPackMain implements Runnable { public static ControlPackMain instance; public static Minecraft mc; private int toggleCounter = 10; public ControlPackMain() throws Exception { instance = this; mc = Minecraft.getMinecraft(); keyBindAlternateLeft = new KeyBinding("key.ctrlpack.altleft", Keyboard.KEY_LCONTROL, "ControlPack"); keyBindAlternateRight = new KeyBinding("key.ctrlpack.altright", Keyboard.KEY_GRAVE, "ControlPack"); keyBindToggleSneak = new KeyBinding("key.ctrlpack.toggleSneak", Keyboard.KEY_CAPITAL, "ControlPack"); keyBindToggleRun = new KeyBinding("key.ctrlpack.autoRun", Keyboard.KEY_R, "ControlPack"); keyBindToggleJump = new KeyBinding("key.ctrlpack.autoJump", Keyboard.KEY_J, "ControlPack"); keyBindToggleMine = new KeyBinding("key.ctrlpack.toggleMine", Keyboard.KEY_M, "ControlPack"); keyBindToggleUse = new KeyBinding("key.ctrlpack.toggleUse", Keyboard.KEY_N, "ControlPack"); keyBindWalkDistance = new KeyBinding("key.ctrlpack.walkDistance", Keyboard.KEY_EQUALS, "ControlPack"); keyBindLookBehind = new KeyBinding("key.ctrlpack.lookBehind", 2-100, "ControlPack"); keyBindToggleGamma = new KeyBinding("key.ctrlpack.toggleGamma", Keyboard.KEY_B, "ControlPack"); keyBindTorch = new KeyBinding("key.ctrlpack.placeTorch", Keyboard.KEY_V, "ControlPack"); keyBindEat = new KeyBinding("key.ctrlpack.eatFood", Keyboard.KEY_HOME, "ControlPack"); keyBindWaypoints = new KeyBinding("key.ctrlpack.waypoints", Keyboard.KEY_PERIOD, "ControlPack"); keyBindSayLocation = new KeyBinding("key.ctrlpack.saylocation", Keyboard.KEY_INSERT, "ControlPack"); keyBindings = new KeyBinding[] { keyBindTorch, keyBindAlternateLeft, keyBindAlternateRight, keyBindEat, keyBindToggleSneak, keyBindToggleRun, keyBindToggleJump, keyBindToggleMine, keyBindToggleUse, keyBindWalkDistance, keyBindLookBehind, keyBindToggleGamma, keyBindSayLocation, keyBindWaypoints };
// Path: cp1.9/src/main/java/ctrlpack/litemod/LiteModControlPack.java // public class LiteModControlPack implements LiteMod, Tickable, InitCompleteListener { // // @Override // public String getName() { // return "ControlPack"; // } // // @Override // public String getVersion() { // return "5.93-beta2"; // } // // public static void regKeys(KeyBinding[] keyArray) { // for (KeyBinding currentKey : keyArray) { // if (currentKey != null) { // LiteLoader.getInput().registerKeyBinding(currentKey); // } // } // } // // @Override // public void init(File configPath) { // try { // new ControlPackMain(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // @Override // public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) { // if (inGame) { // ControlPackMain.instance.tickInGame(); // } // } // // @Override // public void onInitCompleted(Minecraft minecraft, LiteLoader loader) { // ControlPackMain.instance.postMCInit(); // } // // @Override // public void upgradeSettings(String version, File configPath, File oldConfigPath) {} // // } // Path: cp1.11/src/main/java/ctrlpack/ControlPackMain.java import ctrlpack.litemod.LiteModControlPack; import net.minecraft.block.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.resources.I18n; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.*; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult.Type; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.TextComponentString; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.GL11; import java.util.Properties; /* Copyright (c) 2011-2017 Julian Uy, Dave Reed * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package ctrlpack; public class ControlPackMain implements Runnable { public static ControlPackMain instance; public static Minecraft mc; private int toggleCounter = 10; public ControlPackMain() throws Exception { instance = this; mc = Minecraft.getMinecraft(); keyBindAlternateLeft = new KeyBinding("key.ctrlpack.altleft", Keyboard.KEY_LCONTROL, "ControlPack"); keyBindAlternateRight = new KeyBinding("key.ctrlpack.altright", Keyboard.KEY_GRAVE, "ControlPack"); keyBindToggleSneak = new KeyBinding("key.ctrlpack.toggleSneak", Keyboard.KEY_CAPITAL, "ControlPack"); keyBindToggleRun = new KeyBinding("key.ctrlpack.autoRun", Keyboard.KEY_R, "ControlPack"); keyBindToggleJump = new KeyBinding("key.ctrlpack.autoJump", Keyboard.KEY_J, "ControlPack"); keyBindToggleMine = new KeyBinding("key.ctrlpack.toggleMine", Keyboard.KEY_M, "ControlPack"); keyBindToggleUse = new KeyBinding("key.ctrlpack.toggleUse", Keyboard.KEY_N, "ControlPack"); keyBindWalkDistance = new KeyBinding("key.ctrlpack.walkDistance", Keyboard.KEY_EQUALS, "ControlPack"); keyBindLookBehind = new KeyBinding("key.ctrlpack.lookBehind", 2-100, "ControlPack"); keyBindToggleGamma = new KeyBinding("key.ctrlpack.toggleGamma", Keyboard.KEY_B, "ControlPack"); keyBindTorch = new KeyBinding("key.ctrlpack.placeTorch", Keyboard.KEY_V, "ControlPack"); keyBindEat = new KeyBinding("key.ctrlpack.eatFood", Keyboard.KEY_HOME, "ControlPack"); keyBindWaypoints = new KeyBinding("key.ctrlpack.waypoints", Keyboard.KEY_PERIOD, "ControlPack"); keyBindSayLocation = new KeyBinding("key.ctrlpack.saylocation", Keyboard.KEY_INSERT, "ControlPack"); keyBindings = new KeyBinding[] { keyBindTorch, keyBindAlternateLeft, keyBindAlternateRight, keyBindEat, keyBindToggleSneak, keyBindToggleRun, keyBindToggleJump, keyBindToggleMine, keyBindToggleUse, keyBindWalkDistance, keyBindLookBehind, keyBindToggleGamma, keyBindSayLocation, keyBindWaypoints };
LiteModControlPack.regKeys(keyBindings);
uyjulian/ControlPack
cp1.9/src/main/java/ctrlpack/ControlPackMain.java
// Path: cp1.9/src/main/java/ctrlpack/litemod/LiteModControlPack.java // public class LiteModControlPack implements LiteMod, Tickable, InitCompleteListener { // // @Override // public String getName() { // return "ControlPack"; // } // // @Override // public String getVersion() { // return "5.93-beta2"; // } // // public static void regKeys(KeyBinding[] keyArray) { // for (KeyBinding currentKey : keyArray) { // if (currentKey != null) { // LiteLoader.getInput().registerKeyBinding(currentKey); // } // } // } // // @Override // public void init(File configPath) { // try { // new ControlPackMain(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // @Override // public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) { // if (inGame) { // ControlPackMain.instance.tickInGame(); // } // } // // @Override // public void onInitCompleted(Minecraft minecraft, LiteLoader loader) { // ControlPackMain.instance.postMCInit(); // } // // @Override // public void upgradeSettings(String version, File configPath, File oldConfigPath) {} // // }
import ctrlpack.litemod.LiteModControlPack; import net.minecraft.block.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.resources.I18n; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.*; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult.Type; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.TextComponentString; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.GL11; import java.util.Properties;
/* Copyright (c) 2011-2017 Julian Uy, Dave Reed * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package ctrlpack; public class ControlPackMain implements Runnable { public static ControlPackMain instance; public static Minecraft mc; private int toggleCounter = 10; public ControlPackMain() throws Exception { instance = this; mc = Minecraft.getMinecraft(); keyBindAlternateLeft = new KeyBinding("key.ctrlpack.altleft", Keyboard.KEY_LCONTROL, "ControlPack"); keyBindAlternateRight = new KeyBinding("key.ctrlpack.altright", Keyboard.KEY_GRAVE, "ControlPack"); keyBindToggleSneak = new KeyBinding("key.ctrlpack.toggleSneak", Keyboard.KEY_CAPITAL, "ControlPack"); keyBindToggleRun = new KeyBinding("key.ctrlpack.autoRun", Keyboard.KEY_R, "ControlPack"); keyBindToggleJump = new KeyBinding("key.ctrlpack.autoJump", Keyboard.KEY_J, "ControlPack"); keyBindToggleMine = new KeyBinding("key.ctrlpack.toggleMine", Keyboard.KEY_M, "ControlPack"); keyBindToggleUse = new KeyBinding("key.ctrlpack.toggleUse", Keyboard.KEY_N, "ControlPack"); keyBindWalkDistance = new KeyBinding("key.ctrlpack.walkDistance", Keyboard.KEY_EQUALS, "ControlPack"); keyBindLookBehind = new KeyBinding("key.ctrlpack.lookBehind", 2-100, "ControlPack"); keyBindToggleGamma = new KeyBinding("key.ctrlpack.toggleGamma", Keyboard.KEY_B, "ControlPack"); keyBindTorch = new KeyBinding("key.ctrlpack.placeTorch", Keyboard.KEY_V, "ControlPack"); keyBindEat = new KeyBinding("key.ctrlpack.eatFood", Keyboard.KEY_HOME, "ControlPack"); keyBindWaypoints = new KeyBinding("key.ctrlpack.waypoints", Keyboard.KEY_PERIOD, "ControlPack"); keyBindSayLocation = new KeyBinding("key.ctrlpack.saylocation", Keyboard.KEY_INSERT, "ControlPack"); keyBindings = new KeyBinding[] { keyBindTorch, keyBindAlternateLeft, keyBindAlternateRight, keyBindEat, keyBindToggleSneak, keyBindToggleRun, keyBindToggleJump, keyBindToggleMine, keyBindToggleUse, keyBindWalkDistance, keyBindLookBehind, keyBindToggleGamma, keyBindSayLocation, keyBindWaypoints };
// Path: cp1.9/src/main/java/ctrlpack/litemod/LiteModControlPack.java // public class LiteModControlPack implements LiteMod, Tickable, InitCompleteListener { // // @Override // public String getName() { // return "ControlPack"; // } // // @Override // public String getVersion() { // return "5.93-beta2"; // } // // public static void regKeys(KeyBinding[] keyArray) { // for (KeyBinding currentKey : keyArray) { // if (currentKey != null) { // LiteLoader.getInput().registerKeyBinding(currentKey); // } // } // } // // @Override // public void init(File configPath) { // try { // new ControlPackMain(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // @Override // public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) { // if (inGame) { // ControlPackMain.instance.tickInGame(); // } // } // // @Override // public void onInitCompleted(Minecraft minecraft, LiteLoader loader) { // ControlPackMain.instance.postMCInit(); // } // // @Override // public void upgradeSettings(String version, File configPath, File oldConfigPath) {} // // } // Path: cp1.9/src/main/java/ctrlpack/ControlPackMain.java import ctrlpack.litemod.LiteModControlPack; import net.minecraft.block.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.resources.I18n; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.*; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult.Type; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.TextComponentString; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.GL11; import java.util.Properties; /* Copyright (c) 2011-2017 Julian Uy, Dave Reed * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package ctrlpack; public class ControlPackMain implements Runnable { public static ControlPackMain instance; public static Minecraft mc; private int toggleCounter = 10; public ControlPackMain() throws Exception { instance = this; mc = Minecraft.getMinecraft(); keyBindAlternateLeft = new KeyBinding("key.ctrlpack.altleft", Keyboard.KEY_LCONTROL, "ControlPack"); keyBindAlternateRight = new KeyBinding("key.ctrlpack.altright", Keyboard.KEY_GRAVE, "ControlPack"); keyBindToggleSneak = new KeyBinding("key.ctrlpack.toggleSneak", Keyboard.KEY_CAPITAL, "ControlPack"); keyBindToggleRun = new KeyBinding("key.ctrlpack.autoRun", Keyboard.KEY_R, "ControlPack"); keyBindToggleJump = new KeyBinding("key.ctrlpack.autoJump", Keyboard.KEY_J, "ControlPack"); keyBindToggleMine = new KeyBinding("key.ctrlpack.toggleMine", Keyboard.KEY_M, "ControlPack"); keyBindToggleUse = new KeyBinding("key.ctrlpack.toggleUse", Keyboard.KEY_N, "ControlPack"); keyBindWalkDistance = new KeyBinding("key.ctrlpack.walkDistance", Keyboard.KEY_EQUALS, "ControlPack"); keyBindLookBehind = new KeyBinding("key.ctrlpack.lookBehind", 2-100, "ControlPack"); keyBindToggleGamma = new KeyBinding("key.ctrlpack.toggleGamma", Keyboard.KEY_B, "ControlPack"); keyBindTorch = new KeyBinding("key.ctrlpack.placeTorch", Keyboard.KEY_V, "ControlPack"); keyBindEat = new KeyBinding("key.ctrlpack.eatFood", Keyboard.KEY_HOME, "ControlPack"); keyBindWaypoints = new KeyBinding("key.ctrlpack.waypoints", Keyboard.KEY_PERIOD, "ControlPack"); keyBindSayLocation = new KeyBinding("key.ctrlpack.saylocation", Keyboard.KEY_INSERT, "ControlPack"); keyBindings = new KeyBinding[] { keyBindTorch, keyBindAlternateLeft, keyBindAlternateRight, keyBindEat, keyBindToggleSneak, keyBindToggleRun, keyBindToggleJump, keyBindToggleMine, keyBindToggleUse, keyBindWalkDistance, keyBindLookBehind, keyBindToggleGamma, keyBindSayLocation, keyBindWaypoints };
LiteModControlPack.regKeys(keyBindings);
uyjulian/ControlPack
cp1.8.9/src/main/java/ctrlpack/ControlPackMain.java
// Path: cp1.9/src/main/java/ctrlpack/litemod/LiteModControlPack.java // public class LiteModControlPack implements LiteMod, Tickable, InitCompleteListener { // // @Override // public String getName() { // return "ControlPack"; // } // // @Override // public String getVersion() { // return "5.93-beta2"; // } // // public static void regKeys(KeyBinding[] keyArray) { // for (KeyBinding currentKey : keyArray) { // if (currentKey != null) { // LiteLoader.getInput().registerKeyBinding(currentKey); // } // } // } // // @Override // public void init(File configPath) { // try { // new ControlPackMain(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // @Override // public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) { // if (inGame) { // ControlPackMain.instance.tickInGame(); // } // } // // @Override // public void onInitCompleted(Minecraft minecraft, LiteLoader loader) { // ControlPackMain.instance.postMCInit(); // } // // @Override // public void upgradeSettings(String version, File configPath, File oldConfigPath) {} // // }
import ctrlpack.litemod.LiteModControlPack; import net.minecraft.block.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.resources.I18n; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.*; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.MovingObjectPosition.MovingObjectType; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Vec3; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.GL11; import java.util.Properties;
/* Copyright (c) 2011-2017 Julian Uy, Dave Reed * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package ctrlpack; public class ControlPackMain implements Runnable { public static ControlPackMain instance; public static Minecraft mc; private int toggleCounter = 10; public ControlPackMain() throws Exception { instance = this; mc = Minecraft.getMinecraft(); keyBindAlternateLeft = new KeyBinding("key.ctrlpack.altleft", Keyboard.KEY_LCONTROL, "ControlPack"); keyBindAlternateRight = new KeyBinding("key.ctrlpack.altright", Keyboard.KEY_GRAVE, "ControlPack"); keyBindToggleSneak = new KeyBinding("key.ctrlpack.toggleSneak", Keyboard.KEY_CAPITAL, "ControlPack"); keyBindToggleRun = new KeyBinding("key.ctrlpack.autoRun", Keyboard.KEY_R, "ControlPack"); keyBindToggleJump = new KeyBinding("key.ctrlpack.autoJump", Keyboard.KEY_J, "ControlPack"); keyBindToggleMine = new KeyBinding("key.ctrlpack.toggleMine", Keyboard.KEY_M, "ControlPack"); keyBindToggleUse = new KeyBinding("key.ctrlpack.toggleUse", Keyboard.KEY_N, "ControlPack"); keyBindWalkDistance = new KeyBinding("key.ctrlpack.walkDistance", Keyboard.KEY_EQUALS, "ControlPack"); keyBindLookBehind = new KeyBinding("key.ctrlpack.lookBehind", 2-100, "ControlPack"); keyBindToggleGamma = new KeyBinding("key.ctrlpack.toggleGamma", Keyboard.KEY_B, "ControlPack"); keyBindTorch = new KeyBinding("key.ctrlpack.placeTorch", Keyboard.KEY_V, "ControlPack"); keyBindEat = new KeyBinding("key.ctrlpack.eatFood", Keyboard.KEY_HOME, "ControlPack"); keyBindWaypoints = new KeyBinding("key.ctrlpack.waypoints", Keyboard.KEY_PERIOD, "ControlPack"); keyBindSayLocation = new KeyBinding("key.ctrlpack.saylocation", Keyboard.KEY_INSERT, "ControlPack"); keyBindings = new KeyBinding[] { keyBindTorch, keyBindAlternateLeft, keyBindAlternateRight, keyBindEat, keyBindToggleSneak, keyBindToggleRun, keyBindToggleJump, keyBindToggleMine, keyBindToggleUse, keyBindWalkDistance, keyBindLookBehind, keyBindToggleGamma, keyBindSayLocation, keyBindWaypoints };
// Path: cp1.9/src/main/java/ctrlpack/litemod/LiteModControlPack.java // public class LiteModControlPack implements LiteMod, Tickable, InitCompleteListener { // // @Override // public String getName() { // return "ControlPack"; // } // // @Override // public String getVersion() { // return "5.93-beta2"; // } // // public static void regKeys(KeyBinding[] keyArray) { // for (KeyBinding currentKey : keyArray) { // if (currentKey != null) { // LiteLoader.getInput().registerKeyBinding(currentKey); // } // } // } // // @Override // public void init(File configPath) { // try { // new ControlPackMain(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // @Override // public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) { // if (inGame) { // ControlPackMain.instance.tickInGame(); // } // } // // @Override // public void onInitCompleted(Minecraft minecraft, LiteLoader loader) { // ControlPackMain.instance.postMCInit(); // } // // @Override // public void upgradeSettings(String version, File configPath, File oldConfigPath) {} // // } // Path: cp1.8.9/src/main/java/ctrlpack/ControlPackMain.java import ctrlpack.litemod.LiteModControlPack; import net.minecraft.block.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.resources.I18n; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.*; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.MovingObjectPosition.MovingObjectType; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Vec3; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.GL11; import java.util.Properties; /* Copyright (c) 2011-2017 Julian Uy, Dave Reed * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package ctrlpack; public class ControlPackMain implements Runnable { public static ControlPackMain instance; public static Minecraft mc; private int toggleCounter = 10; public ControlPackMain() throws Exception { instance = this; mc = Minecraft.getMinecraft(); keyBindAlternateLeft = new KeyBinding("key.ctrlpack.altleft", Keyboard.KEY_LCONTROL, "ControlPack"); keyBindAlternateRight = new KeyBinding("key.ctrlpack.altright", Keyboard.KEY_GRAVE, "ControlPack"); keyBindToggleSneak = new KeyBinding("key.ctrlpack.toggleSneak", Keyboard.KEY_CAPITAL, "ControlPack"); keyBindToggleRun = new KeyBinding("key.ctrlpack.autoRun", Keyboard.KEY_R, "ControlPack"); keyBindToggleJump = new KeyBinding("key.ctrlpack.autoJump", Keyboard.KEY_J, "ControlPack"); keyBindToggleMine = new KeyBinding("key.ctrlpack.toggleMine", Keyboard.KEY_M, "ControlPack"); keyBindToggleUse = new KeyBinding("key.ctrlpack.toggleUse", Keyboard.KEY_N, "ControlPack"); keyBindWalkDistance = new KeyBinding("key.ctrlpack.walkDistance", Keyboard.KEY_EQUALS, "ControlPack"); keyBindLookBehind = new KeyBinding("key.ctrlpack.lookBehind", 2-100, "ControlPack"); keyBindToggleGamma = new KeyBinding("key.ctrlpack.toggleGamma", Keyboard.KEY_B, "ControlPack"); keyBindTorch = new KeyBinding("key.ctrlpack.placeTorch", Keyboard.KEY_V, "ControlPack"); keyBindEat = new KeyBinding("key.ctrlpack.eatFood", Keyboard.KEY_HOME, "ControlPack"); keyBindWaypoints = new KeyBinding("key.ctrlpack.waypoints", Keyboard.KEY_PERIOD, "ControlPack"); keyBindSayLocation = new KeyBinding("key.ctrlpack.saylocation", Keyboard.KEY_INSERT, "ControlPack"); keyBindings = new KeyBinding[] { keyBindTorch, keyBindAlternateLeft, keyBindAlternateRight, keyBindEat, keyBindToggleSneak, keyBindToggleRun, keyBindToggleJump, keyBindToggleMine, keyBindToggleUse, keyBindWalkDistance, keyBindLookBehind, keyBindToggleGamma, keyBindSayLocation, keyBindWaypoints };
LiteModControlPack.regKeys(keyBindings);
alabeduarte/mypodcasts-android
app/src/test/java/com/mypodcasts/FeedsAdapterTest.java
// Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // }
import android.app.Activity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.mypodcasts.repositories.models.Feed; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.util.List; import static java.lang.String.valueOf; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.robolectric.Robolectric.buildActivity;
package com.mypodcasts; @RunWith(RobolectricTestRunner.class) @Config(constants = BuildConfig.class) public class FeedsAdapterTest { LayoutInflater spiedLayoutInflater; View recycledView; ViewGroup parent; int firstPosition = 0; @Before public void setup() { Activity context = buildActivity(Activity.class).create().get(); spiedLayoutInflater = spy(context.getLayoutInflater()); recycledView = null; parent = new ViewGroup(context) { @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { } }; }
// Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // Path: app/src/test/java/com/mypodcasts/FeedsAdapterTest.java import android.app.Activity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.mypodcasts.repositories.models.Feed; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.util.List; import static java.lang.String.valueOf; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.robolectric.Robolectric.buildActivity; package com.mypodcasts; @RunWith(RobolectricTestRunner.class) @Config(constants = BuildConfig.class) public class FeedsAdapterTest { LayoutInflater spiedLayoutInflater; View recycledView; ViewGroup parent; int firstPosition = 0; @Before public void setup() { Activity context = buildActivity(Activity.class).create().get(); spiedLayoutInflater = spy(context.getLayoutInflater()); recycledView = null; parent = new ViewGroup(context) { @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { } }; }
private FeedsAdapter givenAdapaterWith(List<Feed> feeds) {
alabeduarte/mypodcasts-android
app/src/test/java/com/mypodcasts/util/FeedHelper.java
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Image.java // public class Image implements Serializable { // private String url; // // public String getUrl() { // return url; // } // }
import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; import com.mypodcasts.repositories.models.Image; import java.util.Collections; import java.util.List;
package com.mypodcasts.util; public class FeedHelper { public static Feed aFeed(final String title) {
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Image.java // public class Image implements Serializable { // private String url; // // public String getUrl() { // return url; // } // } // Path: app/src/test/java/com/mypodcasts/util/FeedHelper.java import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; import com.mypodcasts.repositories.models.Image; import java.util.Collections; import java.util.List; package com.mypodcasts.util; public class FeedHelper { public static Feed aFeed(final String title) {
return aFeed(title, Collections.<Episode>emptyList());
alabeduarte/mypodcasts-android
app/src/test/java/com/mypodcasts/util/FeedHelper.java
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Image.java // public class Image implements Serializable { // private String url; // // public String getUrl() { // return url; // } // }
import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; import com.mypodcasts.repositories.models.Image; import java.util.Collections; import java.util.List;
package com.mypodcasts.util; public class FeedHelper { public static Feed aFeed(final String title) { return aFeed(title, Collections.<Episode>emptyList()); } public static Feed aFeedWith(final List<Episode> episodes) { return aFeed(null, episodes); } public static Feed aFeed() { return aFeed("Awesome Podcast"); } public static Feed aFeed(final String title, final List<Episode> episodes) { return new Feed() { @Override public String getId() { return "123"; } @Override
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Image.java // public class Image implements Serializable { // private String url; // // public String getUrl() { // return url; // } // } // Path: app/src/test/java/com/mypodcasts/util/FeedHelper.java import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; import com.mypodcasts.repositories.models.Image; import java.util.Collections; import java.util.List; package com.mypodcasts.util; public class FeedHelper { public static Feed aFeed(final String title) { return aFeed(title, Collections.<Episode>emptyList()); } public static Feed aFeedWith(final List<Episode> episodes) { return aFeed(null, episodes); } public static Feed aFeed() { return aFeed("Awesome Podcast"); } public static Feed aFeed(final String title, final List<Episode> episodes) { return new Feed() { @Override public String getId() { return "123"; } @Override
public Image getImage() {
alabeduarte/mypodcasts-android
app/src/main/java/com/mypodcasts/player/AudioPlayer.java
// Path: app/src/main/java/com/mypodcasts/episodes/EpisodeFile.java // public class EpisodeFile { // private final ExternalPublicFileLookup externalPublicFileLookup; // // @Inject // public EpisodeFile(ExternalPublicFileLookup externalPublicFileLookup) { // this.externalPublicFileLookup = externalPublicFileLookup; // } // // public boolean exists(Episode episode) { // return externalPublicFileLookup.exists( // getExternalStoragePublicDirectory(getPodcastsDirectory()), // episode.getAudioFilePath() // ); // } // // public String getAudioFilePath(Episode episode) { // if (exists(episode)) { // return format( // "%s/%s", // getExternalStoragePublicDirectory(getPodcastsDirectory()), // episode.getAudioFilePath() // ); // } // // return episode.getAudioUrl(); // } // // public String getPodcastsDirectory() { // return DIRECTORY_PODCASTS; // } // } // // Path: app/src/main/java/com/mypodcasts/player/events/AudioPlayingEvent.java // public class AudioPlayingEvent { // private final AudioPlayer audioPlayer; // // public AudioPlayingEvent(AudioPlayer audioPlayer) { // this.audioPlayer = audioPlayer; // } // // public AudioPlayer getAudioPlayer() { // return audioPlayer; // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // }
import android.media.MediaPlayer; import android.media.MediaPlayer.OnPreparedListener; import android.widget.MediaController.MediaPlayerControl; import com.mypodcasts.episodes.EpisodeFile; import com.mypodcasts.player.events.AudioPlayingEvent; import com.mypodcasts.repositories.models.Episode; import java.io.IOException; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import static android.media.AudioManager.STREAM_MUSIC;
package com.mypodcasts.player; public class AudioPlayer implements MediaPlayerControl, OnPreparedListener { private final MediaPlayer mediaPlayer; private final EventBus eventBus;
// Path: app/src/main/java/com/mypodcasts/episodes/EpisodeFile.java // public class EpisodeFile { // private final ExternalPublicFileLookup externalPublicFileLookup; // // @Inject // public EpisodeFile(ExternalPublicFileLookup externalPublicFileLookup) { // this.externalPublicFileLookup = externalPublicFileLookup; // } // // public boolean exists(Episode episode) { // return externalPublicFileLookup.exists( // getExternalStoragePublicDirectory(getPodcastsDirectory()), // episode.getAudioFilePath() // ); // } // // public String getAudioFilePath(Episode episode) { // if (exists(episode)) { // return format( // "%s/%s", // getExternalStoragePublicDirectory(getPodcastsDirectory()), // episode.getAudioFilePath() // ); // } // // return episode.getAudioUrl(); // } // // public String getPodcastsDirectory() { // return DIRECTORY_PODCASTS; // } // } // // Path: app/src/main/java/com/mypodcasts/player/events/AudioPlayingEvent.java // public class AudioPlayingEvent { // private final AudioPlayer audioPlayer; // // public AudioPlayingEvent(AudioPlayer audioPlayer) { // this.audioPlayer = audioPlayer; // } // // public AudioPlayer getAudioPlayer() { // return audioPlayer; // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // Path: app/src/main/java/com/mypodcasts/player/AudioPlayer.java import android.media.MediaPlayer; import android.media.MediaPlayer.OnPreparedListener; import android.widget.MediaController.MediaPlayerControl; import com.mypodcasts.episodes.EpisodeFile; import com.mypodcasts.player.events.AudioPlayingEvent; import com.mypodcasts.repositories.models.Episode; import java.io.IOException; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import static android.media.AudioManager.STREAM_MUSIC; package com.mypodcasts.player; public class AudioPlayer implements MediaPlayerControl, OnPreparedListener { private final MediaPlayer mediaPlayer; private final EventBus eventBus;
private final EpisodeFile episodeFile;
alabeduarte/mypodcasts-android
app/src/main/java/com/mypodcasts/player/AudioPlayer.java
// Path: app/src/main/java/com/mypodcasts/episodes/EpisodeFile.java // public class EpisodeFile { // private final ExternalPublicFileLookup externalPublicFileLookup; // // @Inject // public EpisodeFile(ExternalPublicFileLookup externalPublicFileLookup) { // this.externalPublicFileLookup = externalPublicFileLookup; // } // // public boolean exists(Episode episode) { // return externalPublicFileLookup.exists( // getExternalStoragePublicDirectory(getPodcastsDirectory()), // episode.getAudioFilePath() // ); // } // // public String getAudioFilePath(Episode episode) { // if (exists(episode)) { // return format( // "%s/%s", // getExternalStoragePublicDirectory(getPodcastsDirectory()), // episode.getAudioFilePath() // ); // } // // return episode.getAudioUrl(); // } // // public String getPodcastsDirectory() { // return DIRECTORY_PODCASTS; // } // } // // Path: app/src/main/java/com/mypodcasts/player/events/AudioPlayingEvent.java // public class AudioPlayingEvent { // private final AudioPlayer audioPlayer; // // public AudioPlayingEvent(AudioPlayer audioPlayer) { // this.audioPlayer = audioPlayer; // } // // public AudioPlayer getAudioPlayer() { // return audioPlayer; // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // }
import android.media.MediaPlayer; import android.media.MediaPlayer.OnPreparedListener; import android.widget.MediaController.MediaPlayerControl; import com.mypodcasts.episodes.EpisodeFile; import com.mypodcasts.player.events.AudioPlayingEvent; import com.mypodcasts.repositories.models.Episode; import java.io.IOException; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import static android.media.AudioManager.STREAM_MUSIC;
package com.mypodcasts.player; public class AudioPlayer implements MediaPlayerControl, OnPreparedListener { private final MediaPlayer mediaPlayer; private final EventBus eventBus; private final EpisodeFile episodeFile; @Inject public AudioPlayer(MediaPlayer mediaPlayer, EventBus eventBus, EpisodeFile episodeFile) { this.mediaPlayer = mediaPlayer; this.eventBus = eventBus; this.episodeFile = episodeFile; }
// Path: app/src/main/java/com/mypodcasts/episodes/EpisodeFile.java // public class EpisodeFile { // private final ExternalPublicFileLookup externalPublicFileLookup; // // @Inject // public EpisodeFile(ExternalPublicFileLookup externalPublicFileLookup) { // this.externalPublicFileLookup = externalPublicFileLookup; // } // // public boolean exists(Episode episode) { // return externalPublicFileLookup.exists( // getExternalStoragePublicDirectory(getPodcastsDirectory()), // episode.getAudioFilePath() // ); // } // // public String getAudioFilePath(Episode episode) { // if (exists(episode)) { // return format( // "%s/%s", // getExternalStoragePublicDirectory(getPodcastsDirectory()), // episode.getAudioFilePath() // ); // } // // return episode.getAudioUrl(); // } // // public String getPodcastsDirectory() { // return DIRECTORY_PODCASTS; // } // } // // Path: app/src/main/java/com/mypodcasts/player/events/AudioPlayingEvent.java // public class AudioPlayingEvent { // private final AudioPlayer audioPlayer; // // public AudioPlayingEvent(AudioPlayer audioPlayer) { // this.audioPlayer = audioPlayer; // } // // public AudioPlayer getAudioPlayer() { // return audioPlayer; // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // Path: app/src/main/java/com/mypodcasts/player/AudioPlayer.java import android.media.MediaPlayer; import android.media.MediaPlayer.OnPreparedListener; import android.widget.MediaController.MediaPlayerControl; import com.mypodcasts.episodes.EpisodeFile; import com.mypodcasts.player.events.AudioPlayingEvent; import com.mypodcasts.repositories.models.Episode; import java.io.IOException; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import static android.media.AudioManager.STREAM_MUSIC; package com.mypodcasts.player; public class AudioPlayer implements MediaPlayerControl, OnPreparedListener { private final MediaPlayer mediaPlayer; private final EventBus eventBus; private final EpisodeFile episodeFile; @Inject public AudioPlayer(MediaPlayer mediaPlayer, EventBus eventBus, EpisodeFile episodeFile) { this.mediaPlayer = mediaPlayer; this.eventBus = eventBus; this.episodeFile = episodeFile; }
public MediaPlayer play(Episode episode) throws IOException {
alabeduarte/mypodcasts-android
app/src/main/java/com/mypodcasts/player/AudioPlayer.java
// Path: app/src/main/java/com/mypodcasts/episodes/EpisodeFile.java // public class EpisodeFile { // private final ExternalPublicFileLookup externalPublicFileLookup; // // @Inject // public EpisodeFile(ExternalPublicFileLookup externalPublicFileLookup) { // this.externalPublicFileLookup = externalPublicFileLookup; // } // // public boolean exists(Episode episode) { // return externalPublicFileLookup.exists( // getExternalStoragePublicDirectory(getPodcastsDirectory()), // episode.getAudioFilePath() // ); // } // // public String getAudioFilePath(Episode episode) { // if (exists(episode)) { // return format( // "%s/%s", // getExternalStoragePublicDirectory(getPodcastsDirectory()), // episode.getAudioFilePath() // ); // } // // return episode.getAudioUrl(); // } // // public String getPodcastsDirectory() { // return DIRECTORY_PODCASTS; // } // } // // Path: app/src/main/java/com/mypodcasts/player/events/AudioPlayingEvent.java // public class AudioPlayingEvent { // private final AudioPlayer audioPlayer; // // public AudioPlayingEvent(AudioPlayer audioPlayer) { // this.audioPlayer = audioPlayer; // } // // public AudioPlayer getAudioPlayer() { // return audioPlayer; // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // }
import android.media.MediaPlayer; import android.media.MediaPlayer.OnPreparedListener; import android.widget.MediaController.MediaPlayerControl; import com.mypodcasts.episodes.EpisodeFile; import com.mypodcasts.player.events.AudioPlayingEvent; import com.mypodcasts.repositories.models.Episode; import java.io.IOException; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import static android.media.AudioManager.STREAM_MUSIC;
@Override public int getBufferPercentage() { return 0; } @Override public boolean canPause() { return true; } @Override public boolean canSeekBackward() { return true; } @Override public boolean canSeekForward() { return true; } @Override public int getAudioSessionId() { return mediaPlayer.getAudioSessionId(); } @Override public void onPrepared(MediaPlayer mediaPlayer) { mediaPlayer.start();
// Path: app/src/main/java/com/mypodcasts/episodes/EpisodeFile.java // public class EpisodeFile { // private final ExternalPublicFileLookup externalPublicFileLookup; // // @Inject // public EpisodeFile(ExternalPublicFileLookup externalPublicFileLookup) { // this.externalPublicFileLookup = externalPublicFileLookup; // } // // public boolean exists(Episode episode) { // return externalPublicFileLookup.exists( // getExternalStoragePublicDirectory(getPodcastsDirectory()), // episode.getAudioFilePath() // ); // } // // public String getAudioFilePath(Episode episode) { // if (exists(episode)) { // return format( // "%s/%s", // getExternalStoragePublicDirectory(getPodcastsDirectory()), // episode.getAudioFilePath() // ); // } // // return episode.getAudioUrl(); // } // // public String getPodcastsDirectory() { // return DIRECTORY_PODCASTS; // } // } // // Path: app/src/main/java/com/mypodcasts/player/events/AudioPlayingEvent.java // public class AudioPlayingEvent { // private final AudioPlayer audioPlayer; // // public AudioPlayingEvent(AudioPlayer audioPlayer) { // this.audioPlayer = audioPlayer; // } // // public AudioPlayer getAudioPlayer() { // return audioPlayer; // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // Path: app/src/main/java/com/mypodcasts/player/AudioPlayer.java import android.media.MediaPlayer; import android.media.MediaPlayer.OnPreparedListener; import android.widget.MediaController.MediaPlayerControl; import com.mypodcasts.episodes.EpisodeFile; import com.mypodcasts.player.events.AudioPlayingEvent; import com.mypodcasts.repositories.models.Episode; import java.io.IOException; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import static android.media.AudioManager.STREAM_MUSIC; @Override public int getBufferPercentage() { return 0; } @Override public boolean canPause() { return true; } @Override public boolean canSeekBackward() { return true; } @Override public boolean canSeekForward() { return true; } @Override public int getAudioSessionId() { return mediaPlayer.getAudioSessionId(); } @Override public void onPrepared(MediaPlayer mediaPlayer) { mediaPlayer.start();
eventBus.post(new AudioPlayingEvent(this));
alabeduarte/mypodcasts-android
app/src/test/java/com/mypodcasts/MyPodcastsActivityTest.java
// Path: app/src/main/java/com/mypodcasts/episodes/EpisodeFeedsActivity.java // public class EpisodeFeedsActivity extends MyPodcastsActivity { // // @Inject // private FragmentManager fragmentManager; // // @Inject // private Bundle arguments; // // @Inject // private EpisodeListFragment episodeListFragment; // // @Inject // private ProgressDialog progressDialog; // // @Inject // private UserFeedsRepository userFeedsRepository; // private FeedEpisodesAsyncTask feedEpisodesAsyncTask; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // Feed feed = (Feed) getIntent().getSerializableExtra(Feed.class.toString()); // // feedEpisodesAsyncTask = new FeedEpisodesAsyncTask(this, feed); // // feedEpisodesAsyncTask.execute(); // } // // @Override // protected void onPause() { // super.onPause(); // // feedEpisodesAsyncTask.cancel(); // } // // @Override // protected void onDestroy() { // dismissProgressDialog(); // // super.onDestroy(); // } // // private void showProgressDialog(String feedTitle) { // progressDialog.setIndeterminate(false); // progressDialog.setCancelable(false); // progressDialog.show(); // progressDialog.setMessage(format( // getResources().getString(R.string.loading_feed_episodes), feedTitle // )); // } // // private void dismissProgressDialog() { // if (progressDialog != null && progressDialog.isShowing()) { // progressDialog.dismiss(); // } // } // // class FeedEpisodesAsyncTask extends RetryableAsyncTask<Void, Void, Feed> { // private final Activity activity; // private final Feed feed; // // public FeedEpisodesAsyncTask(Activity activity, Feed feed) { // super(activity); // // this.activity = activity; // this.feed = feed; // } // // @Override // protected void onPreExecute() { // showProgressDialog(feed.getTitle()); // } // // @Override // protected Feed doInBackground(Void... params) { // return userFeedsRepository.getFeed(feed.getId()); // } // // @Override // protected void onPostExecute(Feed feed) { // if (this.activity.isDestroyed()) return; // // dismissProgressDialog(); // // arguments.putSerializable( // EpisodeList.HEADER, // new EpisodeListHeaderInfo(feed.getTitle(), feed.getImage()) // ); // // arguments.putSerializable( // EpisodeList.LIST, // new EpisodeList(feed.getEpisodes()) // ); // // episodeListFragment.setArguments(arguments); // // fragmentManager.beginTransaction() // .replace(R.id.content_frame, episodeListFragment) // .commitAllowingStateLoss(); // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/UserFeedsRepository.java // public class UserFeedsRepository { // // private final HttpClient httpClient; // // @Inject // public UserFeedsRepository(HttpClient httpClient) { // this.httpClient = httpClient; // } // // public List<Feed> getFeeds() { // return httpClient.getApi().getUserFeeds(); // } // // public Feed getFeed(String id) { // return httpClient.getApi().getFeed(id); // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/test/java/com/mypodcasts/util/FeedHelper.java // public static Feed aFeed(final String title) { // return aFeed(title, Collections.<Episode>emptyList()); // } // // Path: app/src/test/java/com/mypodcasts/util/ListViewHelper.java // public static void performItemClickAtPosition(ListView listView, int position) { // listView.performItemClick( // listView.getAdapter().getView(position, null, null), // position, // position // ); // }
import android.app.Activity; import android.content.Intent; import android.widget.ListAdapter; import android.widget.ListView; import com.google.inject.AbstractModule; import com.mypodcasts.episodes.EpisodeFeedsActivity; import com.mypodcasts.repositories.UserFeedsRepository; import com.mypodcasts.repositories.models.Feed; import org.hamcrest.CoreMatchers; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static com.mypodcasts.util.FeedHelper.aFeed; import static com.mypodcasts.util.ListViewHelper.performItemClickAtPosition; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.robolectric.Robolectric.buildActivity; import static org.robolectric.RuntimeEnvironment.application; import static org.robolectric.Shadows.shadowOf; import static roboguice.RoboGuice.Util.reset; import static roboguice.RoboGuice.overrideApplicationInjector;
package com.mypodcasts; @RunWith(RobolectricTestRunner.class) @Config(constants = BuildConfig.class) public class MyPodcastsActivityTest {
// Path: app/src/main/java/com/mypodcasts/episodes/EpisodeFeedsActivity.java // public class EpisodeFeedsActivity extends MyPodcastsActivity { // // @Inject // private FragmentManager fragmentManager; // // @Inject // private Bundle arguments; // // @Inject // private EpisodeListFragment episodeListFragment; // // @Inject // private ProgressDialog progressDialog; // // @Inject // private UserFeedsRepository userFeedsRepository; // private FeedEpisodesAsyncTask feedEpisodesAsyncTask; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // Feed feed = (Feed) getIntent().getSerializableExtra(Feed.class.toString()); // // feedEpisodesAsyncTask = new FeedEpisodesAsyncTask(this, feed); // // feedEpisodesAsyncTask.execute(); // } // // @Override // protected void onPause() { // super.onPause(); // // feedEpisodesAsyncTask.cancel(); // } // // @Override // protected void onDestroy() { // dismissProgressDialog(); // // super.onDestroy(); // } // // private void showProgressDialog(String feedTitle) { // progressDialog.setIndeterminate(false); // progressDialog.setCancelable(false); // progressDialog.show(); // progressDialog.setMessage(format( // getResources().getString(R.string.loading_feed_episodes), feedTitle // )); // } // // private void dismissProgressDialog() { // if (progressDialog != null && progressDialog.isShowing()) { // progressDialog.dismiss(); // } // } // // class FeedEpisodesAsyncTask extends RetryableAsyncTask<Void, Void, Feed> { // private final Activity activity; // private final Feed feed; // // public FeedEpisodesAsyncTask(Activity activity, Feed feed) { // super(activity); // // this.activity = activity; // this.feed = feed; // } // // @Override // protected void onPreExecute() { // showProgressDialog(feed.getTitle()); // } // // @Override // protected Feed doInBackground(Void... params) { // return userFeedsRepository.getFeed(feed.getId()); // } // // @Override // protected void onPostExecute(Feed feed) { // if (this.activity.isDestroyed()) return; // // dismissProgressDialog(); // // arguments.putSerializable( // EpisodeList.HEADER, // new EpisodeListHeaderInfo(feed.getTitle(), feed.getImage()) // ); // // arguments.putSerializable( // EpisodeList.LIST, // new EpisodeList(feed.getEpisodes()) // ); // // episodeListFragment.setArguments(arguments); // // fragmentManager.beginTransaction() // .replace(R.id.content_frame, episodeListFragment) // .commitAllowingStateLoss(); // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/UserFeedsRepository.java // public class UserFeedsRepository { // // private final HttpClient httpClient; // // @Inject // public UserFeedsRepository(HttpClient httpClient) { // this.httpClient = httpClient; // } // // public List<Feed> getFeeds() { // return httpClient.getApi().getUserFeeds(); // } // // public Feed getFeed(String id) { // return httpClient.getApi().getFeed(id); // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/test/java/com/mypodcasts/util/FeedHelper.java // public static Feed aFeed(final String title) { // return aFeed(title, Collections.<Episode>emptyList()); // } // // Path: app/src/test/java/com/mypodcasts/util/ListViewHelper.java // public static void performItemClickAtPosition(ListView listView, int position) { // listView.performItemClick( // listView.getAdapter().getView(position, null, null), // position, // position // ); // } // Path: app/src/test/java/com/mypodcasts/MyPodcastsActivityTest.java import android.app.Activity; import android.content.Intent; import android.widget.ListAdapter; import android.widget.ListView; import com.google.inject.AbstractModule; import com.mypodcasts.episodes.EpisodeFeedsActivity; import com.mypodcasts.repositories.UserFeedsRepository; import com.mypodcasts.repositories.models.Feed; import org.hamcrest.CoreMatchers; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static com.mypodcasts.util.FeedHelper.aFeed; import static com.mypodcasts.util.ListViewHelper.performItemClickAtPosition; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.robolectric.Robolectric.buildActivity; import static org.robolectric.RuntimeEnvironment.application; import static org.robolectric.Shadows.shadowOf; import static roboguice.RoboGuice.Util.reset; import static roboguice.RoboGuice.overrideApplicationInjector; package com.mypodcasts; @RunWith(RobolectricTestRunner.class) @Config(constants = BuildConfig.class) public class MyPodcastsActivityTest {
UserFeedsRepository userFeedsRepositoryMock = mock(UserFeedsRepository.class);
alabeduarte/mypodcasts-android
app/src/test/java/com/mypodcasts/player/notification/AudioPlayerNotificationTest.java
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String FAST_FORWARD = "Fast Forward"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String PAUSE = "Pause"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String REWIND = "Rewind"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String STOP = "Stop";
import android.annotation.TargetApi; import android.app.Notification; import android.graphics.drawable.Icon; import android.os.Build; import com.mypodcasts.BuildConfig; import com.mypodcasts.R; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import static com.mypodcasts.player.notification.AudioPlayerNotification.FAST_FORWARD; import static com.mypodcasts.player.notification.AudioPlayerNotification.PAUSE; import static com.mypodcasts.player.notification.AudioPlayerNotification.REWIND; import static com.mypodcasts.player.notification.AudioPlayerNotification.STOP; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.robolectric.RuntimeEnvironment.application;
package com.mypodcasts.player.notification; @RunWith(RobolectricTestRunner.class) @Config(constants = BuildConfig.class) public class AudioPlayerNotificationTest { Notification.Builder notificationBuilder = new Notification.Builder(application); AudioPlayerNotification audioPlayerNotification = new AudioPlayerNotification(application, notificationBuilder);
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String FAST_FORWARD = "Fast Forward"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String PAUSE = "Pause"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String REWIND = "Rewind"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String STOP = "Stop"; // Path: app/src/test/java/com/mypodcasts/player/notification/AudioPlayerNotificationTest.java import android.annotation.TargetApi; import android.app.Notification; import android.graphics.drawable.Icon; import android.os.Build; import com.mypodcasts.BuildConfig; import com.mypodcasts.R; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import static com.mypodcasts.player.notification.AudioPlayerNotification.FAST_FORWARD; import static com.mypodcasts.player.notification.AudioPlayerNotification.PAUSE; import static com.mypodcasts.player.notification.AudioPlayerNotification.REWIND; import static com.mypodcasts.player.notification.AudioPlayerNotification.STOP; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.robolectric.RuntimeEnvironment.application; package com.mypodcasts.player.notification; @RunWith(RobolectricTestRunner.class) @Config(constants = BuildConfig.class) public class AudioPlayerNotificationTest { Notification.Builder notificationBuilder = new Notification.Builder(application); AudioPlayerNotification audioPlayerNotification = new AudioPlayerNotification(application, notificationBuilder);
Episode episode = new Episode() {
alabeduarte/mypodcasts-android
app/src/test/java/com/mypodcasts/player/notification/AudioPlayerNotificationTest.java
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String FAST_FORWARD = "Fast Forward"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String PAUSE = "Pause"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String REWIND = "Rewind"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String STOP = "Stop";
import android.annotation.TargetApi; import android.app.Notification; import android.graphics.drawable.Icon; import android.os.Build; import com.mypodcasts.BuildConfig; import com.mypodcasts.R; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import static com.mypodcasts.player.notification.AudioPlayerNotification.FAST_FORWARD; import static com.mypodcasts.player.notification.AudioPlayerNotification.PAUSE; import static com.mypodcasts.player.notification.AudioPlayerNotification.REWIND; import static com.mypodcasts.player.notification.AudioPlayerNotification.STOP; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.robolectric.RuntimeEnvironment.application;
package com.mypodcasts.player.notification; @RunWith(RobolectricTestRunner.class) @Config(constants = BuildConfig.class) public class AudioPlayerNotificationTest { Notification.Builder notificationBuilder = new Notification.Builder(application); AudioPlayerNotification audioPlayerNotification = new AudioPlayerNotification(application, notificationBuilder); Episode episode = new Episode() { @Override
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String FAST_FORWARD = "Fast Forward"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String PAUSE = "Pause"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String REWIND = "Rewind"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String STOP = "Stop"; // Path: app/src/test/java/com/mypodcasts/player/notification/AudioPlayerNotificationTest.java import android.annotation.TargetApi; import android.app.Notification; import android.graphics.drawable.Icon; import android.os.Build; import com.mypodcasts.BuildConfig; import com.mypodcasts.R; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import static com.mypodcasts.player.notification.AudioPlayerNotification.FAST_FORWARD; import static com.mypodcasts.player.notification.AudioPlayerNotification.PAUSE; import static com.mypodcasts.player.notification.AudioPlayerNotification.REWIND; import static com.mypodcasts.player.notification.AudioPlayerNotification.STOP; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.robolectric.RuntimeEnvironment.application; package com.mypodcasts.player.notification; @RunWith(RobolectricTestRunner.class) @Config(constants = BuildConfig.class) public class AudioPlayerNotificationTest { Notification.Builder notificationBuilder = new Notification.Builder(application); AudioPlayerNotification audioPlayerNotification = new AudioPlayerNotification(application, notificationBuilder); Episode episode = new Episode() { @Override
public Feed getFeed() {
alabeduarte/mypodcasts-android
app/src/test/java/com/mypodcasts/player/notification/AudioPlayerNotificationTest.java
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String FAST_FORWARD = "Fast Forward"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String PAUSE = "Pause"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String REWIND = "Rewind"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String STOP = "Stop";
import android.annotation.TargetApi; import android.app.Notification; import android.graphics.drawable.Icon; import android.os.Build; import com.mypodcasts.BuildConfig; import com.mypodcasts.R; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import static com.mypodcasts.player.notification.AudioPlayerNotification.FAST_FORWARD; import static com.mypodcasts.player.notification.AudioPlayerNotification.PAUSE; import static com.mypodcasts.player.notification.AudioPlayerNotification.REWIND; import static com.mypodcasts.player.notification.AudioPlayerNotification.STOP; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.robolectric.RuntimeEnvironment.application;
assertThat(notification.icon, is(R.drawable.ic_av_play_circle_fill)); } @Test public void itSetsNotificationVisibility() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.visibility, is(Notification.VISIBILITY_PUBLIC)); } @Test public void itSetsNotificationContentTitle() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.extras.getString(Notification.EXTRA_TITLE), is("Foo Bar")); } @Test public void itSetsNotificationContentText() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.extras.getString(Notification.EXTRA_TEXT), is("Lorem ipsum dolor sit amet")); } @TargetApi(Build.VERSION_CODES.M) @Test public void itReturnsNotificationWithMediaControlActions() { Notification notification = audioPlayerNotification.buildNotification(episode);
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String FAST_FORWARD = "Fast Forward"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String PAUSE = "Pause"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String REWIND = "Rewind"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String STOP = "Stop"; // Path: app/src/test/java/com/mypodcasts/player/notification/AudioPlayerNotificationTest.java import android.annotation.TargetApi; import android.app.Notification; import android.graphics.drawable.Icon; import android.os.Build; import com.mypodcasts.BuildConfig; import com.mypodcasts.R; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import static com.mypodcasts.player.notification.AudioPlayerNotification.FAST_FORWARD; import static com.mypodcasts.player.notification.AudioPlayerNotification.PAUSE; import static com.mypodcasts.player.notification.AudioPlayerNotification.REWIND; import static com.mypodcasts.player.notification.AudioPlayerNotification.STOP; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.robolectric.RuntimeEnvironment.application; assertThat(notification.icon, is(R.drawable.ic_av_play_circle_fill)); } @Test public void itSetsNotificationVisibility() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.visibility, is(Notification.VISIBILITY_PUBLIC)); } @Test public void itSetsNotificationContentTitle() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.extras.getString(Notification.EXTRA_TITLE), is("Foo Bar")); } @Test public void itSetsNotificationContentText() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.extras.getString(Notification.EXTRA_TEXT), is("Lorem ipsum dolor sit amet")); } @TargetApi(Build.VERSION_CODES.M) @Test public void itReturnsNotificationWithMediaControlActions() { Notification notification = audioPlayerNotification.buildNotification(episode);
assertThat(String.valueOf(notification.actions[0].title), is(REWIND));
alabeduarte/mypodcasts-android
app/src/test/java/com/mypodcasts/player/notification/AudioPlayerNotificationTest.java
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String FAST_FORWARD = "Fast Forward"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String PAUSE = "Pause"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String REWIND = "Rewind"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String STOP = "Stop";
import android.annotation.TargetApi; import android.app.Notification; import android.graphics.drawable.Icon; import android.os.Build; import com.mypodcasts.BuildConfig; import com.mypodcasts.R; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import static com.mypodcasts.player.notification.AudioPlayerNotification.FAST_FORWARD; import static com.mypodcasts.player.notification.AudioPlayerNotification.PAUSE; import static com.mypodcasts.player.notification.AudioPlayerNotification.REWIND; import static com.mypodcasts.player.notification.AudioPlayerNotification.STOP; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.robolectric.RuntimeEnvironment.application;
Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.visibility, is(Notification.VISIBILITY_PUBLIC)); } @Test public void itSetsNotificationContentTitle() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.extras.getString(Notification.EXTRA_TITLE), is("Foo Bar")); } @Test public void itSetsNotificationContentText() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.extras.getString(Notification.EXTRA_TEXT), is("Lorem ipsum dolor sit amet")); } @TargetApi(Build.VERSION_CODES.M) @Test public void itReturnsNotificationWithMediaControlActions() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(String.valueOf(notification.actions[0].title), is(REWIND)); assertThat( notification.actions[0].getIcon().toString(), is(Icon.createWithResource("", R.drawable.ic_fast_rewind).toString()) );
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String FAST_FORWARD = "Fast Forward"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String PAUSE = "Pause"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String REWIND = "Rewind"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String STOP = "Stop"; // Path: app/src/test/java/com/mypodcasts/player/notification/AudioPlayerNotificationTest.java import android.annotation.TargetApi; import android.app.Notification; import android.graphics.drawable.Icon; import android.os.Build; import com.mypodcasts.BuildConfig; import com.mypodcasts.R; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import static com.mypodcasts.player.notification.AudioPlayerNotification.FAST_FORWARD; import static com.mypodcasts.player.notification.AudioPlayerNotification.PAUSE; import static com.mypodcasts.player.notification.AudioPlayerNotification.REWIND; import static com.mypodcasts.player.notification.AudioPlayerNotification.STOP; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.robolectric.RuntimeEnvironment.application; Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.visibility, is(Notification.VISIBILITY_PUBLIC)); } @Test public void itSetsNotificationContentTitle() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.extras.getString(Notification.EXTRA_TITLE), is("Foo Bar")); } @Test public void itSetsNotificationContentText() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.extras.getString(Notification.EXTRA_TEXT), is("Lorem ipsum dolor sit amet")); } @TargetApi(Build.VERSION_CODES.M) @Test public void itReturnsNotificationWithMediaControlActions() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(String.valueOf(notification.actions[0].title), is(REWIND)); assertThat( notification.actions[0].getIcon().toString(), is(Icon.createWithResource("", R.drawable.ic_fast_rewind).toString()) );
assertThat(String.valueOf(notification.actions[1].title), is(PAUSE));
alabeduarte/mypodcasts-android
app/src/test/java/com/mypodcasts/player/notification/AudioPlayerNotificationTest.java
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String FAST_FORWARD = "Fast Forward"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String PAUSE = "Pause"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String REWIND = "Rewind"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String STOP = "Stop";
import android.annotation.TargetApi; import android.app.Notification; import android.graphics.drawable.Icon; import android.os.Build; import com.mypodcasts.BuildConfig; import com.mypodcasts.R; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import static com.mypodcasts.player.notification.AudioPlayerNotification.FAST_FORWARD; import static com.mypodcasts.player.notification.AudioPlayerNotification.PAUSE; import static com.mypodcasts.player.notification.AudioPlayerNotification.REWIND; import static com.mypodcasts.player.notification.AudioPlayerNotification.STOP; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.robolectric.RuntimeEnvironment.application;
public void itSetsNotificationContentTitle() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.extras.getString(Notification.EXTRA_TITLE), is("Foo Bar")); } @Test public void itSetsNotificationContentText() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.extras.getString(Notification.EXTRA_TEXT), is("Lorem ipsum dolor sit amet")); } @TargetApi(Build.VERSION_CODES.M) @Test public void itReturnsNotificationWithMediaControlActions() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(String.valueOf(notification.actions[0].title), is(REWIND)); assertThat( notification.actions[0].getIcon().toString(), is(Icon.createWithResource("", R.drawable.ic_fast_rewind).toString()) ); assertThat(String.valueOf(notification.actions[1].title), is(PAUSE)); assertThat( notification.actions[1].getIcon().toString(), is(Icon.createWithResource("", R.drawable.ic_pause).toString()) );
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String FAST_FORWARD = "Fast Forward"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String PAUSE = "Pause"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String REWIND = "Rewind"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String STOP = "Stop"; // Path: app/src/test/java/com/mypodcasts/player/notification/AudioPlayerNotificationTest.java import android.annotation.TargetApi; import android.app.Notification; import android.graphics.drawable.Icon; import android.os.Build; import com.mypodcasts.BuildConfig; import com.mypodcasts.R; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import static com.mypodcasts.player.notification.AudioPlayerNotification.FAST_FORWARD; import static com.mypodcasts.player.notification.AudioPlayerNotification.PAUSE; import static com.mypodcasts.player.notification.AudioPlayerNotification.REWIND; import static com.mypodcasts.player.notification.AudioPlayerNotification.STOP; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.robolectric.RuntimeEnvironment.application; public void itSetsNotificationContentTitle() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.extras.getString(Notification.EXTRA_TITLE), is("Foo Bar")); } @Test public void itSetsNotificationContentText() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.extras.getString(Notification.EXTRA_TEXT), is("Lorem ipsum dolor sit amet")); } @TargetApi(Build.VERSION_CODES.M) @Test public void itReturnsNotificationWithMediaControlActions() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(String.valueOf(notification.actions[0].title), is(REWIND)); assertThat( notification.actions[0].getIcon().toString(), is(Icon.createWithResource("", R.drawable.ic_fast_rewind).toString()) ); assertThat(String.valueOf(notification.actions[1].title), is(PAUSE)); assertThat( notification.actions[1].getIcon().toString(), is(Icon.createWithResource("", R.drawable.ic_pause).toString()) );
assertThat(String.valueOf(notification.actions[2].title), is(STOP));
alabeduarte/mypodcasts-android
app/src/test/java/com/mypodcasts/player/notification/AudioPlayerNotificationTest.java
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String FAST_FORWARD = "Fast Forward"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String PAUSE = "Pause"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String REWIND = "Rewind"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String STOP = "Stop";
import android.annotation.TargetApi; import android.app.Notification; import android.graphics.drawable.Icon; import android.os.Build; import com.mypodcasts.BuildConfig; import com.mypodcasts.R; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import static com.mypodcasts.player.notification.AudioPlayerNotification.FAST_FORWARD; import static com.mypodcasts.player.notification.AudioPlayerNotification.PAUSE; import static com.mypodcasts.player.notification.AudioPlayerNotification.REWIND; import static com.mypodcasts.player.notification.AudioPlayerNotification.STOP; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.robolectric.RuntimeEnvironment.application;
@Test public void itSetsNotificationContentText() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.extras.getString(Notification.EXTRA_TEXT), is("Lorem ipsum dolor sit amet")); } @TargetApi(Build.VERSION_CODES.M) @Test public void itReturnsNotificationWithMediaControlActions() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(String.valueOf(notification.actions[0].title), is(REWIND)); assertThat( notification.actions[0].getIcon().toString(), is(Icon.createWithResource("", R.drawable.ic_fast_rewind).toString()) ); assertThat(String.valueOf(notification.actions[1].title), is(PAUSE)); assertThat( notification.actions[1].getIcon().toString(), is(Icon.createWithResource("", R.drawable.ic_pause).toString()) ); assertThat(String.valueOf(notification.actions[2].title), is(STOP)); assertThat( notification.actions[2].getIcon().toString(), is(Icon.createWithResource("", R.drawable.ic_stop_black).toString()) );
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String FAST_FORWARD = "Fast Forward"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String PAUSE = "Pause"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String REWIND = "Rewind"; // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // protected static final String STOP = "Stop"; // Path: app/src/test/java/com/mypodcasts/player/notification/AudioPlayerNotificationTest.java import android.annotation.TargetApi; import android.app.Notification; import android.graphics.drawable.Icon; import android.os.Build; import com.mypodcasts.BuildConfig; import com.mypodcasts.R; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import static com.mypodcasts.player.notification.AudioPlayerNotification.FAST_FORWARD; import static com.mypodcasts.player.notification.AudioPlayerNotification.PAUSE; import static com.mypodcasts.player.notification.AudioPlayerNotification.REWIND; import static com.mypodcasts.player.notification.AudioPlayerNotification.STOP; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.robolectric.RuntimeEnvironment.application; @Test public void itSetsNotificationContentText() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.extras.getString(Notification.EXTRA_TEXT), is("Lorem ipsum dolor sit amet")); } @TargetApi(Build.VERSION_CODES.M) @Test public void itReturnsNotificationWithMediaControlActions() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(String.valueOf(notification.actions[0].title), is(REWIND)); assertThat( notification.actions[0].getIcon().toString(), is(Icon.createWithResource("", R.drawable.ic_fast_rewind).toString()) ); assertThat(String.valueOf(notification.actions[1].title), is(PAUSE)); assertThat( notification.actions[1].getIcon().toString(), is(Icon.createWithResource("", R.drawable.ic_pause).toString()) ); assertThat(String.valueOf(notification.actions[2].title), is(STOP)); assertThat( notification.actions[2].getIcon().toString(), is(Icon.createWithResource("", R.drawable.ic_stop_black).toString()) );
assertThat(String.valueOf(notification.actions[3].title), is(FAST_FORWARD));
alabeduarte/mypodcasts-android
app/src/main/java/com/mypodcasts/player/AudioPlayerService.java
// Path: app/src/main/java/com/mypodcasts/player/events/AudioStoppedEvent.java // public class AudioStoppedEvent {} // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // public class AudioPlayerNotification { // private final Context context; // private final Notification.Builder notificationBuilder; // // protected static final String REWIND = "Rewind"; // protected static final String PAUSE = "Pause"; // protected static final String STOP = "Stop"; // protected static final String FAST_FORWARD = "Fast Forward"; // // @Inject // public AudioPlayerNotification(Context context, Notification.Builder notificationBuilder) { // this.context = context; // this.notificationBuilder = notificationBuilder; // } // // public Notification buildNotification(Episode episode) { // Notification.MediaStyle mediaStyle = new Notification.MediaStyle(); // // return notificationBuilder // .setSmallIcon(R.drawable.ic_av_play_circle_fill) // .setContentTitle(episode.getFeed().getTitle()) // .setContentText(episode.getTitle()) // .setStyle(mediaStyle) // .setVisibility(Notification.VISIBILITY_PUBLIC) // .addAction(generateAction(episode, R.drawable.ic_fast_rewind, REWIND, ACTION_REWIND)) // .addAction(generateAction(episode, R.drawable.ic_pause, PAUSE, ACTION_PAUSE)) // .addAction(generateAction(episode, R.drawable.ic_stop_black, STOP, ACTION_STOP)) // .addAction(generateAction(episode, R.drawable.ic_fast_forward, FAST_FORWARD, ACTION_FAST_FORWARD)) // .build(); // } // // private Notification.Action generateAction(Episode episode, int icon, String title, String intentAction) { // Intent intent = new Intent(context, AudioPlayerService.class); // intent.setAction(intentAction); // // intent.putExtra(Episode.class.toString(), episode); // // PendingIntent pendingIntent = PendingIntent.getService(context, 1, intent, FLAG_UPDATE_CURRENT); // // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // return new Notification.Action.Builder(Icon.createWithResource("", icon), title, pendingIntent).build(); // } else { // return new Notification.Action.Builder(icon, title, pendingIntent).build(); // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public class Support { // public static final String MYPODCASTS_TAG = "[mypodcasts-android]"; // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public static final String MYPODCASTS_TAG = "[mypodcasts-android]";
import android.content.Context; import android.content.Intent; import android.os.IBinder; import android.util.Log; import com.mypodcasts.player.events.AudioStoppedEvent; import com.mypodcasts.player.notification.AudioPlayerNotification; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.support.Support; import java.io.IOException; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import roboguice.service.RoboService; import static com.mypodcasts.support.Support.MYPODCASTS_TAG;
package com.mypodcasts.player; public class AudioPlayerService extends RoboService { public static final int ONGOING_NOTIFICATION_ID = 1; public static final String ACTION_REWIND = "com.mypodcasts.player.action.rewind"; public static final String ACTION_PAUSE = "com.mypodcasts.player.action.pause"; public static final String ACTION_PLAY = "com.mypodcasts.player.action.play"; public static final String ACTION_STOP = "com.mypodcasts.player.action.stop"; public static final String ACTION_FAST_FORWARD = "com.mypodcasts.player.action.fast_foward"; public static final int POSITION = 25 * 1000; @Inject private Context context; @Inject private AudioPlayer audioPlayer; @Inject
// Path: app/src/main/java/com/mypodcasts/player/events/AudioStoppedEvent.java // public class AudioStoppedEvent {} // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // public class AudioPlayerNotification { // private final Context context; // private final Notification.Builder notificationBuilder; // // protected static final String REWIND = "Rewind"; // protected static final String PAUSE = "Pause"; // protected static final String STOP = "Stop"; // protected static final String FAST_FORWARD = "Fast Forward"; // // @Inject // public AudioPlayerNotification(Context context, Notification.Builder notificationBuilder) { // this.context = context; // this.notificationBuilder = notificationBuilder; // } // // public Notification buildNotification(Episode episode) { // Notification.MediaStyle mediaStyle = new Notification.MediaStyle(); // // return notificationBuilder // .setSmallIcon(R.drawable.ic_av_play_circle_fill) // .setContentTitle(episode.getFeed().getTitle()) // .setContentText(episode.getTitle()) // .setStyle(mediaStyle) // .setVisibility(Notification.VISIBILITY_PUBLIC) // .addAction(generateAction(episode, R.drawable.ic_fast_rewind, REWIND, ACTION_REWIND)) // .addAction(generateAction(episode, R.drawable.ic_pause, PAUSE, ACTION_PAUSE)) // .addAction(generateAction(episode, R.drawable.ic_stop_black, STOP, ACTION_STOP)) // .addAction(generateAction(episode, R.drawable.ic_fast_forward, FAST_FORWARD, ACTION_FAST_FORWARD)) // .build(); // } // // private Notification.Action generateAction(Episode episode, int icon, String title, String intentAction) { // Intent intent = new Intent(context, AudioPlayerService.class); // intent.setAction(intentAction); // // intent.putExtra(Episode.class.toString(), episode); // // PendingIntent pendingIntent = PendingIntent.getService(context, 1, intent, FLAG_UPDATE_CURRENT); // // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // return new Notification.Action.Builder(Icon.createWithResource("", icon), title, pendingIntent).build(); // } else { // return new Notification.Action.Builder(icon, title, pendingIntent).build(); // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public class Support { // public static final String MYPODCASTS_TAG = "[mypodcasts-android]"; // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public static final String MYPODCASTS_TAG = "[mypodcasts-android]"; // Path: app/src/main/java/com/mypodcasts/player/AudioPlayerService.java import android.content.Context; import android.content.Intent; import android.os.IBinder; import android.util.Log; import com.mypodcasts.player.events.AudioStoppedEvent; import com.mypodcasts.player.notification.AudioPlayerNotification; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.support.Support; import java.io.IOException; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import roboguice.service.RoboService; import static com.mypodcasts.support.Support.MYPODCASTS_TAG; package com.mypodcasts.player; public class AudioPlayerService extends RoboService { public static final int ONGOING_NOTIFICATION_ID = 1; public static final String ACTION_REWIND = "com.mypodcasts.player.action.rewind"; public static final String ACTION_PAUSE = "com.mypodcasts.player.action.pause"; public static final String ACTION_PLAY = "com.mypodcasts.player.action.play"; public static final String ACTION_STOP = "com.mypodcasts.player.action.stop"; public static final String ACTION_FAST_FORWARD = "com.mypodcasts.player.action.fast_foward"; public static final int POSITION = 25 * 1000; @Inject private Context context; @Inject private AudioPlayer audioPlayer; @Inject
private AudioPlayerNotification audioPlayerNotification;
alabeduarte/mypodcasts-android
app/src/main/java/com/mypodcasts/player/AudioPlayerService.java
// Path: app/src/main/java/com/mypodcasts/player/events/AudioStoppedEvent.java // public class AudioStoppedEvent {} // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // public class AudioPlayerNotification { // private final Context context; // private final Notification.Builder notificationBuilder; // // protected static final String REWIND = "Rewind"; // protected static final String PAUSE = "Pause"; // protected static final String STOP = "Stop"; // protected static final String FAST_FORWARD = "Fast Forward"; // // @Inject // public AudioPlayerNotification(Context context, Notification.Builder notificationBuilder) { // this.context = context; // this.notificationBuilder = notificationBuilder; // } // // public Notification buildNotification(Episode episode) { // Notification.MediaStyle mediaStyle = new Notification.MediaStyle(); // // return notificationBuilder // .setSmallIcon(R.drawable.ic_av_play_circle_fill) // .setContentTitle(episode.getFeed().getTitle()) // .setContentText(episode.getTitle()) // .setStyle(mediaStyle) // .setVisibility(Notification.VISIBILITY_PUBLIC) // .addAction(generateAction(episode, R.drawable.ic_fast_rewind, REWIND, ACTION_REWIND)) // .addAction(generateAction(episode, R.drawable.ic_pause, PAUSE, ACTION_PAUSE)) // .addAction(generateAction(episode, R.drawable.ic_stop_black, STOP, ACTION_STOP)) // .addAction(generateAction(episode, R.drawable.ic_fast_forward, FAST_FORWARD, ACTION_FAST_FORWARD)) // .build(); // } // // private Notification.Action generateAction(Episode episode, int icon, String title, String intentAction) { // Intent intent = new Intent(context, AudioPlayerService.class); // intent.setAction(intentAction); // // intent.putExtra(Episode.class.toString(), episode); // // PendingIntent pendingIntent = PendingIntent.getService(context, 1, intent, FLAG_UPDATE_CURRENT); // // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // return new Notification.Action.Builder(Icon.createWithResource("", icon), title, pendingIntent).build(); // } else { // return new Notification.Action.Builder(icon, title, pendingIntent).build(); // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public class Support { // public static final String MYPODCASTS_TAG = "[mypodcasts-android]"; // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public static final String MYPODCASTS_TAG = "[mypodcasts-android]";
import android.content.Context; import android.content.Intent; import android.os.IBinder; import android.util.Log; import com.mypodcasts.player.events.AudioStoppedEvent; import com.mypodcasts.player.notification.AudioPlayerNotification; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.support.Support; import java.io.IOException; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import roboguice.service.RoboService; import static com.mypodcasts.support.Support.MYPODCASTS_TAG;
package com.mypodcasts.player; public class AudioPlayerService extends RoboService { public static final int ONGOING_NOTIFICATION_ID = 1; public static final String ACTION_REWIND = "com.mypodcasts.player.action.rewind"; public static final String ACTION_PAUSE = "com.mypodcasts.player.action.pause"; public static final String ACTION_PLAY = "com.mypodcasts.player.action.play"; public static final String ACTION_STOP = "com.mypodcasts.player.action.stop"; public static final String ACTION_FAST_FORWARD = "com.mypodcasts.player.action.fast_foward"; public static final int POSITION = 25 * 1000; @Inject private Context context; @Inject private AudioPlayer audioPlayer; @Inject private AudioPlayerNotification audioPlayerNotification; @Inject private EventBus eventBus; @Override public IBinder onBind(Intent intent) { return null; } @Override public int onStartCommand(Intent intent, int flags, int startId) { try {
// Path: app/src/main/java/com/mypodcasts/player/events/AudioStoppedEvent.java // public class AudioStoppedEvent {} // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // public class AudioPlayerNotification { // private final Context context; // private final Notification.Builder notificationBuilder; // // protected static final String REWIND = "Rewind"; // protected static final String PAUSE = "Pause"; // protected static final String STOP = "Stop"; // protected static final String FAST_FORWARD = "Fast Forward"; // // @Inject // public AudioPlayerNotification(Context context, Notification.Builder notificationBuilder) { // this.context = context; // this.notificationBuilder = notificationBuilder; // } // // public Notification buildNotification(Episode episode) { // Notification.MediaStyle mediaStyle = new Notification.MediaStyle(); // // return notificationBuilder // .setSmallIcon(R.drawable.ic_av_play_circle_fill) // .setContentTitle(episode.getFeed().getTitle()) // .setContentText(episode.getTitle()) // .setStyle(mediaStyle) // .setVisibility(Notification.VISIBILITY_PUBLIC) // .addAction(generateAction(episode, R.drawable.ic_fast_rewind, REWIND, ACTION_REWIND)) // .addAction(generateAction(episode, R.drawable.ic_pause, PAUSE, ACTION_PAUSE)) // .addAction(generateAction(episode, R.drawable.ic_stop_black, STOP, ACTION_STOP)) // .addAction(generateAction(episode, R.drawable.ic_fast_forward, FAST_FORWARD, ACTION_FAST_FORWARD)) // .build(); // } // // private Notification.Action generateAction(Episode episode, int icon, String title, String intentAction) { // Intent intent = new Intent(context, AudioPlayerService.class); // intent.setAction(intentAction); // // intent.putExtra(Episode.class.toString(), episode); // // PendingIntent pendingIntent = PendingIntent.getService(context, 1, intent, FLAG_UPDATE_CURRENT); // // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // return new Notification.Action.Builder(Icon.createWithResource("", icon), title, pendingIntent).build(); // } else { // return new Notification.Action.Builder(icon, title, pendingIntent).build(); // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public class Support { // public static final String MYPODCASTS_TAG = "[mypodcasts-android]"; // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public static final String MYPODCASTS_TAG = "[mypodcasts-android]"; // Path: app/src/main/java/com/mypodcasts/player/AudioPlayerService.java import android.content.Context; import android.content.Intent; import android.os.IBinder; import android.util.Log; import com.mypodcasts.player.events.AudioStoppedEvent; import com.mypodcasts.player.notification.AudioPlayerNotification; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.support.Support; import java.io.IOException; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import roboguice.service.RoboService; import static com.mypodcasts.support.Support.MYPODCASTS_TAG; package com.mypodcasts.player; public class AudioPlayerService extends RoboService { public static final int ONGOING_NOTIFICATION_ID = 1; public static final String ACTION_REWIND = "com.mypodcasts.player.action.rewind"; public static final String ACTION_PAUSE = "com.mypodcasts.player.action.pause"; public static final String ACTION_PLAY = "com.mypodcasts.player.action.play"; public static final String ACTION_STOP = "com.mypodcasts.player.action.stop"; public static final String ACTION_FAST_FORWARD = "com.mypodcasts.player.action.fast_foward"; public static final int POSITION = 25 * 1000; @Inject private Context context; @Inject private AudioPlayer audioPlayer; @Inject private AudioPlayerNotification audioPlayerNotification; @Inject private EventBus eventBus; @Override public IBinder onBind(Intent intent) { return null; } @Override public int onStartCommand(Intent intent, int flags, int startId) { try {
Log.d(Support.MYPODCASTS_TAG, "[AudioPlayerService][onStartCommand]");
alabeduarte/mypodcasts-android
app/src/main/java/com/mypodcasts/player/AudioPlayerService.java
// Path: app/src/main/java/com/mypodcasts/player/events/AudioStoppedEvent.java // public class AudioStoppedEvent {} // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // public class AudioPlayerNotification { // private final Context context; // private final Notification.Builder notificationBuilder; // // protected static final String REWIND = "Rewind"; // protected static final String PAUSE = "Pause"; // protected static final String STOP = "Stop"; // protected static final String FAST_FORWARD = "Fast Forward"; // // @Inject // public AudioPlayerNotification(Context context, Notification.Builder notificationBuilder) { // this.context = context; // this.notificationBuilder = notificationBuilder; // } // // public Notification buildNotification(Episode episode) { // Notification.MediaStyle mediaStyle = new Notification.MediaStyle(); // // return notificationBuilder // .setSmallIcon(R.drawable.ic_av_play_circle_fill) // .setContentTitle(episode.getFeed().getTitle()) // .setContentText(episode.getTitle()) // .setStyle(mediaStyle) // .setVisibility(Notification.VISIBILITY_PUBLIC) // .addAction(generateAction(episode, R.drawable.ic_fast_rewind, REWIND, ACTION_REWIND)) // .addAction(generateAction(episode, R.drawable.ic_pause, PAUSE, ACTION_PAUSE)) // .addAction(generateAction(episode, R.drawable.ic_stop_black, STOP, ACTION_STOP)) // .addAction(generateAction(episode, R.drawable.ic_fast_forward, FAST_FORWARD, ACTION_FAST_FORWARD)) // .build(); // } // // private Notification.Action generateAction(Episode episode, int icon, String title, String intentAction) { // Intent intent = new Intent(context, AudioPlayerService.class); // intent.setAction(intentAction); // // intent.putExtra(Episode.class.toString(), episode); // // PendingIntent pendingIntent = PendingIntent.getService(context, 1, intent, FLAG_UPDATE_CURRENT); // // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // return new Notification.Action.Builder(Icon.createWithResource("", icon), title, pendingIntent).build(); // } else { // return new Notification.Action.Builder(icon, title, pendingIntent).build(); // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public class Support { // public static final String MYPODCASTS_TAG = "[mypodcasts-android]"; // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public static final String MYPODCASTS_TAG = "[mypodcasts-android]";
import android.content.Context; import android.content.Intent; import android.os.IBinder; import android.util.Log; import com.mypodcasts.player.events.AudioStoppedEvent; import com.mypodcasts.player.notification.AudioPlayerNotification; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.support.Support; import java.io.IOException; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import roboguice.service.RoboService; import static com.mypodcasts.support.Support.MYPODCASTS_TAG;
package com.mypodcasts.player; public class AudioPlayerService extends RoboService { public static final int ONGOING_NOTIFICATION_ID = 1; public static final String ACTION_REWIND = "com.mypodcasts.player.action.rewind"; public static final String ACTION_PAUSE = "com.mypodcasts.player.action.pause"; public static final String ACTION_PLAY = "com.mypodcasts.player.action.play"; public static final String ACTION_STOP = "com.mypodcasts.player.action.stop"; public static final String ACTION_FAST_FORWARD = "com.mypodcasts.player.action.fast_foward"; public static final int POSITION = 25 * 1000; @Inject private Context context; @Inject private AudioPlayer audioPlayer; @Inject private AudioPlayerNotification audioPlayerNotification; @Inject private EventBus eventBus; @Override public IBinder onBind(Intent intent) { return null; } @Override public int onStartCommand(Intent intent, int flags, int startId) { try {
// Path: app/src/main/java/com/mypodcasts/player/events/AudioStoppedEvent.java // public class AudioStoppedEvent {} // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // public class AudioPlayerNotification { // private final Context context; // private final Notification.Builder notificationBuilder; // // protected static final String REWIND = "Rewind"; // protected static final String PAUSE = "Pause"; // protected static final String STOP = "Stop"; // protected static final String FAST_FORWARD = "Fast Forward"; // // @Inject // public AudioPlayerNotification(Context context, Notification.Builder notificationBuilder) { // this.context = context; // this.notificationBuilder = notificationBuilder; // } // // public Notification buildNotification(Episode episode) { // Notification.MediaStyle mediaStyle = new Notification.MediaStyle(); // // return notificationBuilder // .setSmallIcon(R.drawable.ic_av_play_circle_fill) // .setContentTitle(episode.getFeed().getTitle()) // .setContentText(episode.getTitle()) // .setStyle(mediaStyle) // .setVisibility(Notification.VISIBILITY_PUBLIC) // .addAction(generateAction(episode, R.drawable.ic_fast_rewind, REWIND, ACTION_REWIND)) // .addAction(generateAction(episode, R.drawable.ic_pause, PAUSE, ACTION_PAUSE)) // .addAction(generateAction(episode, R.drawable.ic_stop_black, STOP, ACTION_STOP)) // .addAction(generateAction(episode, R.drawable.ic_fast_forward, FAST_FORWARD, ACTION_FAST_FORWARD)) // .build(); // } // // private Notification.Action generateAction(Episode episode, int icon, String title, String intentAction) { // Intent intent = new Intent(context, AudioPlayerService.class); // intent.setAction(intentAction); // // intent.putExtra(Episode.class.toString(), episode); // // PendingIntent pendingIntent = PendingIntent.getService(context, 1, intent, FLAG_UPDATE_CURRENT); // // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // return new Notification.Action.Builder(Icon.createWithResource("", icon), title, pendingIntent).build(); // } else { // return new Notification.Action.Builder(icon, title, pendingIntent).build(); // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public class Support { // public static final String MYPODCASTS_TAG = "[mypodcasts-android]"; // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public static final String MYPODCASTS_TAG = "[mypodcasts-android]"; // Path: app/src/main/java/com/mypodcasts/player/AudioPlayerService.java import android.content.Context; import android.content.Intent; import android.os.IBinder; import android.util.Log; import com.mypodcasts.player.events.AudioStoppedEvent; import com.mypodcasts.player.notification.AudioPlayerNotification; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.support.Support; import java.io.IOException; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import roboguice.service.RoboService; import static com.mypodcasts.support.Support.MYPODCASTS_TAG; package com.mypodcasts.player; public class AudioPlayerService extends RoboService { public static final int ONGOING_NOTIFICATION_ID = 1; public static final String ACTION_REWIND = "com.mypodcasts.player.action.rewind"; public static final String ACTION_PAUSE = "com.mypodcasts.player.action.pause"; public static final String ACTION_PLAY = "com.mypodcasts.player.action.play"; public static final String ACTION_STOP = "com.mypodcasts.player.action.stop"; public static final String ACTION_FAST_FORWARD = "com.mypodcasts.player.action.fast_foward"; public static final int POSITION = 25 * 1000; @Inject private Context context; @Inject private AudioPlayer audioPlayer; @Inject private AudioPlayerNotification audioPlayerNotification; @Inject private EventBus eventBus; @Override public IBinder onBind(Intent intent) { return null; } @Override public int onStartCommand(Intent intent, int flags, int startId) { try {
Log.d(Support.MYPODCASTS_TAG, "[AudioPlayerService][onStartCommand]");
alabeduarte/mypodcasts-android
app/src/main/java/com/mypodcasts/player/AudioPlayerService.java
// Path: app/src/main/java/com/mypodcasts/player/events/AudioStoppedEvent.java // public class AudioStoppedEvent {} // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // public class AudioPlayerNotification { // private final Context context; // private final Notification.Builder notificationBuilder; // // protected static final String REWIND = "Rewind"; // protected static final String PAUSE = "Pause"; // protected static final String STOP = "Stop"; // protected static final String FAST_FORWARD = "Fast Forward"; // // @Inject // public AudioPlayerNotification(Context context, Notification.Builder notificationBuilder) { // this.context = context; // this.notificationBuilder = notificationBuilder; // } // // public Notification buildNotification(Episode episode) { // Notification.MediaStyle mediaStyle = new Notification.MediaStyle(); // // return notificationBuilder // .setSmallIcon(R.drawable.ic_av_play_circle_fill) // .setContentTitle(episode.getFeed().getTitle()) // .setContentText(episode.getTitle()) // .setStyle(mediaStyle) // .setVisibility(Notification.VISIBILITY_PUBLIC) // .addAction(generateAction(episode, R.drawable.ic_fast_rewind, REWIND, ACTION_REWIND)) // .addAction(generateAction(episode, R.drawable.ic_pause, PAUSE, ACTION_PAUSE)) // .addAction(generateAction(episode, R.drawable.ic_stop_black, STOP, ACTION_STOP)) // .addAction(generateAction(episode, R.drawable.ic_fast_forward, FAST_FORWARD, ACTION_FAST_FORWARD)) // .build(); // } // // private Notification.Action generateAction(Episode episode, int icon, String title, String intentAction) { // Intent intent = new Intent(context, AudioPlayerService.class); // intent.setAction(intentAction); // // intent.putExtra(Episode.class.toString(), episode); // // PendingIntent pendingIntent = PendingIntent.getService(context, 1, intent, FLAG_UPDATE_CURRENT); // // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // return new Notification.Action.Builder(Icon.createWithResource("", icon), title, pendingIntent).build(); // } else { // return new Notification.Action.Builder(icon, title, pendingIntent).build(); // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public class Support { // public static final String MYPODCASTS_TAG = "[mypodcasts-android]"; // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public static final String MYPODCASTS_TAG = "[mypodcasts-android]";
import android.content.Context; import android.content.Intent; import android.os.IBinder; import android.util.Log; import com.mypodcasts.player.events.AudioStoppedEvent; import com.mypodcasts.player.notification.AudioPlayerNotification; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.support.Support; import java.io.IOException; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import roboguice.service.RoboService; import static com.mypodcasts.support.Support.MYPODCASTS_TAG;
package com.mypodcasts.player; public class AudioPlayerService extends RoboService { public static final int ONGOING_NOTIFICATION_ID = 1; public static final String ACTION_REWIND = "com.mypodcasts.player.action.rewind"; public static final String ACTION_PAUSE = "com.mypodcasts.player.action.pause"; public static final String ACTION_PLAY = "com.mypodcasts.player.action.play"; public static final String ACTION_STOP = "com.mypodcasts.player.action.stop"; public static final String ACTION_FAST_FORWARD = "com.mypodcasts.player.action.fast_foward"; public static final int POSITION = 25 * 1000; @Inject private Context context; @Inject private AudioPlayer audioPlayer; @Inject private AudioPlayerNotification audioPlayerNotification; @Inject private EventBus eventBus; @Override public IBinder onBind(Intent intent) { return null; } @Override public int onStartCommand(Intent intent, int flags, int startId) { try { Log.d(Support.MYPODCASTS_TAG, "[AudioPlayerService][onStartCommand]");
// Path: app/src/main/java/com/mypodcasts/player/events/AudioStoppedEvent.java // public class AudioStoppedEvent {} // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // public class AudioPlayerNotification { // private final Context context; // private final Notification.Builder notificationBuilder; // // protected static final String REWIND = "Rewind"; // protected static final String PAUSE = "Pause"; // protected static final String STOP = "Stop"; // protected static final String FAST_FORWARD = "Fast Forward"; // // @Inject // public AudioPlayerNotification(Context context, Notification.Builder notificationBuilder) { // this.context = context; // this.notificationBuilder = notificationBuilder; // } // // public Notification buildNotification(Episode episode) { // Notification.MediaStyle mediaStyle = new Notification.MediaStyle(); // // return notificationBuilder // .setSmallIcon(R.drawable.ic_av_play_circle_fill) // .setContentTitle(episode.getFeed().getTitle()) // .setContentText(episode.getTitle()) // .setStyle(mediaStyle) // .setVisibility(Notification.VISIBILITY_PUBLIC) // .addAction(generateAction(episode, R.drawable.ic_fast_rewind, REWIND, ACTION_REWIND)) // .addAction(generateAction(episode, R.drawable.ic_pause, PAUSE, ACTION_PAUSE)) // .addAction(generateAction(episode, R.drawable.ic_stop_black, STOP, ACTION_STOP)) // .addAction(generateAction(episode, R.drawable.ic_fast_forward, FAST_FORWARD, ACTION_FAST_FORWARD)) // .build(); // } // // private Notification.Action generateAction(Episode episode, int icon, String title, String intentAction) { // Intent intent = new Intent(context, AudioPlayerService.class); // intent.setAction(intentAction); // // intent.putExtra(Episode.class.toString(), episode); // // PendingIntent pendingIntent = PendingIntent.getService(context, 1, intent, FLAG_UPDATE_CURRENT); // // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // return new Notification.Action.Builder(Icon.createWithResource("", icon), title, pendingIntent).build(); // } else { // return new Notification.Action.Builder(icon, title, pendingIntent).build(); // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public class Support { // public static final String MYPODCASTS_TAG = "[mypodcasts-android]"; // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public static final String MYPODCASTS_TAG = "[mypodcasts-android]"; // Path: app/src/main/java/com/mypodcasts/player/AudioPlayerService.java import android.content.Context; import android.content.Intent; import android.os.IBinder; import android.util.Log; import com.mypodcasts.player.events.AudioStoppedEvent; import com.mypodcasts.player.notification.AudioPlayerNotification; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.support.Support; import java.io.IOException; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import roboguice.service.RoboService; import static com.mypodcasts.support.Support.MYPODCASTS_TAG; package com.mypodcasts.player; public class AudioPlayerService extends RoboService { public static final int ONGOING_NOTIFICATION_ID = 1; public static final String ACTION_REWIND = "com.mypodcasts.player.action.rewind"; public static final String ACTION_PAUSE = "com.mypodcasts.player.action.pause"; public static final String ACTION_PLAY = "com.mypodcasts.player.action.play"; public static final String ACTION_STOP = "com.mypodcasts.player.action.stop"; public static final String ACTION_FAST_FORWARD = "com.mypodcasts.player.action.fast_foward"; public static final int POSITION = 25 * 1000; @Inject private Context context; @Inject private AudioPlayer audioPlayer; @Inject private AudioPlayerNotification audioPlayerNotification; @Inject private EventBus eventBus; @Override public IBinder onBind(Intent intent) { return null; } @Override public int onStartCommand(Intent intent, int flags, int startId) { try { Log.d(Support.MYPODCASTS_TAG, "[AudioPlayerService][onStartCommand]");
final Episode episode = (Episode) intent.getSerializableExtra(Episode.class.toString());
alabeduarte/mypodcasts-android
app/src/main/java/com/mypodcasts/player/AudioPlayerService.java
// Path: app/src/main/java/com/mypodcasts/player/events/AudioStoppedEvent.java // public class AudioStoppedEvent {} // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // public class AudioPlayerNotification { // private final Context context; // private final Notification.Builder notificationBuilder; // // protected static final String REWIND = "Rewind"; // protected static final String PAUSE = "Pause"; // protected static final String STOP = "Stop"; // protected static final String FAST_FORWARD = "Fast Forward"; // // @Inject // public AudioPlayerNotification(Context context, Notification.Builder notificationBuilder) { // this.context = context; // this.notificationBuilder = notificationBuilder; // } // // public Notification buildNotification(Episode episode) { // Notification.MediaStyle mediaStyle = new Notification.MediaStyle(); // // return notificationBuilder // .setSmallIcon(R.drawable.ic_av_play_circle_fill) // .setContentTitle(episode.getFeed().getTitle()) // .setContentText(episode.getTitle()) // .setStyle(mediaStyle) // .setVisibility(Notification.VISIBILITY_PUBLIC) // .addAction(generateAction(episode, R.drawable.ic_fast_rewind, REWIND, ACTION_REWIND)) // .addAction(generateAction(episode, R.drawable.ic_pause, PAUSE, ACTION_PAUSE)) // .addAction(generateAction(episode, R.drawable.ic_stop_black, STOP, ACTION_STOP)) // .addAction(generateAction(episode, R.drawable.ic_fast_forward, FAST_FORWARD, ACTION_FAST_FORWARD)) // .build(); // } // // private Notification.Action generateAction(Episode episode, int icon, String title, String intentAction) { // Intent intent = new Intent(context, AudioPlayerService.class); // intent.setAction(intentAction); // // intent.putExtra(Episode.class.toString(), episode); // // PendingIntent pendingIntent = PendingIntent.getService(context, 1, intent, FLAG_UPDATE_CURRENT); // // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // return new Notification.Action.Builder(Icon.createWithResource("", icon), title, pendingIntent).build(); // } else { // return new Notification.Action.Builder(icon, title, pendingIntent).build(); // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public class Support { // public static final String MYPODCASTS_TAG = "[mypodcasts-android]"; // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public static final String MYPODCASTS_TAG = "[mypodcasts-android]";
import android.content.Context; import android.content.Intent; import android.os.IBinder; import android.util.Log; import com.mypodcasts.player.events.AudioStoppedEvent; import com.mypodcasts.player.notification.AudioPlayerNotification; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.support.Support; import java.io.IOException; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import roboguice.service.RoboService; import static com.mypodcasts.support.Support.MYPODCASTS_TAG;
return START_NOT_STICKY; } @Override public void onDestroy() { super.onDestroy(); audioPlayer.release(); } private void handleMediaControlByAction(Intent intent) { if (intent.getAction() == null) return; if (intent.getAction().equalsIgnoreCase(ACTION_REWIND)) { Log.d(MYPODCASTS_TAG, ACTION_REWIND); audioPlayer.seekTo(audioPlayer.getCurrentPosition() - POSITION); } if (intent.getAction().equalsIgnoreCase(ACTION_PAUSE)) { Log.d(MYPODCASTS_TAG, ACTION_PAUSE); audioPlayer.pause(); } if (intent.getAction().equalsIgnoreCase(ACTION_STOP)) { Log.d(MYPODCASTS_TAG, ACTION_STOP); audioPlayer.pause(); stopForeground(true);
// Path: app/src/main/java/com/mypodcasts/player/events/AudioStoppedEvent.java // public class AudioStoppedEvent {} // // Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java // public class AudioPlayerNotification { // private final Context context; // private final Notification.Builder notificationBuilder; // // protected static final String REWIND = "Rewind"; // protected static final String PAUSE = "Pause"; // protected static final String STOP = "Stop"; // protected static final String FAST_FORWARD = "Fast Forward"; // // @Inject // public AudioPlayerNotification(Context context, Notification.Builder notificationBuilder) { // this.context = context; // this.notificationBuilder = notificationBuilder; // } // // public Notification buildNotification(Episode episode) { // Notification.MediaStyle mediaStyle = new Notification.MediaStyle(); // // return notificationBuilder // .setSmallIcon(R.drawable.ic_av_play_circle_fill) // .setContentTitle(episode.getFeed().getTitle()) // .setContentText(episode.getTitle()) // .setStyle(mediaStyle) // .setVisibility(Notification.VISIBILITY_PUBLIC) // .addAction(generateAction(episode, R.drawable.ic_fast_rewind, REWIND, ACTION_REWIND)) // .addAction(generateAction(episode, R.drawable.ic_pause, PAUSE, ACTION_PAUSE)) // .addAction(generateAction(episode, R.drawable.ic_stop_black, STOP, ACTION_STOP)) // .addAction(generateAction(episode, R.drawable.ic_fast_forward, FAST_FORWARD, ACTION_FAST_FORWARD)) // .build(); // } // // private Notification.Action generateAction(Episode episode, int icon, String title, String intentAction) { // Intent intent = new Intent(context, AudioPlayerService.class); // intent.setAction(intentAction); // // intent.putExtra(Episode.class.toString(), episode); // // PendingIntent pendingIntent = PendingIntent.getService(context, 1, intent, FLAG_UPDATE_CURRENT); // // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // return new Notification.Action.Builder(Icon.createWithResource("", icon), title, pendingIntent).build(); // } else { // return new Notification.Action.Builder(icon, title, pendingIntent).build(); // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public class Support { // public static final String MYPODCASTS_TAG = "[mypodcasts-android]"; // } // // Path: app/src/main/java/com/mypodcasts/support/Support.java // public static final String MYPODCASTS_TAG = "[mypodcasts-android]"; // Path: app/src/main/java/com/mypodcasts/player/AudioPlayerService.java import android.content.Context; import android.content.Intent; import android.os.IBinder; import android.util.Log; import com.mypodcasts.player.events.AudioStoppedEvent; import com.mypodcasts.player.notification.AudioPlayerNotification; import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.support.Support; import java.io.IOException; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import roboguice.service.RoboService; import static com.mypodcasts.support.Support.MYPODCASTS_TAG; return START_NOT_STICKY; } @Override public void onDestroy() { super.onDestroy(); audioPlayer.release(); } private void handleMediaControlByAction(Intent intent) { if (intent.getAction() == null) return; if (intent.getAction().equalsIgnoreCase(ACTION_REWIND)) { Log.d(MYPODCASTS_TAG, ACTION_REWIND); audioPlayer.seekTo(audioPlayer.getCurrentPosition() - POSITION); } if (intent.getAction().equalsIgnoreCase(ACTION_PAUSE)) { Log.d(MYPODCASTS_TAG, ACTION_PAUSE); audioPlayer.pause(); } if (intent.getAction().equalsIgnoreCase(ACTION_STOP)) { Log.d(MYPODCASTS_TAG, ACTION_STOP); audioPlayer.pause(); stopForeground(true);
eventBus.post(new AudioStoppedEvent());
alabeduarte/mypodcasts-android
app/src/test/java/com/mypodcasts/util/EpisodeHelper.java
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // }
import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed;
package com.mypodcasts.util; public class EpisodeHelper { public static Episode anEpisode() { return new Episode() { @Override public String getTitle() { return "An awesome episode"; }
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java // public class Episode implements Serializable { // // private String title; // private String publishedDate; // private String description; // private String duration; // private Audio audio; // private Feed podcast; // private Image image; // // public Image getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public Date getPublishedDate() { // if (publishedDate == null) { return null; } // // return dateTimeParser().parseDateTime(publishedDate).toDate(); // } // // public String getDescription() { // return description == null ? "" : description; // } // // public String getDuration() { // return duration; // } // // public Feed getFeed() { // if (podcast == null) { return new Feed(); } // // return podcast; // } // // public String getAudioFilePath() { // return getFeed().getId() + "/" + getTitle() + ".mp3"; // } // // public String getAudioUrl() { // return getAudio().getUrl(); // } // // public String getAudioLength() { // return getAudio().getLength(); // } // // protected Audio getAudio() { // if (audio == null) { return new EmptyAudio(); } // // return audio; // } // // @Override // public String toString() { // return format( // "{ \"title\": %s, " + // "\"audioFilePath\": %s, " + // "\"feed\": { \"id\": %s, \"title\": %s } " + // "}", // getTitle(), // getAudioFilePath(), // getFeed().getId(), // getFeed().getTitle() // ); // } // // private class EmptyAudio extends Audio { // @Override // public String getUrl() { // return ""; // } // // @Override // public String getLength() { // return "0"; // } // } // } // // Path: app/src/main/java/com/mypodcasts/repositories/models/Feed.java // public class Feed implements Serializable { // private String id; // private String title; // private Image image; // private List<Episode> episodes; // // public String getId() { // return id; // } // // public String getTitle() { // return title; // } // // public Image getImage() { // return image; // } // // public List<Episode> getEpisodes() { // return episodes; // } // // } // Path: app/src/test/java/com/mypodcasts/util/EpisodeHelper.java import com.mypodcasts.repositories.models.Episode; import com.mypodcasts.repositories.models.Feed; package com.mypodcasts.util; public class EpisodeHelper { public static Episode anEpisode() { return new Episode() { @Override public String getTitle() { return "An awesome episode"; }
@Override public Feed getFeed() {