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 |
|---|---|---|---|---|---|---|
trsvax/tapestry-facebook | src/main/java/com/trsvax/facebook/components/ShareButton.java | // Path: src/main/java/com/trsvax/facebook/services/FBAsyncSupport.java
// public interface FBAsyncSupport {
//
// public void init(FBInit fbinit);
// public void init(String init);
// public void meta(Tags tags);
// public void subscribe(String event, ComponentResources resources);
// public void render();
// public void updateDocument(FacebookEnvironment facebookEnvironment, Document document);
//
// }
| import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.SupportsInformalParameters;
import org.apache.tapestry5.ioc.annotations.Inject;
import com.trsvax.facebook.services.FBAsyncSupport; |
//Copyright [2011] [Barry Books]
// 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.trsvax.facebook.components;
/**
* @author bfb
* Facebook XFBML ShareButton component
* replace kind'a by the like button
*
*/
@SupportsInformalParameters
public class ShareButton {
@Inject
private ComponentResources componentResources;
@Environmental | // Path: src/main/java/com/trsvax/facebook/services/FBAsyncSupport.java
// public interface FBAsyncSupport {
//
// public void init(FBInit fbinit);
// public void init(String init);
// public void meta(Tags tags);
// public void subscribe(String event, ComponentResources resources);
// public void render();
// public void updateDocument(FacebookEnvironment facebookEnvironment, Document document);
//
// }
// Path: src/main/java/com/trsvax/facebook/components/ShareButton.java
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.SupportsInformalParameters;
import org.apache.tapestry5.ioc.annotations.Inject;
import com.trsvax.facebook.services.FBAsyncSupport;
//Copyright [2011] [Barry Books]
// 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.trsvax.facebook.components;
/**
* @author bfb
* Facebook XFBML ShareButton component
* replace kind'a by the like button
*
*/
@SupportsInformalParameters
public class ShareButton {
@Inject
private ComponentResources componentResources;
@Environmental | private FBAsyncSupport fbAsyncSupport; |
trsvax/tapestry-facebook | src/main/java/com/trsvax/tapestry/facebook/components/Comments.java | // Path: src/main/java/com/trsvax/tapestry/facebook/services/FBAsyncSupport.java
// public interface FBAsyncSupport {
//
// public void init(FBInit fbinit);
// public void init(String init);
// public void meta(Tags tags);
// public void subscribe(String event, ComponentResources resources);
// public void render();
//
// }
| import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.SupportsInformalParameters;
import org.apache.tapestry5.ioc.annotations.Inject;
import com.trsvax.tapestry.facebook.services.FBAsyncSupport; |
//Copyright [2011] [Barry Books]
// 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.trsvax.tapestry.facebook.components;
/**
* @author bfb
* Facebook XFBML Comments component
* @see <a href="http://developers.facebook.com/docs/reference/plugins/comments/">Comments</a>
*
*/
@SupportsInformalParameters
public class Comments {
@Inject
private ComponentResources componentResources;
@Environmental | // Path: src/main/java/com/trsvax/tapestry/facebook/services/FBAsyncSupport.java
// public interface FBAsyncSupport {
//
// public void init(FBInit fbinit);
// public void init(String init);
// public void meta(Tags tags);
// public void subscribe(String event, ComponentResources resources);
// public void render();
//
// }
// Path: src/main/java/com/trsvax/tapestry/facebook/components/Comments.java
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.SupportsInformalParameters;
import org.apache.tapestry5.ioc.annotations.Inject;
import com.trsvax.tapestry.facebook.services.FBAsyncSupport;
//Copyright [2011] [Barry Books]
// 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.trsvax.tapestry.facebook.components;
/**
* @author bfb
* Facebook XFBML Comments component
* @see <a href="http://developers.facebook.com/docs/reference/plugins/comments/">Comments</a>
*
*/
@SupportsInformalParameters
public class Comments {
@Inject
private ComponentResources componentResources;
@Environmental | private FBAsyncSupport fbAsyncSupport; |
trsvax/tapestry-facebook | src/main/java/com/trsvax/tapestry/facebook/components/NewsFeed.java | // Path: src/main/java/com/trsvax/tapestry/facebook/services/FBAsyncSupport.java
// public interface FBAsyncSupport {
//
// public void init(FBInit fbinit);
// public void init(String init);
// public void meta(Tags tags);
// public void subscribe(String event, ComponentResources resources);
// public void render();
//
// }
| import java.io.StringWriter;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.AfterRender;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;
import com.trsvax.tapestry.facebook.services.FBAsyncSupport; |
//Copyright [2011] [Barry Books]
// 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.trsvax.tapestry.facebook.components;
public class NewsFeed {
@Parameter
private String name;
@Parameter
private String link;
@Parameter
private String picture;
@Parameter
private String caption;
@Parameter
private String description;
@Parameter
private String message;
@Environmental | // Path: src/main/java/com/trsvax/tapestry/facebook/services/FBAsyncSupport.java
// public interface FBAsyncSupport {
//
// public void init(FBInit fbinit);
// public void init(String init);
// public void meta(Tags tags);
// public void subscribe(String event, ComponentResources resources);
// public void render();
//
// }
// Path: src/main/java/com/trsvax/tapestry/facebook/components/NewsFeed.java
import java.io.StringWriter;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.AfterRender;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;
import com.trsvax.tapestry.facebook.services.FBAsyncSupport;
//Copyright [2011] [Barry Books]
// 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.trsvax.tapestry.facebook.components;
public class NewsFeed {
@Parameter
private String name;
@Parameter
private String link;
@Parameter
private String picture;
@Parameter
private String caption;
@Parameter
private String description;
@Parameter
private String message;
@Environmental | private FBAsyncSupport fbAsyncSupport; |
trsvax/tapestry-facebook | src/main/java/com/trsvax/facebook/components/Metadata.java | // Path: src/main/java/com/trsvax/facebook/opengraph/Tags.java
// public class Tags {
//
// private String applicationID;
// private String title;
// private String type;
// private String url;
// private String imageURL;
// private String siteName;
// private String description;
// private String admins;
//
// public String getApplicationID() {
// return applicationID;
// }
// public void setApplicationID(String applicationID) {
// this.applicationID = applicationID;
// }
// public String getTitle() {
// return title;
// }
// public void setTitle(String title) {
// this.title = title;
// }
// public String getType() {
// return type;
// }
// public void setType(String type) {
// this.type = type;
// }
// public String getUrl() {
// return url;
// }
// public void setUrl(String url) {
// this.url = url;
// }
// public String getImageURL() {
// return imageURL;
// }
// public void setImageURL(String imageURL) {
// this.imageURL = imageURL;
// }
// public String getSiteName() {
// return siteName;
// }
// public void setSiteName(String siteName) {
// this.siteName = siteName;
// }
// public String getDescription() {
// return description;
// }
// public void setDescription(String description) {
// this.description = description;
// }
// public void setAdmins(String admins) {
// this.admins = admins;
// }
// public String getAdmins() {
// return admins;
// }
//
//
// }
| import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Parameter;
import com.trsvax.facebook.opengraph.Tags; |
//Copyright [2011] [Barry Books]
// 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.trsvax.facebook.components;
public class Metadata {
@Parameter(autoconnect=true) | // Path: src/main/java/com/trsvax/facebook/opengraph/Tags.java
// public class Tags {
//
// private String applicationID;
// private String title;
// private String type;
// private String url;
// private String imageURL;
// private String siteName;
// private String description;
// private String admins;
//
// public String getApplicationID() {
// return applicationID;
// }
// public void setApplicationID(String applicationID) {
// this.applicationID = applicationID;
// }
// public String getTitle() {
// return title;
// }
// public void setTitle(String title) {
// this.title = title;
// }
// public String getType() {
// return type;
// }
// public void setType(String type) {
// this.type = type;
// }
// public String getUrl() {
// return url;
// }
// public void setUrl(String url) {
// this.url = url;
// }
// public String getImageURL() {
// return imageURL;
// }
// public void setImageURL(String imageURL) {
// this.imageURL = imageURL;
// }
// public String getSiteName() {
// return siteName;
// }
// public void setSiteName(String siteName) {
// this.siteName = siteName;
// }
// public String getDescription() {
// return description;
// }
// public void setDescription(String description) {
// this.description = description;
// }
// public void setAdmins(String admins) {
// this.admins = admins;
// }
// public String getAdmins() {
// return admins;
// }
//
//
// }
// Path: src/main/java/com/trsvax/facebook/components/Metadata.java
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Parameter;
import com.trsvax.facebook.opengraph.Tags;
//Copyright [2011] [Barry Books]
// 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.trsvax.facebook.components;
public class Metadata {
@Parameter(autoconnect=true) | private Tags tags; |
trsvax/tapestry-facebook | src/main/java/com/trsvax/tapestry/facebook/components/LikeBox.java | // Path: src/main/java/com/trsvax/tapestry/facebook/services/FBAsyncSupport.java
// public interface FBAsyncSupport {
//
// public void init(FBInit fbinit);
// public void init(String init);
// public void meta(Tags tags);
// public void subscribe(String event, ComponentResources resources);
// public void render();
//
// }
| import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.AfterRender;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.SupportsInformalParameters;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;
import com.trsvax.tapestry.facebook.services.FBAsyncSupport; |
//Copyright [2011] [Barry Books]
// 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.trsvax.tapestry.facebook.components;
/**
* @author bfb
* Facebook XFBML Like Box component
* @see <a href="http://developers.facebook.com/docs/reference/plugins/like-box/">Like Box</a>
*
*/
@SupportsInformalParameters
public class LikeBox {
@Parameter(value = "literal:edge.create,edge.remove")
private String events;
@Environmental | // Path: src/main/java/com/trsvax/tapestry/facebook/services/FBAsyncSupport.java
// public interface FBAsyncSupport {
//
// public void init(FBInit fbinit);
// public void init(String init);
// public void meta(Tags tags);
// public void subscribe(String event, ComponentResources resources);
// public void render();
//
// }
// Path: src/main/java/com/trsvax/tapestry/facebook/components/LikeBox.java
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.AfterRender;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.SupportsInformalParameters;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;
import com.trsvax.tapestry.facebook.services.FBAsyncSupport;
//Copyright [2011] [Barry Books]
// 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.trsvax.tapestry.facebook.components;
/**
* @author bfb
* Facebook XFBML Like Box component
* @see <a href="http://developers.facebook.com/docs/reference/plugins/like-box/">Like Box</a>
*
*/
@SupportsInformalParameters
public class LikeBox {
@Parameter(value = "literal:edge.create,edge.remove")
private String events;
@Environmental | private FBAsyncSupport fbAsync; |
trsvax/tapestry-facebook | src/main/java/com/trsvax/facebook/components/Facepile.java | // Path: src/main/java/com/trsvax/facebook/services/FBAsyncSupport.java
// public interface FBAsyncSupport {
//
// public void init(FBInit fbinit);
// public void init(String init);
// public void meta(Tags tags);
// public void subscribe(String event, ComponentResources resources);
// public void render();
// public void updateDocument(FacebookEnvironment facebookEnvironment, Document document);
//
// }
| import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.SupportsInformalParameters;
import org.apache.tapestry5.ioc.annotations.Inject;
import com.trsvax.facebook.services.FBAsyncSupport; |
//Copyright [2011] [Barry Books]
// 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.trsvax.facebook.components;
/**
* @author bfb
* Facebook XFBML Facepile component
* @see <a href="http://developers.facebook.com/docs/reference/plugins/facepile/">Facepile</a>
*
*/
@SupportsInformalParameters
public class Facepile {
@Inject
private ComponentResources componentResources;
@Environmental | // Path: src/main/java/com/trsvax/facebook/services/FBAsyncSupport.java
// public interface FBAsyncSupport {
//
// public void init(FBInit fbinit);
// public void init(String init);
// public void meta(Tags tags);
// public void subscribe(String event, ComponentResources resources);
// public void render();
// public void updateDocument(FacebookEnvironment facebookEnvironment, Document document);
//
// }
// Path: src/main/java/com/trsvax/facebook/components/Facepile.java
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.SupportsInformalParameters;
import org.apache.tapestry5.ioc.annotations.Inject;
import com.trsvax.facebook.services.FBAsyncSupport;
//Copyright [2011] [Barry Books]
// 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.trsvax.facebook.components;
/**
* @author bfb
* Facebook XFBML Facepile component
* @see <a href="http://developers.facebook.com/docs/reference/plugins/facepile/">Facepile</a>
*
*/
@SupportsInformalParameters
public class Facepile {
@Inject
private ComponentResources componentResources;
@Environmental | private FBAsyncSupport fbAsyncSupport; |
trsvax/tapestry-facebook | src/main/java/com/trsvax/tapestry/facebook/services/FBAsyncSupportImpl.java | // Path: src/main/java/com/trsvax/tapestry/facebook/FBInit.java
// public class FBInit {
//
// private String appID;
// private Boolean cookie;
// private Boolean logging;
// private Object session;
// private Boolean status;
// private Boolean xfbml = true;
// private String channelURL;
//
// public String getAppID() {
// return appID;
// }
//
// public void setAppID(String appID) {
// this.appID = appID;
// }
//
// public Boolean getCookie() {
// return cookie;
// }
//
// public void setCookie(Boolean cookie) {
// this.cookie = cookie;
// }
//
// public Boolean getLogging() {
// return logging;
// }
//
// public void setLogging(Boolean logging) {
// this.logging = logging;
// }
//
// public Object getSession() {
// return session;
// }
//
// public void setSession(Object session) {
// this.session = session;
// }
//
// public Boolean getStatus() {
// return status;
// }
//
// public void setStatus(Boolean status) {
// this.status = status;
// }
//
// public Boolean getXfbml() {
// return xfbml;
// }
//
// public void setXfbml(Boolean xfbml) {
// this.xfbml = xfbml;
// }
//
// public String getChannelURL() {
// return channelURL;
// }
//
// public void setChannelURL(String channelURL) {
// this.channelURL = channelURL;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/trsvax/tapestry/facebook/opengraph/Tags.java
// public class Tags {
//
// private String applicationID;
// private String title;
// private String type;
// private String url;
// private String imageURL;
// private String siteName;
// private String description;
// private String admins;
//
// public String getApplicationID() {
// return applicationID;
// }
// public void setApplicationID(String applicationID) {
// this.applicationID = applicationID;
// }
// public String getTitle() {
// return title;
// }
// public void setTitle(String title) {
// this.title = title;
// }
// public String getType() {
// return type;
// }
// public void setType(String type) {
// this.type = type;
// }
// public String getUrl() {
// return url;
// }
// public void setUrl(String url) {
// this.url = url;
// }
// public String getImageURL() {
// return imageURL;
// }
// public void setImageURL(String imageURL) {
// this.imageURL = imageURL;
// }
// public String getSiteName() {
// return siteName;
// }
// public void setSiteName(String siteName) {
// this.siteName = siteName;
// }
// public String getDescription() {
// return description;
// }
// public void setDescription(String description) {
// this.description = description;
// }
// public void setAdmins(String admins) {
// this.admins = admins;
// }
// public String getAdmins() {
// return admins;
// }
//
//
// }
| import com.trsvax.tapestry.facebook.opengraph.Tags;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.dom.Document;
import org.apache.tapestry5.dom.Element;
import org.apache.tapestry5.services.RequestGlobals;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;
import org.slf4j.Logger;
import com.trsvax.tapestry.facebook.FBInit; |
//Copyright [2011] [Barry Books]
// 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.trsvax.tapestry.facebook.services;
public class FBAsyncSupportImpl implements FBAsyncSupport {
private final Logger logger;
private final RequestGlobals requestGlobals;
private final String context;
private final JavaScriptSupport javaScriptSupport;
| // Path: src/main/java/com/trsvax/tapestry/facebook/FBInit.java
// public class FBInit {
//
// private String appID;
// private Boolean cookie;
// private Boolean logging;
// private Object session;
// private Boolean status;
// private Boolean xfbml = true;
// private String channelURL;
//
// public String getAppID() {
// return appID;
// }
//
// public void setAppID(String appID) {
// this.appID = appID;
// }
//
// public Boolean getCookie() {
// return cookie;
// }
//
// public void setCookie(Boolean cookie) {
// this.cookie = cookie;
// }
//
// public Boolean getLogging() {
// return logging;
// }
//
// public void setLogging(Boolean logging) {
// this.logging = logging;
// }
//
// public Object getSession() {
// return session;
// }
//
// public void setSession(Object session) {
// this.session = session;
// }
//
// public Boolean getStatus() {
// return status;
// }
//
// public void setStatus(Boolean status) {
// this.status = status;
// }
//
// public Boolean getXfbml() {
// return xfbml;
// }
//
// public void setXfbml(Boolean xfbml) {
// this.xfbml = xfbml;
// }
//
// public String getChannelURL() {
// return channelURL;
// }
//
// public void setChannelURL(String channelURL) {
// this.channelURL = channelURL;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/trsvax/tapestry/facebook/opengraph/Tags.java
// public class Tags {
//
// private String applicationID;
// private String title;
// private String type;
// private String url;
// private String imageURL;
// private String siteName;
// private String description;
// private String admins;
//
// public String getApplicationID() {
// return applicationID;
// }
// public void setApplicationID(String applicationID) {
// this.applicationID = applicationID;
// }
// public String getTitle() {
// return title;
// }
// public void setTitle(String title) {
// this.title = title;
// }
// public String getType() {
// return type;
// }
// public void setType(String type) {
// this.type = type;
// }
// public String getUrl() {
// return url;
// }
// public void setUrl(String url) {
// this.url = url;
// }
// public String getImageURL() {
// return imageURL;
// }
// public void setImageURL(String imageURL) {
// this.imageURL = imageURL;
// }
// public String getSiteName() {
// return siteName;
// }
// public void setSiteName(String siteName) {
// this.siteName = siteName;
// }
// public String getDescription() {
// return description;
// }
// public void setDescription(String description) {
// this.description = description;
// }
// public void setAdmins(String admins) {
// this.admins = admins;
// }
// public String getAdmins() {
// return admins;
// }
//
//
// }
// Path: src/main/java/com/trsvax/tapestry/facebook/services/FBAsyncSupportImpl.java
import com.trsvax.tapestry.facebook.opengraph.Tags;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.dom.Document;
import org.apache.tapestry5.dom.Element;
import org.apache.tapestry5.services.RequestGlobals;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;
import org.slf4j.Logger;
import com.trsvax.tapestry.facebook.FBInit;
//Copyright [2011] [Barry Books]
// 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.trsvax.tapestry.facebook.services;
public class FBAsyncSupportImpl implements FBAsyncSupport {
private final Logger logger;
private final RequestGlobals requestGlobals;
private final String context;
private final JavaScriptSupport javaScriptSupport;
| private FBInit fbinit; |
trsvax/tapestry-facebook | src/main/java/com/trsvax/tapestry/facebook/services/FBAsyncSupportImpl.java | // Path: src/main/java/com/trsvax/tapestry/facebook/FBInit.java
// public class FBInit {
//
// private String appID;
// private Boolean cookie;
// private Boolean logging;
// private Object session;
// private Boolean status;
// private Boolean xfbml = true;
// private String channelURL;
//
// public String getAppID() {
// return appID;
// }
//
// public void setAppID(String appID) {
// this.appID = appID;
// }
//
// public Boolean getCookie() {
// return cookie;
// }
//
// public void setCookie(Boolean cookie) {
// this.cookie = cookie;
// }
//
// public Boolean getLogging() {
// return logging;
// }
//
// public void setLogging(Boolean logging) {
// this.logging = logging;
// }
//
// public Object getSession() {
// return session;
// }
//
// public void setSession(Object session) {
// this.session = session;
// }
//
// public Boolean getStatus() {
// return status;
// }
//
// public void setStatus(Boolean status) {
// this.status = status;
// }
//
// public Boolean getXfbml() {
// return xfbml;
// }
//
// public void setXfbml(Boolean xfbml) {
// this.xfbml = xfbml;
// }
//
// public String getChannelURL() {
// return channelURL;
// }
//
// public void setChannelURL(String channelURL) {
// this.channelURL = channelURL;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/trsvax/tapestry/facebook/opengraph/Tags.java
// public class Tags {
//
// private String applicationID;
// private String title;
// private String type;
// private String url;
// private String imageURL;
// private String siteName;
// private String description;
// private String admins;
//
// public String getApplicationID() {
// return applicationID;
// }
// public void setApplicationID(String applicationID) {
// this.applicationID = applicationID;
// }
// public String getTitle() {
// return title;
// }
// public void setTitle(String title) {
// this.title = title;
// }
// public String getType() {
// return type;
// }
// public void setType(String type) {
// this.type = type;
// }
// public String getUrl() {
// return url;
// }
// public void setUrl(String url) {
// this.url = url;
// }
// public String getImageURL() {
// return imageURL;
// }
// public void setImageURL(String imageURL) {
// this.imageURL = imageURL;
// }
// public String getSiteName() {
// return siteName;
// }
// public void setSiteName(String siteName) {
// this.siteName = siteName;
// }
// public String getDescription() {
// return description;
// }
// public void setDescription(String description) {
// this.description = description;
// }
// public void setAdmins(String admins) {
// this.admins = admins;
// }
// public String getAdmins() {
// return admins;
// }
//
//
// }
| import com.trsvax.tapestry.facebook.opengraph.Tags;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.dom.Document;
import org.apache.tapestry5.dom.Element;
import org.apache.tapestry5.services.RequestGlobals;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;
import org.slf4j.Logger;
import com.trsvax.tapestry.facebook.FBInit; |
//Copyright [2011] [Barry Books]
// 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.trsvax.tapestry.facebook.services;
public class FBAsyncSupportImpl implements FBAsyncSupport {
private final Logger logger;
private final RequestGlobals requestGlobals;
private final String context;
private final JavaScriptSupport javaScriptSupport;
private FBInit fbinit; | // Path: src/main/java/com/trsvax/tapestry/facebook/FBInit.java
// public class FBInit {
//
// private String appID;
// private Boolean cookie;
// private Boolean logging;
// private Object session;
// private Boolean status;
// private Boolean xfbml = true;
// private String channelURL;
//
// public String getAppID() {
// return appID;
// }
//
// public void setAppID(String appID) {
// this.appID = appID;
// }
//
// public Boolean getCookie() {
// return cookie;
// }
//
// public void setCookie(Boolean cookie) {
// this.cookie = cookie;
// }
//
// public Boolean getLogging() {
// return logging;
// }
//
// public void setLogging(Boolean logging) {
// this.logging = logging;
// }
//
// public Object getSession() {
// return session;
// }
//
// public void setSession(Object session) {
// this.session = session;
// }
//
// public Boolean getStatus() {
// return status;
// }
//
// public void setStatus(Boolean status) {
// this.status = status;
// }
//
// public Boolean getXfbml() {
// return xfbml;
// }
//
// public void setXfbml(Boolean xfbml) {
// this.xfbml = xfbml;
// }
//
// public String getChannelURL() {
// return channelURL;
// }
//
// public void setChannelURL(String channelURL) {
// this.channelURL = channelURL;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/trsvax/tapestry/facebook/opengraph/Tags.java
// public class Tags {
//
// private String applicationID;
// private String title;
// private String type;
// private String url;
// private String imageURL;
// private String siteName;
// private String description;
// private String admins;
//
// public String getApplicationID() {
// return applicationID;
// }
// public void setApplicationID(String applicationID) {
// this.applicationID = applicationID;
// }
// public String getTitle() {
// return title;
// }
// public void setTitle(String title) {
// this.title = title;
// }
// public String getType() {
// return type;
// }
// public void setType(String type) {
// this.type = type;
// }
// public String getUrl() {
// return url;
// }
// public void setUrl(String url) {
// this.url = url;
// }
// public String getImageURL() {
// return imageURL;
// }
// public void setImageURL(String imageURL) {
// this.imageURL = imageURL;
// }
// public String getSiteName() {
// return siteName;
// }
// public void setSiteName(String siteName) {
// this.siteName = siteName;
// }
// public String getDescription() {
// return description;
// }
// public void setDescription(String description) {
// this.description = description;
// }
// public void setAdmins(String admins) {
// this.admins = admins;
// }
// public String getAdmins() {
// return admins;
// }
//
//
// }
// Path: src/main/java/com/trsvax/tapestry/facebook/services/FBAsyncSupportImpl.java
import com.trsvax.tapestry.facebook.opengraph.Tags;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.dom.Document;
import org.apache.tapestry5.dom.Element;
import org.apache.tapestry5.services.RequestGlobals;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;
import org.slf4j.Logger;
import com.trsvax.tapestry.facebook.FBInit;
//Copyright [2011] [Barry Books]
// 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.trsvax.tapestry.facebook.services;
public class FBAsyncSupportImpl implements FBAsyncSupport {
private final Logger logger;
private final RequestGlobals requestGlobals;
private final String context;
private final JavaScriptSupport javaScriptSupport;
private FBInit fbinit; | private Tags tags; |
trsvax/tapestry-facebook | src/main/java/com/trsvax/tapestry/facebook/components/Recommendations.java | // Path: src/main/java/com/trsvax/tapestry/facebook/services/FBAsyncSupport.java
// public interface FBAsyncSupport {
//
// public void init(FBInit fbinit);
// public void init(String init);
// public void meta(Tags tags);
// public void subscribe(String event, ComponentResources resources);
// public void render();
//
// }
| import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.SupportsInformalParameters;
import org.apache.tapestry5.ioc.annotations.Inject;
import com.trsvax.tapestry.facebook.services.FBAsyncSupport; |
//Copyright [2011] [Barry Books]
// 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.trsvax.tapestry.facebook.components;
/**
* @author bfb
* Facebook XFBML Recommendations component
* @see <a href="http://developers.facebook.com/docs/reference/plugins/recommendations/">Recommendations</a>
*
*/
@SupportsInformalParameters
public class Recommendations {
@Inject
private ComponentResources componentResources;
@Environmental | // Path: src/main/java/com/trsvax/tapestry/facebook/services/FBAsyncSupport.java
// public interface FBAsyncSupport {
//
// public void init(FBInit fbinit);
// public void init(String init);
// public void meta(Tags tags);
// public void subscribe(String event, ComponentResources resources);
// public void render();
//
// }
// Path: src/main/java/com/trsvax/tapestry/facebook/components/Recommendations.java
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.SupportsInformalParameters;
import org.apache.tapestry5.ioc.annotations.Inject;
import com.trsvax.tapestry.facebook.services.FBAsyncSupport;
//Copyright [2011] [Barry Books]
// 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.trsvax.tapestry.facebook.components;
/**
* @author bfb
* Facebook XFBML Recommendations component
* @see <a href="http://developers.facebook.com/docs/reference/plugins/recommendations/">Recommendations</a>
*
*/
@SupportsInformalParameters
public class Recommendations {
@Inject
private ComponentResources componentResources;
@Environmental | private FBAsyncSupport fbAsyncSupport; |
xdevs23/Cornowser | app/src/main/java/org/xdevs23/crypto/hashing/HashUtils.java | // Path: app/src/main/java/org/xdevs23/debugutils/StackTraceParser.java
// public class StackTraceParser {
//
// public static String parse(Throwable throwable) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// throwable.printStackTrace(pw);
// return sw.toString();
// }
//
// public static void logStackTrace(Throwable throwable) {
// Logging.logd(parse(throwable));
// }
//
// }
| import org.xdevs23.crypto.HexUtils;
import org.xdevs23.debugutils.StackTraceParser;
import java.security.MessageDigest; | MD5 = "MD5",
MD6 = "MD6",
SHA1 = "SHA-1",
SHA128 = "SHA-128",
SHA256 = "SHA-256",
SHA512 = "SHA-512",
BLAKE256 = "BLAKE-256",
BLAKE512 = "BLAKE-512",
ECOH = "ECOH",
FSB = "FSB",
GOST = "GOST",
RIPEMD = "RIPEMD",
RIPEMD128 = "RIPEMD-128",
RIPEMD160 = "RIPEMD-160",
RIPEMD320 = "RIPEMD-320",
SWIFFT = "SWIFFT",
TIGER = "Tiger",
WHIRLPOOL = "Whirlpool"
;
}
public static String hash(byte[] data, String type, String defaultValue) {
try {
MessageDigest md = MessageDigest.getInstance(type);
md.update(data, 0, data.length);
byte[] hash = md.digest();
return HexUtils.convertToHex(hash);
} catch(Exception ex) { | // Path: app/src/main/java/org/xdevs23/debugutils/StackTraceParser.java
// public class StackTraceParser {
//
// public static String parse(Throwable throwable) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// throwable.printStackTrace(pw);
// return sw.toString();
// }
//
// public static void logStackTrace(Throwable throwable) {
// Logging.logd(parse(throwable));
// }
//
// }
// Path: app/src/main/java/org/xdevs23/crypto/hashing/HashUtils.java
import org.xdevs23.crypto.HexUtils;
import org.xdevs23.debugutils.StackTraceParser;
import java.security.MessageDigest;
MD5 = "MD5",
MD6 = "MD6",
SHA1 = "SHA-1",
SHA128 = "SHA-128",
SHA256 = "SHA-256",
SHA512 = "SHA-512",
BLAKE256 = "BLAKE-256",
BLAKE512 = "BLAKE-512",
ECOH = "ECOH",
FSB = "FSB",
GOST = "GOST",
RIPEMD = "RIPEMD",
RIPEMD128 = "RIPEMD-128",
RIPEMD160 = "RIPEMD-160",
RIPEMD320 = "RIPEMD-320",
SWIFFT = "SWIFFT",
TIGER = "Tiger",
WHIRLPOOL = "Whirlpool"
;
}
public static String hash(byte[] data, String type, String defaultValue) {
try {
MessageDigest md = MessageDigest.getInstance(type);
md.update(data, 0, data.length);
byte[] hash = md.digest();
return HexUtils.convertToHex(hash);
} catch(Exception ex) { | StackTraceParser.logStackTrace(ex); |
xdevs23/Cornowser | app/src/main/java/io/xdevs23/cornowser/browser/ExternalInit.java | // Path: app/src/main/java/io/xdevs23/cornowser/browser/activity/BookmarkHistoryActivity.java
// public class BookmarkHistoryActivity extends AppCompatActivity {
//
// public static String[] tabTitles;
// private Fragment[] fragments = {
// new BookmarkFragment(),
// new HistoryFragment()
// };
//
// /**
// * The {@link android.support.v4.view.PagerAdapter} that will provide
// * fragments for each of the sections. We use a
// * {@link FragmentPagerAdapter} derivative, which will keep every
// * loaded fragment in memory. If this becomes too memory intensive, it
// * may be best to switch to a
// * {@link android.support.v4.app.FragmentStatePagerAdapter}.
// */
// private SectionsPagerAdapter mSectionsPagerAdapter;
//
// /**
// * The {@link ViewPager} that will host the section contents.
// */
// private ViewPager mViewPager;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_bookmark_history);
//
// Toolbar toolbar = (Toolbar) findViewById(R.id.bkmhis_toolbar);
// setSupportActionBar(toolbar);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// BarColors.enableBarColoring(getWindow(), R.color.bkmhis_statusbar_background);
//
// // Create the adapter that will return a fragment for each of the three
// // primary sections of the activity.
// mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
//
// // Set up the ViewPager with the sections adapter.
// mViewPager = (ViewPager) findViewById(R.id.bkmhis_container);
// mViewPager.setAdapter(mSectionsPagerAdapter);
//
// TabLayout tabLayout = (TabLayout) findViewById(R.id.bkmhis_tabs);
// tabLayout.setupWithViewPager(mViewPager);
// }
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// getMenuInflater().inflate(R.menu.menu_bookmark_history, menu);
// return true;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// int id = item.getItemId();
//
// switch(id) {
// case R.id.bkmhis_action_delete_all:
// if (mViewPager.getCurrentItem() == 0) {
// ((BookmarkFragment)fragments[0]).bookmarks.createNew();
// CornBrowser.getBrowserStorage().putString(
// BrowserStorage.BPrefKeys.bookmarksPref,
// ((BookmarkFragment)fragments[0]).bookmarks.toString()
// );
// ((BookmarkFragment)fragments[0]).updateAdapter();
// } else {
// ((HistoryFragment)fragments[1]).history.createNew();
// CornBrowser.getBrowserStorage().putString(
// BrowserStorage.BPrefKeys.historyPref,
// ((HistoryFragment)fragments[1]).history.toString()
// );
// ((HistoryFragment)fragments[1]).updateAdapter();
// CornBrowser.getWebEngine().eraseHistory();
// }
// mSectionsPagerAdapter.notifyDataSetChanged();
// break;
// default: break;
// }
//
// return super.onOptionsItemSelected(item);
// }
//
// /**
// * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
// * one of the sections/tabs/pages.
// */
// public class SectionsPagerAdapter extends FragmentPagerAdapter {
//
// public SectionsPagerAdapter(FragmentManager fm) {
// super(fm);
// }
//
// @Override
// public Fragment getItem(int position) {
// return fragments[position];
// }
//
// @Override
// public int getCount() {
// try {
// return tabTitles.length;
// } catch(NullPointerException ex) {
// return 1;
// }
// }
//
// @Override
// public CharSequence getPageTitle(int position) {
// try {
// return tabTitles[position];
// } catch(NullPointerException | IndexOutOfBoundsException ex) {
// // We know that (for whatever reason) one of the above exceptions can occur.
// // So let's catch them and give an empty string instead of crashing or
// // giving null back.
// return "";
// }
// }
// }
//
// }
| import android.content.Context;
import io.xdevs23.cornowser.browser.activity.BookmarkHistoryActivity; | package io.xdevs23.cornowser.browser;
public class ExternalInit {
private ExternalInit() {
}
protected static void initBookmarkHistory(Context context) { | // Path: app/src/main/java/io/xdevs23/cornowser/browser/activity/BookmarkHistoryActivity.java
// public class BookmarkHistoryActivity extends AppCompatActivity {
//
// public static String[] tabTitles;
// private Fragment[] fragments = {
// new BookmarkFragment(),
// new HistoryFragment()
// };
//
// /**
// * The {@link android.support.v4.view.PagerAdapter} that will provide
// * fragments for each of the sections. We use a
// * {@link FragmentPagerAdapter} derivative, which will keep every
// * loaded fragment in memory. If this becomes too memory intensive, it
// * may be best to switch to a
// * {@link android.support.v4.app.FragmentStatePagerAdapter}.
// */
// private SectionsPagerAdapter mSectionsPagerAdapter;
//
// /**
// * The {@link ViewPager} that will host the section contents.
// */
// private ViewPager mViewPager;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_bookmark_history);
//
// Toolbar toolbar = (Toolbar) findViewById(R.id.bkmhis_toolbar);
// setSupportActionBar(toolbar);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// BarColors.enableBarColoring(getWindow(), R.color.bkmhis_statusbar_background);
//
// // Create the adapter that will return a fragment for each of the three
// // primary sections of the activity.
// mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
//
// // Set up the ViewPager with the sections adapter.
// mViewPager = (ViewPager) findViewById(R.id.bkmhis_container);
// mViewPager.setAdapter(mSectionsPagerAdapter);
//
// TabLayout tabLayout = (TabLayout) findViewById(R.id.bkmhis_tabs);
// tabLayout.setupWithViewPager(mViewPager);
// }
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// getMenuInflater().inflate(R.menu.menu_bookmark_history, menu);
// return true;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// int id = item.getItemId();
//
// switch(id) {
// case R.id.bkmhis_action_delete_all:
// if (mViewPager.getCurrentItem() == 0) {
// ((BookmarkFragment)fragments[0]).bookmarks.createNew();
// CornBrowser.getBrowserStorage().putString(
// BrowserStorage.BPrefKeys.bookmarksPref,
// ((BookmarkFragment)fragments[0]).bookmarks.toString()
// );
// ((BookmarkFragment)fragments[0]).updateAdapter();
// } else {
// ((HistoryFragment)fragments[1]).history.createNew();
// CornBrowser.getBrowserStorage().putString(
// BrowserStorage.BPrefKeys.historyPref,
// ((HistoryFragment)fragments[1]).history.toString()
// );
// ((HistoryFragment)fragments[1]).updateAdapter();
// CornBrowser.getWebEngine().eraseHistory();
// }
// mSectionsPagerAdapter.notifyDataSetChanged();
// break;
// default: break;
// }
//
// return super.onOptionsItemSelected(item);
// }
//
// /**
// * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
// * one of the sections/tabs/pages.
// */
// public class SectionsPagerAdapter extends FragmentPagerAdapter {
//
// public SectionsPagerAdapter(FragmentManager fm) {
// super(fm);
// }
//
// @Override
// public Fragment getItem(int position) {
// return fragments[position];
// }
//
// @Override
// public int getCount() {
// try {
// return tabTitles.length;
// } catch(NullPointerException ex) {
// return 1;
// }
// }
//
// @Override
// public CharSequence getPageTitle(int position) {
// try {
// return tabTitles[position];
// } catch(NullPointerException | IndexOutOfBoundsException ex) {
// // We know that (for whatever reason) one of the above exceptions can occur.
// // So let's catch them and give an empty string instead of crashing or
// // giving null back.
// return "";
// }
// }
// }
//
// }
// Path: app/src/main/java/io/xdevs23/cornowser/browser/ExternalInit.java
import android.content.Context;
import io.xdevs23.cornowser.browser.activity.BookmarkHistoryActivity;
package io.xdevs23.cornowser.browser;
public class ExternalInit {
private ExternalInit() {
}
protected static void initBookmarkHistory(Context context) { | BookmarkHistoryActivity.tabTitles = |
xdevs23/Cornowser | app/src/main/java/org/xdevs23/file/FileUtils.java | // Path: app/src/main/java/org/xdevs23/debugutils/StackTraceParser.java
// public class StackTraceParser {
//
// public static String parse(Throwable throwable) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// throwable.printStackTrace(pw);
// return sw.toString();
// }
//
// public static void logStackTrace(Throwable throwable) {
// Logging.logd(parse(throwable));
// }
//
// }
| import android.graphics.Bitmap;
import android.util.Log;
import org.xdevs23.debugutils.Logging;
import org.xdevs23.debugutils.StackTraceParser;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Writer;
import java.util.ArrayList; | } else {
return new String[0];
}
}
/**
* Write a String to file
* @param path Path to file
* @param content Content of file
* @return True if successful, false if not
*/
public static boolean writeFileString(String path, String content) {
try {
File fileWrite = new File(path);
File fileDir = new File(fileWrite.toString().substring(0, path.lastIndexOf("/")));
logt("Destination path: " + path);
logt("Making directories...");
fileDir.mkdirs();
Writer writer = new BufferedWriter(new FileWriter(fileWrite));
logt("Writing...");
writer.write(content);
logt("Closing...");
writer.close();
logt("Finished!");
return true;
} catch(Exception ex) { | // Path: app/src/main/java/org/xdevs23/debugutils/StackTraceParser.java
// public class StackTraceParser {
//
// public static String parse(Throwable throwable) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// throwable.printStackTrace(pw);
// return sw.toString();
// }
//
// public static void logStackTrace(Throwable throwable) {
// Logging.logd(parse(throwable));
// }
//
// }
// Path: app/src/main/java/org/xdevs23/file/FileUtils.java
import android.graphics.Bitmap;
import android.util.Log;
import org.xdevs23.debugutils.Logging;
import org.xdevs23.debugutils.StackTraceParser;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Writer;
import java.util.ArrayList;
} else {
return new String[0];
}
}
/**
* Write a String to file
* @param path Path to file
* @param content Content of file
* @return True if successful, false if not
*/
public static boolean writeFileString(String path, String content) {
try {
File fileWrite = new File(path);
File fileDir = new File(fileWrite.toString().substring(0, path.lastIndexOf("/")));
logt("Destination path: " + path);
logt("Making directories...");
fileDir.mkdirs();
Writer writer = new BufferedWriter(new FileWriter(fileWrite));
logt("Writing...");
writer.write(content);
logt("Closing...");
writer.close();
logt("Finished!");
return true;
} catch(Exception ex) { | StackTraceParser.logStackTrace(ex); |
xdevs23/Cornowser | app/src/main/java/org/xdevs23/io/stream/InputStreamUtils.java | // Path: app/src/main/java/org/xdevs23/debugutils/StackTraceParser.java
// public class StackTraceParser {
//
// public static String parse(Throwable throwable) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// throwable.printStackTrace(pw);
// return sw.toString();
// }
//
// public static void logStackTrace(Throwable throwable) {
// Logging.logd(parse(throwable));
// }
//
// }
| import org.apache.commons.io.IOUtils;
import org.xdevs23.debugutils.StackTraceParser;
import java.io.InputStream; | package org.xdevs23.io.stream;
public class InputStreamUtils {
public static String readToString(InputStream inputStream) {
try {
return IOUtils.toString(inputStream, "UTF-8");
} catch(Exception ex) { | // Path: app/src/main/java/org/xdevs23/debugutils/StackTraceParser.java
// public class StackTraceParser {
//
// public static String parse(Throwable throwable) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// throwable.printStackTrace(pw);
// return sw.toString();
// }
//
// public static void logStackTrace(Throwable throwable) {
// Logging.logd(parse(throwable));
// }
//
// }
// Path: app/src/main/java/org/xdevs23/io/stream/InputStreamUtils.java
import org.apache.commons.io.IOUtils;
import org.xdevs23.debugutils.StackTraceParser;
import java.io.InputStream;
package org.xdevs23.io.stream;
public class InputStreamUtils {
public static String readToString(InputStream inputStream) {
try {
return IOUtils.toString(inputStream, "UTF-8");
} catch(Exception ex) { | StackTraceParser.logStackTrace(ex); |
xdevs23/Cornowser | app/src/main/java/org/xdevs23/threading/BackgroundRunner.java | // Path: app/src/main/java/org/xdevs23/debugutils/StackTraceParser.java
// public class StackTraceParser {
//
// public static String parse(Throwable throwable) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// throwable.printStackTrace(pw);
// return sw.toString();
// }
//
// public static void logStackTrace(Throwable throwable) {
// Logging.logd(parse(throwable));
// }
//
// }
| import android.os.Handler;
import org.xdevs23.debugutils.StackTraceParser; | package org.xdevs23.threading;
/**
* A class used to run something in background
*/
public class BackgroundRunner {
private BackgroundRunner() {
}
public synchronized static void runInBackground(final Runnable runnable, final Handler handler) {
Runnable wrap = new Runnable() {
@Override
public void run() {
try {
runnable.run();
} catch(Exception ex) { | // Path: app/src/main/java/org/xdevs23/debugutils/StackTraceParser.java
// public class StackTraceParser {
//
// public static String parse(Throwable throwable) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// throwable.printStackTrace(pw);
// return sw.toString();
// }
//
// public static void logStackTrace(Throwable throwable) {
// Logging.logd(parse(throwable));
// }
//
// }
// Path: app/src/main/java/org/xdevs23/threading/BackgroundRunner.java
import android.os.Handler;
import org.xdevs23.debugutils.StackTraceParser;
package org.xdevs23.threading;
/**
* A class used to run something in background
*/
public class BackgroundRunner {
private BackgroundRunner() {
}
public synchronized static void runInBackground(final Runnable runnable, final Handler handler) {
Runnable wrap = new Runnable() {
@Override
public void run() {
try {
runnable.run();
} catch(Exception ex) { | StackTraceParser.logStackTrace(ex); |
xdevs23/Cornowser | app/src/main/java/org/xdevs23/ui/dialog/EditTextDialog.java | // Path: app/src/main/java/org/xdevs23/android/app/XquidCompatActivity.java
// public class XquidCompatActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// Logging.logd("INIT START");
// super.onCreate(savedInstanceState);
//
// // Logging.logd only logs to logcat if debug mode is enabled
// // Disable debug mode when releasing the app
// Logging.logd("DEBUG ENABLED");
// Logging.logd(
// "Using debug mode could (maybe) have impact on performance. " +
// "Please make sure that you use release mode when releasing a new " +
// "version to get the best performance and avoid logcat spamming."
// );
//
// if(ConfigUtils.isDebuggable())
// Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
// @Override
// public void uncaughtException(Thread thread, Throwable ex) {
// StackTraceParser.logStackTrace(ex);
// android.os.Process.killProcess(android.os.Process.myPid());
// finish();
// }
// });
//
// BarColors.enableBarColoring(this.getWindow(), R.color.colorPrimaryDark);
// }
//
// public static float dp2px(Context context, float dp) {
// DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
// return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, displayMetrics);
// }
//
// protected void endApplication() {
// onDestroy();
// finish();
// android.os.Process.killProcess(android.os.Process.myPid());
// }
//
// protected void softEndApplication() {
// onDestroy();
// finish();
// }
//
// }
//
// Path: app/src/main/java/org/xdevs23/android/widget/XquidRelativeLayout.java
// public class XquidRelativeLayout extends RelativeLayout {
//
// private AttributeSet attrs;
//
// public XquidRelativeLayout(Context context) {
// super(context);
// }
//
// public XquidRelativeLayout(Context context, AttributeSet attrs) {
// super(context, attrs);
// this.attrs = attrs;
// }
//
// public XquidRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// this.attrs = attrs;
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public XquidRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
// super(context, attrs, defStyleAttr, defStyleRes);
// this.attrs = attrs;
// }
//
// public AttributeSet getAttributeSet() {
// return attrs;
// }
//
// public static void addRuleLP(int rule, RelativeLayout.LayoutParams... params) {
// LayoutParams.addRule(rule, params);
// }
//
// public static class LayoutParams extends RelativeLayout.LayoutParams {
//
// public LayoutParams(Context c, AttributeSet attrs) {
// super(c, attrs);
// }
//
// public LayoutParams(int w, int h) {
// super(w, h);
// }
//
// public LayoutParams(MarginLayoutParams source) {
// super(source);
// }
//
// @TargetApi(Build.VERSION_CODES.KITKAT)
// public LayoutParams(RelativeLayout.LayoutParams source) {
// super(source);
// }
//
// public static RelativeLayout.LayoutParams getPredefinedLPFromViewMetrics(View view) {
// return new RelativeLayout.LayoutParams
// (view.getLayoutParams().width, view.getLayoutParams().height);
// }
//
// public static void addRule(int rule, RelativeLayout.LayoutParams... params) {
// for(RelativeLayout.LayoutParams p : params)
// p.addRule(rule);
// }
//
// public LayoutParams(ViewGroup.LayoutParams source) {
// super(source);
// }
//
// public void setMarginsDp(int left, int top, int right, int bottom, Context context) {
// this.setMargins(
// DpUtil.dp2px(context, left),
// DpUtil.dp2px(context, top),
// DpUtil.dp2px(context, right),
// DpUtil.dp2px(context, bottom)
// );
// }
// }
//
// }
//
// Path: app/src/main/java/org/xdevs23/ui/dialog/templates/DismissDialogButton.java
// public class DismissDialogButton implements DialogInterface.OnClickListener {
//
// @Override
// public void onClick(DialogInterface dialog, int id) {
// dialog.dismiss();
// }
//
// }
| import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatEditText;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.inputmethod.InputMethodManager;
import android.widget.TextView;
import org.xdevs23.android.app.XquidCompatActivity;
import org.xdevs23.android.widget.XquidRelativeLayout;
import org.xdevs23.general.ExtendedAndroidClass;
import org.xdevs23.ui.dialog.templates.DismissDialogButton;
import org.xdevs23.ui.utils.DpUtil;
import io.xdevs23.cornowser.browser.R; | public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
};
}
public EditTextDialog setOnClickListener(DialogInterface.OnClickListener onClickListener) {
this.onClickListener = onClickListener;
return this;
}
public EditTextDialog setPrivateActivity(AppCompatActivity activity) {
this.mActivity = activity;
return this;
}
public EditTextDialog setPrivateActivity(XquidCompatActivity activity) {
this.mActivity = activity;
return this;
}
public AppCompatEditText getEditText() {
return mEditText;
}
public String getEnteredText() {
return mEditText.getEditableText().toString();
}
public void showDialog() { | // Path: app/src/main/java/org/xdevs23/android/app/XquidCompatActivity.java
// public class XquidCompatActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// Logging.logd("INIT START");
// super.onCreate(savedInstanceState);
//
// // Logging.logd only logs to logcat if debug mode is enabled
// // Disable debug mode when releasing the app
// Logging.logd("DEBUG ENABLED");
// Logging.logd(
// "Using debug mode could (maybe) have impact on performance. " +
// "Please make sure that you use release mode when releasing a new " +
// "version to get the best performance and avoid logcat spamming."
// );
//
// if(ConfigUtils.isDebuggable())
// Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
// @Override
// public void uncaughtException(Thread thread, Throwable ex) {
// StackTraceParser.logStackTrace(ex);
// android.os.Process.killProcess(android.os.Process.myPid());
// finish();
// }
// });
//
// BarColors.enableBarColoring(this.getWindow(), R.color.colorPrimaryDark);
// }
//
// public static float dp2px(Context context, float dp) {
// DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
// return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, displayMetrics);
// }
//
// protected void endApplication() {
// onDestroy();
// finish();
// android.os.Process.killProcess(android.os.Process.myPid());
// }
//
// protected void softEndApplication() {
// onDestroy();
// finish();
// }
//
// }
//
// Path: app/src/main/java/org/xdevs23/android/widget/XquidRelativeLayout.java
// public class XquidRelativeLayout extends RelativeLayout {
//
// private AttributeSet attrs;
//
// public XquidRelativeLayout(Context context) {
// super(context);
// }
//
// public XquidRelativeLayout(Context context, AttributeSet attrs) {
// super(context, attrs);
// this.attrs = attrs;
// }
//
// public XquidRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// this.attrs = attrs;
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public XquidRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
// super(context, attrs, defStyleAttr, defStyleRes);
// this.attrs = attrs;
// }
//
// public AttributeSet getAttributeSet() {
// return attrs;
// }
//
// public static void addRuleLP(int rule, RelativeLayout.LayoutParams... params) {
// LayoutParams.addRule(rule, params);
// }
//
// public static class LayoutParams extends RelativeLayout.LayoutParams {
//
// public LayoutParams(Context c, AttributeSet attrs) {
// super(c, attrs);
// }
//
// public LayoutParams(int w, int h) {
// super(w, h);
// }
//
// public LayoutParams(MarginLayoutParams source) {
// super(source);
// }
//
// @TargetApi(Build.VERSION_CODES.KITKAT)
// public LayoutParams(RelativeLayout.LayoutParams source) {
// super(source);
// }
//
// public static RelativeLayout.LayoutParams getPredefinedLPFromViewMetrics(View view) {
// return new RelativeLayout.LayoutParams
// (view.getLayoutParams().width, view.getLayoutParams().height);
// }
//
// public static void addRule(int rule, RelativeLayout.LayoutParams... params) {
// for(RelativeLayout.LayoutParams p : params)
// p.addRule(rule);
// }
//
// public LayoutParams(ViewGroup.LayoutParams source) {
// super(source);
// }
//
// public void setMarginsDp(int left, int top, int right, int bottom, Context context) {
// this.setMargins(
// DpUtil.dp2px(context, left),
// DpUtil.dp2px(context, top),
// DpUtil.dp2px(context, right),
// DpUtil.dp2px(context, bottom)
// );
// }
// }
//
// }
//
// Path: app/src/main/java/org/xdevs23/ui/dialog/templates/DismissDialogButton.java
// public class DismissDialogButton implements DialogInterface.OnClickListener {
//
// @Override
// public void onClick(DialogInterface dialog, int id) {
// dialog.dismiss();
// }
//
// }
// Path: app/src/main/java/org/xdevs23/ui/dialog/EditTextDialog.java
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatEditText;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.inputmethod.InputMethodManager;
import android.widget.TextView;
import org.xdevs23.android.app.XquidCompatActivity;
import org.xdevs23.android.widget.XquidRelativeLayout;
import org.xdevs23.general.ExtendedAndroidClass;
import org.xdevs23.ui.dialog.templates.DismissDialogButton;
import org.xdevs23.ui.utils.DpUtil;
import io.xdevs23.cornowser.browser.R;
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
};
}
public EditTextDialog setOnClickListener(DialogInterface.OnClickListener onClickListener) {
this.onClickListener = onClickListener;
return this;
}
public EditTextDialog setPrivateActivity(AppCompatActivity activity) {
this.mActivity = activity;
return this;
}
public EditTextDialog setPrivateActivity(XquidCompatActivity activity) {
this.mActivity = activity;
return this;
}
public AppCompatEditText getEditText() {
return mEditText;
}
public String getEnteredText() {
return mEditText.getEditableText().toString();
}
public void showDialog() { | XquidRelativeLayout dialogContent = new XquidRelativeLayout(getContext()); |
xdevs23/Cornowser | app/src/main/java/io/xdevs23/cornowser/browser/browser/BrowserStorage.java | // Path: app/src/main/java/org/xdevs23/debugutils/StackTraceParser.java
// public class StackTraceParser {
//
// public static String parse(Throwable throwable) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// throwable.printStackTrace(pw);
// return sw.toString();
// }
//
// public static void logStackTrace(Throwable throwable) {
// Logging.logd(parse(throwable));
// }
//
// }
//
// Path: app/src/main/java/org/xdevs23/management/config/SharedPreferenceArray.java
// public class SharedPreferenceArray {
//
// public static String getPreferenceString(String[] array) {
// if(array == null) return "";
// if(array.length == 0) return "";
// StringBuilder sb = new StringBuilder();
// for ( String s : array) {
// String aps;
// if(s == null) return "";
// else aps = s;
// if(s.contains(":")) aps = s.replace(":", "::");
// if(s.contains("|")) aps = aps.replace("|", "||");
// sb.append(aps).append("|:|");
// }
// sb.delete(sb.length() - 3, sb.length());
// return sb.toString();
// }
//
// public static String[] getStringArray(String preferenceString) {
// if(preferenceString == null || preferenceString.isEmpty())
// return new String[] {""};
// String[] array = preferenceString.split("([|][:][|])");
// for ( int i = 0; i < array.length; i++ ) {
// String aps = array[i];
// if(aps.contains(":")) aps = aps.replace("::", ":");
// if(aps.contains("|")) aps = aps.replace("||", "|");
// array[i] = aps;
// }
// return array;
// }
//
// }
//
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/modules/adblock/AdBlockConst.java
// public final class AdBlockConst {
//
// /**
// * These are hosts files
// * They are downloaded and processed to later be used by the ad blocker
// */
// public static final String[] HOST_FILES_ADBLOCK = new String[] {
// "http://adaway.org/hosts.txt",
// "http://winhelp2002.mvps.org/hosts.txt",
// "http://hosts-file.net/ad_servers.txt",
// "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext"
// };
//
// /**
// * There are some conflicts with the listed websites below.
// * So in order to keep them working, this whitelist is required.
// * Please add hosts here if a website does not load with AdBlock enabled.
// */
// public static final String[] WHITELISTED_HOSTS = new String[] {
// "html5test.com",
// "crashlytics.com",
// ".bplaced.com",
// "bplaced.net",
// };
//
// /**
// * Here are some pre-defined ad hosts which can be blocked without a hosts file
// * This increases loading speed hence they are multiple times defined in the hosts files
// */
// public static final String[] PREDEFINED_HOSTS = new String[] {
// // This blocks many ad hosts like doubleclick, mediafarm and more
// "302br.net",
// ".ads.doubleclick.net",
// ".ad.doubleclick.net"
// };
//
// public static final boolean
// NET_BEHAVIOR_WIFI = false;
//
// }
//
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/modules/ui/RenderColorMode.java
// public class RenderColorMode {
//
// public static class ColorMode {
//
// public static final int
// NORMAL = 0,
// DARK = 1,
// NEGATIVE = 2,
// INVERT = 3,
// GREYSCALE = 4;
//
// public int mode = NORMAL;
//
// public ColorMode setColorMode(int colorMode) {
// mode = colorMode;
// return this;
// }
//
// }
//
// public static ColorMode toColorMode(int colorMode) {
// return (new ColorMode()).setColorMode(colorMode);
// }
//
// }
| import android.content.Context;
import android.content.SharedPreferences;
import org.xdevs23.config.ConfigUtils;
import org.xdevs23.debugutils.Logging;
import org.xdevs23.debugutils.StackTraceParser;
import org.xdevs23.management.config.SharedPreferenceArray;
import java.util.ArrayList;
import io.xdevs23.cornowser.browser.browser.modules.adblock.AdBlockConst;
import io.xdevs23.cornowser.browser.browser.modules.ui.RenderColorMode; | package io.xdevs23.cornowser.browser.browser;
public class BrowserStorage {
//region Variable storage
private ArrayList<String> values = new ArrayList<>();
private ArrayList<String> keys = new ArrayList<>();
private String
userHomePage,
customSearchEngine
;
private String[]
lastSession,
adBlockWhitelist
;
private boolean
omniboxIsBottom,
enableFullscreen,
debugEnabled,
omniColoringEnabled,
adBlockEnabled,
saveLastSession,
crashlyticsOptOut,
adBlockNetBehavior,
waitForAdBlock
;
| // Path: app/src/main/java/org/xdevs23/debugutils/StackTraceParser.java
// public class StackTraceParser {
//
// public static String parse(Throwable throwable) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// throwable.printStackTrace(pw);
// return sw.toString();
// }
//
// public static void logStackTrace(Throwable throwable) {
// Logging.logd(parse(throwable));
// }
//
// }
//
// Path: app/src/main/java/org/xdevs23/management/config/SharedPreferenceArray.java
// public class SharedPreferenceArray {
//
// public static String getPreferenceString(String[] array) {
// if(array == null) return "";
// if(array.length == 0) return "";
// StringBuilder sb = new StringBuilder();
// for ( String s : array) {
// String aps;
// if(s == null) return "";
// else aps = s;
// if(s.contains(":")) aps = s.replace(":", "::");
// if(s.contains("|")) aps = aps.replace("|", "||");
// sb.append(aps).append("|:|");
// }
// sb.delete(sb.length() - 3, sb.length());
// return sb.toString();
// }
//
// public static String[] getStringArray(String preferenceString) {
// if(preferenceString == null || preferenceString.isEmpty())
// return new String[] {""};
// String[] array = preferenceString.split("([|][:][|])");
// for ( int i = 0; i < array.length; i++ ) {
// String aps = array[i];
// if(aps.contains(":")) aps = aps.replace("::", ":");
// if(aps.contains("|")) aps = aps.replace("||", "|");
// array[i] = aps;
// }
// return array;
// }
//
// }
//
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/modules/adblock/AdBlockConst.java
// public final class AdBlockConst {
//
// /**
// * These are hosts files
// * They are downloaded and processed to later be used by the ad blocker
// */
// public static final String[] HOST_FILES_ADBLOCK = new String[] {
// "http://adaway.org/hosts.txt",
// "http://winhelp2002.mvps.org/hosts.txt",
// "http://hosts-file.net/ad_servers.txt",
// "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext"
// };
//
// /**
// * There are some conflicts with the listed websites below.
// * So in order to keep them working, this whitelist is required.
// * Please add hosts here if a website does not load with AdBlock enabled.
// */
// public static final String[] WHITELISTED_HOSTS = new String[] {
// "html5test.com",
// "crashlytics.com",
// ".bplaced.com",
// "bplaced.net",
// };
//
// /**
// * Here are some pre-defined ad hosts which can be blocked without a hosts file
// * This increases loading speed hence they are multiple times defined in the hosts files
// */
// public static final String[] PREDEFINED_HOSTS = new String[] {
// // This blocks many ad hosts like doubleclick, mediafarm and more
// "302br.net",
// ".ads.doubleclick.net",
// ".ad.doubleclick.net"
// };
//
// public static final boolean
// NET_BEHAVIOR_WIFI = false;
//
// }
//
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/modules/ui/RenderColorMode.java
// public class RenderColorMode {
//
// public static class ColorMode {
//
// public static final int
// NORMAL = 0,
// DARK = 1,
// NEGATIVE = 2,
// INVERT = 3,
// GREYSCALE = 4;
//
// public int mode = NORMAL;
//
// public ColorMode setColorMode(int colorMode) {
// mode = colorMode;
// return this;
// }
//
// }
//
// public static ColorMode toColorMode(int colorMode) {
// return (new ColorMode()).setColorMode(colorMode);
// }
//
// }
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/BrowserStorage.java
import android.content.Context;
import android.content.SharedPreferences;
import org.xdevs23.config.ConfigUtils;
import org.xdevs23.debugutils.Logging;
import org.xdevs23.debugutils.StackTraceParser;
import org.xdevs23.management.config.SharedPreferenceArray;
import java.util.ArrayList;
import io.xdevs23.cornowser.browser.browser.modules.adblock.AdBlockConst;
import io.xdevs23.cornowser.browser.browser.modules.ui.RenderColorMode;
package io.xdevs23.cornowser.browser.browser;
public class BrowserStorage {
//region Variable storage
private ArrayList<String> values = new ArrayList<>();
private ArrayList<String> keys = new ArrayList<>();
private String
userHomePage,
customSearchEngine
;
private String[]
lastSession,
adBlockWhitelist
;
private boolean
omniboxIsBottom,
enableFullscreen,
debugEnabled,
omniColoringEnabled,
adBlockEnabled,
saveLastSession,
crashlyticsOptOut,
adBlockNetBehavior,
waitForAdBlock
;
| private RenderColorMode.ColorMode renderingColorMode; |
xdevs23/Cornowser | app/src/main/java/io/xdevs23/cornowser/browser/browser/BrowserStorage.java | // Path: app/src/main/java/org/xdevs23/debugutils/StackTraceParser.java
// public class StackTraceParser {
//
// public static String parse(Throwable throwable) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// throwable.printStackTrace(pw);
// return sw.toString();
// }
//
// public static void logStackTrace(Throwable throwable) {
// Logging.logd(parse(throwable));
// }
//
// }
//
// Path: app/src/main/java/org/xdevs23/management/config/SharedPreferenceArray.java
// public class SharedPreferenceArray {
//
// public static String getPreferenceString(String[] array) {
// if(array == null) return "";
// if(array.length == 0) return "";
// StringBuilder sb = new StringBuilder();
// for ( String s : array) {
// String aps;
// if(s == null) return "";
// else aps = s;
// if(s.contains(":")) aps = s.replace(":", "::");
// if(s.contains("|")) aps = aps.replace("|", "||");
// sb.append(aps).append("|:|");
// }
// sb.delete(sb.length() - 3, sb.length());
// return sb.toString();
// }
//
// public static String[] getStringArray(String preferenceString) {
// if(preferenceString == null || preferenceString.isEmpty())
// return new String[] {""};
// String[] array = preferenceString.split("([|][:][|])");
// for ( int i = 0; i < array.length; i++ ) {
// String aps = array[i];
// if(aps.contains(":")) aps = aps.replace("::", ":");
// if(aps.contains("|")) aps = aps.replace("||", "|");
// array[i] = aps;
// }
// return array;
// }
//
// }
//
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/modules/adblock/AdBlockConst.java
// public final class AdBlockConst {
//
// /**
// * These are hosts files
// * They are downloaded and processed to later be used by the ad blocker
// */
// public static final String[] HOST_FILES_ADBLOCK = new String[] {
// "http://adaway.org/hosts.txt",
// "http://winhelp2002.mvps.org/hosts.txt",
// "http://hosts-file.net/ad_servers.txt",
// "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext"
// };
//
// /**
// * There are some conflicts with the listed websites below.
// * So in order to keep them working, this whitelist is required.
// * Please add hosts here if a website does not load with AdBlock enabled.
// */
// public static final String[] WHITELISTED_HOSTS = new String[] {
// "html5test.com",
// "crashlytics.com",
// ".bplaced.com",
// "bplaced.net",
// };
//
// /**
// * Here are some pre-defined ad hosts which can be blocked without a hosts file
// * This increases loading speed hence they are multiple times defined in the hosts files
// */
// public static final String[] PREDEFINED_HOSTS = new String[] {
// // This blocks many ad hosts like doubleclick, mediafarm and more
// "302br.net",
// ".ads.doubleclick.net",
// ".ad.doubleclick.net"
// };
//
// public static final boolean
// NET_BEHAVIOR_WIFI = false;
//
// }
//
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/modules/ui/RenderColorMode.java
// public class RenderColorMode {
//
// public static class ColorMode {
//
// public static final int
// NORMAL = 0,
// DARK = 1,
// NEGATIVE = 2,
// INVERT = 3,
// GREYSCALE = 4;
//
// public int mode = NORMAL;
//
// public ColorMode setColorMode(int colorMode) {
// mode = colorMode;
// return this;
// }
//
// }
//
// public static ColorMode toColorMode(int colorMode) {
// return (new ColorMode()).setColorMode(colorMode);
// }
//
// }
| import android.content.Context;
import android.content.SharedPreferences;
import org.xdevs23.config.ConfigUtils;
import org.xdevs23.debugutils.Logging;
import org.xdevs23.debugutils.StackTraceParser;
import org.xdevs23.management.config.SharedPreferenceArray;
import java.util.ArrayList;
import io.xdevs23.cornowser.browser.browser.modules.adblock.AdBlockConst;
import io.xdevs23.cornowser.browser.browser.modules.ui.RenderColorMode; |
private RenderColorMode.ColorMode renderingColorMode;
private BrowserStorageEnums.SearchEngine searchEngine;
//endregion
//region Class section
private Context myContext;
public SharedPreferences mSharedPreferences;
public BrowserStorage(Context context) {
myContext = context;
init();
}
public void init() {
mSharedPreferences = getContext().getSharedPreferences("userprefs", 0);
loadSettings();
setUserHomePage(getPref(BPrefKeys.userHomePage, BrowserDefaults.HOME_URL));
setOmniboxPosition(getPref(BPrefKeys.omniboxPos, false));
setEnableFullscreen(getPref(BPrefKeys.fullscreenPref, false));
setColorMode(getPref(BPrefKeys.colorModePref, RenderColorMode.ColorMode.NORMAL));
setOmniColoring(getPref(BPrefKeys.omniColorPref, true));
setSearchEngine(BrowserStorageEnums.SearchEngine.valueOf(getPref(BPrefKeys.searchEngPref,
BrowserStorageEnums.SearchEngine.Google.name())));
setDebugMode(getPref(BPrefKeys.debugModePref, false));
setEnableAdBlock(getPref(BPrefKeys.adBlockEnPref, false)); | // Path: app/src/main/java/org/xdevs23/debugutils/StackTraceParser.java
// public class StackTraceParser {
//
// public static String parse(Throwable throwable) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// throwable.printStackTrace(pw);
// return sw.toString();
// }
//
// public static void logStackTrace(Throwable throwable) {
// Logging.logd(parse(throwable));
// }
//
// }
//
// Path: app/src/main/java/org/xdevs23/management/config/SharedPreferenceArray.java
// public class SharedPreferenceArray {
//
// public static String getPreferenceString(String[] array) {
// if(array == null) return "";
// if(array.length == 0) return "";
// StringBuilder sb = new StringBuilder();
// for ( String s : array) {
// String aps;
// if(s == null) return "";
// else aps = s;
// if(s.contains(":")) aps = s.replace(":", "::");
// if(s.contains("|")) aps = aps.replace("|", "||");
// sb.append(aps).append("|:|");
// }
// sb.delete(sb.length() - 3, sb.length());
// return sb.toString();
// }
//
// public static String[] getStringArray(String preferenceString) {
// if(preferenceString == null || preferenceString.isEmpty())
// return new String[] {""};
// String[] array = preferenceString.split("([|][:][|])");
// for ( int i = 0; i < array.length; i++ ) {
// String aps = array[i];
// if(aps.contains(":")) aps = aps.replace("::", ":");
// if(aps.contains("|")) aps = aps.replace("||", "|");
// array[i] = aps;
// }
// return array;
// }
//
// }
//
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/modules/adblock/AdBlockConst.java
// public final class AdBlockConst {
//
// /**
// * These are hosts files
// * They are downloaded and processed to later be used by the ad blocker
// */
// public static final String[] HOST_FILES_ADBLOCK = new String[] {
// "http://adaway.org/hosts.txt",
// "http://winhelp2002.mvps.org/hosts.txt",
// "http://hosts-file.net/ad_servers.txt",
// "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext"
// };
//
// /**
// * There are some conflicts with the listed websites below.
// * So in order to keep them working, this whitelist is required.
// * Please add hosts here if a website does not load with AdBlock enabled.
// */
// public static final String[] WHITELISTED_HOSTS = new String[] {
// "html5test.com",
// "crashlytics.com",
// ".bplaced.com",
// "bplaced.net",
// };
//
// /**
// * Here are some pre-defined ad hosts which can be blocked without a hosts file
// * This increases loading speed hence they are multiple times defined in the hosts files
// */
// public static final String[] PREDEFINED_HOSTS = new String[] {
// // This blocks many ad hosts like doubleclick, mediafarm and more
// "302br.net",
// ".ads.doubleclick.net",
// ".ad.doubleclick.net"
// };
//
// public static final boolean
// NET_BEHAVIOR_WIFI = false;
//
// }
//
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/modules/ui/RenderColorMode.java
// public class RenderColorMode {
//
// public static class ColorMode {
//
// public static final int
// NORMAL = 0,
// DARK = 1,
// NEGATIVE = 2,
// INVERT = 3,
// GREYSCALE = 4;
//
// public int mode = NORMAL;
//
// public ColorMode setColorMode(int colorMode) {
// mode = colorMode;
// return this;
// }
//
// }
//
// public static ColorMode toColorMode(int colorMode) {
// return (new ColorMode()).setColorMode(colorMode);
// }
//
// }
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/BrowserStorage.java
import android.content.Context;
import android.content.SharedPreferences;
import org.xdevs23.config.ConfigUtils;
import org.xdevs23.debugutils.Logging;
import org.xdevs23.debugutils.StackTraceParser;
import org.xdevs23.management.config.SharedPreferenceArray;
import java.util.ArrayList;
import io.xdevs23.cornowser.browser.browser.modules.adblock.AdBlockConst;
import io.xdevs23.cornowser.browser.browser.modules.ui.RenderColorMode;
private RenderColorMode.ColorMode renderingColorMode;
private BrowserStorageEnums.SearchEngine searchEngine;
//endregion
//region Class section
private Context myContext;
public SharedPreferences mSharedPreferences;
public BrowserStorage(Context context) {
myContext = context;
init();
}
public void init() {
mSharedPreferences = getContext().getSharedPreferences("userprefs", 0);
loadSettings();
setUserHomePage(getPref(BPrefKeys.userHomePage, BrowserDefaults.HOME_URL));
setOmniboxPosition(getPref(BPrefKeys.omniboxPos, false));
setEnableFullscreen(getPref(BPrefKeys.fullscreenPref, false));
setColorMode(getPref(BPrefKeys.colorModePref, RenderColorMode.ColorMode.NORMAL));
setOmniColoring(getPref(BPrefKeys.omniColorPref, true));
setSearchEngine(BrowserStorageEnums.SearchEngine.valueOf(getPref(BPrefKeys.searchEngPref,
BrowserStorageEnums.SearchEngine.Google.name())));
setDebugMode(getPref(BPrefKeys.debugModePref, false));
setEnableAdBlock(getPref(BPrefKeys.adBlockEnPref, false)); | setLastBrowsingSession(SharedPreferenceArray.getStringArray(getPref(BPrefKeys.lastSessionPref, |
xdevs23/Cornowser | app/src/main/java/io/xdevs23/cornowser/browser/browser/BrowserStorage.java | // Path: app/src/main/java/org/xdevs23/debugutils/StackTraceParser.java
// public class StackTraceParser {
//
// public static String parse(Throwable throwable) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// throwable.printStackTrace(pw);
// return sw.toString();
// }
//
// public static void logStackTrace(Throwable throwable) {
// Logging.logd(parse(throwable));
// }
//
// }
//
// Path: app/src/main/java/org/xdevs23/management/config/SharedPreferenceArray.java
// public class SharedPreferenceArray {
//
// public static String getPreferenceString(String[] array) {
// if(array == null) return "";
// if(array.length == 0) return "";
// StringBuilder sb = new StringBuilder();
// for ( String s : array) {
// String aps;
// if(s == null) return "";
// else aps = s;
// if(s.contains(":")) aps = s.replace(":", "::");
// if(s.contains("|")) aps = aps.replace("|", "||");
// sb.append(aps).append("|:|");
// }
// sb.delete(sb.length() - 3, sb.length());
// return sb.toString();
// }
//
// public static String[] getStringArray(String preferenceString) {
// if(preferenceString == null || preferenceString.isEmpty())
// return new String[] {""};
// String[] array = preferenceString.split("([|][:][|])");
// for ( int i = 0; i < array.length; i++ ) {
// String aps = array[i];
// if(aps.contains(":")) aps = aps.replace("::", ":");
// if(aps.contains("|")) aps = aps.replace("||", "|");
// array[i] = aps;
// }
// return array;
// }
//
// }
//
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/modules/adblock/AdBlockConst.java
// public final class AdBlockConst {
//
// /**
// * These are hosts files
// * They are downloaded and processed to later be used by the ad blocker
// */
// public static final String[] HOST_FILES_ADBLOCK = new String[] {
// "http://adaway.org/hosts.txt",
// "http://winhelp2002.mvps.org/hosts.txt",
// "http://hosts-file.net/ad_servers.txt",
// "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext"
// };
//
// /**
// * There are some conflicts with the listed websites below.
// * So in order to keep them working, this whitelist is required.
// * Please add hosts here if a website does not load with AdBlock enabled.
// */
// public static final String[] WHITELISTED_HOSTS = new String[] {
// "html5test.com",
// "crashlytics.com",
// ".bplaced.com",
// "bplaced.net",
// };
//
// /**
// * Here are some pre-defined ad hosts which can be blocked without a hosts file
// * This increases loading speed hence they are multiple times defined in the hosts files
// */
// public static final String[] PREDEFINED_HOSTS = new String[] {
// // This blocks many ad hosts like doubleclick, mediafarm and more
// "302br.net",
// ".ads.doubleclick.net",
// ".ad.doubleclick.net"
// };
//
// public static final boolean
// NET_BEHAVIOR_WIFI = false;
//
// }
//
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/modules/ui/RenderColorMode.java
// public class RenderColorMode {
//
// public static class ColorMode {
//
// public static final int
// NORMAL = 0,
// DARK = 1,
// NEGATIVE = 2,
// INVERT = 3,
// GREYSCALE = 4;
//
// public int mode = NORMAL;
//
// public ColorMode setColorMode(int colorMode) {
// mode = colorMode;
// return this;
// }
//
// }
//
// public static ColorMode toColorMode(int colorMode) {
// return (new ColorMode()).setColorMode(colorMode);
// }
//
// }
| import android.content.Context;
import android.content.SharedPreferences;
import org.xdevs23.config.ConfigUtils;
import org.xdevs23.debugutils.Logging;
import org.xdevs23.debugutils.StackTraceParser;
import org.xdevs23.management.config.SharedPreferenceArray;
import java.util.ArrayList;
import io.xdevs23.cornowser.browser.browser.modules.adblock.AdBlockConst;
import io.xdevs23.cornowser.browser.browser.modules.ui.RenderColorMode; |
//endregion
//region Class section
private Context myContext;
public SharedPreferences mSharedPreferences;
public BrowserStorage(Context context) {
myContext = context;
init();
}
public void init() {
mSharedPreferences = getContext().getSharedPreferences("userprefs", 0);
loadSettings();
setUserHomePage(getPref(BPrefKeys.userHomePage, BrowserDefaults.HOME_URL));
setOmniboxPosition(getPref(BPrefKeys.omniboxPos, false));
setEnableFullscreen(getPref(BPrefKeys.fullscreenPref, false));
setColorMode(getPref(BPrefKeys.colorModePref, RenderColorMode.ColorMode.NORMAL));
setOmniColoring(getPref(BPrefKeys.omniColorPref, true));
setSearchEngine(BrowserStorageEnums.SearchEngine.valueOf(getPref(BPrefKeys.searchEngPref,
BrowserStorageEnums.SearchEngine.Google.name())));
setDebugMode(getPref(BPrefKeys.debugModePref, false));
setEnableAdBlock(getPref(BPrefKeys.adBlockEnPref, false));
setLastBrowsingSession(SharedPreferenceArray.getStringArray(getPref(BPrefKeys.lastSessionPref,
"")));
setSaveBrowsingSession(getPref(BPrefKeys.saveLastSessionPref, false));
setCrashlyticsOptedOut(getPref(BPrefKeys.crashltcOptOutPref, false)); | // Path: app/src/main/java/org/xdevs23/debugutils/StackTraceParser.java
// public class StackTraceParser {
//
// public static String parse(Throwable throwable) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// throwable.printStackTrace(pw);
// return sw.toString();
// }
//
// public static void logStackTrace(Throwable throwable) {
// Logging.logd(parse(throwable));
// }
//
// }
//
// Path: app/src/main/java/org/xdevs23/management/config/SharedPreferenceArray.java
// public class SharedPreferenceArray {
//
// public static String getPreferenceString(String[] array) {
// if(array == null) return "";
// if(array.length == 0) return "";
// StringBuilder sb = new StringBuilder();
// for ( String s : array) {
// String aps;
// if(s == null) return "";
// else aps = s;
// if(s.contains(":")) aps = s.replace(":", "::");
// if(s.contains("|")) aps = aps.replace("|", "||");
// sb.append(aps).append("|:|");
// }
// sb.delete(sb.length() - 3, sb.length());
// return sb.toString();
// }
//
// public static String[] getStringArray(String preferenceString) {
// if(preferenceString == null || preferenceString.isEmpty())
// return new String[] {""};
// String[] array = preferenceString.split("([|][:][|])");
// for ( int i = 0; i < array.length; i++ ) {
// String aps = array[i];
// if(aps.contains(":")) aps = aps.replace("::", ":");
// if(aps.contains("|")) aps = aps.replace("||", "|");
// array[i] = aps;
// }
// return array;
// }
//
// }
//
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/modules/adblock/AdBlockConst.java
// public final class AdBlockConst {
//
// /**
// * These are hosts files
// * They are downloaded and processed to later be used by the ad blocker
// */
// public static final String[] HOST_FILES_ADBLOCK = new String[] {
// "http://adaway.org/hosts.txt",
// "http://winhelp2002.mvps.org/hosts.txt",
// "http://hosts-file.net/ad_servers.txt",
// "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext"
// };
//
// /**
// * There are some conflicts with the listed websites below.
// * So in order to keep them working, this whitelist is required.
// * Please add hosts here if a website does not load with AdBlock enabled.
// */
// public static final String[] WHITELISTED_HOSTS = new String[] {
// "html5test.com",
// "crashlytics.com",
// ".bplaced.com",
// "bplaced.net",
// };
//
// /**
// * Here are some pre-defined ad hosts which can be blocked without a hosts file
// * This increases loading speed hence they are multiple times defined in the hosts files
// */
// public static final String[] PREDEFINED_HOSTS = new String[] {
// // This blocks many ad hosts like doubleclick, mediafarm and more
// "302br.net",
// ".ads.doubleclick.net",
// ".ad.doubleclick.net"
// };
//
// public static final boolean
// NET_BEHAVIOR_WIFI = false;
//
// }
//
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/modules/ui/RenderColorMode.java
// public class RenderColorMode {
//
// public static class ColorMode {
//
// public static final int
// NORMAL = 0,
// DARK = 1,
// NEGATIVE = 2,
// INVERT = 3,
// GREYSCALE = 4;
//
// public int mode = NORMAL;
//
// public ColorMode setColorMode(int colorMode) {
// mode = colorMode;
// return this;
// }
//
// }
//
// public static ColorMode toColorMode(int colorMode) {
// return (new ColorMode()).setColorMode(colorMode);
// }
//
// }
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/BrowserStorage.java
import android.content.Context;
import android.content.SharedPreferences;
import org.xdevs23.config.ConfigUtils;
import org.xdevs23.debugutils.Logging;
import org.xdevs23.debugutils.StackTraceParser;
import org.xdevs23.management.config.SharedPreferenceArray;
import java.util.ArrayList;
import io.xdevs23.cornowser.browser.browser.modules.adblock.AdBlockConst;
import io.xdevs23.cornowser.browser.browser.modules.ui.RenderColorMode;
//endregion
//region Class section
private Context myContext;
public SharedPreferences mSharedPreferences;
public BrowserStorage(Context context) {
myContext = context;
init();
}
public void init() {
mSharedPreferences = getContext().getSharedPreferences("userprefs", 0);
loadSettings();
setUserHomePage(getPref(BPrefKeys.userHomePage, BrowserDefaults.HOME_URL));
setOmniboxPosition(getPref(BPrefKeys.omniboxPos, false));
setEnableFullscreen(getPref(BPrefKeys.fullscreenPref, false));
setColorMode(getPref(BPrefKeys.colorModePref, RenderColorMode.ColorMode.NORMAL));
setOmniColoring(getPref(BPrefKeys.omniColorPref, true));
setSearchEngine(BrowserStorageEnums.SearchEngine.valueOf(getPref(BPrefKeys.searchEngPref,
BrowserStorageEnums.SearchEngine.Google.name())));
setDebugMode(getPref(BPrefKeys.debugModePref, false));
setEnableAdBlock(getPref(BPrefKeys.adBlockEnPref, false));
setLastBrowsingSession(SharedPreferenceArray.getStringArray(getPref(BPrefKeys.lastSessionPref,
"")));
setSaveBrowsingSession(getPref(BPrefKeys.saveLastSessionPref, false));
setCrashlyticsOptedOut(getPref(BPrefKeys.crashltcOptOutPref, false)); | setAdBlockNetBehavior(getPref(BPrefKeys.adBlockNetBehavPref, AdBlockConst.NET_BEHAVIOR_WIFI)); |
xdevs23/Cornowser | app/src/main/java/io/xdevs23/cornowser/browser/browser/BrowserStorage.java | // Path: app/src/main/java/org/xdevs23/debugutils/StackTraceParser.java
// public class StackTraceParser {
//
// public static String parse(Throwable throwable) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// throwable.printStackTrace(pw);
// return sw.toString();
// }
//
// public static void logStackTrace(Throwable throwable) {
// Logging.logd(parse(throwable));
// }
//
// }
//
// Path: app/src/main/java/org/xdevs23/management/config/SharedPreferenceArray.java
// public class SharedPreferenceArray {
//
// public static String getPreferenceString(String[] array) {
// if(array == null) return "";
// if(array.length == 0) return "";
// StringBuilder sb = new StringBuilder();
// for ( String s : array) {
// String aps;
// if(s == null) return "";
// else aps = s;
// if(s.contains(":")) aps = s.replace(":", "::");
// if(s.contains("|")) aps = aps.replace("|", "||");
// sb.append(aps).append("|:|");
// }
// sb.delete(sb.length() - 3, sb.length());
// return sb.toString();
// }
//
// public static String[] getStringArray(String preferenceString) {
// if(preferenceString == null || preferenceString.isEmpty())
// return new String[] {""};
// String[] array = preferenceString.split("([|][:][|])");
// for ( int i = 0; i < array.length; i++ ) {
// String aps = array[i];
// if(aps.contains(":")) aps = aps.replace("::", ":");
// if(aps.contains("|")) aps = aps.replace("||", "|");
// array[i] = aps;
// }
// return array;
// }
//
// }
//
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/modules/adblock/AdBlockConst.java
// public final class AdBlockConst {
//
// /**
// * These are hosts files
// * They are downloaded and processed to later be used by the ad blocker
// */
// public static final String[] HOST_FILES_ADBLOCK = new String[] {
// "http://adaway.org/hosts.txt",
// "http://winhelp2002.mvps.org/hosts.txt",
// "http://hosts-file.net/ad_servers.txt",
// "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext"
// };
//
// /**
// * There are some conflicts with the listed websites below.
// * So in order to keep them working, this whitelist is required.
// * Please add hosts here if a website does not load with AdBlock enabled.
// */
// public static final String[] WHITELISTED_HOSTS = new String[] {
// "html5test.com",
// "crashlytics.com",
// ".bplaced.com",
// "bplaced.net",
// };
//
// /**
// * Here are some pre-defined ad hosts which can be blocked without a hosts file
// * This increases loading speed hence they are multiple times defined in the hosts files
// */
// public static final String[] PREDEFINED_HOSTS = new String[] {
// // This blocks many ad hosts like doubleclick, mediafarm and more
// "302br.net",
// ".ads.doubleclick.net",
// ".ad.doubleclick.net"
// };
//
// public static final boolean
// NET_BEHAVIOR_WIFI = false;
//
// }
//
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/modules/ui/RenderColorMode.java
// public class RenderColorMode {
//
// public static class ColorMode {
//
// public static final int
// NORMAL = 0,
// DARK = 1,
// NEGATIVE = 2,
// INVERT = 3,
// GREYSCALE = 4;
//
// public int mode = NORMAL;
//
// public ColorMode setColorMode(int colorMode) {
// mode = colorMode;
// return this;
// }
//
// }
//
// public static ColorMode toColorMode(int colorMode) {
// return (new ColorMode()).setColorMode(colorMode);
// }
//
// }
| import android.content.Context;
import android.content.SharedPreferences;
import org.xdevs23.config.ConfigUtils;
import org.xdevs23.debugutils.Logging;
import org.xdevs23.debugutils.StackTraceParser;
import org.xdevs23.management.config.SharedPreferenceArray;
import java.util.ArrayList;
import io.xdevs23.cornowser.browser.browser.modules.adblock.AdBlockConst;
import io.xdevs23.cornowser.browser.browser.modules.ui.RenderColorMode; | System.arraycopy(adBlockWhitelist, 0, newList, 0, adBlockWhitelist.length);
newList[newList.length - 1] = domain;
} else newList[0] = domain;
return newList;
}
public String[] removeDomainFromAdBlockWhitelist(String domain) {
Logging.logd("Remove domain from adblock whitelist");
try {
Logging.logd(" Checking...");
String[] newList;
if(adBlockWhitelist.length == 1) {
Logging.logd(" => Erasing new list (only one domain was left)");
newList = null;
} else {
Logging.logd(" => Searching for domain");
newList = new String[adBlockWhitelist.length - 1];
int foundOffset = 0;
for (int i = 0; i < adBlockWhitelist.length; i++) {
if (adBlockWhitelist[i].contains(domain)) {
foundOffset = 1;
Logging.logd(" -- Domain found");
} else
newList[i - foundOffset] = adBlockWhitelist[i];
}
}
return newList;
} catch(Exception ex) {
Logging.logd("Removal of domain " + domain + " failed. Printing stack trace."); | // Path: app/src/main/java/org/xdevs23/debugutils/StackTraceParser.java
// public class StackTraceParser {
//
// public static String parse(Throwable throwable) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// throwable.printStackTrace(pw);
// return sw.toString();
// }
//
// public static void logStackTrace(Throwable throwable) {
// Logging.logd(parse(throwable));
// }
//
// }
//
// Path: app/src/main/java/org/xdevs23/management/config/SharedPreferenceArray.java
// public class SharedPreferenceArray {
//
// public static String getPreferenceString(String[] array) {
// if(array == null) return "";
// if(array.length == 0) return "";
// StringBuilder sb = new StringBuilder();
// for ( String s : array) {
// String aps;
// if(s == null) return "";
// else aps = s;
// if(s.contains(":")) aps = s.replace(":", "::");
// if(s.contains("|")) aps = aps.replace("|", "||");
// sb.append(aps).append("|:|");
// }
// sb.delete(sb.length() - 3, sb.length());
// return sb.toString();
// }
//
// public static String[] getStringArray(String preferenceString) {
// if(preferenceString == null || preferenceString.isEmpty())
// return new String[] {""};
// String[] array = preferenceString.split("([|][:][|])");
// for ( int i = 0; i < array.length; i++ ) {
// String aps = array[i];
// if(aps.contains(":")) aps = aps.replace("::", ":");
// if(aps.contains("|")) aps = aps.replace("||", "|");
// array[i] = aps;
// }
// return array;
// }
//
// }
//
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/modules/adblock/AdBlockConst.java
// public final class AdBlockConst {
//
// /**
// * These are hosts files
// * They are downloaded and processed to later be used by the ad blocker
// */
// public static final String[] HOST_FILES_ADBLOCK = new String[] {
// "http://adaway.org/hosts.txt",
// "http://winhelp2002.mvps.org/hosts.txt",
// "http://hosts-file.net/ad_servers.txt",
// "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext"
// };
//
// /**
// * There are some conflicts with the listed websites below.
// * So in order to keep them working, this whitelist is required.
// * Please add hosts here if a website does not load with AdBlock enabled.
// */
// public static final String[] WHITELISTED_HOSTS = new String[] {
// "html5test.com",
// "crashlytics.com",
// ".bplaced.com",
// "bplaced.net",
// };
//
// /**
// * Here are some pre-defined ad hosts which can be blocked without a hosts file
// * This increases loading speed hence they are multiple times defined in the hosts files
// */
// public static final String[] PREDEFINED_HOSTS = new String[] {
// // This blocks many ad hosts like doubleclick, mediafarm and more
// "302br.net",
// ".ads.doubleclick.net",
// ".ad.doubleclick.net"
// };
//
// public static final boolean
// NET_BEHAVIOR_WIFI = false;
//
// }
//
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/modules/ui/RenderColorMode.java
// public class RenderColorMode {
//
// public static class ColorMode {
//
// public static final int
// NORMAL = 0,
// DARK = 1,
// NEGATIVE = 2,
// INVERT = 3,
// GREYSCALE = 4;
//
// public int mode = NORMAL;
//
// public ColorMode setColorMode(int colorMode) {
// mode = colorMode;
// return this;
// }
//
// }
//
// public static ColorMode toColorMode(int colorMode) {
// return (new ColorMode()).setColorMode(colorMode);
// }
//
// }
// Path: app/src/main/java/io/xdevs23/cornowser/browser/browser/BrowserStorage.java
import android.content.Context;
import android.content.SharedPreferences;
import org.xdevs23.config.ConfigUtils;
import org.xdevs23.debugutils.Logging;
import org.xdevs23.debugutils.StackTraceParser;
import org.xdevs23.management.config.SharedPreferenceArray;
import java.util.ArrayList;
import io.xdevs23.cornowser.browser.browser.modules.adblock.AdBlockConst;
import io.xdevs23.cornowser.browser.browser.modules.ui.RenderColorMode;
System.arraycopy(adBlockWhitelist, 0, newList, 0, adBlockWhitelist.length);
newList[newList.length - 1] = domain;
} else newList[0] = domain;
return newList;
}
public String[] removeDomainFromAdBlockWhitelist(String domain) {
Logging.logd("Remove domain from adblock whitelist");
try {
Logging.logd(" Checking...");
String[] newList;
if(adBlockWhitelist.length == 1) {
Logging.logd(" => Erasing new list (only one domain was left)");
newList = null;
} else {
Logging.logd(" => Searching for domain");
newList = new String[adBlockWhitelist.length - 1];
int foundOffset = 0;
for (int i = 0; i < adBlockWhitelist.length; i++) {
if (adBlockWhitelist[i].contains(domain)) {
foundOffset = 1;
Logging.logd(" -- Domain found");
} else
newList[i - foundOffset] = adBlockWhitelist[i];
}
}
return newList;
} catch(Exception ex) {
Logging.logd("Removal of domain " + domain + " failed. Printing stack trace."); | StackTraceParser.logStackTrace(ex); |
xdevs23/Cornowser | app/src/main/java/org/xdevs23/android/content/res/AssetHelper.java | // Path: app/src/main/java/org/xdevs23/io/stream/InputStreamUtils.java
// public class InputStreamUtils {
//
// public static String readToString(InputStream inputStream) {
// try {
// return IOUtils.toString(inputStream, "UTF-8");
// } catch(Exception ex) {
// StackTraceParser.logStackTrace(ex);
// return "";
// }
// }
//
// }
| import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.RawRes;
import org.xdevs23.io.stream.InputStreamUtils;
import java.io.IOException; | package org.xdevs23.android.content.res;
public class AssetHelper {
public static String getAssetString(@RawRes String assetPath, @NonNull Context context) {
try { | // Path: app/src/main/java/org/xdevs23/io/stream/InputStreamUtils.java
// public class InputStreamUtils {
//
// public static String readToString(InputStream inputStream) {
// try {
// return IOUtils.toString(inputStream, "UTF-8");
// } catch(Exception ex) {
// StackTraceParser.logStackTrace(ex);
// return "";
// }
// }
//
// }
// Path: app/src/main/java/org/xdevs23/android/content/res/AssetHelper.java
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.RawRes;
import org.xdevs23.io.stream.InputStreamUtils;
import java.io.IOException;
package org.xdevs23.android.content.res;
public class AssetHelper {
public static String getAssetString(@RawRes String assetPath, @NonNull Context context) {
try { | return InputStreamUtils.readToString(context.getAssets().open(assetPath)); |
xdevs23/Cornowser | app/src/main/java/org/xdevs23/ui/widget/TastyOverflowMenu.java | // Path: app/src/main/java/org/xdevs23/android/app/XquidCompatActivity.java
// public class XquidCompatActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// Logging.logd("INIT START");
// super.onCreate(savedInstanceState);
//
// // Logging.logd only logs to logcat if debug mode is enabled
// // Disable debug mode when releasing the app
// Logging.logd("DEBUG ENABLED");
// Logging.logd(
// "Using debug mode could (maybe) have impact on performance. " +
// "Please make sure that you use release mode when releasing a new " +
// "version to get the best performance and avoid logcat spamming."
// );
//
// if(ConfigUtils.isDebuggable())
// Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
// @Override
// public void uncaughtException(Thread thread, Throwable ex) {
// StackTraceParser.logStackTrace(ex);
// android.os.Process.killProcess(android.os.Process.myPid());
// finish();
// }
// });
//
// BarColors.enableBarColoring(this.getWindow(), R.color.colorPrimaryDark);
// }
//
// public static float dp2px(Context context, float dp) {
// DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
// return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, displayMetrics);
// }
//
// protected void endApplication() {
// onDestroy();
// finish();
// android.os.Process.killProcess(android.os.Process.myPid());
// }
//
// protected void softEndApplication() {
// onDestroy();
// finish();
// }
//
// }
| import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import org.xdevs23.android.app.XquidCompatActivity;
import io.xdevs23.cornowser.browser.R; | package org.xdevs23.ui.widget;
public class TastyOverflowMenu extends ImageButton {
public int
mainColor = Color.BLACK,
pressedColor = Color.BLACK;
private Context ccontext;
public TastyOverflowMenu(Context context) {
super(context);
init(context);
}
public TastyOverflowMenu(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public TastyOverflowMenu(Context context, AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public TastyOverflowMenu(Context context, AttributeSet attrs, int defStyleAttrs, int defStyleRes) {
super(context, attrs, defStyleAttrs, defStyleRes);
init(context);
}
public void init(Context context) {
final Context fContext = context;
ccontext = context;
pressedColor = ContextCompat.getColor(fContext, R.color.dark_semi_more_transparent);
| // Path: app/src/main/java/org/xdevs23/android/app/XquidCompatActivity.java
// public class XquidCompatActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// Logging.logd("INIT START");
// super.onCreate(savedInstanceState);
//
// // Logging.logd only logs to logcat if debug mode is enabled
// // Disable debug mode when releasing the app
// Logging.logd("DEBUG ENABLED");
// Logging.logd(
// "Using debug mode could (maybe) have impact on performance. " +
// "Please make sure that you use release mode when releasing a new " +
// "version to get the best performance and avoid logcat spamming."
// );
//
// if(ConfigUtils.isDebuggable())
// Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
// @Override
// public void uncaughtException(Thread thread, Throwable ex) {
// StackTraceParser.logStackTrace(ex);
// android.os.Process.killProcess(android.os.Process.myPid());
// finish();
// }
// });
//
// BarColors.enableBarColoring(this.getWindow(), R.color.colorPrimaryDark);
// }
//
// public static float dp2px(Context context, float dp) {
// DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
// return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, displayMetrics);
// }
//
// protected void endApplication() {
// onDestroy();
// finish();
// android.os.Process.killProcess(android.os.Process.myPid());
// }
//
// protected void softEndApplication() {
// onDestroy();
// finish();
// }
//
// }
// Path: app/src/main/java/org/xdevs23/ui/widget/TastyOverflowMenu.java
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import org.xdevs23.android.app.XquidCompatActivity;
import io.xdevs23.cornowser.browser.R;
package org.xdevs23.ui.widget;
public class TastyOverflowMenu extends ImageButton {
public int
mainColor = Color.BLACK,
pressedColor = Color.BLACK;
private Context ccontext;
public TastyOverflowMenu(Context context) {
super(context);
init(context);
}
public TastyOverflowMenu(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public TastyOverflowMenu(Context context, AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public TastyOverflowMenu(Context context, AttributeSet attrs, int defStyleAttrs, int defStyleRes) {
super(context, attrs, defStyleAttrs, defStyleRes);
init(context);
}
public void init(Context context) {
final Context fContext = context;
ccontext = context;
pressedColor = ContextCompat.getColor(fContext, R.color.dark_semi_more_transparent);
| int ah = (int)XquidCompatActivity.dp2px(context, 32); |
xdevs23/Cornowser | app/src/main/java/org/xdevs23/config/AppConfig.java | // Path: app/src/main/java/io/xdevs23/cornowser/browser/updater/UpdaterStorage.java
// public class UpdaterStorage {
//
// public static final String
// URL_RAW_GITHUB_USERCONTENT = "https://raw.githubusercontent.com",
// URL_RAW_GIT_REPO = URL_RAW_GITHUB_USERCONTENT + "/xdevs23/Cornowser/master",
//
// URL_LINK_UPDSERVER = URL_RAW_GIT_REPO + "/update/linkserver.txt",
//
// URL_VERSION_CODE = URL_RAW_GIT_REPO + "/update/rel.txt",
// URL_VERSION_NAME = URL_RAW_GIT_REPO + "/update/version.txt",
//
// URL_CHANGELOG = URL_RAW_GIT_REPO + "/update/changelog.txt"
// ;
//
// public static String
// URL_APK
// ;
//
// }
| import io.xdevs23.cornowser.browser.updater.UpdaterStorage; | package org.xdevs23.config;
@SuppressWarnings("unused")
public final class AppConfig {
protected static final String
debug = "debug",
alpha = "alpharelease",
beta = "betarelease",
rel = "release",
nightly = "nightly";
public static final String
appName = "Cornowser",
mainDevUrl = "http://xdevs23.bplaced.com/", | // Path: app/src/main/java/io/xdevs23/cornowser/browser/updater/UpdaterStorage.java
// public class UpdaterStorage {
//
// public static final String
// URL_RAW_GITHUB_USERCONTENT = "https://raw.githubusercontent.com",
// URL_RAW_GIT_REPO = URL_RAW_GITHUB_USERCONTENT + "/xdevs23/Cornowser/master",
//
// URL_LINK_UPDSERVER = URL_RAW_GIT_REPO + "/update/linkserver.txt",
//
// URL_VERSION_CODE = URL_RAW_GIT_REPO + "/update/rel.txt",
// URL_VERSION_NAME = URL_RAW_GIT_REPO + "/update/version.txt",
//
// URL_CHANGELOG = URL_RAW_GIT_REPO + "/update/changelog.txt"
// ;
//
// public static String
// URL_APK
// ;
//
// }
// Path: app/src/main/java/org/xdevs23/config/AppConfig.java
import io.xdevs23.cornowser.browser.updater.UpdaterStorage;
package org.xdevs23.config;
@SuppressWarnings("unused")
public final class AppConfig {
protected static final String
debug = "debug",
alpha = "alpharelease",
beta = "betarelease",
rel = "release",
nightly = "nightly";
public static final String
appName = "Cornowser",
mainDevUrl = "http://xdevs23.bplaced.com/", | updateRoot = UpdaterStorage.URL_RAW_GIT_REPO + "/update/", |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/NetworkingErrorFeedbackTests.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/NetworkingError.java
// public class NetworkingError extends RuntimeException {
//
// public NetworkingError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
// public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
//
// private NetworkingErrorView view;
// private Scheduler uiScheduler;
//
// public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.doOnError(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
//
// if (throwable instanceof NetworkingError) {
// Completable.fromAction(view.reportNetworkingError())
// .observeOn(uiScheduler)
// .subscribe();
// }
//
// return Flowable.error(throwable);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.NetworkingError;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorFeedback;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; | package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/6/17.
*/
public class NetworkingErrorFeedbackTests {
Scheduler uiScheduler = Schedulers.trampoline(); | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/NetworkingError.java
// public class NetworkingError extends RuntimeException {
//
// public NetworkingError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
// public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
//
// private NetworkingErrorView view;
// private Scheduler uiScheduler;
//
// public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.doOnError(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
//
// if (throwable instanceof NetworkingError) {
// Completable.fromAction(view.reportNetworkingError())
// .observeOn(uiScheduler)
// .subscribe();
// }
//
// return Flowable.error(throwable);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/NetworkingErrorFeedbackTests.java
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.NetworkingError;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorFeedback;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/6/17.
*/
public class NetworkingErrorFeedbackTests {
Scheduler uiScheduler = Schedulers.trampoline(); | NetworkingErrorFeedback<String> networkingFeedback; |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/NetworkingErrorFeedbackTests.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/NetworkingError.java
// public class NetworkingError extends RuntimeException {
//
// public NetworkingError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
// public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
//
// private NetworkingErrorView view;
// private Scheduler uiScheduler;
//
// public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.doOnError(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
//
// if (throwable instanceof NetworkingError) {
// Completable.fromAction(view.reportNetworkingError())
// .observeOn(uiScheduler)
// .subscribe();
// }
//
// return Flowable.error(throwable);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.NetworkingError;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorFeedback;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; | package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/6/17.
*/
public class NetworkingErrorFeedbackTests {
Scheduler uiScheduler = Schedulers.trampoline();
NetworkingErrorFeedback<String> networkingFeedback;
@Mock Action report;
@Before public void beforeEachTest() {
MockitoAnnotations.initMocks(this);
networkingFeedback = new NetworkingErrorFeedback<>(() -> report, uiScheduler);
}
@Test public void shouldNotReport_WhenFlowEmmits() throws Exception {
Flowable.just("A", "B")
.compose(networkingFeedback)
.subscribe();
verify(report, never()).run();
}
@Test public void shouldNotReport_WhenFlowIsEmpty() throws Exception {
Flowable<String> noData = Flowable.empty();
noData.compose(networkingFeedback).subscribe();
verify(report, never()).run();
}
@Test public void shouldNotReport_ForNonNetworkingError() throws Exception { | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/NetworkingError.java
// public class NetworkingError extends RuntimeException {
//
// public NetworkingError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
// public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
//
// private NetworkingErrorView view;
// private Scheduler uiScheduler;
//
// public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.doOnError(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
//
// if (throwable instanceof NetworkingError) {
// Completable.fromAction(view.reportNetworkingError())
// .observeOn(uiScheduler)
// .subscribe();
// }
//
// return Flowable.error(throwable);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/NetworkingErrorFeedbackTests.java
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.NetworkingError;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorFeedback;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/6/17.
*/
public class NetworkingErrorFeedbackTests {
Scheduler uiScheduler = Schedulers.trampoline();
NetworkingErrorFeedback<String> networkingFeedback;
@Mock Action report;
@Before public void beforeEachTest() {
MockitoAnnotations.initMocks(this);
networkingFeedback = new NetworkingErrorFeedback<>(() -> report, uiScheduler);
}
@Test public void shouldNotReport_WhenFlowEmmits() throws Exception {
Flowable.just("A", "B")
.compose(networkingFeedback)
.subscribe();
verify(report, never()).run();
}
@Test public void shouldNotReport_WhenFlowIsEmpty() throws Exception {
Flowable<String> noData = Flowable.empty();
noData.compose(networkingFeedback).subscribe();
verify(report, never()).run();
}
@Test public void shouldNotReport_ForNonNetworkingError() throws Exception { | Flowable<String> otherError = Flowable.error(new ContentNotFoundError()); |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/NetworkingErrorFeedbackTests.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/NetworkingError.java
// public class NetworkingError extends RuntimeException {
//
// public NetworkingError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
// public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
//
// private NetworkingErrorView view;
// private Scheduler uiScheduler;
//
// public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.doOnError(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
//
// if (throwable instanceof NetworkingError) {
// Completable.fromAction(view.reportNetworkingError())
// .observeOn(uiScheduler)
// .subscribe();
// }
//
// return Flowable.error(throwable);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.NetworkingError;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorFeedback;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; | package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/6/17.
*/
public class NetworkingErrorFeedbackTests {
Scheduler uiScheduler = Schedulers.trampoline();
NetworkingErrorFeedback<String> networkingFeedback;
@Mock Action report;
@Before public void beforeEachTest() {
MockitoAnnotations.initMocks(this);
networkingFeedback = new NetworkingErrorFeedback<>(() -> report, uiScheduler);
}
@Test public void shouldNotReport_WhenFlowEmmits() throws Exception {
Flowable.just("A", "B")
.compose(networkingFeedback)
.subscribe();
verify(report, never()).run();
}
@Test public void shouldNotReport_WhenFlowIsEmpty() throws Exception {
Flowable<String> noData = Flowable.empty();
noData.compose(networkingFeedback).subscribe();
verify(report, never()).run();
}
@Test public void shouldNotReport_ForNonNetworkingError() throws Exception {
Flowable<String> otherError = Flowable.error(new ContentNotFoundError());
otherError.compose(networkingFeedback).subscribe();
verify(report, never()).run();
}
@Test public void shoulReport_ForNetworkingError() throws Exception { | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/NetworkingError.java
// public class NetworkingError extends RuntimeException {
//
// public NetworkingError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
// public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
//
// private NetworkingErrorView view;
// private Scheduler uiScheduler;
//
// public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.doOnError(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
//
// if (throwable instanceof NetworkingError) {
// Completable.fromAction(view.reportNetworkingError())
// .observeOn(uiScheduler)
// .subscribe();
// }
//
// return Flowable.error(throwable);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/NetworkingErrorFeedbackTests.java
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.NetworkingError;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorFeedback;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/6/17.
*/
public class NetworkingErrorFeedbackTests {
Scheduler uiScheduler = Schedulers.trampoline();
NetworkingErrorFeedback<String> networkingFeedback;
@Mock Action report;
@Before public void beforeEachTest() {
MockitoAnnotations.initMocks(this);
networkingFeedback = new NetworkingErrorFeedback<>(() -> report, uiScheduler);
}
@Test public void shouldNotReport_WhenFlowEmmits() throws Exception {
Flowable.just("A", "B")
.compose(networkingFeedback)
.subscribe();
verify(report, never()).run();
}
@Test public void shouldNotReport_WhenFlowIsEmpty() throws Exception {
Flowable<String> noData = Flowable.empty();
noData.compose(networkingFeedback).subscribe();
verify(report, never()).run();
}
@Test public void shouldNotReport_ForNonNetworkingError() throws Exception {
Flowable<String> otherError = Flowable.error(new ContentNotFoundError());
otherError.compose(networkingFeedback).subscribe();
verify(report, never()).run();
}
@Test public void shoulReport_ForNetworkingError() throws Exception { | Flowable<String> otherError = Flowable.error(new NetworkingError("Canceled")); |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/NetworkingErrorFeedbackTests.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/NetworkingError.java
// public class NetworkingError extends RuntimeException {
//
// public NetworkingError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
// public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
//
// private NetworkingErrorView view;
// private Scheduler uiScheduler;
//
// public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.doOnError(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
//
// if (throwable instanceof NetworkingError) {
// Completable.fromAction(view.reportNetworkingError())
// .observeOn(uiScheduler)
// .subscribe();
// }
//
// return Flowable.error(throwable);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.NetworkingError;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorFeedback;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; | package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/6/17.
*/
public class NetworkingErrorFeedbackTests {
Scheduler uiScheduler = Schedulers.trampoline();
NetworkingErrorFeedback<String> networkingFeedback;
@Mock Action report;
@Before public void beforeEachTest() {
MockitoAnnotations.initMocks(this);
networkingFeedback = new NetworkingErrorFeedback<>(() -> report, uiScheduler);
}
@Test public void shouldNotReport_WhenFlowEmmits() throws Exception {
Flowable.just("A", "B")
.compose(networkingFeedback)
.subscribe();
verify(report, never()).run();
}
@Test public void shouldNotReport_WhenFlowIsEmpty() throws Exception {
Flowable<String> noData = Flowable.empty();
noData.compose(networkingFeedback).subscribe();
verify(report, never()).run();
}
@Test public void shouldNotReport_ForNonNetworkingError() throws Exception {
Flowable<String> otherError = Flowable.error(new ContentNotFoundError());
otherError.compose(networkingFeedback).subscribe();
verify(report, never()).run();
}
@Test public void shoulReport_ForNetworkingError() throws Exception {
Flowable<String> otherError = Flowable.error(new NetworkingError("Canceled"));
otherError.compose(networkingFeedback).subscribe(); | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/NetworkingError.java
// public class NetworkingError extends RuntimeException {
//
// public NetworkingError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
// public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
//
// private NetworkingErrorView view;
// private Scheduler uiScheduler;
//
// public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.doOnError(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
//
// if (throwable instanceof NetworkingError) {
// Completable.fromAction(view.reportNetworkingError())
// .observeOn(uiScheduler)
// .subscribe();
// }
//
// return Flowable.error(throwable);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/NetworkingErrorFeedbackTests.java
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.NetworkingError;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorFeedback;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/6/17.
*/
public class NetworkingErrorFeedbackTests {
Scheduler uiScheduler = Schedulers.trampoline();
NetworkingErrorFeedback<String> networkingFeedback;
@Mock Action report;
@Before public void beforeEachTest() {
MockitoAnnotations.initMocks(this);
networkingFeedback = new NetworkingErrorFeedback<>(() -> report, uiScheduler);
}
@Test public void shouldNotReport_WhenFlowEmmits() throws Exception {
Flowable.just("A", "B")
.compose(networkingFeedback)
.subscribe();
verify(report, never()).run();
}
@Test public void shouldNotReport_WhenFlowIsEmpty() throws Exception {
Flowable<String> noData = Flowable.empty();
noData.compose(networkingFeedback).subscribe();
verify(report, never()).run();
}
@Test public void shouldNotReport_ForNonNetworkingError() throws Exception {
Flowable<String> otherError = Flowable.error(new ContentNotFoundError());
otherError.compose(networkingFeedback).subscribe();
verify(report, never()).run();
}
@Test public void shoulReport_ForNetworkingError() throws Exception {
Flowable<String> otherError = Flowable.error(new NetworkingError("Canceled"));
otherError.compose(networkingFeedback).subscribe(); | verify(report, oneTimeOnly()).run(); |
ubiratansoares/reactive-architectures-playground | app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public class FakeWebService implements NumbersWebService {
//
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// private NextCall nextReturn;
//
//
// public FakeWebService() {
// nextReturn = NextCall.UNDEFINED_ERROR;
// }
//
// public void nextCallPerform(NextCall nextReturn) {
// this.nextReturn = nextReturn;
// }
//
// @Override public Flowable<NumbersTriviaPayload> getTrivia(String commaSeparatedNumbers) {
//
// switch (nextReturn) {
// case SUCCESS_200:
// return FakeResponses.triviaResults();
//
// case NOT_FOUND_404:
// return FakeResponses.notFound();
//
// case INTERNAL_SERVER_ERROR_5xy:
// return FakeResponses.internalServerError();
//
// case CONNECTION_ERROR:
// return FakeResponses.connectionIssue();
//
// case CONNECTION_TIMEOUT:
// return FakeResponses.requestTimeout();
// }
//
// return Flowable.empty();
// }
//
// }
//
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
| import android.app.Activity;
import android.app.Application;
import javax.inject.Inject;
import br.ufs.demos.rxmvp.playground.dagger.components.DaggerAppComponent;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService.NextCall;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector; | package br.ufs.demos.rxmvp.playground.app;
/**
* Created by bira on 6/26/17.
*/
public class MainApplication extends Application implements HasActivityInjector {
@Inject DispatchingAndroidInjector<Activity> injector; | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public class FakeWebService implements NumbersWebService {
//
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// private NextCall nextReturn;
//
//
// public FakeWebService() {
// nextReturn = NextCall.UNDEFINED_ERROR;
// }
//
// public void nextCallPerform(NextCall nextReturn) {
// this.nextReturn = nextReturn;
// }
//
// @Override public Flowable<NumbersTriviaPayload> getTrivia(String commaSeparatedNumbers) {
//
// switch (nextReturn) {
// case SUCCESS_200:
// return FakeResponses.triviaResults();
//
// case NOT_FOUND_404:
// return FakeResponses.notFound();
//
// case INTERNAL_SERVER_ERROR_5xy:
// return FakeResponses.internalServerError();
//
// case CONNECTION_ERROR:
// return FakeResponses.connectionIssue();
//
// case CONNECTION_TIMEOUT:
// return FakeResponses.requestTimeout();
// }
//
// return Flowable.empty();
// }
//
// }
//
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
import android.app.Activity;
import android.app.Application;
import javax.inject.Inject;
import br.ufs.demos.rxmvp.playground.dagger.components.DaggerAppComponent;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService.NextCall;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector;
package br.ufs.demos.rxmvp.playground.app;
/**
* Created by bira on 6/26/17.
*/
public class MainApplication extends Application implements HasActivityInjector {
@Inject DispatchingAndroidInjector<Activity> injector; | @Inject public NumbersWebService webservice; |
ubiratansoares/reactive-architectures-playground | app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public class FakeWebService implements NumbersWebService {
//
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// private NextCall nextReturn;
//
//
// public FakeWebService() {
// nextReturn = NextCall.UNDEFINED_ERROR;
// }
//
// public void nextCallPerform(NextCall nextReturn) {
// this.nextReturn = nextReturn;
// }
//
// @Override public Flowable<NumbersTriviaPayload> getTrivia(String commaSeparatedNumbers) {
//
// switch (nextReturn) {
// case SUCCESS_200:
// return FakeResponses.triviaResults();
//
// case NOT_FOUND_404:
// return FakeResponses.notFound();
//
// case INTERNAL_SERVER_ERROR_5xy:
// return FakeResponses.internalServerError();
//
// case CONNECTION_ERROR:
// return FakeResponses.connectionIssue();
//
// case CONNECTION_TIMEOUT:
// return FakeResponses.requestTimeout();
// }
//
// return Flowable.empty();
// }
//
// }
//
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
| import android.app.Activity;
import android.app.Application;
import javax.inject.Inject;
import br.ufs.demos.rxmvp.playground.dagger.components.DaggerAppComponent;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService.NextCall;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector; | package br.ufs.demos.rxmvp.playground.app;
/**
* Created by bira on 6/26/17.
*/
public class MainApplication extends Application implements HasActivityInjector {
@Inject DispatchingAndroidInjector<Activity> injector;
@Inject public NumbersWebService webservice;
@Override public void onCreate() {
super.onCreate();
buildTopLevelDependenciesGraph();
setupMock();
}
@Override public DispatchingAndroidInjector<Activity> activityInjector() {
return injector;
}
protected void buildTopLevelDependenciesGraph() {
DaggerAppComponent.builder().application(this).build().inject(this);
}
private void setupMock() { | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public class FakeWebService implements NumbersWebService {
//
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// private NextCall nextReturn;
//
//
// public FakeWebService() {
// nextReturn = NextCall.UNDEFINED_ERROR;
// }
//
// public void nextCallPerform(NextCall nextReturn) {
// this.nextReturn = nextReturn;
// }
//
// @Override public Flowable<NumbersTriviaPayload> getTrivia(String commaSeparatedNumbers) {
//
// switch (nextReturn) {
// case SUCCESS_200:
// return FakeResponses.triviaResults();
//
// case NOT_FOUND_404:
// return FakeResponses.notFound();
//
// case INTERNAL_SERVER_ERROR_5xy:
// return FakeResponses.internalServerError();
//
// case CONNECTION_ERROR:
// return FakeResponses.connectionIssue();
//
// case CONNECTION_TIMEOUT:
// return FakeResponses.requestTimeout();
// }
//
// return Flowable.empty();
// }
//
// }
//
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
import android.app.Activity;
import android.app.Application;
import javax.inject.Inject;
import br.ufs.demos.rxmvp.playground.dagger.components.DaggerAppComponent;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService.NextCall;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector;
package br.ufs.demos.rxmvp.playground.app;
/**
* Created by bira on 6/26/17.
*/
public class MainApplication extends Application implements HasActivityInjector {
@Inject DispatchingAndroidInjector<Activity> injector;
@Inject public NumbersWebService webservice;
@Override public void onCreate() {
super.onCreate();
buildTopLevelDependenciesGraph();
setupMock();
}
@Override public DispatchingAndroidInjector<Activity> activityInjector() {
return injector;
}
protected void buildTopLevelDependenciesGraph() {
DaggerAppComponent.builder().application(this).build().inject(this);
}
private void setupMock() { | FakeWebService service = (FakeWebService) webservice; |
ubiratansoares/reactive-architectures-playground | app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public class FakeWebService implements NumbersWebService {
//
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// private NextCall nextReturn;
//
//
// public FakeWebService() {
// nextReturn = NextCall.UNDEFINED_ERROR;
// }
//
// public void nextCallPerform(NextCall nextReturn) {
// this.nextReturn = nextReturn;
// }
//
// @Override public Flowable<NumbersTriviaPayload> getTrivia(String commaSeparatedNumbers) {
//
// switch (nextReturn) {
// case SUCCESS_200:
// return FakeResponses.triviaResults();
//
// case NOT_FOUND_404:
// return FakeResponses.notFound();
//
// case INTERNAL_SERVER_ERROR_5xy:
// return FakeResponses.internalServerError();
//
// case CONNECTION_ERROR:
// return FakeResponses.connectionIssue();
//
// case CONNECTION_TIMEOUT:
// return FakeResponses.requestTimeout();
// }
//
// return Flowable.empty();
// }
//
// }
//
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
| import android.app.Activity;
import android.app.Application;
import javax.inject.Inject;
import br.ufs.demos.rxmvp.playground.dagger.components.DaggerAppComponent;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService.NextCall;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector; | package br.ufs.demos.rxmvp.playground.app;
/**
* Created by bira on 6/26/17.
*/
public class MainApplication extends Application implements HasActivityInjector {
@Inject DispatchingAndroidInjector<Activity> injector;
@Inject public NumbersWebService webservice;
@Override public void onCreate() {
super.onCreate();
buildTopLevelDependenciesGraph();
setupMock();
}
@Override public DispatchingAndroidInjector<Activity> activityInjector() {
return injector;
}
protected void buildTopLevelDependenciesGraph() {
DaggerAppComponent.builder().application(this).build().inject(this);
}
private void setupMock() {
FakeWebService service = (FakeWebService) webservice; | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public class FakeWebService implements NumbersWebService {
//
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// private NextCall nextReturn;
//
//
// public FakeWebService() {
// nextReturn = NextCall.UNDEFINED_ERROR;
// }
//
// public void nextCallPerform(NextCall nextReturn) {
// this.nextReturn = nextReturn;
// }
//
// @Override public Flowable<NumbersTriviaPayload> getTrivia(String commaSeparatedNumbers) {
//
// switch (nextReturn) {
// case SUCCESS_200:
// return FakeResponses.triviaResults();
//
// case NOT_FOUND_404:
// return FakeResponses.notFound();
//
// case INTERNAL_SERVER_ERROR_5xy:
// return FakeResponses.internalServerError();
//
// case CONNECTION_ERROR:
// return FakeResponses.connectionIssue();
//
// case CONNECTION_TIMEOUT:
// return FakeResponses.requestTimeout();
// }
//
// return Flowable.empty();
// }
//
// }
//
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
import android.app.Activity;
import android.app.Application;
import javax.inject.Inject;
import br.ufs.demos.rxmvp.playground.dagger.components.DaggerAppComponent;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService.NextCall;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector;
package br.ufs.demos.rxmvp.playground.app;
/**
* Created by bira on 6/26/17.
*/
public class MainApplication extends Application implements HasActivityInjector {
@Inject DispatchingAndroidInjector<Activity> injector;
@Inject public NumbersWebService webservice;
@Override public void onCreate() {
super.onCreate();
buildTopLevelDependenciesGraph();
setupMock();
}
@Override public DispatchingAndroidInjector<Activity> activityInjector() {
return injector;
}
protected void buildTopLevelDependenciesGraph() {
DaggerAppComponent.builder().application(this).build().inject(this);
}
private void setupMock() {
FakeWebService service = (FakeWebService) webservice; | service.nextCallPerform(NextCall.SUCCESS_200); |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/util/BehavioursRobot.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.mockito.InOrder;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; | package br.ufs.demos.rxmvp.playground.util;
/**
* Created by bira on 6/30/17.
*/
public class BehavioursRobot {
private Object target;
private BehavioursRobot(Object target) {
this.target = target;
}
public static BehavioursRobot with(Object target) {
return new BehavioursRobot(target);
}
public BehavioursRobot shouldShowErrorState() throws Exception {
checkErrorStateView(); | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/BehavioursRobot.java
import org.mockito.InOrder;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
package br.ufs.demos.rxmvp.playground.util;
/**
* Created by bira on 6/30/17.
*/
public class BehavioursRobot {
private Object target;
private BehavioursRobot(Object target) {
this.target = target;
}
public static BehavioursRobot with(Object target) {
return new BehavioursRobot(target);
}
public BehavioursRobot shouldShowErrorState() throws Exception {
checkErrorStateView(); | ErrorStateView view = (ErrorStateView) target; |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/util/BehavioursRobot.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.mockito.InOrder;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; | package br.ufs.demos.rxmvp.playground.util;
/**
* Created by bira on 6/30/17.
*/
public class BehavioursRobot {
private Object target;
private BehavioursRobot(Object target) {
this.target = target;
}
public static BehavioursRobot with(Object target) {
return new BehavioursRobot(target);
}
public BehavioursRobot shouldShowErrorState() throws Exception {
checkErrorStateView();
ErrorStateView view = (ErrorStateView) target; | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/BehavioursRobot.java
import org.mockito.InOrder;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
package br.ufs.demos.rxmvp.playground.util;
/**
* Created by bira on 6/30/17.
*/
public class BehavioursRobot {
private Object target;
private BehavioursRobot(Object target) {
this.target = target;
}
public static BehavioursRobot with(Object target) {
return new BehavioursRobot(target);
}
public BehavioursRobot shouldShowErrorState() throws Exception {
checkErrorStateView();
ErrorStateView view = (ErrorStateView) target; | verify(view.showErrorState(), oneTimeOnly()).run(); |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/util/BehavioursRobot.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.mockito.InOrder;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; | package br.ufs.demos.rxmvp.playground.util;
/**
* Created by bira on 6/30/17.
*/
public class BehavioursRobot {
private Object target;
private BehavioursRobot(Object target) {
this.target = target;
}
public static BehavioursRobot with(Object target) {
return new BehavioursRobot(target);
}
public BehavioursRobot shouldShowErrorState() throws Exception {
checkErrorStateView();
ErrorStateView view = (ErrorStateView) target;
verify(view.showErrorState(), oneTimeOnly()).run();
return this;
}
public BehavioursRobot shouldNotShowErrorState() throws Exception {
checkErrorStateView();
ErrorStateView view = (ErrorStateView) target;
verify(view.showErrorState(), never()).run();
return this;
}
public BehavioursRobot shouldShowEmptyState() throws Exception {
checkEmptyStateView(); | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/BehavioursRobot.java
import org.mockito.InOrder;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
package br.ufs.demos.rxmvp.playground.util;
/**
* Created by bira on 6/30/17.
*/
public class BehavioursRobot {
private Object target;
private BehavioursRobot(Object target) {
this.target = target;
}
public static BehavioursRobot with(Object target) {
return new BehavioursRobot(target);
}
public BehavioursRobot shouldShowErrorState() throws Exception {
checkErrorStateView();
ErrorStateView view = (ErrorStateView) target;
verify(view.showErrorState(), oneTimeOnly()).run();
return this;
}
public BehavioursRobot shouldNotShowErrorState() throws Exception {
checkErrorStateView();
ErrorStateView view = (ErrorStateView) target;
verify(view.showErrorState(), never()).run();
return this;
}
public BehavioursRobot shouldShowEmptyState() throws Exception {
checkEmptyStateView(); | EmptyStateView view = (EmptyStateView) target; |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/util/BehavioursRobot.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.mockito.InOrder;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; | public BehavioursRobot shouldShowErrorState() throws Exception {
checkErrorStateView();
ErrorStateView view = (ErrorStateView) target;
verify(view.showErrorState(), oneTimeOnly()).run();
return this;
}
public BehavioursRobot shouldNotShowErrorState() throws Exception {
checkErrorStateView();
ErrorStateView view = (ErrorStateView) target;
verify(view.showErrorState(), never()).run();
return this;
}
public BehavioursRobot shouldShowEmptyState() throws Exception {
checkEmptyStateView();
EmptyStateView view = (EmptyStateView) target;
verify(view.showEmptyState(), oneTimeOnly()).run();
return this;
}
public BehavioursRobot shouldNotShowEmptyState() throws Exception {
checkEmptyStateView();
EmptyStateView view = (EmptyStateView) target;
verify(view.showEmptyState(), never()).run();
return this;
}
public BehavioursRobot shouldReportNetworkingError() throws Exception {
checkNetworkingErrorView(); | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/BehavioursRobot.java
import org.mockito.InOrder;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
public BehavioursRobot shouldShowErrorState() throws Exception {
checkErrorStateView();
ErrorStateView view = (ErrorStateView) target;
verify(view.showErrorState(), oneTimeOnly()).run();
return this;
}
public BehavioursRobot shouldNotShowErrorState() throws Exception {
checkErrorStateView();
ErrorStateView view = (ErrorStateView) target;
verify(view.showErrorState(), never()).run();
return this;
}
public BehavioursRobot shouldShowEmptyState() throws Exception {
checkEmptyStateView();
EmptyStateView view = (EmptyStateView) target;
verify(view.showEmptyState(), oneTimeOnly()).run();
return this;
}
public BehavioursRobot shouldNotShowEmptyState() throws Exception {
checkEmptyStateView();
EmptyStateView view = (EmptyStateView) target;
verify(view.showEmptyState(), never()).run();
return this;
}
public BehavioursRobot shouldReportNetworkingError() throws Exception {
checkNetworkingErrorView(); | NetworkingErrorView view = (NetworkingErrorView) target; |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/util/BehavioursRobot.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.mockito.InOrder;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; | public BehavioursRobot shouldShowEmptyState() throws Exception {
checkEmptyStateView();
EmptyStateView view = (EmptyStateView) target;
verify(view.showEmptyState(), oneTimeOnly()).run();
return this;
}
public BehavioursRobot shouldNotShowEmptyState() throws Exception {
checkEmptyStateView();
EmptyStateView view = (EmptyStateView) target;
verify(view.showEmptyState(), never()).run();
return this;
}
public BehavioursRobot shouldReportNetworkingError() throws Exception {
checkNetworkingErrorView();
NetworkingErrorView view = (NetworkingErrorView) target;
verify(view.reportNetworkingError(), oneTimeOnly()).run();
return this;
}
public BehavioursRobot shouldNotReportNetworkingError() throws Exception {
checkNetworkingErrorView();
NetworkingErrorView view = (NetworkingErrorView) target;
verify(view.reportNetworkingError(), never()).run();
return this;
}
public BehavioursRobot showLoadingFirstHideLoadingAfter() throws Exception {
checkLoadingView(); | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/BehavioursRobot.java
import org.mockito.InOrder;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
public BehavioursRobot shouldShowEmptyState() throws Exception {
checkEmptyStateView();
EmptyStateView view = (EmptyStateView) target;
verify(view.showEmptyState(), oneTimeOnly()).run();
return this;
}
public BehavioursRobot shouldNotShowEmptyState() throws Exception {
checkEmptyStateView();
EmptyStateView view = (EmptyStateView) target;
verify(view.showEmptyState(), never()).run();
return this;
}
public BehavioursRobot shouldReportNetworkingError() throws Exception {
checkNetworkingErrorView();
NetworkingErrorView view = (NetworkingErrorView) target;
verify(view.reportNetworkingError(), oneTimeOnly()).run();
return this;
}
public BehavioursRobot shouldNotReportNetworkingError() throws Exception {
checkNetworkingErrorView();
NetworkingErrorView view = (NetworkingErrorView) target;
verify(view.reportNetworkingError(), never()).run();
return this;
}
public BehavioursRobot showLoadingFirstHideLoadingAfter() throws Exception {
checkLoadingView(); | LoadingView view = (LoadingView) target; |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/util/BehavioursRobot.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.mockito.InOrder;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; | public BehavioursRobot shouldNotShowEmptyState() throws Exception {
checkEmptyStateView();
EmptyStateView view = (EmptyStateView) target;
verify(view.showEmptyState(), never()).run();
return this;
}
public BehavioursRobot shouldReportNetworkingError() throws Exception {
checkNetworkingErrorView();
NetworkingErrorView view = (NetworkingErrorView) target;
verify(view.reportNetworkingError(), oneTimeOnly()).run();
return this;
}
public BehavioursRobot shouldNotReportNetworkingError() throws Exception {
checkNetworkingErrorView();
NetworkingErrorView view = (NetworkingErrorView) target;
verify(view.reportNetworkingError(), never()).run();
return this;
}
public BehavioursRobot showLoadingFirstHideLoadingAfter() throws Exception {
checkLoadingView();
LoadingView view = (LoadingView) target;
verifyInOrderShowAndHideLoading(view);
return this;
}
public BehavioursRobot disableRefreshFirstAndEnableAfter() throws Exception {
checkToogleRefreshView(); | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/BehavioursRobot.java
import org.mockito.InOrder;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
public BehavioursRobot shouldNotShowEmptyState() throws Exception {
checkEmptyStateView();
EmptyStateView view = (EmptyStateView) target;
verify(view.showEmptyState(), never()).run();
return this;
}
public BehavioursRobot shouldReportNetworkingError() throws Exception {
checkNetworkingErrorView();
NetworkingErrorView view = (NetworkingErrorView) target;
verify(view.reportNetworkingError(), oneTimeOnly()).run();
return this;
}
public BehavioursRobot shouldNotReportNetworkingError() throws Exception {
checkNetworkingErrorView();
NetworkingErrorView view = (NetworkingErrorView) target;
verify(view.reportNetworkingError(), never()).run();
return this;
}
public BehavioursRobot showLoadingFirstHideLoadingAfter() throws Exception {
checkLoadingView();
LoadingView view = (LoadingView) target;
verifyInOrderShowAndHideLoading(view);
return this;
}
public BehavioursRobot disableRefreshFirstAndEnableAfter() throws Exception {
checkToogleRefreshView(); | ToogleRefreshView view = (ToogleRefreshView) target; |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/RestErrorsHandlerTests.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/infraerrors/RestErrorsHandler.java
// public class RestErrorsHandler<T> implements FlowableTransformer<T, T> {
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.onErrorResumeNext(this::handleIfRestError);
// }
//
// private Publisher<T> handleIfRestError(Throwable throwable) {
//
// if (otherThanNotFound(throwable)) {
// return Flowable.error(new UnexpectedResponseError("Undesired response for this call"));
// }
//
// if (notFound(throwable)) {
// return Flowable.error(new ContentNotFoundError());
// }
//
// return Flowable.error(throwable);
// }
//
// private boolean otherThanNotFound(Throwable throwable) {
// return throwable instanceof HttpException && !notFound(throwable);
// }
//
// private boolean notFound(Throwable throwable) {
//
// if (throwable instanceof HttpException) {
// HttpException error = (HttpException) throwable;
// return error.code() == 404;
// }
//
// return false;
// }
// }
| import org.junit.Test;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import br.ufs.demos.rxmvp.playground.core.infraerrors.RestErrorsHandler;
import io.reactivex.Flowable;
import okhttp3.MediaType;
import okhttp3.ResponseBody;
import retrofit2.HttpException;
import retrofit2.Response; | package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/10/17.
*/
public class RestErrorsHandlerTests {
RestErrorsHandler<String> handler = new RestErrorsHandler<>();
@Test public void shouldHandle_404() {
ResponseBody body = ResponseBody.create(
MediaType.parse("application/json"),
"{\"message\":\"Not found\"}");
Response<?> error = Response.error(404, body);
HttpException exp = new HttpException(error);
Flowable<String> notFound = Flowable.error(exp);
notFound.compose(handler)
.test() | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/infraerrors/RestErrorsHandler.java
// public class RestErrorsHandler<T> implements FlowableTransformer<T, T> {
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.onErrorResumeNext(this::handleIfRestError);
// }
//
// private Publisher<T> handleIfRestError(Throwable throwable) {
//
// if (otherThanNotFound(throwable)) {
// return Flowable.error(new UnexpectedResponseError("Undesired response for this call"));
// }
//
// if (notFound(throwable)) {
// return Flowable.error(new ContentNotFoundError());
// }
//
// return Flowable.error(throwable);
// }
//
// private boolean otherThanNotFound(Throwable throwable) {
// return throwable instanceof HttpException && !notFound(throwable);
// }
//
// private boolean notFound(Throwable throwable) {
//
// if (throwable instanceof HttpException) {
// HttpException error = (HttpException) throwable;
// return error.code() == 404;
// }
//
// return false;
// }
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/RestErrorsHandlerTests.java
import org.junit.Test;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import br.ufs.demos.rxmvp.playground.core.infraerrors.RestErrorsHandler;
import io.reactivex.Flowable;
import okhttp3.MediaType;
import okhttp3.ResponseBody;
import retrofit2.HttpException;
import retrofit2.Response;
package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/10/17.
*/
public class RestErrorsHandlerTests {
RestErrorsHandler<String> handler = new RestErrorsHandler<>();
@Test public void shouldHandle_404() {
ResponseBody body = ResponseBody.create(
MediaType.parse("application/json"),
"{\"message\":\"Not found\"}");
Response<?> error = Response.error(404, body);
HttpException exp = new HttpException(error);
Flowable<String> notFound = Flowable.error(exp);
notFound.compose(handler)
.test() | .assertError(ContentNotFoundError.class); |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/RestErrorsHandlerTests.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/infraerrors/RestErrorsHandler.java
// public class RestErrorsHandler<T> implements FlowableTransformer<T, T> {
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.onErrorResumeNext(this::handleIfRestError);
// }
//
// private Publisher<T> handleIfRestError(Throwable throwable) {
//
// if (otherThanNotFound(throwable)) {
// return Flowable.error(new UnexpectedResponseError("Undesired response for this call"));
// }
//
// if (notFound(throwable)) {
// return Flowable.error(new ContentNotFoundError());
// }
//
// return Flowable.error(throwable);
// }
//
// private boolean otherThanNotFound(Throwable throwable) {
// return throwable instanceof HttpException && !notFound(throwable);
// }
//
// private boolean notFound(Throwable throwable) {
//
// if (throwable instanceof HttpException) {
// HttpException error = (HttpException) throwable;
// return error.code() == 404;
// }
//
// return false;
// }
// }
| import org.junit.Test;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import br.ufs.demos.rxmvp.playground.core.infraerrors.RestErrorsHandler;
import io.reactivex.Flowable;
import okhttp3.MediaType;
import okhttp3.ResponseBody;
import retrofit2.HttpException;
import retrofit2.Response; | package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/10/17.
*/
public class RestErrorsHandlerTests {
RestErrorsHandler<String> handler = new RestErrorsHandler<>();
@Test public void shouldHandle_404() {
ResponseBody body = ResponseBody.create(
MediaType.parse("application/json"),
"{\"message\":\"Not found\"}");
Response<?> error = Response.error(404, body);
HttpException exp = new HttpException(error);
Flowable<String> notFound = Flowable.error(exp);
notFound.compose(handler)
.test()
.assertError(ContentNotFoundError.class);
}
@Test public void shouldHandle_5xx() {
ResponseBody body = ResponseBody.create(
MediaType.parse("application/json"),
"{\"message\":\"Internal server error\"}");
Response<?> error = Response.error(503, body);
HttpException exp = new HttpException(error);
Flowable<String> internalServer = Flowable.error(exp);
internalServer.compose(handler)
.test() | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/infraerrors/RestErrorsHandler.java
// public class RestErrorsHandler<T> implements FlowableTransformer<T, T> {
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.onErrorResumeNext(this::handleIfRestError);
// }
//
// private Publisher<T> handleIfRestError(Throwable throwable) {
//
// if (otherThanNotFound(throwable)) {
// return Flowable.error(new UnexpectedResponseError("Undesired response for this call"));
// }
//
// if (notFound(throwable)) {
// return Flowable.error(new ContentNotFoundError());
// }
//
// return Flowable.error(throwable);
// }
//
// private boolean otherThanNotFound(Throwable throwable) {
// return throwable instanceof HttpException && !notFound(throwable);
// }
//
// private boolean notFound(Throwable throwable) {
//
// if (throwable instanceof HttpException) {
// HttpException error = (HttpException) throwable;
// return error.code() == 404;
// }
//
// return false;
// }
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/RestErrorsHandlerTests.java
import org.junit.Test;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import br.ufs.demos.rxmvp.playground.core.infraerrors.RestErrorsHandler;
import io.reactivex.Flowable;
import okhttp3.MediaType;
import okhttp3.ResponseBody;
import retrofit2.HttpException;
import retrofit2.Response;
package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/10/17.
*/
public class RestErrorsHandlerTests {
RestErrorsHandler<String> handler = new RestErrorsHandler<>();
@Test public void shouldHandle_404() {
ResponseBody body = ResponseBody.create(
MediaType.parse("application/json"),
"{\"message\":\"Not found\"}");
Response<?> error = Response.error(404, body);
HttpException exp = new HttpException(error);
Flowable<String> notFound = Flowable.error(exp);
notFound.compose(handler)
.test()
.assertError(ContentNotFoundError.class);
}
@Test public void shouldHandle_5xx() {
ResponseBody body = ResponseBody.create(
MediaType.parse("application/json"),
"{\"message\":\"Internal server error\"}");
Response<?> error = Response.error(503, body);
HttpException exp = new HttpException(error);
Flowable<String> internalServer = Flowable.error(exp);
internalServer.compose(handler)
.test() | .assertError(UnexpectedResponseError.class); |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/AssignErrorState.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/HideAtStartShowAtError.java
// public class HideAtStartShowAtError<T> implements FlowableTransformer<T, T> {
//
// private Action whenStart;
// private Action atError;
// private ErrorPredicate errorPredicate;
// private Scheduler targetScheduler;
//
// public HideAtStartShowAtError(Action whenStart,
// Action atError,
// ErrorPredicate errorPredicate,
// Scheduler targetScheduler) {
//
// this.whenStart = whenStart;
// this.atError = atError;
// this.errorPredicate = errorPredicate;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> hide())
// .doOnError(this::evaluateAndShowIfApplicable);
// }
//
// private void evaluateAndShowIfApplicable(Throwable throwable) {
// if (errorPredicate.evaluate(throwable)) {
// subscribeAndFireAction(atError);
// }
// }
//
// private void hide() {
// subscribeAndFireAction(whenStart);
// }
//
// private void subscribeAndFireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
| import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.HideAtStartShowAtError;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
import io.reactivex.Scheduler; | package br.ufs.demos.rxmvp.playground.core.behaviours.errorstate;
/**
* Created by bira on 6/30/17.
*/
public class AssignErrorState<T> implements FlowableTransformer<T, T> {
private ErrorStateView view;
private Scheduler uiScheduler;
public AssignErrorState(ErrorStateView view, Scheduler uiScheduler) {
this.view = view;
this.uiScheduler = uiScheduler;
}
@Override public Publisher<T> apply(Flowable<T> upstream) { | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/HideAtStartShowAtError.java
// public class HideAtStartShowAtError<T> implements FlowableTransformer<T, T> {
//
// private Action whenStart;
// private Action atError;
// private ErrorPredicate errorPredicate;
// private Scheduler targetScheduler;
//
// public HideAtStartShowAtError(Action whenStart,
// Action atError,
// ErrorPredicate errorPredicate,
// Scheduler targetScheduler) {
//
// this.whenStart = whenStart;
// this.atError = atError;
// this.errorPredicate = errorPredicate;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> hide())
// .doOnError(this::evaluateAndShowIfApplicable);
// }
//
// private void evaluateAndShowIfApplicable(Throwable throwable) {
// if (errorPredicate.evaluate(throwable)) {
// subscribeAndFireAction(atError);
// }
// }
//
// private void hide() {
// subscribeAndFireAction(whenStart);
// }
//
// private void subscribeAndFireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/AssignErrorState.java
import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.HideAtStartShowAtError;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
import io.reactivex.Scheduler;
package br.ufs.demos.rxmvp.playground.core.behaviours.errorstate;
/**
* Created by bira on 6/30/17.
*/
public class AssignErrorState<T> implements FlowableTransformer<T, T> {
private ErrorStateView view;
private Scheduler uiScheduler;
public AssignErrorState(ErrorStateView view, Scheduler uiScheduler) {
this.view = view;
this.uiScheduler = uiScheduler;
}
@Override public Publisher<T> apply(Flowable<T> upstream) { | HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>( |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/AssignErrorState.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/HideAtStartShowAtError.java
// public class HideAtStartShowAtError<T> implements FlowableTransformer<T, T> {
//
// private Action whenStart;
// private Action atError;
// private ErrorPredicate errorPredicate;
// private Scheduler targetScheduler;
//
// public HideAtStartShowAtError(Action whenStart,
// Action atError,
// ErrorPredicate errorPredicate,
// Scheduler targetScheduler) {
//
// this.whenStart = whenStart;
// this.atError = atError;
// this.errorPredicate = errorPredicate;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> hide())
// .doOnError(this::evaluateAndShowIfApplicable);
// }
//
// private void evaluateAndShowIfApplicable(Throwable throwable) {
// if (errorPredicate.evaluate(throwable)) {
// subscribeAndFireAction(atError);
// }
// }
//
// private void hide() {
// subscribeAndFireAction(whenStart);
// }
//
// private void subscribeAndFireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
| import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.HideAtStartShowAtError;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
import io.reactivex.Scheduler; | package br.ufs.demos.rxmvp.playground.core.behaviours.errorstate;
/**
* Created by bira on 6/30/17.
*/
public class AssignErrorState<T> implements FlowableTransformer<T, T> {
private ErrorStateView view;
private Scheduler uiScheduler;
public AssignErrorState(ErrorStateView view, Scheduler uiScheduler) {
this.view = view;
this.uiScheduler = uiScheduler;
}
@Override public Publisher<T> apply(Flowable<T> upstream) {
HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
view.hideErrorState(),
view.showErrorState(), | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/HideAtStartShowAtError.java
// public class HideAtStartShowAtError<T> implements FlowableTransformer<T, T> {
//
// private Action whenStart;
// private Action atError;
// private ErrorPredicate errorPredicate;
// private Scheduler targetScheduler;
//
// public HideAtStartShowAtError(Action whenStart,
// Action atError,
// ErrorPredicate errorPredicate,
// Scheduler targetScheduler) {
//
// this.whenStart = whenStart;
// this.atError = atError;
// this.errorPredicate = errorPredicate;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> hide())
// .doOnError(this::evaluateAndShowIfApplicable);
// }
//
// private void evaluateAndShowIfApplicable(Throwable throwable) {
// if (errorPredicate.evaluate(throwable)) {
// subscribeAndFireAction(atError);
// }
// }
//
// private void hide() {
// subscribeAndFireAction(whenStart);
// }
//
// private void subscribeAndFireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/AssignErrorState.java
import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.HideAtStartShowAtError;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
import io.reactivex.Scheduler;
package br.ufs.demos.rxmvp.playground.core.behaviours.errorstate;
/**
* Created by bira on 6/30/17.
*/
public class AssignErrorState<T> implements FlowableTransformer<T, T> {
private ErrorStateView view;
private Scheduler uiScheduler;
public AssignErrorState(ErrorStateView view, Scheduler uiScheduler) {
this.view = view;
this.uiScheduler = uiScheduler;
}
@Override public Publisher<T> apply(Flowable<T> upstream) {
HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
view.hideErrorState(),
view.showErrorState(), | error -> !(error instanceof ContentNotFoundError), |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/NetworkingErrorHandlerTests.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/NetworkingError.java
// public class NetworkingError extends RuntimeException {
//
// public NetworkingError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorHandler.java
// public class NetworkingErrorHandler<T>
// implements FlowableTransformer<T, T> {
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.onErrorResumeNext(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
// if (isNetworkingError(throwable)) return asNetworkingError(throwable);
// return Flowable.error(throwable);
// }
//
// private Flowable<T> asNetworkingError(Throwable throwable) {
// String failure = failureFrom(throwable);
// return Flowable.error(new NetworkingError(failure));
// }
//
// private String failureFrom(Throwable throwable) {
// if (isConnectionTimeout(throwable)) {
// return "Connection timeout";
// }
//
// if (isRequestCanceled(throwable)) {
// return "Connection interrupted error";
// }
//
// return "No internet available";
// }
//
// private boolean isNetworkingError(Throwable throwable) {
// return isConnectionTimeout(throwable) ||
// noInternetAvailable(throwable) ||
// isRequestCanceled(throwable);
// }
//
// private boolean isRequestCanceled(Throwable throwable) {
// return throwable instanceof IOException
// && throwable.getMessage().contentEquals("Canceled");
// }
//
// private boolean noInternetAvailable(Throwable throwable) {
// return throwable instanceof UnknownHostException;
// }
//
// private boolean isConnectionTimeout(Throwable throwable) {
// return throwable instanceof SocketTimeoutException;
// }
//
// }
| import com.google.gson.JsonSyntaxException;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.NetworkingError;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorHandler;
import io.reactivex.Flowable; | package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/6/17.
*/
public class NetworkingErrorHandlerTests {
NetworkingErrorHandler handler;
@Before public void beforeEachTest() {
handler = new NetworkingErrorHandler();
}
@Test public void shouldHandle_NoInternetAvailable() {
Flowable<?> noInternet = Flowable.error(new UnknownHostException("No Internet"));
noInternet.compose(handler)
.test() | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/NetworkingError.java
// public class NetworkingError extends RuntimeException {
//
// public NetworkingError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorHandler.java
// public class NetworkingErrorHandler<T>
// implements FlowableTransformer<T, T> {
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.onErrorResumeNext(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
// if (isNetworkingError(throwable)) return asNetworkingError(throwable);
// return Flowable.error(throwable);
// }
//
// private Flowable<T> asNetworkingError(Throwable throwable) {
// String failure = failureFrom(throwable);
// return Flowable.error(new NetworkingError(failure));
// }
//
// private String failureFrom(Throwable throwable) {
// if (isConnectionTimeout(throwable)) {
// return "Connection timeout";
// }
//
// if (isRequestCanceled(throwable)) {
// return "Connection interrupted error";
// }
//
// return "No internet available";
// }
//
// private boolean isNetworkingError(Throwable throwable) {
// return isConnectionTimeout(throwable) ||
// noInternetAvailable(throwable) ||
// isRequestCanceled(throwable);
// }
//
// private boolean isRequestCanceled(Throwable throwable) {
// return throwable instanceof IOException
// && throwable.getMessage().contentEquals("Canceled");
// }
//
// private boolean noInternetAvailable(Throwable throwable) {
// return throwable instanceof UnknownHostException;
// }
//
// private boolean isConnectionTimeout(Throwable throwable) {
// return throwable instanceof SocketTimeoutException;
// }
//
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/NetworkingErrorHandlerTests.java
import com.google.gson.JsonSyntaxException;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.NetworkingError;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorHandler;
import io.reactivex.Flowable;
package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/6/17.
*/
public class NetworkingErrorHandlerTests {
NetworkingErrorHandler handler;
@Before public void beforeEachTest() {
handler = new NetworkingErrorHandler();
}
@Test public void shouldHandle_NoInternetAvailable() {
Flowable<?> noInternet = Flowable.error(new UnknownHostException("No Internet"));
noInternet.compose(handler)
.test() | .assertError(NetworkingError.class); |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/core/infraerrors/DeserializationIssuesHandler.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
| import com.google.gson.JsonIOException;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer; | package br.ufs.demos.rxmvp.playground.core.infraerrors;
/**
* Created by bira on 6/29/17.
*
* Handles any errors throwed by GSON and report an UnexpectedResponse to
* next steps of pipeline
*
*/
public class DeserializationIssuesHandler<T> implements FlowableTransformer<T, T> {
@Override public Publisher<T> apply(Flowable<T> upstream) {
return upstream.onErrorResumeNext(this::handleErrorFromDeserializer);
}
private Publisher<T> handleErrorFromDeserializer(Throwable throwable) {
if (isDeserializationError(throwable)) { | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/infraerrors/DeserializationIssuesHandler.java
import com.google.gson.JsonIOException;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
package br.ufs.demos.rxmvp.playground.core.infraerrors;
/**
* Created by bira on 6/29/17.
*
* Handles any errors throwed by GSON and report an UnexpectedResponse to
* next steps of pipeline
*
*/
public class DeserializationIssuesHandler<T> implements FlowableTransformer<T, T> {
@Override public Publisher<T> apply(Flowable<T> upstream) {
return upstream.onErrorResumeNext(this::handleErrorFromDeserializer);
}
private Publisher<T> handleErrorFromDeserializer(Throwable throwable) {
if (isDeserializationError(throwable)) { | return Flowable.error(new UnexpectedResponseError("Deserialization Error")); |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/LifecycleStrategistTests.java | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/DisposeStrategy.java
// public class DisposeStrategy implements LifecycleObserver {
//
// private CompositeDisposable composite = new CompositeDisposable();
//
// public void addDisposable(Disposable toDispose) {
// composite.add(toDispose);
// }
//
// @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroy() {
// composite.dispose();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import android.arch.lifecycle.LifecycleOwner;
import android.support.v4.app.FragmentActivity;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import br.ufs.demos.rxmvp.playground.BuildConfig;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.core.lifecycles.DisposeStrategy;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.robolectric.Robolectric.buildActivity; | package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 10/5/17.
*/
@RunWith(RobolectricTestRunner.class)
@Config(
constants = BuildConfig.class, | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/DisposeStrategy.java
// public class DisposeStrategy implements LifecycleObserver {
//
// private CompositeDisposable composite = new CompositeDisposable();
//
// public void addDisposable(Disposable toDispose) {
// composite.add(toDispose);
// }
//
// @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroy() {
// composite.dispose();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/LifecycleStrategistTests.java
import android.arch.lifecycle.LifecycleOwner;
import android.support.v4.app.FragmentActivity;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import br.ufs.demos.rxmvp.playground.BuildConfig;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.core.lifecycles.DisposeStrategy;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.robolectric.Robolectric.buildActivity;
package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 10/5/17.
*/
@RunWith(RobolectricTestRunner.class)
@Config(
constants = BuildConfig.class, | application = MainApplication.class, |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/LifecycleStrategistTests.java | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/DisposeStrategy.java
// public class DisposeStrategy implements LifecycleObserver {
//
// private CompositeDisposable composite = new CompositeDisposable();
//
// public void addDisposable(Disposable toDispose) {
// composite.add(toDispose);
// }
//
// @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroy() {
// composite.dispose();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import android.arch.lifecycle.LifecycleOwner;
import android.support.v4.app.FragmentActivity;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import br.ufs.demos.rxmvp.playground.BuildConfig;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.core.lifecycles.DisposeStrategy;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.robolectric.Robolectric.buildActivity; | package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 10/5/17.
*/
@RunWith(RobolectricTestRunner.class)
@Config(
constants = BuildConfig.class,
application = MainApplication.class,
sdk = 25,
packageName = "br.ufs.demos.rxmvp.playground"
)
public class LifecycleStrategistTests {
LifecycleOwner lifecycleOwner; | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/DisposeStrategy.java
// public class DisposeStrategy implements LifecycleObserver {
//
// private CompositeDisposable composite = new CompositeDisposable();
//
// public void addDisposable(Disposable toDispose) {
// composite.add(toDispose);
// }
//
// @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroy() {
// composite.dispose();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/LifecycleStrategistTests.java
import android.arch.lifecycle.LifecycleOwner;
import android.support.v4.app.FragmentActivity;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import br.ufs.demos.rxmvp.playground.BuildConfig;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.core.lifecycles.DisposeStrategy;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.robolectric.Robolectric.buildActivity;
package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 10/5/17.
*/
@RunWith(RobolectricTestRunner.class)
@Config(
constants = BuildConfig.class,
application = MainApplication.class,
sdk = 25,
packageName = "br.ufs.demos.rxmvp.playground"
)
public class LifecycleStrategistTests {
LifecycleOwner lifecycleOwner; | DisposeStrategy mockedStrategy; |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/LifecycleStrategistTests.java | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/DisposeStrategy.java
// public class DisposeStrategy implements LifecycleObserver {
//
// private CompositeDisposable composite = new CompositeDisposable();
//
// public void addDisposable(Disposable toDispose) {
// composite.add(toDispose);
// }
//
// @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroy() {
// composite.dispose();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import android.arch.lifecycle.LifecycleOwner;
import android.support.v4.app.FragmentActivity;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import br.ufs.demos.rxmvp.playground.BuildConfig;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.core.lifecycles.DisposeStrategy;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.robolectric.Robolectric.buildActivity; | package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 10/5/17.
*/
@RunWith(RobolectricTestRunner.class)
@Config(
constants = BuildConfig.class,
application = MainApplication.class,
sdk = 25,
packageName = "br.ufs.demos.rxmvp.playground"
)
public class LifecycleStrategistTests {
LifecycleOwner lifecycleOwner;
DisposeStrategy mockedStrategy; | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/DisposeStrategy.java
// public class DisposeStrategy implements LifecycleObserver {
//
// private CompositeDisposable composite = new CompositeDisposable();
//
// public void addDisposable(Disposable toDispose) {
// composite.add(toDispose);
// }
//
// @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroy() {
// composite.dispose();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/LifecycleStrategistTests.java
import android.arch.lifecycle.LifecycleOwner;
import android.support.v4.app.FragmentActivity;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import br.ufs.demos.rxmvp.playground.BuildConfig;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.core.lifecycles.DisposeStrategy;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.robolectric.Robolectric.buildActivity;
package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 10/5/17.
*/
@RunWith(RobolectricTestRunner.class)
@Config(
constants = BuildConfig.class,
application = MainApplication.class,
sdk = 25,
packageName = "br.ufs.demos.rxmvp.playground"
)
public class LifecycleStrategistTests {
LifecycleOwner lifecycleOwner;
DisposeStrategy mockedStrategy; | LifecycleStrategist strategist; |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/LifecycleStrategistTests.java | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/DisposeStrategy.java
// public class DisposeStrategy implements LifecycleObserver {
//
// private CompositeDisposable composite = new CompositeDisposable();
//
// public void addDisposable(Disposable toDispose) {
// composite.add(toDispose);
// }
//
// @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroy() {
// composite.dispose();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import android.arch.lifecycle.LifecycleOwner;
import android.support.v4.app.FragmentActivity;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import br.ufs.demos.rxmvp.playground.BuildConfig;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.core.lifecycles.DisposeStrategy;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.robolectric.Robolectric.buildActivity; | package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 10/5/17.
*/
@RunWith(RobolectricTestRunner.class)
@Config(
constants = BuildConfig.class,
application = MainApplication.class,
sdk = 25,
packageName = "br.ufs.demos.rxmvp.playground"
)
public class LifecycleStrategistTests {
LifecycleOwner lifecycleOwner;
DisposeStrategy mockedStrategy;
LifecycleStrategist strategist;
@Before public void setup() {
lifecycleOwner = buildActivity(FragmentActivity.class).create().get();
mockedStrategy = mock(DisposeStrategy.class);
strategist = new LifecycleStrategist(lifecycleOwner, mockedStrategy);
}
@Test public void shouldApplyStrategy() {
Disposable target = Flowable.just("Test").subscribe();
strategist.applyStrategy(target); | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/DisposeStrategy.java
// public class DisposeStrategy implements LifecycleObserver {
//
// private CompositeDisposable composite = new CompositeDisposable();
//
// public void addDisposable(Disposable toDispose) {
// composite.add(toDispose);
// }
//
// @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroy() {
// composite.dispose();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/LifecycleStrategistTests.java
import android.arch.lifecycle.LifecycleOwner;
import android.support.v4.app.FragmentActivity;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import br.ufs.demos.rxmvp.playground.BuildConfig;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.core.lifecycles.DisposeStrategy;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.robolectric.Robolectric.buildActivity;
package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 10/5/17.
*/
@RunWith(RobolectricTestRunner.class)
@Config(
constants = BuildConfig.class,
application = MainApplication.class,
sdk = 25,
packageName = "br.ufs.demos.rxmvp.playground"
)
public class LifecycleStrategistTests {
LifecycleOwner lifecycleOwner;
DisposeStrategy mockedStrategy;
LifecycleStrategist strategist;
@Before public void setup() {
lifecycleOwner = buildActivity(FragmentActivity.class).create().get();
mockedStrategy = mock(DisposeStrategy.class);
strategist = new LifecycleStrategist(lifecycleOwner, mockedStrategy);
}
@Test public void shouldApplyStrategy() {
Disposable target = Flowable.just("Test").subscribe();
strategist.applyStrategy(target); | verify(mockedStrategy, oneTimeOnly()).addDisposable(Mockito.any()); |
ubiratansoares/reactive-architectures-playground | app/src/androidTestMock/java/br/ufs/demos/rxmvp/playground/ScriptableWebServerTestRule.java | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public class FakeWebService implements NumbersWebService {
//
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// private NextCall nextReturn;
//
//
// public FakeWebService() {
// nextReturn = NextCall.UNDEFINED_ERROR;
// }
//
// public void nextCallPerform(NextCall nextReturn) {
// this.nextReturn = nextReturn;
// }
//
// @Override public Flowable<NumbersTriviaPayload> getTrivia(String commaSeparatedNumbers) {
//
// switch (nextReturn) {
// case SUCCESS_200:
// return FakeResponses.triviaResults();
//
// case NOT_FOUND_404:
// return FakeResponses.notFound();
//
// case INTERNAL_SERVER_ERROR_5xy:
// return FakeResponses.internalServerError();
//
// case CONNECTION_ERROR:
// return FakeResponses.connectionIssue();
//
// case CONNECTION_TIMEOUT:
// return FakeResponses.requestTimeout();
// }
//
// return Flowable.empty();
// }
//
// }
| import android.app.Activity;
import android.app.Application;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService; | package br.ufs.demos.rxmvp.playground;
/**
* Created by bira on 10/3/17.
*/
public class ScriptableWebServerTestRule<T extends Activity> extends ActivityTestRule<T> {
private FakeWebService mockWebService;
private FakeWebService.NextCall next;
public ScriptableWebServerTestRule(Class<T> activityClass) {
super(activityClass, false, false);
setupWebService();
}
@Override protected void beforeActivityLaunched() {
mockWebService.nextCallPerform(next);
super.beforeActivityLaunched();
}
public void startWithCenario(FakeWebService.NextCall next) {
this.next = next;
launchActivity(new Intent());
}
private void setupWebService() {
Application main =
(Application) InstrumentationRegistry.getInstrumentation()
.getTargetContext()
.getApplicationContext();
| // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public class FakeWebService implements NumbersWebService {
//
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// private NextCall nextReturn;
//
//
// public FakeWebService() {
// nextReturn = NextCall.UNDEFINED_ERROR;
// }
//
// public void nextCallPerform(NextCall nextReturn) {
// this.nextReturn = nextReturn;
// }
//
// @Override public Flowable<NumbersTriviaPayload> getTrivia(String commaSeparatedNumbers) {
//
// switch (nextReturn) {
// case SUCCESS_200:
// return FakeResponses.triviaResults();
//
// case NOT_FOUND_404:
// return FakeResponses.notFound();
//
// case INTERNAL_SERVER_ERROR_5xy:
// return FakeResponses.internalServerError();
//
// case CONNECTION_ERROR:
// return FakeResponses.connectionIssue();
//
// case CONNECTION_TIMEOUT:
// return FakeResponses.requestTimeout();
// }
//
// return Flowable.empty();
// }
//
// }
// Path: app/src/androidTestMock/java/br/ufs/demos/rxmvp/playground/ScriptableWebServerTestRule.java
import android.app.Activity;
import android.app.Application;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService;
package br.ufs.demos.rxmvp.playground;
/**
* Created by bira on 10/3/17.
*/
public class ScriptableWebServerTestRule<T extends Activity> extends ActivityTestRule<T> {
private FakeWebService mockWebService;
private FakeWebService.NextCall next;
public ScriptableWebServerTestRule(Class<T> activityClass) {
super(activityClass, false, false);
setupWebService();
}
@Override protected void beforeActivityLaunched() {
mockWebService.nextCallPerform(next);
super.beforeActivityLaunched();
}
public void startWithCenario(FakeWebService.NextCall next) {
this.next = next;
launchActivity(new Intent());
}
private void setupWebService() {
Application main =
(Application) InstrumentationRegistry.getInstrumentation()
.getTargetContext()
.getApplicationContext();
| MainApplication app = (MainApplication) main; |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/ui/FactsAdapter.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/ComposedWithSpannedStyles.java
// public class ComposedWithSpannedStyles implements FactViewModel {
//
// private String number;
// private String fact;
// private ForegroundColorSpan numberColor;
//
//
// private ComposedWithSpannedStyles(String number,
// String fact,
// ForegroundColorSpan numberColor) {
// this.number = number;
// this.fact = fact;
// this.numberColor = numberColor;
// }
//
// public static ComposedWithSpannedStyles with(String number,
// String fact,
// ForegroundColorSpan numberColor) {
//
// return new ComposedWithSpannedStyles(number, fact, numberColor);
// }
//
// @Override public CharSequence formattedFact() {
//
// return new Spanny()
// .append(number, new StyleSpan(Typeface.BOLD), numberColor)
// .append(fact);
// }
//
// @Override public int viewType() {
// return TYPE_SINGLE_LABEL;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/NumberAndFact.java
// public class NumberAndFact implements FactViewModel {
//
// private String number;
// private String fact;
//
// public NumberAndFact(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// @Override public CharSequence formattedFact() {
// return fact;
// }
//
// @Override public int viewType() {
// return TYPE_TWO_LABELS;
// }
//
// public String relatedNumber() {
// return number;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/Checks.java
// public static boolean notNullNotEmpty(Collection<?> objects) {
// return objects != null && !objects.isEmpty();
// }
| import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import br.ufs.demos.rxmvp.playground.R;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.ComposedWithSpannedStyles;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.NumberAndFact;
import butterknife.BindView;
import butterknife.ButterKnife;
import static br.ufs.demos.rxmvp.playground.util.Checks.notNullNotEmpty; | package br.ufs.demos.rxmvp.playground.trivia.ui;
/**
* Created by bira on 7/4/17.
*/
public class FactsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private List<FactViewModel> models = new ArrayList<>();
private LayoutInflater inflater;
public FactsAdapter(LayoutInflater inflater) {
this.inflater = inflater;
}
public void addModel(FactViewModel modelToBeAdded) {
int actualPosition = models.size();
models.add(modelToBeAdded);
notifyItemInserted(actualPosition);
}
void clear() {
models.clear();
notifyDataSetChanged();
}
@Override public int getItemViewType(int position) { | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/ComposedWithSpannedStyles.java
// public class ComposedWithSpannedStyles implements FactViewModel {
//
// private String number;
// private String fact;
// private ForegroundColorSpan numberColor;
//
//
// private ComposedWithSpannedStyles(String number,
// String fact,
// ForegroundColorSpan numberColor) {
// this.number = number;
// this.fact = fact;
// this.numberColor = numberColor;
// }
//
// public static ComposedWithSpannedStyles with(String number,
// String fact,
// ForegroundColorSpan numberColor) {
//
// return new ComposedWithSpannedStyles(number, fact, numberColor);
// }
//
// @Override public CharSequence formattedFact() {
//
// return new Spanny()
// .append(number, new StyleSpan(Typeface.BOLD), numberColor)
// .append(fact);
// }
//
// @Override public int viewType() {
// return TYPE_SINGLE_LABEL;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/NumberAndFact.java
// public class NumberAndFact implements FactViewModel {
//
// private String number;
// private String fact;
//
// public NumberAndFact(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// @Override public CharSequence formattedFact() {
// return fact;
// }
//
// @Override public int viewType() {
// return TYPE_TWO_LABELS;
// }
//
// public String relatedNumber() {
// return number;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/Checks.java
// public static boolean notNullNotEmpty(Collection<?> objects) {
// return objects != null && !objects.isEmpty();
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/ui/FactsAdapter.java
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import br.ufs.demos.rxmvp.playground.R;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.ComposedWithSpannedStyles;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.NumberAndFact;
import butterknife.BindView;
import butterknife.ButterKnife;
import static br.ufs.demos.rxmvp.playground.util.Checks.notNullNotEmpty;
package br.ufs.demos.rxmvp.playground.trivia.ui;
/**
* Created by bira on 7/4/17.
*/
public class FactsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private List<FactViewModel> models = new ArrayList<>();
private LayoutInflater inflater;
public FactsAdapter(LayoutInflater inflater) {
this.inflater = inflater;
}
public void addModel(FactViewModel modelToBeAdded) {
int actualPosition = models.size();
models.add(modelToBeAdded);
notifyItemInserted(actualPosition);
}
void clear() {
models.clear();
notifyDataSetChanged();
}
@Override public int getItemViewType(int position) { | if (notNullNotEmpty(models)) { |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/ui/FactsAdapter.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/ComposedWithSpannedStyles.java
// public class ComposedWithSpannedStyles implements FactViewModel {
//
// private String number;
// private String fact;
// private ForegroundColorSpan numberColor;
//
//
// private ComposedWithSpannedStyles(String number,
// String fact,
// ForegroundColorSpan numberColor) {
// this.number = number;
// this.fact = fact;
// this.numberColor = numberColor;
// }
//
// public static ComposedWithSpannedStyles with(String number,
// String fact,
// ForegroundColorSpan numberColor) {
//
// return new ComposedWithSpannedStyles(number, fact, numberColor);
// }
//
// @Override public CharSequence formattedFact() {
//
// return new Spanny()
// .append(number, new StyleSpan(Typeface.BOLD), numberColor)
// .append(fact);
// }
//
// @Override public int viewType() {
// return TYPE_SINGLE_LABEL;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/NumberAndFact.java
// public class NumberAndFact implements FactViewModel {
//
// private String number;
// private String fact;
//
// public NumberAndFact(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// @Override public CharSequence formattedFact() {
// return fact;
// }
//
// @Override public int viewType() {
// return TYPE_TWO_LABELS;
// }
//
// public String relatedNumber() {
// return number;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/Checks.java
// public static boolean notNullNotEmpty(Collection<?> objects) {
// return objects != null && !objects.isEmpty();
// }
| import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import br.ufs.demos.rxmvp.playground.R;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.ComposedWithSpannedStyles;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.NumberAndFact;
import butterknife.BindView;
import butterknife.ButterKnife;
import static br.ufs.demos.rxmvp.playground.util.Checks.notNullNotEmpty; | throw new IllegalArgumentException("Invalid viewType");
}
private RecyclerView.ViewHolder asTwoLabelsHolder(ViewGroup parent) {
View card = inflater.inflate(R.layout.listitem_fact_and_number, parent, false);
return new TwoLabelsHolder(card);
}
private RecyclerView.ViewHolder asSingleLabelHolder(ViewGroup parent) {
View card = inflater.inflate(R.layout.listitem_fact_withstyles, parent, false);
return new SingleLabelHolder(card);
}
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
FactViewModel viewModel = models.get(position);
switch (viewModel.viewType()) {
case FactViewModel.TYPE_TWO_LABELS:
bindAsTwoLabels(holder, viewModel);
break;
case FactViewModel.TYPE_SINGLE_LABEL:
bindAsSingleLabel(holder, viewModel);
break;
}
}
private void bindAsSingleLabel(RecyclerView.ViewHolder holder, FactViewModel viewModel) { | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/ComposedWithSpannedStyles.java
// public class ComposedWithSpannedStyles implements FactViewModel {
//
// private String number;
// private String fact;
// private ForegroundColorSpan numberColor;
//
//
// private ComposedWithSpannedStyles(String number,
// String fact,
// ForegroundColorSpan numberColor) {
// this.number = number;
// this.fact = fact;
// this.numberColor = numberColor;
// }
//
// public static ComposedWithSpannedStyles with(String number,
// String fact,
// ForegroundColorSpan numberColor) {
//
// return new ComposedWithSpannedStyles(number, fact, numberColor);
// }
//
// @Override public CharSequence formattedFact() {
//
// return new Spanny()
// .append(number, new StyleSpan(Typeface.BOLD), numberColor)
// .append(fact);
// }
//
// @Override public int viewType() {
// return TYPE_SINGLE_LABEL;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/NumberAndFact.java
// public class NumberAndFact implements FactViewModel {
//
// private String number;
// private String fact;
//
// public NumberAndFact(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// @Override public CharSequence formattedFact() {
// return fact;
// }
//
// @Override public int viewType() {
// return TYPE_TWO_LABELS;
// }
//
// public String relatedNumber() {
// return number;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/Checks.java
// public static boolean notNullNotEmpty(Collection<?> objects) {
// return objects != null && !objects.isEmpty();
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/ui/FactsAdapter.java
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import br.ufs.demos.rxmvp.playground.R;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.ComposedWithSpannedStyles;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.NumberAndFact;
import butterknife.BindView;
import butterknife.ButterKnife;
import static br.ufs.demos.rxmvp.playground.util.Checks.notNullNotEmpty;
throw new IllegalArgumentException("Invalid viewType");
}
private RecyclerView.ViewHolder asTwoLabelsHolder(ViewGroup parent) {
View card = inflater.inflate(R.layout.listitem_fact_and_number, parent, false);
return new TwoLabelsHolder(card);
}
private RecyclerView.ViewHolder asSingleLabelHolder(ViewGroup parent) {
View card = inflater.inflate(R.layout.listitem_fact_withstyles, parent, false);
return new SingleLabelHolder(card);
}
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
FactViewModel viewModel = models.get(position);
switch (viewModel.viewType()) {
case FactViewModel.TYPE_TWO_LABELS:
bindAsTwoLabels(holder, viewModel);
break;
case FactViewModel.TYPE_SINGLE_LABEL:
bindAsSingleLabel(holder, viewModel);
break;
}
}
private void bindAsSingleLabel(RecyclerView.ViewHolder holder, FactViewModel viewModel) { | ComposedWithSpannedStyles composed = (ComposedWithSpannedStyles) viewModel; |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/ui/FactsAdapter.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/ComposedWithSpannedStyles.java
// public class ComposedWithSpannedStyles implements FactViewModel {
//
// private String number;
// private String fact;
// private ForegroundColorSpan numberColor;
//
//
// private ComposedWithSpannedStyles(String number,
// String fact,
// ForegroundColorSpan numberColor) {
// this.number = number;
// this.fact = fact;
// this.numberColor = numberColor;
// }
//
// public static ComposedWithSpannedStyles with(String number,
// String fact,
// ForegroundColorSpan numberColor) {
//
// return new ComposedWithSpannedStyles(number, fact, numberColor);
// }
//
// @Override public CharSequence formattedFact() {
//
// return new Spanny()
// .append(number, new StyleSpan(Typeface.BOLD), numberColor)
// .append(fact);
// }
//
// @Override public int viewType() {
// return TYPE_SINGLE_LABEL;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/NumberAndFact.java
// public class NumberAndFact implements FactViewModel {
//
// private String number;
// private String fact;
//
// public NumberAndFact(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// @Override public CharSequence formattedFact() {
// return fact;
// }
//
// @Override public int viewType() {
// return TYPE_TWO_LABELS;
// }
//
// public String relatedNumber() {
// return number;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/Checks.java
// public static boolean notNullNotEmpty(Collection<?> objects) {
// return objects != null && !objects.isEmpty();
// }
| import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import br.ufs.demos.rxmvp.playground.R;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.ComposedWithSpannedStyles;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.NumberAndFact;
import butterknife.BindView;
import butterknife.ButterKnife;
import static br.ufs.demos.rxmvp.playground.util.Checks.notNullNotEmpty; | }
private RecyclerView.ViewHolder asSingleLabelHolder(ViewGroup parent) {
View card = inflater.inflate(R.layout.listitem_fact_withstyles, parent, false);
return new SingleLabelHolder(card);
}
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
FactViewModel viewModel = models.get(position);
switch (viewModel.viewType()) {
case FactViewModel.TYPE_TWO_LABELS:
bindAsTwoLabels(holder, viewModel);
break;
case FactViewModel.TYPE_SINGLE_LABEL:
bindAsSingleLabel(holder, viewModel);
break;
}
}
private void bindAsSingleLabel(RecyclerView.ViewHolder holder, FactViewModel viewModel) {
ComposedWithSpannedStyles composed = (ComposedWithSpannedStyles) viewModel;
SingleLabelHolder vh = (SingleLabelHolder) holder;
vh.singleLabel.setText(composed.formattedFact());
}
private void bindAsTwoLabels(RecyclerView.ViewHolder holder, FactViewModel viewModel) { | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/ComposedWithSpannedStyles.java
// public class ComposedWithSpannedStyles implements FactViewModel {
//
// private String number;
// private String fact;
// private ForegroundColorSpan numberColor;
//
//
// private ComposedWithSpannedStyles(String number,
// String fact,
// ForegroundColorSpan numberColor) {
// this.number = number;
// this.fact = fact;
// this.numberColor = numberColor;
// }
//
// public static ComposedWithSpannedStyles with(String number,
// String fact,
// ForegroundColorSpan numberColor) {
//
// return new ComposedWithSpannedStyles(number, fact, numberColor);
// }
//
// @Override public CharSequence formattedFact() {
//
// return new Spanny()
// .append(number, new StyleSpan(Typeface.BOLD), numberColor)
// .append(fact);
// }
//
// @Override public int viewType() {
// return TYPE_SINGLE_LABEL;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/NumberAndFact.java
// public class NumberAndFact implements FactViewModel {
//
// private String number;
// private String fact;
//
// public NumberAndFact(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// @Override public CharSequence formattedFact() {
// return fact;
// }
//
// @Override public int viewType() {
// return TYPE_TWO_LABELS;
// }
//
// public String relatedNumber() {
// return number;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/Checks.java
// public static boolean notNullNotEmpty(Collection<?> objects) {
// return objects != null && !objects.isEmpty();
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/ui/FactsAdapter.java
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import br.ufs.demos.rxmvp.playground.R;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.ComposedWithSpannedStyles;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.NumberAndFact;
import butterknife.BindView;
import butterknife.ButterKnife;
import static br.ufs.demos.rxmvp.playground.util.Checks.notNullNotEmpty;
}
private RecyclerView.ViewHolder asSingleLabelHolder(ViewGroup parent) {
View card = inflater.inflate(R.layout.listitem_fact_withstyles, parent, false);
return new SingleLabelHolder(card);
}
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
FactViewModel viewModel = models.get(position);
switch (viewModel.viewType()) {
case FactViewModel.TYPE_TWO_LABELS:
bindAsTwoLabels(holder, viewModel);
break;
case FactViewModel.TYPE_SINGLE_LABEL:
bindAsSingleLabel(holder, viewModel);
break;
}
}
private void bindAsSingleLabel(RecyclerView.ViewHolder holder, FactViewModel viewModel) {
ComposedWithSpannedStyles composed = (ComposedWithSpannedStyles) viewModel;
SingleLabelHolder vh = (SingleLabelHolder) holder;
vh.singleLabel.setText(composed.formattedFact());
}
private void bindAsTwoLabels(RecyclerView.ViewHolder holder, FactViewModel viewModel) { | NumberAndFact numberAndFact = (NumberAndFact) viewModel; |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/ui/FactsAboutNumbersActivity.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/DisplayFactsView.java
// public interface DisplayFactsView extends
// LoadingView,
// ErrorStateView,
// EmptyStateView,
// NetworkingErrorView,
// ToogleRefreshView {
//
// Disposable subscribeInto(Flowable<FactViewModel> flow);
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsPresenter.java
// public class FactsPresenter {
//
// private GetRandomFacts usecase;
// private DisplayFactsView view;
// private BehavioursCoordinator<FactAboutNumber> coordinator;
// private LifecycleStrategist strategist;
// private DomainToViewModel<FactAboutNumber, FactViewModel> mapper;
//
// public FactsPresenter(GetRandomFacts usecase,
// DisplayFactsView view,
// BehavioursCoordinator<FactAboutNumber> coordinator,
// LifecycleStrategist strategist,
// DomainToViewModel<FactAboutNumber, FactViewModel> mapper) {
//
// this.usecase = usecase;
// this.view = view;
// this.coordinator = coordinator;
// this.strategist = strategist;
// this.mapper = mapper;
// }
//
// public void fetchRandomFacts() {
// Flowable<FactViewModel> dataFlow =
// usecase.fetchTrivia()
// .compose(coordinator)
// .map(fact -> mapper.translate(fact));
//
// Disposable toDispose = view.subscribeInto(dataFlow);
// strategist.applyStrategy(toDispose);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
| import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import javax.inject.Inject;
import br.ufs.demos.rxmvp.playground.R;
import br.ufs.demos.rxmvp.playground.trivia.presentation.DisplayFactsView;
import br.ufs.demos.rxmvp.playground.trivia.presentation.FactsPresenter;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import butterknife.BindView;
import butterknife.ButterKnife;
import dagger.android.AndroidInjection;
import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
import static android.support.design.widget.Snackbar.LENGTH_INDEFINITE; | package br.ufs.demos.rxmvp.playground.trivia.ui;
public class FactsAboutNumbersActivity
extends AppCompatActivity implements DisplayFactsView {
private static final String TAG = FactsAboutNumbersActivity.class.getSimpleName();
@BindView(R.id.recyclerview_facts) public RecyclerView factsView;
@BindView(R.id.container) View container;
@BindView(R.id.label_feedback_message) TextView feedbackMessage;
@BindView(R.id.progressBar) ProgressBar loading;
@BindView(R.id.fab) FloatingActionButton fab;
| // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/DisplayFactsView.java
// public interface DisplayFactsView extends
// LoadingView,
// ErrorStateView,
// EmptyStateView,
// NetworkingErrorView,
// ToogleRefreshView {
//
// Disposable subscribeInto(Flowable<FactViewModel> flow);
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsPresenter.java
// public class FactsPresenter {
//
// private GetRandomFacts usecase;
// private DisplayFactsView view;
// private BehavioursCoordinator<FactAboutNumber> coordinator;
// private LifecycleStrategist strategist;
// private DomainToViewModel<FactAboutNumber, FactViewModel> mapper;
//
// public FactsPresenter(GetRandomFacts usecase,
// DisplayFactsView view,
// BehavioursCoordinator<FactAboutNumber> coordinator,
// LifecycleStrategist strategist,
// DomainToViewModel<FactAboutNumber, FactViewModel> mapper) {
//
// this.usecase = usecase;
// this.view = view;
// this.coordinator = coordinator;
// this.strategist = strategist;
// this.mapper = mapper;
// }
//
// public void fetchRandomFacts() {
// Flowable<FactViewModel> dataFlow =
// usecase.fetchTrivia()
// .compose(coordinator)
// .map(fact -> mapper.translate(fact));
//
// Disposable toDispose = view.subscribeInto(dataFlow);
// strategist.applyStrategy(toDispose);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/ui/FactsAboutNumbersActivity.java
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import javax.inject.Inject;
import br.ufs.demos.rxmvp.playground.R;
import br.ufs.demos.rxmvp.playground.trivia.presentation.DisplayFactsView;
import br.ufs.demos.rxmvp.playground.trivia.presentation.FactsPresenter;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import butterknife.BindView;
import butterknife.ButterKnife;
import dagger.android.AndroidInjection;
import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
import static android.support.design.widget.Snackbar.LENGTH_INDEFINITE;
package br.ufs.demos.rxmvp.playground.trivia.ui;
public class FactsAboutNumbersActivity
extends AppCompatActivity implements DisplayFactsView {
private static final String TAG = FactsAboutNumbersActivity.class.getSimpleName();
@BindView(R.id.recyclerview_facts) public RecyclerView factsView;
@BindView(R.id.container) View container;
@BindView(R.id.label_feedback_message) TextView feedbackMessage;
@BindView(R.id.progressBar) ProgressBar loading;
@BindView(R.id.fab) FloatingActionButton fab;
| @Inject FactsPresenter presenter; |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/ui/FactsAboutNumbersActivity.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/DisplayFactsView.java
// public interface DisplayFactsView extends
// LoadingView,
// ErrorStateView,
// EmptyStateView,
// NetworkingErrorView,
// ToogleRefreshView {
//
// Disposable subscribeInto(Flowable<FactViewModel> flow);
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsPresenter.java
// public class FactsPresenter {
//
// private GetRandomFacts usecase;
// private DisplayFactsView view;
// private BehavioursCoordinator<FactAboutNumber> coordinator;
// private LifecycleStrategist strategist;
// private DomainToViewModel<FactAboutNumber, FactViewModel> mapper;
//
// public FactsPresenter(GetRandomFacts usecase,
// DisplayFactsView view,
// BehavioursCoordinator<FactAboutNumber> coordinator,
// LifecycleStrategist strategist,
// DomainToViewModel<FactAboutNumber, FactViewModel> mapper) {
//
// this.usecase = usecase;
// this.view = view;
// this.coordinator = coordinator;
// this.strategist = strategist;
// this.mapper = mapper;
// }
//
// public void fetchRandomFacts() {
// Flowable<FactViewModel> dataFlow =
// usecase.fetchTrivia()
// .compose(coordinator)
// .map(fact -> mapper.translate(fact));
//
// Disposable toDispose = view.subscribeInto(dataFlow);
// strategist.applyStrategy(toDispose);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
| import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import javax.inject.Inject;
import br.ufs.demos.rxmvp.playground.R;
import br.ufs.demos.rxmvp.playground.trivia.presentation.DisplayFactsView;
import br.ufs.demos.rxmvp.playground.trivia.presentation.FactsPresenter;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import butterknife.BindView;
import butterknife.ButterKnife;
import dagger.android.AndroidInjection;
import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
import static android.support.design.widget.Snackbar.LENGTH_INDEFINITE; | @Override public Action hideEmptyState() {
return () -> feedbackMessage.setVisibility(View.GONE);
}
@Override public Action showErrorState() {
return () -> {
feedbackMessage.setVisibility(View.VISIBLE);
feedbackMessage.setText(R.string.feedback_error_state);
};
}
@Override public Action hideErrorState() {
return () -> feedbackMessage.setVisibility(View.GONE);
}
@Override public Action reportNetworkingError() {
return () ->
Snackbar.make(container, R.string.feedback_message_internet_issue, LENGTH_INDEFINITE)
.setAction("TENTAR NOVAMENTE", view -> newTrivia())
.show();
}
@Override public Action disableRefresh() {
return () -> fab.setVisibility(View.GONE);
}
@Override public Action enableRefresh() {
return () -> fab.setVisibility(View.VISIBLE);
}
| // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/DisplayFactsView.java
// public interface DisplayFactsView extends
// LoadingView,
// ErrorStateView,
// EmptyStateView,
// NetworkingErrorView,
// ToogleRefreshView {
//
// Disposable subscribeInto(Flowable<FactViewModel> flow);
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsPresenter.java
// public class FactsPresenter {
//
// private GetRandomFacts usecase;
// private DisplayFactsView view;
// private BehavioursCoordinator<FactAboutNumber> coordinator;
// private LifecycleStrategist strategist;
// private DomainToViewModel<FactAboutNumber, FactViewModel> mapper;
//
// public FactsPresenter(GetRandomFacts usecase,
// DisplayFactsView view,
// BehavioursCoordinator<FactAboutNumber> coordinator,
// LifecycleStrategist strategist,
// DomainToViewModel<FactAboutNumber, FactViewModel> mapper) {
//
// this.usecase = usecase;
// this.view = view;
// this.coordinator = coordinator;
// this.strategist = strategist;
// this.mapper = mapper;
// }
//
// public void fetchRandomFacts() {
// Flowable<FactViewModel> dataFlow =
// usecase.fetchTrivia()
// .compose(coordinator)
// .map(fact -> mapper.translate(fact));
//
// Disposable toDispose = view.subscribeInto(dataFlow);
// strategist.applyStrategy(toDispose);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/ui/FactsAboutNumbersActivity.java
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import javax.inject.Inject;
import br.ufs.demos.rxmvp.playground.R;
import br.ufs.demos.rxmvp.playground.trivia.presentation.DisplayFactsView;
import br.ufs.demos.rxmvp.playground.trivia.presentation.FactsPresenter;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import butterknife.BindView;
import butterknife.ButterKnife;
import dagger.android.AndroidInjection;
import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
import static android.support.design.widget.Snackbar.LENGTH_INDEFINITE;
@Override public Action hideEmptyState() {
return () -> feedbackMessage.setVisibility(View.GONE);
}
@Override public Action showErrorState() {
return () -> {
feedbackMessage.setVisibility(View.VISIBLE);
feedbackMessage.setText(R.string.feedback_error_state);
};
}
@Override public Action hideErrorState() {
return () -> feedbackMessage.setVisibility(View.GONE);
}
@Override public Action reportNetworkingError() {
return () ->
Snackbar.make(container, R.string.feedback_message_internet_issue, LENGTH_INDEFINITE)
.setAction("TENTAR NOVAMENTE", view -> newTrivia())
.show();
}
@Override public Action disableRefresh() {
return () -> fab.setVisibility(View.GONE);
}
@Override public Action enableRefresh() {
return () -> fab.setVisibility(View.VISIBLE);
}
| @Override public Disposable subscribeInto(Flowable<FactViewModel> flow) { |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsViewModelMapper.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/FactAboutNumber.java
// public class FactAboutNumber {
//
// public String number;
// public String fact;
//
// private FactAboutNumber(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// public static FactAboutNumber of(String number, String fact) {
// return new FactAboutNumber(number, fact);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/ComposedWithSpannedStyles.java
// public class ComposedWithSpannedStyles implements FactViewModel {
//
// private String number;
// private String fact;
// private ForegroundColorSpan numberColor;
//
//
// private ComposedWithSpannedStyles(String number,
// String fact,
// ForegroundColorSpan numberColor) {
// this.number = number;
// this.fact = fact;
// this.numberColor = numberColor;
// }
//
// public static ComposedWithSpannedStyles with(String number,
// String fact,
// ForegroundColorSpan numberColor) {
//
// return new ComposedWithSpannedStyles(number, fact, numberColor);
// }
//
// @Override public CharSequence formattedFact() {
//
// return new Spanny()
// .append(number, new StyleSpan(Typeface.BOLD), numberColor)
// .append(fact);
// }
//
// @Override public int viewType() {
// return TYPE_SINGLE_LABEL;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/NumberAndFact.java
// public class NumberAndFact implements FactViewModel {
//
// private String number;
// private String fact;
//
// public NumberAndFact(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// @Override public CharSequence formattedFact() {
// return fact;
// }
//
// @Override public int viewType() {
// return TYPE_TWO_LABELS;
// }
//
// public String relatedNumber() {
// return number;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/DomainToViewModel.java
// public interface DomainToViewModel<Data, ViewModel> {
//
// ViewModel translate(Data data);
//
// }
| import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.text.style.ForegroundColorSpan;
import br.ufs.demos.rxmvp.playground.R;
import br.ufs.demos.rxmvp.playground.trivia.domain.FactAboutNumber;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.ComposedWithSpannedStyles;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.NumberAndFact;
import br.ufs.demos.rxmvp.playground.util.DomainToViewModel; | package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 7/1/17.
*/
public class FactsViewModelMapper implements DomainToViewModel<FactAboutNumber, FactViewModel> {
private static final int MAX_CHARS_FOR_SMALL_FACT = 50;
private Context context;
public FactsViewModelMapper(Context context) {
this.context = context;
}
@Override public FactViewModel translate(FactAboutNumber fact) {
if (isFactTooLarge(fact)) return composedWithSpans(fact);
return asNumberAndFact(fact);
}
private FactViewModel asNumberAndFact(FactAboutNumber fact) { | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/FactAboutNumber.java
// public class FactAboutNumber {
//
// public String number;
// public String fact;
//
// private FactAboutNumber(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// public static FactAboutNumber of(String number, String fact) {
// return new FactAboutNumber(number, fact);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/ComposedWithSpannedStyles.java
// public class ComposedWithSpannedStyles implements FactViewModel {
//
// private String number;
// private String fact;
// private ForegroundColorSpan numberColor;
//
//
// private ComposedWithSpannedStyles(String number,
// String fact,
// ForegroundColorSpan numberColor) {
// this.number = number;
// this.fact = fact;
// this.numberColor = numberColor;
// }
//
// public static ComposedWithSpannedStyles with(String number,
// String fact,
// ForegroundColorSpan numberColor) {
//
// return new ComposedWithSpannedStyles(number, fact, numberColor);
// }
//
// @Override public CharSequence formattedFact() {
//
// return new Spanny()
// .append(number, new StyleSpan(Typeface.BOLD), numberColor)
// .append(fact);
// }
//
// @Override public int viewType() {
// return TYPE_SINGLE_LABEL;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/NumberAndFact.java
// public class NumberAndFact implements FactViewModel {
//
// private String number;
// private String fact;
//
// public NumberAndFact(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// @Override public CharSequence formattedFact() {
// return fact;
// }
//
// @Override public int viewType() {
// return TYPE_TWO_LABELS;
// }
//
// public String relatedNumber() {
// return number;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/DomainToViewModel.java
// public interface DomainToViewModel<Data, ViewModel> {
//
// ViewModel translate(Data data);
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsViewModelMapper.java
import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.text.style.ForegroundColorSpan;
import br.ufs.demos.rxmvp.playground.R;
import br.ufs.demos.rxmvp.playground.trivia.domain.FactAboutNumber;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.ComposedWithSpannedStyles;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.NumberAndFact;
import br.ufs.demos.rxmvp.playground.util.DomainToViewModel;
package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 7/1/17.
*/
public class FactsViewModelMapper implements DomainToViewModel<FactAboutNumber, FactViewModel> {
private static final int MAX_CHARS_FOR_SMALL_FACT = 50;
private Context context;
public FactsViewModelMapper(Context context) {
this.context = context;
}
@Override public FactViewModel translate(FactAboutNumber fact) {
if (isFactTooLarge(fact)) return composedWithSpans(fact);
return asNumberAndFact(fact);
}
private FactViewModel asNumberAndFact(FactAboutNumber fact) { | return new NumberAndFact( |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsViewModelMapper.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/FactAboutNumber.java
// public class FactAboutNumber {
//
// public String number;
// public String fact;
//
// private FactAboutNumber(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// public static FactAboutNumber of(String number, String fact) {
// return new FactAboutNumber(number, fact);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/ComposedWithSpannedStyles.java
// public class ComposedWithSpannedStyles implements FactViewModel {
//
// private String number;
// private String fact;
// private ForegroundColorSpan numberColor;
//
//
// private ComposedWithSpannedStyles(String number,
// String fact,
// ForegroundColorSpan numberColor) {
// this.number = number;
// this.fact = fact;
// this.numberColor = numberColor;
// }
//
// public static ComposedWithSpannedStyles with(String number,
// String fact,
// ForegroundColorSpan numberColor) {
//
// return new ComposedWithSpannedStyles(number, fact, numberColor);
// }
//
// @Override public CharSequence formattedFact() {
//
// return new Spanny()
// .append(number, new StyleSpan(Typeface.BOLD), numberColor)
// .append(fact);
// }
//
// @Override public int viewType() {
// return TYPE_SINGLE_LABEL;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/NumberAndFact.java
// public class NumberAndFact implements FactViewModel {
//
// private String number;
// private String fact;
//
// public NumberAndFact(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// @Override public CharSequence formattedFact() {
// return fact;
// }
//
// @Override public int viewType() {
// return TYPE_TWO_LABELS;
// }
//
// public String relatedNumber() {
// return number;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/DomainToViewModel.java
// public interface DomainToViewModel<Data, ViewModel> {
//
// ViewModel translate(Data data);
//
// }
| import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.text.style.ForegroundColorSpan;
import br.ufs.demos.rxmvp.playground.R;
import br.ufs.demos.rxmvp.playground.trivia.domain.FactAboutNumber;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.ComposedWithSpannedStyles;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.NumberAndFact;
import br.ufs.demos.rxmvp.playground.util.DomainToViewModel; | package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 7/1/17.
*/
public class FactsViewModelMapper implements DomainToViewModel<FactAboutNumber, FactViewModel> {
private static final int MAX_CHARS_FOR_SMALL_FACT = 50;
private Context context;
public FactsViewModelMapper(Context context) {
this.context = context;
}
@Override public FactViewModel translate(FactAboutNumber fact) {
if (isFactTooLarge(fact)) return composedWithSpans(fact);
return asNumberAndFact(fact);
}
private FactViewModel asNumberAndFact(FactAboutNumber fact) {
return new NumberAndFact(
fact.number,
formatFact(fact.number, fact.fact)
);
}
private FactViewModel composedWithSpans(FactAboutNumber fact) {
int accent = ContextCompat.getColor(context, R.color.colorAccent);
| // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/FactAboutNumber.java
// public class FactAboutNumber {
//
// public String number;
// public String fact;
//
// private FactAboutNumber(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// public static FactAboutNumber of(String number, String fact) {
// return new FactAboutNumber(number, fact);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/ComposedWithSpannedStyles.java
// public class ComposedWithSpannedStyles implements FactViewModel {
//
// private String number;
// private String fact;
// private ForegroundColorSpan numberColor;
//
//
// private ComposedWithSpannedStyles(String number,
// String fact,
// ForegroundColorSpan numberColor) {
// this.number = number;
// this.fact = fact;
// this.numberColor = numberColor;
// }
//
// public static ComposedWithSpannedStyles with(String number,
// String fact,
// ForegroundColorSpan numberColor) {
//
// return new ComposedWithSpannedStyles(number, fact, numberColor);
// }
//
// @Override public CharSequence formattedFact() {
//
// return new Spanny()
// .append(number, new StyleSpan(Typeface.BOLD), numberColor)
// .append(fact);
// }
//
// @Override public int viewType() {
// return TYPE_SINGLE_LABEL;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/NumberAndFact.java
// public class NumberAndFact implements FactViewModel {
//
// private String number;
// private String fact;
//
// public NumberAndFact(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// @Override public CharSequence formattedFact() {
// return fact;
// }
//
// @Override public int viewType() {
// return TYPE_TWO_LABELS;
// }
//
// public String relatedNumber() {
// return number;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/DomainToViewModel.java
// public interface DomainToViewModel<Data, ViewModel> {
//
// ViewModel translate(Data data);
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsViewModelMapper.java
import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.text.style.ForegroundColorSpan;
import br.ufs.demos.rxmvp.playground.R;
import br.ufs.demos.rxmvp.playground.trivia.domain.FactAboutNumber;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.ComposedWithSpannedStyles;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.NumberAndFact;
import br.ufs.demos.rxmvp.playground.util.DomainToViewModel;
package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 7/1/17.
*/
public class FactsViewModelMapper implements DomainToViewModel<FactAboutNumber, FactViewModel> {
private static final int MAX_CHARS_FOR_SMALL_FACT = 50;
private Context context;
public FactsViewModelMapper(Context context) {
this.context = context;
}
@Override public FactViewModel translate(FactAboutNumber fact) {
if (isFactTooLarge(fact)) return composedWithSpans(fact);
return asNumberAndFact(fact);
}
private FactViewModel asNumberAndFact(FactAboutNumber fact) {
return new NumberAndFact(
fact.number,
formatFact(fact.number, fact.fact)
);
}
private FactViewModel composedWithSpans(FactAboutNumber fact) {
int accent = ContextCompat.getColor(context, R.color.colorAccent);
| return ComposedWithSpannedStyles.with( |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/LifecycleStrategistModule.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/DisposeStrategy.java
// public class DisposeStrategy implements LifecycleObserver {
//
// private CompositeDisposable composite = new CompositeDisposable();
//
// public void addDisposable(Disposable toDispose) {
// composite.add(toDispose);
// }
//
// @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroy() {
// composite.dispose();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
| import android.arch.lifecycle.LifecycleOwner;
import br.ufs.demos.rxmvp.playground.core.lifecycles.DisposeStrategy;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import dagger.Module;
import dagger.Provides; | package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 7/5/17.
*/
@Module
public class LifecycleStrategistModule {
| // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/DisposeStrategy.java
// public class DisposeStrategy implements LifecycleObserver {
//
// private CompositeDisposable composite = new CompositeDisposable();
//
// public void addDisposable(Disposable toDispose) {
// composite.add(toDispose);
// }
//
// @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroy() {
// composite.dispose();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/LifecycleStrategistModule.java
import android.arch.lifecycle.LifecycleOwner;
import br.ufs.demos.rxmvp.playground.core.lifecycles.DisposeStrategy;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import dagger.Module;
import dagger.Provides;
package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 7/5/17.
*/
@Module
public class LifecycleStrategistModule {
| @Provides static LifecycleStrategist strategist(LifecycleOwner owner) { |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/LifecycleStrategistModule.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/DisposeStrategy.java
// public class DisposeStrategy implements LifecycleObserver {
//
// private CompositeDisposable composite = new CompositeDisposable();
//
// public void addDisposable(Disposable toDispose) {
// composite.add(toDispose);
// }
//
// @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroy() {
// composite.dispose();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
| import android.arch.lifecycle.LifecycleOwner;
import br.ufs.demos.rxmvp.playground.core.lifecycles.DisposeStrategy;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import dagger.Module;
import dagger.Provides; | package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 7/5/17.
*/
@Module
public class LifecycleStrategistModule {
@Provides static LifecycleStrategist strategist(LifecycleOwner owner) { | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/DisposeStrategy.java
// public class DisposeStrategy implements LifecycleObserver {
//
// private CompositeDisposable composite = new CompositeDisposable();
//
// public void addDisposable(Disposable toDispose) {
// composite.add(toDispose);
// }
//
// @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroy() {
// composite.dispose();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/LifecycleStrategistModule.java
import android.arch.lifecycle.LifecycleOwner;
import br.ufs.demos.rxmvp.playground.core.lifecycles.DisposeStrategy;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import dagger.Module;
import dagger.Provides;
package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 7/5/17.
*/
@Module
public class LifecycleStrategistModule {
@Provides static LifecycleStrategist strategist(LifecycleOwner owner) { | return new LifecycleStrategist(owner, new DisposeStrategy()); |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/InfrastructureModule.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/TriviaGenerator.java
// public class TriviaGenerator {
//
// private static final int LARGER_NUMBER_TO_LEARN_ABOUT = 200;
// private static final int TRIVIA_COUNT = 10;
// private static final Random RANDOMIZER = new Random();
//
// private List<Integer> numbers = new ArrayList<>();
//
// public List<Integer> numberForTrivia() {
//
// numbers.clear();
//
// while (numbers.size() < TRIVIA_COUNT) {
//
// int candidate = RANDOMIZER.nextInt(LARGER_NUMBER_TO_LEARN_ABOUT);
//
// if (!numbers.contains(candidate)) {
// numbers.add(candidate);
// }
// }
//
// return numbers;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadMapper.java
// public class PayloadMapper {
//
// List<FactAboutNumber> toNumberFacts(NumbersTriviaPayload payload) {
//
// return Ix.from(payload.entrySet())
// .map(entry -> FactAboutNumber.of(entry.getKey(), entry.getValue()))
// .cast(FactAboutNumber.class)
// .toList();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadValidator.java
// public class PayloadValidator {
//
// boolean accept(NumbersTriviaPayload payload) {
// return notNullNotEmpty(payload.entrySet());
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/TriviaInfrastructure.java
// public class TriviaInfrastructure implements GetRandomFacts {
//
// private NumbersWebService webService;
// private TriviaGenerator triviaGenerator;
// private PayloadMapper mapper;
// private PayloadValidator validator;
// private Scheduler executionScheduler;
//
// public TriviaInfrastructure(NumbersWebService webService,
// TriviaGenerator triviaGenerator,
// PayloadMapper mapper,
// PayloadValidator validator,
// Scheduler executionScheduler) {
//
// this.webService = webService;
// this.triviaGenerator = triviaGenerator;
// this.mapper = mapper;
// this.validator = validator;
// this.executionScheduler = executionScheduler;
// }
//
// @Override public Flowable<FactAboutNumber> fetchTrivia() {
//
// List<Integer> numbersForTrivia = triviaGenerator.numberForTrivia();
// String formattedUrlPath = formatPathWithCommas(numbersForTrivia);
//
// return webService
// .getTrivia(formattedUrlPath)
// .subscribeOn(executionScheduler)
// .compose(new NetworkingErrorHandler<>())
// .compose(new RestErrorsHandler<>())
// .compose(new DeserializationIssuesHandler<>())
// .filter(payload -> validator.accept(payload))
// .map(payload -> mapper.toNumberFacts(payload))
// .flatMap(Flowable::fromIterable);
// }
//
// private String formatPathWithCommas(List<Integer> numbersForTrivia) {
// return numbersForTrivia
// .toString()
// .replace(" ", "")
// .replace("[", "")
// .replace("]", "");
// }
//
// }
| import br.ufs.demos.rxmvp.playground.dagger.qualifiers.IOScheduler;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.domain.TriviaGenerator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadMapper;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadValidator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.TriviaInfrastructure;
import dagger.Module;
import dagger.Provides;
import io.reactivex.Scheduler; | package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 7/1/17.
*/
@Module
public class InfrastructureModule {
| // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/TriviaGenerator.java
// public class TriviaGenerator {
//
// private static final int LARGER_NUMBER_TO_LEARN_ABOUT = 200;
// private static final int TRIVIA_COUNT = 10;
// private static final Random RANDOMIZER = new Random();
//
// private List<Integer> numbers = new ArrayList<>();
//
// public List<Integer> numberForTrivia() {
//
// numbers.clear();
//
// while (numbers.size() < TRIVIA_COUNT) {
//
// int candidate = RANDOMIZER.nextInt(LARGER_NUMBER_TO_LEARN_ABOUT);
//
// if (!numbers.contains(candidate)) {
// numbers.add(candidate);
// }
// }
//
// return numbers;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadMapper.java
// public class PayloadMapper {
//
// List<FactAboutNumber> toNumberFacts(NumbersTriviaPayload payload) {
//
// return Ix.from(payload.entrySet())
// .map(entry -> FactAboutNumber.of(entry.getKey(), entry.getValue()))
// .cast(FactAboutNumber.class)
// .toList();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadValidator.java
// public class PayloadValidator {
//
// boolean accept(NumbersTriviaPayload payload) {
// return notNullNotEmpty(payload.entrySet());
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/TriviaInfrastructure.java
// public class TriviaInfrastructure implements GetRandomFacts {
//
// private NumbersWebService webService;
// private TriviaGenerator triviaGenerator;
// private PayloadMapper mapper;
// private PayloadValidator validator;
// private Scheduler executionScheduler;
//
// public TriviaInfrastructure(NumbersWebService webService,
// TriviaGenerator triviaGenerator,
// PayloadMapper mapper,
// PayloadValidator validator,
// Scheduler executionScheduler) {
//
// this.webService = webService;
// this.triviaGenerator = triviaGenerator;
// this.mapper = mapper;
// this.validator = validator;
// this.executionScheduler = executionScheduler;
// }
//
// @Override public Flowable<FactAboutNumber> fetchTrivia() {
//
// List<Integer> numbersForTrivia = triviaGenerator.numberForTrivia();
// String formattedUrlPath = formatPathWithCommas(numbersForTrivia);
//
// return webService
// .getTrivia(formattedUrlPath)
// .subscribeOn(executionScheduler)
// .compose(new NetworkingErrorHandler<>())
// .compose(new RestErrorsHandler<>())
// .compose(new DeserializationIssuesHandler<>())
// .filter(payload -> validator.accept(payload))
// .map(payload -> mapper.toNumberFacts(payload))
// .flatMap(Flowable::fromIterable);
// }
//
// private String formatPathWithCommas(List<Integer> numbersForTrivia) {
// return numbersForTrivia
// .toString()
// .replace(" ", "")
// .replace("[", "")
// .replace("]", "");
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/InfrastructureModule.java
import br.ufs.demos.rxmvp.playground.dagger.qualifiers.IOScheduler;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.domain.TriviaGenerator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadMapper;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadValidator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.TriviaInfrastructure;
import dagger.Module;
import dagger.Provides;
import io.reactivex.Scheduler;
package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 7/1/17.
*/
@Module
public class InfrastructureModule {
| @Provides static GetRandomFacts infrastructure( |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/InfrastructureModule.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/TriviaGenerator.java
// public class TriviaGenerator {
//
// private static final int LARGER_NUMBER_TO_LEARN_ABOUT = 200;
// private static final int TRIVIA_COUNT = 10;
// private static final Random RANDOMIZER = new Random();
//
// private List<Integer> numbers = new ArrayList<>();
//
// public List<Integer> numberForTrivia() {
//
// numbers.clear();
//
// while (numbers.size() < TRIVIA_COUNT) {
//
// int candidate = RANDOMIZER.nextInt(LARGER_NUMBER_TO_LEARN_ABOUT);
//
// if (!numbers.contains(candidate)) {
// numbers.add(candidate);
// }
// }
//
// return numbers;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadMapper.java
// public class PayloadMapper {
//
// List<FactAboutNumber> toNumberFacts(NumbersTriviaPayload payload) {
//
// return Ix.from(payload.entrySet())
// .map(entry -> FactAboutNumber.of(entry.getKey(), entry.getValue()))
// .cast(FactAboutNumber.class)
// .toList();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadValidator.java
// public class PayloadValidator {
//
// boolean accept(NumbersTriviaPayload payload) {
// return notNullNotEmpty(payload.entrySet());
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/TriviaInfrastructure.java
// public class TriviaInfrastructure implements GetRandomFacts {
//
// private NumbersWebService webService;
// private TriviaGenerator triviaGenerator;
// private PayloadMapper mapper;
// private PayloadValidator validator;
// private Scheduler executionScheduler;
//
// public TriviaInfrastructure(NumbersWebService webService,
// TriviaGenerator triviaGenerator,
// PayloadMapper mapper,
// PayloadValidator validator,
// Scheduler executionScheduler) {
//
// this.webService = webService;
// this.triviaGenerator = triviaGenerator;
// this.mapper = mapper;
// this.validator = validator;
// this.executionScheduler = executionScheduler;
// }
//
// @Override public Flowable<FactAboutNumber> fetchTrivia() {
//
// List<Integer> numbersForTrivia = triviaGenerator.numberForTrivia();
// String formattedUrlPath = formatPathWithCommas(numbersForTrivia);
//
// return webService
// .getTrivia(formattedUrlPath)
// .subscribeOn(executionScheduler)
// .compose(new NetworkingErrorHandler<>())
// .compose(new RestErrorsHandler<>())
// .compose(new DeserializationIssuesHandler<>())
// .filter(payload -> validator.accept(payload))
// .map(payload -> mapper.toNumberFacts(payload))
// .flatMap(Flowable::fromIterable);
// }
//
// private String formatPathWithCommas(List<Integer> numbersForTrivia) {
// return numbersForTrivia
// .toString()
// .replace(" ", "")
// .replace("[", "")
// .replace("]", "");
// }
//
// }
| import br.ufs.demos.rxmvp.playground.dagger.qualifiers.IOScheduler;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.domain.TriviaGenerator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadMapper;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadValidator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.TriviaInfrastructure;
import dagger.Module;
import dagger.Provides;
import io.reactivex.Scheduler; | package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 7/1/17.
*/
@Module
public class InfrastructureModule {
@Provides static GetRandomFacts infrastructure( | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/TriviaGenerator.java
// public class TriviaGenerator {
//
// private static final int LARGER_NUMBER_TO_LEARN_ABOUT = 200;
// private static final int TRIVIA_COUNT = 10;
// private static final Random RANDOMIZER = new Random();
//
// private List<Integer> numbers = new ArrayList<>();
//
// public List<Integer> numberForTrivia() {
//
// numbers.clear();
//
// while (numbers.size() < TRIVIA_COUNT) {
//
// int candidate = RANDOMIZER.nextInt(LARGER_NUMBER_TO_LEARN_ABOUT);
//
// if (!numbers.contains(candidate)) {
// numbers.add(candidate);
// }
// }
//
// return numbers;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadMapper.java
// public class PayloadMapper {
//
// List<FactAboutNumber> toNumberFacts(NumbersTriviaPayload payload) {
//
// return Ix.from(payload.entrySet())
// .map(entry -> FactAboutNumber.of(entry.getKey(), entry.getValue()))
// .cast(FactAboutNumber.class)
// .toList();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadValidator.java
// public class PayloadValidator {
//
// boolean accept(NumbersTriviaPayload payload) {
// return notNullNotEmpty(payload.entrySet());
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/TriviaInfrastructure.java
// public class TriviaInfrastructure implements GetRandomFacts {
//
// private NumbersWebService webService;
// private TriviaGenerator triviaGenerator;
// private PayloadMapper mapper;
// private PayloadValidator validator;
// private Scheduler executionScheduler;
//
// public TriviaInfrastructure(NumbersWebService webService,
// TriviaGenerator triviaGenerator,
// PayloadMapper mapper,
// PayloadValidator validator,
// Scheduler executionScheduler) {
//
// this.webService = webService;
// this.triviaGenerator = triviaGenerator;
// this.mapper = mapper;
// this.validator = validator;
// this.executionScheduler = executionScheduler;
// }
//
// @Override public Flowable<FactAboutNumber> fetchTrivia() {
//
// List<Integer> numbersForTrivia = triviaGenerator.numberForTrivia();
// String formattedUrlPath = formatPathWithCommas(numbersForTrivia);
//
// return webService
// .getTrivia(formattedUrlPath)
// .subscribeOn(executionScheduler)
// .compose(new NetworkingErrorHandler<>())
// .compose(new RestErrorsHandler<>())
// .compose(new DeserializationIssuesHandler<>())
// .filter(payload -> validator.accept(payload))
// .map(payload -> mapper.toNumberFacts(payload))
// .flatMap(Flowable::fromIterable);
// }
//
// private String formatPathWithCommas(List<Integer> numbersForTrivia) {
// return numbersForTrivia
// .toString()
// .replace(" ", "")
// .replace("[", "")
// .replace("]", "");
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/InfrastructureModule.java
import br.ufs.demos.rxmvp.playground.dagger.qualifiers.IOScheduler;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.domain.TriviaGenerator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadMapper;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadValidator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.TriviaInfrastructure;
import dagger.Module;
import dagger.Provides;
import io.reactivex.Scheduler;
package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 7/1/17.
*/
@Module
public class InfrastructureModule {
@Provides static GetRandomFacts infrastructure( | NumbersWebService webService, |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/InfrastructureModule.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/TriviaGenerator.java
// public class TriviaGenerator {
//
// private static final int LARGER_NUMBER_TO_LEARN_ABOUT = 200;
// private static final int TRIVIA_COUNT = 10;
// private static final Random RANDOMIZER = new Random();
//
// private List<Integer> numbers = new ArrayList<>();
//
// public List<Integer> numberForTrivia() {
//
// numbers.clear();
//
// while (numbers.size() < TRIVIA_COUNT) {
//
// int candidate = RANDOMIZER.nextInt(LARGER_NUMBER_TO_LEARN_ABOUT);
//
// if (!numbers.contains(candidate)) {
// numbers.add(candidate);
// }
// }
//
// return numbers;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadMapper.java
// public class PayloadMapper {
//
// List<FactAboutNumber> toNumberFacts(NumbersTriviaPayload payload) {
//
// return Ix.from(payload.entrySet())
// .map(entry -> FactAboutNumber.of(entry.getKey(), entry.getValue()))
// .cast(FactAboutNumber.class)
// .toList();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadValidator.java
// public class PayloadValidator {
//
// boolean accept(NumbersTriviaPayload payload) {
// return notNullNotEmpty(payload.entrySet());
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/TriviaInfrastructure.java
// public class TriviaInfrastructure implements GetRandomFacts {
//
// private NumbersWebService webService;
// private TriviaGenerator triviaGenerator;
// private PayloadMapper mapper;
// private PayloadValidator validator;
// private Scheduler executionScheduler;
//
// public TriviaInfrastructure(NumbersWebService webService,
// TriviaGenerator triviaGenerator,
// PayloadMapper mapper,
// PayloadValidator validator,
// Scheduler executionScheduler) {
//
// this.webService = webService;
// this.triviaGenerator = triviaGenerator;
// this.mapper = mapper;
// this.validator = validator;
// this.executionScheduler = executionScheduler;
// }
//
// @Override public Flowable<FactAboutNumber> fetchTrivia() {
//
// List<Integer> numbersForTrivia = triviaGenerator.numberForTrivia();
// String formattedUrlPath = formatPathWithCommas(numbersForTrivia);
//
// return webService
// .getTrivia(formattedUrlPath)
// .subscribeOn(executionScheduler)
// .compose(new NetworkingErrorHandler<>())
// .compose(new RestErrorsHandler<>())
// .compose(new DeserializationIssuesHandler<>())
// .filter(payload -> validator.accept(payload))
// .map(payload -> mapper.toNumberFacts(payload))
// .flatMap(Flowable::fromIterable);
// }
//
// private String formatPathWithCommas(List<Integer> numbersForTrivia) {
// return numbersForTrivia
// .toString()
// .replace(" ", "")
// .replace("[", "")
// .replace("]", "");
// }
//
// }
| import br.ufs.demos.rxmvp.playground.dagger.qualifiers.IOScheduler;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.domain.TriviaGenerator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadMapper;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadValidator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.TriviaInfrastructure;
import dagger.Module;
import dagger.Provides;
import io.reactivex.Scheduler; | package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 7/1/17.
*/
@Module
public class InfrastructureModule {
@Provides static GetRandomFacts infrastructure(
NumbersWebService webService, | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/TriviaGenerator.java
// public class TriviaGenerator {
//
// private static final int LARGER_NUMBER_TO_LEARN_ABOUT = 200;
// private static final int TRIVIA_COUNT = 10;
// private static final Random RANDOMIZER = new Random();
//
// private List<Integer> numbers = new ArrayList<>();
//
// public List<Integer> numberForTrivia() {
//
// numbers.clear();
//
// while (numbers.size() < TRIVIA_COUNT) {
//
// int candidate = RANDOMIZER.nextInt(LARGER_NUMBER_TO_LEARN_ABOUT);
//
// if (!numbers.contains(candidate)) {
// numbers.add(candidate);
// }
// }
//
// return numbers;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadMapper.java
// public class PayloadMapper {
//
// List<FactAboutNumber> toNumberFacts(NumbersTriviaPayload payload) {
//
// return Ix.from(payload.entrySet())
// .map(entry -> FactAboutNumber.of(entry.getKey(), entry.getValue()))
// .cast(FactAboutNumber.class)
// .toList();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadValidator.java
// public class PayloadValidator {
//
// boolean accept(NumbersTriviaPayload payload) {
// return notNullNotEmpty(payload.entrySet());
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/TriviaInfrastructure.java
// public class TriviaInfrastructure implements GetRandomFacts {
//
// private NumbersWebService webService;
// private TriviaGenerator triviaGenerator;
// private PayloadMapper mapper;
// private PayloadValidator validator;
// private Scheduler executionScheduler;
//
// public TriviaInfrastructure(NumbersWebService webService,
// TriviaGenerator triviaGenerator,
// PayloadMapper mapper,
// PayloadValidator validator,
// Scheduler executionScheduler) {
//
// this.webService = webService;
// this.triviaGenerator = triviaGenerator;
// this.mapper = mapper;
// this.validator = validator;
// this.executionScheduler = executionScheduler;
// }
//
// @Override public Flowable<FactAboutNumber> fetchTrivia() {
//
// List<Integer> numbersForTrivia = triviaGenerator.numberForTrivia();
// String formattedUrlPath = formatPathWithCommas(numbersForTrivia);
//
// return webService
// .getTrivia(formattedUrlPath)
// .subscribeOn(executionScheduler)
// .compose(new NetworkingErrorHandler<>())
// .compose(new RestErrorsHandler<>())
// .compose(new DeserializationIssuesHandler<>())
// .filter(payload -> validator.accept(payload))
// .map(payload -> mapper.toNumberFacts(payload))
// .flatMap(Flowable::fromIterable);
// }
//
// private String formatPathWithCommas(List<Integer> numbersForTrivia) {
// return numbersForTrivia
// .toString()
// .replace(" ", "")
// .replace("[", "")
// .replace("]", "");
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/InfrastructureModule.java
import br.ufs.demos.rxmvp.playground.dagger.qualifiers.IOScheduler;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.domain.TriviaGenerator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadMapper;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadValidator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.TriviaInfrastructure;
import dagger.Module;
import dagger.Provides;
import io.reactivex.Scheduler;
package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 7/1/17.
*/
@Module
public class InfrastructureModule {
@Provides static GetRandomFacts infrastructure(
NumbersWebService webService, | TriviaGenerator generator, |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/InfrastructureModule.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/TriviaGenerator.java
// public class TriviaGenerator {
//
// private static final int LARGER_NUMBER_TO_LEARN_ABOUT = 200;
// private static final int TRIVIA_COUNT = 10;
// private static final Random RANDOMIZER = new Random();
//
// private List<Integer> numbers = new ArrayList<>();
//
// public List<Integer> numberForTrivia() {
//
// numbers.clear();
//
// while (numbers.size() < TRIVIA_COUNT) {
//
// int candidate = RANDOMIZER.nextInt(LARGER_NUMBER_TO_LEARN_ABOUT);
//
// if (!numbers.contains(candidate)) {
// numbers.add(candidate);
// }
// }
//
// return numbers;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadMapper.java
// public class PayloadMapper {
//
// List<FactAboutNumber> toNumberFacts(NumbersTriviaPayload payload) {
//
// return Ix.from(payload.entrySet())
// .map(entry -> FactAboutNumber.of(entry.getKey(), entry.getValue()))
// .cast(FactAboutNumber.class)
// .toList();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadValidator.java
// public class PayloadValidator {
//
// boolean accept(NumbersTriviaPayload payload) {
// return notNullNotEmpty(payload.entrySet());
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/TriviaInfrastructure.java
// public class TriviaInfrastructure implements GetRandomFacts {
//
// private NumbersWebService webService;
// private TriviaGenerator triviaGenerator;
// private PayloadMapper mapper;
// private PayloadValidator validator;
// private Scheduler executionScheduler;
//
// public TriviaInfrastructure(NumbersWebService webService,
// TriviaGenerator triviaGenerator,
// PayloadMapper mapper,
// PayloadValidator validator,
// Scheduler executionScheduler) {
//
// this.webService = webService;
// this.triviaGenerator = triviaGenerator;
// this.mapper = mapper;
// this.validator = validator;
// this.executionScheduler = executionScheduler;
// }
//
// @Override public Flowable<FactAboutNumber> fetchTrivia() {
//
// List<Integer> numbersForTrivia = triviaGenerator.numberForTrivia();
// String formattedUrlPath = formatPathWithCommas(numbersForTrivia);
//
// return webService
// .getTrivia(formattedUrlPath)
// .subscribeOn(executionScheduler)
// .compose(new NetworkingErrorHandler<>())
// .compose(new RestErrorsHandler<>())
// .compose(new DeserializationIssuesHandler<>())
// .filter(payload -> validator.accept(payload))
// .map(payload -> mapper.toNumberFacts(payload))
// .flatMap(Flowable::fromIterable);
// }
//
// private String formatPathWithCommas(List<Integer> numbersForTrivia) {
// return numbersForTrivia
// .toString()
// .replace(" ", "")
// .replace("[", "")
// .replace("]", "");
// }
//
// }
| import br.ufs.demos.rxmvp.playground.dagger.qualifiers.IOScheduler;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.domain.TriviaGenerator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadMapper;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadValidator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.TriviaInfrastructure;
import dagger.Module;
import dagger.Provides;
import io.reactivex.Scheduler; | package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 7/1/17.
*/
@Module
public class InfrastructureModule {
@Provides static GetRandomFacts infrastructure(
NumbersWebService webService,
TriviaGenerator generator, | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/TriviaGenerator.java
// public class TriviaGenerator {
//
// private static final int LARGER_NUMBER_TO_LEARN_ABOUT = 200;
// private static final int TRIVIA_COUNT = 10;
// private static final Random RANDOMIZER = new Random();
//
// private List<Integer> numbers = new ArrayList<>();
//
// public List<Integer> numberForTrivia() {
//
// numbers.clear();
//
// while (numbers.size() < TRIVIA_COUNT) {
//
// int candidate = RANDOMIZER.nextInt(LARGER_NUMBER_TO_LEARN_ABOUT);
//
// if (!numbers.contains(candidate)) {
// numbers.add(candidate);
// }
// }
//
// return numbers;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadMapper.java
// public class PayloadMapper {
//
// List<FactAboutNumber> toNumberFacts(NumbersTriviaPayload payload) {
//
// return Ix.from(payload.entrySet())
// .map(entry -> FactAboutNumber.of(entry.getKey(), entry.getValue()))
// .cast(FactAboutNumber.class)
// .toList();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadValidator.java
// public class PayloadValidator {
//
// boolean accept(NumbersTriviaPayload payload) {
// return notNullNotEmpty(payload.entrySet());
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/TriviaInfrastructure.java
// public class TriviaInfrastructure implements GetRandomFacts {
//
// private NumbersWebService webService;
// private TriviaGenerator triviaGenerator;
// private PayloadMapper mapper;
// private PayloadValidator validator;
// private Scheduler executionScheduler;
//
// public TriviaInfrastructure(NumbersWebService webService,
// TriviaGenerator triviaGenerator,
// PayloadMapper mapper,
// PayloadValidator validator,
// Scheduler executionScheduler) {
//
// this.webService = webService;
// this.triviaGenerator = triviaGenerator;
// this.mapper = mapper;
// this.validator = validator;
// this.executionScheduler = executionScheduler;
// }
//
// @Override public Flowable<FactAboutNumber> fetchTrivia() {
//
// List<Integer> numbersForTrivia = triviaGenerator.numberForTrivia();
// String formattedUrlPath = formatPathWithCommas(numbersForTrivia);
//
// return webService
// .getTrivia(formattedUrlPath)
// .subscribeOn(executionScheduler)
// .compose(new NetworkingErrorHandler<>())
// .compose(new RestErrorsHandler<>())
// .compose(new DeserializationIssuesHandler<>())
// .filter(payload -> validator.accept(payload))
// .map(payload -> mapper.toNumberFacts(payload))
// .flatMap(Flowable::fromIterable);
// }
//
// private String formatPathWithCommas(List<Integer> numbersForTrivia) {
// return numbersForTrivia
// .toString()
// .replace(" ", "")
// .replace("[", "")
// .replace("]", "");
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/InfrastructureModule.java
import br.ufs.demos.rxmvp.playground.dagger.qualifiers.IOScheduler;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.domain.TriviaGenerator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadMapper;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadValidator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.TriviaInfrastructure;
import dagger.Module;
import dagger.Provides;
import io.reactivex.Scheduler;
package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 7/1/17.
*/
@Module
public class InfrastructureModule {
@Provides static GetRandomFacts infrastructure(
NumbersWebService webService,
TriviaGenerator generator, | PayloadMapper mapper, |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/InfrastructureModule.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/TriviaGenerator.java
// public class TriviaGenerator {
//
// private static final int LARGER_NUMBER_TO_LEARN_ABOUT = 200;
// private static final int TRIVIA_COUNT = 10;
// private static final Random RANDOMIZER = new Random();
//
// private List<Integer> numbers = new ArrayList<>();
//
// public List<Integer> numberForTrivia() {
//
// numbers.clear();
//
// while (numbers.size() < TRIVIA_COUNT) {
//
// int candidate = RANDOMIZER.nextInt(LARGER_NUMBER_TO_LEARN_ABOUT);
//
// if (!numbers.contains(candidate)) {
// numbers.add(candidate);
// }
// }
//
// return numbers;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadMapper.java
// public class PayloadMapper {
//
// List<FactAboutNumber> toNumberFacts(NumbersTriviaPayload payload) {
//
// return Ix.from(payload.entrySet())
// .map(entry -> FactAboutNumber.of(entry.getKey(), entry.getValue()))
// .cast(FactAboutNumber.class)
// .toList();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadValidator.java
// public class PayloadValidator {
//
// boolean accept(NumbersTriviaPayload payload) {
// return notNullNotEmpty(payload.entrySet());
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/TriviaInfrastructure.java
// public class TriviaInfrastructure implements GetRandomFacts {
//
// private NumbersWebService webService;
// private TriviaGenerator triviaGenerator;
// private PayloadMapper mapper;
// private PayloadValidator validator;
// private Scheduler executionScheduler;
//
// public TriviaInfrastructure(NumbersWebService webService,
// TriviaGenerator triviaGenerator,
// PayloadMapper mapper,
// PayloadValidator validator,
// Scheduler executionScheduler) {
//
// this.webService = webService;
// this.triviaGenerator = triviaGenerator;
// this.mapper = mapper;
// this.validator = validator;
// this.executionScheduler = executionScheduler;
// }
//
// @Override public Flowable<FactAboutNumber> fetchTrivia() {
//
// List<Integer> numbersForTrivia = triviaGenerator.numberForTrivia();
// String formattedUrlPath = formatPathWithCommas(numbersForTrivia);
//
// return webService
// .getTrivia(formattedUrlPath)
// .subscribeOn(executionScheduler)
// .compose(new NetworkingErrorHandler<>())
// .compose(new RestErrorsHandler<>())
// .compose(new DeserializationIssuesHandler<>())
// .filter(payload -> validator.accept(payload))
// .map(payload -> mapper.toNumberFacts(payload))
// .flatMap(Flowable::fromIterable);
// }
//
// private String formatPathWithCommas(List<Integer> numbersForTrivia) {
// return numbersForTrivia
// .toString()
// .replace(" ", "")
// .replace("[", "")
// .replace("]", "");
// }
//
// }
| import br.ufs.demos.rxmvp.playground.dagger.qualifiers.IOScheduler;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.domain.TriviaGenerator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadMapper;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadValidator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.TriviaInfrastructure;
import dagger.Module;
import dagger.Provides;
import io.reactivex.Scheduler; | package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 7/1/17.
*/
@Module
public class InfrastructureModule {
@Provides static GetRandomFacts infrastructure(
NumbersWebService webService,
TriviaGenerator generator,
PayloadMapper mapper, | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/TriviaGenerator.java
// public class TriviaGenerator {
//
// private static final int LARGER_NUMBER_TO_LEARN_ABOUT = 200;
// private static final int TRIVIA_COUNT = 10;
// private static final Random RANDOMIZER = new Random();
//
// private List<Integer> numbers = new ArrayList<>();
//
// public List<Integer> numberForTrivia() {
//
// numbers.clear();
//
// while (numbers.size() < TRIVIA_COUNT) {
//
// int candidate = RANDOMIZER.nextInt(LARGER_NUMBER_TO_LEARN_ABOUT);
//
// if (!numbers.contains(candidate)) {
// numbers.add(candidate);
// }
// }
//
// return numbers;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadMapper.java
// public class PayloadMapper {
//
// List<FactAboutNumber> toNumberFacts(NumbersTriviaPayload payload) {
//
// return Ix.from(payload.entrySet())
// .map(entry -> FactAboutNumber.of(entry.getKey(), entry.getValue()))
// .cast(FactAboutNumber.class)
// .toList();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadValidator.java
// public class PayloadValidator {
//
// boolean accept(NumbersTriviaPayload payload) {
// return notNullNotEmpty(payload.entrySet());
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/TriviaInfrastructure.java
// public class TriviaInfrastructure implements GetRandomFacts {
//
// private NumbersWebService webService;
// private TriviaGenerator triviaGenerator;
// private PayloadMapper mapper;
// private PayloadValidator validator;
// private Scheduler executionScheduler;
//
// public TriviaInfrastructure(NumbersWebService webService,
// TriviaGenerator triviaGenerator,
// PayloadMapper mapper,
// PayloadValidator validator,
// Scheduler executionScheduler) {
//
// this.webService = webService;
// this.triviaGenerator = triviaGenerator;
// this.mapper = mapper;
// this.validator = validator;
// this.executionScheduler = executionScheduler;
// }
//
// @Override public Flowable<FactAboutNumber> fetchTrivia() {
//
// List<Integer> numbersForTrivia = triviaGenerator.numberForTrivia();
// String formattedUrlPath = formatPathWithCommas(numbersForTrivia);
//
// return webService
// .getTrivia(formattedUrlPath)
// .subscribeOn(executionScheduler)
// .compose(new NetworkingErrorHandler<>())
// .compose(new RestErrorsHandler<>())
// .compose(new DeserializationIssuesHandler<>())
// .filter(payload -> validator.accept(payload))
// .map(payload -> mapper.toNumberFacts(payload))
// .flatMap(Flowable::fromIterable);
// }
//
// private String formatPathWithCommas(List<Integer> numbersForTrivia) {
// return numbersForTrivia
// .toString()
// .replace(" ", "")
// .replace("[", "")
// .replace("]", "");
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/InfrastructureModule.java
import br.ufs.demos.rxmvp.playground.dagger.qualifiers.IOScheduler;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.domain.TriviaGenerator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadMapper;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadValidator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.TriviaInfrastructure;
import dagger.Module;
import dagger.Provides;
import io.reactivex.Scheduler;
package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 7/1/17.
*/
@Module
public class InfrastructureModule {
@Provides static GetRandomFacts infrastructure(
NumbersWebService webService,
TriviaGenerator generator,
PayloadMapper mapper, | PayloadValidator validator, |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/InfrastructureModule.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/TriviaGenerator.java
// public class TriviaGenerator {
//
// private static final int LARGER_NUMBER_TO_LEARN_ABOUT = 200;
// private static final int TRIVIA_COUNT = 10;
// private static final Random RANDOMIZER = new Random();
//
// private List<Integer> numbers = new ArrayList<>();
//
// public List<Integer> numberForTrivia() {
//
// numbers.clear();
//
// while (numbers.size() < TRIVIA_COUNT) {
//
// int candidate = RANDOMIZER.nextInt(LARGER_NUMBER_TO_LEARN_ABOUT);
//
// if (!numbers.contains(candidate)) {
// numbers.add(candidate);
// }
// }
//
// return numbers;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadMapper.java
// public class PayloadMapper {
//
// List<FactAboutNumber> toNumberFacts(NumbersTriviaPayload payload) {
//
// return Ix.from(payload.entrySet())
// .map(entry -> FactAboutNumber.of(entry.getKey(), entry.getValue()))
// .cast(FactAboutNumber.class)
// .toList();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadValidator.java
// public class PayloadValidator {
//
// boolean accept(NumbersTriviaPayload payload) {
// return notNullNotEmpty(payload.entrySet());
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/TriviaInfrastructure.java
// public class TriviaInfrastructure implements GetRandomFacts {
//
// private NumbersWebService webService;
// private TriviaGenerator triviaGenerator;
// private PayloadMapper mapper;
// private PayloadValidator validator;
// private Scheduler executionScheduler;
//
// public TriviaInfrastructure(NumbersWebService webService,
// TriviaGenerator triviaGenerator,
// PayloadMapper mapper,
// PayloadValidator validator,
// Scheduler executionScheduler) {
//
// this.webService = webService;
// this.triviaGenerator = triviaGenerator;
// this.mapper = mapper;
// this.validator = validator;
// this.executionScheduler = executionScheduler;
// }
//
// @Override public Flowable<FactAboutNumber> fetchTrivia() {
//
// List<Integer> numbersForTrivia = triviaGenerator.numberForTrivia();
// String formattedUrlPath = formatPathWithCommas(numbersForTrivia);
//
// return webService
// .getTrivia(formattedUrlPath)
// .subscribeOn(executionScheduler)
// .compose(new NetworkingErrorHandler<>())
// .compose(new RestErrorsHandler<>())
// .compose(new DeserializationIssuesHandler<>())
// .filter(payload -> validator.accept(payload))
// .map(payload -> mapper.toNumberFacts(payload))
// .flatMap(Flowable::fromIterable);
// }
//
// private String formatPathWithCommas(List<Integer> numbersForTrivia) {
// return numbersForTrivia
// .toString()
// .replace(" ", "")
// .replace("[", "")
// .replace("]", "");
// }
//
// }
| import br.ufs.demos.rxmvp.playground.dagger.qualifiers.IOScheduler;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.domain.TriviaGenerator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadMapper;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadValidator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.TriviaInfrastructure;
import dagger.Module;
import dagger.Provides;
import io.reactivex.Scheduler; | package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 7/1/17.
*/
@Module
public class InfrastructureModule {
@Provides static GetRandomFacts infrastructure(
NumbersWebService webService,
TriviaGenerator generator,
PayloadMapper mapper,
PayloadValidator validator,
@IOScheduler Scheduler ioScheduler) {
| // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/TriviaGenerator.java
// public class TriviaGenerator {
//
// private static final int LARGER_NUMBER_TO_LEARN_ABOUT = 200;
// private static final int TRIVIA_COUNT = 10;
// private static final Random RANDOMIZER = new Random();
//
// private List<Integer> numbers = new ArrayList<>();
//
// public List<Integer> numberForTrivia() {
//
// numbers.clear();
//
// while (numbers.size() < TRIVIA_COUNT) {
//
// int candidate = RANDOMIZER.nextInt(LARGER_NUMBER_TO_LEARN_ABOUT);
//
// if (!numbers.contains(candidate)) {
// numbers.add(candidate);
// }
// }
//
// return numbers;
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadMapper.java
// public class PayloadMapper {
//
// List<FactAboutNumber> toNumberFacts(NumbersTriviaPayload payload) {
//
// return Ix.from(payload.entrySet())
// .map(entry -> FactAboutNumber.of(entry.getKey(), entry.getValue()))
// .cast(FactAboutNumber.class)
// .toList();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/PayloadValidator.java
// public class PayloadValidator {
//
// boolean accept(NumbersTriviaPayload payload) {
// return notNullNotEmpty(payload.entrySet());
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/TriviaInfrastructure.java
// public class TriviaInfrastructure implements GetRandomFacts {
//
// private NumbersWebService webService;
// private TriviaGenerator triviaGenerator;
// private PayloadMapper mapper;
// private PayloadValidator validator;
// private Scheduler executionScheduler;
//
// public TriviaInfrastructure(NumbersWebService webService,
// TriviaGenerator triviaGenerator,
// PayloadMapper mapper,
// PayloadValidator validator,
// Scheduler executionScheduler) {
//
// this.webService = webService;
// this.triviaGenerator = triviaGenerator;
// this.mapper = mapper;
// this.validator = validator;
// this.executionScheduler = executionScheduler;
// }
//
// @Override public Flowable<FactAboutNumber> fetchTrivia() {
//
// List<Integer> numbersForTrivia = triviaGenerator.numberForTrivia();
// String formattedUrlPath = formatPathWithCommas(numbersForTrivia);
//
// return webService
// .getTrivia(formattedUrlPath)
// .subscribeOn(executionScheduler)
// .compose(new NetworkingErrorHandler<>())
// .compose(new RestErrorsHandler<>())
// .compose(new DeserializationIssuesHandler<>())
// .filter(payload -> validator.accept(payload))
// .map(payload -> mapper.toNumberFacts(payload))
// .flatMap(Flowable::fromIterable);
// }
//
// private String formatPathWithCommas(List<Integer> numbersForTrivia) {
// return numbersForTrivia
// .toString()
// .replace(" ", "")
// .replace("[", "")
// .replace("]", "");
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/InfrastructureModule.java
import br.ufs.demos.rxmvp.playground.dagger.qualifiers.IOScheduler;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.domain.TriviaGenerator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadMapper;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.PayloadValidator;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.TriviaInfrastructure;
import dagger.Module;
import dagger.Provides;
import io.reactivex.Scheduler;
package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 7/1/17.
*/
@Module
public class InfrastructureModule {
@Provides static GetRandomFacts infrastructure(
NumbersWebService webService,
TriviaGenerator generator,
PayloadMapper mapper,
PayloadValidator validator,
@IOScheduler Scheduler ioScheduler) {
| return new TriviaInfrastructure(webService, generator, mapper, validator, ioScheduler); |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/components/AppComponent.java | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/ActivitiesBuilder.java
// @Module
// public abstract class ActivitiesBuilder {
//
// @ContributesAndroidInjector(modules = FactsAboutNumbersModule.class)
// abstract FactsAboutNumbersActivity factsAboutNumbersActivity();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/AppModule.java
// @Module
// public class AppModule {
//
// @Provides @Singleton static Context provideContext(Application application) {
// return application;
// }
//
// @Provides @Singleton @UIScheduler static Scheduler uiScheduler() {
// return AndroidSchedulers.mainThread();
// }
//
// @Provides @Singleton @IOScheduler static Scheduler ioScheduler() {
// return Schedulers.io();
// }
//
// }
//
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/dagger/modules/RestWebServiceModule.java
// @Module
// public class RestWebServiceModule {
//
// @Provides @Singleton static NumbersWebService webService() {
// return new FakeWebService();
// }
//
// }
| import android.app.Application;
import javax.inject.Singleton;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.dagger.modules.ActivitiesBuilder;
import br.ufs.demos.rxmvp.playground.dagger.modules.AppModule;
import br.ufs.demos.rxmvp.playground.dagger.modules.RestWebServiceModule;
import dagger.BindsInstance;
import dagger.Component;
import dagger.android.AndroidInjectionModule; | package br.ufs.demos.rxmvp.playground.dagger.components;
/**
* Created by bira on 6/26/17.
*/
@Singleton
@Component(
modules = {
AndroidInjectionModule.class, | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/ActivitiesBuilder.java
// @Module
// public abstract class ActivitiesBuilder {
//
// @ContributesAndroidInjector(modules = FactsAboutNumbersModule.class)
// abstract FactsAboutNumbersActivity factsAboutNumbersActivity();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/AppModule.java
// @Module
// public class AppModule {
//
// @Provides @Singleton static Context provideContext(Application application) {
// return application;
// }
//
// @Provides @Singleton @UIScheduler static Scheduler uiScheduler() {
// return AndroidSchedulers.mainThread();
// }
//
// @Provides @Singleton @IOScheduler static Scheduler ioScheduler() {
// return Schedulers.io();
// }
//
// }
//
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/dagger/modules/RestWebServiceModule.java
// @Module
// public class RestWebServiceModule {
//
// @Provides @Singleton static NumbersWebService webService() {
// return new FakeWebService();
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/components/AppComponent.java
import android.app.Application;
import javax.inject.Singleton;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.dagger.modules.ActivitiesBuilder;
import br.ufs.demos.rxmvp.playground.dagger.modules.AppModule;
import br.ufs.demos.rxmvp.playground.dagger.modules.RestWebServiceModule;
import dagger.BindsInstance;
import dagger.Component;
import dagger.android.AndroidInjectionModule;
package br.ufs.demos.rxmvp.playground.dagger.components;
/**
* Created by bira on 6/26/17.
*/
@Singleton
@Component(
modules = {
AndroidInjectionModule.class, | AppModule.class, |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/components/AppComponent.java | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/ActivitiesBuilder.java
// @Module
// public abstract class ActivitiesBuilder {
//
// @ContributesAndroidInjector(modules = FactsAboutNumbersModule.class)
// abstract FactsAboutNumbersActivity factsAboutNumbersActivity();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/AppModule.java
// @Module
// public class AppModule {
//
// @Provides @Singleton static Context provideContext(Application application) {
// return application;
// }
//
// @Provides @Singleton @UIScheduler static Scheduler uiScheduler() {
// return AndroidSchedulers.mainThread();
// }
//
// @Provides @Singleton @IOScheduler static Scheduler ioScheduler() {
// return Schedulers.io();
// }
//
// }
//
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/dagger/modules/RestWebServiceModule.java
// @Module
// public class RestWebServiceModule {
//
// @Provides @Singleton static NumbersWebService webService() {
// return new FakeWebService();
// }
//
// }
| import android.app.Application;
import javax.inject.Singleton;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.dagger.modules.ActivitiesBuilder;
import br.ufs.demos.rxmvp.playground.dagger.modules.AppModule;
import br.ufs.demos.rxmvp.playground.dagger.modules.RestWebServiceModule;
import dagger.BindsInstance;
import dagger.Component;
import dagger.android.AndroidInjectionModule; | package br.ufs.demos.rxmvp.playground.dagger.components;
/**
* Created by bira on 6/26/17.
*/
@Singleton
@Component(
modules = {
AndroidInjectionModule.class,
AppModule.class, | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/ActivitiesBuilder.java
// @Module
// public abstract class ActivitiesBuilder {
//
// @ContributesAndroidInjector(modules = FactsAboutNumbersModule.class)
// abstract FactsAboutNumbersActivity factsAboutNumbersActivity();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/AppModule.java
// @Module
// public class AppModule {
//
// @Provides @Singleton static Context provideContext(Application application) {
// return application;
// }
//
// @Provides @Singleton @UIScheduler static Scheduler uiScheduler() {
// return AndroidSchedulers.mainThread();
// }
//
// @Provides @Singleton @IOScheduler static Scheduler ioScheduler() {
// return Schedulers.io();
// }
//
// }
//
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/dagger/modules/RestWebServiceModule.java
// @Module
// public class RestWebServiceModule {
//
// @Provides @Singleton static NumbersWebService webService() {
// return new FakeWebService();
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/components/AppComponent.java
import android.app.Application;
import javax.inject.Singleton;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.dagger.modules.ActivitiesBuilder;
import br.ufs.demos.rxmvp.playground.dagger.modules.AppModule;
import br.ufs.demos.rxmvp.playground.dagger.modules.RestWebServiceModule;
import dagger.BindsInstance;
import dagger.Component;
import dagger.android.AndroidInjectionModule;
package br.ufs.demos.rxmvp.playground.dagger.components;
/**
* Created by bira on 6/26/17.
*/
@Singleton
@Component(
modules = {
AndroidInjectionModule.class,
AppModule.class, | RestWebServiceModule.class, |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/components/AppComponent.java | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/ActivitiesBuilder.java
// @Module
// public abstract class ActivitiesBuilder {
//
// @ContributesAndroidInjector(modules = FactsAboutNumbersModule.class)
// abstract FactsAboutNumbersActivity factsAboutNumbersActivity();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/AppModule.java
// @Module
// public class AppModule {
//
// @Provides @Singleton static Context provideContext(Application application) {
// return application;
// }
//
// @Provides @Singleton @UIScheduler static Scheduler uiScheduler() {
// return AndroidSchedulers.mainThread();
// }
//
// @Provides @Singleton @IOScheduler static Scheduler ioScheduler() {
// return Schedulers.io();
// }
//
// }
//
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/dagger/modules/RestWebServiceModule.java
// @Module
// public class RestWebServiceModule {
//
// @Provides @Singleton static NumbersWebService webService() {
// return new FakeWebService();
// }
//
// }
| import android.app.Application;
import javax.inject.Singleton;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.dagger.modules.ActivitiesBuilder;
import br.ufs.demos.rxmvp.playground.dagger.modules.AppModule;
import br.ufs.demos.rxmvp.playground.dagger.modules.RestWebServiceModule;
import dagger.BindsInstance;
import dagger.Component;
import dagger.android.AndroidInjectionModule; | package br.ufs.demos.rxmvp.playground.dagger.components;
/**
* Created by bira on 6/26/17.
*/
@Singleton
@Component(
modules = {
AndroidInjectionModule.class,
AppModule.class,
RestWebServiceModule.class, | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/ActivitiesBuilder.java
// @Module
// public abstract class ActivitiesBuilder {
//
// @ContributesAndroidInjector(modules = FactsAboutNumbersModule.class)
// abstract FactsAboutNumbersActivity factsAboutNumbersActivity();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/AppModule.java
// @Module
// public class AppModule {
//
// @Provides @Singleton static Context provideContext(Application application) {
// return application;
// }
//
// @Provides @Singleton @UIScheduler static Scheduler uiScheduler() {
// return AndroidSchedulers.mainThread();
// }
//
// @Provides @Singleton @IOScheduler static Scheduler ioScheduler() {
// return Schedulers.io();
// }
//
// }
//
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/dagger/modules/RestWebServiceModule.java
// @Module
// public class RestWebServiceModule {
//
// @Provides @Singleton static NumbersWebService webService() {
// return new FakeWebService();
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/components/AppComponent.java
import android.app.Application;
import javax.inject.Singleton;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.dagger.modules.ActivitiesBuilder;
import br.ufs.demos.rxmvp.playground.dagger.modules.AppModule;
import br.ufs.demos.rxmvp.playground.dagger.modules.RestWebServiceModule;
import dagger.BindsInstance;
import dagger.Component;
import dagger.android.AndroidInjectionModule;
package br.ufs.demos.rxmvp.playground.dagger.components;
/**
* Created by bira on 6/26/17.
*/
@Singleton
@Component(
modules = {
AndroidInjectionModule.class,
AppModule.class,
RestWebServiceModule.class, | ActivitiesBuilder.class |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/components/AppComponent.java | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/ActivitiesBuilder.java
// @Module
// public abstract class ActivitiesBuilder {
//
// @ContributesAndroidInjector(modules = FactsAboutNumbersModule.class)
// abstract FactsAboutNumbersActivity factsAboutNumbersActivity();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/AppModule.java
// @Module
// public class AppModule {
//
// @Provides @Singleton static Context provideContext(Application application) {
// return application;
// }
//
// @Provides @Singleton @UIScheduler static Scheduler uiScheduler() {
// return AndroidSchedulers.mainThread();
// }
//
// @Provides @Singleton @IOScheduler static Scheduler ioScheduler() {
// return Schedulers.io();
// }
//
// }
//
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/dagger/modules/RestWebServiceModule.java
// @Module
// public class RestWebServiceModule {
//
// @Provides @Singleton static NumbersWebService webService() {
// return new FakeWebService();
// }
//
// }
| import android.app.Application;
import javax.inject.Singleton;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.dagger.modules.ActivitiesBuilder;
import br.ufs.demos.rxmvp.playground.dagger.modules.AppModule;
import br.ufs.demos.rxmvp.playground.dagger.modules.RestWebServiceModule;
import dagger.BindsInstance;
import dagger.Component;
import dagger.android.AndroidInjectionModule; | package br.ufs.demos.rxmvp.playground.dagger.components;
/**
* Created by bira on 6/26/17.
*/
@Singleton
@Component(
modules = {
AndroidInjectionModule.class,
AppModule.class,
RestWebServiceModule.class,
ActivitiesBuilder.class
}
)
public interface AppComponent {
@Component.Builder
interface Builder {
@BindsInstance Builder application(Application application);
AppComponent build();
}
| // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/app/MainApplication.java
// public class MainApplication extends Application implements HasActivityInjector {
//
// @Inject DispatchingAndroidInjector<Activity> injector;
// @Inject public NumbersWebService webservice;
//
// @Override public void onCreate() {
// super.onCreate();
// buildTopLevelDependenciesGraph();
// setupMock();
// }
//
// @Override public DispatchingAndroidInjector<Activity> activityInjector() {
// return injector;
// }
//
// protected void buildTopLevelDependenciesGraph() {
// DaggerAppComponent.builder().application(this).build().inject(this);
// }
//
// private void setupMock() {
// FakeWebService service = (FakeWebService) webservice;
// service.nextCallPerform(NextCall.SUCCESS_200);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/ActivitiesBuilder.java
// @Module
// public abstract class ActivitiesBuilder {
//
// @ContributesAndroidInjector(modules = FactsAboutNumbersModule.class)
// abstract FactsAboutNumbersActivity factsAboutNumbersActivity();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/AppModule.java
// @Module
// public class AppModule {
//
// @Provides @Singleton static Context provideContext(Application application) {
// return application;
// }
//
// @Provides @Singleton @UIScheduler static Scheduler uiScheduler() {
// return AndroidSchedulers.mainThread();
// }
//
// @Provides @Singleton @IOScheduler static Scheduler ioScheduler() {
// return Schedulers.io();
// }
//
// }
//
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/dagger/modules/RestWebServiceModule.java
// @Module
// public class RestWebServiceModule {
//
// @Provides @Singleton static NumbersWebService webService() {
// return new FakeWebService();
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/components/AppComponent.java
import android.app.Application;
import javax.inject.Singleton;
import br.ufs.demos.rxmvp.playground.app.MainApplication;
import br.ufs.demos.rxmvp.playground.dagger.modules.ActivitiesBuilder;
import br.ufs.demos.rxmvp.playground.dagger.modules.AppModule;
import br.ufs.demos.rxmvp.playground.dagger.modules.RestWebServiceModule;
import dagger.BindsInstance;
import dagger.Component;
import dagger.android.AndroidInjectionModule;
package br.ufs.demos.rxmvp.playground.dagger.components;
/**
* Created by bira on 6/26/17.
*/
@Singleton
@Component(
modules = {
AndroidInjectionModule.class,
AppModule.class,
RestWebServiceModule.class,
ActivitiesBuilder.class
}
)
public interface AppComponent {
@Component.Builder
interface Builder {
@BindsInstance Builder application(Application application);
AppComponent build();
}
| void inject(MainApplication target); |
ubiratansoares/reactive-architectures-playground | app/src/androidTestMock/java/br/ufs/demos/rxmvp/playground/TriviaAcceptanceTests.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/ui/FactsAboutNumbersActivity.java
// public class FactsAboutNumbersActivity
// extends AppCompatActivity implements DisplayFactsView {
//
// private static final String TAG = FactsAboutNumbersActivity.class.getSimpleName();
//
// @BindView(R.id.recyclerview_facts) public RecyclerView factsView;
// @BindView(R.id.container) View container;
// @BindView(R.id.label_feedback_message) TextView feedbackMessage;
// @BindView(R.id.progressBar) ProgressBar loading;
// @BindView(R.id.fab) FloatingActionButton fab;
//
// @Inject FactsPresenter presenter;
//
// public FactsAdapter adapter;
//
// @Override protected void onCreate(Bundle savedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
// ButterKnife.bind(this);
// setupViews();
// }
//
// @Override protected void onResume() {
// super.onResume();
// newTrivia();
// }
//
// @Override public Action showLoading() {
// return () -> loading.setVisibility(View.VISIBLE);
// }
//
// @Override public Action hideLoading() {
// return () -> loading.setVisibility(View.GONE);
// }
//
// @Override public Action showEmptyState() {
// return () -> {
// feedbackMessage.setVisibility(View.VISIBLE);
// feedbackMessage.setText(R.string.feedback_empty_state);
// };
// }
//
// @Override public Action hideEmptyState() {
// return () -> feedbackMessage.setVisibility(View.GONE);
// }
//
// @Override public Action showErrorState() {
// return () -> {
// feedbackMessage.setVisibility(View.VISIBLE);
// feedbackMessage.setText(R.string.feedback_error_state);
// };
// }
//
// @Override public Action hideErrorState() {
// return () -> feedbackMessage.setVisibility(View.GONE);
// }
//
// @Override public Action reportNetworkingError() {
// return () ->
// Snackbar.make(container, R.string.feedback_message_internet_issue, LENGTH_INDEFINITE)
// .setAction("TENTAR NOVAMENTE", view -> newTrivia())
// .show();
// }
//
// @Override public Action disableRefresh() {
// return () -> fab.setVisibility(View.GONE);
// }
//
// @Override public Action enableRefresh() {
// return () -> fab.setVisibility(View.VISIBLE);
// }
//
// @Override public Disposable subscribeInto(Flowable<FactViewModel> flow) {
// adapter.clear();
// return flow
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(
// model -> adapter.addModel(model),
// throwable -> Log.e(TAG, "Error -> " + throwable.getMessage()),
// () -> Log.i(TAG, "Done")
// );
// }
//
// private void setupViews() {
// fab.setOnClickListener(view -> newTrivia());
// adapter = new FactsAdapter(LayoutInflater.from(this));
// factsView.setLayoutManager(new LinearLayoutManager(this));
// factsView.setAdapter(adapter);
// }
//
// private void newTrivia() {
// if (presenter != null) presenter.fetchRandomFacts();
// }
//
// }
| import android.support.test.runner.AndroidJUnit4;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import br.ufs.demos.rxmvp.playground.trivia.ui.FactsAboutNumbersActivity;
import static br.ufs.demos.rxmvp.playground.fakes.FakeWebService.NextCall.CONNECTION_ERROR;
import static br.ufs.demos.rxmvp.playground.fakes.FakeWebService.NextCall.INTERNAL_SERVER_ERROR_5xy;
import static br.ufs.demos.rxmvp.playground.fakes.FakeWebService.NextCall.NOT_FOUND_404;
import static br.ufs.demos.rxmvp.playground.fakes.FakeWebService.NextCall.SUCCESS_200; | package br.ufs.demos.rxmvp.playground;
/**
* Created by bira on 10/3/17.
*/
@RunWith(AndroidJUnit4.class)
public class TriviaAcceptanceTests {
Verifier verifier;
| // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/ui/FactsAboutNumbersActivity.java
// public class FactsAboutNumbersActivity
// extends AppCompatActivity implements DisplayFactsView {
//
// private static final String TAG = FactsAboutNumbersActivity.class.getSimpleName();
//
// @BindView(R.id.recyclerview_facts) public RecyclerView factsView;
// @BindView(R.id.container) View container;
// @BindView(R.id.label_feedback_message) TextView feedbackMessage;
// @BindView(R.id.progressBar) ProgressBar loading;
// @BindView(R.id.fab) FloatingActionButton fab;
//
// @Inject FactsPresenter presenter;
//
// public FactsAdapter adapter;
//
// @Override protected void onCreate(Bundle savedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
// ButterKnife.bind(this);
// setupViews();
// }
//
// @Override protected void onResume() {
// super.onResume();
// newTrivia();
// }
//
// @Override public Action showLoading() {
// return () -> loading.setVisibility(View.VISIBLE);
// }
//
// @Override public Action hideLoading() {
// return () -> loading.setVisibility(View.GONE);
// }
//
// @Override public Action showEmptyState() {
// return () -> {
// feedbackMessage.setVisibility(View.VISIBLE);
// feedbackMessage.setText(R.string.feedback_empty_state);
// };
// }
//
// @Override public Action hideEmptyState() {
// return () -> feedbackMessage.setVisibility(View.GONE);
// }
//
// @Override public Action showErrorState() {
// return () -> {
// feedbackMessage.setVisibility(View.VISIBLE);
// feedbackMessage.setText(R.string.feedback_error_state);
// };
// }
//
// @Override public Action hideErrorState() {
// return () -> feedbackMessage.setVisibility(View.GONE);
// }
//
// @Override public Action reportNetworkingError() {
// return () ->
// Snackbar.make(container, R.string.feedback_message_internet_issue, LENGTH_INDEFINITE)
// .setAction("TENTAR NOVAMENTE", view -> newTrivia())
// .show();
// }
//
// @Override public Action disableRefresh() {
// return () -> fab.setVisibility(View.GONE);
// }
//
// @Override public Action enableRefresh() {
// return () -> fab.setVisibility(View.VISIBLE);
// }
//
// @Override public Disposable subscribeInto(Flowable<FactViewModel> flow) {
// adapter.clear();
// return flow
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(
// model -> adapter.addModel(model),
// throwable -> Log.e(TAG, "Error -> " + throwable.getMessage()),
// () -> Log.i(TAG, "Done")
// );
// }
//
// private void setupViews() {
// fab.setOnClickListener(view -> newTrivia());
// adapter = new FactsAdapter(LayoutInflater.from(this));
// factsView.setLayoutManager(new LinearLayoutManager(this));
// factsView.setAdapter(adapter);
// }
//
// private void newTrivia() {
// if (presenter != null) presenter.fetchRandomFacts();
// }
//
// }
// Path: app/src/androidTestMock/java/br/ufs/demos/rxmvp/playground/TriviaAcceptanceTests.java
import android.support.test.runner.AndroidJUnit4;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import br.ufs.demos.rxmvp.playground.trivia.ui.FactsAboutNumbersActivity;
import static br.ufs.demos.rxmvp.playground.fakes.FakeWebService.NextCall.CONNECTION_ERROR;
import static br.ufs.demos.rxmvp.playground.fakes.FakeWebService.NextCall.INTERNAL_SERVER_ERROR_5xy;
import static br.ufs.demos.rxmvp.playground.fakes.FakeWebService.NextCall.NOT_FOUND_404;
import static br.ufs.demos.rxmvp.playground.fakes.FakeWebService.NextCall.SUCCESS_200;
package br.ufs.demos.rxmvp.playground;
/**
* Created by bira on 10/3/17.
*/
@RunWith(AndroidJUnit4.class)
public class TriviaAcceptanceTests {
Verifier verifier;
| @Rule public ScriptableWebServerTestRule<FactsAboutNumbersActivity> launcher = |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/LoadingCoordinationTests.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingCoordination.java
// public class LoadingCoordination<T> implements FlowableTransformer<T, T> {
//
// private LoadingView view;
// private Scheduler uiScheduler;
//
// public LoadingCoordination(LoadingView view,
// Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// ShowAtStartHideWhenDone<T> delegate = new ShowAtStartHideWhenDone<>(
// view.showLoading(),
// view.hideLoading(),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingCoordination;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly; | package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 6/30/17.
*/
public class LoadingCoordinationTests {
Scheduler uiScheduler = Schedulers.trampoline(); | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingCoordination.java
// public class LoadingCoordination<T> implements FlowableTransformer<T, T> {
//
// private LoadingView view;
// private Scheduler uiScheduler;
//
// public LoadingCoordination(LoadingView view,
// Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// ShowAtStartHideWhenDone<T> delegate = new ShowAtStartHideWhenDone<>(
// view.showLoading(),
// view.hideLoading(),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/LoadingCoordinationTests.java
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingCoordination;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 6/30/17.
*/
public class LoadingCoordinationTests {
Scheduler uiScheduler = Schedulers.trampoline(); | LoadingCoordination<String> loadingCoordination; |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/LoadingCoordinationTests.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingCoordination.java
// public class LoadingCoordination<T> implements FlowableTransformer<T, T> {
//
// private LoadingView view;
// private Scheduler uiScheduler;
//
// public LoadingCoordination(LoadingView view,
// Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// ShowAtStartHideWhenDone<T> delegate = new ShowAtStartHideWhenDone<>(
// view.showLoading(),
// view.hideLoading(),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingCoordination;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly; | package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 6/30/17.
*/
public class LoadingCoordinationTests {
Scheduler uiScheduler = Schedulers.trampoline();
LoadingCoordination<String> loadingCoordination;
@Mock Action showAction;
@Mock Action hideAction;
@Before public void beforeEachTest() {
MockitoAnnotations.initMocks(this);
| // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingCoordination.java
// public class LoadingCoordination<T> implements FlowableTransformer<T, T> {
//
// private LoadingView view;
// private Scheduler uiScheduler;
//
// public LoadingCoordination(LoadingView view,
// Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// ShowAtStartHideWhenDone<T> delegate = new ShowAtStartHideWhenDone<>(
// view.showLoading(),
// view.hideLoading(),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/LoadingCoordinationTests.java
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingCoordination;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 6/30/17.
*/
public class LoadingCoordinationTests {
Scheduler uiScheduler = Schedulers.trampoline();
LoadingCoordination<String> loadingCoordination;
@Mock Action showAction;
@Mock Action hideAction;
@Before public void beforeEachTest() {
MockitoAnnotations.initMocks(this);
| LoadingView view = new LoadingView() { |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/LoadingCoordinationTests.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingCoordination.java
// public class LoadingCoordination<T> implements FlowableTransformer<T, T> {
//
// private LoadingView view;
// private Scheduler uiScheduler;
//
// public LoadingCoordination(LoadingView view,
// Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// ShowAtStartHideWhenDone<T> delegate = new ShowAtStartHideWhenDone<>(
// view.showLoading(),
// view.hideLoading(),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingCoordination;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly; | Flowable.just("A", "B", "C")
.compose(loadingCoordination)
.subscribe();
checkLoadingCoordinated();
}
@Test public void shouldCoordinateLoading_WithEmptyFlow() throws Exception {
Flowable<String> empty = Flowable.empty();
empty.compose(loadingCoordination).subscribe();
checkLoadingCoordinated();
}
@Test public void shouldCoordinateLoading_WithErrorAtFlow() throws Exception {
Flowable<String> broken = Flowable.error(new RuntimeException("WTF!!"));
broken.compose(loadingCoordination)
.subscribe(
some -> {},
Throwable::printStackTrace,
() -> {}
);
checkLoadingCoordinated();
}
private void checkLoadingCoordinated() throws Exception {
InOrder inOrder = Mockito.inOrder(showAction, hideAction); | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingCoordination.java
// public class LoadingCoordination<T> implements FlowableTransformer<T, T> {
//
// private LoadingView view;
// private Scheduler uiScheduler;
//
// public LoadingCoordination(LoadingView view,
// Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// ShowAtStartHideWhenDone<T> delegate = new ShowAtStartHideWhenDone<>(
// view.showLoading(),
// view.hideLoading(),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/LoadingCoordinationTests.java
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingCoordination;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
Flowable.just("A", "B", "C")
.compose(loadingCoordination)
.subscribe();
checkLoadingCoordinated();
}
@Test public void shouldCoordinateLoading_WithEmptyFlow() throws Exception {
Flowable<String> empty = Flowable.empty();
empty.compose(loadingCoordination).subscribe();
checkLoadingCoordinated();
}
@Test public void shouldCoordinateLoading_WithErrorAtFlow() throws Exception {
Flowable<String> broken = Flowable.error(new RuntimeException("WTF!!"));
broken.compose(loadingCoordination)
.subscribe(
some -> {},
Throwable::printStackTrace,
() -> {}
);
checkLoadingCoordinated();
}
private void checkLoadingCoordinated() throws Exception {
InOrder inOrder = Mockito.inOrder(showAction, hideAction); | inOrder.verify(showAction, oneTimeOnly()).run(); |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/DisplayFactsView.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
| import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable; | package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public interface DisplayFactsView extends
LoadingView, | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/DisplayFactsView.java
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public interface DisplayFactsView extends
LoadingView, | ErrorStateView, |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/DisplayFactsView.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
| import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable; | package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public interface DisplayFactsView extends
LoadingView,
ErrorStateView, | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/DisplayFactsView.java
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public interface DisplayFactsView extends
LoadingView,
ErrorStateView, | EmptyStateView, |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/DisplayFactsView.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
| import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable; | package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public interface DisplayFactsView extends
LoadingView,
ErrorStateView,
EmptyStateView, | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/DisplayFactsView.java
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public interface DisplayFactsView extends
LoadingView,
ErrorStateView,
EmptyStateView, | NetworkingErrorView, |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/DisplayFactsView.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
| import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable; | package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public interface DisplayFactsView extends
LoadingView,
ErrorStateView,
EmptyStateView,
NetworkingErrorView, | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/DisplayFactsView.java
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public interface DisplayFactsView extends
LoadingView,
ErrorStateView,
EmptyStateView,
NetworkingErrorView, | ToogleRefreshView { |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/DisplayFactsView.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
| import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable; | package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public interface DisplayFactsView extends
LoadingView,
ErrorStateView,
EmptyStateView,
NetworkingErrorView,
ToogleRefreshView {
| // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/EmptyStateView.java
// public interface EmptyStateView {
//
// Action showEmptyState();
//
// Action hideEmptyState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
//
// Action showErrorState();
//
// Action hideErrorState();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingView.java
// public interface LoadingView {
//
// Action showLoading();
//
// Action hideLoading();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorView.java
// public interface NetworkingErrorView {
//
// Action reportNetworkingError();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/DisplayFactsView.java
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.EmptyStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingView;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorView;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public interface DisplayFactsView extends
LoadingView,
ErrorStateView,
EmptyStateView,
NetworkingErrorView,
ToogleRefreshView {
| Disposable subscribeInto(Flowable<FactViewModel> flow); |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/NumbersTriviaPayload.java
// public class NumbersTriviaPayload extends HashMap<String, String> {
//
// // Shame on me by my lazyness ....
//
// }
| import br.ufs.demos.rxmvp.playground.trivia.infrastructure.NumbersTriviaPayload;
import io.reactivex.Flowable;
import retrofit2.http.GET;
import retrofit2.http.Path; | package br.ufs.demos.rxmvp.playground.webservice;
/**
* Created by bira on 6/26/17.
*/
public interface NumbersWebService {
String BASE_URL = "http://numbersapi.com";
| // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/NumbersTriviaPayload.java
// public class NumbersTriviaPayload extends HashMap<String, String> {
//
// // Shame on me by my lazyness ....
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.NumbersTriviaPayload;
import io.reactivex.Flowable;
import retrofit2.http.GET;
import retrofit2.http.Path;
package br.ufs.demos.rxmvp.playground.webservice;
/**
* Created by bira on 6/26/17.
*/
public interface NumbersWebService {
String BASE_URL = "http://numbersapi.com";
| @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia( |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/util/DataFlowWatcher.java | // Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; | package br.ufs.demos.rxmvp.playground.util;
/**
* Created by bira on 6/30/17.
*/
public class DataFlowWatcher {
private Consumer<?> onNext;
private Consumer<Throwable> onError;
private Action onCompleted;
private DataFlowWatcher(Consumer<?> onNext,
Consumer<Throwable> onError,
Action onCompleted) {
this.onNext = onNext;
this.onError = onError;
this.onCompleted = onCompleted;
}
public static DataFlowWatcher with(Consumer<?> onNext,
Consumer<Throwable> onError,
Action onCompleted) {
return new DataFlowWatcher(onNext, onError, onCompleted);
}
public void shouldReceiveItems(int quantity) throws Exception {
if (quantity == 0) {
throw new IllegalArgumentException("Should receive at least one item");
}
verify(onNext, atMost(quantity)).accept(any());
verify(onCompleted).run();
verifyZeroInteractions(onError);
}
public void shouldFinishWithError() throws Exception { | // Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/DataFlowWatcher.java
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
package br.ufs.demos.rxmvp.playground.util;
/**
* Created by bira on 6/30/17.
*/
public class DataFlowWatcher {
private Consumer<?> onNext;
private Consumer<Throwable> onError;
private Action onCompleted;
private DataFlowWatcher(Consumer<?> onNext,
Consumer<Throwable> onError,
Action onCompleted) {
this.onNext = onNext;
this.onError = onError;
this.onCompleted = onCompleted;
}
public static DataFlowWatcher with(Consumer<?> onNext,
Consumer<Throwable> onError,
Action onCompleted) {
return new DataFlowWatcher(onNext, onError, onCompleted);
}
public void shouldReceiveItems(int quantity) throws Exception {
if (quantity == 0) {
throw new IllegalArgumentException("Should receive at least one item");
}
verify(onNext, atMost(quantity)).accept(any());
verify(onCompleted).run();
verifyZeroInteractions(onError);
}
public void shouldFinishWithError() throws Exception { | verify(onError, oneTimeOnly()).accept(any()); |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/DisposeStrategyTests.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/DisposeStrategy.java
// public class DisposeStrategy implements LifecycleObserver {
//
// private CompositeDisposable composite = new CompositeDisposable();
//
// public void addDisposable(Disposable toDispose) {
// composite.add(toDispose);
// }
//
// @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroy() {
// composite.dispose();
// }
//
// }
| import org.junit.Test;
import br.ufs.demos.rxmvp.playground.core.lifecycles.DisposeStrategy;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
import static org.assertj.core.api.Assertions.assertThat; | package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 10/5/17.
*/
public class DisposeStrategyTests {
@Test public void shouldDispose_OnDestroy() { | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/DisposeStrategy.java
// public class DisposeStrategy implements LifecycleObserver {
//
// private CompositeDisposable composite = new CompositeDisposable();
//
// public void addDisposable(Disposable toDispose) {
// composite.add(toDispose);
// }
//
// @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroy() {
// composite.dispose();
// }
//
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/DisposeStrategyTests.java
import org.junit.Test;
import br.ufs.demos.rxmvp.playground.core.lifecycles.DisposeStrategy;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
import static org.assertj.core.api.Assertions.assertThat;
package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 10/5/17.
*/
public class DisposeStrategyTests {
@Test public void shouldDispose_OnDestroy() { | DisposeStrategy strategy = new DisposeStrategy(); |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/ToogleRefreshTests.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/RefreshToogle.java
// public class RefreshToogle<T> implements FlowableTransformer<T, T> {
//
// private final ToogleRefreshView view;
// private Scheduler targetScheduler;
//
// public RefreshToogle(ToogleRefreshView view, Scheduler targetScheduler) {
// this.view = view;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> fireAction(view.disableRefresh()))
// .doOnError(this::enableForSpecialErrorCase)
// .doOnComplete(() -> fireAction(view.enableRefresh()));
// }
//
// private void enableForSpecialErrorCase(Throwable throwable) {
// if (!(throwable instanceof UnexpectedResponseError)) fireAction(view.enableRefresh());
// }
//
// private void fireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.RefreshToogle;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never; | package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/8/17.
*/
public class ToogleRefreshTests {
Scheduler uiScheduler = Schedulers.trampoline(); | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/RefreshToogle.java
// public class RefreshToogle<T> implements FlowableTransformer<T, T> {
//
// private final ToogleRefreshView view;
// private Scheduler targetScheduler;
//
// public RefreshToogle(ToogleRefreshView view, Scheduler targetScheduler) {
// this.view = view;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> fireAction(view.disableRefresh()))
// .doOnError(this::enableForSpecialErrorCase)
// .doOnComplete(() -> fireAction(view.enableRefresh()));
// }
//
// private void enableForSpecialErrorCase(Throwable throwable) {
// if (!(throwable instanceof UnexpectedResponseError)) fireAction(view.enableRefresh());
// }
//
// private void fireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/ToogleRefreshTests.java
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.RefreshToogle;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/8/17.
*/
public class ToogleRefreshTests {
Scheduler uiScheduler = Schedulers.trampoline(); | RefreshToogle<Integer> toogler; |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/ToogleRefreshTests.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/RefreshToogle.java
// public class RefreshToogle<T> implements FlowableTransformer<T, T> {
//
// private final ToogleRefreshView view;
// private Scheduler targetScheduler;
//
// public RefreshToogle(ToogleRefreshView view, Scheduler targetScheduler) {
// this.view = view;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> fireAction(view.disableRefresh()))
// .doOnError(this::enableForSpecialErrorCase)
// .doOnComplete(() -> fireAction(view.enableRefresh()));
// }
//
// private void enableForSpecialErrorCase(Throwable throwable) {
// if (!(throwable instanceof UnexpectedResponseError)) fireAction(view.enableRefresh());
// }
//
// private void fireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.RefreshToogle;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never; | package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/8/17.
*/
public class ToogleRefreshTests {
Scheduler uiScheduler = Schedulers.trampoline();
RefreshToogle<Integer> toogler;
@Mock Action enableRefresh;
@Mock Action disableRefresh;
@Before public void beforeEachTest() {
MockitoAnnotations.initMocks(this);
| // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/RefreshToogle.java
// public class RefreshToogle<T> implements FlowableTransformer<T, T> {
//
// private final ToogleRefreshView view;
// private Scheduler targetScheduler;
//
// public RefreshToogle(ToogleRefreshView view, Scheduler targetScheduler) {
// this.view = view;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> fireAction(view.disableRefresh()))
// .doOnError(this::enableForSpecialErrorCase)
// .doOnComplete(() -> fireAction(view.enableRefresh()));
// }
//
// private void enableForSpecialErrorCase(Throwable throwable) {
// if (!(throwable instanceof UnexpectedResponseError)) fireAction(view.enableRefresh());
// }
//
// private void fireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/ToogleRefreshTests.java
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.RefreshToogle;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
package br.ufs.demos.rxmvp.playground.core;
/**
* Created by bira on 7/8/17.
*/
public class ToogleRefreshTests {
Scheduler uiScheduler = Schedulers.trampoline();
RefreshToogle<Integer> toogler;
@Mock Action enableRefresh;
@Mock Action disableRefresh;
@Before public void beforeEachTest() {
MockitoAnnotations.initMocks(this);
| ToogleRefreshView view = new ToogleRefreshView() { |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/ToogleRefreshTests.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/RefreshToogle.java
// public class RefreshToogle<T> implements FlowableTransformer<T, T> {
//
// private final ToogleRefreshView view;
// private Scheduler targetScheduler;
//
// public RefreshToogle(ToogleRefreshView view, Scheduler targetScheduler) {
// this.view = view;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> fireAction(view.disableRefresh()))
// .doOnError(this::enableForSpecialErrorCase)
// .doOnComplete(() -> fireAction(view.enableRefresh()));
// }
//
// private void enableForSpecialErrorCase(Throwable throwable) {
// if (!(throwable instanceof UnexpectedResponseError)) fireAction(view.enableRefresh());
// }
//
// private void fireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.RefreshToogle;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never; |
@Test public void shouldDisableFirstEnableAfter_WhenFlowEmmits() throws Exception {
Flowable.just(10, 20, 30, 40, 50)
.compose(toogler)
.subscribe();
checkForDisableFirstEnableAfter();
}
@Test public void shouldDisableFirstEnableAfter_WhenEmptyFlow() throws Exception {
Flowable<Integer> empty = Flowable.empty();
empty.compose(toogler).subscribe();
checkForDisableFirstEnableAfter();
}
@Test public void shouldEnableAfter_WhenNoSpecialError() throws Exception {
Flowable<Integer> broken = Flowable.error(new RuntimeException("WTF!!"));
broken.compose(toogler)
.subscribe(
some -> {},
Throwable::printStackTrace,
() -> {}
);
checkForDisableFirstEnableAfter();
}
@Test public void shouldDisableAfter_WithSpecialError() throws Exception { | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/RefreshToogle.java
// public class RefreshToogle<T> implements FlowableTransformer<T, T> {
//
// private final ToogleRefreshView view;
// private Scheduler targetScheduler;
//
// public RefreshToogle(ToogleRefreshView view, Scheduler targetScheduler) {
// this.view = view;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> fireAction(view.disableRefresh()))
// .doOnError(this::enableForSpecialErrorCase)
// .doOnComplete(() -> fireAction(view.enableRefresh()));
// }
//
// private void enableForSpecialErrorCase(Throwable throwable) {
// if (!(throwable instanceof UnexpectedResponseError)) fireAction(view.enableRefresh());
// }
//
// private void fireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/ToogleRefreshTests.java
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.RefreshToogle;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
@Test public void shouldDisableFirstEnableAfter_WhenFlowEmmits() throws Exception {
Flowable.just(10, 20, 30, 40, 50)
.compose(toogler)
.subscribe();
checkForDisableFirstEnableAfter();
}
@Test public void shouldDisableFirstEnableAfter_WhenEmptyFlow() throws Exception {
Flowable<Integer> empty = Flowable.empty();
empty.compose(toogler).subscribe();
checkForDisableFirstEnableAfter();
}
@Test public void shouldEnableAfter_WhenNoSpecialError() throws Exception {
Flowable<Integer> broken = Flowable.error(new RuntimeException("WTF!!"));
broken.compose(toogler)
.subscribe(
some -> {},
Throwable::printStackTrace,
() -> {}
);
checkForDisableFirstEnableAfter();
}
@Test public void shouldDisableAfter_WithSpecialError() throws Exception { | Flowable<Integer> broken = Flowable.error(new UnexpectedResponseError("Server down")); |
ubiratansoares/reactive-architectures-playground | app/src/test/java/br/ufs/demos/rxmvp/playground/core/ToogleRefreshTests.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/RefreshToogle.java
// public class RefreshToogle<T> implements FlowableTransformer<T, T> {
//
// private final ToogleRefreshView view;
// private Scheduler targetScheduler;
//
// public RefreshToogle(ToogleRefreshView view, Scheduler targetScheduler) {
// this.view = view;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> fireAction(view.disableRefresh()))
// .doOnError(this::enableForSpecialErrorCase)
// .doOnComplete(() -> fireAction(view.enableRefresh()));
// }
//
// private void enableForSpecialErrorCase(Throwable throwable) {
// if (!(throwable instanceof UnexpectedResponseError)) fireAction(view.enableRefresh());
// }
//
// private void fireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
| import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.RefreshToogle;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never; |
@Test public void shouldEnableAfter_WhenNoSpecialError() throws Exception {
Flowable<Integer> broken = Flowable.error(new RuntimeException("WTF!!"));
broken.compose(toogler)
.subscribe(
some -> {},
Throwable::printStackTrace,
() -> {}
);
checkForDisableFirstEnableAfter();
}
@Test public void shouldDisableAfter_WithSpecialError() throws Exception {
Flowable<Integer> broken = Flowable.error(new UnexpectedResponseError("Server down"));
broken.compose(toogler)
.subscribe(
some -> {},
Throwable::printStackTrace,
() -> {}
);
checkForDisableFirstNotEnableAfter();
}
private void checkForDisableFirstEnableAfter() throws Exception {
InOrder inOrder = inOrder(disableRefresh, enableRefresh); | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/RefreshToogle.java
// public class RefreshToogle<T> implements FlowableTransformer<T, T> {
//
// private final ToogleRefreshView view;
// private Scheduler targetScheduler;
//
// public RefreshToogle(ToogleRefreshView view, Scheduler targetScheduler) {
// this.view = view;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> fireAction(view.disableRefresh()))
// .doOnError(this::enableForSpecialErrorCase)
// .doOnComplete(() -> fireAction(view.enableRefresh()));
// }
//
// private void enableForSpecialErrorCase(Throwable throwable) {
// if (!(throwable instanceof UnexpectedResponseError)) fireAction(view.enableRefresh());
// }
//
// private void fireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/ToogleRefreshView.java
// public interface ToogleRefreshView {
//
// Action disableRefresh();
//
// Action enableRefresh();
//
// }
//
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
// return VerificationModeFactory.times(1);
// }
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/ToogleRefreshTests.java
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.RefreshToogle;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.ToogleRefreshView;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
@Test public void shouldEnableAfter_WhenNoSpecialError() throws Exception {
Flowable<Integer> broken = Flowable.error(new RuntimeException("WTF!!"));
broken.compose(toogler)
.subscribe(
some -> {},
Throwable::printStackTrace,
() -> {}
);
checkForDisableFirstEnableAfter();
}
@Test public void shouldDisableAfter_WithSpecialError() throws Exception {
Flowable<Integer> broken = Flowable.error(new UnexpectedResponseError("Server down"));
broken.compose(toogler)
.subscribe(
some -> {},
Throwable::printStackTrace,
() -> {}
);
checkForDisableFirstNotEnableAfter();
}
private void checkForDisableFirstEnableAfter() throws Exception {
InOrder inOrder = inOrder(disableRefresh, enableRefresh); | inOrder.verify(disableRefresh, oneTimeOnly()).run(); |
ubiratansoares/reactive-architectures-playground | app/src/mock/java/br/ufs/demos/rxmvp/playground/dagger/modules/RestWebServiceModule.java | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public class FakeWebService implements NumbersWebService {
//
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// private NextCall nextReturn;
//
//
// public FakeWebService() {
// nextReturn = NextCall.UNDEFINED_ERROR;
// }
//
// public void nextCallPerform(NextCall nextReturn) {
// this.nextReturn = nextReturn;
// }
//
// @Override public Flowable<NumbersTriviaPayload> getTrivia(String commaSeparatedNumbers) {
//
// switch (nextReturn) {
// case SUCCESS_200:
// return FakeResponses.triviaResults();
//
// case NOT_FOUND_404:
// return FakeResponses.notFound();
//
// case INTERNAL_SERVER_ERROR_5xy:
// return FakeResponses.internalServerError();
//
// case CONNECTION_ERROR:
// return FakeResponses.connectionIssue();
//
// case CONNECTION_TIMEOUT:
// return FakeResponses.requestTimeout();
// }
//
// return Flowable.empty();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
| import javax.inject.Singleton;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import dagger.Module;
import dagger.Provides; | package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 6/26/17.
*/
@Module
public class RestWebServiceModule {
| // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public class FakeWebService implements NumbersWebService {
//
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// private NextCall nextReturn;
//
//
// public FakeWebService() {
// nextReturn = NextCall.UNDEFINED_ERROR;
// }
//
// public void nextCallPerform(NextCall nextReturn) {
// this.nextReturn = nextReturn;
// }
//
// @Override public Flowable<NumbersTriviaPayload> getTrivia(String commaSeparatedNumbers) {
//
// switch (nextReturn) {
// case SUCCESS_200:
// return FakeResponses.triviaResults();
//
// case NOT_FOUND_404:
// return FakeResponses.notFound();
//
// case INTERNAL_SERVER_ERROR_5xy:
// return FakeResponses.internalServerError();
//
// case CONNECTION_ERROR:
// return FakeResponses.connectionIssue();
//
// case CONNECTION_TIMEOUT:
// return FakeResponses.requestTimeout();
// }
//
// return Flowable.empty();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/dagger/modules/RestWebServiceModule.java
import javax.inject.Singleton;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import dagger.Module;
import dagger.Provides;
package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 6/26/17.
*/
@Module
public class RestWebServiceModule {
| @Provides @Singleton static NumbersWebService webService() { |
ubiratansoares/reactive-architectures-playground | app/src/mock/java/br/ufs/demos/rxmvp/playground/dagger/modules/RestWebServiceModule.java | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public class FakeWebService implements NumbersWebService {
//
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// private NextCall nextReturn;
//
//
// public FakeWebService() {
// nextReturn = NextCall.UNDEFINED_ERROR;
// }
//
// public void nextCallPerform(NextCall nextReturn) {
// this.nextReturn = nextReturn;
// }
//
// @Override public Flowable<NumbersTriviaPayload> getTrivia(String commaSeparatedNumbers) {
//
// switch (nextReturn) {
// case SUCCESS_200:
// return FakeResponses.triviaResults();
//
// case NOT_FOUND_404:
// return FakeResponses.notFound();
//
// case INTERNAL_SERVER_ERROR_5xy:
// return FakeResponses.internalServerError();
//
// case CONNECTION_ERROR:
// return FakeResponses.connectionIssue();
//
// case CONNECTION_TIMEOUT:
// return FakeResponses.requestTimeout();
// }
//
// return Flowable.empty();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
| import javax.inject.Singleton;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import dagger.Module;
import dagger.Provides; | package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 6/26/17.
*/
@Module
public class RestWebServiceModule {
@Provides @Singleton static NumbersWebService webService() { | // Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
// public class FakeWebService implements NumbersWebService {
//
// public enum NextCall {
// UNDEFINED_ERROR,
// CONNECTION_ERROR,
// CONNECTION_TIMEOUT,
// INTERNAL_SERVER_ERROR_5xy,
// NOT_FOUND_404,
// SUCCESS_200
// }
//
// private NextCall nextReturn;
//
//
// public FakeWebService() {
// nextReturn = NextCall.UNDEFINED_ERROR;
// }
//
// public void nextCallPerform(NextCall nextReturn) {
// this.nextReturn = nextReturn;
// }
//
// @Override public Flowable<NumbersTriviaPayload> getTrivia(String commaSeparatedNumbers) {
//
// switch (nextReturn) {
// case SUCCESS_200:
// return FakeResponses.triviaResults();
//
// case NOT_FOUND_404:
// return FakeResponses.notFound();
//
// case INTERNAL_SERVER_ERROR_5xy:
// return FakeResponses.internalServerError();
//
// case CONNECTION_ERROR:
// return FakeResponses.connectionIssue();
//
// case CONNECTION_TIMEOUT:
// return FakeResponses.requestTimeout();
// }
//
// return Flowable.empty();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/dagger/modules/RestWebServiceModule.java
import javax.inject.Singleton;
import br.ufs.demos.rxmvp.playground.fakes.FakeWebService;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import dagger.Module;
import dagger.Provides;
package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 6/26/17.
*/
@Module
public class RestWebServiceModule {
@Provides @Singleton static NumbersWebService webService() { | return new FakeWebService(); |
ubiratansoares/reactive-architectures-playground | app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeResponses.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/NumbersTriviaPayload.java
// public class NumbersTriviaPayload extends HashMap<String, String> {
//
// // Shame on me by my lazyness ....
//
// }
| import com.google.gson.Gson;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.util.concurrent.TimeUnit;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.NumbersTriviaPayload;
import io.reactivex.Flowable;
import okhttp3.MediaType;
import okhttp3.ResponseBody;
import retrofit2.HttpException;
import retrofit2.Response; | package br.ufs.demos.rxmvp.playground.fakes;
/**
* Created by bira on 10/3/17.
*/
public class FakeResponses {
private static final Gson GSON = new Gson();
| // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/NumbersTriviaPayload.java
// public class NumbersTriviaPayload extends HashMap<String, String> {
//
// // Shame on me by my lazyness ....
//
// }
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeResponses.java
import com.google.gson.Gson;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.util.concurrent.TimeUnit;
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.NumbersTriviaPayload;
import io.reactivex.Flowable;
import okhttp3.MediaType;
import okhttp3.ResponseBody;
import retrofit2.HttpException;
import retrofit2.Response;
package br.ufs.demos.rxmvp.playground.fakes;
/**
* Created by bira on 10/3/17.
*/
public class FakeResponses {
private static final Gson GSON = new Gson();
| static Flowable<NumbersTriviaPayload> triviaResults() { |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/AssignEmptyState.java
// public class AssignEmptyState<T> implements FlowableTransformer<T, T> {
//
// private EmptyStateView view;
// private Scheduler uiScheduler;
//
// public AssignEmptyState(EmptyStateView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
// view.hideEmptyState(),
// view.showEmptyState(),
// error -> error instanceof ContentNotFoundError,
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/AssignErrorState.java
// public class AssignErrorState<T> implements FlowableTransformer<T, T> {
//
// private ErrorStateView view;
// private Scheduler uiScheduler;
//
// public AssignErrorState(ErrorStateView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
// view.hideErrorState(),
// view.showErrorState(),
// error -> !(error instanceof ContentNotFoundError),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingCoordination.java
// public class LoadingCoordination<T> implements FlowableTransformer<T, T> {
//
// private LoadingView view;
// private Scheduler uiScheduler;
//
// public LoadingCoordination(LoadingView view,
// Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// ShowAtStartHideWhenDone<T> delegate = new ShowAtStartHideWhenDone<>(
// view.showLoading(),
// view.hideLoading(),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
// public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
//
// private NetworkingErrorView view;
// private Scheduler uiScheduler;
//
// public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.doOnError(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
//
// if (throwable instanceof NetworkingError) {
// Completable.fromAction(view.reportNetworkingError())
// .observeOn(uiScheduler)
// .subscribe();
// }
//
// return Flowable.error(throwable);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/RefreshToogle.java
// public class RefreshToogle<T> implements FlowableTransformer<T, T> {
//
// private final ToogleRefreshView view;
// private Scheduler targetScheduler;
//
// public RefreshToogle(ToogleRefreshView view, Scheduler targetScheduler) {
// this.view = view;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> fireAction(view.disableRefresh()))
// .doOnError(this::enableForSpecialErrorCase)
// .doOnComplete(() -> fireAction(view.enableRefresh()));
// }
//
// private void enableForSpecialErrorCase(Throwable throwable) {
// if (!(throwable instanceof UnexpectedResponseError)) fireAction(view.enableRefresh());
// }
//
// private void fireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
| import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.AssignEmptyState;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.AssignErrorState;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingCoordination;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorFeedback;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.RefreshToogle;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer; | package br.ufs.demos.rxmvp.playground.core.behaviours;
/**
* Created by bira on 6/30/17.
*/
public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
private AssignEmptyState<T> dealWithEmptyState; | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/AssignEmptyState.java
// public class AssignEmptyState<T> implements FlowableTransformer<T, T> {
//
// private EmptyStateView view;
// private Scheduler uiScheduler;
//
// public AssignEmptyState(EmptyStateView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
// view.hideEmptyState(),
// view.showEmptyState(),
// error -> error instanceof ContentNotFoundError,
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/AssignErrorState.java
// public class AssignErrorState<T> implements FlowableTransformer<T, T> {
//
// private ErrorStateView view;
// private Scheduler uiScheduler;
//
// public AssignErrorState(ErrorStateView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
// view.hideErrorState(),
// view.showErrorState(),
// error -> !(error instanceof ContentNotFoundError),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingCoordination.java
// public class LoadingCoordination<T> implements FlowableTransformer<T, T> {
//
// private LoadingView view;
// private Scheduler uiScheduler;
//
// public LoadingCoordination(LoadingView view,
// Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// ShowAtStartHideWhenDone<T> delegate = new ShowAtStartHideWhenDone<>(
// view.showLoading(),
// view.hideLoading(),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
// public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
//
// private NetworkingErrorView view;
// private Scheduler uiScheduler;
//
// public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.doOnError(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
//
// if (throwable instanceof NetworkingError) {
// Completable.fromAction(view.reportNetworkingError())
// .observeOn(uiScheduler)
// .subscribe();
// }
//
// return Flowable.error(throwable);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/RefreshToogle.java
// public class RefreshToogle<T> implements FlowableTransformer<T, T> {
//
// private final ToogleRefreshView view;
// private Scheduler targetScheduler;
//
// public RefreshToogle(ToogleRefreshView view, Scheduler targetScheduler) {
// this.view = view;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> fireAction(view.disableRefresh()))
// .doOnError(this::enableForSpecialErrorCase)
// .doOnComplete(() -> fireAction(view.enableRefresh()));
// }
//
// private void enableForSpecialErrorCase(Throwable throwable) {
// if (!(throwable instanceof UnexpectedResponseError)) fireAction(view.enableRefresh());
// }
//
// private void fireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java
import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.AssignEmptyState;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.AssignErrorState;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingCoordination;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorFeedback;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.RefreshToogle;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
package br.ufs.demos.rxmvp.playground.core.behaviours;
/**
* Created by bira on 6/30/17.
*/
public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
private AssignEmptyState<T> dealWithEmptyState; | private AssignErrorState<T> assignErrorState; |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/AssignEmptyState.java
// public class AssignEmptyState<T> implements FlowableTransformer<T, T> {
//
// private EmptyStateView view;
// private Scheduler uiScheduler;
//
// public AssignEmptyState(EmptyStateView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
// view.hideEmptyState(),
// view.showEmptyState(),
// error -> error instanceof ContentNotFoundError,
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/AssignErrorState.java
// public class AssignErrorState<T> implements FlowableTransformer<T, T> {
//
// private ErrorStateView view;
// private Scheduler uiScheduler;
//
// public AssignErrorState(ErrorStateView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
// view.hideErrorState(),
// view.showErrorState(),
// error -> !(error instanceof ContentNotFoundError),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingCoordination.java
// public class LoadingCoordination<T> implements FlowableTransformer<T, T> {
//
// private LoadingView view;
// private Scheduler uiScheduler;
//
// public LoadingCoordination(LoadingView view,
// Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// ShowAtStartHideWhenDone<T> delegate = new ShowAtStartHideWhenDone<>(
// view.showLoading(),
// view.hideLoading(),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
// public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
//
// private NetworkingErrorView view;
// private Scheduler uiScheduler;
//
// public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.doOnError(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
//
// if (throwable instanceof NetworkingError) {
// Completable.fromAction(view.reportNetworkingError())
// .observeOn(uiScheduler)
// .subscribe();
// }
//
// return Flowable.error(throwable);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/RefreshToogle.java
// public class RefreshToogle<T> implements FlowableTransformer<T, T> {
//
// private final ToogleRefreshView view;
// private Scheduler targetScheduler;
//
// public RefreshToogle(ToogleRefreshView view, Scheduler targetScheduler) {
// this.view = view;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> fireAction(view.disableRefresh()))
// .doOnError(this::enableForSpecialErrorCase)
// .doOnComplete(() -> fireAction(view.enableRefresh()));
// }
//
// private void enableForSpecialErrorCase(Throwable throwable) {
// if (!(throwable instanceof UnexpectedResponseError)) fireAction(view.enableRefresh());
// }
//
// private void fireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
| import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.AssignEmptyState;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.AssignErrorState;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingCoordination;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorFeedback;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.RefreshToogle;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer; | package br.ufs.demos.rxmvp.playground.core.behaviours;
/**
* Created by bira on 6/30/17.
*/
public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
private AssignEmptyState<T> dealWithEmptyState;
private AssignErrorState<T> assignErrorState; | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/AssignEmptyState.java
// public class AssignEmptyState<T> implements FlowableTransformer<T, T> {
//
// private EmptyStateView view;
// private Scheduler uiScheduler;
//
// public AssignEmptyState(EmptyStateView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
// view.hideEmptyState(),
// view.showEmptyState(),
// error -> error instanceof ContentNotFoundError,
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/AssignErrorState.java
// public class AssignErrorState<T> implements FlowableTransformer<T, T> {
//
// private ErrorStateView view;
// private Scheduler uiScheduler;
//
// public AssignErrorState(ErrorStateView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
// view.hideErrorState(),
// view.showErrorState(),
// error -> !(error instanceof ContentNotFoundError),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingCoordination.java
// public class LoadingCoordination<T> implements FlowableTransformer<T, T> {
//
// private LoadingView view;
// private Scheduler uiScheduler;
//
// public LoadingCoordination(LoadingView view,
// Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// ShowAtStartHideWhenDone<T> delegate = new ShowAtStartHideWhenDone<>(
// view.showLoading(),
// view.hideLoading(),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
// public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
//
// private NetworkingErrorView view;
// private Scheduler uiScheduler;
//
// public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.doOnError(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
//
// if (throwable instanceof NetworkingError) {
// Completable.fromAction(view.reportNetworkingError())
// .observeOn(uiScheduler)
// .subscribe();
// }
//
// return Flowable.error(throwable);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/RefreshToogle.java
// public class RefreshToogle<T> implements FlowableTransformer<T, T> {
//
// private final ToogleRefreshView view;
// private Scheduler targetScheduler;
//
// public RefreshToogle(ToogleRefreshView view, Scheduler targetScheduler) {
// this.view = view;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> fireAction(view.disableRefresh()))
// .doOnError(this::enableForSpecialErrorCase)
// .doOnComplete(() -> fireAction(view.enableRefresh()));
// }
//
// private void enableForSpecialErrorCase(Throwable throwable) {
// if (!(throwable instanceof UnexpectedResponseError)) fireAction(view.enableRefresh());
// }
//
// private void fireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java
import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.AssignEmptyState;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.AssignErrorState;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingCoordination;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorFeedback;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.RefreshToogle;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
package br.ufs.demos.rxmvp.playground.core.behaviours;
/**
* Created by bira on 6/30/17.
*/
public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
private AssignEmptyState<T> dealWithEmptyState;
private AssignErrorState<T> assignErrorState; | private LoadingCoordination<T> loadingCoordinator; |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/AssignEmptyState.java
// public class AssignEmptyState<T> implements FlowableTransformer<T, T> {
//
// private EmptyStateView view;
// private Scheduler uiScheduler;
//
// public AssignEmptyState(EmptyStateView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
// view.hideEmptyState(),
// view.showEmptyState(),
// error -> error instanceof ContentNotFoundError,
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/AssignErrorState.java
// public class AssignErrorState<T> implements FlowableTransformer<T, T> {
//
// private ErrorStateView view;
// private Scheduler uiScheduler;
//
// public AssignErrorState(ErrorStateView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
// view.hideErrorState(),
// view.showErrorState(),
// error -> !(error instanceof ContentNotFoundError),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingCoordination.java
// public class LoadingCoordination<T> implements FlowableTransformer<T, T> {
//
// private LoadingView view;
// private Scheduler uiScheduler;
//
// public LoadingCoordination(LoadingView view,
// Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// ShowAtStartHideWhenDone<T> delegate = new ShowAtStartHideWhenDone<>(
// view.showLoading(),
// view.hideLoading(),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
// public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
//
// private NetworkingErrorView view;
// private Scheduler uiScheduler;
//
// public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.doOnError(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
//
// if (throwable instanceof NetworkingError) {
// Completable.fromAction(view.reportNetworkingError())
// .observeOn(uiScheduler)
// .subscribe();
// }
//
// return Flowable.error(throwable);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/RefreshToogle.java
// public class RefreshToogle<T> implements FlowableTransformer<T, T> {
//
// private final ToogleRefreshView view;
// private Scheduler targetScheduler;
//
// public RefreshToogle(ToogleRefreshView view, Scheduler targetScheduler) {
// this.view = view;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> fireAction(view.disableRefresh()))
// .doOnError(this::enableForSpecialErrorCase)
// .doOnComplete(() -> fireAction(view.enableRefresh()));
// }
//
// private void enableForSpecialErrorCase(Throwable throwable) {
// if (!(throwable instanceof UnexpectedResponseError)) fireAction(view.enableRefresh());
// }
//
// private void fireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
| import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.AssignEmptyState;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.AssignErrorState;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingCoordination;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorFeedback;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.RefreshToogle;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer; | package br.ufs.demos.rxmvp.playground.core.behaviours;
/**
* Created by bira on 6/30/17.
*/
public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
private AssignEmptyState<T> dealWithEmptyState;
private AssignErrorState<T> assignErrorState;
private LoadingCoordination<T> loadingCoordinator; | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/AssignEmptyState.java
// public class AssignEmptyState<T> implements FlowableTransformer<T, T> {
//
// private EmptyStateView view;
// private Scheduler uiScheduler;
//
// public AssignEmptyState(EmptyStateView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
// view.hideEmptyState(),
// view.showEmptyState(),
// error -> error instanceof ContentNotFoundError,
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/AssignErrorState.java
// public class AssignErrorState<T> implements FlowableTransformer<T, T> {
//
// private ErrorStateView view;
// private Scheduler uiScheduler;
//
// public AssignErrorState(ErrorStateView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
// view.hideErrorState(),
// view.showErrorState(),
// error -> !(error instanceof ContentNotFoundError),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingCoordination.java
// public class LoadingCoordination<T> implements FlowableTransformer<T, T> {
//
// private LoadingView view;
// private Scheduler uiScheduler;
//
// public LoadingCoordination(LoadingView view,
// Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// ShowAtStartHideWhenDone<T> delegate = new ShowAtStartHideWhenDone<>(
// view.showLoading(),
// view.hideLoading(),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
// public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
//
// private NetworkingErrorView view;
// private Scheduler uiScheduler;
//
// public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.doOnError(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
//
// if (throwable instanceof NetworkingError) {
// Completable.fromAction(view.reportNetworkingError())
// .observeOn(uiScheduler)
// .subscribe();
// }
//
// return Flowable.error(throwable);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/RefreshToogle.java
// public class RefreshToogle<T> implements FlowableTransformer<T, T> {
//
// private final ToogleRefreshView view;
// private Scheduler targetScheduler;
//
// public RefreshToogle(ToogleRefreshView view, Scheduler targetScheduler) {
// this.view = view;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> fireAction(view.disableRefresh()))
// .doOnError(this::enableForSpecialErrorCase)
// .doOnComplete(() -> fireAction(view.enableRefresh()));
// }
//
// private void enableForSpecialErrorCase(Throwable throwable) {
// if (!(throwable instanceof UnexpectedResponseError)) fireAction(view.enableRefresh());
// }
//
// private void fireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java
import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.AssignEmptyState;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.AssignErrorState;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingCoordination;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorFeedback;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.RefreshToogle;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
package br.ufs.demos.rxmvp.playground.core.behaviours;
/**
* Created by bira on 6/30/17.
*/
public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
private AssignEmptyState<T> dealWithEmptyState;
private AssignErrorState<T> assignErrorState;
private LoadingCoordination<T> loadingCoordinator; | private NetworkingErrorFeedback<T> networkingErrorFeedback; |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/AssignEmptyState.java
// public class AssignEmptyState<T> implements FlowableTransformer<T, T> {
//
// private EmptyStateView view;
// private Scheduler uiScheduler;
//
// public AssignEmptyState(EmptyStateView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
// view.hideEmptyState(),
// view.showEmptyState(),
// error -> error instanceof ContentNotFoundError,
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/AssignErrorState.java
// public class AssignErrorState<T> implements FlowableTransformer<T, T> {
//
// private ErrorStateView view;
// private Scheduler uiScheduler;
//
// public AssignErrorState(ErrorStateView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
// view.hideErrorState(),
// view.showErrorState(),
// error -> !(error instanceof ContentNotFoundError),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingCoordination.java
// public class LoadingCoordination<T> implements FlowableTransformer<T, T> {
//
// private LoadingView view;
// private Scheduler uiScheduler;
//
// public LoadingCoordination(LoadingView view,
// Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// ShowAtStartHideWhenDone<T> delegate = new ShowAtStartHideWhenDone<>(
// view.showLoading(),
// view.hideLoading(),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
// public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
//
// private NetworkingErrorView view;
// private Scheduler uiScheduler;
//
// public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.doOnError(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
//
// if (throwable instanceof NetworkingError) {
// Completable.fromAction(view.reportNetworkingError())
// .observeOn(uiScheduler)
// .subscribe();
// }
//
// return Flowable.error(throwable);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/RefreshToogle.java
// public class RefreshToogle<T> implements FlowableTransformer<T, T> {
//
// private final ToogleRefreshView view;
// private Scheduler targetScheduler;
//
// public RefreshToogle(ToogleRefreshView view, Scheduler targetScheduler) {
// this.view = view;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> fireAction(view.disableRefresh()))
// .doOnError(this::enableForSpecialErrorCase)
// .doOnComplete(() -> fireAction(view.enableRefresh()));
// }
//
// private void enableForSpecialErrorCase(Throwable throwable) {
// if (!(throwable instanceof UnexpectedResponseError)) fireAction(view.enableRefresh());
// }
//
// private void fireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
| import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.AssignEmptyState;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.AssignErrorState;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingCoordination;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorFeedback;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.RefreshToogle;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer; | package br.ufs.demos.rxmvp.playground.core.behaviours;
/**
* Created by bira on 6/30/17.
*/
public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
private AssignEmptyState<T> dealWithEmptyState;
private AssignErrorState<T> assignErrorState;
private LoadingCoordination<T> loadingCoordinator;
private NetworkingErrorFeedback<T> networkingErrorFeedback; | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/AssignEmptyState.java
// public class AssignEmptyState<T> implements FlowableTransformer<T, T> {
//
// private EmptyStateView view;
// private Scheduler uiScheduler;
//
// public AssignEmptyState(EmptyStateView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
// view.hideEmptyState(),
// view.showEmptyState(),
// error -> error instanceof ContentNotFoundError,
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/AssignErrorState.java
// public class AssignErrorState<T> implements FlowableTransformer<T, T> {
//
// private ErrorStateView view;
// private Scheduler uiScheduler;
//
// public AssignErrorState(ErrorStateView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
// view.hideErrorState(),
// view.showErrorState(),
// error -> !(error instanceof ContentNotFoundError),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/loadingcontent/LoadingCoordination.java
// public class LoadingCoordination<T> implements FlowableTransformer<T, T> {
//
// private LoadingView view;
// private Scheduler uiScheduler;
//
// public LoadingCoordination(LoadingView view,
// Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
//
// ShowAtStartHideWhenDone<T> delegate = new ShowAtStartHideWhenDone<>(
// view.showLoading(),
// view.hideLoading(),
// uiScheduler
// );
//
// return upstream.compose(delegate);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
// public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
//
// private NetworkingErrorView view;
// private Scheduler uiScheduler;
//
// public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
// this.view = view;
// this.uiScheduler = uiScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.doOnError(this::handleIfNetworkingError);
// }
//
// private Publisher<T> handleIfNetworkingError(Throwable throwable) {
//
// if (throwable instanceof NetworkingError) {
// Completable.fromAction(view.reportNetworkingError())
// .observeOn(uiScheduler)
// .subscribe();
// }
//
// return Flowable.error(throwable);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/tooglerefresh/RefreshToogle.java
// public class RefreshToogle<T> implements FlowableTransformer<T, T> {
//
// private final ToogleRefreshView view;
// private Scheduler targetScheduler;
//
// public RefreshToogle(ToogleRefreshView view, Scheduler targetScheduler) {
// this.view = view;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> fireAction(view.disableRefresh()))
// .doOnError(this::enableForSpecialErrorCase)
// .doOnComplete(() -> fireAction(view.enableRefresh()));
// }
//
// private void enableForSpecialErrorCase(Throwable throwable) {
// if (!(throwable instanceof UnexpectedResponseError)) fireAction(view.enableRefresh());
// }
//
// private void fireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java
import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.emptystate.AssignEmptyState;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.AssignErrorState;
import br.ufs.demos.rxmvp.playground.core.behaviours.loadingcontent.LoadingCoordination;
import br.ufs.demos.rxmvp.playground.core.behaviours.networking.NetworkingErrorFeedback;
import br.ufs.demos.rxmvp.playground.core.behaviours.tooglerefresh.RefreshToogle;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
package br.ufs.demos.rxmvp.playground.core.behaviours;
/**
* Created by bira on 6/30/17.
*/
public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
private AssignEmptyState<T> dealWithEmptyState;
private AssignErrorState<T> assignErrorState;
private LoadingCoordination<T> loadingCoordinator;
private NetworkingErrorFeedback<T> networkingErrorFeedback; | private RefreshToogle<T> refreshToogle; |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/AssignEmptyState.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/HideAtStartShowAtError.java
// public class HideAtStartShowAtError<T> implements FlowableTransformer<T, T> {
//
// private Action whenStart;
// private Action atError;
// private ErrorPredicate errorPredicate;
// private Scheduler targetScheduler;
//
// public HideAtStartShowAtError(Action whenStart,
// Action atError,
// ErrorPredicate errorPredicate,
// Scheduler targetScheduler) {
//
// this.whenStart = whenStart;
// this.atError = atError;
// this.errorPredicate = errorPredicate;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> hide())
// .doOnError(this::evaluateAndShowIfApplicable);
// }
//
// private void evaluateAndShowIfApplicable(Throwable throwable) {
// if (errorPredicate.evaluate(throwable)) {
// subscribeAndFireAction(atError);
// }
// }
//
// private void hide() {
// subscribeAndFireAction(whenStart);
// }
//
// private void subscribeAndFireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
| import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.HideAtStartShowAtError;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
import io.reactivex.Scheduler; | package br.ufs.demos.rxmvp.playground.core.behaviours.emptystate;
/**
* Created by bira on 6/30/17.
*/
public class AssignEmptyState<T> implements FlowableTransformer<T, T> {
private EmptyStateView view;
private Scheduler uiScheduler;
public AssignEmptyState(EmptyStateView view, Scheduler uiScheduler) {
this.view = view;
this.uiScheduler = uiScheduler;
}
@Override public Publisher<T> apply(Flowable<T> upstream) {
| // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/HideAtStartShowAtError.java
// public class HideAtStartShowAtError<T> implements FlowableTransformer<T, T> {
//
// private Action whenStart;
// private Action atError;
// private ErrorPredicate errorPredicate;
// private Scheduler targetScheduler;
//
// public HideAtStartShowAtError(Action whenStart,
// Action atError,
// ErrorPredicate errorPredicate,
// Scheduler targetScheduler) {
//
// this.whenStart = whenStart;
// this.atError = atError;
// this.errorPredicate = errorPredicate;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> hide())
// .doOnError(this::evaluateAndShowIfApplicable);
// }
//
// private void evaluateAndShowIfApplicable(Throwable throwable) {
// if (errorPredicate.evaluate(throwable)) {
// subscribeAndFireAction(atError);
// }
// }
//
// private void hide() {
// subscribeAndFireAction(whenStart);
// }
//
// private void subscribeAndFireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/AssignEmptyState.java
import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.HideAtStartShowAtError;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
import io.reactivex.Scheduler;
package br.ufs.demos.rxmvp.playground.core.behaviours.emptystate;
/**
* Created by bira on 6/30/17.
*/
public class AssignEmptyState<T> implements FlowableTransformer<T, T> {
private EmptyStateView view;
private Scheduler uiScheduler;
public AssignEmptyState(EmptyStateView view, Scheduler uiScheduler) {
this.view = view;
this.uiScheduler = uiScheduler;
}
@Override public Publisher<T> apply(Flowable<T> upstream) {
| HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>( |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/AssignEmptyState.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/HideAtStartShowAtError.java
// public class HideAtStartShowAtError<T> implements FlowableTransformer<T, T> {
//
// private Action whenStart;
// private Action atError;
// private ErrorPredicate errorPredicate;
// private Scheduler targetScheduler;
//
// public HideAtStartShowAtError(Action whenStart,
// Action atError,
// ErrorPredicate errorPredicate,
// Scheduler targetScheduler) {
//
// this.whenStart = whenStart;
// this.atError = atError;
// this.errorPredicate = errorPredicate;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> hide())
// .doOnError(this::evaluateAndShowIfApplicable);
// }
//
// private void evaluateAndShowIfApplicable(Throwable throwable) {
// if (errorPredicate.evaluate(throwable)) {
// subscribeAndFireAction(atError);
// }
// }
//
// private void hide() {
// subscribeAndFireAction(whenStart);
// }
//
// private void subscribeAndFireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
| import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.HideAtStartShowAtError;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
import io.reactivex.Scheduler; | package br.ufs.demos.rxmvp.playground.core.behaviours.emptystate;
/**
* Created by bira on 6/30/17.
*/
public class AssignEmptyState<T> implements FlowableTransformer<T, T> {
private EmptyStateView view;
private Scheduler uiScheduler;
public AssignEmptyState(EmptyStateView view, Scheduler uiScheduler) {
this.view = view;
this.uiScheduler = uiScheduler;
}
@Override public Publisher<T> apply(Flowable<T> upstream) {
HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
view.hideEmptyState(),
view.showEmptyState(), | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/HideAtStartShowAtError.java
// public class HideAtStartShowAtError<T> implements FlowableTransformer<T, T> {
//
// private Action whenStart;
// private Action atError;
// private ErrorPredicate errorPredicate;
// private Scheduler targetScheduler;
//
// public HideAtStartShowAtError(Action whenStart,
// Action atError,
// ErrorPredicate errorPredicate,
// Scheduler targetScheduler) {
//
// this.whenStart = whenStart;
// this.atError = atError;
// this.errorPredicate = errorPredicate;
// this.targetScheduler = targetScheduler;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .doOnSubscribe(subscription -> hide())
// .doOnError(this::evaluateAndShowIfApplicable);
// }
//
// private void evaluateAndShowIfApplicable(Throwable throwable) {
// if (errorPredicate.evaluate(throwable)) {
// subscribeAndFireAction(atError);
// }
// }
//
// private void hide() {
// subscribeAndFireAction(whenStart);
// }
//
// private void subscribeAndFireAction(Action toPerform) {
// Completable.fromAction(toPerform)
// .subscribeOn(targetScheduler)
// .subscribe();
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/emptystate/AssignEmptyState.java
import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.HideAtStartShowAtError;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
import io.reactivex.Scheduler;
package br.ufs.demos.rxmvp.playground.core.behaviours.emptystate;
/**
* Created by bira on 6/30/17.
*/
public class AssignEmptyState<T> implements FlowableTransformer<T, T> {
private EmptyStateView view;
private Scheduler uiScheduler;
public AssignEmptyState(EmptyStateView view, Scheduler uiScheduler) {
this.view = view;
this.uiScheduler = uiScheduler;
}
@Override public Publisher<T> apply(Flowable<T> upstream) {
HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
view.hideEmptyState(),
view.showEmptyState(), | error -> error instanceof ContentNotFoundError, |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsPresenter.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java
// public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
//
// private AssignEmptyState<T> dealWithEmptyState;
// private AssignErrorState<T> assignErrorState;
// private LoadingCoordination<T> loadingCoordinator;
// private NetworkingErrorFeedback<T> networkingErrorFeedback;
// private RefreshToogle<T> refreshToogle;
//
// public BehavioursCoordinator(AssignEmptyState<T> dealWithEmptyState,
// AssignErrorState<T> assignErrorState,
// LoadingCoordination<T> loadingCoordinator,
// NetworkingErrorFeedback<T> networkingErrorFeedback,
// RefreshToogle<T> refreshToogle) {
//
// this.dealWithEmptyState = dealWithEmptyState;
// this.assignErrorState = assignErrorState;
// this.loadingCoordinator = loadingCoordinator;
// this.networkingErrorFeedback = networkingErrorFeedback;
// this.refreshToogle = refreshToogle;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .compose(dealWithEmptyState)
// .compose(assignErrorState)
// .compose(loadingCoordinator)
// .compose(refreshToogle)
// .compose(networkingErrorFeedback);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/FactAboutNumber.java
// public class FactAboutNumber {
//
// public String number;
// public String fact;
//
// private FactAboutNumber(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// public static FactAboutNumber of(String number, String fact) {
// return new FactAboutNumber(number, fact);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/DomainToViewModel.java
// public interface DomainToViewModel<Data, ViewModel> {
//
// ViewModel translate(Data data);
//
// }
| import br.ufs.demos.rxmvp.playground.core.behaviours.BehavioursCoordinator;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import br.ufs.demos.rxmvp.playground.trivia.domain.FactAboutNumber;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.util.DomainToViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable; | package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public class FactsPresenter {
private GetRandomFacts usecase;
private DisplayFactsView view; | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java
// public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
//
// private AssignEmptyState<T> dealWithEmptyState;
// private AssignErrorState<T> assignErrorState;
// private LoadingCoordination<T> loadingCoordinator;
// private NetworkingErrorFeedback<T> networkingErrorFeedback;
// private RefreshToogle<T> refreshToogle;
//
// public BehavioursCoordinator(AssignEmptyState<T> dealWithEmptyState,
// AssignErrorState<T> assignErrorState,
// LoadingCoordination<T> loadingCoordinator,
// NetworkingErrorFeedback<T> networkingErrorFeedback,
// RefreshToogle<T> refreshToogle) {
//
// this.dealWithEmptyState = dealWithEmptyState;
// this.assignErrorState = assignErrorState;
// this.loadingCoordinator = loadingCoordinator;
// this.networkingErrorFeedback = networkingErrorFeedback;
// this.refreshToogle = refreshToogle;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .compose(dealWithEmptyState)
// .compose(assignErrorState)
// .compose(loadingCoordinator)
// .compose(refreshToogle)
// .compose(networkingErrorFeedback);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/FactAboutNumber.java
// public class FactAboutNumber {
//
// public String number;
// public String fact;
//
// private FactAboutNumber(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// public static FactAboutNumber of(String number, String fact) {
// return new FactAboutNumber(number, fact);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/DomainToViewModel.java
// public interface DomainToViewModel<Data, ViewModel> {
//
// ViewModel translate(Data data);
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsPresenter.java
import br.ufs.demos.rxmvp.playground.core.behaviours.BehavioursCoordinator;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import br.ufs.demos.rxmvp.playground.trivia.domain.FactAboutNumber;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.util.DomainToViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public class FactsPresenter {
private GetRandomFacts usecase;
private DisplayFactsView view; | private BehavioursCoordinator<FactAboutNumber> coordinator; |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsPresenter.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java
// public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
//
// private AssignEmptyState<T> dealWithEmptyState;
// private AssignErrorState<T> assignErrorState;
// private LoadingCoordination<T> loadingCoordinator;
// private NetworkingErrorFeedback<T> networkingErrorFeedback;
// private RefreshToogle<T> refreshToogle;
//
// public BehavioursCoordinator(AssignEmptyState<T> dealWithEmptyState,
// AssignErrorState<T> assignErrorState,
// LoadingCoordination<T> loadingCoordinator,
// NetworkingErrorFeedback<T> networkingErrorFeedback,
// RefreshToogle<T> refreshToogle) {
//
// this.dealWithEmptyState = dealWithEmptyState;
// this.assignErrorState = assignErrorState;
// this.loadingCoordinator = loadingCoordinator;
// this.networkingErrorFeedback = networkingErrorFeedback;
// this.refreshToogle = refreshToogle;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .compose(dealWithEmptyState)
// .compose(assignErrorState)
// .compose(loadingCoordinator)
// .compose(refreshToogle)
// .compose(networkingErrorFeedback);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/FactAboutNumber.java
// public class FactAboutNumber {
//
// public String number;
// public String fact;
//
// private FactAboutNumber(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// public static FactAboutNumber of(String number, String fact) {
// return new FactAboutNumber(number, fact);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/DomainToViewModel.java
// public interface DomainToViewModel<Data, ViewModel> {
//
// ViewModel translate(Data data);
//
// }
| import br.ufs.demos.rxmvp.playground.core.behaviours.BehavioursCoordinator;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import br.ufs.demos.rxmvp.playground.trivia.domain.FactAboutNumber;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.util.DomainToViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable; | package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public class FactsPresenter {
private GetRandomFacts usecase;
private DisplayFactsView view; | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java
// public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
//
// private AssignEmptyState<T> dealWithEmptyState;
// private AssignErrorState<T> assignErrorState;
// private LoadingCoordination<T> loadingCoordinator;
// private NetworkingErrorFeedback<T> networkingErrorFeedback;
// private RefreshToogle<T> refreshToogle;
//
// public BehavioursCoordinator(AssignEmptyState<T> dealWithEmptyState,
// AssignErrorState<T> assignErrorState,
// LoadingCoordination<T> loadingCoordinator,
// NetworkingErrorFeedback<T> networkingErrorFeedback,
// RefreshToogle<T> refreshToogle) {
//
// this.dealWithEmptyState = dealWithEmptyState;
// this.assignErrorState = assignErrorState;
// this.loadingCoordinator = loadingCoordinator;
// this.networkingErrorFeedback = networkingErrorFeedback;
// this.refreshToogle = refreshToogle;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .compose(dealWithEmptyState)
// .compose(assignErrorState)
// .compose(loadingCoordinator)
// .compose(refreshToogle)
// .compose(networkingErrorFeedback);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/FactAboutNumber.java
// public class FactAboutNumber {
//
// public String number;
// public String fact;
//
// private FactAboutNumber(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// public static FactAboutNumber of(String number, String fact) {
// return new FactAboutNumber(number, fact);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/DomainToViewModel.java
// public interface DomainToViewModel<Data, ViewModel> {
//
// ViewModel translate(Data data);
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsPresenter.java
import br.ufs.demos.rxmvp.playground.core.behaviours.BehavioursCoordinator;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import br.ufs.demos.rxmvp.playground.trivia.domain.FactAboutNumber;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.util.DomainToViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public class FactsPresenter {
private GetRandomFacts usecase;
private DisplayFactsView view; | private BehavioursCoordinator<FactAboutNumber> coordinator; |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsPresenter.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java
// public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
//
// private AssignEmptyState<T> dealWithEmptyState;
// private AssignErrorState<T> assignErrorState;
// private LoadingCoordination<T> loadingCoordinator;
// private NetworkingErrorFeedback<T> networkingErrorFeedback;
// private RefreshToogle<T> refreshToogle;
//
// public BehavioursCoordinator(AssignEmptyState<T> dealWithEmptyState,
// AssignErrorState<T> assignErrorState,
// LoadingCoordination<T> loadingCoordinator,
// NetworkingErrorFeedback<T> networkingErrorFeedback,
// RefreshToogle<T> refreshToogle) {
//
// this.dealWithEmptyState = dealWithEmptyState;
// this.assignErrorState = assignErrorState;
// this.loadingCoordinator = loadingCoordinator;
// this.networkingErrorFeedback = networkingErrorFeedback;
// this.refreshToogle = refreshToogle;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .compose(dealWithEmptyState)
// .compose(assignErrorState)
// .compose(loadingCoordinator)
// .compose(refreshToogle)
// .compose(networkingErrorFeedback);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/FactAboutNumber.java
// public class FactAboutNumber {
//
// public String number;
// public String fact;
//
// private FactAboutNumber(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// public static FactAboutNumber of(String number, String fact) {
// return new FactAboutNumber(number, fact);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/DomainToViewModel.java
// public interface DomainToViewModel<Data, ViewModel> {
//
// ViewModel translate(Data data);
//
// }
| import br.ufs.demos.rxmvp.playground.core.behaviours.BehavioursCoordinator;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import br.ufs.demos.rxmvp.playground.trivia.domain.FactAboutNumber;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.util.DomainToViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable; | package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public class FactsPresenter {
private GetRandomFacts usecase;
private DisplayFactsView view;
private BehavioursCoordinator<FactAboutNumber> coordinator; | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java
// public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
//
// private AssignEmptyState<T> dealWithEmptyState;
// private AssignErrorState<T> assignErrorState;
// private LoadingCoordination<T> loadingCoordinator;
// private NetworkingErrorFeedback<T> networkingErrorFeedback;
// private RefreshToogle<T> refreshToogle;
//
// public BehavioursCoordinator(AssignEmptyState<T> dealWithEmptyState,
// AssignErrorState<T> assignErrorState,
// LoadingCoordination<T> loadingCoordinator,
// NetworkingErrorFeedback<T> networkingErrorFeedback,
// RefreshToogle<T> refreshToogle) {
//
// this.dealWithEmptyState = dealWithEmptyState;
// this.assignErrorState = assignErrorState;
// this.loadingCoordinator = loadingCoordinator;
// this.networkingErrorFeedback = networkingErrorFeedback;
// this.refreshToogle = refreshToogle;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .compose(dealWithEmptyState)
// .compose(assignErrorState)
// .compose(loadingCoordinator)
// .compose(refreshToogle)
// .compose(networkingErrorFeedback);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/FactAboutNumber.java
// public class FactAboutNumber {
//
// public String number;
// public String fact;
//
// private FactAboutNumber(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// public static FactAboutNumber of(String number, String fact) {
// return new FactAboutNumber(number, fact);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/DomainToViewModel.java
// public interface DomainToViewModel<Data, ViewModel> {
//
// ViewModel translate(Data data);
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsPresenter.java
import br.ufs.demos.rxmvp.playground.core.behaviours.BehavioursCoordinator;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import br.ufs.demos.rxmvp.playground.trivia.domain.FactAboutNumber;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.util.DomainToViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public class FactsPresenter {
private GetRandomFacts usecase;
private DisplayFactsView view;
private BehavioursCoordinator<FactAboutNumber> coordinator; | private LifecycleStrategist strategist; |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsPresenter.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java
// public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
//
// private AssignEmptyState<T> dealWithEmptyState;
// private AssignErrorState<T> assignErrorState;
// private LoadingCoordination<T> loadingCoordinator;
// private NetworkingErrorFeedback<T> networkingErrorFeedback;
// private RefreshToogle<T> refreshToogle;
//
// public BehavioursCoordinator(AssignEmptyState<T> dealWithEmptyState,
// AssignErrorState<T> assignErrorState,
// LoadingCoordination<T> loadingCoordinator,
// NetworkingErrorFeedback<T> networkingErrorFeedback,
// RefreshToogle<T> refreshToogle) {
//
// this.dealWithEmptyState = dealWithEmptyState;
// this.assignErrorState = assignErrorState;
// this.loadingCoordinator = loadingCoordinator;
// this.networkingErrorFeedback = networkingErrorFeedback;
// this.refreshToogle = refreshToogle;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .compose(dealWithEmptyState)
// .compose(assignErrorState)
// .compose(loadingCoordinator)
// .compose(refreshToogle)
// .compose(networkingErrorFeedback);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/FactAboutNumber.java
// public class FactAboutNumber {
//
// public String number;
// public String fact;
//
// private FactAboutNumber(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// public static FactAboutNumber of(String number, String fact) {
// return new FactAboutNumber(number, fact);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/DomainToViewModel.java
// public interface DomainToViewModel<Data, ViewModel> {
//
// ViewModel translate(Data data);
//
// }
| import br.ufs.demos.rxmvp.playground.core.behaviours.BehavioursCoordinator;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import br.ufs.demos.rxmvp.playground.trivia.domain.FactAboutNumber;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.util.DomainToViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable; | package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public class FactsPresenter {
private GetRandomFacts usecase;
private DisplayFactsView view;
private BehavioursCoordinator<FactAboutNumber> coordinator;
private LifecycleStrategist strategist; | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java
// public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
//
// private AssignEmptyState<T> dealWithEmptyState;
// private AssignErrorState<T> assignErrorState;
// private LoadingCoordination<T> loadingCoordinator;
// private NetworkingErrorFeedback<T> networkingErrorFeedback;
// private RefreshToogle<T> refreshToogle;
//
// public BehavioursCoordinator(AssignEmptyState<T> dealWithEmptyState,
// AssignErrorState<T> assignErrorState,
// LoadingCoordination<T> loadingCoordinator,
// NetworkingErrorFeedback<T> networkingErrorFeedback,
// RefreshToogle<T> refreshToogle) {
//
// this.dealWithEmptyState = dealWithEmptyState;
// this.assignErrorState = assignErrorState;
// this.loadingCoordinator = loadingCoordinator;
// this.networkingErrorFeedback = networkingErrorFeedback;
// this.refreshToogle = refreshToogle;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .compose(dealWithEmptyState)
// .compose(assignErrorState)
// .compose(loadingCoordinator)
// .compose(refreshToogle)
// .compose(networkingErrorFeedback);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/FactAboutNumber.java
// public class FactAboutNumber {
//
// public String number;
// public String fact;
//
// private FactAboutNumber(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// public static FactAboutNumber of(String number, String fact) {
// return new FactAboutNumber(number, fact);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/DomainToViewModel.java
// public interface DomainToViewModel<Data, ViewModel> {
//
// ViewModel translate(Data data);
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsPresenter.java
import br.ufs.demos.rxmvp.playground.core.behaviours.BehavioursCoordinator;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import br.ufs.demos.rxmvp.playground.trivia.domain.FactAboutNumber;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.util.DomainToViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public class FactsPresenter {
private GetRandomFacts usecase;
private DisplayFactsView view;
private BehavioursCoordinator<FactAboutNumber> coordinator;
private LifecycleStrategist strategist; | private DomainToViewModel<FactAboutNumber, FactViewModel> mapper; |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsPresenter.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java
// public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
//
// private AssignEmptyState<T> dealWithEmptyState;
// private AssignErrorState<T> assignErrorState;
// private LoadingCoordination<T> loadingCoordinator;
// private NetworkingErrorFeedback<T> networkingErrorFeedback;
// private RefreshToogle<T> refreshToogle;
//
// public BehavioursCoordinator(AssignEmptyState<T> dealWithEmptyState,
// AssignErrorState<T> assignErrorState,
// LoadingCoordination<T> loadingCoordinator,
// NetworkingErrorFeedback<T> networkingErrorFeedback,
// RefreshToogle<T> refreshToogle) {
//
// this.dealWithEmptyState = dealWithEmptyState;
// this.assignErrorState = assignErrorState;
// this.loadingCoordinator = loadingCoordinator;
// this.networkingErrorFeedback = networkingErrorFeedback;
// this.refreshToogle = refreshToogle;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .compose(dealWithEmptyState)
// .compose(assignErrorState)
// .compose(loadingCoordinator)
// .compose(refreshToogle)
// .compose(networkingErrorFeedback);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/FactAboutNumber.java
// public class FactAboutNumber {
//
// public String number;
// public String fact;
//
// private FactAboutNumber(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// public static FactAboutNumber of(String number, String fact) {
// return new FactAboutNumber(number, fact);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/DomainToViewModel.java
// public interface DomainToViewModel<Data, ViewModel> {
//
// ViewModel translate(Data data);
//
// }
| import br.ufs.demos.rxmvp.playground.core.behaviours.BehavioursCoordinator;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import br.ufs.demos.rxmvp.playground.trivia.domain.FactAboutNumber;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.util.DomainToViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable; | package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public class FactsPresenter {
private GetRandomFacts usecase;
private DisplayFactsView view;
private BehavioursCoordinator<FactAboutNumber> coordinator;
private LifecycleStrategist strategist; | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/BehavioursCoordinator.java
// public class BehavioursCoordinator<T> implements FlowableTransformer<T, T> {
//
// private AssignEmptyState<T> dealWithEmptyState;
// private AssignErrorState<T> assignErrorState;
// private LoadingCoordination<T> loadingCoordinator;
// private NetworkingErrorFeedback<T> networkingErrorFeedback;
// private RefreshToogle<T> refreshToogle;
//
// public BehavioursCoordinator(AssignEmptyState<T> dealWithEmptyState,
// AssignErrorState<T> assignErrorState,
// LoadingCoordination<T> loadingCoordinator,
// NetworkingErrorFeedback<T> networkingErrorFeedback,
// RefreshToogle<T> refreshToogle) {
//
// this.dealWithEmptyState = dealWithEmptyState;
// this.assignErrorState = assignErrorState;
// this.loadingCoordinator = loadingCoordinator;
// this.networkingErrorFeedback = networkingErrorFeedback;
// this.refreshToogle = refreshToogle;
// }
//
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream
// .compose(dealWithEmptyState)
// .compose(assignErrorState)
// .compose(loadingCoordinator)
// .compose(refreshToogle)
// .compose(networkingErrorFeedback);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/lifecycles/LifecycleStrategist.java
// public class LifecycleStrategist {
//
// private DisposeStrategy strategy;
//
// public LifecycleStrategist(LifecycleOwner owner, DisposeStrategy strategy) {
// this.strategy = strategy;
// owner.getLifecycle().addObserver(strategy);
// }
//
// public void applyStrategy(Disposable toDispose) {
// strategy.addDisposable(toDispose);
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/FactAboutNumber.java
// public class FactAboutNumber {
//
// public String number;
// public String fact;
//
// private FactAboutNumber(String number, String fact) {
// this.number = number;
// this.fact = fact;
// }
//
// public static FactAboutNumber of(String number, String fact) {
// return new FactAboutNumber(number, fact);
// }
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/GetRandomFacts.java
// public interface GetRandomFacts {
//
// Flowable<FactAboutNumber> fetchTrivia();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
//
// int TYPE_TWO_LABELS = 0;
// int TYPE_SINGLE_LABEL = 1;
//
// CharSequence formattedFact();
//
// int viewType();
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/DomainToViewModel.java
// public interface DomainToViewModel<Data, ViewModel> {
//
// ViewModel translate(Data data);
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsPresenter.java
import br.ufs.demos.rxmvp.playground.core.behaviours.BehavioursCoordinator;
import br.ufs.demos.rxmvp.playground.core.lifecycles.LifecycleStrategist;
import br.ufs.demos.rxmvp.playground.trivia.domain.FactAboutNumber;
import br.ufs.demos.rxmvp.playground.trivia.domain.GetRandomFacts;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.util.DomainToViewModel;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
package br.ufs.demos.rxmvp.playground.trivia.presentation;
/**
* Created by bira on 6/29/17.
*/
public class FactsPresenter {
private GetRandomFacts usecase;
private DisplayFactsView view;
private BehavioursCoordinator<FactAboutNumber> coordinator;
private LifecycleStrategist strategist; | private DomainToViewModel<FactAboutNumber, FactViewModel> mapper; |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/ActivitiesBuilder.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/ui/FactsAboutNumbersActivity.java
// public class FactsAboutNumbersActivity
// extends AppCompatActivity implements DisplayFactsView {
//
// private static final String TAG = FactsAboutNumbersActivity.class.getSimpleName();
//
// @BindView(R.id.recyclerview_facts) public RecyclerView factsView;
// @BindView(R.id.container) View container;
// @BindView(R.id.label_feedback_message) TextView feedbackMessage;
// @BindView(R.id.progressBar) ProgressBar loading;
// @BindView(R.id.fab) FloatingActionButton fab;
//
// @Inject FactsPresenter presenter;
//
// public FactsAdapter adapter;
//
// @Override protected void onCreate(Bundle savedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
// ButterKnife.bind(this);
// setupViews();
// }
//
// @Override protected void onResume() {
// super.onResume();
// newTrivia();
// }
//
// @Override public Action showLoading() {
// return () -> loading.setVisibility(View.VISIBLE);
// }
//
// @Override public Action hideLoading() {
// return () -> loading.setVisibility(View.GONE);
// }
//
// @Override public Action showEmptyState() {
// return () -> {
// feedbackMessage.setVisibility(View.VISIBLE);
// feedbackMessage.setText(R.string.feedback_empty_state);
// };
// }
//
// @Override public Action hideEmptyState() {
// return () -> feedbackMessage.setVisibility(View.GONE);
// }
//
// @Override public Action showErrorState() {
// return () -> {
// feedbackMessage.setVisibility(View.VISIBLE);
// feedbackMessage.setText(R.string.feedback_error_state);
// };
// }
//
// @Override public Action hideErrorState() {
// return () -> feedbackMessage.setVisibility(View.GONE);
// }
//
// @Override public Action reportNetworkingError() {
// return () ->
// Snackbar.make(container, R.string.feedback_message_internet_issue, LENGTH_INDEFINITE)
// .setAction("TENTAR NOVAMENTE", view -> newTrivia())
// .show();
// }
//
// @Override public Action disableRefresh() {
// return () -> fab.setVisibility(View.GONE);
// }
//
// @Override public Action enableRefresh() {
// return () -> fab.setVisibility(View.VISIBLE);
// }
//
// @Override public Disposable subscribeInto(Flowable<FactViewModel> flow) {
// adapter.clear();
// return flow
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(
// model -> adapter.addModel(model),
// throwable -> Log.e(TAG, "Error -> " + throwable.getMessage()),
// () -> Log.i(TAG, "Done")
// );
// }
//
// private void setupViews() {
// fab.setOnClickListener(view -> newTrivia());
// adapter = new FactsAdapter(LayoutInflater.from(this));
// factsView.setLayoutManager(new LinearLayoutManager(this));
// factsView.setAdapter(adapter);
// }
//
// private void newTrivia() {
// if (presenter != null) presenter.fetchRandomFacts();
// }
//
// }
| import br.ufs.demos.rxmvp.playground.trivia.ui.FactsAboutNumbersActivity;
import dagger.Module;
import dagger.android.ContributesAndroidInjector; | package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 6/26/17.
*/
@Module
public abstract class ActivitiesBuilder {
@ContributesAndroidInjector(modules = FactsAboutNumbersModule.class) | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/ui/FactsAboutNumbersActivity.java
// public class FactsAboutNumbersActivity
// extends AppCompatActivity implements DisplayFactsView {
//
// private static final String TAG = FactsAboutNumbersActivity.class.getSimpleName();
//
// @BindView(R.id.recyclerview_facts) public RecyclerView factsView;
// @BindView(R.id.container) View container;
// @BindView(R.id.label_feedback_message) TextView feedbackMessage;
// @BindView(R.id.progressBar) ProgressBar loading;
// @BindView(R.id.fab) FloatingActionButton fab;
//
// @Inject FactsPresenter presenter;
//
// public FactsAdapter adapter;
//
// @Override protected void onCreate(Bundle savedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
// ButterKnife.bind(this);
// setupViews();
// }
//
// @Override protected void onResume() {
// super.onResume();
// newTrivia();
// }
//
// @Override public Action showLoading() {
// return () -> loading.setVisibility(View.VISIBLE);
// }
//
// @Override public Action hideLoading() {
// return () -> loading.setVisibility(View.GONE);
// }
//
// @Override public Action showEmptyState() {
// return () -> {
// feedbackMessage.setVisibility(View.VISIBLE);
// feedbackMessage.setText(R.string.feedback_empty_state);
// };
// }
//
// @Override public Action hideEmptyState() {
// return () -> feedbackMessage.setVisibility(View.GONE);
// }
//
// @Override public Action showErrorState() {
// return () -> {
// feedbackMessage.setVisibility(View.VISIBLE);
// feedbackMessage.setText(R.string.feedback_error_state);
// };
// }
//
// @Override public Action hideErrorState() {
// return () -> feedbackMessage.setVisibility(View.GONE);
// }
//
// @Override public Action reportNetworkingError() {
// return () ->
// Snackbar.make(container, R.string.feedback_message_internet_issue, LENGTH_INDEFINITE)
// .setAction("TENTAR NOVAMENTE", view -> newTrivia())
// .show();
// }
//
// @Override public Action disableRefresh() {
// return () -> fab.setVisibility(View.GONE);
// }
//
// @Override public Action enableRefresh() {
// return () -> fab.setVisibility(View.VISIBLE);
// }
//
// @Override public Disposable subscribeInto(Flowable<FactViewModel> flow) {
// adapter.clear();
// return flow
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(
// model -> adapter.addModel(model),
// throwable -> Log.e(TAG, "Error -> " + throwable.getMessage()),
// () -> Log.i(TAG, "Done")
// );
// }
//
// private void setupViews() {
// fab.setOnClickListener(view -> newTrivia());
// adapter = new FactsAdapter(LayoutInflater.from(this));
// factsView.setLayoutManager(new LinearLayoutManager(this));
// factsView.setAdapter(adapter);
// }
//
// private void newTrivia() {
// if (presenter != null) presenter.fetchRandomFacts();
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/dagger/modules/ActivitiesBuilder.java
import br.ufs.demos.rxmvp.playground.trivia.ui.FactsAboutNumbersActivity;
import dagger.Module;
import dagger.android.ContributesAndroidInjector;
package br.ufs.demos.rxmvp.playground.dagger.modules;
/**
* Created by bira on 6/26/17.
*/
@Module
public abstract class ActivitiesBuilder {
@ContributesAndroidInjector(modules = FactsAboutNumbersModule.class) | abstract FactsAboutNumbersActivity factsAboutNumbersActivity(); |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/NetworkingError.java
// public class NetworkingError extends RuntimeException {
//
// public NetworkingError(String message) {
// super(message);
// }
//
// }
| import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.NetworkingError;
import io.reactivex.Completable;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
import io.reactivex.Scheduler; | package br.ufs.demos.rxmvp.playground.core.behaviours.networking;
/**
* Created by bira on 7/5/17.
*/
public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
private NetworkingErrorView view;
private Scheduler uiScheduler;
public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
this.view = view;
this.uiScheduler = uiScheduler;
}
@Override public Publisher<T> apply(Flowable<T> upstream) {
return upstream.doOnError(this::handleIfNetworkingError);
}
private Publisher<T> handleIfNetworkingError(Throwable throwable) {
| // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/NetworkingError.java
// public class NetworkingError extends RuntimeException {
//
// public NetworkingError(String message) {
// super(message);
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/networking/NetworkingErrorFeedback.java
import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.NetworkingError;
import io.reactivex.Completable;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
import io.reactivex.Scheduler;
package br.ufs.demos.rxmvp.playground.core.behaviours.networking;
/**
* Created by bira on 7/5/17.
*/
public class NetworkingErrorFeedback<T> implements FlowableTransformer<T, T> {
private NetworkingErrorView view;
private Scheduler uiScheduler;
public NetworkingErrorFeedback(NetworkingErrorView view, Scheduler uiScheduler) {
this.view = view;
this.uiScheduler = uiScheduler;
}
@Override public Publisher<T> apply(Flowable<T> upstream) {
return upstream.doOnError(this::handleIfNetworkingError);
}
private Publisher<T> handleIfNetworkingError(Throwable throwable) {
| if (throwable instanceof NetworkingError) { |
ubiratansoares/reactive-architectures-playground | app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/NumbersTriviaPayload.java
// public class NumbersTriviaPayload extends HashMap<String, String> {
//
// // Shame on me by my lazyness ....
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
| import br.ufs.demos.rxmvp.playground.trivia.infrastructure.NumbersTriviaPayload;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import io.reactivex.Flowable; | package br.ufs.demos.rxmvp.playground.fakes;
/**
* Created by bira on 10/3/17.
*/
public class FakeWebService implements NumbersWebService {
public enum NextCall {
UNDEFINED_ERROR,
CONNECTION_ERROR,
CONNECTION_TIMEOUT,
INTERNAL_SERVER_ERROR_5xy,
NOT_FOUND_404,
SUCCESS_200
}
private NextCall nextReturn;
public FakeWebService() {
nextReturn = NextCall.UNDEFINED_ERROR;
}
public void nextCallPerform(NextCall nextReturn) {
this.nextReturn = nextReturn;
}
| // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/infrastructure/NumbersTriviaPayload.java
// public class NumbersTriviaPayload extends HashMap<String, String> {
//
// // Shame on me by my lazyness ....
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
//
// String BASE_URL = "http://numbersapi.com";
//
// @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
// @Path("numbers") String commaSeparatedNumbers
// );
//
// }
// Path: app/src/mock/java/br/ufs/demos/rxmvp/playground/fakes/FakeWebService.java
import br.ufs.demos.rxmvp.playground.trivia.infrastructure.NumbersTriviaPayload;
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import io.reactivex.Flowable;
package br.ufs.demos.rxmvp.playground.fakes;
/**
* Created by bira on 10/3/17.
*/
public class FakeWebService implements NumbersWebService {
public enum NextCall {
UNDEFINED_ERROR,
CONNECTION_ERROR,
CONNECTION_TIMEOUT,
INTERNAL_SERVER_ERROR_5xy,
NOT_FOUND_404,
SUCCESS_200
}
private NextCall nextReturn;
public FakeWebService() {
nextReturn = NextCall.UNDEFINED_ERROR;
}
public void nextCallPerform(NextCall nextReturn) {
this.nextReturn = nextReturn;
}
| @Override public Flowable<NumbersTriviaPayload> getTrivia(String commaSeparatedNumbers) { |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/core/infraerrors/RestErrorsHandler.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
| import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
import retrofit2.HttpException; | package br.ufs.demos.rxmvp.playground.core.infraerrors;
/**
* Created by bira on 6/29/17.
*/
public class RestErrorsHandler<T> implements FlowableTransformer<T, T> {
@Override public Publisher<T> apply(Flowable<T> upstream) {
return upstream.onErrorResumeNext(this::handleIfRestError);
}
private Publisher<T> handleIfRestError(Throwable throwable) {
if (otherThanNotFound(throwable)) { | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/infraerrors/RestErrorsHandler.java
import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
import retrofit2.HttpException;
package br.ufs.demos.rxmvp.playground.core.infraerrors;
/**
* Created by bira on 6/29/17.
*/
public class RestErrorsHandler<T> implements FlowableTransformer<T, T> {
@Override public Publisher<T> apply(Flowable<T> upstream) {
return upstream.onErrorResumeNext(this::handleIfRestError);
}
private Publisher<T> handleIfRestError(Throwable throwable) {
if (otherThanNotFound(throwable)) { | return Flowable.error(new UnexpectedResponseError("Undesired response for this call")); |
ubiratansoares/reactive-architectures-playground | app/src/main/java/br/ufs/demos/rxmvp/playground/core/infraerrors/RestErrorsHandler.java | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
| import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
import retrofit2.HttpException; | package br.ufs.demos.rxmvp.playground.core.infraerrors;
/**
* Created by bira on 6/29/17.
*/
public class RestErrorsHandler<T> implements FlowableTransformer<T, T> {
@Override public Publisher<T> apply(Flowable<T> upstream) {
return upstream.onErrorResumeNext(this::handleIfRestError);
}
private Publisher<T> handleIfRestError(Throwable throwable) {
if (otherThanNotFound(throwable)) {
return Flowable.error(new UnexpectedResponseError("Undesired response for this call"));
}
if (notFound(throwable)) { | // Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/ContentNotFoundError.java
// public class ContentNotFoundError extends RuntimeException {
//
// @Override public String getMessage() {
// return "No content available";
// }
//
// }
//
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errors/UnexpectedResponseError.java
// public class UnexpectedResponseError extends RuntimeException {
//
// public UnexpectedResponseError(String message) {
// super(message);
// }
//
// }
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/infraerrors/RestErrorsHandler.java
import org.reactivestreams.Publisher;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.ContentNotFoundError;
import br.ufs.demos.rxmvp.playground.core.behaviours.errors.UnexpectedResponseError;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
import retrofit2.HttpException;
package br.ufs.demos.rxmvp.playground.core.infraerrors;
/**
* Created by bira on 6/29/17.
*/
public class RestErrorsHandler<T> implements FlowableTransformer<T, T> {
@Override public Publisher<T> apply(Flowable<T> upstream) {
return upstream.onErrorResumeNext(this::handleIfRestError);
}
private Publisher<T> handleIfRestError(Throwable throwable) {
if (otherThanNotFound(throwable)) {
return Flowable.error(new UnexpectedResponseError("Undesired response for this call"));
}
if (notFound(throwable)) { | return Flowable.error(new ContentNotFoundError()); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.