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
|
---|---|---|---|---|---|---|
07kit/07kit
|
src/main/java/com/kit/api/collection/queries/Query.java
|
// Path: src/main/java/com/kit/api/collection/Filter.java
// public interface Filter<T> {
//
// /**
// * Filter function
// *
// * @param acceptable an item that can be filtered
// * @return true if item should be retained, false otherwise.
// */
// boolean accept(T acceptable);
//
// static <T> Filter<T> collapse(List<Filter<T>> filters) {
// return acceptable -> {
// for (Filter<T> filter : filters) {
// if (!filter.accept(acceptable)) {
// return false;
// }
// }
// return true;
// };
// }
//
// }
//
// Path: src/main/java/com/kit/api/collection/Filter.java
// public interface Filter<T> {
//
// /**
// * Filter function
// *
// * @param acceptable an item that can be filtered
// * @return true if item should be retained, false otherwise.
// */
// boolean accept(T acceptable);
//
// static <T> Filter<T> collapse(List<Filter<T>> filters) {
// return acceptable -> {
// for (Filter<T> filter : filters) {
// if (!filter.accept(acceptable)) {
// return false;
// }
// }
// return true;
// };
// }
//
// }
|
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.kit.api.collection.Filter;
import com.kit.api.collection.Filter;
import java.util.*;
import static com.google.common.collect.Lists.newArrayList;
|
package com.kit.api.collection.queries;
/**
* An abstract base class for queries
*
*/
public abstract class Query<T> implements Iterable<T> {
static final Map<String, Query> prepared = new HashMap<String, Query>();
List<Comparator<T>> orderings = new ArrayList<Comparator<T>>();
|
// Path: src/main/java/com/kit/api/collection/Filter.java
// public interface Filter<T> {
//
// /**
// * Filter function
// *
// * @param acceptable an item that can be filtered
// * @return true if item should be retained, false otherwise.
// */
// boolean accept(T acceptable);
//
// static <T> Filter<T> collapse(List<Filter<T>> filters) {
// return acceptable -> {
// for (Filter<T> filter : filters) {
// if (!filter.accept(acceptable)) {
// return false;
// }
// }
// return true;
// };
// }
//
// }
//
// Path: src/main/java/com/kit/api/collection/Filter.java
// public interface Filter<T> {
//
// /**
// * Filter function
// *
// * @param acceptable an item that can be filtered
// * @return true if item should be retained, false otherwise.
// */
// boolean accept(T acceptable);
//
// static <T> Filter<T> collapse(List<Filter<T>> filters) {
// return acceptable -> {
// for (Filter<T> filter : filters) {
// if (!filter.accept(acceptable)) {
// return false;
// }
// }
// return true;
// };
// }
//
// }
// Path: src/main/java/com/kit/api/collection/queries/Query.java
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.kit.api.collection.Filter;
import com.kit.api.collection.Filter;
import java.util.*;
import static com.google.common.collect.Lists.newArrayList;
package com.kit.api.collection.queries;
/**
* An abstract base class for queries
*
*/
public abstract class Query<T> implements Iterable<T> {
static final Map<String, Query> prepared = new HashMap<String, Query>();
List<Comparator<T>> orderings = new ArrayList<Comparator<T>>();
|
List<Filter<T>> filters = new ArrayList<Filter<T>>();
|
07kit/07kit
|
src/main/java/com/kit/api/Players.java
|
// Path: src/main/java/com/kit/api/collection/Filter.java
// public interface Filter<T> {
//
// /**
// * Filter function
// *
// * @param acceptable an item that can be filtered
// * @return true if item should be retained, false otherwise.
// */
// boolean accept(T acceptable);
//
// static <T> Filter<T> collapse(List<Filter<T>> filters) {
// return acceptable -> {
// for (Filter<T> filter : filters) {
// if (!filter.accept(acceptable)) {
// return false;
// }
// }
// return true;
// };
// }
//
// }
//
// Path: src/main/java/com/kit/api/collection/queries/PlayerQuery.java
// public class PlayerQuery extends EntityQuery<Player, PlayerQuery> {
//
// public PlayerQuery(MethodContext context) {
// super(context);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Player single() {
// List<Player> players = asList();
// return !players.isEmpty() ? players.get(0) : null;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public List<Player> asList() {
// List<Player> all = context.players.getAll(filters);
// Collections.sort(all, new Comparator<Player>() {
// @Override
// public int compare(Player o1, Player o2) {
// int dist1 = o1.distanceTo(context.players.getLocal());
// int dist2 = o2.distanceTo(context.players.getLocal());
// return dist1 - dist2;
// }
// });
// return all;
// }
//
// public PlayerQuery levelBetween(int lower, int higher) {
// addCondition(acceptable -> acceptable.getCombatLevel() >= lower && acceptable.getCombatLevel() <= higher);
// return this;
// }
// }
|
import com.kit.api.collection.Filter;
import com.kit.api.collection.queries.PlayerQuery;
import com.kit.api.wrappers.Player;
import com.kit.api.wrappers.Region;
import java.util.List;
|
package com.kit.api;
/**
* Methods for dealing with Players in the game.
*
*/
public interface Players {
/**
* Gets the currently logged in player
*
* @return local player
*/
Player getLocal();
/**
* Gets all players within the current region.
*
* @return players
*/
List<Player> getAll();
/**
* Gets a new PlayerQuery which can be used for
* finding and selecting players matching certain
* conditions.
*
* @return query
*/
|
// Path: src/main/java/com/kit/api/collection/Filter.java
// public interface Filter<T> {
//
// /**
// * Filter function
// *
// * @param acceptable an item that can be filtered
// * @return true if item should be retained, false otherwise.
// */
// boolean accept(T acceptable);
//
// static <T> Filter<T> collapse(List<Filter<T>> filters) {
// return acceptable -> {
// for (Filter<T> filter : filters) {
// if (!filter.accept(acceptable)) {
// return false;
// }
// }
// return true;
// };
// }
//
// }
//
// Path: src/main/java/com/kit/api/collection/queries/PlayerQuery.java
// public class PlayerQuery extends EntityQuery<Player, PlayerQuery> {
//
// public PlayerQuery(MethodContext context) {
// super(context);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Player single() {
// List<Player> players = asList();
// return !players.isEmpty() ? players.get(0) : null;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public List<Player> asList() {
// List<Player> all = context.players.getAll(filters);
// Collections.sort(all, new Comparator<Player>() {
// @Override
// public int compare(Player o1, Player o2) {
// int dist1 = o1.distanceTo(context.players.getLocal());
// int dist2 = o2.distanceTo(context.players.getLocal());
// return dist1 - dist2;
// }
// });
// return all;
// }
//
// public PlayerQuery levelBetween(int lower, int higher) {
// addCondition(acceptable -> acceptable.getCombatLevel() >= lower && acceptable.getCombatLevel() <= higher);
// return this;
// }
// }
// Path: src/main/java/com/kit/api/Players.java
import com.kit.api.collection.Filter;
import com.kit.api.collection.queries.PlayerQuery;
import com.kit.api.wrappers.Player;
import com.kit.api.wrappers.Region;
import java.util.List;
package com.kit.api;
/**
* Methods for dealing with Players in the game.
*
*/
public interface Players {
/**
* Gets the currently logged in player
*
* @return local player
*/
Player getLocal();
/**
* Gets all players within the current region.
*
* @return players
*/
List<Player> getAll();
/**
* Gets a new PlayerQuery which can be used for
* finding and selecting players matching certain
* conditions.
*
* @return query
*/
|
PlayerQuery find();
|
07kit/07kit
|
src/main/java/com/kit/api/Players.java
|
// Path: src/main/java/com/kit/api/collection/Filter.java
// public interface Filter<T> {
//
// /**
// * Filter function
// *
// * @param acceptable an item that can be filtered
// * @return true if item should be retained, false otherwise.
// */
// boolean accept(T acceptable);
//
// static <T> Filter<T> collapse(List<Filter<T>> filters) {
// return acceptable -> {
// for (Filter<T> filter : filters) {
// if (!filter.accept(acceptable)) {
// return false;
// }
// }
// return true;
// };
// }
//
// }
//
// Path: src/main/java/com/kit/api/collection/queries/PlayerQuery.java
// public class PlayerQuery extends EntityQuery<Player, PlayerQuery> {
//
// public PlayerQuery(MethodContext context) {
// super(context);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Player single() {
// List<Player> players = asList();
// return !players.isEmpty() ? players.get(0) : null;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public List<Player> asList() {
// List<Player> all = context.players.getAll(filters);
// Collections.sort(all, new Comparator<Player>() {
// @Override
// public int compare(Player o1, Player o2) {
// int dist1 = o1.distanceTo(context.players.getLocal());
// int dist2 = o2.distanceTo(context.players.getLocal());
// return dist1 - dist2;
// }
// });
// return all;
// }
//
// public PlayerQuery levelBetween(int lower, int higher) {
// addCondition(acceptable -> acceptable.getCombatLevel() >= lower && acceptable.getCombatLevel() <= higher);
// return this;
// }
// }
|
import com.kit.api.collection.Filter;
import com.kit.api.collection.queries.PlayerQuery;
import com.kit.api.wrappers.Player;
import com.kit.api.wrappers.Region;
import java.util.List;
|
package com.kit.api;
/**
* Methods for dealing with Players in the game.
*
*/
public interface Players {
/**
* Gets the currently logged in player
*
* @return local player
*/
Player getLocal();
/**
* Gets all players within the current region.
*
* @return players
*/
List<Player> getAll();
/**
* Gets a new PlayerQuery which can be used for
* finding and selecting players matching certain
* conditions.
*
* @return query
*/
PlayerQuery find();
/**
* Creates a query using a Player's most basic attribute, being it's name.
*
* @return query
*/
PlayerQuery find(String... names);
void loadPlayerPositions();
|
// Path: src/main/java/com/kit/api/collection/Filter.java
// public interface Filter<T> {
//
// /**
// * Filter function
// *
// * @param acceptable an item that can be filtered
// * @return true if item should be retained, false otherwise.
// */
// boolean accept(T acceptable);
//
// static <T> Filter<T> collapse(List<Filter<T>> filters) {
// return acceptable -> {
// for (Filter<T> filter : filters) {
// if (!filter.accept(acceptable)) {
// return false;
// }
// }
// return true;
// };
// }
//
// }
//
// Path: src/main/java/com/kit/api/collection/queries/PlayerQuery.java
// public class PlayerQuery extends EntityQuery<Player, PlayerQuery> {
//
// public PlayerQuery(MethodContext context) {
// super(context);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Player single() {
// List<Player> players = asList();
// return !players.isEmpty() ? players.get(0) : null;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public List<Player> asList() {
// List<Player> all = context.players.getAll(filters);
// Collections.sort(all, new Comparator<Player>() {
// @Override
// public int compare(Player o1, Player o2) {
// int dist1 = o1.distanceTo(context.players.getLocal());
// int dist2 = o2.distanceTo(context.players.getLocal());
// return dist1 - dist2;
// }
// });
// return all;
// }
//
// public PlayerQuery levelBetween(int lower, int higher) {
// addCondition(acceptable -> acceptable.getCombatLevel() >= lower && acceptable.getCombatLevel() <= higher);
// return this;
// }
// }
// Path: src/main/java/com/kit/api/Players.java
import com.kit.api.collection.Filter;
import com.kit.api.collection.queries.PlayerQuery;
import com.kit.api.wrappers.Player;
import com.kit.api.wrappers.Region;
import java.util.List;
package com.kit.api;
/**
* Methods for dealing with Players in the game.
*
*/
public interface Players {
/**
* Gets the currently logged in player
*
* @return local player
*/
Player getLocal();
/**
* Gets all players within the current region.
*
* @return players
*/
List<Player> getAll();
/**
* Gets a new PlayerQuery which can be used for
* finding and selecting players matching certain
* conditions.
*
* @return query
*/
PlayerQuery find();
/**
* Creates a query using a Player's most basic attribute, being it's name.
*
* @return query
*/
PlayerQuery find(String... names);
void loadPlayerPositions();
|
List<Player> getAll(List<Filter<Player>> filters);
|
07kit/07kit
|
src/main/java/com/kit/api/wrappers/WidgetGroup.java
|
// Path: src/main/java/com/kit/api/MethodContext.java
// public class MethodContext {
//
// public static final int FIXED_VIEWPORT_WIDTH = 512;
// public static final int FIXED_VIEWPORT_HEIGHT = 334;
//
//
// public Logger logger = new LoggerImpl();
//
//
// public LocalPlayer player = new LocalPlayer(this);
//
//
// public Viewport viewport = new ViewportImpl(this);
//
//
// public Widgets widgets = new WidgetsImpl(this);
//
//
// public Players players = new PlayersImpl(this);
//
//
// public Npcs npcs = new NpcsImpl(this);
//
//
// public Objects objects = new ObjectsImpl(this);
//
//
// public Loots loot = new LootsImpl(this);
//
//
// public Menu menu = new MenuImpl(this);
//
//
// public Worlds worlds = new WorldsImpl(this);
//
//
// public Inventory inventory = new InventoryImpl(this);
//
//
// public Equipment equipment = new EquipmentImpl(this);
//
//
// public Skills skills = new SkillsImpl(this);
//
//
// public Tabs tabs = new TabsImpl(this);
//
//
// public Camera camera = new CameraImpl(this);
//
//
// public Bank bank = new BankImpl(this);
//
//
// public Magic magic = new MagicImpl(this);
//
//
// public Minimap minimap = new MinimapImpl(this);
//
//
// public Mouse mouse = new MouseImpl(this);
//
//
// public Settings settings = new SettingsImpl(this);
//
// public Shops shops = new ShopsImpl(this);
//
//
// public Prayers prayers = new PrayersImpl(this);
//
//
// public Screen screen = new ScreenImpl(this);
//
// public Hiscores hiscores = new HiscoresImpl(this);
//
// public Composites composites = new CompositesImpl(this);
//
// public UserInterface ui = new UserInterfaceImpl();
//
// public Game game = new GameImpl(this);
//
// public Friends friends = new FriendsImpl(this);
//
// public ClanChat clanChat = new ClanChatImpl(this);
//
// public IClient client() {
// return Session.get().getClient();
// }
//
// public boolean inResizableMode() {
// return client().getViewportWidth() != FIXED_VIEWPORT_WIDTH ||
// client().getViewportHeight() != FIXED_VIEWPORT_HEIGHT;
// }
//
// public boolean isLoggedIn() {
// return client() != null &&
// client().getLoginIndex() >= 30 &&
// widgets.find(378, 6) == null;
// }
//
// }
//
// Path: src/main/java/com/kit/api/MethodContext.java
// public class MethodContext {
//
// public static final int FIXED_VIEWPORT_WIDTH = 512;
// public static final int FIXED_VIEWPORT_HEIGHT = 334;
//
//
// public Logger logger = new LoggerImpl();
//
//
// public LocalPlayer player = new LocalPlayer(this);
//
//
// public Viewport viewport = new ViewportImpl(this);
//
//
// public Widgets widgets = new WidgetsImpl(this);
//
//
// public Players players = new PlayersImpl(this);
//
//
// public Npcs npcs = new NpcsImpl(this);
//
//
// public Objects objects = new ObjectsImpl(this);
//
//
// public Loots loot = new LootsImpl(this);
//
//
// public Menu menu = new MenuImpl(this);
//
//
// public Worlds worlds = new WorldsImpl(this);
//
//
// public Inventory inventory = new InventoryImpl(this);
//
//
// public Equipment equipment = new EquipmentImpl(this);
//
//
// public Skills skills = new SkillsImpl(this);
//
//
// public Tabs tabs = new TabsImpl(this);
//
//
// public Camera camera = new CameraImpl(this);
//
//
// public Bank bank = new BankImpl(this);
//
//
// public Magic magic = new MagicImpl(this);
//
//
// public Minimap minimap = new MinimapImpl(this);
//
//
// public Mouse mouse = new MouseImpl(this);
//
//
// public Settings settings = new SettingsImpl(this);
//
// public Shops shops = new ShopsImpl(this);
//
//
// public Prayers prayers = new PrayersImpl(this);
//
//
// public Screen screen = new ScreenImpl(this);
//
// public Hiscores hiscores = new HiscoresImpl(this);
//
// public Composites composites = new CompositesImpl(this);
//
// public UserInterface ui = new UserInterfaceImpl();
//
// public Game game = new GameImpl(this);
//
// public Friends friends = new FriendsImpl(this);
//
// public ClanChat clanChat = new ClanChatImpl(this);
//
// public IClient client() {
// return Session.get().getClient();
// }
//
// public boolean inResizableMode() {
// return client().getViewportWidth() != FIXED_VIEWPORT_WIDTH ||
// client().getViewportHeight() != FIXED_VIEWPORT_HEIGHT;
// }
//
// public boolean isLoggedIn() {
// return client() != null &&
// client().getLoginIndex() >= 30 &&
// widgets.find(378, 6) == null;
// }
//
// }
|
import com.kit.api.MethodContext;
import com.kit.game.engine.media.IWidget;
import com.kit.api.MethodContext;
import com.kit.game.engine.media.IWidget;
import java.lang.ref.WeakReference;
|
package com.kit.api.wrappers;
/**
* A wrapper for a collection of widgets also known as a widget group
*
*/
public class WidgetGroup implements Wrapper<IWidget[]> {
private final WeakReference<IWidget[]> wrapped;
private final Widget[] widgets;
private final int index;
|
// Path: src/main/java/com/kit/api/MethodContext.java
// public class MethodContext {
//
// public static final int FIXED_VIEWPORT_WIDTH = 512;
// public static final int FIXED_VIEWPORT_HEIGHT = 334;
//
//
// public Logger logger = new LoggerImpl();
//
//
// public LocalPlayer player = new LocalPlayer(this);
//
//
// public Viewport viewport = new ViewportImpl(this);
//
//
// public Widgets widgets = new WidgetsImpl(this);
//
//
// public Players players = new PlayersImpl(this);
//
//
// public Npcs npcs = new NpcsImpl(this);
//
//
// public Objects objects = new ObjectsImpl(this);
//
//
// public Loots loot = new LootsImpl(this);
//
//
// public Menu menu = new MenuImpl(this);
//
//
// public Worlds worlds = new WorldsImpl(this);
//
//
// public Inventory inventory = new InventoryImpl(this);
//
//
// public Equipment equipment = new EquipmentImpl(this);
//
//
// public Skills skills = new SkillsImpl(this);
//
//
// public Tabs tabs = new TabsImpl(this);
//
//
// public Camera camera = new CameraImpl(this);
//
//
// public Bank bank = new BankImpl(this);
//
//
// public Magic magic = new MagicImpl(this);
//
//
// public Minimap minimap = new MinimapImpl(this);
//
//
// public Mouse mouse = new MouseImpl(this);
//
//
// public Settings settings = new SettingsImpl(this);
//
// public Shops shops = new ShopsImpl(this);
//
//
// public Prayers prayers = new PrayersImpl(this);
//
//
// public Screen screen = new ScreenImpl(this);
//
// public Hiscores hiscores = new HiscoresImpl(this);
//
// public Composites composites = new CompositesImpl(this);
//
// public UserInterface ui = new UserInterfaceImpl();
//
// public Game game = new GameImpl(this);
//
// public Friends friends = new FriendsImpl(this);
//
// public ClanChat clanChat = new ClanChatImpl(this);
//
// public IClient client() {
// return Session.get().getClient();
// }
//
// public boolean inResizableMode() {
// return client().getViewportWidth() != FIXED_VIEWPORT_WIDTH ||
// client().getViewportHeight() != FIXED_VIEWPORT_HEIGHT;
// }
//
// public boolean isLoggedIn() {
// return client() != null &&
// client().getLoginIndex() >= 30 &&
// widgets.find(378, 6) == null;
// }
//
// }
//
// Path: src/main/java/com/kit/api/MethodContext.java
// public class MethodContext {
//
// public static final int FIXED_VIEWPORT_WIDTH = 512;
// public static final int FIXED_VIEWPORT_HEIGHT = 334;
//
//
// public Logger logger = new LoggerImpl();
//
//
// public LocalPlayer player = new LocalPlayer(this);
//
//
// public Viewport viewport = new ViewportImpl(this);
//
//
// public Widgets widgets = new WidgetsImpl(this);
//
//
// public Players players = new PlayersImpl(this);
//
//
// public Npcs npcs = new NpcsImpl(this);
//
//
// public Objects objects = new ObjectsImpl(this);
//
//
// public Loots loot = new LootsImpl(this);
//
//
// public Menu menu = new MenuImpl(this);
//
//
// public Worlds worlds = new WorldsImpl(this);
//
//
// public Inventory inventory = new InventoryImpl(this);
//
//
// public Equipment equipment = new EquipmentImpl(this);
//
//
// public Skills skills = new SkillsImpl(this);
//
//
// public Tabs tabs = new TabsImpl(this);
//
//
// public Camera camera = new CameraImpl(this);
//
//
// public Bank bank = new BankImpl(this);
//
//
// public Magic magic = new MagicImpl(this);
//
//
// public Minimap minimap = new MinimapImpl(this);
//
//
// public Mouse mouse = new MouseImpl(this);
//
//
// public Settings settings = new SettingsImpl(this);
//
// public Shops shops = new ShopsImpl(this);
//
//
// public Prayers prayers = new PrayersImpl(this);
//
//
// public Screen screen = new ScreenImpl(this);
//
// public Hiscores hiscores = new HiscoresImpl(this);
//
// public Composites composites = new CompositesImpl(this);
//
// public UserInterface ui = new UserInterfaceImpl();
//
// public Game game = new GameImpl(this);
//
// public Friends friends = new FriendsImpl(this);
//
// public ClanChat clanChat = new ClanChatImpl(this);
//
// public IClient client() {
// return Session.get().getClient();
// }
//
// public boolean inResizableMode() {
// return client().getViewportWidth() != FIXED_VIEWPORT_WIDTH ||
// client().getViewportHeight() != FIXED_VIEWPORT_HEIGHT;
// }
//
// public boolean isLoggedIn() {
// return client() != null &&
// client().getLoginIndex() >= 30 &&
// widgets.find(378, 6) == null;
// }
//
// }
// Path: src/main/java/com/kit/api/wrappers/WidgetGroup.java
import com.kit.api.MethodContext;
import com.kit.game.engine.media.IWidget;
import com.kit.api.MethodContext;
import com.kit.game.engine.media.IWidget;
import java.lang.ref.WeakReference;
package com.kit.api.wrappers;
/**
* A wrapper for a collection of widgets also known as a widget group
*
*/
public class WidgetGroup implements Wrapper<IWidget[]> {
private final WeakReference<IWidget[]> wrapped;
private final Widget[] widgets;
private final int index;
|
public WidgetGroup(MethodContext ctx, final IWidget[] widgets, int index) {
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/views/IServicesFragmentView.java
|
// Path: app/src/main/java/com/livingstoneapp/models/ServiceInfoInternal.java
// public class ServiceInfoInternal {
// private String mName;
// private boolean mEnabled;
// private boolean mExported;
// private String mProcessName;
// private String mPermission;
// private ArrayList<String> mFlags;
//
// public ServiceInfoInternal(String mName, boolean mEnabled, boolean mExported, String mProcessName, String mPermission, ArrayList<String> mFlags) {
// this.mName = mName;
// this.mEnabled = mEnabled;
// this.mExported = mExported;
// this.mProcessName = mProcessName;
// this.mPermission = mPermission;
// this.mFlags = mFlags;
// }
//
// public boolean isEnabled() {
// return mEnabled;
// }
//
// public boolean isExported() {
// return mExported;
// }
//
// public ArrayList<String> getFlags() {
// return mFlags;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getPermission() {
// return mPermission;
// }
//
// public String getProcessName() {
// return mProcessName;
// }
// }
|
import java.util.ArrayList;
import com.livingstoneapp.models.ServiceInfoInternal;
|
package com.livingstoneapp.views;
/**
* Created by renier on 2/18/2016.
*/
public interface IServicesFragmentView {
void showError(String message);
|
// Path: app/src/main/java/com/livingstoneapp/models/ServiceInfoInternal.java
// public class ServiceInfoInternal {
// private String mName;
// private boolean mEnabled;
// private boolean mExported;
// private String mProcessName;
// private String mPermission;
// private ArrayList<String> mFlags;
//
// public ServiceInfoInternal(String mName, boolean mEnabled, boolean mExported, String mProcessName, String mPermission, ArrayList<String> mFlags) {
// this.mName = mName;
// this.mEnabled = mEnabled;
// this.mExported = mExported;
// this.mProcessName = mProcessName;
// this.mPermission = mPermission;
// this.mFlags = mFlags;
// }
//
// public boolean isEnabled() {
// return mEnabled;
// }
//
// public boolean isExported() {
// return mExported;
// }
//
// public ArrayList<String> getFlags() {
// return mFlags;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getPermission() {
// return mPermission;
// }
//
// public String getProcessName() {
// return mProcessName;
// }
// }
// Path: app/src/main/java/com/livingstoneapp/views/IServicesFragmentView.java
import java.util.ArrayList;
import com.livingstoneapp.models.ServiceInfoInternal;
package com.livingstoneapp.views;
/**
* Created by renier on 2/18/2016.
*/
public interface IServicesFragmentView {
void showError(String message);
|
void setModel(ArrayList<ServiceInfoInternal> services);
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/adapters/PathPermissionAdapter.java
|
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListener.java
// public interface RecyclerViewOnClickListener<T> {
// void onItemClick(T item);
// }
//
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListenerInternal.java
// public interface RecyclerViewOnClickListenerInternal {
// void onItemClick(int position);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/PathPermission.java
// public class PathPermission implements Parcelable {
//
// private String mPath;
// private String mType;
// private String mWritePermission;
// private String mReadPermission;
//
// public PathPermission(String mPath, String mReadPermission, String mWritePermission, String mType) {
// this.mPath = mPath;
// this.mReadPermission = mReadPermission;
// this.mType = mType;
// this.mWritePermission = mWritePermission;
// }
//
// public String getPath() {
// return mPath;
// }
//
// public String getReadPermission() {
// return mReadPermission;
// }
//
// public String getType() {
// return mType;
// }
//
// public String getWritePermission() {
// return mWritePermission;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mPath);
// dest.writeString(this.mType);
// dest.writeString(this.mWritePermission);
// dest.writeString(this.mReadPermission);
// }
//
// protected PathPermission(Parcel in) {
// this.mPath = in.readString();
// this.mType = in.readString();
// this.mWritePermission = in.readString();
// this.mReadPermission = in.readString();
// }
//
// public static final Parcelable.Creator<PathPermission> CREATOR = new Parcelable.Creator<PathPermission>() {
// public PathPermission createFromParcel(Parcel source) {
// return new PathPermission(source);
// }
//
// public PathPermission[] newArray(int size) {
// return new PathPermission[size];
// }
// };
// }
|
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.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.R;
import com.livingstoneapp.helpers.RecyclerViewOnClickListener;
import com.livingstoneapp.helpers.RecyclerViewOnClickListenerInternal;
import com.livingstoneapp.models.PathPermission;
|
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return
new ViewHolder(
LayoutInflater.from(parent.getContext())
.inflate(R.layout.content_provider_path_permission_item_adapter_layout, parent, false),
position -> {
if (mListener != null) {
mListener.onItemClick(mData.get(position));
}
});
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
PathPermission pp = mData.get(position);
holder.tvPath.setText(pp.getPath());
holder.tvType.setText(pp.getType());
holder.tvReadPermission.setText(pp.getReadPermission());
holder.tvWritePermission.setText(pp.getWritePermission());
}
@Override
public int getItemCount() {
return mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
|
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListener.java
// public interface RecyclerViewOnClickListener<T> {
// void onItemClick(T item);
// }
//
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListenerInternal.java
// public interface RecyclerViewOnClickListenerInternal {
// void onItemClick(int position);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/PathPermission.java
// public class PathPermission implements Parcelable {
//
// private String mPath;
// private String mType;
// private String mWritePermission;
// private String mReadPermission;
//
// public PathPermission(String mPath, String mReadPermission, String mWritePermission, String mType) {
// this.mPath = mPath;
// this.mReadPermission = mReadPermission;
// this.mType = mType;
// this.mWritePermission = mWritePermission;
// }
//
// public String getPath() {
// return mPath;
// }
//
// public String getReadPermission() {
// return mReadPermission;
// }
//
// public String getType() {
// return mType;
// }
//
// public String getWritePermission() {
// return mWritePermission;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mPath);
// dest.writeString(this.mType);
// dest.writeString(this.mWritePermission);
// dest.writeString(this.mReadPermission);
// }
//
// protected PathPermission(Parcel in) {
// this.mPath = in.readString();
// this.mType = in.readString();
// this.mWritePermission = in.readString();
// this.mReadPermission = in.readString();
// }
//
// public static final Parcelable.Creator<PathPermission> CREATOR = new Parcelable.Creator<PathPermission>() {
// public PathPermission createFromParcel(Parcel source) {
// return new PathPermission(source);
// }
//
// public PathPermission[] newArray(int size) {
// return new PathPermission[size];
// }
// };
// }
// Path: app/src/main/java/com/livingstoneapp/adapters/PathPermissionAdapter.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.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.R;
import com.livingstoneapp.helpers.RecyclerViewOnClickListener;
import com.livingstoneapp.helpers.RecyclerViewOnClickListenerInternal;
import com.livingstoneapp.models.PathPermission;
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return
new ViewHolder(
LayoutInflater.from(parent.getContext())
.inflate(R.layout.content_provider_path_permission_item_adapter_layout, parent, false),
position -> {
if (mListener != null) {
mListener.onItemClick(mData.get(position));
}
});
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
PathPermission pp = mData.get(position);
holder.tvPath.setText(pp.getPath());
holder.tvType.setText(pp.getType());
holder.tvReadPermission.setText(pp.getReadPermission());
holder.tvWritePermission.setText(pp.getWritePermission());
}
@Override
public int getItemCount() {
return mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
|
private RecyclerViewOnClickListenerInternal mListener;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/adapters/ServicesAdapter.java
|
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListener.java
// public interface RecyclerViewOnClickListener<T> {
// void onItemClick(T item);
// }
//
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListenerInternal.java
// public interface RecyclerViewOnClickListenerInternal {
// void onItemClick(int position);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/ServiceInfoInternal.java
// public class ServiceInfoInternal {
// private String mName;
// private boolean mEnabled;
// private boolean mExported;
// private String mProcessName;
// private String mPermission;
// private ArrayList<String> mFlags;
//
// public ServiceInfoInternal(String mName, boolean mEnabled, boolean mExported, String mProcessName, String mPermission, ArrayList<String> mFlags) {
// this.mName = mName;
// this.mEnabled = mEnabled;
// this.mExported = mExported;
// this.mProcessName = mProcessName;
// this.mPermission = mPermission;
// this.mFlags = mFlags;
// }
//
// public boolean isEnabled() {
// return mEnabled;
// }
//
// public boolean isExported() {
// return mExported;
// }
//
// public ArrayList<String> getFlags() {
// return mFlags;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getPermission() {
// return mPermission;
// }
//
// public String getProcessName() {
// return mProcessName;
// }
// }
|
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.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.R;
import com.livingstoneapp.helpers.RecyclerViewOnClickListener;
import com.livingstoneapp.helpers.RecyclerViewOnClickListenerInternal;
import com.livingstoneapp.models.ServiceInfoInternal;
|
} else {
holder.tvPermissionHeader.setVisibility(View.GONE);
holder.tvPermission.setVisibility(View.GONE);
}
if (!si.getFlags().isEmpty()) {
holder.tvFlagsHeader.setVisibility(View.VISIBLE);
holder.tvFlags.setVisibility(View.VISIBLE);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < si.getFlags().size(); i++) {
if (i != 0)
sb.append("\n");
sb.append(si.getFlags().get(i));
}
holder.tvFlags.setText(sb);
} else {
holder.tvFlagsHeader.setVisibility(View.GONE);
holder.tvFlags.setVisibility(View.GONE);
}
}
@Override
public int getItemCount() {
return mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
|
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListener.java
// public interface RecyclerViewOnClickListener<T> {
// void onItemClick(T item);
// }
//
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListenerInternal.java
// public interface RecyclerViewOnClickListenerInternal {
// void onItemClick(int position);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/ServiceInfoInternal.java
// public class ServiceInfoInternal {
// private String mName;
// private boolean mEnabled;
// private boolean mExported;
// private String mProcessName;
// private String mPermission;
// private ArrayList<String> mFlags;
//
// public ServiceInfoInternal(String mName, boolean mEnabled, boolean mExported, String mProcessName, String mPermission, ArrayList<String> mFlags) {
// this.mName = mName;
// this.mEnabled = mEnabled;
// this.mExported = mExported;
// this.mProcessName = mProcessName;
// this.mPermission = mPermission;
// this.mFlags = mFlags;
// }
//
// public boolean isEnabled() {
// return mEnabled;
// }
//
// public boolean isExported() {
// return mExported;
// }
//
// public ArrayList<String> getFlags() {
// return mFlags;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getPermission() {
// return mPermission;
// }
//
// public String getProcessName() {
// return mProcessName;
// }
// }
// Path: app/src/main/java/com/livingstoneapp/adapters/ServicesAdapter.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.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.R;
import com.livingstoneapp.helpers.RecyclerViewOnClickListener;
import com.livingstoneapp.helpers.RecyclerViewOnClickListenerInternal;
import com.livingstoneapp.models.ServiceInfoInternal;
} else {
holder.tvPermissionHeader.setVisibility(View.GONE);
holder.tvPermission.setVisibility(View.GONE);
}
if (!si.getFlags().isEmpty()) {
holder.tvFlagsHeader.setVisibility(View.VISIBLE);
holder.tvFlags.setVisibility(View.VISIBLE);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < si.getFlags().size(); i++) {
if (i != 0)
sb.append("\n");
sb.append(si.getFlags().get(i));
}
holder.tvFlags.setText(sb);
} else {
holder.tvFlagsHeader.setVisibility(View.GONE);
holder.tvFlags.setVisibility(View.GONE);
}
}
@Override
public int getItemCount() {
return mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
|
private RecyclerViewOnClickListenerInternal mListener;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/presenters/IContentProvidersFragmentPresenter.java
|
// Path: app/src/main/java/com/livingstoneapp/models/ContentProviderInfo.java
// public class ContentProviderInfo implements Parcelable {
// private String mName;
// private boolean mEnabled;
// private boolean mExported;
// private String mAuthority;
// private String mReadPermission;
// private String mWritePermission;
// private String mProcessName;
// private boolean mMultiProcess;
// private boolean mSingleUser;
// private int mInitOrder;
// private boolean mIsSyncable;
// private boolean mGrantURIPermissions;
// private ArrayList<PathPermission> mPathPermissions;
// private ArrayList<URIPermissionPattern> mURIPermissionPatterns;
//
// public ContentProviderInfo(String name) {
// this.mName = name;
// }
//
// public ContentProviderInfo(
// String mName,
// boolean mEnabled,
// boolean mExported,
// String mAuthority,
// String mReadPermission,
// String mWritePermission,
// String mProcessName,
// boolean mMultiProcess,
// boolean mSingleUser,
// int mInitOrder,
// boolean mIsSyncable,
// boolean mGrantURIPermissions,
// ArrayList<PathPermission> mPathPermissions,
// ArrayList<URIPermissionPattern> mURIPermissionPatterns) {
// this.mAuthority = mAuthority;
// this.mEnabled = mEnabled;
// this.mExported = mExported;
// this.mGrantURIPermissions = mGrantURIPermissions;
// this.mInitOrder = mInitOrder;
// this.mIsSyncable = mIsSyncable;
// this.mMultiProcess = mMultiProcess;
// this.mName = mName;
// this.mPathPermissions = mPathPermissions;
// this.mProcessName = mProcessName;
// this.mReadPermission = mReadPermission;
// this.mSingleUser = mSingleUser;
// this.mURIPermissionPatterns = mURIPermissionPatterns;
// this.mWritePermission = mWritePermission;
// }
//
// public String getAuthority() {
// return mAuthority;
// }
//
// public boolean isEnabled() {
// return mEnabled;
// }
//
// public boolean isExported() {
// return mExported;
// }
//
// public boolean isGrantURIPermissions() {
// return mGrantURIPermissions;
// }
//
// public int getInitOrder() {
// return mInitOrder;
// }
//
// public boolean isIsSyncable() {
// return mIsSyncable;
// }
//
// public boolean isMultiProcess() {
// return mMultiProcess;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<PathPermission> getPathPermissions() {
// return mPathPermissions;
// }
//
// public String getProcessName() {
// return mProcessName;
// }
//
// public String getReadPermission() {
// return mReadPermission;
// }
//
// public boolean isSingleUser() {
// return mSingleUser;
// }
//
// public ArrayList<URIPermissionPattern> getURIPermissionPatterns() {
// return mURIPermissionPatterns;
// }
//
// public String getWritePermission() {
// return mWritePermission;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// dest.writeByte(mEnabled ? (byte) 1 : (byte) 0);
// dest.writeByte(mExported ? (byte) 1 : (byte) 0);
// dest.writeString(this.mAuthority);
// dest.writeString(this.mReadPermission);
// dest.writeString(this.mWritePermission);
// dest.writeString(this.mProcessName);
// dest.writeByte(mMultiProcess ? (byte) 1 : (byte) 0);
// dest.writeByte(mSingleUser ? (byte) 1 : (byte) 0);
// dest.writeInt(this.mInitOrder);
// dest.writeByte(mIsSyncable ? (byte) 1 : (byte) 0);
// dest.writeByte(mGrantURIPermissions ? (byte) 1 : (byte) 0);
// dest.writeTypedList(mPathPermissions);
// dest.writeTypedList(mURIPermissionPatterns);
// }
//
// protected ContentProviderInfo(Parcel in) {
// this.mName = in.readString();
// this.mEnabled = in.readByte() != 0;
// this.mExported = in.readByte() != 0;
// this.mAuthority = in.readString();
// this.mReadPermission = in.readString();
// this.mWritePermission = in.readString();
// this.mProcessName = in.readString();
// this.mMultiProcess = in.readByte() != 0;
// this.mSingleUser = in.readByte() != 0;
// this.mInitOrder = in.readInt();
// this.mIsSyncable = in.readByte() != 0;
// this.mGrantURIPermissions = in.readByte() != 0;
// this.mPathPermissions = in.createTypedArrayList(PathPermission.CREATOR);
// this.mURIPermissionPatterns = in.createTypedArrayList(URIPermissionPattern.CREATOR);
// }
//
// public static final Parcelable.Creator<ContentProviderInfo> CREATOR = new Parcelable.Creator<ContentProviderInfo>() {
// public ContentProviderInfo createFromParcel(Parcel source) {
// return new ContentProviderInfo(source);
// }
//
// public ContentProviderInfo[] newArray(int size) {
// return new ContentProviderInfo[size];
// }
// };
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IContentProvidersFragmentView.java
// public interface IContentProvidersFragmentView {
// void showError(String message);
// void setModel(ArrayList<ContentProviderInfo> contentProviders);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void startContentProviderDetailActivity(ContentProviderInfo provider);
// void showNoValuesText();
// void hideNoValuesText();
// }
|
import com.livingstoneapp.models.ContentProviderInfo;
import com.livingstoneapp.views.IContentProvidersFragmentView;
|
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/02/16.
*/
public interface IContentProvidersFragmentPresenter {
void setView(IContentProvidersFragmentView view);
void clearView();
void init(String packageName);
|
// Path: app/src/main/java/com/livingstoneapp/models/ContentProviderInfo.java
// public class ContentProviderInfo implements Parcelable {
// private String mName;
// private boolean mEnabled;
// private boolean mExported;
// private String mAuthority;
// private String mReadPermission;
// private String mWritePermission;
// private String mProcessName;
// private boolean mMultiProcess;
// private boolean mSingleUser;
// private int mInitOrder;
// private boolean mIsSyncable;
// private boolean mGrantURIPermissions;
// private ArrayList<PathPermission> mPathPermissions;
// private ArrayList<URIPermissionPattern> mURIPermissionPatterns;
//
// public ContentProviderInfo(String name) {
// this.mName = name;
// }
//
// public ContentProviderInfo(
// String mName,
// boolean mEnabled,
// boolean mExported,
// String mAuthority,
// String mReadPermission,
// String mWritePermission,
// String mProcessName,
// boolean mMultiProcess,
// boolean mSingleUser,
// int mInitOrder,
// boolean mIsSyncable,
// boolean mGrantURIPermissions,
// ArrayList<PathPermission> mPathPermissions,
// ArrayList<URIPermissionPattern> mURIPermissionPatterns) {
// this.mAuthority = mAuthority;
// this.mEnabled = mEnabled;
// this.mExported = mExported;
// this.mGrantURIPermissions = mGrantURIPermissions;
// this.mInitOrder = mInitOrder;
// this.mIsSyncable = mIsSyncable;
// this.mMultiProcess = mMultiProcess;
// this.mName = mName;
// this.mPathPermissions = mPathPermissions;
// this.mProcessName = mProcessName;
// this.mReadPermission = mReadPermission;
// this.mSingleUser = mSingleUser;
// this.mURIPermissionPatterns = mURIPermissionPatterns;
// this.mWritePermission = mWritePermission;
// }
//
// public String getAuthority() {
// return mAuthority;
// }
//
// public boolean isEnabled() {
// return mEnabled;
// }
//
// public boolean isExported() {
// return mExported;
// }
//
// public boolean isGrantURIPermissions() {
// return mGrantURIPermissions;
// }
//
// public int getInitOrder() {
// return mInitOrder;
// }
//
// public boolean isIsSyncable() {
// return mIsSyncable;
// }
//
// public boolean isMultiProcess() {
// return mMultiProcess;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<PathPermission> getPathPermissions() {
// return mPathPermissions;
// }
//
// public String getProcessName() {
// return mProcessName;
// }
//
// public String getReadPermission() {
// return mReadPermission;
// }
//
// public boolean isSingleUser() {
// return mSingleUser;
// }
//
// public ArrayList<URIPermissionPattern> getURIPermissionPatterns() {
// return mURIPermissionPatterns;
// }
//
// public String getWritePermission() {
// return mWritePermission;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// dest.writeByte(mEnabled ? (byte) 1 : (byte) 0);
// dest.writeByte(mExported ? (byte) 1 : (byte) 0);
// dest.writeString(this.mAuthority);
// dest.writeString(this.mReadPermission);
// dest.writeString(this.mWritePermission);
// dest.writeString(this.mProcessName);
// dest.writeByte(mMultiProcess ? (byte) 1 : (byte) 0);
// dest.writeByte(mSingleUser ? (byte) 1 : (byte) 0);
// dest.writeInt(this.mInitOrder);
// dest.writeByte(mIsSyncable ? (byte) 1 : (byte) 0);
// dest.writeByte(mGrantURIPermissions ? (byte) 1 : (byte) 0);
// dest.writeTypedList(mPathPermissions);
// dest.writeTypedList(mURIPermissionPatterns);
// }
//
// protected ContentProviderInfo(Parcel in) {
// this.mName = in.readString();
// this.mEnabled = in.readByte() != 0;
// this.mExported = in.readByte() != 0;
// this.mAuthority = in.readString();
// this.mReadPermission = in.readString();
// this.mWritePermission = in.readString();
// this.mProcessName = in.readString();
// this.mMultiProcess = in.readByte() != 0;
// this.mSingleUser = in.readByte() != 0;
// this.mInitOrder = in.readInt();
// this.mIsSyncable = in.readByte() != 0;
// this.mGrantURIPermissions = in.readByte() != 0;
// this.mPathPermissions = in.createTypedArrayList(PathPermission.CREATOR);
// this.mURIPermissionPatterns = in.createTypedArrayList(URIPermissionPattern.CREATOR);
// }
//
// public static final Parcelable.Creator<ContentProviderInfo> CREATOR = new Parcelable.Creator<ContentProviderInfo>() {
// public ContentProviderInfo createFromParcel(Parcel source) {
// return new ContentProviderInfo(source);
// }
//
// public ContentProviderInfo[] newArray(int size) {
// return new ContentProviderInfo[size];
// }
// };
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IContentProvidersFragmentView.java
// public interface IContentProvidersFragmentView {
// void showError(String message);
// void setModel(ArrayList<ContentProviderInfo> contentProviders);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void startContentProviderDetailActivity(ContentProviderInfo provider);
// void showNoValuesText();
// void hideNoValuesText();
// }
// Path: app/src/main/java/com/livingstoneapp/presenters/IContentProvidersFragmentPresenter.java
import com.livingstoneapp.models.ContentProviderInfo;
import com.livingstoneapp.views.IContentProvidersFragmentView;
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/02/16.
*/
public interface IContentProvidersFragmentPresenter {
void setView(IContentProvidersFragmentView view);
void clearView();
void init(String packageName);
|
void onContentProviderSelected(ContentProviderInfo provider);
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/presenters/IPackageListActivityPresenter.java
|
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
// public interface IPackageListView {
// void init();
// void setInstalledPackages(List<InstalledPackageHeader> items);
// void setError(String message);
// void startDetailActivity(InstalledPackageHeader item);
// void setDetailFragment(InstalledPackageHeader item);
// void showWaitDialog();
// void hideWaitDialog();
// void showContentView();
// void hideContentView();
// }
|
import com.livingstoneapp.models.InstalledPackageHeader;
import com.livingstoneapp.views.IPackageListView;
|
package com.livingstoneapp.presenters;
/**
* Created by renier on 2/2/2016.
*/
public interface IPackageListActivityPresenter {
void setView(IPackageListView view);
void clearView();
void setTwoPane();
void init();
void loadPackages(boolean refresh);
|
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
// public interface IPackageListView {
// void init();
// void setInstalledPackages(List<InstalledPackageHeader> items);
// void setError(String message);
// void startDetailActivity(InstalledPackageHeader item);
// void setDetailFragment(InstalledPackageHeader item);
// void showWaitDialog();
// void hideWaitDialog();
// void showContentView();
// void hideContentView();
// }
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageListActivityPresenter.java
import com.livingstoneapp.models.InstalledPackageHeader;
import com.livingstoneapp.views.IPackageListView;
package com.livingstoneapp.presenters;
/**
* Created by renier on 2/2/2016.
*/
public interface IPackageListActivityPresenter {
void setView(IPackageListView view);
void clearView();
void setTwoPane();
void init();
void loadPackages(boolean refresh);
|
void packageSelected(InstalledPackageHeader header);
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/views/IRequestedFeaturesFragmentView.java
|
// Path: app/src/main/java/com/livingstoneapp/models/FeatureInfoInternal.java
// public class FeatureInfoInternal {
// private String mName;
// private boolean mRequired;
// private String mGLESVersion;
//
// public FeatureInfoInternal(String mName, boolean mRequired, String mGLESVersion) {
//
// this.mName = mName;
// this.mRequired = mRequired;
// this.mGLESVersion = mGLESVersion;
// }
//
// public String getName() {
// return mName;
// }
//
// public boolean isRequired() {
// return mRequired;
// }
//
// public String getGLESVersion() {
// return mGLESVersion;
// }
// }
|
import java.util.ArrayList;
import com.livingstoneapp.models.FeatureInfoInternal;
|
package com.livingstoneapp.views;
/**
* Created by renier on 2/18/2016.
*/
public interface IRequestedFeaturesFragmentView {
void showError(String message);
|
// Path: app/src/main/java/com/livingstoneapp/models/FeatureInfoInternal.java
// public class FeatureInfoInternal {
// private String mName;
// private boolean mRequired;
// private String mGLESVersion;
//
// public FeatureInfoInternal(String mName, boolean mRequired, String mGLESVersion) {
//
// this.mName = mName;
// this.mRequired = mRequired;
// this.mGLESVersion = mGLESVersion;
// }
//
// public String getName() {
// return mName;
// }
//
// public boolean isRequired() {
// return mRequired;
// }
//
// public String getGLESVersion() {
// return mGLESVersion;
// }
// }
// Path: app/src/main/java/com/livingstoneapp/views/IRequestedFeaturesFragmentView.java
import java.util.ArrayList;
import com.livingstoneapp.models.FeatureInfoInternal;
package com.livingstoneapp.views;
/**
* Created by renier on 2/18/2016.
*/
public interface IRequestedFeaturesFragmentView {
void showError(String message);
|
void setModel(ArrayList<FeatureInfoInternal> permissions);
|
oosthuizenr/Livingstone
|
app/src/release/java/za/co/flatrocksolutions/installedpackagelister/dagger/PackageListActivityModule.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageListActivityPresenter.java
// public interface IPackageListActivityPresenter {
// void setView(IPackageListView view);
// void clearView();
// void setTwoPane();
// void init();
// void loadPackages(boolean refresh);
// void packageSelected(InstalledPackageHeader header);
//
//
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/PackageListActivityPresenterImpl.java
// public class PackageListActivityPresenterImpl implements IPackageListActivityPresenter {
//
// private IPackageListView mView;
// private boolean mIsTwoPane = false;
// private IPackageInteractor mPackageInteractor;
//
//
// @Inject
// public PackageListActivityPresenterImpl(IPackageInteractor interactor) {
// mPackageInteractor = interactor;
// }
//
// @Override
// public void setView(IPackageListView view) {
// mView = view;
// }
//
// @Override
// public void clearView() {
// mView = null;
// }
//
// @Override
// public void setTwoPane() {
// mIsTwoPane = true;
// }
//
// @Override
// public void init() {
// mView.init();
// }
//
// @Override
// public void loadPackages(boolean refresh) {
// if (mView != null) {
// mView.hideContentView();
// mView.showWaitDialog();
//
// mPackageInteractor.getInstalledPackages(refresh)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(
// items -> {
// if (mView != null) {
// if (items.size() > 0) {
// mView.setInstalledPackages(items);
// mView.hideWaitDialog();
// mView.showContentView();
// } else {
// mView.hideWaitDialog();
// mView.setError("No Packages");
// }
// }
// },
// error -> {
// if (mView != null) {
// mView.setError(error.getMessage());
// mView.hideWaitDialog();
// }
// });
// }
// }
//
// @Override
// public void packageSelected(InstalledPackageHeader header) {
// if (mView != null) {
// if (mIsTwoPane) {
// mView.setDetailFragment(header);
// } else {
// mView.startDetailActivity(header);
// }
// }
// }
//
//
// }
|
import dagger.Module;
import dagger.Provides;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.presenters.IPackageListActivityPresenter;
import com.livingstoneapp.presenters.PackageListActivityPresenterImpl;
|
package com.livingstoneapp.dagger;
/**
* Created by renier on 2/2/2016.
*/
@Module
public class PackageListActivityModule {
public PackageListActivityModule(boolean provideMocks) {
}
@Provides
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageListActivityPresenter.java
// public interface IPackageListActivityPresenter {
// void setView(IPackageListView view);
// void clearView();
// void setTwoPane();
// void init();
// void loadPackages(boolean refresh);
// void packageSelected(InstalledPackageHeader header);
//
//
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/PackageListActivityPresenterImpl.java
// public class PackageListActivityPresenterImpl implements IPackageListActivityPresenter {
//
// private IPackageListView mView;
// private boolean mIsTwoPane = false;
// private IPackageInteractor mPackageInteractor;
//
//
// @Inject
// public PackageListActivityPresenterImpl(IPackageInteractor interactor) {
// mPackageInteractor = interactor;
// }
//
// @Override
// public void setView(IPackageListView view) {
// mView = view;
// }
//
// @Override
// public void clearView() {
// mView = null;
// }
//
// @Override
// public void setTwoPane() {
// mIsTwoPane = true;
// }
//
// @Override
// public void init() {
// mView.init();
// }
//
// @Override
// public void loadPackages(boolean refresh) {
// if (mView != null) {
// mView.hideContentView();
// mView.showWaitDialog();
//
// mPackageInteractor.getInstalledPackages(refresh)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(
// items -> {
// if (mView != null) {
// if (items.size() > 0) {
// mView.setInstalledPackages(items);
// mView.hideWaitDialog();
// mView.showContentView();
// } else {
// mView.hideWaitDialog();
// mView.setError("No Packages");
// }
// }
// },
// error -> {
// if (mView != null) {
// mView.setError(error.getMessage());
// mView.hideWaitDialog();
// }
// });
// }
// }
//
// @Override
// public void packageSelected(InstalledPackageHeader header) {
// if (mView != null) {
// if (mIsTwoPane) {
// mView.setDetailFragment(header);
// } else {
// mView.startDetailActivity(header);
// }
// }
// }
//
//
// }
// Path: app/src/release/java/za/co/flatrocksolutions/installedpackagelister/dagger/PackageListActivityModule.java
import dagger.Module;
import dagger.Provides;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.presenters.IPackageListActivityPresenter;
import com.livingstoneapp.presenters.PackageListActivityPresenterImpl;
package com.livingstoneapp.dagger;
/**
* Created by renier on 2/2/2016.
*/
@Module
public class PackageListActivityModule {
public PackageListActivityModule(boolean provideMocks) {
}
@Provides
|
IPackageListActivityPresenter providesMainActivityPresenter(IPackageInteractor interactor) {
|
oosthuizenr/Livingstone
|
app/src/release/java/za/co/flatrocksolutions/installedpackagelister/dagger/PackageListActivityModule.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageListActivityPresenter.java
// public interface IPackageListActivityPresenter {
// void setView(IPackageListView view);
// void clearView();
// void setTwoPane();
// void init();
// void loadPackages(boolean refresh);
// void packageSelected(InstalledPackageHeader header);
//
//
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/PackageListActivityPresenterImpl.java
// public class PackageListActivityPresenterImpl implements IPackageListActivityPresenter {
//
// private IPackageListView mView;
// private boolean mIsTwoPane = false;
// private IPackageInteractor mPackageInteractor;
//
//
// @Inject
// public PackageListActivityPresenterImpl(IPackageInteractor interactor) {
// mPackageInteractor = interactor;
// }
//
// @Override
// public void setView(IPackageListView view) {
// mView = view;
// }
//
// @Override
// public void clearView() {
// mView = null;
// }
//
// @Override
// public void setTwoPane() {
// mIsTwoPane = true;
// }
//
// @Override
// public void init() {
// mView.init();
// }
//
// @Override
// public void loadPackages(boolean refresh) {
// if (mView != null) {
// mView.hideContentView();
// mView.showWaitDialog();
//
// mPackageInteractor.getInstalledPackages(refresh)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(
// items -> {
// if (mView != null) {
// if (items.size() > 0) {
// mView.setInstalledPackages(items);
// mView.hideWaitDialog();
// mView.showContentView();
// } else {
// mView.hideWaitDialog();
// mView.setError("No Packages");
// }
// }
// },
// error -> {
// if (mView != null) {
// mView.setError(error.getMessage());
// mView.hideWaitDialog();
// }
// });
// }
// }
//
// @Override
// public void packageSelected(InstalledPackageHeader header) {
// if (mView != null) {
// if (mIsTwoPane) {
// mView.setDetailFragment(header);
// } else {
// mView.startDetailActivity(header);
// }
// }
// }
//
//
// }
|
import dagger.Module;
import dagger.Provides;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.presenters.IPackageListActivityPresenter;
import com.livingstoneapp.presenters.PackageListActivityPresenterImpl;
|
package com.livingstoneapp.dagger;
/**
* Created by renier on 2/2/2016.
*/
@Module
public class PackageListActivityModule {
public PackageListActivityModule(boolean provideMocks) {
}
@Provides
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageListActivityPresenter.java
// public interface IPackageListActivityPresenter {
// void setView(IPackageListView view);
// void clearView();
// void setTwoPane();
// void init();
// void loadPackages(boolean refresh);
// void packageSelected(InstalledPackageHeader header);
//
//
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/PackageListActivityPresenterImpl.java
// public class PackageListActivityPresenterImpl implements IPackageListActivityPresenter {
//
// private IPackageListView mView;
// private boolean mIsTwoPane = false;
// private IPackageInteractor mPackageInteractor;
//
//
// @Inject
// public PackageListActivityPresenterImpl(IPackageInteractor interactor) {
// mPackageInteractor = interactor;
// }
//
// @Override
// public void setView(IPackageListView view) {
// mView = view;
// }
//
// @Override
// public void clearView() {
// mView = null;
// }
//
// @Override
// public void setTwoPane() {
// mIsTwoPane = true;
// }
//
// @Override
// public void init() {
// mView.init();
// }
//
// @Override
// public void loadPackages(boolean refresh) {
// if (mView != null) {
// mView.hideContentView();
// mView.showWaitDialog();
//
// mPackageInteractor.getInstalledPackages(refresh)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(
// items -> {
// if (mView != null) {
// if (items.size() > 0) {
// mView.setInstalledPackages(items);
// mView.hideWaitDialog();
// mView.showContentView();
// } else {
// mView.hideWaitDialog();
// mView.setError("No Packages");
// }
// }
// },
// error -> {
// if (mView != null) {
// mView.setError(error.getMessage());
// mView.hideWaitDialog();
// }
// });
// }
// }
//
// @Override
// public void packageSelected(InstalledPackageHeader header) {
// if (mView != null) {
// if (mIsTwoPane) {
// mView.setDetailFragment(header);
// } else {
// mView.startDetailActivity(header);
// }
// }
// }
//
//
// }
// Path: app/src/release/java/za/co/flatrocksolutions/installedpackagelister/dagger/PackageListActivityModule.java
import dagger.Module;
import dagger.Provides;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.presenters.IPackageListActivityPresenter;
import com.livingstoneapp.presenters.PackageListActivityPresenterImpl;
package com.livingstoneapp.dagger;
/**
* Created by renier on 2/2/2016.
*/
@Module
public class PackageListActivityModule {
public PackageListActivityModule(boolean provideMocks) {
}
@Provides
|
IPackageListActivityPresenter providesMainActivityPresenter(IPackageInteractor interactor) {
|
oosthuizenr/Livingstone
|
app/src/release/java/za/co/flatrocksolutions/installedpackagelister/dagger/PackageListActivityModule.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageListActivityPresenter.java
// public interface IPackageListActivityPresenter {
// void setView(IPackageListView view);
// void clearView();
// void setTwoPane();
// void init();
// void loadPackages(boolean refresh);
// void packageSelected(InstalledPackageHeader header);
//
//
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/PackageListActivityPresenterImpl.java
// public class PackageListActivityPresenterImpl implements IPackageListActivityPresenter {
//
// private IPackageListView mView;
// private boolean mIsTwoPane = false;
// private IPackageInteractor mPackageInteractor;
//
//
// @Inject
// public PackageListActivityPresenterImpl(IPackageInteractor interactor) {
// mPackageInteractor = interactor;
// }
//
// @Override
// public void setView(IPackageListView view) {
// mView = view;
// }
//
// @Override
// public void clearView() {
// mView = null;
// }
//
// @Override
// public void setTwoPane() {
// mIsTwoPane = true;
// }
//
// @Override
// public void init() {
// mView.init();
// }
//
// @Override
// public void loadPackages(boolean refresh) {
// if (mView != null) {
// mView.hideContentView();
// mView.showWaitDialog();
//
// mPackageInteractor.getInstalledPackages(refresh)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(
// items -> {
// if (mView != null) {
// if (items.size() > 0) {
// mView.setInstalledPackages(items);
// mView.hideWaitDialog();
// mView.showContentView();
// } else {
// mView.hideWaitDialog();
// mView.setError("No Packages");
// }
// }
// },
// error -> {
// if (mView != null) {
// mView.setError(error.getMessage());
// mView.hideWaitDialog();
// }
// });
// }
// }
//
// @Override
// public void packageSelected(InstalledPackageHeader header) {
// if (mView != null) {
// if (mIsTwoPane) {
// mView.setDetailFragment(header);
// } else {
// mView.startDetailActivity(header);
// }
// }
// }
//
//
// }
|
import dagger.Module;
import dagger.Provides;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.presenters.IPackageListActivityPresenter;
import com.livingstoneapp.presenters.PackageListActivityPresenterImpl;
|
package com.livingstoneapp.dagger;
/**
* Created by renier on 2/2/2016.
*/
@Module
public class PackageListActivityModule {
public PackageListActivityModule(boolean provideMocks) {
}
@Provides
IPackageListActivityPresenter providesMainActivityPresenter(IPackageInteractor interactor) {
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageListActivityPresenter.java
// public interface IPackageListActivityPresenter {
// void setView(IPackageListView view);
// void clearView();
// void setTwoPane();
// void init();
// void loadPackages(boolean refresh);
// void packageSelected(InstalledPackageHeader header);
//
//
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/PackageListActivityPresenterImpl.java
// public class PackageListActivityPresenterImpl implements IPackageListActivityPresenter {
//
// private IPackageListView mView;
// private boolean mIsTwoPane = false;
// private IPackageInteractor mPackageInteractor;
//
//
// @Inject
// public PackageListActivityPresenterImpl(IPackageInteractor interactor) {
// mPackageInteractor = interactor;
// }
//
// @Override
// public void setView(IPackageListView view) {
// mView = view;
// }
//
// @Override
// public void clearView() {
// mView = null;
// }
//
// @Override
// public void setTwoPane() {
// mIsTwoPane = true;
// }
//
// @Override
// public void init() {
// mView.init();
// }
//
// @Override
// public void loadPackages(boolean refresh) {
// if (mView != null) {
// mView.hideContentView();
// mView.showWaitDialog();
//
// mPackageInteractor.getInstalledPackages(refresh)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(
// items -> {
// if (mView != null) {
// if (items.size() > 0) {
// mView.setInstalledPackages(items);
// mView.hideWaitDialog();
// mView.showContentView();
// } else {
// mView.hideWaitDialog();
// mView.setError("No Packages");
// }
// }
// },
// error -> {
// if (mView != null) {
// mView.setError(error.getMessage());
// mView.hideWaitDialog();
// }
// });
// }
// }
//
// @Override
// public void packageSelected(InstalledPackageHeader header) {
// if (mView != null) {
// if (mIsTwoPane) {
// mView.setDetailFragment(header);
// } else {
// mView.startDetailActivity(header);
// }
// }
// }
//
//
// }
// Path: app/src/release/java/za/co/flatrocksolutions/installedpackagelister/dagger/PackageListActivityModule.java
import dagger.Module;
import dagger.Provides;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.presenters.IPackageListActivityPresenter;
import com.livingstoneapp.presenters.PackageListActivityPresenterImpl;
package com.livingstoneapp.dagger;
/**
* Created by renier on 2/2/2016.
*/
@Module
public class PackageListActivityModule {
public PackageListActivityModule(boolean provideMocks) {
}
@Provides
IPackageListActivityPresenter providesMainActivityPresenter(IPackageInteractor interactor) {
|
return new PackageListActivityPresenterImpl(interactor);
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/fragments/PackageDetailFragment.java
|
// Path: app/src/main/java/com/livingstoneapp/MainApplication.java
// public class MainApplication extends Application {
// private Graph mGraph;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// mGraph = Graph.Initializer.init(this, false);
// }
//
// public Graph getGraph() {
// return mGraph;
// }
//
// public void setMockMode(boolean provideMocks) {
// mGraph = Graph.Initializer.init(this, provideMocks);
// }
//
// public static MainApplication from(@NonNull Context context) {
// return (MainApplication) context.getApplicationContext();
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/adapters/PackageDetailViewPagerAdapter.java
// public class PackageDetailViewPagerAdapter extends FragmentPagerAdapter {
// private final List<Fragment> mFragmentList = new ArrayList<>();
// private final List<String> mFragmentTitleList = new ArrayList<>();
//
// public PackageDetailViewPagerAdapter(FragmentManager manager) {
// super(manager);
// }
//
// @Override
// public Fragment getItem(int position) {
// return mFragmentList.get(position);
// }
//
// @Override
// public int getCount() {
// return mFragmentList.size();
// }
//
// public void addFragment(Fragment fragment, String title) {
// mFragmentList.add(fragment);
// mFragmentTitleList.add(title);
// }
//
// @Override
// public CharSequence getPageTitle(int position) {
// return mFragmentTitleList.get(position);
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageDetailFragmentPresenter.java
// public interface IPackageDetailFragmentPresenter {
// void setView(IPackageDetailFragmentView view);
// void clearView();
// void init(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageDetailFragmentView.java
// public interface IPackageDetailFragmentView {
//
// void setTitle(String title);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void initViews(String appName, String packageName);
// void showError(String message);
// }
|
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import javax.inject.Inject;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.MainApplication;
import com.livingstoneapp.R;
import com.livingstoneapp.adapters.PackageDetailViewPagerAdapter;
import com.livingstoneapp.presenters.IPackageDetailFragmentPresenter;
import com.livingstoneapp.views.IPackageDetailFragmentView;
|
package com.livingstoneapp.fragments;
/**
* Created by renier on 2/2/2016.
*/
public class PackageDetailFragment extends Fragment implements IPackageDetailFragmentView {
public static String ARG_PACKAGE_NAME = "PackageName";
public static String ARG_2_PANE = "2Pane";
@Inject
|
// Path: app/src/main/java/com/livingstoneapp/MainApplication.java
// public class MainApplication extends Application {
// private Graph mGraph;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// mGraph = Graph.Initializer.init(this, false);
// }
//
// public Graph getGraph() {
// return mGraph;
// }
//
// public void setMockMode(boolean provideMocks) {
// mGraph = Graph.Initializer.init(this, provideMocks);
// }
//
// public static MainApplication from(@NonNull Context context) {
// return (MainApplication) context.getApplicationContext();
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/adapters/PackageDetailViewPagerAdapter.java
// public class PackageDetailViewPagerAdapter extends FragmentPagerAdapter {
// private final List<Fragment> mFragmentList = new ArrayList<>();
// private final List<String> mFragmentTitleList = new ArrayList<>();
//
// public PackageDetailViewPagerAdapter(FragmentManager manager) {
// super(manager);
// }
//
// @Override
// public Fragment getItem(int position) {
// return mFragmentList.get(position);
// }
//
// @Override
// public int getCount() {
// return mFragmentList.size();
// }
//
// public void addFragment(Fragment fragment, String title) {
// mFragmentList.add(fragment);
// mFragmentTitleList.add(title);
// }
//
// @Override
// public CharSequence getPageTitle(int position) {
// return mFragmentTitleList.get(position);
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageDetailFragmentPresenter.java
// public interface IPackageDetailFragmentPresenter {
// void setView(IPackageDetailFragmentView view);
// void clearView();
// void init(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageDetailFragmentView.java
// public interface IPackageDetailFragmentView {
//
// void setTitle(String title);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void initViews(String appName, String packageName);
// void showError(String message);
// }
// Path: app/src/main/java/com/livingstoneapp/fragments/PackageDetailFragment.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import javax.inject.Inject;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.MainApplication;
import com.livingstoneapp.R;
import com.livingstoneapp.adapters.PackageDetailViewPagerAdapter;
import com.livingstoneapp.presenters.IPackageDetailFragmentPresenter;
import com.livingstoneapp.views.IPackageDetailFragmentView;
package com.livingstoneapp.fragments;
/**
* Created by renier on 2/2/2016.
*/
public class PackageDetailFragment extends Fragment implements IPackageDetailFragmentView {
public static String ARG_PACKAGE_NAME = "PackageName";
public static String ARG_2_PANE = "2Pane";
@Inject
|
IPackageDetailFragmentPresenter mPresenter;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/fragments/PackageDetailFragment.java
|
// Path: app/src/main/java/com/livingstoneapp/MainApplication.java
// public class MainApplication extends Application {
// private Graph mGraph;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// mGraph = Graph.Initializer.init(this, false);
// }
//
// public Graph getGraph() {
// return mGraph;
// }
//
// public void setMockMode(boolean provideMocks) {
// mGraph = Graph.Initializer.init(this, provideMocks);
// }
//
// public static MainApplication from(@NonNull Context context) {
// return (MainApplication) context.getApplicationContext();
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/adapters/PackageDetailViewPagerAdapter.java
// public class PackageDetailViewPagerAdapter extends FragmentPagerAdapter {
// private final List<Fragment> mFragmentList = new ArrayList<>();
// private final List<String> mFragmentTitleList = new ArrayList<>();
//
// public PackageDetailViewPagerAdapter(FragmentManager manager) {
// super(manager);
// }
//
// @Override
// public Fragment getItem(int position) {
// return mFragmentList.get(position);
// }
//
// @Override
// public int getCount() {
// return mFragmentList.size();
// }
//
// public void addFragment(Fragment fragment, String title) {
// mFragmentList.add(fragment);
// mFragmentTitleList.add(title);
// }
//
// @Override
// public CharSequence getPageTitle(int position) {
// return mFragmentTitleList.get(position);
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageDetailFragmentPresenter.java
// public interface IPackageDetailFragmentPresenter {
// void setView(IPackageDetailFragmentView view);
// void clearView();
// void init(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageDetailFragmentView.java
// public interface IPackageDetailFragmentView {
//
// void setTitle(String title);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void initViews(String appName, String packageName);
// void showError(String message);
// }
|
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import javax.inject.Inject;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.MainApplication;
import com.livingstoneapp.R;
import com.livingstoneapp.adapters.PackageDetailViewPagerAdapter;
import com.livingstoneapp.presenters.IPackageDetailFragmentPresenter;
import com.livingstoneapp.views.IPackageDetailFragmentView;
|
package com.livingstoneapp.fragments;
/**
* Created by renier on 2/2/2016.
*/
public class PackageDetailFragment extends Fragment implements IPackageDetailFragmentView {
public static String ARG_PACKAGE_NAME = "PackageName";
public static String ARG_2_PANE = "2Pane";
@Inject
IPackageDetailFragmentPresenter mPresenter;
@Bind(R.id.progress_bar)
ProgressBar mProgressBar;
@Bind(R.id.tabs)
TabLayout mTabLayout;
@Bind(R.id.viewpager)
ViewPager mViewPager;
|
// Path: app/src/main/java/com/livingstoneapp/MainApplication.java
// public class MainApplication extends Application {
// private Graph mGraph;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// mGraph = Graph.Initializer.init(this, false);
// }
//
// public Graph getGraph() {
// return mGraph;
// }
//
// public void setMockMode(boolean provideMocks) {
// mGraph = Graph.Initializer.init(this, provideMocks);
// }
//
// public static MainApplication from(@NonNull Context context) {
// return (MainApplication) context.getApplicationContext();
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/adapters/PackageDetailViewPagerAdapter.java
// public class PackageDetailViewPagerAdapter extends FragmentPagerAdapter {
// private final List<Fragment> mFragmentList = new ArrayList<>();
// private final List<String> mFragmentTitleList = new ArrayList<>();
//
// public PackageDetailViewPagerAdapter(FragmentManager manager) {
// super(manager);
// }
//
// @Override
// public Fragment getItem(int position) {
// return mFragmentList.get(position);
// }
//
// @Override
// public int getCount() {
// return mFragmentList.size();
// }
//
// public void addFragment(Fragment fragment, String title) {
// mFragmentList.add(fragment);
// mFragmentTitleList.add(title);
// }
//
// @Override
// public CharSequence getPageTitle(int position) {
// return mFragmentTitleList.get(position);
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageDetailFragmentPresenter.java
// public interface IPackageDetailFragmentPresenter {
// void setView(IPackageDetailFragmentView view);
// void clearView();
// void init(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageDetailFragmentView.java
// public interface IPackageDetailFragmentView {
//
// void setTitle(String title);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void initViews(String appName, String packageName);
// void showError(String message);
// }
// Path: app/src/main/java/com/livingstoneapp/fragments/PackageDetailFragment.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import javax.inject.Inject;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.MainApplication;
import com.livingstoneapp.R;
import com.livingstoneapp.adapters.PackageDetailViewPagerAdapter;
import com.livingstoneapp.presenters.IPackageDetailFragmentPresenter;
import com.livingstoneapp.views.IPackageDetailFragmentView;
package com.livingstoneapp.fragments;
/**
* Created by renier on 2/2/2016.
*/
public class PackageDetailFragment extends Fragment implements IPackageDetailFragmentView {
public static String ARG_PACKAGE_NAME = "PackageName";
public static String ARG_2_PANE = "2Pane";
@Inject
IPackageDetailFragmentPresenter mPresenter;
@Bind(R.id.progress_bar)
ProgressBar mProgressBar;
@Bind(R.id.tabs)
TabLayout mTabLayout;
@Bind(R.id.viewpager)
ViewPager mViewPager;
|
private PackageDetailViewPagerAdapter mViewPagerAdapter;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/fragments/PackageDetailFragment.java
|
// Path: app/src/main/java/com/livingstoneapp/MainApplication.java
// public class MainApplication extends Application {
// private Graph mGraph;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// mGraph = Graph.Initializer.init(this, false);
// }
//
// public Graph getGraph() {
// return mGraph;
// }
//
// public void setMockMode(boolean provideMocks) {
// mGraph = Graph.Initializer.init(this, provideMocks);
// }
//
// public static MainApplication from(@NonNull Context context) {
// return (MainApplication) context.getApplicationContext();
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/adapters/PackageDetailViewPagerAdapter.java
// public class PackageDetailViewPagerAdapter extends FragmentPagerAdapter {
// private final List<Fragment> mFragmentList = new ArrayList<>();
// private final List<String> mFragmentTitleList = new ArrayList<>();
//
// public PackageDetailViewPagerAdapter(FragmentManager manager) {
// super(manager);
// }
//
// @Override
// public Fragment getItem(int position) {
// return mFragmentList.get(position);
// }
//
// @Override
// public int getCount() {
// return mFragmentList.size();
// }
//
// public void addFragment(Fragment fragment, String title) {
// mFragmentList.add(fragment);
// mFragmentTitleList.add(title);
// }
//
// @Override
// public CharSequence getPageTitle(int position) {
// return mFragmentTitleList.get(position);
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageDetailFragmentPresenter.java
// public interface IPackageDetailFragmentPresenter {
// void setView(IPackageDetailFragmentView view);
// void clearView();
// void init(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageDetailFragmentView.java
// public interface IPackageDetailFragmentView {
//
// void setTitle(String title);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void initViews(String appName, String packageName);
// void showError(String message);
// }
|
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import javax.inject.Inject;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.MainApplication;
import com.livingstoneapp.R;
import com.livingstoneapp.adapters.PackageDetailViewPagerAdapter;
import com.livingstoneapp.presenters.IPackageDetailFragmentPresenter;
import com.livingstoneapp.views.IPackageDetailFragmentView;
|
package com.livingstoneapp.fragments;
/**
* Created by renier on 2/2/2016.
*/
public class PackageDetailFragment extends Fragment implements IPackageDetailFragmentView {
public static String ARG_PACKAGE_NAME = "PackageName";
public static String ARG_2_PANE = "2Pane";
@Inject
IPackageDetailFragmentPresenter mPresenter;
@Bind(R.id.progress_bar)
ProgressBar mProgressBar;
@Bind(R.id.tabs)
TabLayout mTabLayout;
@Bind(R.id.viewpager)
ViewPager mViewPager;
private PackageDetailViewPagerAdapter mViewPagerAdapter;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_package_detail, container, false);
String packageName = getArguments().getString(ARG_PACKAGE_NAME);
|
// Path: app/src/main/java/com/livingstoneapp/MainApplication.java
// public class MainApplication extends Application {
// private Graph mGraph;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// mGraph = Graph.Initializer.init(this, false);
// }
//
// public Graph getGraph() {
// return mGraph;
// }
//
// public void setMockMode(boolean provideMocks) {
// mGraph = Graph.Initializer.init(this, provideMocks);
// }
//
// public static MainApplication from(@NonNull Context context) {
// return (MainApplication) context.getApplicationContext();
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/adapters/PackageDetailViewPagerAdapter.java
// public class PackageDetailViewPagerAdapter extends FragmentPagerAdapter {
// private final List<Fragment> mFragmentList = new ArrayList<>();
// private final List<String> mFragmentTitleList = new ArrayList<>();
//
// public PackageDetailViewPagerAdapter(FragmentManager manager) {
// super(manager);
// }
//
// @Override
// public Fragment getItem(int position) {
// return mFragmentList.get(position);
// }
//
// @Override
// public int getCount() {
// return mFragmentList.size();
// }
//
// public void addFragment(Fragment fragment, String title) {
// mFragmentList.add(fragment);
// mFragmentTitleList.add(title);
// }
//
// @Override
// public CharSequence getPageTitle(int position) {
// return mFragmentTitleList.get(position);
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageDetailFragmentPresenter.java
// public interface IPackageDetailFragmentPresenter {
// void setView(IPackageDetailFragmentView view);
// void clearView();
// void init(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageDetailFragmentView.java
// public interface IPackageDetailFragmentView {
//
// void setTitle(String title);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void initViews(String appName, String packageName);
// void showError(String message);
// }
// Path: app/src/main/java/com/livingstoneapp/fragments/PackageDetailFragment.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import javax.inject.Inject;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.MainApplication;
import com.livingstoneapp.R;
import com.livingstoneapp.adapters.PackageDetailViewPagerAdapter;
import com.livingstoneapp.presenters.IPackageDetailFragmentPresenter;
import com.livingstoneapp.views.IPackageDetailFragmentView;
package com.livingstoneapp.fragments;
/**
* Created by renier on 2/2/2016.
*/
public class PackageDetailFragment extends Fragment implements IPackageDetailFragmentView {
public static String ARG_PACKAGE_NAME = "PackageName";
public static String ARG_2_PANE = "2Pane";
@Inject
IPackageDetailFragmentPresenter mPresenter;
@Bind(R.id.progress_bar)
ProgressBar mProgressBar;
@Bind(R.id.tabs)
TabLayout mTabLayout;
@Bind(R.id.viewpager)
ViewPager mViewPager;
private PackageDetailViewPagerAdapter mViewPagerAdapter;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_package_detail, container, false);
String packageName = getArguments().getString(ARG_PACKAGE_NAME);
|
MainApplication.from(getActivity()).getGraph().inject(this);
|
oosthuizenr/Livingstone
|
app/src/test/java/com/livingstoneapp/presenters/PackageListActivityPresenterImplTest.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
//
// Path: app/src/test/java/com/livingstoneapp/presenters/utils/RxSchedulersOverrideRule.java
// public class RxSchedulersOverrideRule implements TestRule {
//
// private final RxJavaSchedulersHook mRxJavaSchedulersHook = new RxJavaSchedulersHook() {
// @Override
// public Scheduler getIOScheduler() {
// return Schedulers.immediate();
// }
//
// @Override
// public Scheduler getNewThreadScheduler() {
// return Schedulers.immediate();
// }
// };
//
// private final RxAndroidSchedulersHook mRxAndroidSchedulersHook = new RxAndroidSchedulersHook() {
// @Override
// public Scheduler getMainThreadScheduler() {
// return Schedulers.immediate();
// }
// };
//
// // Hack to get around RxJavaPlugins.reset() not being public
// // See https://github.com/ReactiveX/RxJava/issues/2297
// // Hopefully the method will be public in new releases of RxAndroid and we can remove the hack.
// private void callResetViaReflectionIn(RxJavaPlugins rxJavaPlugins)
// throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
// Method method = rxJavaPlugins.getClass().getDeclaredMethod("reset");
// method.setAccessible(true);
// method.invoke(rxJavaPlugins);
// }
//
// @Override
// public Statement apply(final Statement base, Description description) {
// return new Statement() {
// @Override
// public void evaluate() throws Throwable {
// RxAndroidPlugins.getInstance().reset();
// RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook);
// callResetViaReflectionIn(RxJavaPlugins.getInstance());
// RxJavaPlugins.getInstance().registerSchedulersHook(mRxJavaSchedulersHook);
//
// base.evaluate();
//
// RxAndroidPlugins.getInstance().reset();
// callResetViaReflectionIn(RxJavaPlugins.getInstance());
// }
// };
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
// public interface IPackageListView {
// void init();
// void setInstalledPackages(List<InstalledPackageHeader> items);
// void setError(String message);
// void startDetailActivity(InstalledPackageHeader item);
// void setDetailFragment(InstalledPackageHeader item);
// void showWaitDialog();
// void hideWaitDialog();
// void showContentView();
// void hideContentView();
// }
|
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.models.InstalledPackageHeader;
import com.livingstoneapp.presenters.utils.RxSchedulersOverrideRule;
import com.livingstoneapp.views.IPackageListView;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;
import static org.mockito.Matchers.anyListOf;
|
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/03/11.
*/
@RunWith(MockitoJUnitRunner.class)
public class PackageListActivityPresenterImplTest {
@Mock
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
//
// Path: app/src/test/java/com/livingstoneapp/presenters/utils/RxSchedulersOverrideRule.java
// public class RxSchedulersOverrideRule implements TestRule {
//
// private final RxJavaSchedulersHook mRxJavaSchedulersHook = new RxJavaSchedulersHook() {
// @Override
// public Scheduler getIOScheduler() {
// return Schedulers.immediate();
// }
//
// @Override
// public Scheduler getNewThreadScheduler() {
// return Schedulers.immediate();
// }
// };
//
// private final RxAndroidSchedulersHook mRxAndroidSchedulersHook = new RxAndroidSchedulersHook() {
// @Override
// public Scheduler getMainThreadScheduler() {
// return Schedulers.immediate();
// }
// };
//
// // Hack to get around RxJavaPlugins.reset() not being public
// // See https://github.com/ReactiveX/RxJava/issues/2297
// // Hopefully the method will be public in new releases of RxAndroid and we can remove the hack.
// private void callResetViaReflectionIn(RxJavaPlugins rxJavaPlugins)
// throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
// Method method = rxJavaPlugins.getClass().getDeclaredMethod("reset");
// method.setAccessible(true);
// method.invoke(rxJavaPlugins);
// }
//
// @Override
// public Statement apply(final Statement base, Description description) {
// return new Statement() {
// @Override
// public void evaluate() throws Throwable {
// RxAndroidPlugins.getInstance().reset();
// RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook);
// callResetViaReflectionIn(RxJavaPlugins.getInstance());
// RxJavaPlugins.getInstance().registerSchedulersHook(mRxJavaSchedulersHook);
//
// base.evaluate();
//
// RxAndroidPlugins.getInstance().reset();
// callResetViaReflectionIn(RxJavaPlugins.getInstance());
// }
// };
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
// public interface IPackageListView {
// void init();
// void setInstalledPackages(List<InstalledPackageHeader> items);
// void setError(String message);
// void startDetailActivity(InstalledPackageHeader item);
// void setDetailFragment(InstalledPackageHeader item);
// void showWaitDialog();
// void hideWaitDialog();
// void showContentView();
// void hideContentView();
// }
// Path: app/src/test/java/com/livingstoneapp/presenters/PackageListActivityPresenterImplTest.java
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.models.InstalledPackageHeader;
import com.livingstoneapp.presenters.utils.RxSchedulersOverrideRule;
import com.livingstoneapp.views.IPackageListView;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;
import static org.mockito.Matchers.anyListOf;
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/03/11.
*/
@RunWith(MockitoJUnitRunner.class)
public class PackageListActivityPresenterImplTest {
@Mock
|
IPackageListView mView;
|
oosthuizenr/Livingstone
|
app/src/test/java/com/livingstoneapp/presenters/PackageListActivityPresenterImplTest.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
//
// Path: app/src/test/java/com/livingstoneapp/presenters/utils/RxSchedulersOverrideRule.java
// public class RxSchedulersOverrideRule implements TestRule {
//
// private final RxJavaSchedulersHook mRxJavaSchedulersHook = new RxJavaSchedulersHook() {
// @Override
// public Scheduler getIOScheduler() {
// return Schedulers.immediate();
// }
//
// @Override
// public Scheduler getNewThreadScheduler() {
// return Schedulers.immediate();
// }
// };
//
// private final RxAndroidSchedulersHook mRxAndroidSchedulersHook = new RxAndroidSchedulersHook() {
// @Override
// public Scheduler getMainThreadScheduler() {
// return Schedulers.immediate();
// }
// };
//
// // Hack to get around RxJavaPlugins.reset() not being public
// // See https://github.com/ReactiveX/RxJava/issues/2297
// // Hopefully the method will be public in new releases of RxAndroid and we can remove the hack.
// private void callResetViaReflectionIn(RxJavaPlugins rxJavaPlugins)
// throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
// Method method = rxJavaPlugins.getClass().getDeclaredMethod("reset");
// method.setAccessible(true);
// method.invoke(rxJavaPlugins);
// }
//
// @Override
// public Statement apply(final Statement base, Description description) {
// return new Statement() {
// @Override
// public void evaluate() throws Throwable {
// RxAndroidPlugins.getInstance().reset();
// RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook);
// callResetViaReflectionIn(RxJavaPlugins.getInstance());
// RxJavaPlugins.getInstance().registerSchedulersHook(mRxJavaSchedulersHook);
//
// base.evaluate();
//
// RxAndroidPlugins.getInstance().reset();
// callResetViaReflectionIn(RxJavaPlugins.getInstance());
// }
// };
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
// public interface IPackageListView {
// void init();
// void setInstalledPackages(List<InstalledPackageHeader> items);
// void setError(String message);
// void startDetailActivity(InstalledPackageHeader item);
// void setDetailFragment(InstalledPackageHeader item);
// void showWaitDialog();
// void hideWaitDialog();
// void showContentView();
// void hideContentView();
// }
|
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.models.InstalledPackageHeader;
import com.livingstoneapp.presenters.utils.RxSchedulersOverrideRule;
import com.livingstoneapp.views.IPackageListView;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;
import static org.mockito.Matchers.anyListOf;
|
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/03/11.
*/
@RunWith(MockitoJUnitRunner.class)
public class PackageListActivityPresenterImplTest {
@Mock
IPackageListView mView;
@Mock
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
//
// Path: app/src/test/java/com/livingstoneapp/presenters/utils/RxSchedulersOverrideRule.java
// public class RxSchedulersOverrideRule implements TestRule {
//
// private final RxJavaSchedulersHook mRxJavaSchedulersHook = new RxJavaSchedulersHook() {
// @Override
// public Scheduler getIOScheduler() {
// return Schedulers.immediate();
// }
//
// @Override
// public Scheduler getNewThreadScheduler() {
// return Schedulers.immediate();
// }
// };
//
// private final RxAndroidSchedulersHook mRxAndroidSchedulersHook = new RxAndroidSchedulersHook() {
// @Override
// public Scheduler getMainThreadScheduler() {
// return Schedulers.immediate();
// }
// };
//
// // Hack to get around RxJavaPlugins.reset() not being public
// // See https://github.com/ReactiveX/RxJava/issues/2297
// // Hopefully the method will be public in new releases of RxAndroid and we can remove the hack.
// private void callResetViaReflectionIn(RxJavaPlugins rxJavaPlugins)
// throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
// Method method = rxJavaPlugins.getClass().getDeclaredMethod("reset");
// method.setAccessible(true);
// method.invoke(rxJavaPlugins);
// }
//
// @Override
// public Statement apply(final Statement base, Description description) {
// return new Statement() {
// @Override
// public void evaluate() throws Throwable {
// RxAndroidPlugins.getInstance().reset();
// RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook);
// callResetViaReflectionIn(RxJavaPlugins.getInstance());
// RxJavaPlugins.getInstance().registerSchedulersHook(mRxJavaSchedulersHook);
//
// base.evaluate();
//
// RxAndroidPlugins.getInstance().reset();
// callResetViaReflectionIn(RxJavaPlugins.getInstance());
// }
// };
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
// public interface IPackageListView {
// void init();
// void setInstalledPackages(List<InstalledPackageHeader> items);
// void setError(String message);
// void startDetailActivity(InstalledPackageHeader item);
// void setDetailFragment(InstalledPackageHeader item);
// void showWaitDialog();
// void hideWaitDialog();
// void showContentView();
// void hideContentView();
// }
// Path: app/src/test/java/com/livingstoneapp/presenters/PackageListActivityPresenterImplTest.java
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.models.InstalledPackageHeader;
import com.livingstoneapp.presenters.utils.RxSchedulersOverrideRule;
import com.livingstoneapp.views.IPackageListView;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;
import static org.mockito.Matchers.anyListOf;
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/03/11.
*/
@RunWith(MockitoJUnitRunner.class)
public class PackageListActivityPresenterImplTest {
@Mock
IPackageListView mView;
@Mock
|
IPackageInteractor mPackageInteractor;
|
oosthuizenr/Livingstone
|
app/src/test/java/com/livingstoneapp/presenters/PackageListActivityPresenterImplTest.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
//
// Path: app/src/test/java/com/livingstoneapp/presenters/utils/RxSchedulersOverrideRule.java
// public class RxSchedulersOverrideRule implements TestRule {
//
// private final RxJavaSchedulersHook mRxJavaSchedulersHook = new RxJavaSchedulersHook() {
// @Override
// public Scheduler getIOScheduler() {
// return Schedulers.immediate();
// }
//
// @Override
// public Scheduler getNewThreadScheduler() {
// return Schedulers.immediate();
// }
// };
//
// private final RxAndroidSchedulersHook mRxAndroidSchedulersHook = new RxAndroidSchedulersHook() {
// @Override
// public Scheduler getMainThreadScheduler() {
// return Schedulers.immediate();
// }
// };
//
// // Hack to get around RxJavaPlugins.reset() not being public
// // See https://github.com/ReactiveX/RxJava/issues/2297
// // Hopefully the method will be public in new releases of RxAndroid and we can remove the hack.
// private void callResetViaReflectionIn(RxJavaPlugins rxJavaPlugins)
// throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
// Method method = rxJavaPlugins.getClass().getDeclaredMethod("reset");
// method.setAccessible(true);
// method.invoke(rxJavaPlugins);
// }
//
// @Override
// public Statement apply(final Statement base, Description description) {
// return new Statement() {
// @Override
// public void evaluate() throws Throwable {
// RxAndroidPlugins.getInstance().reset();
// RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook);
// callResetViaReflectionIn(RxJavaPlugins.getInstance());
// RxJavaPlugins.getInstance().registerSchedulersHook(mRxJavaSchedulersHook);
//
// base.evaluate();
//
// RxAndroidPlugins.getInstance().reset();
// callResetViaReflectionIn(RxJavaPlugins.getInstance());
// }
// };
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
// public interface IPackageListView {
// void init();
// void setInstalledPackages(List<InstalledPackageHeader> items);
// void setError(String message);
// void startDetailActivity(InstalledPackageHeader item);
// void setDetailFragment(InstalledPackageHeader item);
// void showWaitDialog();
// void hideWaitDialog();
// void showContentView();
// void hideContentView();
// }
|
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.models.InstalledPackageHeader;
import com.livingstoneapp.presenters.utils.RxSchedulersOverrideRule;
import com.livingstoneapp.views.IPackageListView;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;
import static org.mockito.Matchers.anyListOf;
|
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/03/11.
*/
@RunWith(MockitoJUnitRunner.class)
public class PackageListActivityPresenterImplTest {
@Mock
IPackageListView mView;
@Mock
IPackageInteractor mPackageInteractor;
private IPackageListActivityPresenter mPresenter;
@Rule
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
//
// Path: app/src/test/java/com/livingstoneapp/presenters/utils/RxSchedulersOverrideRule.java
// public class RxSchedulersOverrideRule implements TestRule {
//
// private final RxJavaSchedulersHook mRxJavaSchedulersHook = new RxJavaSchedulersHook() {
// @Override
// public Scheduler getIOScheduler() {
// return Schedulers.immediate();
// }
//
// @Override
// public Scheduler getNewThreadScheduler() {
// return Schedulers.immediate();
// }
// };
//
// private final RxAndroidSchedulersHook mRxAndroidSchedulersHook = new RxAndroidSchedulersHook() {
// @Override
// public Scheduler getMainThreadScheduler() {
// return Schedulers.immediate();
// }
// };
//
// // Hack to get around RxJavaPlugins.reset() not being public
// // See https://github.com/ReactiveX/RxJava/issues/2297
// // Hopefully the method will be public in new releases of RxAndroid and we can remove the hack.
// private void callResetViaReflectionIn(RxJavaPlugins rxJavaPlugins)
// throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
// Method method = rxJavaPlugins.getClass().getDeclaredMethod("reset");
// method.setAccessible(true);
// method.invoke(rxJavaPlugins);
// }
//
// @Override
// public Statement apply(final Statement base, Description description) {
// return new Statement() {
// @Override
// public void evaluate() throws Throwable {
// RxAndroidPlugins.getInstance().reset();
// RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook);
// callResetViaReflectionIn(RxJavaPlugins.getInstance());
// RxJavaPlugins.getInstance().registerSchedulersHook(mRxJavaSchedulersHook);
//
// base.evaluate();
//
// RxAndroidPlugins.getInstance().reset();
// callResetViaReflectionIn(RxJavaPlugins.getInstance());
// }
// };
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
// public interface IPackageListView {
// void init();
// void setInstalledPackages(List<InstalledPackageHeader> items);
// void setError(String message);
// void startDetailActivity(InstalledPackageHeader item);
// void setDetailFragment(InstalledPackageHeader item);
// void showWaitDialog();
// void hideWaitDialog();
// void showContentView();
// void hideContentView();
// }
// Path: app/src/test/java/com/livingstoneapp/presenters/PackageListActivityPresenterImplTest.java
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.models.InstalledPackageHeader;
import com.livingstoneapp.presenters.utils.RxSchedulersOverrideRule;
import com.livingstoneapp.views.IPackageListView;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;
import static org.mockito.Matchers.anyListOf;
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/03/11.
*/
@RunWith(MockitoJUnitRunner.class)
public class PackageListActivityPresenterImplTest {
@Mock
IPackageListView mView;
@Mock
IPackageInteractor mPackageInteractor;
private IPackageListActivityPresenter mPresenter;
@Rule
|
public final RxSchedulersOverrideRule mOverrideSchedulersRule = new RxSchedulersOverrideRule();
|
oosthuizenr/Livingstone
|
app/src/test/java/com/livingstoneapp/presenters/PackageListActivityPresenterImplTest.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
//
// Path: app/src/test/java/com/livingstoneapp/presenters/utils/RxSchedulersOverrideRule.java
// public class RxSchedulersOverrideRule implements TestRule {
//
// private final RxJavaSchedulersHook mRxJavaSchedulersHook = new RxJavaSchedulersHook() {
// @Override
// public Scheduler getIOScheduler() {
// return Schedulers.immediate();
// }
//
// @Override
// public Scheduler getNewThreadScheduler() {
// return Schedulers.immediate();
// }
// };
//
// private final RxAndroidSchedulersHook mRxAndroidSchedulersHook = new RxAndroidSchedulersHook() {
// @Override
// public Scheduler getMainThreadScheduler() {
// return Schedulers.immediate();
// }
// };
//
// // Hack to get around RxJavaPlugins.reset() not being public
// // See https://github.com/ReactiveX/RxJava/issues/2297
// // Hopefully the method will be public in new releases of RxAndroid and we can remove the hack.
// private void callResetViaReflectionIn(RxJavaPlugins rxJavaPlugins)
// throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
// Method method = rxJavaPlugins.getClass().getDeclaredMethod("reset");
// method.setAccessible(true);
// method.invoke(rxJavaPlugins);
// }
//
// @Override
// public Statement apply(final Statement base, Description description) {
// return new Statement() {
// @Override
// public void evaluate() throws Throwable {
// RxAndroidPlugins.getInstance().reset();
// RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook);
// callResetViaReflectionIn(RxJavaPlugins.getInstance());
// RxJavaPlugins.getInstance().registerSchedulersHook(mRxJavaSchedulersHook);
//
// base.evaluate();
//
// RxAndroidPlugins.getInstance().reset();
// callResetViaReflectionIn(RxJavaPlugins.getInstance());
// }
// };
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
// public interface IPackageListView {
// void init();
// void setInstalledPackages(List<InstalledPackageHeader> items);
// void setError(String message);
// void startDetailActivity(InstalledPackageHeader item);
// void setDetailFragment(InstalledPackageHeader item);
// void showWaitDialog();
// void hideWaitDialog();
// void showContentView();
// void hideContentView();
// }
|
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.models.InstalledPackageHeader;
import com.livingstoneapp.presenters.utils.RxSchedulersOverrideRule;
import com.livingstoneapp.views.IPackageListView;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;
import static org.mockito.Matchers.anyListOf;
|
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/03/11.
*/
@RunWith(MockitoJUnitRunner.class)
public class PackageListActivityPresenterImplTest {
@Mock
IPackageListView mView;
@Mock
IPackageInteractor mPackageInteractor;
private IPackageListActivityPresenter mPresenter;
@Rule
public final RxSchedulersOverrideRule mOverrideSchedulersRule = new RxSchedulersOverrideRule();
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mPresenter = new PackageListActivityPresenterImpl(mPackageInteractor);
mPresenter.setView(mView);
}
@After
public void tearDown() throws Exception {
}
@Test
public void testInit() {
mPresenter.init();
verify(mView, times(1)).init();
}
@Test
public void testLoadPackages() {
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
//
// Path: app/src/test/java/com/livingstoneapp/presenters/utils/RxSchedulersOverrideRule.java
// public class RxSchedulersOverrideRule implements TestRule {
//
// private final RxJavaSchedulersHook mRxJavaSchedulersHook = new RxJavaSchedulersHook() {
// @Override
// public Scheduler getIOScheduler() {
// return Schedulers.immediate();
// }
//
// @Override
// public Scheduler getNewThreadScheduler() {
// return Schedulers.immediate();
// }
// };
//
// private final RxAndroidSchedulersHook mRxAndroidSchedulersHook = new RxAndroidSchedulersHook() {
// @Override
// public Scheduler getMainThreadScheduler() {
// return Schedulers.immediate();
// }
// };
//
// // Hack to get around RxJavaPlugins.reset() not being public
// // See https://github.com/ReactiveX/RxJava/issues/2297
// // Hopefully the method will be public in new releases of RxAndroid and we can remove the hack.
// private void callResetViaReflectionIn(RxJavaPlugins rxJavaPlugins)
// throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
// Method method = rxJavaPlugins.getClass().getDeclaredMethod("reset");
// method.setAccessible(true);
// method.invoke(rxJavaPlugins);
// }
//
// @Override
// public Statement apply(final Statement base, Description description) {
// return new Statement() {
// @Override
// public void evaluate() throws Throwable {
// RxAndroidPlugins.getInstance().reset();
// RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook);
// callResetViaReflectionIn(RxJavaPlugins.getInstance());
// RxJavaPlugins.getInstance().registerSchedulersHook(mRxJavaSchedulersHook);
//
// base.evaluate();
//
// RxAndroidPlugins.getInstance().reset();
// callResetViaReflectionIn(RxJavaPlugins.getInstance());
// }
// };
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
// public interface IPackageListView {
// void init();
// void setInstalledPackages(List<InstalledPackageHeader> items);
// void setError(String message);
// void startDetailActivity(InstalledPackageHeader item);
// void setDetailFragment(InstalledPackageHeader item);
// void showWaitDialog();
// void hideWaitDialog();
// void showContentView();
// void hideContentView();
// }
// Path: app/src/test/java/com/livingstoneapp/presenters/PackageListActivityPresenterImplTest.java
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.models.InstalledPackageHeader;
import com.livingstoneapp.presenters.utils.RxSchedulersOverrideRule;
import com.livingstoneapp.views.IPackageListView;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;
import static org.mockito.Matchers.anyListOf;
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/03/11.
*/
@RunWith(MockitoJUnitRunner.class)
public class PackageListActivityPresenterImplTest {
@Mock
IPackageListView mView;
@Mock
IPackageInteractor mPackageInteractor;
private IPackageListActivityPresenter mPresenter;
@Rule
public final RxSchedulersOverrideRule mOverrideSchedulersRule = new RxSchedulersOverrideRule();
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mPresenter = new PackageListActivityPresenterImpl(mPackageInteractor);
mPresenter.setView(mView);
}
@After
public void tearDown() throws Exception {
}
@Test
public void testInit() {
mPresenter.init();
verify(mView, times(1)).init();
}
@Test
public void testLoadPackages() {
|
ArrayList<InstalledPackageHeader> toReturn = new ArrayList<>();
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/adapters/RequestedFeaturesAdapter.java
|
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListener.java
// public interface RecyclerViewOnClickListener<T> {
// void onItemClick(T item);
// }
//
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListenerInternal.java
// public interface RecyclerViewOnClickListenerInternal {
// void onItemClick(int position);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/FeatureInfoInternal.java
// public class FeatureInfoInternal {
// private String mName;
// private boolean mRequired;
// private String mGLESVersion;
//
// public FeatureInfoInternal(String mName, boolean mRequired, String mGLESVersion) {
//
// this.mName = mName;
// this.mRequired = mRequired;
// this.mGLESVersion = mGLESVersion;
// }
//
// public String getName() {
// return mName;
// }
//
// public boolean isRequired() {
// return mRequired;
// }
//
// public String getGLESVersion() {
// return mGLESVersion;
// }
// }
|
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.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.R;
import com.livingstoneapp.helpers.RecyclerViewOnClickListener;
import com.livingstoneapp.helpers.RecyclerViewOnClickListenerInternal;
import com.livingstoneapp.models.FeatureInfoInternal;
|
holder.tvName.setVisibility(View.VISIBLE);
holder.tvName.setText(mData.get(position).getName());
} else {
holder.tvName.setVisibility(View.GONE);
}
if (!mData.get(position).getGLESVersion().equalsIgnoreCase(holder.tvGLESVersion.getContext().getString(R.string.requested_features_empty_gles))) {
holder.tvGLESVersion.setVisibility(View.VISIBLE);
holder.tvGLESVersion.setText(holder.tvGLESVersion.getContext().getString(R.string.requested_features_gles_version_prefix) + " " + mData.get(position).getGLESVersion());
} else {
holder.tvGLESVersion.setVisibility(View.GONE);
}
if (mData.get(position).isRequired()) {
holder.tvRequiredHeader.setVisibility(View.VISIBLE);
holder.tvNotRequiredHeader.setVisibility(View.GONE);
} else {
holder.tvRequiredHeader.setVisibility(View.GONE);
holder.tvNotRequiredHeader.setVisibility(View.VISIBLE);
}
}
@Override
public int getItemCount() {
return mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
|
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListener.java
// public interface RecyclerViewOnClickListener<T> {
// void onItemClick(T item);
// }
//
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListenerInternal.java
// public interface RecyclerViewOnClickListenerInternal {
// void onItemClick(int position);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/FeatureInfoInternal.java
// public class FeatureInfoInternal {
// private String mName;
// private boolean mRequired;
// private String mGLESVersion;
//
// public FeatureInfoInternal(String mName, boolean mRequired, String mGLESVersion) {
//
// this.mName = mName;
// this.mRequired = mRequired;
// this.mGLESVersion = mGLESVersion;
// }
//
// public String getName() {
// return mName;
// }
//
// public boolean isRequired() {
// return mRequired;
// }
//
// public String getGLESVersion() {
// return mGLESVersion;
// }
// }
// Path: app/src/main/java/com/livingstoneapp/adapters/RequestedFeaturesAdapter.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.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.R;
import com.livingstoneapp.helpers.RecyclerViewOnClickListener;
import com.livingstoneapp.helpers.RecyclerViewOnClickListenerInternal;
import com.livingstoneapp.models.FeatureInfoInternal;
holder.tvName.setVisibility(View.VISIBLE);
holder.tvName.setText(mData.get(position).getName());
} else {
holder.tvName.setVisibility(View.GONE);
}
if (!mData.get(position).getGLESVersion().equalsIgnoreCase(holder.tvGLESVersion.getContext().getString(R.string.requested_features_empty_gles))) {
holder.tvGLESVersion.setVisibility(View.VISIBLE);
holder.tvGLESVersion.setText(holder.tvGLESVersion.getContext().getString(R.string.requested_features_gles_version_prefix) + " " + mData.get(position).getGLESVersion());
} else {
holder.tvGLESVersion.setVisibility(View.GONE);
}
if (mData.get(position).isRequired()) {
holder.tvRequiredHeader.setVisibility(View.VISIBLE);
holder.tvNotRequiredHeader.setVisibility(View.GONE);
} else {
holder.tvRequiredHeader.setVisibility(View.GONE);
holder.tvNotRequiredHeader.setVisibility(View.VISIBLE);
}
}
@Override
public int getItemCount() {
return mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
|
private RecyclerViewOnClickListenerInternal mListener;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
|
// Path: app/src/main/java/com/livingstoneapp/models/AppInfo.java
// public class AppInfo {
//
// private ArrayList<String> mSignatures;
// private ArrayList<String> mFlags;
// private DirectoryInfo mDirectoryInfo;
// private GeneralInfo mGeneralInfo;
//
// public ArrayList<String> getSignatures() {
// return mSignatures;
// }
//
// public void setSignatures(ArrayList<String> mSignatures) {
// this.mSignatures = mSignatures;
// }
//
// public ArrayList<String> getFlags() {
// return mFlags;
// }
// public void setFlags(ArrayList<String> mFlags) {
// this.mFlags = mFlags;
// }
//
// public DirectoryInfo getDirectoryInfo() {
// return mDirectoryInfo;
// }
//
// public void setDirectoryInfo(DirectoryInfo mDirectoryInfo) {
// this.mDirectoryInfo = mDirectoryInfo;
// }
//
// public GeneralInfo getGeneralInfo() {
// return mGeneralInfo;
// }
//
// public void setGeneralInfo(GeneralInfo mGeneralInfo) {
// this.mGeneralInfo = mGeneralInfo;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/FeatureInfoInternal.java
// public class FeatureInfoInternal {
// private String mName;
// private boolean mRequired;
// private String mGLESVersion;
//
// public FeatureInfoInternal(String mName, boolean mRequired, String mGLESVersion) {
//
// this.mName = mName;
// this.mRequired = mRequired;
// this.mGLESVersion = mGLESVersion;
// }
//
// public String getName() {
// return mName;
// }
//
// public boolean isRequired() {
// return mRequired;
// }
//
// public String getGLESVersion() {
// return mGLESVersion;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
|
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.AppInfo;
import com.livingstoneapp.models.FeatureInfoInternal;
import com.livingstoneapp.models.InstalledPackageHeader;
|
package com.livingstoneapp.interactors;
/**
* Created by renier on 2/2/2016.
*/
public interface IPackageInteractor {
Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
Observable<String> getAppNameFromPackage(String packageName);
|
// Path: app/src/main/java/com/livingstoneapp/models/AppInfo.java
// public class AppInfo {
//
// private ArrayList<String> mSignatures;
// private ArrayList<String> mFlags;
// private DirectoryInfo mDirectoryInfo;
// private GeneralInfo mGeneralInfo;
//
// public ArrayList<String> getSignatures() {
// return mSignatures;
// }
//
// public void setSignatures(ArrayList<String> mSignatures) {
// this.mSignatures = mSignatures;
// }
//
// public ArrayList<String> getFlags() {
// return mFlags;
// }
// public void setFlags(ArrayList<String> mFlags) {
// this.mFlags = mFlags;
// }
//
// public DirectoryInfo getDirectoryInfo() {
// return mDirectoryInfo;
// }
//
// public void setDirectoryInfo(DirectoryInfo mDirectoryInfo) {
// this.mDirectoryInfo = mDirectoryInfo;
// }
//
// public GeneralInfo getGeneralInfo() {
// return mGeneralInfo;
// }
//
// public void setGeneralInfo(GeneralInfo mGeneralInfo) {
// this.mGeneralInfo = mGeneralInfo;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/FeatureInfoInternal.java
// public class FeatureInfoInternal {
// private String mName;
// private boolean mRequired;
// private String mGLESVersion;
//
// public FeatureInfoInternal(String mName, boolean mRequired, String mGLESVersion) {
//
// this.mName = mName;
// this.mRequired = mRequired;
// this.mGLESVersion = mGLESVersion;
// }
//
// public String getName() {
// return mName;
// }
//
// public boolean isRequired() {
// return mRequired;
// }
//
// public String getGLESVersion() {
// return mGLESVersion;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.AppInfo;
import com.livingstoneapp.models.FeatureInfoInternal;
import com.livingstoneapp.models.InstalledPackageHeader;
package com.livingstoneapp.interactors;
/**
* Created by renier on 2/2/2016.
*/
public interface IPackageInteractor {
Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
Observable<String> getAppNameFromPackage(String packageName);
|
Observable<AppInfo> getApplicationInfo(String packageName);
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
|
// Path: app/src/main/java/com/livingstoneapp/models/AppInfo.java
// public class AppInfo {
//
// private ArrayList<String> mSignatures;
// private ArrayList<String> mFlags;
// private DirectoryInfo mDirectoryInfo;
// private GeneralInfo mGeneralInfo;
//
// public ArrayList<String> getSignatures() {
// return mSignatures;
// }
//
// public void setSignatures(ArrayList<String> mSignatures) {
// this.mSignatures = mSignatures;
// }
//
// public ArrayList<String> getFlags() {
// return mFlags;
// }
// public void setFlags(ArrayList<String> mFlags) {
// this.mFlags = mFlags;
// }
//
// public DirectoryInfo getDirectoryInfo() {
// return mDirectoryInfo;
// }
//
// public void setDirectoryInfo(DirectoryInfo mDirectoryInfo) {
// this.mDirectoryInfo = mDirectoryInfo;
// }
//
// public GeneralInfo getGeneralInfo() {
// return mGeneralInfo;
// }
//
// public void setGeneralInfo(GeneralInfo mGeneralInfo) {
// this.mGeneralInfo = mGeneralInfo;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/FeatureInfoInternal.java
// public class FeatureInfoInternal {
// private String mName;
// private boolean mRequired;
// private String mGLESVersion;
//
// public FeatureInfoInternal(String mName, boolean mRequired, String mGLESVersion) {
//
// this.mName = mName;
// this.mRequired = mRequired;
// this.mGLESVersion = mGLESVersion;
// }
//
// public String getName() {
// return mName;
// }
//
// public boolean isRequired() {
// return mRequired;
// }
//
// public String getGLESVersion() {
// return mGLESVersion;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
|
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.AppInfo;
import com.livingstoneapp.models.FeatureInfoInternal;
import com.livingstoneapp.models.InstalledPackageHeader;
|
package com.livingstoneapp.interactors;
/**
* Created by renier on 2/2/2016.
*/
public interface IPackageInteractor {
Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
Observable<String> getAppNameFromPackage(String packageName);
Observable<AppInfo> getApplicationInfo(String packageName);
|
// Path: app/src/main/java/com/livingstoneapp/models/AppInfo.java
// public class AppInfo {
//
// private ArrayList<String> mSignatures;
// private ArrayList<String> mFlags;
// private DirectoryInfo mDirectoryInfo;
// private GeneralInfo mGeneralInfo;
//
// public ArrayList<String> getSignatures() {
// return mSignatures;
// }
//
// public void setSignatures(ArrayList<String> mSignatures) {
// this.mSignatures = mSignatures;
// }
//
// public ArrayList<String> getFlags() {
// return mFlags;
// }
// public void setFlags(ArrayList<String> mFlags) {
// this.mFlags = mFlags;
// }
//
// public DirectoryInfo getDirectoryInfo() {
// return mDirectoryInfo;
// }
//
// public void setDirectoryInfo(DirectoryInfo mDirectoryInfo) {
// this.mDirectoryInfo = mDirectoryInfo;
// }
//
// public GeneralInfo getGeneralInfo() {
// return mGeneralInfo;
// }
//
// public void setGeneralInfo(GeneralInfo mGeneralInfo) {
// this.mGeneralInfo = mGeneralInfo;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/FeatureInfoInternal.java
// public class FeatureInfoInternal {
// private String mName;
// private boolean mRequired;
// private String mGLESVersion;
//
// public FeatureInfoInternal(String mName, boolean mRequired, String mGLESVersion) {
//
// this.mName = mName;
// this.mRequired = mRequired;
// this.mGLESVersion = mGLESVersion;
// }
//
// public String getName() {
// return mName;
// }
//
// public boolean isRequired() {
// return mRequired;
// }
//
// public String getGLESVersion() {
// return mGLESVersion;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.AppInfo;
import com.livingstoneapp.models.FeatureInfoInternal;
import com.livingstoneapp.models.InstalledPackageHeader;
package com.livingstoneapp.interactors;
/**
* Created by renier on 2/2/2016.
*/
public interface IPackageInteractor {
Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
Observable<String> getAppNameFromPackage(String packageName);
Observable<AppInfo> getApplicationInfo(String packageName);
|
Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/presenters/ServicesFragmentPresenterImpl.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IServiceInteractor.java
// public interface IServiceInteractor {
// Observable<ArrayList<ServiceInfoInternal>> getServices(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IServicesFragmentView.java
// public interface IServicesFragmentView {
// void showError(String message);
// void setModel(ArrayList<ServiceInfoInternal> services);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void showNoValuesText();
// void hideNoValuesText();
// }
|
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IServiceInteractor;
import com.livingstoneapp.views.IServicesFragmentView;
|
package com.livingstoneapp.presenters;
/**
* Created by renier on 2/18/2016.
*/
public class ServicesFragmentPresenterImpl implements IServicesFragmentPresenter {
private IServiceInteractor mInteractor;
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IServiceInteractor.java
// public interface IServiceInteractor {
// Observable<ArrayList<ServiceInfoInternal>> getServices(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IServicesFragmentView.java
// public interface IServicesFragmentView {
// void showError(String message);
// void setModel(ArrayList<ServiceInfoInternal> services);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void showNoValuesText();
// void hideNoValuesText();
// }
// Path: app/src/main/java/com/livingstoneapp/presenters/ServicesFragmentPresenterImpl.java
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IServiceInteractor;
import com.livingstoneapp.views.IServicesFragmentView;
package com.livingstoneapp.presenters;
/**
* Created by renier on 2/18/2016.
*/
public class ServicesFragmentPresenterImpl implements IServicesFragmentPresenter {
private IServiceInteractor mInteractor;
|
private IServicesFragmentView mView;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/presenters/IContentProviderDetailActivityPresenter.java
|
// Path: app/src/main/java/com/livingstoneapp/models/ContentProviderInfo.java
// public class ContentProviderInfo implements Parcelable {
// private String mName;
// private boolean mEnabled;
// private boolean mExported;
// private String mAuthority;
// private String mReadPermission;
// private String mWritePermission;
// private String mProcessName;
// private boolean mMultiProcess;
// private boolean mSingleUser;
// private int mInitOrder;
// private boolean mIsSyncable;
// private boolean mGrantURIPermissions;
// private ArrayList<PathPermission> mPathPermissions;
// private ArrayList<URIPermissionPattern> mURIPermissionPatterns;
//
// public ContentProviderInfo(String name) {
// this.mName = name;
// }
//
// public ContentProviderInfo(
// String mName,
// boolean mEnabled,
// boolean mExported,
// String mAuthority,
// String mReadPermission,
// String mWritePermission,
// String mProcessName,
// boolean mMultiProcess,
// boolean mSingleUser,
// int mInitOrder,
// boolean mIsSyncable,
// boolean mGrantURIPermissions,
// ArrayList<PathPermission> mPathPermissions,
// ArrayList<URIPermissionPattern> mURIPermissionPatterns) {
// this.mAuthority = mAuthority;
// this.mEnabled = mEnabled;
// this.mExported = mExported;
// this.mGrantURIPermissions = mGrantURIPermissions;
// this.mInitOrder = mInitOrder;
// this.mIsSyncable = mIsSyncable;
// this.mMultiProcess = mMultiProcess;
// this.mName = mName;
// this.mPathPermissions = mPathPermissions;
// this.mProcessName = mProcessName;
// this.mReadPermission = mReadPermission;
// this.mSingleUser = mSingleUser;
// this.mURIPermissionPatterns = mURIPermissionPatterns;
// this.mWritePermission = mWritePermission;
// }
//
// public String getAuthority() {
// return mAuthority;
// }
//
// public boolean isEnabled() {
// return mEnabled;
// }
//
// public boolean isExported() {
// return mExported;
// }
//
// public boolean isGrantURIPermissions() {
// return mGrantURIPermissions;
// }
//
// public int getInitOrder() {
// return mInitOrder;
// }
//
// public boolean isIsSyncable() {
// return mIsSyncable;
// }
//
// public boolean isMultiProcess() {
// return mMultiProcess;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<PathPermission> getPathPermissions() {
// return mPathPermissions;
// }
//
// public String getProcessName() {
// return mProcessName;
// }
//
// public String getReadPermission() {
// return mReadPermission;
// }
//
// public boolean isSingleUser() {
// return mSingleUser;
// }
//
// public ArrayList<URIPermissionPattern> getURIPermissionPatterns() {
// return mURIPermissionPatterns;
// }
//
// public String getWritePermission() {
// return mWritePermission;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// dest.writeByte(mEnabled ? (byte) 1 : (byte) 0);
// dest.writeByte(mExported ? (byte) 1 : (byte) 0);
// dest.writeString(this.mAuthority);
// dest.writeString(this.mReadPermission);
// dest.writeString(this.mWritePermission);
// dest.writeString(this.mProcessName);
// dest.writeByte(mMultiProcess ? (byte) 1 : (byte) 0);
// dest.writeByte(mSingleUser ? (byte) 1 : (byte) 0);
// dest.writeInt(this.mInitOrder);
// dest.writeByte(mIsSyncable ? (byte) 1 : (byte) 0);
// dest.writeByte(mGrantURIPermissions ? (byte) 1 : (byte) 0);
// dest.writeTypedList(mPathPermissions);
// dest.writeTypedList(mURIPermissionPatterns);
// }
//
// protected ContentProviderInfo(Parcel in) {
// this.mName = in.readString();
// this.mEnabled = in.readByte() != 0;
// this.mExported = in.readByte() != 0;
// this.mAuthority = in.readString();
// this.mReadPermission = in.readString();
// this.mWritePermission = in.readString();
// this.mProcessName = in.readString();
// this.mMultiProcess = in.readByte() != 0;
// this.mSingleUser = in.readByte() != 0;
// this.mInitOrder = in.readInt();
// this.mIsSyncable = in.readByte() != 0;
// this.mGrantURIPermissions = in.readByte() != 0;
// this.mPathPermissions = in.createTypedArrayList(PathPermission.CREATOR);
// this.mURIPermissionPatterns = in.createTypedArrayList(URIPermissionPattern.CREATOR);
// }
//
// public static final Parcelable.Creator<ContentProviderInfo> CREATOR = new Parcelable.Creator<ContentProviderInfo>() {
// public ContentProviderInfo createFromParcel(Parcel source) {
// return new ContentProviderInfo(source);
// }
//
// public ContentProviderInfo[] newArray(int size) {
// return new ContentProviderInfo[size];
// }
// };
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IContentProviderDetailActivityView.java
// public interface IContentProviderDetailActivityView {
// void setTitle(String title);
// void setModel(Object[] items, int[] dataSetTypes);
// }
|
import com.livingstoneapp.models.ContentProviderInfo;
import com.livingstoneapp.views.IContentProviderDetailActivityView;
|
package com.livingstoneapp.presenters;
/**
* Created by renier on 2/18/2016.
*/
public interface IContentProviderDetailActivityPresenter {
void setView(IContentProviderDetailActivityView view);
void clearView();
|
// Path: app/src/main/java/com/livingstoneapp/models/ContentProviderInfo.java
// public class ContentProviderInfo implements Parcelable {
// private String mName;
// private boolean mEnabled;
// private boolean mExported;
// private String mAuthority;
// private String mReadPermission;
// private String mWritePermission;
// private String mProcessName;
// private boolean mMultiProcess;
// private boolean mSingleUser;
// private int mInitOrder;
// private boolean mIsSyncable;
// private boolean mGrantURIPermissions;
// private ArrayList<PathPermission> mPathPermissions;
// private ArrayList<URIPermissionPattern> mURIPermissionPatterns;
//
// public ContentProviderInfo(String name) {
// this.mName = name;
// }
//
// public ContentProviderInfo(
// String mName,
// boolean mEnabled,
// boolean mExported,
// String mAuthority,
// String mReadPermission,
// String mWritePermission,
// String mProcessName,
// boolean mMultiProcess,
// boolean mSingleUser,
// int mInitOrder,
// boolean mIsSyncable,
// boolean mGrantURIPermissions,
// ArrayList<PathPermission> mPathPermissions,
// ArrayList<URIPermissionPattern> mURIPermissionPatterns) {
// this.mAuthority = mAuthority;
// this.mEnabled = mEnabled;
// this.mExported = mExported;
// this.mGrantURIPermissions = mGrantURIPermissions;
// this.mInitOrder = mInitOrder;
// this.mIsSyncable = mIsSyncable;
// this.mMultiProcess = mMultiProcess;
// this.mName = mName;
// this.mPathPermissions = mPathPermissions;
// this.mProcessName = mProcessName;
// this.mReadPermission = mReadPermission;
// this.mSingleUser = mSingleUser;
// this.mURIPermissionPatterns = mURIPermissionPatterns;
// this.mWritePermission = mWritePermission;
// }
//
// public String getAuthority() {
// return mAuthority;
// }
//
// public boolean isEnabled() {
// return mEnabled;
// }
//
// public boolean isExported() {
// return mExported;
// }
//
// public boolean isGrantURIPermissions() {
// return mGrantURIPermissions;
// }
//
// public int getInitOrder() {
// return mInitOrder;
// }
//
// public boolean isIsSyncable() {
// return mIsSyncable;
// }
//
// public boolean isMultiProcess() {
// return mMultiProcess;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<PathPermission> getPathPermissions() {
// return mPathPermissions;
// }
//
// public String getProcessName() {
// return mProcessName;
// }
//
// public String getReadPermission() {
// return mReadPermission;
// }
//
// public boolean isSingleUser() {
// return mSingleUser;
// }
//
// public ArrayList<URIPermissionPattern> getURIPermissionPatterns() {
// return mURIPermissionPatterns;
// }
//
// public String getWritePermission() {
// return mWritePermission;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// dest.writeByte(mEnabled ? (byte) 1 : (byte) 0);
// dest.writeByte(mExported ? (byte) 1 : (byte) 0);
// dest.writeString(this.mAuthority);
// dest.writeString(this.mReadPermission);
// dest.writeString(this.mWritePermission);
// dest.writeString(this.mProcessName);
// dest.writeByte(mMultiProcess ? (byte) 1 : (byte) 0);
// dest.writeByte(mSingleUser ? (byte) 1 : (byte) 0);
// dest.writeInt(this.mInitOrder);
// dest.writeByte(mIsSyncable ? (byte) 1 : (byte) 0);
// dest.writeByte(mGrantURIPermissions ? (byte) 1 : (byte) 0);
// dest.writeTypedList(mPathPermissions);
// dest.writeTypedList(mURIPermissionPatterns);
// }
//
// protected ContentProviderInfo(Parcel in) {
// this.mName = in.readString();
// this.mEnabled = in.readByte() != 0;
// this.mExported = in.readByte() != 0;
// this.mAuthority = in.readString();
// this.mReadPermission = in.readString();
// this.mWritePermission = in.readString();
// this.mProcessName = in.readString();
// this.mMultiProcess = in.readByte() != 0;
// this.mSingleUser = in.readByte() != 0;
// this.mInitOrder = in.readInt();
// this.mIsSyncable = in.readByte() != 0;
// this.mGrantURIPermissions = in.readByte() != 0;
// this.mPathPermissions = in.createTypedArrayList(PathPermission.CREATOR);
// this.mURIPermissionPatterns = in.createTypedArrayList(URIPermissionPattern.CREATOR);
// }
//
// public static final Parcelable.Creator<ContentProviderInfo> CREATOR = new Parcelable.Creator<ContentProviderInfo>() {
// public ContentProviderInfo createFromParcel(Parcel source) {
// return new ContentProviderInfo(source);
// }
//
// public ContentProviderInfo[] newArray(int size) {
// return new ContentProviderInfo[size];
// }
// };
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IContentProviderDetailActivityView.java
// public interface IContentProviderDetailActivityView {
// void setTitle(String title);
// void setModel(Object[] items, int[] dataSetTypes);
// }
// Path: app/src/main/java/com/livingstoneapp/presenters/IContentProviderDetailActivityPresenter.java
import com.livingstoneapp.models.ContentProviderInfo;
import com.livingstoneapp.views.IContentProviderDetailActivityView;
package com.livingstoneapp.presenters;
/**
* Created by renier on 2/18/2016.
*/
public interface IContentProviderDetailActivityPresenter {
void setView(IContentProviderDetailActivityView view);
void clearView();
|
void init(ContentProviderInfo cpi);
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/views/IPackageListView.java
|
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
|
import java.util.List;
import com.livingstoneapp.models.InstalledPackageHeader;
|
package com.livingstoneapp.views;
/**
* Created by renier on 2/2/2016.
*/
public interface IPackageListView {
void init();
|
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
import java.util.List;
import com.livingstoneapp.models.InstalledPackageHeader;
package com.livingstoneapp.views;
/**
* Created by renier on 2/2/2016.
*/
public interface IPackageListView {
void init();
|
void setInstalledPackages(List<InstalledPackageHeader> items);
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/presenters/RequestedFeaturesFragmentPresenterImpl.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IRequestedFeaturesFragmentView.java
// public interface IRequestedFeaturesFragmentView {
// void showError(String message);
// void setModel(ArrayList<FeatureInfoInternal> permissions);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void showNoValuesText();
// void hideNoValuesText();
// }
|
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.views.IRequestedFeaturesFragmentView;
|
package com.livingstoneapp.presenters;
/**
* Created by renier on 2/18/2016.
*/
public class RequestedFeaturesFragmentPresenterImpl implements IRequestedFeaturesFragmentPresenter {
private IPackageInteractor mInteractor;
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IRequestedFeaturesFragmentView.java
// public interface IRequestedFeaturesFragmentView {
// void showError(String message);
// void setModel(ArrayList<FeatureInfoInternal> permissions);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void showNoValuesText();
// void hideNoValuesText();
// }
// Path: app/src/main/java/com/livingstoneapp/presenters/RequestedFeaturesFragmentPresenterImpl.java
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.views.IRequestedFeaturesFragmentView;
package com.livingstoneapp.presenters;
/**
* Created by renier on 2/18/2016.
*/
public class RequestedFeaturesFragmentPresenterImpl implements IRequestedFeaturesFragmentPresenter {
private IPackageInteractor mInteractor;
|
private IRequestedFeaturesFragmentView mView;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/interactors/ServiceInteractorImpl.java
|
// Path: app/src/main/java/com/livingstoneapp/models/ServiceInfoInternal.java
// public class ServiceInfoInternal {
// private String mName;
// private boolean mEnabled;
// private boolean mExported;
// private String mProcessName;
// private String mPermission;
// private ArrayList<String> mFlags;
//
// public ServiceInfoInternal(String mName, boolean mEnabled, boolean mExported, String mProcessName, String mPermission, ArrayList<String> mFlags) {
// this.mName = mName;
// this.mEnabled = mEnabled;
// this.mExported = mExported;
// this.mProcessName = mProcessName;
// this.mPermission = mPermission;
// this.mFlags = mFlags;
// }
//
// public boolean isEnabled() {
// return mEnabled;
// }
//
// public boolean isExported() {
// return mExported;
// }
//
// public ArrayList<String> getFlags() {
// return mFlags;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getPermission() {
// return mPermission;
// }
//
// public String getProcessName() {
// return mProcessName;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/utils/Utils.java
// public class Utils {
// public static boolean hasFlag(
// int flags,
// int flagToCheck
// ) {
// return ((flags & flagToCheck) == flagToCheck);
// }
// }
|
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.ServiceInfoInternal;
import com.livingstoneapp.utils.Utils;
|
package com.livingstoneapp.interactors;
/**
* Created by renier on 2/22/2016.
*/
public class ServiceInteractorImpl implements IServiceInteractor {
private Context mContext;
public ServiceInteractorImpl(Context context) {
mContext = context;
}
@Override
|
// Path: app/src/main/java/com/livingstoneapp/models/ServiceInfoInternal.java
// public class ServiceInfoInternal {
// private String mName;
// private boolean mEnabled;
// private boolean mExported;
// private String mProcessName;
// private String mPermission;
// private ArrayList<String> mFlags;
//
// public ServiceInfoInternal(String mName, boolean mEnabled, boolean mExported, String mProcessName, String mPermission, ArrayList<String> mFlags) {
// this.mName = mName;
// this.mEnabled = mEnabled;
// this.mExported = mExported;
// this.mProcessName = mProcessName;
// this.mPermission = mPermission;
// this.mFlags = mFlags;
// }
//
// public boolean isEnabled() {
// return mEnabled;
// }
//
// public boolean isExported() {
// return mExported;
// }
//
// public ArrayList<String> getFlags() {
// return mFlags;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getPermission() {
// return mPermission;
// }
//
// public String getProcessName() {
// return mProcessName;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/utils/Utils.java
// public class Utils {
// public static boolean hasFlag(
// int flags,
// int flagToCheck
// ) {
// return ((flags & flagToCheck) == flagToCheck);
// }
// }
// Path: app/src/main/java/com/livingstoneapp/interactors/ServiceInteractorImpl.java
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.ServiceInfoInternal;
import com.livingstoneapp.utils.Utils;
package com.livingstoneapp.interactors;
/**
* Created by renier on 2/22/2016.
*/
public class ServiceInteractorImpl implements IServiceInteractor {
private Context mContext;
public ServiceInteractorImpl(Context context) {
mContext = context;
}
@Override
|
public Observable<ArrayList<ServiceInfoInternal>> getServices(String packageName) {
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/interactors/ServiceInteractorImpl.java
|
// Path: app/src/main/java/com/livingstoneapp/models/ServiceInfoInternal.java
// public class ServiceInfoInternal {
// private String mName;
// private boolean mEnabled;
// private boolean mExported;
// private String mProcessName;
// private String mPermission;
// private ArrayList<String> mFlags;
//
// public ServiceInfoInternal(String mName, boolean mEnabled, boolean mExported, String mProcessName, String mPermission, ArrayList<String> mFlags) {
// this.mName = mName;
// this.mEnabled = mEnabled;
// this.mExported = mExported;
// this.mProcessName = mProcessName;
// this.mPermission = mPermission;
// this.mFlags = mFlags;
// }
//
// public boolean isEnabled() {
// return mEnabled;
// }
//
// public boolean isExported() {
// return mExported;
// }
//
// public ArrayList<String> getFlags() {
// return mFlags;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getPermission() {
// return mPermission;
// }
//
// public String getProcessName() {
// return mProcessName;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/utils/Utils.java
// public class Utils {
// public static boolean hasFlag(
// int flags,
// int flagToCheck
// ) {
// return ((flags & flagToCheck) == flagToCheck);
// }
// }
|
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.ServiceInfoInternal;
import com.livingstoneapp.utils.Utils;
|
package com.livingstoneapp.interactors;
/**
* Created by renier on 2/22/2016.
*/
public class ServiceInteractorImpl implements IServiceInteractor {
private Context mContext;
public ServiceInteractorImpl(Context context) {
mContext = context;
}
@Override
public Observable<ArrayList<ServiceInfoInternal>> getServices(String packageName) {
return Observable.defer(() -> Observable.create(subscriber -> {
try {
PackageManager packageManager = mContext.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_SERVICES);
ArrayList<ServiceInfoInternal> toReturn = new ArrayList<>();
if (packageInfo.services != null) {
for (ServiceInfo si : packageInfo.services) {
ArrayList<String> flags = new ArrayList<>();
|
// Path: app/src/main/java/com/livingstoneapp/models/ServiceInfoInternal.java
// public class ServiceInfoInternal {
// private String mName;
// private boolean mEnabled;
// private boolean mExported;
// private String mProcessName;
// private String mPermission;
// private ArrayList<String> mFlags;
//
// public ServiceInfoInternal(String mName, boolean mEnabled, boolean mExported, String mProcessName, String mPermission, ArrayList<String> mFlags) {
// this.mName = mName;
// this.mEnabled = mEnabled;
// this.mExported = mExported;
// this.mProcessName = mProcessName;
// this.mPermission = mPermission;
// this.mFlags = mFlags;
// }
//
// public boolean isEnabled() {
// return mEnabled;
// }
//
// public boolean isExported() {
// return mExported;
// }
//
// public ArrayList<String> getFlags() {
// return mFlags;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getPermission() {
// return mPermission;
// }
//
// public String getProcessName() {
// return mProcessName;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/utils/Utils.java
// public class Utils {
// public static boolean hasFlag(
// int flags,
// int flagToCheck
// ) {
// return ((flags & flagToCheck) == flagToCheck);
// }
// }
// Path: app/src/main/java/com/livingstoneapp/interactors/ServiceInteractorImpl.java
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.ServiceInfoInternal;
import com.livingstoneapp.utils.Utils;
package com.livingstoneapp.interactors;
/**
* Created by renier on 2/22/2016.
*/
public class ServiceInteractorImpl implements IServiceInteractor {
private Context mContext;
public ServiceInteractorImpl(Context context) {
mContext = context;
}
@Override
public Observable<ArrayList<ServiceInfoInternal>> getServices(String packageName) {
return Observable.defer(() -> Observable.create(subscriber -> {
try {
PackageManager packageManager = mContext.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_SERVICES);
ArrayList<ServiceInfoInternal> toReturn = new ArrayList<>();
if (packageInfo.services != null) {
for (ServiceInfo si : packageInfo.services) {
ArrayList<String> flags = new ArrayList<>();
|
if (Utils.hasFlag(si.flags, ServiceInfo.FLAG_ISOLATED_PROCESS))
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/presenters/PackageDetailFragmentPresenterImpl.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageDetailFragmentView.java
// public interface IPackageDetailFragmentView {
//
// void setTitle(String title);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void initViews(String appName, String packageName);
// void showError(String message);
// }
|
import javax.inject.Inject;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.views.IPackageDetailFragmentView;
|
package com.livingstoneapp.presenters;
/**
* Created by renier on 2/3/2016.
*/
public class PackageDetailFragmentPresenterImpl implements IPackageDetailFragmentPresenter {
private IPackageInteractor mPackageInteractor;
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageDetailFragmentView.java
// public interface IPackageDetailFragmentView {
//
// void setTitle(String title);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void initViews(String appName, String packageName);
// void showError(String message);
// }
// Path: app/src/main/java/com/livingstoneapp/presenters/PackageDetailFragmentPresenterImpl.java
import javax.inject.Inject;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.views.IPackageDetailFragmentView;
package com.livingstoneapp.presenters;
/**
* Created by renier on 2/3/2016.
*/
public class PackageDetailFragmentPresenterImpl implements IPackageDetailFragmentPresenter {
private IPackageInteractor mPackageInteractor;
|
private IPackageDetailFragmentView mView;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/interactors/PermissionsInteractorImpl.java
|
// Path: app/src/main/java/com/livingstoneapp/models/DeclaredPermission.java
// public class DeclaredPermission {
//
// private String mName;
// private String mLabel;
// private ArrayList<String> mProtectionLevel;
// private ArrayList<String> mFlags;
//
// public DeclaredPermission(String mName, String mLabel, ArrayList<String> mProtectionLevel, ArrayList<String> mFlags) {
// this.mLabel = mLabel;
// this.mName = mName;
// this.mProtectionLevel = mProtectionLevel;
// this.mFlags = mFlags;
// }
//
// public String getLabel() {
// return mLabel;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<String> getProtectionLevel() {
// return mProtectionLevel;
// }
//
// public ArrayList<String> getFlags() { return mFlags; }
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/RequestedPermission.java
// public class RequestedPermission {
// private String mName;
// private boolean mGranted;
//
// public RequestedPermission(String mName, boolean mGranted) {
// this.mGranted = mGranted;
// this.mName = mName;
// }
//
// public boolean isGranted() {
// return mGranted;
// }
//
// public String getName() {
// return mName;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/utils/Utils.java
// public class Utils {
// public static boolean hasFlag(
// int flags,
// int flagToCheck
// ) {
// return ((flags & flagToCheck) == flagToCheck);
// }
// }
|
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PermissionInfo;
import android.os.Build;
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.DeclaredPermission;
import com.livingstoneapp.models.RequestedPermission;
import com.livingstoneapp.utils.Utils;
|
package com.livingstoneapp.interactors;
/**
* Created by renier on 2/19/2016.
*/
public class PermissionsInteractorImpl implements IPermissionsInteractor {
private Context mContext;
public PermissionsInteractorImpl(Context context) {
mContext = context;
}
@Override
|
// Path: app/src/main/java/com/livingstoneapp/models/DeclaredPermission.java
// public class DeclaredPermission {
//
// private String mName;
// private String mLabel;
// private ArrayList<String> mProtectionLevel;
// private ArrayList<String> mFlags;
//
// public DeclaredPermission(String mName, String mLabel, ArrayList<String> mProtectionLevel, ArrayList<String> mFlags) {
// this.mLabel = mLabel;
// this.mName = mName;
// this.mProtectionLevel = mProtectionLevel;
// this.mFlags = mFlags;
// }
//
// public String getLabel() {
// return mLabel;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<String> getProtectionLevel() {
// return mProtectionLevel;
// }
//
// public ArrayList<String> getFlags() { return mFlags; }
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/RequestedPermission.java
// public class RequestedPermission {
// private String mName;
// private boolean mGranted;
//
// public RequestedPermission(String mName, boolean mGranted) {
// this.mGranted = mGranted;
// this.mName = mName;
// }
//
// public boolean isGranted() {
// return mGranted;
// }
//
// public String getName() {
// return mName;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/utils/Utils.java
// public class Utils {
// public static boolean hasFlag(
// int flags,
// int flagToCheck
// ) {
// return ((flags & flagToCheck) == flagToCheck);
// }
// }
// Path: app/src/main/java/com/livingstoneapp/interactors/PermissionsInteractorImpl.java
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PermissionInfo;
import android.os.Build;
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.DeclaredPermission;
import com.livingstoneapp.models.RequestedPermission;
import com.livingstoneapp.utils.Utils;
package com.livingstoneapp.interactors;
/**
* Created by renier on 2/19/2016.
*/
public class PermissionsInteractorImpl implements IPermissionsInteractor {
private Context mContext;
public PermissionsInteractorImpl(Context context) {
mContext = context;
}
@Override
|
public Observable<ArrayList<DeclaredPermission>> getDeclaredPermissions(String packageName) {
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/interactors/PermissionsInteractorImpl.java
|
// Path: app/src/main/java/com/livingstoneapp/models/DeclaredPermission.java
// public class DeclaredPermission {
//
// private String mName;
// private String mLabel;
// private ArrayList<String> mProtectionLevel;
// private ArrayList<String> mFlags;
//
// public DeclaredPermission(String mName, String mLabel, ArrayList<String> mProtectionLevel, ArrayList<String> mFlags) {
// this.mLabel = mLabel;
// this.mName = mName;
// this.mProtectionLevel = mProtectionLevel;
// this.mFlags = mFlags;
// }
//
// public String getLabel() {
// return mLabel;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<String> getProtectionLevel() {
// return mProtectionLevel;
// }
//
// public ArrayList<String> getFlags() { return mFlags; }
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/RequestedPermission.java
// public class RequestedPermission {
// private String mName;
// private boolean mGranted;
//
// public RequestedPermission(String mName, boolean mGranted) {
// this.mGranted = mGranted;
// this.mName = mName;
// }
//
// public boolean isGranted() {
// return mGranted;
// }
//
// public String getName() {
// return mName;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/utils/Utils.java
// public class Utils {
// public static boolean hasFlag(
// int flags,
// int flagToCheck
// ) {
// return ((flags & flagToCheck) == flagToCheck);
// }
// }
|
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PermissionInfo;
import android.os.Build;
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.DeclaredPermission;
import com.livingstoneapp.models.RequestedPermission;
import com.livingstoneapp.utils.Utils;
|
package com.livingstoneapp.interactors;
/**
* Created by renier on 2/19/2016.
*/
public class PermissionsInteractorImpl implements IPermissionsInteractor {
private Context mContext;
public PermissionsInteractorImpl(Context context) {
mContext = context;
}
@Override
public Observable<ArrayList<DeclaredPermission>> getDeclaredPermissions(String packageName) {
return Observable.defer(() -> Observable.create(subscriber -> {
try {
ArrayList<DeclaredPermission> toReturn = new ArrayList<>();
PackageManager packageManager = mContext.getPackageManager();
PackageInfo pi = packageManager.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS);
if (pi.permissions != null) {
for (PermissionInfo info : pi.permissions) {
ArrayList<String> protectionLevels = new ArrayList<>();
ArrayList<String> flags = new ArrayList<>();
//Protection Levels
|
// Path: app/src/main/java/com/livingstoneapp/models/DeclaredPermission.java
// public class DeclaredPermission {
//
// private String mName;
// private String mLabel;
// private ArrayList<String> mProtectionLevel;
// private ArrayList<String> mFlags;
//
// public DeclaredPermission(String mName, String mLabel, ArrayList<String> mProtectionLevel, ArrayList<String> mFlags) {
// this.mLabel = mLabel;
// this.mName = mName;
// this.mProtectionLevel = mProtectionLevel;
// this.mFlags = mFlags;
// }
//
// public String getLabel() {
// return mLabel;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<String> getProtectionLevel() {
// return mProtectionLevel;
// }
//
// public ArrayList<String> getFlags() { return mFlags; }
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/RequestedPermission.java
// public class RequestedPermission {
// private String mName;
// private boolean mGranted;
//
// public RequestedPermission(String mName, boolean mGranted) {
// this.mGranted = mGranted;
// this.mName = mName;
// }
//
// public boolean isGranted() {
// return mGranted;
// }
//
// public String getName() {
// return mName;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/utils/Utils.java
// public class Utils {
// public static boolean hasFlag(
// int flags,
// int flagToCheck
// ) {
// return ((flags & flagToCheck) == flagToCheck);
// }
// }
// Path: app/src/main/java/com/livingstoneapp/interactors/PermissionsInteractorImpl.java
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PermissionInfo;
import android.os.Build;
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.DeclaredPermission;
import com.livingstoneapp.models.RequestedPermission;
import com.livingstoneapp.utils.Utils;
package com.livingstoneapp.interactors;
/**
* Created by renier on 2/19/2016.
*/
public class PermissionsInteractorImpl implements IPermissionsInteractor {
private Context mContext;
public PermissionsInteractorImpl(Context context) {
mContext = context;
}
@Override
public Observable<ArrayList<DeclaredPermission>> getDeclaredPermissions(String packageName) {
return Observable.defer(() -> Observable.create(subscriber -> {
try {
ArrayList<DeclaredPermission> toReturn = new ArrayList<>();
PackageManager packageManager = mContext.getPackageManager();
PackageInfo pi = packageManager.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS);
if (pi.permissions != null) {
for (PermissionInfo info : pi.permissions) {
ArrayList<String> protectionLevels = new ArrayList<>();
ArrayList<String> flags = new ArrayList<>();
//Protection Levels
|
if (Utils.hasFlag(info.protectionLevel, PermissionInfo.PROTECTION_DANGEROUS))
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/interactors/PermissionsInteractorImpl.java
|
// Path: app/src/main/java/com/livingstoneapp/models/DeclaredPermission.java
// public class DeclaredPermission {
//
// private String mName;
// private String mLabel;
// private ArrayList<String> mProtectionLevel;
// private ArrayList<String> mFlags;
//
// public DeclaredPermission(String mName, String mLabel, ArrayList<String> mProtectionLevel, ArrayList<String> mFlags) {
// this.mLabel = mLabel;
// this.mName = mName;
// this.mProtectionLevel = mProtectionLevel;
// this.mFlags = mFlags;
// }
//
// public String getLabel() {
// return mLabel;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<String> getProtectionLevel() {
// return mProtectionLevel;
// }
//
// public ArrayList<String> getFlags() { return mFlags; }
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/RequestedPermission.java
// public class RequestedPermission {
// private String mName;
// private boolean mGranted;
//
// public RequestedPermission(String mName, boolean mGranted) {
// this.mGranted = mGranted;
// this.mName = mName;
// }
//
// public boolean isGranted() {
// return mGranted;
// }
//
// public String getName() {
// return mName;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/utils/Utils.java
// public class Utils {
// public static boolean hasFlag(
// int flags,
// int flagToCheck
// ) {
// return ((flags & flagToCheck) == flagToCheck);
// }
// }
|
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PermissionInfo;
import android.os.Build;
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.DeclaredPermission;
import com.livingstoneapp.models.RequestedPermission;
import com.livingstoneapp.utils.Utils;
|
if (Utils.hasFlag(info.protectionLevel, PermissionInfo.PROTECTION_FLAG_SYSTEM))
protectionLevels.add("PROTECTION_FLAG_SYSTEM");
if (Utils.hasFlag(info.protectionLevel, PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM))
protectionLevels.add("PROTECTION_SIGNATURE_OR_SYSTEM");
//Flags
if (Utils.hasFlag(info.flags, PermissionInfo.FLAG_COSTS_MONEY))
flags.add("FLAG_COSTS_MONEY");
//hidden - http://developer.android.com/intl/ko/reference/android/R.attr.html#permissionFlags
if (Utils.hasFlag(info.flags, 0x2))
flags.add("hidden");
toReturn.add(new DeclaredPermission(
info.name.startsWith(packageName) == true ? info.name.replace(packageName, "") : info.name,
String.valueOf(info.loadLabel(packageManager)),
protectionLevels,
flags));
}
}
subscriber.onNext(toReturn);
subscriber.onCompleted();
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
subscriber.onError(e);
}
}));
}
@Override
|
// Path: app/src/main/java/com/livingstoneapp/models/DeclaredPermission.java
// public class DeclaredPermission {
//
// private String mName;
// private String mLabel;
// private ArrayList<String> mProtectionLevel;
// private ArrayList<String> mFlags;
//
// public DeclaredPermission(String mName, String mLabel, ArrayList<String> mProtectionLevel, ArrayList<String> mFlags) {
// this.mLabel = mLabel;
// this.mName = mName;
// this.mProtectionLevel = mProtectionLevel;
// this.mFlags = mFlags;
// }
//
// public String getLabel() {
// return mLabel;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<String> getProtectionLevel() {
// return mProtectionLevel;
// }
//
// public ArrayList<String> getFlags() { return mFlags; }
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/RequestedPermission.java
// public class RequestedPermission {
// private String mName;
// private boolean mGranted;
//
// public RequestedPermission(String mName, boolean mGranted) {
// this.mGranted = mGranted;
// this.mName = mName;
// }
//
// public boolean isGranted() {
// return mGranted;
// }
//
// public String getName() {
// return mName;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/utils/Utils.java
// public class Utils {
// public static boolean hasFlag(
// int flags,
// int flagToCheck
// ) {
// return ((flags & flagToCheck) == flagToCheck);
// }
// }
// Path: app/src/main/java/com/livingstoneapp/interactors/PermissionsInteractorImpl.java
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PermissionInfo;
import android.os.Build;
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.DeclaredPermission;
import com.livingstoneapp.models.RequestedPermission;
import com.livingstoneapp.utils.Utils;
if (Utils.hasFlag(info.protectionLevel, PermissionInfo.PROTECTION_FLAG_SYSTEM))
protectionLevels.add("PROTECTION_FLAG_SYSTEM");
if (Utils.hasFlag(info.protectionLevel, PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM))
protectionLevels.add("PROTECTION_SIGNATURE_OR_SYSTEM");
//Flags
if (Utils.hasFlag(info.flags, PermissionInfo.FLAG_COSTS_MONEY))
flags.add("FLAG_COSTS_MONEY");
//hidden - http://developer.android.com/intl/ko/reference/android/R.attr.html#permissionFlags
if (Utils.hasFlag(info.flags, 0x2))
flags.add("hidden");
toReturn.add(new DeclaredPermission(
info.name.startsWith(packageName) == true ? info.name.replace(packageName, "") : info.name,
String.valueOf(info.loadLabel(packageManager)),
protectionLevels,
flags));
}
}
subscriber.onNext(toReturn);
subscriber.onCompleted();
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
subscriber.onError(e);
}
}));
}
@Override
|
public Observable<ArrayList<RequestedPermission>> getRequestedPermissions(String packageName) {
|
oosthuizenr/Livingstone
|
app/src/test/java/com/livingstoneapp/presenters/ActivitiesFragmentPresenterImplTest.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IActivityInteractor.java
// public interface IActivityInteractor {
// Observable<ArrayList<ActivityInfoInternal>> getActivities(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IActivitiesFragmentView.java
// public interface IActivitiesFragmentView {
// void showError(String message);
// void setModel(ArrayList<ActivityInfoInternal> activities);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void startActivityDetailActivity(ActivityInfoInternal activity);
// void showNoValuesText();
// void hideNoValuesText();
// }
|
import com.livingstoneapp.interactors.IActivityInteractor;
import com.livingstoneapp.views.IActivitiesFragmentView;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;
import static org.mockito.Matchers.anyListOf;
import static org.junit.Assert.*;
|
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/03/15.
*/
public class ActivitiesFragmentPresenterImplTest {
@Mock
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IActivityInteractor.java
// public interface IActivityInteractor {
// Observable<ArrayList<ActivityInfoInternal>> getActivities(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IActivitiesFragmentView.java
// public interface IActivitiesFragmentView {
// void showError(String message);
// void setModel(ArrayList<ActivityInfoInternal> activities);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void startActivityDetailActivity(ActivityInfoInternal activity);
// void showNoValuesText();
// void hideNoValuesText();
// }
// Path: app/src/test/java/com/livingstoneapp/presenters/ActivitiesFragmentPresenterImplTest.java
import com.livingstoneapp.interactors.IActivityInteractor;
import com.livingstoneapp.views.IActivitiesFragmentView;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;
import static org.mockito.Matchers.anyListOf;
import static org.junit.Assert.*;
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/03/15.
*/
public class ActivitiesFragmentPresenterImplTest {
@Mock
|
IActivitiesFragmentView mView;
|
oosthuizenr/Livingstone
|
app/src/test/java/com/livingstoneapp/presenters/ActivitiesFragmentPresenterImplTest.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IActivityInteractor.java
// public interface IActivityInteractor {
// Observable<ArrayList<ActivityInfoInternal>> getActivities(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IActivitiesFragmentView.java
// public interface IActivitiesFragmentView {
// void showError(String message);
// void setModel(ArrayList<ActivityInfoInternal> activities);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void startActivityDetailActivity(ActivityInfoInternal activity);
// void showNoValuesText();
// void hideNoValuesText();
// }
|
import com.livingstoneapp.interactors.IActivityInteractor;
import com.livingstoneapp.views.IActivitiesFragmentView;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;
import static org.mockito.Matchers.anyListOf;
import static org.junit.Assert.*;
|
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/03/15.
*/
public class ActivitiesFragmentPresenterImplTest {
@Mock
IActivitiesFragmentView mView;
@Mock
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IActivityInteractor.java
// public interface IActivityInteractor {
// Observable<ArrayList<ActivityInfoInternal>> getActivities(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IActivitiesFragmentView.java
// public interface IActivitiesFragmentView {
// void showError(String message);
// void setModel(ArrayList<ActivityInfoInternal> activities);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void startActivityDetailActivity(ActivityInfoInternal activity);
// void showNoValuesText();
// void hideNoValuesText();
// }
// Path: app/src/test/java/com/livingstoneapp/presenters/ActivitiesFragmentPresenterImplTest.java
import com.livingstoneapp.interactors.IActivityInteractor;
import com.livingstoneapp.views.IActivitiesFragmentView;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;
import static org.mockito.Matchers.anyListOf;
import static org.junit.Assert.*;
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/03/15.
*/
public class ActivitiesFragmentPresenterImplTest {
@Mock
IActivitiesFragmentView mView;
@Mock
|
IActivityInteractor mInteractor;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/adapters/BroadcastReceiversListAdapter.java
|
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListener.java
// public interface RecyclerViewOnClickListener<T> {
// void onItemClick(T item);
// }
//
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListenerInternal.java
// public interface RecyclerViewOnClickListenerInternal {
// void onItemClick(int position);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/BroadcastReceiverInfo.java
// public class BroadcastReceiverInfo implements Parcelable, Comparable<BroadcastReceiverInfo> {
// private String mName;
//
// public BroadcastReceiverInfo(
// String mName) {
// this.mName = mName;
// }
//
//
// public String getName() {
// return mName;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// }
//
// protected BroadcastReceiverInfo(Parcel in) {
// this.mName = in.readString();
// }
//
// public static final Creator<BroadcastReceiverInfo> CREATOR = new Creator<BroadcastReceiverInfo>() {
// public BroadcastReceiverInfo createFromParcel(Parcel source) {
// return new BroadcastReceiverInfo(source);
// }
//
// public BroadcastReceiverInfo[] newArray(int size) {
// return new BroadcastReceiverInfo[size];
// }
// };
//
// @Override
// public int compareTo(BroadcastReceiverInfo another) {
// return this.getName().compareToIgnoreCase(another.getName());
// }
// }
|
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.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.R;
import com.livingstoneapp.helpers.RecyclerViewOnClickListener;
import com.livingstoneapp.helpers.RecyclerViewOnClickListenerInternal;
import com.livingstoneapp.models.BroadcastReceiverInfo;
|
public void setOnClickListener(RecyclerViewOnClickListener<BroadcastReceiverInfo> listener) {
this.mListener = listener;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return
new ViewHolder(
LayoutInflater.from(parent.getContext())
.inflate(R.layout.app_info_broadcast_receivers_adapter_layout, parent, false),
position -> {
if (mListener != null) {
mListener.onItemClick(mData.get(position));
}
});
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.tvName.setText(mData.get(position).getName());
}
@Override
public int getItemCount() {
return mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
|
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListener.java
// public interface RecyclerViewOnClickListener<T> {
// void onItemClick(T item);
// }
//
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListenerInternal.java
// public interface RecyclerViewOnClickListenerInternal {
// void onItemClick(int position);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/BroadcastReceiverInfo.java
// public class BroadcastReceiverInfo implements Parcelable, Comparable<BroadcastReceiverInfo> {
// private String mName;
//
// public BroadcastReceiverInfo(
// String mName) {
// this.mName = mName;
// }
//
//
// public String getName() {
// return mName;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// }
//
// protected BroadcastReceiverInfo(Parcel in) {
// this.mName = in.readString();
// }
//
// public static final Creator<BroadcastReceiverInfo> CREATOR = new Creator<BroadcastReceiverInfo>() {
// public BroadcastReceiverInfo createFromParcel(Parcel source) {
// return new BroadcastReceiverInfo(source);
// }
//
// public BroadcastReceiverInfo[] newArray(int size) {
// return new BroadcastReceiverInfo[size];
// }
// };
//
// @Override
// public int compareTo(BroadcastReceiverInfo another) {
// return this.getName().compareToIgnoreCase(another.getName());
// }
// }
// Path: app/src/main/java/com/livingstoneapp/adapters/BroadcastReceiversListAdapter.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.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.R;
import com.livingstoneapp.helpers.RecyclerViewOnClickListener;
import com.livingstoneapp.helpers.RecyclerViewOnClickListenerInternal;
import com.livingstoneapp.models.BroadcastReceiverInfo;
public void setOnClickListener(RecyclerViewOnClickListener<BroadcastReceiverInfo> listener) {
this.mListener = listener;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return
new ViewHolder(
LayoutInflater.from(parent.getContext())
.inflate(R.layout.app_info_broadcast_receivers_adapter_layout, parent, false),
position -> {
if (mListener != null) {
mListener.onItemClick(mData.get(position));
}
});
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.tvName.setText(mData.get(position).getName());
}
@Override
public int getItemCount() {
return mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
|
private RecyclerViewOnClickListenerInternal mListener;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/adapters/DeclaredPermissionsAdapter.java
|
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListener.java
// public interface RecyclerViewOnClickListener<T> {
// void onItemClick(T item);
// }
//
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListenerInternal.java
// public interface RecyclerViewOnClickListenerInternal {
// void onItemClick(int position);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/DeclaredPermission.java
// public class DeclaredPermission {
//
// private String mName;
// private String mLabel;
// private ArrayList<String> mProtectionLevel;
// private ArrayList<String> mFlags;
//
// public DeclaredPermission(String mName, String mLabel, ArrayList<String> mProtectionLevel, ArrayList<String> mFlags) {
// this.mLabel = mLabel;
// this.mName = mName;
// this.mProtectionLevel = mProtectionLevel;
// this.mFlags = mFlags;
// }
//
// public String getLabel() {
// return mLabel;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<String> getProtectionLevel() {
// return mProtectionLevel;
// }
//
// public ArrayList<String> getFlags() { return mFlags; }
// }
|
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.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.R;
import com.livingstoneapp.helpers.RecyclerViewOnClickListener;
import com.livingstoneapp.helpers.RecyclerViewOnClickListenerInternal;
import com.livingstoneapp.models.DeclaredPermission;
|
holder.tvProtectionLevel.setText(sb);
} else {
holder.tvProtectionLevelHeader.setVisibility(View.GONE);
holder.tvProtectionLevel.setVisibility(View.GONE);
}
if (mData.get(position).getFlags().size() > 0) {
holder.tvFlagsHeader.setVisibility(View.VISIBLE);
holder.tvFlags.setVisibility(View.VISIBLE);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < mData.get(position).getFlags().size(); i++) {
if (i != 0)
sb.append("\n");
sb.append(mData.get(position).getFlags().get(i));
}
holder.tvFlags.setText(sb);
} else {
holder.tvFlagsHeader.setVisibility(View.GONE);
holder.tvFlags.setVisibility(View.GONE);
}
}
@Override
public int getItemCount() {
return mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
|
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListener.java
// public interface RecyclerViewOnClickListener<T> {
// void onItemClick(T item);
// }
//
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListenerInternal.java
// public interface RecyclerViewOnClickListenerInternal {
// void onItemClick(int position);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/DeclaredPermission.java
// public class DeclaredPermission {
//
// private String mName;
// private String mLabel;
// private ArrayList<String> mProtectionLevel;
// private ArrayList<String> mFlags;
//
// public DeclaredPermission(String mName, String mLabel, ArrayList<String> mProtectionLevel, ArrayList<String> mFlags) {
// this.mLabel = mLabel;
// this.mName = mName;
// this.mProtectionLevel = mProtectionLevel;
// this.mFlags = mFlags;
// }
//
// public String getLabel() {
// return mLabel;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<String> getProtectionLevel() {
// return mProtectionLevel;
// }
//
// public ArrayList<String> getFlags() { return mFlags; }
// }
// Path: app/src/main/java/com/livingstoneapp/adapters/DeclaredPermissionsAdapter.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.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.R;
import com.livingstoneapp.helpers.RecyclerViewOnClickListener;
import com.livingstoneapp.helpers.RecyclerViewOnClickListenerInternal;
import com.livingstoneapp.models.DeclaredPermission;
holder.tvProtectionLevel.setText(sb);
} else {
holder.tvProtectionLevelHeader.setVisibility(View.GONE);
holder.tvProtectionLevel.setVisibility(View.GONE);
}
if (mData.get(position).getFlags().size() > 0) {
holder.tvFlagsHeader.setVisibility(View.VISIBLE);
holder.tvFlags.setVisibility(View.VISIBLE);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < mData.get(position).getFlags().size(); i++) {
if (i != 0)
sb.append("\n");
sb.append(mData.get(position).getFlags().get(i));
}
holder.tvFlags.setText(sb);
} else {
holder.tvFlagsHeader.setVisibility(View.GONE);
holder.tvFlags.setVisibility(View.GONE);
}
}
@Override
public int getItemCount() {
return mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
|
private RecyclerViewOnClickListenerInternal mListener;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/activities/PackageDetailActivity.java
|
// Path: app/src/main/java/com/livingstoneapp/fragments/PackageDetailFragment.java
// public class PackageDetailFragment extends Fragment implements IPackageDetailFragmentView {
//
// public static String ARG_PACKAGE_NAME = "PackageName";
// public static String ARG_2_PANE = "2Pane";
//
// @Inject
// IPackageDetailFragmentPresenter mPresenter;
//
// @Bind(R.id.progress_bar)
// ProgressBar mProgressBar;
//
// @Bind(R.id.tabs)
// TabLayout mTabLayout;
//
// @Bind(R.id.viewpager)
// ViewPager mViewPager;
//
// private PackageDetailViewPagerAdapter mViewPagerAdapter;
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View rootView = inflater.inflate(R.layout.fragment_package_detail, container, false);
//
//
//
// String packageName = getArguments().getString(ARG_PACKAGE_NAME);
//
// MainApplication.from(getActivity()).getGraph().inject(this);
//
// ButterKnife.bind(this, rootView);
//
// mPresenter.setView(this);
//
// mPresenter.init(packageName);
//
// return rootView;
// }
//
// @Override
// public void onPause() {
// mPresenter.clearView();
// super.onPause();
// }
//
// @Override
// public void onResume() {
// super.onResume();
// mPresenter.setView(this);
// }
//
// @Override
// public void showWaitDialog() {
// mProgressBar.setVisibility(View.VISIBLE);
// }
//
// @Override
// public void hideWaitDialog() {
// mProgressBar.setVisibility(View.GONE);
// }
//
// @Override
// public void showDetailContainer() {
// mTabLayout.setVisibility(View.VISIBLE);
// mViewPager.setVisibility(View.VISIBLE);
// }
//
// @Override
// public void hideDetailContainer() {
// mTabLayout.setVisibility(View.GONE);
// mViewPager.setVisibility(View.GONE);
// }
//
// @Override
// public void setTitle(String title) {
// ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(title);
// }
//
// @Override
// public void initViews(String appName, String packageName) {
// ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(appName);
//
// mViewPagerAdapter = new PackageDetailViewPagerAdapter(this.getChildFragmentManager());
// mViewPagerAdapter.addFragment(ApplicationInfoFragment.newInstance(packageName), getString(R.string.tab_header_application_info));
// mViewPagerAdapter.addFragment(ActivitiesFragment.newInstance(packageName), getString(R.string.tab_header_activities));
// mViewPagerAdapter.addFragment(ServicesFragment.newInstance(packageName), getString(R.string.tab_header_services));
// mViewPagerAdapter.addFragment(ContentProvidersFragment.newInstance(packageName), getString(R.string.tab_header_content_providers));
// mViewPagerAdapter.addFragment(BroadcastReceiversFragment.newInstance(packageName), getString(R.string.tab_header_broadcast_receivers));
// mViewPagerAdapter.addFragment(RequestedPermissionsFragment.newInstance(packageName), getString(R.string.tab_header_requested_permissions));
// mViewPagerAdapter.addFragment(DeclaredPermissionsFragment.newInstance(packageName), getString(R.string.tab_header_declared_permissions));
// mViewPagerAdapter.addFragment(RequestedFeaturesFragment.newInstance(packageName), getString(R.string.tab_header_requested_features));
// mViewPager.setAdapter(mViewPagerAdapter);
// mTabLayout.setupWithViewPager(mViewPager);
// }
//
// @Override
// public void showError(String message) {
//
// }
// }
|
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.livingstoneapp.R;
import com.livingstoneapp.fragments.PackageDetailFragment;
|
package com.livingstoneapp.activities;
public class PackageDetailActivity extends AppCompatActivity {
public static String ARG_PACKAGE_NAME = "PackageName";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_package_detail);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if(getSupportActionBar() != null) {
getSupportActionBar().setElevation(0);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
Bundle arguments = new Bundle();
|
// Path: app/src/main/java/com/livingstoneapp/fragments/PackageDetailFragment.java
// public class PackageDetailFragment extends Fragment implements IPackageDetailFragmentView {
//
// public static String ARG_PACKAGE_NAME = "PackageName";
// public static String ARG_2_PANE = "2Pane";
//
// @Inject
// IPackageDetailFragmentPresenter mPresenter;
//
// @Bind(R.id.progress_bar)
// ProgressBar mProgressBar;
//
// @Bind(R.id.tabs)
// TabLayout mTabLayout;
//
// @Bind(R.id.viewpager)
// ViewPager mViewPager;
//
// private PackageDetailViewPagerAdapter mViewPagerAdapter;
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View rootView = inflater.inflate(R.layout.fragment_package_detail, container, false);
//
//
//
// String packageName = getArguments().getString(ARG_PACKAGE_NAME);
//
// MainApplication.from(getActivity()).getGraph().inject(this);
//
// ButterKnife.bind(this, rootView);
//
// mPresenter.setView(this);
//
// mPresenter.init(packageName);
//
// return rootView;
// }
//
// @Override
// public void onPause() {
// mPresenter.clearView();
// super.onPause();
// }
//
// @Override
// public void onResume() {
// super.onResume();
// mPresenter.setView(this);
// }
//
// @Override
// public void showWaitDialog() {
// mProgressBar.setVisibility(View.VISIBLE);
// }
//
// @Override
// public void hideWaitDialog() {
// mProgressBar.setVisibility(View.GONE);
// }
//
// @Override
// public void showDetailContainer() {
// mTabLayout.setVisibility(View.VISIBLE);
// mViewPager.setVisibility(View.VISIBLE);
// }
//
// @Override
// public void hideDetailContainer() {
// mTabLayout.setVisibility(View.GONE);
// mViewPager.setVisibility(View.GONE);
// }
//
// @Override
// public void setTitle(String title) {
// ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(title);
// }
//
// @Override
// public void initViews(String appName, String packageName) {
// ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(appName);
//
// mViewPagerAdapter = new PackageDetailViewPagerAdapter(this.getChildFragmentManager());
// mViewPagerAdapter.addFragment(ApplicationInfoFragment.newInstance(packageName), getString(R.string.tab_header_application_info));
// mViewPagerAdapter.addFragment(ActivitiesFragment.newInstance(packageName), getString(R.string.tab_header_activities));
// mViewPagerAdapter.addFragment(ServicesFragment.newInstance(packageName), getString(R.string.tab_header_services));
// mViewPagerAdapter.addFragment(ContentProvidersFragment.newInstance(packageName), getString(R.string.tab_header_content_providers));
// mViewPagerAdapter.addFragment(BroadcastReceiversFragment.newInstance(packageName), getString(R.string.tab_header_broadcast_receivers));
// mViewPagerAdapter.addFragment(RequestedPermissionsFragment.newInstance(packageName), getString(R.string.tab_header_requested_permissions));
// mViewPagerAdapter.addFragment(DeclaredPermissionsFragment.newInstance(packageName), getString(R.string.tab_header_declared_permissions));
// mViewPagerAdapter.addFragment(RequestedFeaturesFragment.newInstance(packageName), getString(R.string.tab_header_requested_features));
// mViewPager.setAdapter(mViewPagerAdapter);
// mTabLayout.setupWithViewPager(mViewPager);
// }
//
// @Override
// public void showError(String message) {
//
// }
// }
// Path: app/src/main/java/com/livingstoneapp/activities/PackageDetailActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.livingstoneapp.R;
import com.livingstoneapp.fragments.PackageDetailFragment;
package com.livingstoneapp.activities;
public class PackageDetailActivity extends AppCompatActivity {
public static String ARG_PACKAGE_NAME = "PackageName";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_package_detail);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if(getSupportActionBar() != null) {
getSupportActionBar().setElevation(0);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
Bundle arguments = new Bundle();
|
arguments.putString(PackageDetailFragment.ARG_PACKAGE_NAME, getIntent().getStringExtra(ARG_PACKAGE_NAME));
|
oosthuizenr/Livingstone
|
app/src/debug/java/com/livingstoneapp/dagger/PackageListActivityModule.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageListActivityPresenter.java
// public interface IPackageListActivityPresenter {
// void setView(IPackageListView view);
// void clearView();
// void setTwoPane();
// void init();
// void loadPackages(boolean refresh);
// void packageSelected(InstalledPackageHeader header);
//
//
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/PackageListActivityPresenterImpl.java
// public class PackageListActivityPresenterImpl implements IPackageListActivityPresenter {
//
// private IPackageListView mView;
// private boolean mIsTwoPane = false;
// private IPackageInteractor mPackageInteractor;
//
//
// @Inject
// public PackageListActivityPresenterImpl(IPackageInteractor interactor) {
// mPackageInteractor = interactor;
// }
//
// @Override
// public void setView(IPackageListView view) {
// mView = view;
// }
//
// @Override
// public void clearView() {
// mView = null;
// }
//
// @Override
// public void setTwoPane() {
// mIsTwoPane = true;
// }
//
// @Override
// public void init() {
// mView.init();
// }
//
// @Override
// public void loadPackages(boolean refresh) {
// if (mView != null) {
// mView.hideContentView();
// mView.showWaitDialog();
//
// mPackageInteractor.getInstalledPackages(refresh)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(
// items -> {
// if (mView != null) {
// if (items.size() > 0) {
// mView.setInstalledPackages(items);
// mView.hideWaitDialog();
// mView.showContentView();
// } else {
// mView.hideWaitDialog();
// mView.setError("No Packages");
// }
// }
// },
// error -> {
// if (mView != null) {
// mView.setError(error.getMessage());
// mView.hideWaitDialog();
// }
// });
// }
// }
//
// @Override
// public void packageSelected(InstalledPackageHeader header) {
// if (mView != null) {
// if (mIsTwoPane) {
// mView.setDetailFragment(header);
// } else {
// mView.startDetailActivity(header);
// }
// }
// }
//
//
// }
|
import org.mockito.Mockito;
import dagger.Module;
import dagger.Provides;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.presenters.IPackageListActivityPresenter;
import com.livingstoneapp.presenters.PackageListActivityPresenterImpl;
|
package com.livingstoneapp.dagger;
/**
* Created by renier on 2/2/2016.
*/
@Module
public class PackageListActivityModule {
private boolean mProvideMocks;
public PackageListActivityModule(boolean provideMocks) {
this.mProvideMocks = provideMocks;
}
@Provides
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageListActivityPresenter.java
// public interface IPackageListActivityPresenter {
// void setView(IPackageListView view);
// void clearView();
// void setTwoPane();
// void init();
// void loadPackages(boolean refresh);
// void packageSelected(InstalledPackageHeader header);
//
//
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/PackageListActivityPresenterImpl.java
// public class PackageListActivityPresenterImpl implements IPackageListActivityPresenter {
//
// private IPackageListView mView;
// private boolean mIsTwoPane = false;
// private IPackageInteractor mPackageInteractor;
//
//
// @Inject
// public PackageListActivityPresenterImpl(IPackageInteractor interactor) {
// mPackageInteractor = interactor;
// }
//
// @Override
// public void setView(IPackageListView view) {
// mView = view;
// }
//
// @Override
// public void clearView() {
// mView = null;
// }
//
// @Override
// public void setTwoPane() {
// mIsTwoPane = true;
// }
//
// @Override
// public void init() {
// mView.init();
// }
//
// @Override
// public void loadPackages(boolean refresh) {
// if (mView != null) {
// mView.hideContentView();
// mView.showWaitDialog();
//
// mPackageInteractor.getInstalledPackages(refresh)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(
// items -> {
// if (mView != null) {
// if (items.size() > 0) {
// mView.setInstalledPackages(items);
// mView.hideWaitDialog();
// mView.showContentView();
// } else {
// mView.hideWaitDialog();
// mView.setError("No Packages");
// }
// }
// },
// error -> {
// if (mView != null) {
// mView.setError(error.getMessage());
// mView.hideWaitDialog();
// }
// });
// }
// }
//
// @Override
// public void packageSelected(InstalledPackageHeader header) {
// if (mView != null) {
// if (mIsTwoPane) {
// mView.setDetailFragment(header);
// } else {
// mView.startDetailActivity(header);
// }
// }
// }
//
//
// }
// Path: app/src/debug/java/com/livingstoneapp/dagger/PackageListActivityModule.java
import org.mockito.Mockito;
import dagger.Module;
import dagger.Provides;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.presenters.IPackageListActivityPresenter;
import com.livingstoneapp.presenters.PackageListActivityPresenterImpl;
package com.livingstoneapp.dagger;
/**
* Created by renier on 2/2/2016.
*/
@Module
public class PackageListActivityModule {
private boolean mProvideMocks;
public PackageListActivityModule(boolean provideMocks) {
this.mProvideMocks = provideMocks;
}
@Provides
|
IPackageListActivityPresenter providesMainActivityPresenter(IPackageInteractor interactor) {
|
oosthuizenr/Livingstone
|
app/src/debug/java/com/livingstoneapp/dagger/PackageListActivityModule.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageListActivityPresenter.java
// public interface IPackageListActivityPresenter {
// void setView(IPackageListView view);
// void clearView();
// void setTwoPane();
// void init();
// void loadPackages(boolean refresh);
// void packageSelected(InstalledPackageHeader header);
//
//
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/PackageListActivityPresenterImpl.java
// public class PackageListActivityPresenterImpl implements IPackageListActivityPresenter {
//
// private IPackageListView mView;
// private boolean mIsTwoPane = false;
// private IPackageInteractor mPackageInteractor;
//
//
// @Inject
// public PackageListActivityPresenterImpl(IPackageInteractor interactor) {
// mPackageInteractor = interactor;
// }
//
// @Override
// public void setView(IPackageListView view) {
// mView = view;
// }
//
// @Override
// public void clearView() {
// mView = null;
// }
//
// @Override
// public void setTwoPane() {
// mIsTwoPane = true;
// }
//
// @Override
// public void init() {
// mView.init();
// }
//
// @Override
// public void loadPackages(boolean refresh) {
// if (mView != null) {
// mView.hideContentView();
// mView.showWaitDialog();
//
// mPackageInteractor.getInstalledPackages(refresh)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(
// items -> {
// if (mView != null) {
// if (items.size() > 0) {
// mView.setInstalledPackages(items);
// mView.hideWaitDialog();
// mView.showContentView();
// } else {
// mView.hideWaitDialog();
// mView.setError("No Packages");
// }
// }
// },
// error -> {
// if (mView != null) {
// mView.setError(error.getMessage());
// mView.hideWaitDialog();
// }
// });
// }
// }
//
// @Override
// public void packageSelected(InstalledPackageHeader header) {
// if (mView != null) {
// if (mIsTwoPane) {
// mView.setDetailFragment(header);
// } else {
// mView.startDetailActivity(header);
// }
// }
// }
//
//
// }
|
import org.mockito.Mockito;
import dagger.Module;
import dagger.Provides;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.presenters.IPackageListActivityPresenter;
import com.livingstoneapp.presenters.PackageListActivityPresenterImpl;
|
package com.livingstoneapp.dagger;
/**
* Created by renier on 2/2/2016.
*/
@Module
public class PackageListActivityModule {
private boolean mProvideMocks;
public PackageListActivityModule(boolean provideMocks) {
this.mProvideMocks = provideMocks;
}
@Provides
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageListActivityPresenter.java
// public interface IPackageListActivityPresenter {
// void setView(IPackageListView view);
// void clearView();
// void setTwoPane();
// void init();
// void loadPackages(boolean refresh);
// void packageSelected(InstalledPackageHeader header);
//
//
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/PackageListActivityPresenterImpl.java
// public class PackageListActivityPresenterImpl implements IPackageListActivityPresenter {
//
// private IPackageListView mView;
// private boolean mIsTwoPane = false;
// private IPackageInteractor mPackageInteractor;
//
//
// @Inject
// public PackageListActivityPresenterImpl(IPackageInteractor interactor) {
// mPackageInteractor = interactor;
// }
//
// @Override
// public void setView(IPackageListView view) {
// mView = view;
// }
//
// @Override
// public void clearView() {
// mView = null;
// }
//
// @Override
// public void setTwoPane() {
// mIsTwoPane = true;
// }
//
// @Override
// public void init() {
// mView.init();
// }
//
// @Override
// public void loadPackages(boolean refresh) {
// if (mView != null) {
// mView.hideContentView();
// mView.showWaitDialog();
//
// mPackageInteractor.getInstalledPackages(refresh)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(
// items -> {
// if (mView != null) {
// if (items.size() > 0) {
// mView.setInstalledPackages(items);
// mView.hideWaitDialog();
// mView.showContentView();
// } else {
// mView.hideWaitDialog();
// mView.setError("No Packages");
// }
// }
// },
// error -> {
// if (mView != null) {
// mView.setError(error.getMessage());
// mView.hideWaitDialog();
// }
// });
// }
// }
//
// @Override
// public void packageSelected(InstalledPackageHeader header) {
// if (mView != null) {
// if (mIsTwoPane) {
// mView.setDetailFragment(header);
// } else {
// mView.startDetailActivity(header);
// }
// }
// }
//
//
// }
// Path: app/src/debug/java/com/livingstoneapp/dagger/PackageListActivityModule.java
import org.mockito.Mockito;
import dagger.Module;
import dagger.Provides;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.presenters.IPackageListActivityPresenter;
import com.livingstoneapp.presenters.PackageListActivityPresenterImpl;
package com.livingstoneapp.dagger;
/**
* Created by renier on 2/2/2016.
*/
@Module
public class PackageListActivityModule {
private boolean mProvideMocks;
public PackageListActivityModule(boolean provideMocks) {
this.mProvideMocks = provideMocks;
}
@Provides
|
IPackageListActivityPresenter providesMainActivityPresenter(IPackageInteractor interactor) {
|
oosthuizenr/Livingstone
|
app/src/debug/java/com/livingstoneapp/dagger/PackageListActivityModule.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageListActivityPresenter.java
// public interface IPackageListActivityPresenter {
// void setView(IPackageListView view);
// void clearView();
// void setTwoPane();
// void init();
// void loadPackages(boolean refresh);
// void packageSelected(InstalledPackageHeader header);
//
//
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/PackageListActivityPresenterImpl.java
// public class PackageListActivityPresenterImpl implements IPackageListActivityPresenter {
//
// private IPackageListView mView;
// private boolean mIsTwoPane = false;
// private IPackageInteractor mPackageInteractor;
//
//
// @Inject
// public PackageListActivityPresenterImpl(IPackageInteractor interactor) {
// mPackageInteractor = interactor;
// }
//
// @Override
// public void setView(IPackageListView view) {
// mView = view;
// }
//
// @Override
// public void clearView() {
// mView = null;
// }
//
// @Override
// public void setTwoPane() {
// mIsTwoPane = true;
// }
//
// @Override
// public void init() {
// mView.init();
// }
//
// @Override
// public void loadPackages(boolean refresh) {
// if (mView != null) {
// mView.hideContentView();
// mView.showWaitDialog();
//
// mPackageInteractor.getInstalledPackages(refresh)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(
// items -> {
// if (mView != null) {
// if (items.size() > 0) {
// mView.setInstalledPackages(items);
// mView.hideWaitDialog();
// mView.showContentView();
// } else {
// mView.hideWaitDialog();
// mView.setError("No Packages");
// }
// }
// },
// error -> {
// if (mView != null) {
// mView.setError(error.getMessage());
// mView.hideWaitDialog();
// }
// });
// }
// }
//
// @Override
// public void packageSelected(InstalledPackageHeader header) {
// if (mView != null) {
// if (mIsTwoPane) {
// mView.setDetailFragment(header);
// } else {
// mView.startDetailActivity(header);
// }
// }
// }
//
//
// }
|
import org.mockito.Mockito;
import dagger.Module;
import dagger.Provides;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.presenters.IPackageListActivityPresenter;
import com.livingstoneapp.presenters.PackageListActivityPresenterImpl;
|
package com.livingstoneapp.dagger;
/**
* Created by renier on 2/2/2016.
*/
@Module
public class PackageListActivityModule {
private boolean mProvideMocks;
public PackageListActivityModule(boolean provideMocks) {
this.mProvideMocks = provideMocks;
}
@Provides
IPackageListActivityPresenter providesMainActivityPresenter(IPackageInteractor interactor) {
if (mProvideMocks) {
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/IPackageListActivityPresenter.java
// public interface IPackageListActivityPresenter {
// void setView(IPackageListView view);
// void clearView();
// void setTwoPane();
// void init();
// void loadPackages(boolean refresh);
// void packageSelected(InstalledPackageHeader header);
//
//
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/presenters/PackageListActivityPresenterImpl.java
// public class PackageListActivityPresenterImpl implements IPackageListActivityPresenter {
//
// private IPackageListView mView;
// private boolean mIsTwoPane = false;
// private IPackageInteractor mPackageInteractor;
//
//
// @Inject
// public PackageListActivityPresenterImpl(IPackageInteractor interactor) {
// mPackageInteractor = interactor;
// }
//
// @Override
// public void setView(IPackageListView view) {
// mView = view;
// }
//
// @Override
// public void clearView() {
// mView = null;
// }
//
// @Override
// public void setTwoPane() {
// mIsTwoPane = true;
// }
//
// @Override
// public void init() {
// mView.init();
// }
//
// @Override
// public void loadPackages(boolean refresh) {
// if (mView != null) {
// mView.hideContentView();
// mView.showWaitDialog();
//
// mPackageInteractor.getInstalledPackages(refresh)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(
// items -> {
// if (mView != null) {
// if (items.size() > 0) {
// mView.setInstalledPackages(items);
// mView.hideWaitDialog();
// mView.showContentView();
// } else {
// mView.hideWaitDialog();
// mView.setError("No Packages");
// }
// }
// },
// error -> {
// if (mView != null) {
// mView.setError(error.getMessage());
// mView.hideWaitDialog();
// }
// });
// }
// }
//
// @Override
// public void packageSelected(InstalledPackageHeader header) {
// if (mView != null) {
// if (mIsTwoPane) {
// mView.setDetailFragment(header);
// } else {
// mView.startDetailActivity(header);
// }
// }
// }
//
//
// }
// Path: app/src/debug/java/com/livingstoneapp/dagger/PackageListActivityModule.java
import org.mockito.Mockito;
import dagger.Module;
import dagger.Provides;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.presenters.IPackageListActivityPresenter;
import com.livingstoneapp.presenters.PackageListActivityPresenterImpl;
package com.livingstoneapp.dagger;
/**
* Created by renier on 2/2/2016.
*/
@Module
public class PackageListActivityModule {
private boolean mProvideMocks;
public PackageListActivityModule(boolean provideMocks) {
this.mProvideMocks = provideMocks;
}
@Provides
IPackageListActivityPresenter providesMainActivityPresenter(IPackageInteractor interactor) {
if (mProvideMocks) {
|
return Mockito.mock(PackageListActivityPresenterImpl.class);
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/views/IBroadcastReceiversFragmentView.java
|
// Path: app/src/main/java/com/livingstoneapp/models/BroadcastReceiverInfo.java
// public class BroadcastReceiverInfo implements Parcelable, Comparable<BroadcastReceiverInfo> {
// private String mName;
//
// public BroadcastReceiverInfo(
// String mName) {
// this.mName = mName;
// }
//
//
// public String getName() {
// return mName;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// }
//
// protected BroadcastReceiverInfo(Parcel in) {
// this.mName = in.readString();
// }
//
// public static final Creator<BroadcastReceiverInfo> CREATOR = new Creator<BroadcastReceiverInfo>() {
// public BroadcastReceiverInfo createFromParcel(Parcel source) {
// return new BroadcastReceiverInfo(source);
// }
//
// public BroadcastReceiverInfo[] newArray(int size) {
// return new BroadcastReceiverInfo[size];
// }
// };
//
// @Override
// public int compareTo(BroadcastReceiverInfo another) {
// return this.getName().compareToIgnoreCase(another.getName());
// }
// }
|
import java.util.ArrayList;
import com.livingstoneapp.models.BroadcastReceiverInfo;
|
package com.livingstoneapp.views;
/**
* Created by Renier on 2016/02/16.
*/
public interface IBroadcastReceiversFragmentView {
void showError(String message);
|
// Path: app/src/main/java/com/livingstoneapp/models/BroadcastReceiverInfo.java
// public class BroadcastReceiverInfo implements Parcelable, Comparable<BroadcastReceiverInfo> {
// private String mName;
//
// public BroadcastReceiverInfo(
// String mName) {
// this.mName = mName;
// }
//
//
// public String getName() {
// return mName;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// }
//
// protected BroadcastReceiverInfo(Parcel in) {
// this.mName = in.readString();
// }
//
// public static final Creator<BroadcastReceiverInfo> CREATOR = new Creator<BroadcastReceiverInfo>() {
// public BroadcastReceiverInfo createFromParcel(Parcel source) {
// return new BroadcastReceiverInfo(source);
// }
//
// public BroadcastReceiverInfo[] newArray(int size) {
// return new BroadcastReceiverInfo[size];
// }
// };
//
// @Override
// public int compareTo(BroadcastReceiverInfo another) {
// return this.getName().compareToIgnoreCase(another.getName());
// }
// }
// Path: app/src/main/java/com/livingstoneapp/views/IBroadcastReceiversFragmentView.java
import java.util.ArrayList;
import com.livingstoneapp.models.BroadcastReceiverInfo;
package com.livingstoneapp.views;
/**
* Created by Renier on 2016/02/16.
*/
public interface IBroadcastReceiversFragmentView {
void showError(String message);
|
void setModel(ArrayList<BroadcastReceiverInfo> receivers);
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/views/IDeclaredPermissionsFragmentView.java
|
// Path: app/src/main/java/com/livingstoneapp/models/DeclaredPermission.java
// public class DeclaredPermission {
//
// private String mName;
// private String mLabel;
// private ArrayList<String> mProtectionLevel;
// private ArrayList<String> mFlags;
//
// public DeclaredPermission(String mName, String mLabel, ArrayList<String> mProtectionLevel, ArrayList<String> mFlags) {
// this.mLabel = mLabel;
// this.mName = mName;
// this.mProtectionLevel = mProtectionLevel;
// this.mFlags = mFlags;
// }
//
// public String getLabel() {
// return mLabel;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<String> getProtectionLevel() {
// return mProtectionLevel;
// }
//
// public ArrayList<String> getFlags() { return mFlags; }
// }
|
import java.util.ArrayList;
import com.livingstoneapp.models.DeclaredPermission;
|
package com.livingstoneapp.views;
/**
* Created by renier on 2/18/2016.
*/
public interface IDeclaredPermissionsFragmentView {
void showError(String message);
|
// Path: app/src/main/java/com/livingstoneapp/models/DeclaredPermission.java
// public class DeclaredPermission {
//
// private String mName;
// private String mLabel;
// private ArrayList<String> mProtectionLevel;
// private ArrayList<String> mFlags;
//
// public DeclaredPermission(String mName, String mLabel, ArrayList<String> mProtectionLevel, ArrayList<String> mFlags) {
// this.mLabel = mLabel;
// this.mName = mName;
// this.mProtectionLevel = mProtectionLevel;
// this.mFlags = mFlags;
// }
//
// public String getLabel() {
// return mLabel;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<String> getProtectionLevel() {
// return mProtectionLevel;
// }
//
// public ArrayList<String> getFlags() { return mFlags; }
// }
// Path: app/src/main/java/com/livingstoneapp/views/IDeclaredPermissionsFragmentView.java
import java.util.ArrayList;
import com.livingstoneapp.models.DeclaredPermission;
package com.livingstoneapp.views;
/**
* Created by renier on 2/18/2016.
*/
public interface IDeclaredPermissionsFragmentView {
void showError(String message);
|
void setModel(ArrayList<DeclaredPermission> permissions);
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/presenters/RequestedPermissionsFragmentPresenterImpl.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPermissionsInteractor.java
// public interface IPermissionsInteractor {
// Observable<ArrayList<DeclaredPermission>> getDeclaredPermissions(String packageName);
// Observable<ArrayList<RequestedPermission>> getRequestedPermissions(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IRequestedPermissionsFragmentView.java
// public interface IRequestedPermissionsFragmentView {
// void showError(String message);
// void setModel(ArrayList<RequestedPermission> permissions);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void showNoValuesText();
// void hideNoValuesText();
// }
|
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IPermissionsInteractor;
import com.livingstoneapp.views.IRequestedPermissionsFragmentView;
|
package com.livingstoneapp.presenters;
/**
* Created by renier on 2/18/2016.
*/
public class RequestedPermissionsFragmentPresenterImpl implements IRequestedPermissionsFragmentPresenter {
private IPermissionsInteractor mInteractor;
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPermissionsInteractor.java
// public interface IPermissionsInteractor {
// Observable<ArrayList<DeclaredPermission>> getDeclaredPermissions(String packageName);
// Observable<ArrayList<RequestedPermission>> getRequestedPermissions(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IRequestedPermissionsFragmentView.java
// public interface IRequestedPermissionsFragmentView {
// void showError(String message);
// void setModel(ArrayList<RequestedPermission> permissions);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void showNoValuesText();
// void hideNoValuesText();
// }
// Path: app/src/main/java/com/livingstoneapp/presenters/RequestedPermissionsFragmentPresenterImpl.java
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IPermissionsInteractor;
import com.livingstoneapp.views.IRequestedPermissionsFragmentView;
package com.livingstoneapp.presenters;
/**
* Created by renier on 2/18/2016.
*/
public class RequestedPermissionsFragmentPresenterImpl implements IRequestedPermissionsFragmentPresenter {
private IPermissionsInteractor mInteractor;
|
private IRequestedPermissionsFragmentView mView;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/presenters/DeclaredPermissionsFragmentPresenterImpl.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPermissionsInteractor.java
// public interface IPermissionsInteractor {
// Observable<ArrayList<DeclaredPermission>> getDeclaredPermissions(String packageName);
// Observable<ArrayList<RequestedPermission>> getRequestedPermissions(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IDeclaredPermissionsFragmentView.java
// public interface IDeclaredPermissionsFragmentView {
// void showError(String message);
// void setModel(ArrayList<DeclaredPermission> permissions);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void showNoValuesText();
// void hideNoValuesText();
// }
|
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IPermissionsInteractor;
import com.livingstoneapp.views.IDeclaredPermissionsFragmentView;
|
package com.livingstoneapp.presenters;
/**
* Created by renier on 2/18/2016.
*/
public class DeclaredPermissionsFragmentPresenterImpl implements IDeclaredPermissionsFragmentPresenter {
private IPermissionsInteractor mInteractor;
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPermissionsInteractor.java
// public interface IPermissionsInteractor {
// Observable<ArrayList<DeclaredPermission>> getDeclaredPermissions(String packageName);
// Observable<ArrayList<RequestedPermission>> getRequestedPermissions(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IDeclaredPermissionsFragmentView.java
// public interface IDeclaredPermissionsFragmentView {
// void showError(String message);
// void setModel(ArrayList<DeclaredPermission> permissions);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void showNoValuesText();
// void hideNoValuesText();
// }
// Path: app/src/main/java/com/livingstoneapp/presenters/DeclaredPermissionsFragmentPresenterImpl.java
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IPermissionsInteractor;
import com.livingstoneapp.views.IDeclaredPermissionsFragmentView;
package com.livingstoneapp.presenters;
/**
* Created by renier on 2/18/2016.
*/
public class DeclaredPermissionsFragmentPresenterImpl implements IDeclaredPermissionsFragmentPresenter {
private IPermissionsInteractor mInteractor;
|
private IDeclaredPermissionsFragmentView mView;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/presenters/IBroadcastReceiversFragmentPresenter.java
|
// Path: app/src/main/java/com/livingstoneapp/models/BroadcastReceiverInfo.java
// public class BroadcastReceiverInfo implements Parcelable, Comparable<BroadcastReceiverInfo> {
// private String mName;
//
// public BroadcastReceiverInfo(
// String mName) {
// this.mName = mName;
// }
//
//
// public String getName() {
// return mName;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// }
//
// protected BroadcastReceiverInfo(Parcel in) {
// this.mName = in.readString();
// }
//
// public static final Creator<BroadcastReceiverInfo> CREATOR = new Creator<BroadcastReceiverInfo>() {
// public BroadcastReceiverInfo createFromParcel(Parcel source) {
// return new BroadcastReceiverInfo(source);
// }
//
// public BroadcastReceiverInfo[] newArray(int size) {
// return new BroadcastReceiverInfo[size];
// }
// };
//
// @Override
// public int compareTo(BroadcastReceiverInfo another) {
// return this.getName().compareToIgnoreCase(another.getName());
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IBroadcastReceiversFragmentView.java
// public interface IBroadcastReceiversFragmentView {
// void showError(String message);
// void setModel(ArrayList<BroadcastReceiverInfo> receivers);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void startBroadcastReceiverDetailActivity(BroadcastReceiverInfo receiver);
// void showNoValuesText();
// void hideNoValuesText();
// }
|
import com.livingstoneapp.models.BroadcastReceiverInfo;
import com.livingstoneapp.views.IBroadcastReceiversFragmentView;
|
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/02/16.
*/
public interface IBroadcastReceiversFragmentPresenter {
void setView(IBroadcastReceiversFragmentView view);
void clearView();
void init(String packageName);
|
// Path: app/src/main/java/com/livingstoneapp/models/BroadcastReceiverInfo.java
// public class BroadcastReceiverInfo implements Parcelable, Comparable<BroadcastReceiverInfo> {
// private String mName;
//
// public BroadcastReceiverInfo(
// String mName) {
// this.mName = mName;
// }
//
//
// public String getName() {
// return mName;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// }
//
// protected BroadcastReceiverInfo(Parcel in) {
// this.mName = in.readString();
// }
//
// public static final Creator<BroadcastReceiverInfo> CREATOR = new Creator<BroadcastReceiverInfo>() {
// public BroadcastReceiverInfo createFromParcel(Parcel source) {
// return new BroadcastReceiverInfo(source);
// }
//
// public BroadcastReceiverInfo[] newArray(int size) {
// return new BroadcastReceiverInfo[size];
// }
// };
//
// @Override
// public int compareTo(BroadcastReceiverInfo another) {
// return this.getName().compareToIgnoreCase(another.getName());
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IBroadcastReceiversFragmentView.java
// public interface IBroadcastReceiversFragmentView {
// void showError(String message);
// void setModel(ArrayList<BroadcastReceiverInfo> receivers);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void startBroadcastReceiverDetailActivity(BroadcastReceiverInfo receiver);
// void showNoValuesText();
// void hideNoValuesText();
// }
// Path: app/src/main/java/com/livingstoneapp/presenters/IBroadcastReceiversFragmentPresenter.java
import com.livingstoneapp.models.BroadcastReceiverInfo;
import com.livingstoneapp.views.IBroadcastReceiversFragmentView;
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/02/16.
*/
public interface IBroadcastReceiversFragmentPresenter {
void setView(IBroadcastReceiversFragmentView view);
void clearView();
void init(String packageName);
|
void onBroadcastReceiverSelected(BroadcastReceiverInfo receiver);
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/views/IRequestedPermissionsFragmentView.java
|
// Path: app/src/main/java/com/livingstoneapp/models/RequestedPermission.java
// public class RequestedPermission {
// private String mName;
// private boolean mGranted;
//
// public RequestedPermission(String mName, boolean mGranted) {
// this.mGranted = mGranted;
// this.mName = mName;
// }
//
// public boolean isGranted() {
// return mGranted;
// }
//
// public String getName() {
// return mName;
// }
// }
|
import java.util.ArrayList;
import com.livingstoneapp.models.RequestedPermission;
|
package com.livingstoneapp.views;
/**
* Created by renier on 2/18/2016.
*/
public interface IRequestedPermissionsFragmentView {
void showError(String message);
|
// Path: app/src/main/java/com/livingstoneapp/models/RequestedPermission.java
// public class RequestedPermission {
// private String mName;
// private boolean mGranted;
//
// public RequestedPermission(String mName, boolean mGranted) {
// this.mGranted = mGranted;
// this.mName = mName;
// }
//
// public boolean isGranted() {
// return mGranted;
// }
//
// public String getName() {
// return mName;
// }
// }
// Path: app/src/main/java/com/livingstoneapp/views/IRequestedPermissionsFragmentView.java
import java.util.ArrayList;
import com.livingstoneapp.models.RequestedPermission;
package com.livingstoneapp.views;
/**
* Created by renier on 2/18/2016.
*/
public interface IRequestedPermissionsFragmentView {
void showError(String message);
|
void setModel(ArrayList<RequestedPermission> permissions);
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/dagger/ApplicationModule.java
|
// Path: app/src/main/java/com/livingstoneapp/MainApplication.java
// public class MainApplication extends Application {
// private Graph mGraph;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// mGraph = Graph.Initializer.init(this, false);
// }
//
// public Graph getGraph() {
// return mGraph;
// }
//
// public void setMockMode(boolean provideMocks) {
// mGraph = Graph.Initializer.init(this, provideMocks);
// }
//
// public static MainApplication from(@NonNull Context context) {
// return (MainApplication) context.getApplicationContext();
// }
// }
|
import android.content.Context;
import dagger.Module;
import dagger.Provides;
import com.livingstoneapp.MainApplication;
|
package com.livingstoneapp.dagger;
/**
* Created by renier on 1/12/2016.
*/
@Module
public class ApplicationModule {
|
// Path: app/src/main/java/com/livingstoneapp/MainApplication.java
// public class MainApplication extends Application {
// private Graph mGraph;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// mGraph = Graph.Initializer.init(this, false);
// }
//
// public Graph getGraph() {
// return mGraph;
// }
//
// public void setMockMode(boolean provideMocks) {
// mGraph = Graph.Initializer.init(this, provideMocks);
// }
//
// public static MainApplication from(@NonNull Context context) {
// return (MainApplication) context.getApplicationContext();
// }
// }
// Path: app/src/main/java/com/livingstoneapp/dagger/ApplicationModule.java
import android.content.Context;
import dagger.Module;
import dagger.Provides;
import com.livingstoneapp.MainApplication;
package com.livingstoneapp.dagger;
/**
* Created by renier on 1/12/2016.
*/
@Module
public class ApplicationModule {
|
private static MainApplication sApplication;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/presenters/PackageListActivityPresenterImpl.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
// public interface IPackageListView {
// void init();
// void setInstalledPackages(List<InstalledPackageHeader> items);
// void setError(String message);
// void startDetailActivity(InstalledPackageHeader item);
// void setDetailFragment(InstalledPackageHeader item);
// void showWaitDialog();
// void hideWaitDialog();
// void showContentView();
// void hideContentView();
// }
|
import javax.inject.Inject;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.models.InstalledPackageHeader;
import com.livingstoneapp.views.IPackageListView;
|
package com.livingstoneapp.presenters;
/**
* Created by renier on 2/2/2016.
*/
public class PackageListActivityPresenterImpl implements IPackageListActivityPresenter {
private IPackageListView mView;
private boolean mIsTwoPane = false;
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
// public interface IPackageListView {
// void init();
// void setInstalledPackages(List<InstalledPackageHeader> items);
// void setError(String message);
// void startDetailActivity(InstalledPackageHeader item);
// void setDetailFragment(InstalledPackageHeader item);
// void showWaitDialog();
// void hideWaitDialog();
// void showContentView();
// void hideContentView();
// }
// Path: app/src/main/java/com/livingstoneapp/presenters/PackageListActivityPresenterImpl.java
import javax.inject.Inject;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.models.InstalledPackageHeader;
import com.livingstoneapp.views.IPackageListView;
package com.livingstoneapp.presenters;
/**
* Created by renier on 2/2/2016.
*/
public class PackageListActivityPresenterImpl implements IPackageListActivityPresenter {
private IPackageListView mView;
private boolean mIsTwoPane = false;
|
private IPackageInteractor mPackageInteractor;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/presenters/PackageListActivityPresenterImpl.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
// public interface IPackageListView {
// void init();
// void setInstalledPackages(List<InstalledPackageHeader> items);
// void setError(String message);
// void startDetailActivity(InstalledPackageHeader item);
// void setDetailFragment(InstalledPackageHeader item);
// void showWaitDialog();
// void hideWaitDialog();
// void showContentView();
// void hideContentView();
// }
|
import javax.inject.Inject;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.models.InstalledPackageHeader;
import com.livingstoneapp.views.IPackageListView;
|
if (mView != null) {
mView.hideContentView();
mView.showWaitDialog();
mPackageInteractor.getInstalledPackages(refresh)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
items -> {
if (mView != null) {
if (items.size() > 0) {
mView.setInstalledPackages(items);
mView.hideWaitDialog();
mView.showContentView();
} else {
mView.hideWaitDialog();
mView.setError("No Packages");
}
}
},
error -> {
if (mView != null) {
mView.setError(error.getMessage());
mView.hideWaitDialog();
}
});
}
}
@Override
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
// Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
// Observable<String> getAppNameFromPackage(String packageName);
// Observable<AppInfo> getApplicationInfo(String packageName);
// Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
//
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
// public interface IPackageListView {
// void init();
// void setInstalledPackages(List<InstalledPackageHeader> items);
// void setError(String message);
// void startDetailActivity(InstalledPackageHeader item);
// void setDetailFragment(InstalledPackageHeader item);
// void showWaitDialog();
// void hideWaitDialog();
// void showContentView();
// void hideContentView();
// }
// Path: app/src/main/java/com/livingstoneapp/presenters/PackageListActivityPresenterImpl.java
import javax.inject.Inject;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.models.InstalledPackageHeader;
import com.livingstoneapp.views.IPackageListView;
if (mView != null) {
mView.hideContentView();
mView.showWaitDialog();
mPackageInteractor.getInstalledPackages(refresh)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
items -> {
if (mView != null) {
if (items.size() > 0) {
mView.setInstalledPackages(items);
mView.hideWaitDialog();
mView.showContentView();
} else {
mView.hideWaitDialog();
mView.setError("No Packages");
}
}
},
error -> {
if (mView != null) {
mView.setError(error.getMessage());
mView.hideWaitDialog();
}
});
}
}
@Override
|
public void packageSelected(InstalledPackageHeader header) {
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/presenters/BroadcastReceiversFragmentPresenterImpl.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IBroadcastReceiverInteractor.java
// public interface IBroadcastReceiverInteractor {
// Observable<ArrayList<BroadcastReceiverInfo>> getBroadcastReceivers(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/BroadcastReceiverInfo.java
// public class BroadcastReceiverInfo implements Parcelable, Comparable<BroadcastReceiverInfo> {
// private String mName;
//
// public BroadcastReceiverInfo(
// String mName) {
// this.mName = mName;
// }
//
//
// public String getName() {
// return mName;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// }
//
// protected BroadcastReceiverInfo(Parcel in) {
// this.mName = in.readString();
// }
//
// public static final Creator<BroadcastReceiverInfo> CREATOR = new Creator<BroadcastReceiverInfo>() {
// public BroadcastReceiverInfo createFromParcel(Parcel source) {
// return new BroadcastReceiverInfo(source);
// }
//
// public BroadcastReceiverInfo[] newArray(int size) {
// return new BroadcastReceiverInfo[size];
// }
// };
//
// @Override
// public int compareTo(BroadcastReceiverInfo another) {
// return this.getName().compareToIgnoreCase(another.getName());
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IBroadcastReceiversFragmentView.java
// public interface IBroadcastReceiversFragmentView {
// void showError(String message);
// void setModel(ArrayList<BroadcastReceiverInfo> receivers);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void startBroadcastReceiverDetailActivity(BroadcastReceiverInfo receiver);
// void showNoValuesText();
// void hideNoValuesText();
// }
|
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IBroadcastReceiverInteractor;
import com.livingstoneapp.models.BroadcastReceiverInfo;
import com.livingstoneapp.views.IBroadcastReceiversFragmentView;
|
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/02/16.
*/
public class BroadcastReceiversFragmentPresenterImpl implements IBroadcastReceiversFragmentPresenter {
private IBroadcastReceiverInteractor mInteractor;
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IBroadcastReceiverInteractor.java
// public interface IBroadcastReceiverInteractor {
// Observable<ArrayList<BroadcastReceiverInfo>> getBroadcastReceivers(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/BroadcastReceiverInfo.java
// public class BroadcastReceiverInfo implements Parcelable, Comparable<BroadcastReceiverInfo> {
// private String mName;
//
// public BroadcastReceiverInfo(
// String mName) {
// this.mName = mName;
// }
//
//
// public String getName() {
// return mName;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// }
//
// protected BroadcastReceiverInfo(Parcel in) {
// this.mName = in.readString();
// }
//
// public static final Creator<BroadcastReceiverInfo> CREATOR = new Creator<BroadcastReceiverInfo>() {
// public BroadcastReceiverInfo createFromParcel(Parcel source) {
// return new BroadcastReceiverInfo(source);
// }
//
// public BroadcastReceiverInfo[] newArray(int size) {
// return new BroadcastReceiverInfo[size];
// }
// };
//
// @Override
// public int compareTo(BroadcastReceiverInfo another) {
// return this.getName().compareToIgnoreCase(another.getName());
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IBroadcastReceiversFragmentView.java
// public interface IBroadcastReceiversFragmentView {
// void showError(String message);
// void setModel(ArrayList<BroadcastReceiverInfo> receivers);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void startBroadcastReceiverDetailActivity(BroadcastReceiverInfo receiver);
// void showNoValuesText();
// void hideNoValuesText();
// }
// Path: app/src/main/java/com/livingstoneapp/presenters/BroadcastReceiversFragmentPresenterImpl.java
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IBroadcastReceiverInteractor;
import com.livingstoneapp.models.BroadcastReceiverInfo;
import com.livingstoneapp.views.IBroadcastReceiversFragmentView;
package com.livingstoneapp.presenters;
/**
* Created by Renier on 2016/02/16.
*/
public class BroadcastReceiversFragmentPresenterImpl implements IBroadcastReceiversFragmentPresenter {
private IBroadcastReceiverInteractor mInteractor;
|
private IBroadcastReceiversFragmentView mView;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/presenters/BroadcastReceiversFragmentPresenterImpl.java
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IBroadcastReceiverInteractor.java
// public interface IBroadcastReceiverInteractor {
// Observable<ArrayList<BroadcastReceiverInfo>> getBroadcastReceivers(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/BroadcastReceiverInfo.java
// public class BroadcastReceiverInfo implements Parcelable, Comparable<BroadcastReceiverInfo> {
// private String mName;
//
// public BroadcastReceiverInfo(
// String mName) {
// this.mName = mName;
// }
//
//
// public String getName() {
// return mName;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// }
//
// protected BroadcastReceiverInfo(Parcel in) {
// this.mName = in.readString();
// }
//
// public static final Creator<BroadcastReceiverInfo> CREATOR = new Creator<BroadcastReceiverInfo>() {
// public BroadcastReceiverInfo createFromParcel(Parcel source) {
// return new BroadcastReceiverInfo(source);
// }
//
// public BroadcastReceiverInfo[] newArray(int size) {
// return new BroadcastReceiverInfo[size];
// }
// };
//
// @Override
// public int compareTo(BroadcastReceiverInfo another) {
// return this.getName().compareToIgnoreCase(another.getName());
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IBroadcastReceiversFragmentView.java
// public interface IBroadcastReceiversFragmentView {
// void showError(String message);
// void setModel(ArrayList<BroadcastReceiverInfo> receivers);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void startBroadcastReceiverDetailActivity(BroadcastReceiverInfo receiver);
// void showNoValuesText();
// void hideNoValuesText();
// }
|
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IBroadcastReceiverInteractor;
import com.livingstoneapp.models.BroadcastReceiverInfo;
import com.livingstoneapp.views.IBroadcastReceiversFragmentView;
|
@Override
public void init(String packageName) {
mView.hideNoValuesText();
mView.hideDetailContainer();
mView.showWaitDialog();
mInteractor.getBroadcastReceivers(packageName)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {
if (mView != null) {
if (result.size() > 0) {
mView.setModel(result);
mView.showDetailContainer();
mView.hideWaitDialog();
} else {
mView.showNoValuesText();
mView.hideWaitDialog();
}
}
}, error -> {
if (mView != null) {
mView.hideWaitDialog();
mView.showError(error.getMessage());
}
});
}
@Override
|
// Path: app/src/main/java/com/livingstoneapp/interactors/IBroadcastReceiverInteractor.java
// public interface IBroadcastReceiverInteractor {
// Observable<ArrayList<BroadcastReceiverInfo>> getBroadcastReceivers(String packageName);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/BroadcastReceiverInfo.java
// public class BroadcastReceiverInfo implements Parcelable, Comparable<BroadcastReceiverInfo> {
// private String mName;
//
// public BroadcastReceiverInfo(
// String mName) {
// this.mName = mName;
// }
//
//
// public String getName() {
// return mName;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// }
//
// protected BroadcastReceiverInfo(Parcel in) {
// this.mName = in.readString();
// }
//
// public static final Creator<BroadcastReceiverInfo> CREATOR = new Creator<BroadcastReceiverInfo>() {
// public BroadcastReceiverInfo createFromParcel(Parcel source) {
// return new BroadcastReceiverInfo(source);
// }
//
// public BroadcastReceiverInfo[] newArray(int size) {
// return new BroadcastReceiverInfo[size];
// }
// };
//
// @Override
// public int compareTo(BroadcastReceiverInfo another) {
// return this.getName().compareToIgnoreCase(another.getName());
// }
// }
//
// Path: app/src/main/java/com/livingstoneapp/views/IBroadcastReceiversFragmentView.java
// public interface IBroadcastReceiversFragmentView {
// void showError(String message);
// void setModel(ArrayList<BroadcastReceiverInfo> receivers);
// void showWaitDialog();
// void hideWaitDialog();
// void showDetailContainer();
// void hideDetailContainer();
// void startBroadcastReceiverDetailActivity(BroadcastReceiverInfo receiver);
// void showNoValuesText();
// void hideNoValuesText();
// }
// Path: app/src/main/java/com/livingstoneapp/presenters/BroadcastReceiversFragmentPresenterImpl.java
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.livingstoneapp.interactors.IBroadcastReceiverInteractor;
import com.livingstoneapp.models.BroadcastReceiverInfo;
import com.livingstoneapp.views.IBroadcastReceiversFragmentView;
@Override
public void init(String packageName) {
mView.hideNoValuesText();
mView.hideDetailContainer();
mView.showWaitDialog();
mInteractor.getBroadcastReceivers(packageName)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {
if (mView != null) {
if (result.size() > 0) {
mView.setModel(result);
mView.showDetailContainer();
mView.hideWaitDialog();
} else {
mView.showNoValuesText();
mView.hideWaitDialog();
}
}
}, error -> {
if (mView != null) {
mView.hideWaitDialog();
mView.showError(error.getMessage());
}
});
}
@Override
|
public void onBroadcastReceiverSelected(BroadcastReceiverInfo receiver) {
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/adapters/PackageListAdapter.java
|
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListener.java
// public interface RecyclerViewOnClickListener<T> {
// void onItemClick(T item);
// }
//
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListenerInternal.java
// public interface RecyclerViewOnClickListenerInternal {
// void onItemClick(int position);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
|
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.R;
import com.livingstoneapp.helpers.RecyclerViewOnClickListener;
import com.livingstoneapp.helpers.RecyclerViewOnClickListenerInternal;
import com.livingstoneapp.models.InstalledPackageHeader;
|
mData = items;
notifyDataSetChanged();
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return
new ViewHolder(
LayoutInflater.from(parent.getContext())
.inflate(R.layout.package_list_item_content, parent, false),
position -> {
if (mListener != null) {
mListener.onItemClick(mData.get(position));
}
});
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.tvAppName.setText(mData.get(position).getAppName());
holder.ivIcon.setImageDrawable(mData.get(position).getAppIcon());
}
@Override
public int getItemCount() {
return mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
|
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListener.java
// public interface RecyclerViewOnClickListener<T> {
// void onItemClick(T item);
// }
//
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListenerInternal.java
// public interface RecyclerViewOnClickListenerInternal {
// void onItemClick(int position);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
// private String mPackageName;
// private String mAppName;
// private Drawable mAppIcon;
//
// public InstalledPackageHeader() {
//
// }
//
// public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
// this.mPackageName = packageName;
// this.mAppName = appName;
// this.mAppIcon = appIcon;
// }
//
// public Drawable getAppIcon() {
// return mAppIcon;
// }
// public void setAppIcon(Drawable mAppIcon) {
// this.mAppIcon = mAppIcon;
// }
//
// public String getAppName() {
// return mAppName;
// }
// public void setAppName(String mAppName) {
// this.mAppName = mAppName;
// }
//
// public String getPackageName() {
// return mPackageName;
// }
// public void setPackageName(String mPackageName) {
// this.mPackageName = mPackageName;
// }
// }
// Path: app/src/main/java/com/livingstoneapp/adapters/PackageListAdapter.java
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.R;
import com.livingstoneapp.helpers.RecyclerViewOnClickListener;
import com.livingstoneapp.helpers.RecyclerViewOnClickListenerInternal;
import com.livingstoneapp.models.InstalledPackageHeader;
mData = items;
notifyDataSetChanged();
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return
new ViewHolder(
LayoutInflater.from(parent.getContext())
.inflate(R.layout.package_list_item_content, parent, false),
position -> {
if (mListener != null) {
mListener.onItemClick(mData.get(position));
}
});
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.tvAppName.setText(mData.get(position).getAppName());
holder.ivIcon.setImageDrawable(mData.get(position).getAppIcon());
}
@Override
public int getItemCount() {
return mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
|
private RecyclerViewOnClickListenerInternal mListener;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/interactors/BroadcastReceiverInteractorImpl.java
|
// Path: app/src/main/java/com/livingstoneapp/models/BroadcastReceiverInfo.java
// public class BroadcastReceiverInfo implements Parcelable, Comparable<BroadcastReceiverInfo> {
// private String mName;
//
// public BroadcastReceiverInfo(
// String mName) {
// this.mName = mName;
// }
//
//
// public String getName() {
// return mName;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// }
//
// protected BroadcastReceiverInfo(Parcel in) {
// this.mName = in.readString();
// }
//
// public static final Creator<BroadcastReceiverInfo> CREATOR = new Creator<BroadcastReceiverInfo>() {
// public BroadcastReceiverInfo createFromParcel(Parcel source) {
// return new BroadcastReceiverInfo(source);
// }
//
// public BroadcastReceiverInfo[] newArray(int size) {
// return new BroadcastReceiverInfo[size];
// }
// };
//
// @Override
// public int compareTo(BroadcastReceiverInfo another) {
// return this.getName().compareToIgnoreCase(another.getName());
// }
// }
|
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.BroadcastReceiverInfo;
|
package com.livingstoneapp.interactors;
/**
* Created by renier on 2/17/2016.
*/
public class BroadcastReceiverInteractorImpl implements IBroadcastReceiverInteractor {
private Context mContext;
public BroadcastReceiverInteractorImpl(Context context) {
mContext = context;
}
@Override
|
// Path: app/src/main/java/com/livingstoneapp/models/BroadcastReceiverInfo.java
// public class BroadcastReceiverInfo implements Parcelable, Comparable<BroadcastReceiverInfo> {
// private String mName;
//
// public BroadcastReceiverInfo(
// String mName) {
// this.mName = mName;
// }
//
//
// public String getName() {
// return mName;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// }
//
// protected BroadcastReceiverInfo(Parcel in) {
// this.mName = in.readString();
// }
//
// public static final Creator<BroadcastReceiverInfo> CREATOR = new Creator<BroadcastReceiverInfo>() {
// public BroadcastReceiverInfo createFromParcel(Parcel source) {
// return new BroadcastReceiverInfo(source);
// }
//
// public BroadcastReceiverInfo[] newArray(int size) {
// return new BroadcastReceiverInfo[size];
// }
// };
//
// @Override
// public int compareTo(BroadcastReceiverInfo another) {
// return this.getName().compareToIgnoreCase(another.getName());
// }
// }
// Path: app/src/main/java/com/livingstoneapp/interactors/BroadcastReceiverInteractorImpl.java
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.BroadcastReceiverInfo;
package com.livingstoneapp.interactors;
/**
* Created by renier on 2/17/2016.
*/
public class BroadcastReceiverInteractorImpl implements IBroadcastReceiverInteractor {
private Context mContext;
public BroadcastReceiverInteractorImpl(Context context) {
mContext = context;
}
@Override
|
public Observable<ArrayList<BroadcastReceiverInfo>> getBroadcastReceivers(String packageName) {
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/adapters/URIPermissionPatternsAdapter.java
|
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListener.java
// public interface RecyclerViewOnClickListener<T> {
// void onItemClick(T item);
// }
//
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListenerInternal.java
// public interface RecyclerViewOnClickListenerInternal {
// void onItemClick(int position);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/URIPermissionPattern.java
// public class URIPermissionPattern implements Parcelable {
// private String mPath;
// private String mType;
//
// public URIPermissionPattern(String mPath, String mType) {
// this.mPath = mPath;
// this.mType = mType;
// }
//
// public String getPath() {
// return mPath;
// }
//
// public String getType() {
// return mType;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mPath);
// dest.writeString(this.mType);
// }
//
// protected URIPermissionPattern(Parcel in) {
// this.mPath = in.readString();
// this.mType = in.readString();
// }
//
// public static final Parcelable.Creator<URIPermissionPattern> CREATOR = new Parcelable.Creator<URIPermissionPattern>() {
// public URIPermissionPattern createFromParcel(Parcel source) {
// return new URIPermissionPattern(source);
// }
//
// public URIPermissionPattern[] newArray(int size) {
// return new URIPermissionPattern[size];
// }
// };
// }
|
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.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.R;
import com.livingstoneapp.helpers.RecyclerViewOnClickListener;
import com.livingstoneapp.helpers.RecyclerViewOnClickListenerInternal;
import com.livingstoneapp.models.URIPermissionPattern;
|
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return
new ViewHolder(
LayoutInflater.from(parent.getContext())
.inflate(R.layout.content_provider_uri_permission_pattern_item_adapter_layout, parent, false),
position -> {
if (mListener != null) {
mListener.onItemClick(mData.get(position));
}
});
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
URIPermissionPattern upp = mData.get(position);
holder.tvPath.setText(upp.getPath());
holder.tvType.setText(upp.getType());
}
@Override
public int getItemCount() {
return mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
|
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListener.java
// public interface RecyclerViewOnClickListener<T> {
// void onItemClick(T item);
// }
//
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListenerInternal.java
// public interface RecyclerViewOnClickListenerInternal {
// void onItemClick(int position);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/URIPermissionPattern.java
// public class URIPermissionPattern implements Parcelable {
// private String mPath;
// private String mType;
//
// public URIPermissionPattern(String mPath, String mType) {
// this.mPath = mPath;
// this.mType = mType;
// }
//
// public String getPath() {
// return mPath;
// }
//
// public String getType() {
// return mType;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mPath);
// dest.writeString(this.mType);
// }
//
// protected URIPermissionPattern(Parcel in) {
// this.mPath = in.readString();
// this.mType = in.readString();
// }
//
// public static final Parcelable.Creator<URIPermissionPattern> CREATOR = new Parcelable.Creator<URIPermissionPattern>() {
// public URIPermissionPattern createFromParcel(Parcel source) {
// return new URIPermissionPattern(source);
// }
//
// public URIPermissionPattern[] newArray(int size) {
// return new URIPermissionPattern[size];
// }
// };
// }
// Path: app/src/main/java/com/livingstoneapp/adapters/URIPermissionPatternsAdapter.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.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.R;
import com.livingstoneapp.helpers.RecyclerViewOnClickListener;
import com.livingstoneapp.helpers.RecyclerViewOnClickListenerInternal;
import com.livingstoneapp.models.URIPermissionPattern;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return
new ViewHolder(
LayoutInflater.from(parent.getContext())
.inflate(R.layout.content_provider_uri_permission_pattern_item_adapter_layout, parent, false),
position -> {
if (mListener != null) {
mListener.onItemClick(mData.get(position));
}
});
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
URIPermissionPattern upp = mData.get(position);
holder.tvPath.setText(upp.getPath());
holder.tvType.setText(upp.getType());
}
@Override
public int getItemCount() {
return mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
|
private RecyclerViewOnClickListenerInternal mListener;
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/interactors/IPermissionsInteractor.java
|
// Path: app/src/main/java/com/livingstoneapp/models/DeclaredPermission.java
// public class DeclaredPermission {
//
// private String mName;
// private String mLabel;
// private ArrayList<String> mProtectionLevel;
// private ArrayList<String> mFlags;
//
// public DeclaredPermission(String mName, String mLabel, ArrayList<String> mProtectionLevel, ArrayList<String> mFlags) {
// this.mLabel = mLabel;
// this.mName = mName;
// this.mProtectionLevel = mProtectionLevel;
// this.mFlags = mFlags;
// }
//
// public String getLabel() {
// return mLabel;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<String> getProtectionLevel() {
// return mProtectionLevel;
// }
//
// public ArrayList<String> getFlags() { return mFlags; }
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/RequestedPermission.java
// public class RequestedPermission {
// private String mName;
// private boolean mGranted;
//
// public RequestedPermission(String mName, boolean mGranted) {
// this.mGranted = mGranted;
// this.mName = mName;
// }
//
// public boolean isGranted() {
// return mGranted;
// }
//
// public String getName() {
// return mName;
// }
// }
|
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.DeclaredPermission;
import com.livingstoneapp.models.RequestedPermission;
|
package com.livingstoneapp.interactors;
/**
* Created by renier on 2/19/2016.
*/
public interface IPermissionsInteractor {
Observable<ArrayList<DeclaredPermission>> getDeclaredPermissions(String packageName);
|
// Path: app/src/main/java/com/livingstoneapp/models/DeclaredPermission.java
// public class DeclaredPermission {
//
// private String mName;
// private String mLabel;
// private ArrayList<String> mProtectionLevel;
// private ArrayList<String> mFlags;
//
// public DeclaredPermission(String mName, String mLabel, ArrayList<String> mProtectionLevel, ArrayList<String> mFlags) {
// this.mLabel = mLabel;
// this.mName = mName;
// this.mProtectionLevel = mProtectionLevel;
// this.mFlags = mFlags;
// }
//
// public String getLabel() {
// return mLabel;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<String> getProtectionLevel() {
// return mProtectionLevel;
// }
//
// public ArrayList<String> getFlags() { return mFlags; }
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/RequestedPermission.java
// public class RequestedPermission {
// private String mName;
// private boolean mGranted;
//
// public RequestedPermission(String mName, boolean mGranted) {
// this.mGranted = mGranted;
// this.mName = mName;
// }
//
// public boolean isGranted() {
// return mGranted;
// }
//
// public String getName() {
// return mName;
// }
// }
// Path: app/src/main/java/com/livingstoneapp/interactors/IPermissionsInteractor.java
import java.util.ArrayList;
import rx.Observable;
import com.livingstoneapp.models.DeclaredPermission;
import com.livingstoneapp.models.RequestedPermission;
package com.livingstoneapp.interactors;
/**
* Created by renier on 2/19/2016.
*/
public interface IPermissionsInteractor {
Observable<ArrayList<DeclaredPermission>> getDeclaredPermissions(String packageName);
|
Observable<ArrayList<RequestedPermission>> getRequestedPermissions(String packageName);
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/views/IContentProvidersFragmentView.java
|
// Path: app/src/main/java/com/livingstoneapp/models/ContentProviderInfo.java
// public class ContentProviderInfo implements Parcelable {
// private String mName;
// private boolean mEnabled;
// private boolean mExported;
// private String mAuthority;
// private String mReadPermission;
// private String mWritePermission;
// private String mProcessName;
// private boolean mMultiProcess;
// private boolean mSingleUser;
// private int mInitOrder;
// private boolean mIsSyncable;
// private boolean mGrantURIPermissions;
// private ArrayList<PathPermission> mPathPermissions;
// private ArrayList<URIPermissionPattern> mURIPermissionPatterns;
//
// public ContentProviderInfo(String name) {
// this.mName = name;
// }
//
// public ContentProviderInfo(
// String mName,
// boolean mEnabled,
// boolean mExported,
// String mAuthority,
// String mReadPermission,
// String mWritePermission,
// String mProcessName,
// boolean mMultiProcess,
// boolean mSingleUser,
// int mInitOrder,
// boolean mIsSyncable,
// boolean mGrantURIPermissions,
// ArrayList<PathPermission> mPathPermissions,
// ArrayList<URIPermissionPattern> mURIPermissionPatterns) {
// this.mAuthority = mAuthority;
// this.mEnabled = mEnabled;
// this.mExported = mExported;
// this.mGrantURIPermissions = mGrantURIPermissions;
// this.mInitOrder = mInitOrder;
// this.mIsSyncable = mIsSyncable;
// this.mMultiProcess = mMultiProcess;
// this.mName = mName;
// this.mPathPermissions = mPathPermissions;
// this.mProcessName = mProcessName;
// this.mReadPermission = mReadPermission;
// this.mSingleUser = mSingleUser;
// this.mURIPermissionPatterns = mURIPermissionPatterns;
// this.mWritePermission = mWritePermission;
// }
//
// public String getAuthority() {
// return mAuthority;
// }
//
// public boolean isEnabled() {
// return mEnabled;
// }
//
// public boolean isExported() {
// return mExported;
// }
//
// public boolean isGrantURIPermissions() {
// return mGrantURIPermissions;
// }
//
// public int getInitOrder() {
// return mInitOrder;
// }
//
// public boolean isIsSyncable() {
// return mIsSyncable;
// }
//
// public boolean isMultiProcess() {
// return mMultiProcess;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<PathPermission> getPathPermissions() {
// return mPathPermissions;
// }
//
// public String getProcessName() {
// return mProcessName;
// }
//
// public String getReadPermission() {
// return mReadPermission;
// }
//
// public boolean isSingleUser() {
// return mSingleUser;
// }
//
// public ArrayList<URIPermissionPattern> getURIPermissionPatterns() {
// return mURIPermissionPatterns;
// }
//
// public String getWritePermission() {
// return mWritePermission;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// dest.writeByte(mEnabled ? (byte) 1 : (byte) 0);
// dest.writeByte(mExported ? (byte) 1 : (byte) 0);
// dest.writeString(this.mAuthority);
// dest.writeString(this.mReadPermission);
// dest.writeString(this.mWritePermission);
// dest.writeString(this.mProcessName);
// dest.writeByte(mMultiProcess ? (byte) 1 : (byte) 0);
// dest.writeByte(mSingleUser ? (byte) 1 : (byte) 0);
// dest.writeInt(this.mInitOrder);
// dest.writeByte(mIsSyncable ? (byte) 1 : (byte) 0);
// dest.writeByte(mGrantURIPermissions ? (byte) 1 : (byte) 0);
// dest.writeTypedList(mPathPermissions);
// dest.writeTypedList(mURIPermissionPatterns);
// }
//
// protected ContentProviderInfo(Parcel in) {
// this.mName = in.readString();
// this.mEnabled = in.readByte() != 0;
// this.mExported = in.readByte() != 0;
// this.mAuthority = in.readString();
// this.mReadPermission = in.readString();
// this.mWritePermission = in.readString();
// this.mProcessName = in.readString();
// this.mMultiProcess = in.readByte() != 0;
// this.mSingleUser = in.readByte() != 0;
// this.mInitOrder = in.readInt();
// this.mIsSyncable = in.readByte() != 0;
// this.mGrantURIPermissions = in.readByte() != 0;
// this.mPathPermissions = in.createTypedArrayList(PathPermission.CREATOR);
// this.mURIPermissionPatterns = in.createTypedArrayList(URIPermissionPattern.CREATOR);
// }
//
// public static final Parcelable.Creator<ContentProviderInfo> CREATOR = new Parcelable.Creator<ContentProviderInfo>() {
// public ContentProviderInfo createFromParcel(Parcel source) {
// return new ContentProviderInfo(source);
// }
//
// public ContentProviderInfo[] newArray(int size) {
// return new ContentProviderInfo[size];
// }
// };
// }
|
import java.util.ArrayList;
import com.livingstoneapp.models.ContentProviderInfo;
|
package com.livingstoneapp.views;
/**
* Created by Renier on 2016/02/16.
*/
public interface IContentProvidersFragmentView {
void showError(String message);
|
// Path: app/src/main/java/com/livingstoneapp/models/ContentProviderInfo.java
// public class ContentProviderInfo implements Parcelable {
// private String mName;
// private boolean mEnabled;
// private boolean mExported;
// private String mAuthority;
// private String mReadPermission;
// private String mWritePermission;
// private String mProcessName;
// private boolean mMultiProcess;
// private boolean mSingleUser;
// private int mInitOrder;
// private boolean mIsSyncable;
// private boolean mGrantURIPermissions;
// private ArrayList<PathPermission> mPathPermissions;
// private ArrayList<URIPermissionPattern> mURIPermissionPatterns;
//
// public ContentProviderInfo(String name) {
// this.mName = name;
// }
//
// public ContentProviderInfo(
// String mName,
// boolean mEnabled,
// boolean mExported,
// String mAuthority,
// String mReadPermission,
// String mWritePermission,
// String mProcessName,
// boolean mMultiProcess,
// boolean mSingleUser,
// int mInitOrder,
// boolean mIsSyncable,
// boolean mGrantURIPermissions,
// ArrayList<PathPermission> mPathPermissions,
// ArrayList<URIPermissionPattern> mURIPermissionPatterns) {
// this.mAuthority = mAuthority;
// this.mEnabled = mEnabled;
// this.mExported = mExported;
// this.mGrantURIPermissions = mGrantURIPermissions;
// this.mInitOrder = mInitOrder;
// this.mIsSyncable = mIsSyncable;
// this.mMultiProcess = mMultiProcess;
// this.mName = mName;
// this.mPathPermissions = mPathPermissions;
// this.mProcessName = mProcessName;
// this.mReadPermission = mReadPermission;
// this.mSingleUser = mSingleUser;
// this.mURIPermissionPatterns = mURIPermissionPatterns;
// this.mWritePermission = mWritePermission;
// }
//
// public String getAuthority() {
// return mAuthority;
// }
//
// public boolean isEnabled() {
// return mEnabled;
// }
//
// public boolean isExported() {
// return mExported;
// }
//
// public boolean isGrantURIPermissions() {
// return mGrantURIPermissions;
// }
//
// public int getInitOrder() {
// return mInitOrder;
// }
//
// public boolean isIsSyncable() {
// return mIsSyncable;
// }
//
// public boolean isMultiProcess() {
// return mMultiProcess;
// }
//
// public String getName() {
// return mName;
// }
//
// public ArrayList<PathPermission> getPathPermissions() {
// return mPathPermissions;
// }
//
// public String getProcessName() {
// return mProcessName;
// }
//
// public String getReadPermission() {
// return mReadPermission;
// }
//
// public boolean isSingleUser() {
// return mSingleUser;
// }
//
// public ArrayList<URIPermissionPattern> getURIPermissionPatterns() {
// return mURIPermissionPatterns;
// }
//
// public String getWritePermission() {
// return mWritePermission;
// }
//
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.mName);
// dest.writeByte(mEnabled ? (byte) 1 : (byte) 0);
// dest.writeByte(mExported ? (byte) 1 : (byte) 0);
// dest.writeString(this.mAuthority);
// dest.writeString(this.mReadPermission);
// dest.writeString(this.mWritePermission);
// dest.writeString(this.mProcessName);
// dest.writeByte(mMultiProcess ? (byte) 1 : (byte) 0);
// dest.writeByte(mSingleUser ? (byte) 1 : (byte) 0);
// dest.writeInt(this.mInitOrder);
// dest.writeByte(mIsSyncable ? (byte) 1 : (byte) 0);
// dest.writeByte(mGrantURIPermissions ? (byte) 1 : (byte) 0);
// dest.writeTypedList(mPathPermissions);
// dest.writeTypedList(mURIPermissionPatterns);
// }
//
// protected ContentProviderInfo(Parcel in) {
// this.mName = in.readString();
// this.mEnabled = in.readByte() != 0;
// this.mExported = in.readByte() != 0;
// this.mAuthority = in.readString();
// this.mReadPermission = in.readString();
// this.mWritePermission = in.readString();
// this.mProcessName = in.readString();
// this.mMultiProcess = in.readByte() != 0;
// this.mSingleUser = in.readByte() != 0;
// this.mInitOrder = in.readInt();
// this.mIsSyncable = in.readByte() != 0;
// this.mGrantURIPermissions = in.readByte() != 0;
// this.mPathPermissions = in.createTypedArrayList(PathPermission.CREATOR);
// this.mURIPermissionPatterns = in.createTypedArrayList(URIPermissionPattern.CREATOR);
// }
//
// public static final Parcelable.Creator<ContentProviderInfo> CREATOR = new Parcelable.Creator<ContentProviderInfo>() {
// public ContentProviderInfo createFromParcel(Parcel source) {
// return new ContentProviderInfo(source);
// }
//
// public ContentProviderInfo[] newArray(int size) {
// return new ContentProviderInfo[size];
// }
// };
// }
// Path: app/src/main/java/com/livingstoneapp/views/IContentProvidersFragmentView.java
import java.util.ArrayList;
import com.livingstoneapp.models.ContentProviderInfo;
package com.livingstoneapp.views;
/**
* Created by Renier on 2016/02/16.
*/
public interface IContentProvidersFragmentView {
void showError(String message);
|
void setModel(ArrayList<ContentProviderInfo> contentProviders);
|
oosthuizenr/Livingstone
|
app/src/main/java/com/livingstoneapp/adapters/RequestedPermissionsAdapter.java
|
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListener.java
// public interface RecyclerViewOnClickListener<T> {
// void onItemClick(T item);
// }
//
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListenerInternal.java
// public interface RecyclerViewOnClickListenerInternal {
// void onItemClick(int position);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/RequestedPermission.java
// public class RequestedPermission {
// private String mName;
// private boolean mGranted;
//
// public RequestedPermission(String mName, boolean mGranted) {
// this.mGranted = mGranted;
// this.mName = mName;
// }
//
// public boolean isGranted() {
// return mGranted;
// }
//
// public String getName() {
// return mName;
// }
// }
|
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.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.R;
import com.livingstoneapp.helpers.RecyclerViewOnClickListener;
import com.livingstoneapp.helpers.RecyclerViewOnClickListenerInternal;
import com.livingstoneapp.models.RequestedPermission;
|
new ViewHolder(
LayoutInflater.from(parent.getContext())
.inflate(R.layout.requested_permissions_adapter_layout, parent, false),
position -> {
if (mListener != null) {
mListener.onItemClick(mData.get(position));
}
});
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.tvName.setText(mData.get(position).getName());
if (mData.get(position).isGranted()) {
holder.tvGrantedHeader.setVisibility(View.VISIBLE);
holder.tvDeniedHeader.setVisibility(View.GONE);
} else {
holder.tvGrantedHeader.setVisibility(View.GONE);
holder.tvDeniedHeader.setVisibility(View.VISIBLE);
}
}
@Override
public int getItemCount() {
return mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
|
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListener.java
// public interface RecyclerViewOnClickListener<T> {
// void onItemClick(T item);
// }
//
// Path: app/src/main/java/com/livingstoneapp/helpers/RecyclerViewOnClickListenerInternal.java
// public interface RecyclerViewOnClickListenerInternal {
// void onItemClick(int position);
// }
//
// Path: app/src/main/java/com/livingstoneapp/models/RequestedPermission.java
// public class RequestedPermission {
// private String mName;
// private boolean mGranted;
//
// public RequestedPermission(String mName, boolean mGranted) {
// this.mGranted = mGranted;
// this.mName = mName;
// }
//
// public boolean isGranted() {
// return mGranted;
// }
//
// public String getName() {
// return mName;
// }
// }
// Path: app/src/main/java/com/livingstoneapp/adapters/RequestedPermissionsAdapter.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.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.livingstoneapp.R;
import com.livingstoneapp.helpers.RecyclerViewOnClickListener;
import com.livingstoneapp.helpers.RecyclerViewOnClickListenerInternal;
import com.livingstoneapp.models.RequestedPermission;
new ViewHolder(
LayoutInflater.from(parent.getContext())
.inflate(R.layout.requested_permissions_adapter_layout, parent, false),
position -> {
if (mListener != null) {
mListener.onItemClick(mData.get(position));
}
});
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.tvName.setText(mData.get(position).getName());
if (mData.get(position).isGranted()) {
holder.tvGrantedHeader.setVisibility(View.VISIBLE);
holder.tvDeniedHeader.setVisibility(View.GONE);
} else {
holder.tvGrantedHeader.setVisibility(View.GONE);
holder.tvDeniedHeader.setVisibility(View.VISIBLE);
}
}
@Override
public int getItemCount() {
return mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
|
private RecyclerViewOnClickListenerInternal mListener;
|
braintree/braintree-android-drop-in
|
Demo/src/main/java/com/braintreepayments/demo/CreateTransactionActivity.java
|
// Path: Demo/src/main/java/com/braintreepayments/demo/models/Transaction.java
// public class Transaction {
//
// @SerializedName("message")
// private String message;
//
// public String getMessage() {
// return message;
// }
// }
|
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.braintreepayments.api.CardNonce;
import com.braintreepayments.api.PaymentMethodNonce;
import com.braintreepayments.demo.models.Transaction;
import androidx.appcompat.app.AppCompatActivity;
import retrofit.Callback;
import retrofit.RetrofitError;
import retrofit.client.Response;
|
package com.braintreepayments.demo;
public class CreateTransactionActivity extends AppCompatActivity {
public static final String EXTRA_PAYMENT_METHOD_NONCE = "nonce";
private ProgressBar loadingSpinner;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.create_transaction_activity);
loadingSpinner = findViewById(R.id.loading_spinner);
setTitle(R.string.processing_transaction);
sendNonceToServer((PaymentMethodNonce) getIntent().getParcelableExtra(EXTRA_PAYMENT_METHOD_NONCE));
}
private void sendNonceToServer(PaymentMethodNonce nonce) {
|
// Path: Demo/src/main/java/com/braintreepayments/demo/models/Transaction.java
// public class Transaction {
//
// @SerializedName("message")
// private String message;
//
// public String getMessage() {
// return message;
// }
// }
// Path: Demo/src/main/java/com/braintreepayments/demo/CreateTransactionActivity.java
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.braintreepayments.api.CardNonce;
import com.braintreepayments.api.PaymentMethodNonce;
import com.braintreepayments.demo.models.Transaction;
import androidx.appcompat.app.AppCompatActivity;
import retrofit.Callback;
import retrofit.RetrofitError;
import retrofit.client.Response;
package com.braintreepayments.demo;
public class CreateTransactionActivity extends AppCompatActivity {
public static final String EXTRA_PAYMENT_METHOD_NONCE = "nonce";
private ProgressBar loadingSpinner;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.create_transaction_activity);
loadingSpinner = findViewById(R.id.loading_spinner);
setTitle(R.string.processing_transaction);
sendNonceToServer((PaymentMethodNonce) getIntent().getParcelableExtra(EXTRA_PAYMENT_METHOD_NONCE));
}
private void sendNonceToServer(PaymentMethodNonce nonce) {
|
Callback<Transaction> callback = new Callback<Transaction>() {
|
braintree/braintree-android-drop-in
|
Demo/src/androidTest/java/com/braintreepayments/demo/test/OptionalVaultingDropInTest.java
|
// Path: Demo/src/androidTest/java/com/braintreepayments/demo/test/utilities/TestHelper.java
// public class TestHelper {
//
// @CallSuper
// public void setup() {
// clearPreference("BraintreeApi");
// clearPreference("PayPalOTC");
//
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .clear()
// .putBoolean("paypal_use_hardcoded_configuration", true)
// .commit();
// }
//
// public void launchApp() {
// onDevice().onHomeScreen().launchApp("com.braintreepayments.demo");
// ensureEnvironmentIs("Sandbox");
// }
//
// public DeviceAutomator getNonceDetails() {
// return onDevice(withResourceId("com.braintreepayments.demo:id/nonce_details"));
// }
//
// public void setCustomerId(String customerId) {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putString("customer", customerId)
// .commit();
// }
//
// /**
// * Sets the customer ID to a value that should be randomized.
// * There should not be any saved payment methods for this customer.
// */
// public void setUniqueCustomerId() {
// setCustomerId(""+System.currentTimeMillis());
// }
//
// public void setMerchantAccountId(String merchantAccountId) {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putString("merchant_account", merchantAccountId)
// .commit();
// }
//
// public void useTokenizationKey() {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putBoolean("tokenization_key", true)
// .commit();
// }
//
// public void enableThreeDSecure() {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putBoolean("enable_three_d_secure", true)
// .commit();
// }
//
// public void enableVaultManager() {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putBoolean("enable_vault_manager", true)
// .commit();
// }
//
// public void setCardholderNameStatus(int cardholderNameStatus) {
// String status;
//
// switch(cardholderNameStatus) {
// case CardForm.FIELD_REQUIRED:
// status = "Required";
// break;
// case CardForm.FIELD_OPTIONAL:
// status = "Optional";
// break;
// default:
// case CardForm.FIELD_DISABLED:
// status = "Disabled";
// break;
// }
//
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putString("cardholder_name_status", status)
// .commit();
// }
//
// public void setSaveCardCheckBox(boolean visible, boolean defaultValue) {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putBoolean("save_card_checkbox_visible", visible)
// .putBoolean("save_card_checkbox_default_value", defaultValue)
// .commit();
// }
//
// private void clearPreference(String preference) {
// ApplicationProvider.getApplicationContext().getSharedPreferences(preference, Context.MODE_PRIVATE)
// .edit()
// .clear()
// .commit();
// }
//
// private static void ensureEnvironmentIs(String environment) {
// try {
// onDevice(withText(environment)).check(text(equalTo(environment)));
// } catch (RuntimeException e) {
// onDevice(withClass(Spinner.class)).perform(click());
// onDevice(withText(environment)).perform(click());
// onDevice(withText(environment)).check(text(equalTo(environment)));
// }
// }
//
// protected void performCardDetailsEntry() {
// onDevice(withText("Expiration Date")).perform(setText("12" + ExpirationDate.VALID_EXPIRATION_YEAR));
// onDevice(withText("CVV")).perform(setText("123"));
// onDevice(withText("Postal Code")).perform(setText("12345"));
// }
//
// protected void tokenizeCard(String cardNumber) {
// onDevice(withText("Credit or Debit Card")).waitForExists().perform(click());
// onDevice(withText("Card Number")).waitForExists().perform(setText(cardNumber));
// onDevice(withText("Next")).perform(click());
// performCardDetailsEntry();
// onDevice(withTextContaining("Add Card")).perform(click());
// }
// }
//
// Path: Demo/src/androidTest/java/com/braintreepayments/demo/test/utilities/CardNumber.java
// public static final String VISA = "4111111111111111";
|
import com.braintreepayments.demo.test.utilities.TestHelper;
import org.junit.Before;
import org.junit.Test;
import static com.braintreepayments.demo.test.utilities.CardNumber.VISA;
import static com.braintreepayments.AutomatorAction.click;
import static com.braintreepayments.AutomatorAction.setText;
import static com.braintreepayments.DeviceAutomator.onDevice;
import static com.braintreepayments.UiObjectMatcher.withText;
import static com.braintreepayments.UiObjectMatcher.withTextContaining;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertFalse;
|
package com.braintreepayments.demo.test;
public class OptionalVaultingDropInTest extends TestHelper {
@Before
public void setup() {
super.setup();
}
@Test(timeout = 60000)
public void saveCardCheckBox_whenVisibleAndChecked_vaults() {
setSaveCardCheckBox(true, true);
setUniqueCustomerId();
launchApp();
onDevice(withText("Add Payment Method")).waitForExists().waitForEnabled().perform(click());
|
// Path: Demo/src/androidTest/java/com/braintreepayments/demo/test/utilities/TestHelper.java
// public class TestHelper {
//
// @CallSuper
// public void setup() {
// clearPreference("BraintreeApi");
// clearPreference("PayPalOTC");
//
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .clear()
// .putBoolean("paypal_use_hardcoded_configuration", true)
// .commit();
// }
//
// public void launchApp() {
// onDevice().onHomeScreen().launchApp("com.braintreepayments.demo");
// ensureEnvironmentIs("Sandbox");
// }
//
// public DeviceAutomator getNonceDetails() {
// return onDevice(withResourceId("com.braintreepayments.demo:id/nonce_details"));
// }
//
// public void setCustomerId(String customerId) {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putString("customer", customerId)
// .commit();
// }
//
// /**
// * Sets the customer ID to a value that should be randomized.
// * There should not be any saved payment methods for this customer.
// */
// public void setUniqueCustomerId() {
// setCustomerId(""+System.currentTimeMillis());
// }
//
// public void setMerchantAccountId(String merchantAccountId) {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putString("merchant_account", merchantAccountId)
// .commit();
// }
//
// public void useTokenizationKey() {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putBoolean("tokenization_key", true)
// .commit();
// }
//
// public void enableThreeDSecure() {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putBoolean("enable_three_d_secure", true)
// .commit();
// }
//
// public void enableVaultManager() {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putBoolean("enable_vault_manager", true)
// .commit();
// }
//
// public void setCardholderNameStatus(int cardholderNameStatus) {
// String status;
//
// switch(cardholderNameStatus) {
// case CardForm.FIELD_REQUIRED:
// status = "Required";
// break;
// case CardForm.FIELD_OPTIONAL:
// status = "Optional";
// break;
// default:
// case CardForm.FIELD_DISABLED:
// status = "Disabled";
// break;
// }
//
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putString("cardholder_name_status", status)
// .commit();
// }
//
// public void setSaveCardCheckBox(boolean visible, boolean defaultValue) {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putBoolean("save_card_checkbox_visible", visible)
// .putBoolean("save_card_checkbox_default_value", defaultValue)
// .commit();
// }
//
// private void clearPreference(String preference) {
// ApplicationProvider.getApplicationContext().getSharedPreferences(preference, Context.MODE_PRIVATE)
// .edit()
// .clear()
// .commit();
// }
//
// private static void ensureEnvironmentIs(String environment) {
// try {
// onDevice(withText(environment)).check(text(equalTo(environment)));
// } catch (RuntimeException e) {
// onDevice(withClass(Spinner.class)).perform(click());
// onDevice(withText(environment)).perform(click());
// onDevice(withText(environment)).check(text(equalTo(environment)));
// }
// }
//
// protected void performCardDetailsEntry() {
// onDevice(withText("Expiration Date")).perform(setText("12" + ExpirationDate.VALID_EXPIRATION_YEAR));
// onDevice(withText("CVV")).perform(setText("123"));
// onDevice(withText("Postal Code")).perform(setText("12345"));
// }
//
// protected void tokenizeCard(String cardNumber) {
// onDevice(withText("Credit or Debit Card")).waitForExists().perform(click());
// onDevice(withText("Card Number")).waitForExists().perform(setText(cardNumber));
// onDevice(withText("Next")).perform(click());
// performCardDetailsEntry();
// onDevice(withTextContaining("Add Card")).perform(click());
// }
// }
//
// Path: Demo/src/androidTest/java/com/braintreepayments/demo/test/utilities/CardNumber.java
// public static final String VISA = "4111111111111111";
// Path: Demo/src/androidTest/java/com/braintreepayments/demo/test/OptionalVaultingDropInTest.java
import com.braintreepayments.demo.test.utilities.TestHelper;
import org.junit.Before;
import org.junit.Test;
import static com.braintreepayments.demo.test.utilities.CardNumber.VISA;
import static com.braintreepayments.AutomatorAction.click;
import static com.braintreepayments.AutomatorAction.setText;
import static com.braintreepayments.DeviceAutomator.onDevice;
import static com.braintreepayments.UiObjectMatcher.withText;
import static com.braintreepayments.UiObjectMatcher.withTextContaining;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertFalse;
package com.braintreepayments.demo.test;
public class OptionalVaultingDropInTest extends TestHelper {
@Before
public void setup() {
super.setup();
}
@Test(timeout = 60000)
public void saveCardCheckBox_whenVisibleAndChecked_vaults() {
setSaveCardCheckBox(true, true);
setUniqueCustomerId();
launchApp();
onDevice(withText("Add Payment Method")).waitForExists().waitForEnabled().perform(click());
|
tokenizeCard(VISA);
|
braintree/braintree-android-drop-in
|
Drop-In/src/androidTest/java/com/braintreepayments/api/PaymentMethodClientTest.java
|
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/Assertions.java
// public static void assertIsANonce(String maybeANonce) {
// assertNotNull("Nonce was null", maybeANonce);
// assertTrue("Does not match the expected form of a nonce. Expected \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\" got \"" + maybeANonce + "\"",
// maybeANonce.matches("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"));
// }
//
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/CardNumber.java
// public static final String VISA = "4111111111111111";
//
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/ExpirationDate.java
// public static String validExpirationYear() {
// return String.valueOf(Calendar.getInstance().get(Calendar.YEAR) + 1).substring(2);
// }
|
import static com.braintreepayments.api.Assertions.assertIsANonce;
import static com.braintreepayments.api.CardNumber.VISA;
import static com.braintreepayments.api.ExpirationDate.validExpirationYear;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import android.content.Context;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.concurrent.CountDownLatch;
|
package com.braintreepayments.api;
@RunWith(AndroidJUnit4ClassRunner.class)
public class PaymentMethodClientTest {
private Context context;
@Before
public void setUp() {
context = ApplicationProvider.getApplicationContext();
}
@Test(timeout = 10000)
public void getPaymentMethodNonces_andDeletePaymentMethod_returnsCardNonce() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final String clientToken = new TestClientTokenBuilder().withCustomerId().build();
final BraintreeClient braintreeClient = new BraintreeClient(context, clientToken);
CardClient cardClient = new CardClient(braintreeClient);
final PaymentMethodClient sut = new PaymentMethodClient(braintreeClient);
Card card = new Card();
|
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/Assertions.java
// public static void assertIsANonce(String maybeANonce) {
// assertNotNull("Nonce was null", maybeANonce);
// assertTrue("Does not match the expected form of a nonce. Expected \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\" got \"" + maybeANonce + "\"",
// maybeANonce.matches("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"));
// }
//
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/CardNumber.java
// public static final String VISA = "4111111111111111";
//
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/ExpirationDate.java
// public static String validExpirationYear() {
// return String.valueOf(Calendar.getInstance().get(Calendar.YEAR) + 1).substring(2);
// }
// Path: Drop-In/src/androidTest/java/com/braintreepayments/api/PaymentMethodClientTest.java
import static com.braintreepayments.api.Assertions.assertIsANonce;
import static com.braintreepayments.api.CardNumber.VISA;
import static com.braintreepayments.api.ExpirationDate.validExpirationYear;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import android.content.Context;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.concurrent.CountDownLatch;
package com.braintreepayments.api;
@RunWith(AndroidJUnit4ClassRunner.class)
public class PaymentMethodClientTest {
private Context context;
@Before
public void setUp() {
context = ApplicationProvider.getApplicationContext();
}
@Test(timeout = 10000)
public void getPaymentMethodNonces_andDeletePaymentMethod_returnsCardNonce() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final String clientToken = new TestClientTokenBuilder().withCustomerId().build();
final BraintreeClient braintreeClient = new BraintreeClient(context, clientToken);
CardClient cardClient = new CardClient(braintreeClient);
final PaymentMethodClient sut = new PaymentMethodClient(braintreeClient);
Card card = new Card();
|
card.setNumber(VISA);
|
braintree/braintree-android-drop-in
|
Drop-In/src/androidTest/java/com/braintreepayments/api/PaymentMethodClientTest.java
|
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/Assertions.java
// public static void assertIsANonce(String maybeANonce) {
// assertNotNull("Nonce was null", maybeANonce);
// assertTrue("Does not match the expected form of a nonce. Expected \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\" got \"" + maybeANonce + "\"",
// maybeANonce.matches("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"));
// }
//
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/CardNumber.java
// public static final String VISA = "4111111111111111";
//
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/ExpirationDate.java
// public static String validExpirationYear() {
// return String.valueOf(Calendar.getInstance().get(Calendar.YEAR) + 1).substring(2);
// }
|
import static com.braintreepayments.api.Assertions.assertIsANonce;
import static com.braintreepayments.api.CardNumber.VISA;
import static com.braintreepayments.api.ExpirationDate.validExpirationYear;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import android.content.Context;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.concurrent.CountDownLatch;
|
package com.braintreepayments.api;
@RunWith(AndroidJUnit4ClassRunner.class)
public class PaymentMethodClientTest {
private Context context;
@Before
public void setUp() {
context = ApplicationProvider.getApplicationContext();
}
@Test(timeout = 10000)
public void getPaymentMethodNonces_andDeletePaymentMethod_returnsCardNonce() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final String clientToken = new TestClientTokenBuilder().withCustomerId().build();
final BraintreeClient braintreeClient = new BraintreeClient(context, clientToken);
CardClient cardClient = new CardClient(braintreeClient);
final PaymentMethodClient sut = new PaymentMethodClient(braintreeClient);
Card card = new Card();
card.setNumber(VISA);
card.setExpirationMonth("12");
|
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/Assertions.java
// public static void assertIsANonce(String maybeANonce) {
// assertNotNull("Nonce was null", maybeANonce);
// assertTrue("Does not match the expected form of a nonce. Expected \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\" got \"" + maybeANonce + "\"",
// maybeANonce.matches("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"));
// }
//
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/CardNumber.java
// public static final String VISA = "4111111111111111";
//
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/ExpirationDate.java
// public static String validExpirationYear() {
// return String.valueOf(Calendar.getInstance().get(Calendar.YEAR) + 1).substring(2);
// }
// Path: Drop-In/src/androidTest/java/com/braintreepayments/api/PaymentMethodClientTest.java
import static com.braintreepayments.api.Assertions.assertIsANonce;
import static com.braintreepayments.api.CardNumber.VISA;
import static com.braintreepayments.api.ExpirationDate.validExpirationYear;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import android.content.Context;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.concurrent.CountDownLatch;
package com.braintreepayments.api;
@RunWith(AndroidJUnit4ClassRunner.class)
public class PaymentMethodClientTest {
private Context context;
@Before
public void setUp() {
context = ApplicationProvider.getApplicationContext();
}
@Test(timeout = 10000)
public void getPaymentMethodNonces_andDeletePaymentMethod_returnsCardNonce() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final String clientToken = new TestClientTokenBuilder().withCustomerId().build();
final BraintreeClient braintreeClient = new BraintreeClient(context, clientToken);
CardClient cardClient = new CardClient(braintreeClient);
final PaymentMethodClient sut = new PaymentMethodClient(braintreeClient);
Card card = new Card();
card.setNumber(VISA);
card.setExpirationMonth("12");
|
card.setExpirationYear(validExpirationYear());
|
braintree/braintree-android-drop-in
|
Drop-In/src/androidTest/java/com/braintreepayments/api/PaymentMethodClientTest.java
|
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/Assertions.java
// public static void assertIsANonce(String maybeANonce) {
// assertNotNull("Nonce was null", maybeANonce);
// assertTrue("Does not match the expected form of a nonce. Expected \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\" got \"" + maybeANonce + "\"",
// maybeANonce.matches("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"));
// }
//
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/CardNumber.java
// public static final String VISA = "4111111111111111";
//
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/ExpirationDate.java
// public static String validExpirationYear() {
// return String.valueOf(Calendar.getInstance().get(Calendar.YEAR) + 1).substring(2);
// }
|
import static com.braintreepayments.api.Assertions.assertIsANonce;
import static com.braintreepayments.api.CardNumber.VISA;
import static com.braintreepayments.api.ExpirationDate.validExpirationYear;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import android.content.Context;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.concurrent.CountDownLatch;
|
package com.braintreepayments.api;
@RunWith(AndroidJUnit4ClassRunner.class)
public class PaymentMethodClientTest {
private Context context;
@Before
public void setUp() {
context = ApplicationProvider.getApplicationContext();
}
@Test(timeout = 10000)
public void getPaymentMethodNonces_andDeletePaymentMethod_returnsCardNonce() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final String clientToken = new TestClientTokenBuilder().withCustomerId().build();
final BraintreeClient braintreeClient = new BraintreeClient(context, clientToken);
CardClient cardClient = new CardClient(braintreeClient);
final PaymentMethodClient sut = new PaymentMethodClient(braintreeClient);
Card card = new Card();
card.setNumber(VISA);
card.setExpirationMonth("12");
card.setExpirationYear(validExpirationYear());
card.setShouldValidate(true);
cardClient.tokenize(card, (cardNonce, tokenizeError) -> {
if (tokenizeError != null) {
fail(tokenizeError.getMessage());
}
sut.getPaymentMethodNonces((paymentMethodNonces, getPaymentMethodNoncesError) -> {
assertNull(getPaymentMethodNoncesError);
assertNotNull(paymentMethodNonces);
assertEquals(1, paymentMethodNonces.size());
PaymentMethodNonce paymentMethodNonce = paymentMethodNonces.get(0);
|
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/Assertions.java
// public static void assertIsANonce(String maybeANonce) {
// assertNotNull("Nonce was null", maybeANonce);
// assertTrue("Does not match the expected form of a nonce. Expected \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\" got \"" + maybeANonce + "\"",
// maybeANonce.matches("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"));
// }
//
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/CardNumber.java
// public static final String VISA = "4111111111111111";
//
// Path: Drop-In/src/sharedTest/java/com/braintreepayments/api/ExpirationDate.java
// public static String validExpirationYear() {
// return String.valueOf(Calendar.getInstance().get(Calendar.YEAR) + 1).substring(2);
// }
// Path: Drop-In/src/androidTest/java/com/braintreepayments/api/PaymentMethodClientTest.java
import static com.braintreepayments.api.Assertions.assertIsANonce;
import static com.braintreepayments.api.CardNumber.VISA;
import static com.braintreepayments.api.ExpirationDate.validExpirationYear;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import android.content.Context;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.concurrent.CountDownLatch;
package com.braintreepayments.api;
@RunWith(AndroidJUnit4ClassRunner.class)
public class PaymentMethodClientTest {
private Context context;
@Before
public void setUp() {
context = ApplicationProvider.getApplicationContext();
}
@Test(timeout = 10000)
public void getPaymentMethodNonces_andDeletePaymentMethod_returnsCardNonce() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final String clientToken = new TestClientTokenBuilder().withCustomerId().build();
final BraintreeClient braintreeClient = new BraintreeClient(context, clientToken);
CardClient cardClient = new CardClient(braintreeClient);
final PaymentMethodClient sut = new PaymentMethodClient(braintreeClient);
Card card = new Card();
card.setNumber(VISA);
card.setExpirationMonth("12");
card.setExpirationYear(validExpirationYear());
card.setShouldValidate(true);
cardClient.tokenize(card, (cardNonce, tokenizeError) -> {
if (tokenizeError != null) {
fail(tokenizeError.getMessage());
}
sut.getPaymentMethodNonces((paymentMethodNonces, getPaymentMethodNoncesError) -> {
assertNull(getPaymentMethodNoncesError);
assertNotNull(paymentMethodNonces);
assertEquals(1, paymentMethodNonces.size());
PaymentMethodNonce paymentMethodNonce = paymentMethodNonces.get(0);
|
assertIsANonce(paymentMethodNonce.getString());
|
braintree/braintree-android-drop-in
|
Demo/src/main/java/com/braintreepayments/demo/SettingsActivity.java
|
// Path: Demo/src/main/java/com/braintreepayments/demo/fragments/SettingsFragment.java
// public class SettingsFragment extends PreferenceFragment
// implements OnSharedPreferenceChangeListener {
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// addPreferencesFromResource(R.xml.settings);
//
// SharedPreferences preferences = getPreferenceManager().getSharedPreferences();
// onSharedPreferenceChanged(preferences, "paypal_payment_type");
// preferences.registerOnSharedPreferenceChangeListener(this);
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
// }
//
// @Override
// public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
// Preference preference = findPreference(key);
// if (preference instanceof ListPreference) {
// preference.setSummary(((ListPreference) preference).getEntry());
// } else if (preference instanceof SummaryEditTestPreference) {
// preference.setSummary(preference.getSummary());
// }
// }
// }
|
import android.os.Bundle;
import android.view.MenuItem;
import com.braintreepayments.demo.fragments.SettingsFragment;
import androidx.appcompat.app.AppCompatActivity;
|
package com.braintreepayments.demo;
public class SettingsActivity extends AppCompatActivity {
@SuppressWarnings("ConstantConditions")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getFragmentManager().beginTransaction()
|
// Path: Demo/src/main/java/com/braintreepayments/demo/fragments/SettingsFragment.java
// public class SettingsFragment extends PreferenceFragment
// implements OnSharedPreferenceChangeListener {
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// addPreferencesFromResource(R.xml.settings);
//
// SharedPreferences preferences = getPreferenceManager().getSharedPreferences();
// onSharedPreferenceChanged(preferences, "paypal_payment_type");
// preferences.registerOnSharedPreferenceChangeListener(this);
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
// }
//
// @Override
// public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
// Preference preference = findPreference(key);
// if (preference instanceof ListPreference) {
// preference.setSummary(((ListPreference) preference).getEntry());
// } else if (preference instanceof SummaryEditTestPreference) {
// preference.setSummary(preference.getSummary());
// }
// }
// }
// Path: Demo/src/main/java/com/braintreepayments/demo/SettingsActivity.java
import android.os.Bundle;
import android.view.MenuItem;
import com.braintreepayments.demo.fragments.SettingsFragment;
import androidx.appcompat.app.AppCompatActivity;
package com.braintreepayments.demo;
public class SettingsActivity extends AppCompatActivity {
@SuppressWarnings("ConstantConditions")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getFragmentManager().beginTransaction()
|
.replace(android.R.id.content, new SettingsFragment())
|
braintree/braintree-android-drop-in
|
Demo/src/main/java/com/braintreepayments/demo/fragments/SettingsFragment.java
|
// Path: Demo/src/main/java/com/braintreepayments/demo/views/SummaryEditTestPreference.java
// public class SummaryEditTestPreference extends EditTextPreference {
//
// private String summaryString;
//
// public SummaryEditTestPreference(Context context) {
// super(context);
// init();
// }
//
// public SummaryEditTestPreference(Context context, AttributeSet attrs) {
// super(context, attrs);
// init();
// }
//
// public SummaryEditTestPreference(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// init();
// }
//
// @TargetApi(VERSION_CODES.LOLLIPOP)
// public SummaryEditTestPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
// super(context, attrs, defStyleAttr, defStyleRes);
// init();
// }
//
// private void init() {
// summaryString = super.getSummary().toString();
// }
//
// /**
// * Returns the summary of this EditTextPreference. If the summary has a
// * {@link java.lang.String#format String formatting} marker in it (i.e. "%s" or "%1$s"), then the current value
// * will be substituted in its place.
// *
// * @return the summary with appropriate string substitution
// */
// @Override
// public CharSequence getSummary() {
// final CharSequence text = getText();
// return String.format(summaryString, text == null ? "" : text);
// }
// }
|
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import com.braintreepayments.demo.R;
import com.braintreepayments.demo.views.SummaryEditTestPreference;
|
package com.braintreepayments.demo.fragments;
public class SettingsFragment extends PreferenceFragment
implements OnSharedPreferenceChangeListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
SharedPreferences preferences = getPreferenceManager().getSharedPreferences();
onSharedPreferenceChanged(preferences, "paypal_payment_type");
preferences.registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onDestroy() {
super.onDestroy();
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Preference preference = findPreference(key);
if (preference instanceof ListPreference) {
preference.setSummary(((ListPreference) preference).getEntry());
|
// Path: Demo/src/main/java/com/braintreepayments/demo/views/SummaryEditTestPreference.java
// public class SummaryEditTestPreference extends EditTextPreference {
//
// private String summaryString;
//
// public SummaryEditTestPreference(Context context) {
// super(context);
// init();
// }
//
// public SummaryEditTestPreference(Context context, AttributeSet attrs) {
// super(context, attrs);
// init();
// }
//
// public SummaryEditTestPreference(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// init();
// }
//
// @TargetApi(VERSION_CODES.LOLLIPOP)
// public SummaryEditTestPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
// super(context, attrs, defStyleAttr, defStyleRes);
// init();
// }
//
// private void init() {
// summaryString = super.getSummary().toString();
// }
//
// /**
// * Returns the summary of this EditTextPreference. If the summary has a
// * {@link java.lang.String#format String formatting} marker in it (i.e. "%s" or "%1$s"), then the current value
// * will be substituted in its place.
// *
// * @return the summary with appropriate string substitution
// */
// @Override
// public CharSequence getSummary() {
// final CharSequence text = getText();
// return String.format(summaryString, text == null ? "" : text);
// }
// }
// Path: Demo/src/main/java/com/braintreepayments/demo/fragments/SettingsFragment.java
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import com.braintreepayments.demo.R;
import com.braintreepayments.demo.views.SummaryEditTestPreference;
package com.braintreepayments.demo.fragments;
public class SettingsFragment extends PreferenceFragment
implements OnSharedPreferenceChangeListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
SharedPreferences preferences = getPreferenceManager().getSharedPreferences();
onSharedPreferenceChanged(preferences, "paypal_payment_type");
preferences.registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onDestroy() {
super.onDestroy();
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Preference preference = findPreference(key);
if (preference instanceof ListPreference) {
preference.setSummary(((ListPreference) preference).getEntry());
|
} else if (preference instanceof SummaryEditTestPreference) {
|
braintree/braintree-android-drop-in
|
Demo/src/androidTest/java/com/braintreepayments/demo/test/CardholderNameDropInTest.java
|
// Path: Demo/src/androidTest/java/com/braintreepayments/demo/test/utilities/TestHelper.java
// public class TestHelper {
//
// @CallSuper
// public void setup() {
// clearPreference("BraintreeApi");
// clearPreference("PayPalOTC");
//
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .clear()
// .putBoolean("paypal_use_hardcoded_configuration", true)
// .commit();
// }
//
// public void launchApp() {
// onDevice().onHomeScreen().launchApp("com.braintreepayments.demo");
// ensureEnvironmentIs("Sandbox");
// }
//
// public DeviceAutomator getNonceDetails() {
// return onDevice(withResourceId("com.braintreepayments.demo:id/nonce_details"));
// }
//
// public void setCustomerId(String customerId) {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putString("customer", customerId)
// .commit();
// }
//
// /**
// * Sets the customer ID to a value that should be randomized.
// * There should not be any saved payment methods for this customer.
// */
// public void setUniqueCustomerId() {
// setCustomerId(""+System.currentTimeMillis());
// }
//
// public void setMerchantAccountId(String merchantAccountId) {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putString("merchant_account", merchantAccountId)
// .commit();
// }
//
// public void useTokenizationKey() {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putBoolean("tokenization_key", true)
// .commit();
// }
//
// public void enableThreeDSecure() {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putBoolean("enable_three_d_secure", true)
// .commit();
// }
//
// public void enableVaultManager() {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putBoolean("enable_vault_manager", true)
// .commit();
// }
//
// public void setCardholderNameStatus(int cardholderNameStatus) {
// String status;
//
// switch(cardholderNameStatus) {
// case CardForm.FIELD_REQUIRED:
// status = "Required";
// break;
// case CardForm.FIELD_OPTIONAL:
// status = "Optional";
// break;
// default:
// case CardForm.FIELD_DISABLED:
// status = "Disabled";
// break;
// }
//
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putString("cardholder_name_status", status)
// .commit();
// }
//
// public void setSaveCardCheckBox(boolean visible, boolean defaultValue) {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putBoolean("save_card_checkbox_visible", visible)
// .putBoolean("save_card_checkbox_default_value", defaultValue)
// .commit();
// }
//
// private void clearPreference(String preference) {
// ApplicationProvider.getApplicationContext().getSharedPreferences(preference, Context.MODE_PRIVATE)
// .edit()
// .clear()
// .commit();
// }
//
// private static void ensureEnvironmentIs(String environment) {
// try {
// onDevice(withText(environment)).check(text(equalTo(environment)));
// } catch (RuntimeException e) {
// onDevice(withClass(Spinner.class)).perform(click());
// onDevice(withText(environment)).perform(click());
// onDevice(withText(environment)).check(text(equalTo(environment)));
// }
// }
//
// protected void performCardDetailsEntry() {
// onDevice(withText("Expiration Date")).perform(setText("12" + ExpirationDate.VALID_EXPIRATION_YEAR));
// onDevice(withText("CVV")).perform(setText("123"));
// onDevice(withText("Postal Code")).perform(setText("12345"));
// }
//
// protected void tokenizeCard(String cardNumber) {
// onDevice(withText("Credit or Debit Card")).waitForExists().perform(click());
// onDevice(withText("Card Number")).waitForExists().perform(setText(cardNumber));
// onDevice(withText("Next")).perform(click());
// performCardDetailsEntry();
// onDevice(withTextContaining("Add Card")).perform(click());
// }
// }
//
// Path: Demo/src/androidTest/java/com/braintreepayments/demo/test/utilities/CardNumber.java
// public static final String VISA = "4111111111111111";
|
import com.braintreepayments.cardform.view.CardForm;
import com.braintreepayments.demo.test.utilities.TestHelper;
import org.junit.Before;
import org.junit.Test;
import static com.braintreepayments.demo.test.utilities.CardNumber.VISA;
import static com.braintreepayments.AutomatorAction.click;
import static com.braintreepayments.AutomatorAction.setText;
import static com.braintreepayments.AutomatorAssertion.text;
import static com.braintreepayments.DeviceAutomator.onDevice;
import static com.braintreepayments.UiObjectMatcher.withText;
import static com.braintreepayments.UiObjectMatcher.withTextContaining;
import static com.braintreepayments.UiObjectMatcher.withTextStartingWith;
import static junit.framework.Assert.fail;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.core.StringEndsWith.endsWith;
|
package com.braintreepayments.demo.test;
public class CardholderNameDropInTest extends TestHelper {
@Before
public void setup() {
super.setup();
}
@Test(timeout = 60000)
public void cardholderName_whenDisabled_isHidden() {
setCardholderNameStatus(CardForm.FIELD_DISABLED);
launchApp();
onDevice(withText("Add Payment Method")).waitForExists(20000).waitForEnabled(20000).perform(click());
onDevice(withText("Credit or Debit Card")).perform(click());
|
// Path: Demo/src/androidTest/java/com/braintreepayments/demo/test/utilities/TestHelper.java
// public class TestHelper {
//
// @CallSuper
// public void setup() {
// clearPreference("BraintreeApi");
// clearPreference("PayPalOTC");
//
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .clear()
// .putBoolean("paypal_use_hardcoded_configuration", true)
// .commit();
// }
//
// public void launchApp() {
// onDevice().onHomeScreen().launchApp("com.braintreepayments.demo");
// ensureEnvironmentIs("Sandbox");
// }
//
// public DeviceAutomator getNonceDetails() {
// return onDevice(withResourceId("com.braintreepayments.demo:id/nonce_details"));
// }
//
// public void setCustomerId(String customerId) {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putString("customer", customerId)
// .commit();
// }
//
// /**
// * Sets the customer ID to a value that should be randomized.
// * There should not be any saved payment methods for this customer.
// */
// public void setUniqueCustomerId() {
// setCustomerId(""+System.currentTimeMillis());
// }
//
// public void setMerchantAccountId(String merchantAccountId) {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putString("merchant_account", merchantAccountId)
// .commit();
// }
//
// public void useTokenizationKey() {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putBoolean("tokenization_key", true)
// .commit();
// }
//
// public void enableThreeDSecure() {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putBoolean("enable_three_d_secure", true)
// .commit();
// }
//
// public void enableVaultManager() {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putBoolean("enable_vault_manager", true)
// .commit();
// }
//
// public void setCardholderNameStatus(int cardholderNameStatus) {
// String status;
//
// switch(cardholderNameStatus) {
// case CardForm.FIELD_REQUIRED:
// status = "Required";
// break;
// case CardForm.FIELD_OPTIONAL:
// status = "Optional";
// break;
// default:
// case CardForm.FIELD_DISABLED:
// status = "Disabled";
// break;
// }
//
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putString("cardholder_name_status", status)
// .commit();
// }
//
// public void setSaveCardCheckBox(boolean visible, boolean defaultValue) {
// PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
// .edit()
// .putBoolean("save_card_checkbox_visible", visible)
// .putBoolean("save_card_checkbox_default_value", defaultValue)
// .commit();
// }
//
// private void clearPreference(String preference) {
// ApplicationProvider.getApplicationContext().getSharedPreferences(preference, Context.MODE_PRIVATE)
// .edit()
// .clear()
// .commit();
// }
//
// private static void ensureEnvironmentIs(String environment) {
// try {
// onDevice(withText(environment)).check(text(equalTo(environment)));
// } catch (RuntimeException e) {
// onDevice(withClass(Spinner.class)).perform(click());
// onDevice(withText(environment)).perform(click());
// onDevice(withText(environment)).check(text(equalTo(environment)));
// }
// }
//
// protected void performCardDetailsEntry() {
// onDevice(withText("Expiration Date")).perform(setText("12" + ExpirationDate.VALID_EXPIRATION_YEAR));
// onDevice(withText("CVV")).perform(setText("123"));
// onDevice(withText("Postal Code")).perform(setText("12345"));
// }
//
// protected void tokenizeCard(String cardNumber) {
// onDevice(withText("Credit or Debit Card")).waitForExists().perform(click());
// onDevice(withText("Card Number")).waitForExists().perform(setText(cardNumber));
// onDevice(withText("Next")).perform(click());
// performCardDetailsEntry();
// onDevice(withTextContaining("Add Card")).perform(click());
// }
// }
//
// Path: Demo/src/androidTest/java/com/braintreepayments/demo/test/utilities/CardNumber.java
// public static final String VISA = "4111111111111111";
// Path: Demo/src/androidTest/java/com/braintreepayments/demo/test/CardholderNameDropInTest.java
import com.braintreepayments.cardform.view.CardForm;
import com.braintreepayments.demo.test.utilities.TestHelper;
import org.junit.Before;
import org.junit.Test;
import static com.braintreepayments.demo.test.utilities.CardNumber.VISA;
import static com.braintreepayments.AutomatorAction.click;
import static com.braintreepayments.AutomatorAction.setText;
import static com.braintreepayments.AutomatorAssertion.text;
import static com.braintreepayments.DeviceAutomator.onDevice;
import static com.braintreepayments.UiObjectMatcher.withText;
import static com.braintreepayments.UiObjectMatcher.withTextContaining;
import static com.braintreepayments.UiObjectMatcher.withTextStartingWith;
import static junit.framework.Assert.fail;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.core.StringEndsWith.endsWith;
package com.braintreepayments.demo.test;
public class CardholderNameDropInTest extends TestHelper {
@Before
public void setup() {
super.setup();
}
@Test(timeout = 60000)
public void cardholderName_whenDisabled_isHidden() {
setCardholderNameStatus(CardForm.FIELD_DISABLED);
launchApp();
onDevice(withText("Add Payment Method")).waitForExists(20000).waitForEnabled(20000).perform(click());
onDevice(withText("Credit or Debit Card")).perform(click());
|
onDevice(withText("Card Number")).perform(setText(VISA));
|
gubatron/SellerTrade
|
src/com/seller/trade/servlets/LobbyServlet.java
|
// Path: src/com/seller/trade/services/ServiceBroker.java
// public final class ServiceBroker {
//
// protected final Logger LOG;
// private final Configuration configuration;
// private final DHTService dhtService;
// private final StoreService storeService;
// private final TemplateService templateService;
//
// private final String serverIp;
//
// public ServiceBroker(Configuration configuration) {
// System.out.println("Starting ServiceBroker...");
// this.configuration = configuration;
// LOG = Lumberjack.getLogger(this);
// serverIp = configuration.getString(ConfigurationKeys.ST_SERVER_IP);
// int tcpPort = configuration.getInt(ConfigurationKeys.ST_SERVER_PORT);
//
// dhtService = new DHTServiceImpl(configuration.getBoolean(ConfigurationKeys.ST_USE_LAN_MAPPINGS));
// if (!configuration.getBoolean(ConfigurationKeys.ST_IS_LOBBY_SERVER)) {
// System.out.println("Announcing myself, not lobby.");
// dhtService.announceNode(tcpPort);
// } else {
// System.out.println("Not announcing myself, I'm a lobby server....");
// }
//
// storeService = new StoreService(configuration, dhtService);
// storeService.announceProducts();
//
// templateService = new TemplateService(configuration);
// System.out.println("ServiceBroker started.");
// }
//
// public Configuration getConfiguration() {
// return configuration;
// }
//
// public DHTService getDhtService() { return dhtService; }
//
// public StoreService getStoreService() { return storeService; }
//
// public TemplateService getTemplateService() { return templateService; }
// }
//
// Path: src/com/seller/trade/services/dht/DHTNode.java
// public class DHTNode {
// public final String ipAddress;
// public final int port;
//
// public DHTNode(String ipAddress, int port) {
// this.ipAddress = ipAddress;
// this.port = port;
// }
//
// public final String getIPAddress() {
// return ipAddress;
// }
//
// /** Returns the http port under which the peer is being announced.
// * All further HTTP interaction between servers should be done through this
// * port*/
// public final int getHttpPort() {
// return port;
// }
// }
//
// Path: src/com/seller/trade/services/dht/DHTService.java
// public interface DHTService {
//
// public List<DHTNode> getNodes();
//
// public List<DHTNode> getNodes(String keyword);
//
// public void announceNode(int httpPort);
//
// public void announceKeywords(List<String> keywords, int httpPort);
// }
|
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import com.seller.trade.services.ServiceBroker;
import com.seller.trade.services.dht.DHTNode;
import com.seller.trade.services.dht.DHTService;
|
/**
* The MIT License
===============
Copyright (C) 2015 SellerTrade Developers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.seller.trade.servlets;
/**
* TODO: Add HTTP redirection to peer.
* Created by gubatron on 1/10/15.
* Returns a list of known peers to connect to.
* It will cache the last known list as fetching peers from the DHT
* can take time.
*/
public class LobbyServlet extends STAbstractServlet {
private final DHTService dhtService;
|
// Path: src/com/seller/trade/services/ServiceBroker.java
// public final class ServiceBroker {
//
// protected final Logger LOG;
// private final Configuration configuration;
// private final DHTService dhtService;
// private final StoreService storeService;
// private final TemplateService templateService;
//
// private final String serverIp;
//
// public ServiceBroker(Configuration configuration) {
// System.out.println("Starting ServiceBroker...");
// this.configuration = configuration;
// LOG = Lumberjack.getLogger(this);
// serverIp = configuration.getString(ConfigurationKeys.ST_SERVER_IP);
// int tcpPort = configuration.getInt(ConfigurationKeys.ST_SERVER_PORT);
//
// dhtService = new DHTServiceImpl(configuration.getBoolean(ConfigurationKeys.ST_USE_LAN_MAPPINGS));
// if (!configuration.getBoolean(ConfigurationKeys.ST_IS_LOBBY_SERVER)) {
// System.out.println("Announcing myself, not lobby.");
// dhtService.announceNode(tcpPort);
// } else {
// System.out.println("Not announcing myself, I'm a lobby server....");
// }
//
// storeService = new StoreService(configuration, dhtService);
// storeService.announceProducts();
//
// templateService = new TemplateService(configuration);
// System.out.println("ServiceBroker started.");
// }
//
// public Configuration getConfiguration() {
// return configuration;
// }
//
// public DHTService getDhtService() { return dhtService; }
//
// public StoreService getStoreService() { return storeService; }
//
// public TemplateService getTemplateService() { return templateService; }
// }
//
// Path: src/com/seller/trade/services/dht/DHTNode.java
// public class DHTNode {
// public final String ipAddress;
// public final int port;
//
// public DHTNode(String ipAddress, int port) {
// this.ipAddress = ipAddress;
// this.port = port;
// }
//
// public final String getIPAddress() {
// return ipAddress;
// }
//
// /** Returns the http port under which the peer is being announced.
// * All further HTTP interaction between servers should be done through this
// * port*/
// public final int getHttpPort() {
// return port;
// }
// }
//
// Path: src/com/seller/trade/services/dht/DHTService.java
// public interface DHTService {
//
// public List<DHTNode> getNodes();
//
// public List<DHTNode> getNodes(String keyword);
//
// public void announceNode(int httpPort);
//
// public void announceKeywords(List<String> keywords, int httpPort);
// }
// Path: src/com/seller/trade/servlets/LobbyServlet.java
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import com.seller.trade.services.ServiceBroker;
import com.seller.trade.services.dht.DHTNode;
import com.seller.trade.services.dht.DHTService;
/**
* The MIT License
===============
Copyright (C) 2015 SellerTrade Developers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.seller.trade.servlets;
/**
* TODO: Add HTTP redirection to peer.
* Created by gubatron on 1/10/15.
* Returns a list of known peers to connect to.
* It will cache the last known list as fetching peers from the DHT
* can take time.
*/
public class LobbyServlet extends STAbstractServlet {
private final DHTService dhtService;
|
public LobbyServlet(String command, ServiceBroker broker) {
|
gubatron/SellerTrade
|
src/com/seller/trade/servlets/LobbyServlet.java
|
// Path: src/com/seller/trade/services/ServiceBroker.java
// public final class ServiceBroker {
//
// protected final Logger LOG;
// private final Configuration configuration;
// private final DHTService dhtService;
// private final StoreService storeService;
// private final TemplateService templateService;
//
// private final String serverIp;
//
// public ServiceBroker(Configuration configuration) {
// System.out.println("Starting ServiceBroker...");
// this.configuration = configuration;
// LOG = Lumberjack.getLogger(this);
// serverIp = configuration.getString(ConfigurationKeys.ST_SERVER_IP);
// int tcpPort = configuration.getInt(ConfigurationKeys.ST_SERVER_PORT);
//
// dhtService = new DHTServiceImpl(configuration.getBoolean(ConfigurationKeys.ST_USE_LAN_MAPPINGS));
// if (!configuration.getBoolean(ConfigurationKeys.ST_IS_LOBBY_SERVER)) {
// System.out.println("Announcing myself, not lobby.");
// dhtService.announceNode(tcpPort);
// } else {
// System.out.println("Not announcing myself, I'm a lobby server....");
// }
//
// storeService = new StoreService(configuration, dhtService);
// storeService.announceProducts();
//
// templateService = new TemplateService(configuration);
// System.out.println("ServiceBroker started.");
// }
//
// public Configuration getConfiguration() {
// return configuration;
// }
//
// public DHTService getDhtService() { return dhtService; }
//
// public StoreService getStoreService() { return storeService; }
//
// public TemplateService getTemplateService() { return templateService; }
// }
//
// Path: src/com/seller/trade/services/dht/DHTNode.java
// public class DHTNode {
// public final String ipAddress;
// public final int port;
//
// public DHTNode(String ipAddress, int port) {
// this.ipAddress = ipAddress;
// this.port = port;
// }
//
// public final String getIPAddress() {
// return ipAddress;
// }
//
// /** Returns the http port under which the peer is being announced.
// * All further HTTP interaction between servers should be done through this
// * port*/
// public final int getHttpPort() {
// return port;
// }
// }
//
// Path: src/com/seller/trade/services/dht/DHTService.java
// public interface DHTService {
//
// public List<DHTNode> getNodes();
//
// public List<DHTNode> getNodes(String keyword);
//
// public void announceNode(int httpPort);
//
// public void announceKeywords(List<String> keywords, int httpPort);
// }
|
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import com.seller.trade.services.ServiceBroker;
import com.seller.trade.services.dht.DHTNode;
import com.seller.trade.services.dht.DHTService;
|
/**
* The MIT License
===============
Copyright (C) 2015 SellerTrade Developers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.seller.trade.servlets;
/**
* TODO: Add HTTP redirection to peer.
* Created by gubatron on 1/10/15.
* Returns a list of known peers to connect to.
* It will cache the last known list as fetching peers from the DHT
* can take time.
*/
public class LobbyServlet extends STAbstractServlet {
private final DHTService dhtService;
public LobbyServlet(String command, ServiceBroker broker) {
super(command, broker);
dhtService = broker.getDhtService();
}
@Override
protected void handleUncached(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String output;
response.setContentType("text/html");
response.setStatus(HttpServletResponse.SC_OK);
|
// Path: src/com/seller/trade/services/ServiceBroker.java
// public final class ServiceBroker {
//
// protected final Logger LOG;
// private final Configuration configuration;
// private final DHTService dhtService;
// private final StoreService storeService;
// private final TemplateService templateService;
//
// private final String serverIp;
//
// public ServiceBroker(Configuration configuration) {
// System.out.println("Starting ServiceBroker...");
// this.configuration = configuration;
// LOG = Lumberjack.getLogger(this);
// serverIp = configuration.getString(ConfigurationKeys.ST_SERVER_IP);
// int tcpPort = configuration.getInt(ConfigurationKeys.ST_SERVER_PORT);
//
// dhtService = new DHTServiceImpl(configuration.getBoolean(ConfigurationKeys.ST_USE_LAN_MAPPINGS));
// if (!configuration.getBoolean(ConfigurationKeys.ST_IS_LOBBY_SERVER)) {
// System.out.println("Announcing myself, not lobby.");
// dhtService.announceNode(tcpPort);
// } else {
// System.out.println("Not announcing myself, I'm a lobby server....");
// }
//
// storeService = new StoreService(configuration, dhtService);
// storeService.announceProducts();
//
// templateService = new TemplateService(configuration);
// System.out.println("ServiceBroker started.");
// }
//
// public Configuration getConfiguration() {
// return configuration;
// }
//
// public DHTService getDhtService() { return dhtService; }
//
// public StoreService getStoreService() { return storeService; }
//
// public TemplateService getTemplateService() { return templateService; }
// }
//
// Path: src/com/seller/trade/services/dht/DHTNode.java
// public class DHTNode {
// public final String ipAddress;
// public final int port;
//
// public DHTNode(String ipAddress, int port) {
// this.ipAddress = ipAddress;
// this.port = port;
// }
//
// public final String getIPAddress() {
// return ipAddress;
// }
//
// /** Returns the http port under which the peer is being announced.
// * All further HTTP interaction between servers should be done through this
// * port*/
// public final int getHttpPort() {
// return port;
// }
// }
//
// Path: src/com/seller/trade/services/dht/DHTService.java
// public interface DHTService {
//
// public List<DHTNode> getNodes();
//
// public List<DHTNode> getNodes(String keyword);
//
// public void announceNode(int httpPort);
//
// public void announceKeywords(List<String> keywords, int httpPort);
// }
// Path: src/com/seller/trade/servlets/LobbyServlet.java
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import com.seller.trade.services.ServiceBroker;
import com.seller.trade.services.dht.DHTNode;
import com.seller.trade.services.dht.DHTService;
/**
* The MIT License
===============
Copyright (C) 2015 SellerTrade Developers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.seller.trade.servlets;
/**
* TODO: Add HTTP redirection to peer.
* Created by gubatron on 1/10/15.
* Returns a list of known peers to connect to.
* It will cache the last known list as fetching peers from the DHT
* can take time.
*/
public class LobbyServlet extends STAbstractServlet {
private final DHTService dhtService;
public LobbyServlet(String command, ServiceBroker broker) {
super(command, broker);
dhtService = broker.getDhtService();
}
@Override
protected void handleUncached(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String output;
response.setContentType("text/html");
response.setStatus(HttpServletResponse.SC_OK);
|
final List<DHTNode> nodes = null;// dhtService.getNodes();
|
gubatron/SellerTrade
|
src/com/seller/trade/services/APIServer.java
|
// Path: src/com/seller/trade/core/Configuration.java
// public final class Configuration {
//
// private static final Logger LOG = Lumberjack.getLogger(Configuration.class);
//
// private static final String ST_CONF_ENV = "ST_CONF";
//
// private final Properties properties;
//
// public Configuration(String filename) {
// properties = new Properties();
//
// try {
// properties.load(new FileInputStream(filename));
// } catch (Throwable e) {
// throw new RuntimeException("Can't run without configuration", e);
// }
// }
//
// public Configuration() {
// this(System.getenv(ST_CONF_ENV));
// }
//
// public String getString(String key) {
// String r = "";
//
// try{
// r = properties.getProperty(key);
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
//
// public int getInt(String key) {
// int r = 0;
//
// try {
// r = Integer.parseInt(properties.getProperty(key));
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
//
// public float getFloat(String key) {
// float r = 0f;
//
// try {
// r = Float.parseFloat(properties.getProperty(key));
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
//
// public boolean getBoolean(String key) {
// boolean r = false;
//
// try {
// r = Boolean.parseBoolean(properties.getProperty(key));
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
//
// public List<String> getList(String key) {
//
// List<String> results = new ArrayList<>();
// String property = null;
// String[] split = null;
//
// try {
// property = properties.getProperty(key);
//
// if (property == null) {
// return null;
// }
//
// split = property.split(",");
// results = Arrays.asList(split);
// } catch (Exception e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return results;
// }
//
// public long getLong(String key) {
// long r = 0;
//
// try {
// r = Long.parseLong(properties.getProperty(key));
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
// }
//
// Path: src/com/seller/trade/core/ConfigurationKeys.java
// public class ConfigurationKeys {
// public static final String ST_VERSION = "st.version";
// public static final String ST_SERVER_PORT = "st.server_port";
// public static final String ST_SITE_NAME = "st.site_name";
// public static final String ST_TEMPLATES_FOLDER = "st.templates.folder";
// public static final String ST_SITE_SLOGAN = "st.site_slogan";
// public static final String ST_SITE_DESCRIPTION = "st.site_description";
// public static final String ST_SITE_KEYWORDS = "st.site_keywords";
// public static final String ST_SHIPPING_FROM = "st.shipping_from";
// public static final String ST_HOSTNAME = "st.hostname";
// public static final String ST_SERVER_IP = "st.server_ip";
// public static final String ST_IS_LOBBY_SERVER = "st.is_lobby_server";
// public static final String ST_USE_LAN_MAPPINGS= "st.use_lan_mappings";
// public static final String ST_SEND_ACCESS_CONTROL_ALLOW_ORIGIN = "st.send_access_control_allow_origin";
// public static final String ST_SEARCH_HOPS = "st.search.hops";
// public static final String ST_PRODUCTS_SET = "st.products_set";
// public static final String ST_QUERY_NODE_TIMEOUT_MS = "st.query_node_timeout_ms";
//
// protected ConfigurationKeys() {
// }
// }
|
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.seller.trade.core.Configuration;
import com.seller.trade.core.ConfigurationKeys;
import com.seller.trade.servlets.*;
import org.eclipse.jetty.server.DispatcherType;
|
Collection<STAbstractServlet> servlets = SERVLET_MAP.values();
for (STAbstractServlet servlet : servlets) {
if (servlet.getClass().equals(clazz)) {
return servlet.getURLCommandName();
}
}
return null;
}
private void addServletsToContextHandler(ServletContextHandler context) {
for (Entry<String, STAbstractServlet> entry : SERVLET_MAP.entrySet()) {
String contextPath = "/" + entry.getKey() + "/";
if (contextPath.equals("///")) {
contextPath = "/";
}
System.out.println("key: [" + entry.getKey() + "] value: [" + entry.getValue().getClass().getName() + "] contextPath: [" + contextPath + "]");
context.addServlet(new ServletHolder(entry.getValue()), contextPath);
}
}
public static void main(String[] args) {
ServiceBroker broker = null;
|
// Path: src/com/seller/trade/core/Configuration.java
// public final class Configuration {
//
// private static final Logger LOG = Lumberjack.getLogger(Configuration.class);
//
// private static final String ST_CONF_ENV = "ST_CONF";
//
// private final Properties properties;
//
// public Configuration(String filename) {
// properties = new Properties();
//
// try {
// properties.load(new FileInputStream(filename));
// } catch (Throwable e) {
// throw new RuntimeException("Can't run without configuration", e);
// }
// }
//
// public Configuration() {
// this(System.getenv(ST_CONF_ENV));
// }
//
// public String getString(String key) {
// String r = "";
//
// try{
// r = properties.getProperty(key);
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
//
// public int getInt(String key) {
// int r = 0;
//
// try {
// r = Integer.parseInt(properties.getProperty(key));
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
//
// public float getFloat(String key) {
// float r = 0f;
//
// try {
// r = Float.parseFloat(properties.getProperty(key));
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
//
// public boolean getBoolean(String key) {
// boolean r = false;
//
// try {
// r = Boolean.parseBoolean(properties.getProperty(key));
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
//
// public List<String> getList(String key) {
//
// List<String> results = new ArrayList<>();
// String property = null;
// String[] split = null;
//
// try {
// property = properties.getProperty(key);
//
// if (property == null) {
// return null;
// }
//
// split = property.split(",");
// results = Arrays.asList(split);
// } catch (Exception e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return results;
// }
//
// public long getLong(String key) {
// long r = 0;
//
// try {
// r = Long.parseLong(properties.getProperty(key));
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
// }
//
// Path: src/com/seller/trade/core/ConfigurationKeys.java
// public class ConfigurationKeys {
// public static final String ST_VERSION = "st.version";
// public static final String ST_SERVER_PORT = "st.server_port";
// public static final String ST_SITE_NAME = "st.site_name";
// public static final String ST_TEMPLATES_FOLDER = "st.templates.folder";
// public static final String ST_SITE_SLOGAN = "st.site_slogan";
// public static final String ST_SITE_DESCRIPTION = "st.site_description";
// public static final String ST_SITE_KEYWORDS = "st.site_keywords";
// public static final String ST_SHIPPING_FROM = "st.shipping_from";
// public static final String ST_HOSTNAME = "st.hostname";
// public static final String ST_SERVER_IP = "st.server_ip";
// public static final String ST_IS_LOBBY_SERVER = "st.is_lobby_server";
// public static final String ST_USE_LAN_MAPPINGS= "st.use_lan_mappings";
// public static final String ST_SEND_ACCESS_CONTROL_ALLOW_ORIGIN = "st.send_access_control_allow_origin";
// public static final String ST_SEARCH_HOPS = "st.search.hops";
// public static final String ST_PRODUCTS_SET = "st.products_set";
// public static final String ST_QUERY_NODE_TIMEOUT_MS = "st.query_node_timeout_ms";
//
// protected ConfigurationKeys() {
// }
// }
// Path: src/com/seller/trade/services/APIServer.java
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.seller.trade.core.Configuration;
import com.seller.trade.core.ConfigurationKeys;
import com.seller.trade.servlets.*;
import org.eclipse.jetty.server.DispatcherType;
Collection<STAbstractServlet> servlets = SERVLET_MAP.values();
for (STAbstractServlet servlet : servlets) {
if (servlet.getClass().equals(clazz)) {
return servlet.getURLCommandName();
}
}
return null;
}
private void addServletsToContextHandler(ServletContextHandler context) {
for (Entry<String, STAbstractServlet> entry : SERVLET_MAP.entrySet()) {
String contextPath = "/" + entry.getKey() + "/";
if (contextPath.equals("///")) {
contextPath = "/";
}
System.out.println("key: [" + entry.getKey() + "] value: [" + entry.getValue().getClass().getName() + "] contextPath: [" + contextPath + "]");
context.addServlet(new ServletHolder(entry.getValue()), contextPath);
}
}
public static void main(String[] args) {
ServiceBroker broker = null;
|
Configuration configuration = null;
|
gubatron/SellerTrade
|
src/com/seller/trade/servlets/HelloWorldServlet.java
|
// Path: src/com/seller/trade/core/ConfigurationKeys.java
// public class ConfigurationKeys {
// public static final String ST_VERSION = "st.version";
// public static final String ST_SERVER_PORT = "st.server_port";
// public static final String ST_SITE_NAME = "st.site_name";
// public static final String ST_TEMPLATES_FOLDER = "st.templates.folder";
// public static final String ST_SITE_SLOGAN = "st.site_slogan";
// public static final String ST_SITE_DESCRIPTION = "st.site_description";
// public static final String ST_SITE_KEYWORDS = "st.site_keywords";
// public static final String ST_SHIPPING_FROM = "st.shipping_from";
// public static final String ST_HOSTNAME = "st.hostname";
// public static final String ST_SERVER_IP = "st.server_ip";
// public static final String ST_IS_LOBBY_SERVER = "st.is_lobby_server";
// public static final String ST_USE_LAN_MAPPINGS= "st.use_lan_mappings";
// public static final String ST_SEND_ACCESS_CONTROL_ALLOW_ORIGIN = "st.send_access_control_allow_origin";
// public static final String ST_SEARCH_HOPS = "st.search.hops";
// public static final String ST_PRODUCTS_SET = "st.products_set";
// public static final String ST_QUERY_NODE_TIMEOUT_MS = "st.query_node_timeout_ms";
//
// protected ConfigurationKeys() {
// }
// }
//
// Path: src/com/seller/trade/services/ServiceBroker.java
// public final class ServiceBroker {
//
// protected final Logger LOG;
// private final Configuration configuration;
// private final DHTService dhtService;
// private final StoreService storeService;
// private final TemplateService templateService;
//
// private final String serverIp;
//
// public ServiceBroker(Configuration configuration) {
// System.out.println("Starting ServiceBroker...");
// this.configuration = configuration;
// LOG = Lumberjack.getLogger(this);
// serverIp = configuration.getString(ConfigurationKeys.ST_SERVER_IP);
// int tcpPort = configuration.getInt(ConfigurationKeys.ST_SERVER_PORT);
//
// dhtService = new DHTServiceImpl(configuration.getBoolean(ConfigurationKeys.ST_USE_LAN_MAPPINGS));
// if (!configuration.getBoolean(ConfigurationKeys.ST_IS_LOBBY_SERVER)) {
// System.out.println("Announcing myself, not lobby.");
// dhtService.announceNode(tcpPort);
// } else {
// System.out.println("Not announcing myself, I'm a lobby server....");
// }
//
// storeService = new StoreService(configuration, dhtService);
// storeService.announceProducts();
//
// templateService = new TemplateService(configuration);
// System.out.println("ServiceBroker started.");
// }
//
// public Configuration getConfiguration() {
// return configuration;
// }
//
// public DHTService getDhtService() { return dhtService; }
//
// public StoreService getStoreService() { return storeService; }
//
// public TemplateService getTemplateService() { return templateService; }
// }
|
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import com.seller.trade.core.ConfigurationKeys;
import com.seller.trade.services.ServiceBroker;
import org.apache.velocity.VelocityContext;
|
/**
* The MIT License
===============
Copyright (C) 2015 SellerTrade Developers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.seller.trade.servlets;
public final class HelloWorldServlet extends STAbstractServlet {
public HelloWorldServlet(String command, ServiceBroker broker) {
super(command, broker);
}
@Override
protected void handleUncached(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.setContentType("text/html");
response.setStatus(HttpServletResponse.SC_OK);
VelocityContext context = new VelocityContext();
|
// Path: src/com/seller/trade/core/ConfigurationKeys.java
// public class ConfigurationKeys {
// public static final String ST_VERSION = "st.version";
// public static final String ST_SERVER_PORT = "st.server_port";
// public static final String ST_SITE_NAME = "st.site_name";
// public static final String ST_TEMPLATES_FOLDER = "st.templates.folder";
// public static final String ST_SITE_SLOGAN = "st.site_slogan";
// public static final String ST_SITE_DESCRIPTION = "st.site_description";
// public static final String ST_SITE_KEYWORDS = "st.site_keywords";
// public static final String ST_SHIPPING_FROM = "st.shipping_from";
// public static final String ST_HOSTNAME = "st.hostname";
// public static final String ST_SERVER_IP = "st.server_ip";
// public static final String ST_IS_LOBBY_SERVER = "st.is_lobby_server";
// public static final String ST_USE_LAN_MAPPINGS= "st.use_lan_mappings";
// public static final String ST_SEND_ACCESS_CONTROL_ALLOW_ORIGIN = "st.send_access_control_allow_origin";
// public static final String ST_SEARCH_HOPS = "st.search.hops";
// public static final String ST_PRODUCTS_SET = "st.products_set";
// public static final String ST_QUERY_NODE_TIMEOUT_MS = "st.query_node_timeout_ms";
//
// protected ConfigurationKeys() {
// }
// }
//
// Path: src/com/seller/trade/services/ServiceBroker.java
// public final class ServiceBroker {
//
// protected final Logger LOG;
// private final Configuration configuration;
// private final DHTService dhtService;
// private final StoreService storeService;
// private final TemplateService templateService;
//
// private final String serverIp;
//
// public ServiceBroker(Configuration configuration) {
// System.out.println("Starting ServiceBroker...");
// this.configuration = configuration;
// LOG = Lumberjack.getLogger(this);
// serverIp = configuration.getString(ConfigurationKeys.ST_SERVER_IP);
// int tcpPort = configuration.getInt(ConfigurationKeys.ST_SERVER_PORT);
//
// dhtService = new DHTServiceImpl(configuration.getBoolean(ConfigurationKeys.ST_USE_LAN_MAPPINGS));
// if (!configuration.getBoolean(ConfigurationKeys.ST_IS_LOBBY_SERVER)) {
// System.out.println("Announcing myself, not lobby.");
// dhtService.announceNode(tcpPort);
// } else {
// System.out.println("Not announcing myself, I'm a lobby server....");
// }
//
// storeService = new StoreService(configuration, dhtService);
// storeService.announceProducts();
//
// templateService = new TemplateService(configuration);
// System.out.println("ServiceBroker started.");
// }
//
// public Configuration getConfiguration() {
// return configuration;
// }
//
// public DHTService getDhtService() { return dhtService; }
//
// public StoreService getStoreService() { return storeService; }
//
// public TemplateService getTemplateService() { return templateService; }
// }
// Path: src/com/seller/trade/servlets/HelloWorldServlet.java
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import com.seller.trade.core.ConfigurationKeys;
import com.seller.trade.services.ServiceBroker;
import org.apache.velocity.VelocityContext;
/**
* The MIT License
===============
Copyright (C) 2015 SellerTrade Developers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.seller.trade.servlets;
public final class HelloWorldServlet extends STAbstractServlet {
public HelloWorldServlet(String command, ServiceBroker broker) {
super(command, broker);
}
@Override
protected void handleUncached(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.setContentType("text/html");
response.setStatus(HttpServletResponse.SC_OK);
VelocityContext context = new VelocityContext();
|
context.put("siteName", broker.getConfiguration().getString(ConfigurationKeys.ST_SITE_NAME));
|
gubatron/SellerTrade
|
src/com/seller/trade/servlets/ProductPageServlet.java
|
// Path: src/com/seller/trade/models/Product.java
// public class Product {
//
// public long id;
// public String name;
// public String description;
// public String[] keywords;
// public String thumbnailUrl;
//
// /**
// * No price volatility anxiety, thank you BitPay.
// */
// public float usdPrice;
// public String bitpayData;
//
// // TODO: list of pictures urls, for more product pictures.
// }
//
// Path: src/com/seller/trade/services/ServiceBroker.java
// public final class ServiceBroker {
//
// protected final Logger LOG;
// private final Configuration configuration;
// private final DHTService dhtService;
// private final StoreService storeService;
// private final TemplateService templateService;
//
// private final String serverIp;
//
// public ServiceBroker(Configuration configuration) {
// System.out.println("Starting ServiceBroker...");
// this.configuration = configuration;
// LOG = Lumberjack.getLogger(this);
// serverIp = configuration.getString(ConfigurationKeys.ST_SERVER_IP);
// int tcpPort = configuration.getInt(ConfigurationKeys.ST_SERVER_PORT);
//
// dhtService = new DHTServiceImpl(configuration.getBoolean(ConfigurationKeys.ST_USE_LAN_MAPPINGS));
// if (!configuration.getBoolean(ConfigurationKeys.ST_IS_LOBBY_SERVER)) {
// System.out.println("Announcing myself, not lobby.");
// dhtService.announceNode(tcpPort);
// } else {
// System.out.println("Not announcing myself, I'm a lobby server....");
// }
//
// storeService = new StoreService(configuration, dhtService);
// storeService.announceProducts();
//
// templateService = new TemplateService(configuration);
// System.out.println("ServiceBroker started.");
// }
//
// public Configuration getConfiguration() {
// return configuration;
// }
//
// public DHTService getDhtService() { return dhtService; }
//
// public StoreService getStoreService() { return storeService; }
//
// public TemplateService getTemplateService() { return templateService; }
// }
|
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import com.seller.trade.models.Product;
import com.seller.trade.services.ServiceBroker;
import org.apache.velocity.VelocityContext;
|
/**
* The MIT License
===============
Copyright (C) 2015 SellerTrade Developers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.seller.trade.servlets;
public final class ProductPageServlet extends STAbstractServlet {
public ProductPageServlet(String command, ServiceBroker broker) {
super(command, broker);
}
@Override
protected void handleUncached(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
long id = Long.parseLong(getDefaultParameter(request, "id"));
|
// Path: src/com/seller/trade/models/Product.java
// public class Product {
//
// public long id;
// public String name;
// public String description;
// public String[] keywords;
// public String thumbnailUrl;
//
// /**
// * No price volatility anxiety, thank you BitPay.
// */
// public float usdPrice;
// public String bitpayData;
//
// // TODO: list of pictures urls, for more product pictures.
// }
//
// Path: src/com/seller/trade/services/ServiceBroker.java
// public final class ServiceBroker {
//
// protected final Logger LOG;
// private final Configuration configuration;
// private final DHTService dhtService;
// private final StoreService storeService;
// private final TemplateService templateService;
//
// private final String serverIp;
//
// public ServiceBroker(Configuration configuration) {
// System.out.println("Starting ServiceBroker...");
// this.configuration = configuration;
// LOG = Lumberjack.getLogger(this);
// serverIp = configuration.getString(ConfigurationKeys.ST_SERVER_IP);
// int tcpPort = configuration.getInt(ConfigurationKeys.ST_SERVER_PORT);
//
// dhtService = new DHTServiceImpl(configuration.getBoolean(ConfigurationKeys.ST_USE_LAN_MAPPINGS));
// if (!configuration.getBoolean(ConfigurationKeys.ST_IS_LOBBY_SERVER)) {
// System.out.println("Announcing myself, not lobby.");
// dhtService.announceNode(tcpPort);
// } else {
// System.out.println("Not announcing myself, I'm a lobby server....");
// }
//
// storeService = new StoreService(configuration, dhtService);
// storeService.announceProducts();
//
// templateService = new TemplateService(configuration);
// System.out.println("ServiceBroker started.");
// }
//
// public Configuration getConfiguration() {
// return configuration;
// }
//
// public DHTService getDhtService() { return dhtService; }
//
// public StoreService getStoreService() { return storeService; }
//
// public TemplateService getTemplateService() { return templateService; }
// }
// Path: src/com/seller/trade/servlets/ProductPageServlet.java
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import com.seller.trade.models.Product;
import com.seller.trade.services.ServiceBroker;
import org.apache.velocity.VelocityContext;
/**
* The MIT License
===============
Copyright (C) 2015 SellerTrade Developers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.seller.trade.servlets;
public final class ProductPageServlet extends STAbstractServlet {
public ProductPageServlet(String command, ServiceBroker broker) {
super(command, broker);
}
@Override
protected void handleUncached(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
long id = Long.parseLong(getDefaultParameter(request, "id"));
|
Product p = broker.getStoreService().getProduct(id);
|
gubatron/SellerTrade
|
src/com/seller/trade/services/TemplateService.java
|
// Path: src/com/seller/trade/core/Configuration.java
// public final class Configuration {
//
// private static final Logger LOG = Lumberjack.getLogger(Configuration.class);
//
// private static final String ST_CONF_ENV = "ST_CONF";
//
// private final Properties properties;
//
// public Configuration(String filename) {
// properties = new Properties();
//
// try {
// properties.load(new FileInputStream(filename));
// } catch (Throwable e) {
// throw new RuntimeException("Can't run without configuration", e);
// }
// }
//
// public Configuration() {
// this(System.getenv(ST_CONF_ENV));
// }
//
// public String getString(String key) {
// String r = "";
//
// try{
// r = properties.getProperty(key);
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
//
// public int getInt(String key) {
// int r = 0;
//
// try {
// r = Integer.parseInt(properties.getProperty(key));
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
//
// public float getFloat(String key) {
// float r = 0f;
//
// try {
// r = Float.parseFloat(properties.getProperty(key));
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
//
// public boolean getBoolean(String key) {
// boolean r = false;
//
// try {
// r = Boolean.parseBoolean(properties.getProperty(key));
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
//
// public List<String> getList(String key) {
//
// List<String> results = new ArrayList<>();
// String property = null;
// String[] split = null;
//
// try {
// property = properties.getProperty(key);
//
// if (property == null) {
// return null;
// }
//
// split = property.split(",");
// results = Arrays.asList(split);
// } catch (Exception e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return results;
// }
//
// public long getLong(String key) {
// long r = 0;
//
// try {
// r = Long.parseLong(properties.getProperty(key));
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
// }
//
// Path: src/com/seller/trade/core/ConfigurationKeys.java
// public class ConfigurationKeys {
// public static final String ST_VERSION = "st.version";
// public static final String ST_SERVER_PORT = "st.server_port";
// public static final String ST_SITE_NAME = "st.site_name";
// public static final String ST_TEMPLATES_FOLDER = "st.templates.folder";
// public static final String ST_SITE_SLOGAN = "st.site_slogan";
// public static final String ST_SITE_DESCRIPTION = "st.site_description";
// public static final String ST_SITE_KEYWORDS = "st.site_keywords";
// public static final String ST_SHIPPING_FROM = "st.shipping_from";
// public static final String ST_HOSTNAME = "st.hostname";
// public static final String ST_SERVER_IP = "st.server_ip";
// public static final String ST_IS_LOBBY_SERVER = "st.is_lobby_server";
// public static final String ST_USE_LAN_MAPPINGS= "st.use_lan_mappings";
// public static final String ST_SEND_ACCESS_CONTROL_ALLOW_ORIGIN = "st.send_access_control_allow_origin";
// public static final String ST_SEARCH_HOPS = "st.search.hops";
// public static final String ST_PRODUCTS_SET = "st.products_set";
// public static final String ST_QUERY_NODE_TIMEOUT_MS = "st.query_node_timeout_ms";
//
// protected ConfigurationKeys() {
// }
// }
|
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
import java.io.Writer;
import java.util.Properties;
import com.seller.trade.core.Configuration;
import com.seller.trade.core.ConfigurationKeys;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.context.Context;
|
/**
* The MIT License
===============
Copyright (C) 2015 SellerTrade Developers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.seller.trade.services;
/**
* Created by gubatron on 1/10/15.
*/
public class TemplateService {
private final Configuration configuration;
private final VelocityEngine templateEngine;
public TemplateService(Configuration configuration) {
this.configuration = configuration;
|
// Path: src/com/seller/trade/core/Configuration.java
// public final class Configuration {
//
// private static final Logger LOG = Lumberjack.getLogger(Configuration.class);
//
// private static final String ST_CONF_ENV = "ST_CONF";
//
// private final Properties properties;
//
// public Configuration(String filename) {
// properties = new Properties();
//
// try {
// properties.load(new FileInputStream(filename));
// } catch (Throwable e) {
// throw new RuntimeException("Can't run without configuration", e);
// }
// }
//
// public Configuration() {
// this(System.getenv(ST_CONF_ENV));
// }
//
// public String getString(String key) {
// String r = "";
//
// try{
// r = properties.getProperty(key);
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
//
// public int getInt(String key) {
// int r = 0;
//
// try {
// r = Integer.parseInt(properties.getProperty(key));
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
//
// public float getFloat(String key) {
// float r = 0f;
//
// try {
// r = Float.parseFloat(properties.getProperty(key));
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
//
// public boolean getBoolean(String key) {
// boolean r = false;
//
// try {
// r = Boolean.parseBoolean(properties.getProperty(key));
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
//
// public List<String> getList(String key) {
//
// List<String> results = new ArrayList<>();
// String property = null;
// String[] split = null;
//
// try {
// property = properties.getProperty(key);
//
// if (property == null) {
// return null;
// }
//
// split = property.split(",");
// results = Arrays.asList(split);
// } catch (Exception e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return results;
// }
//
// public long getLong(String key) {
// long r = 0;
//
// try {
// r = Long.parseLong(properties.getProperty(key));
// } catch (Throwable e) {
// LOG.log(Level.SEVERE, String.format("Error reading configuration key %s", key), e);
// }
//
// return r;
// }
// }
//
// Path: src/com/seller/trade/core/ConfigurationKeys.java
// public class ConfigurationKeys {
// public static final String ST_VERSION = "st.version";
// public static final String ST_SERVER_PORT = "st.server_port";
// public static final String ST_SITE_NAME = "st.site_name";
// public static final String ST_TEMPLATES_FOLDER = "st.templates.folder";
// public static final String ST_SITE_SLOGAN = "st.site_slogan";
// public static final String ST_SITE_DESCRIPTION = "st.site_description";
// public static final String ST_SITE_KEYWORDS = "st.site_keywords";
// public static final String ST_SHIPPING_FROM = "st.shipping_from";
// public static final String ST_HOSTNAME = "st.hostname";
// public static final String ST_SERVER_IP = "st.server_ip";
// public static final String ST_IS_LOBBY_SERVER = "st.is_lobby_server";
// public static final String ST_USE_LAN_MAPPINGS= "st.use_lan_mappings";
// public static final String ST_SEND_ACCESS_CONTROL_ALLOW_ORIGIN = "st.send_access_control_allow_origin";
// public static final String ST_SEARCH_HOPS = "st.search.hops";
// public static final String ST_PRODUCTS_SET = "st.products_set";
// public static final String ST_QUERY_NODE_TIMEOUT_MS = "st.query_node_timeout_ms";
//
// protected ConfigurationKeys() {
// }
// }
// Path: src/com/seller/trade/services/TemplateService.java
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
import java.io.Writer;
import java.util.Properties;
import com.seller.trade.core.Configuration;
import com.seller.trade.core.ConfigurationKeys;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.context.Context;
/**
* The MIT License
===============
Copyright (C) 2015 SellerTrade Developers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.seller.trade.services;
/**
* Created by gubatron on 1/10/15.
*/
public class TemplateService {
private final Configuration configuration;
private final VelocityEngine templateEngine;
public TemplateService(Configuration configuration) {
this.configuration = configuration;
|
final String templatesFolder = configuration.getString(ConfigurationKeys.ST_TEMPLATES_FOLDER);
|
ddf/Minim
|
src/main/java/ddf/minim/spi/AudioOut.java
|
// Path: src/main/java/ddf/minim/AudioListener.java
// public interface AudioListener
// {
// /**
// * Called by the audio object this AudioListener is attached to
// * when that object has new samples.
// *
// * @example Advanced/AddAndRemoveAudioListener
// *
// * @param samp
// * a float[] buffer of samples from a MONO sound stream
// *
// * @related AudioListener
// */
// void samples(float[] samp);
//
// /**
// * Called by the <code>Recordable</code> object this is attached to
// * when that object has new samples.
// *
// * @param sampL
// * a float[] buffer containing the left channel of a STEREO sound stream
// * @param sampR
// * a float[] buffer containing the right channel of a STEREO sound stream
// *
// * @related AudioListener
// */
// void samples(float[] sampL, float[] sampR);
//
// // TODO: consider replacing above two methods with this single one
// // void samples( MultiChannelBuffer buffer );
// }
|
import ddf.minim.AudioEffect;
import ddf.minim.AudioListener;
import ddf.minim.AudioSignal;
|
/*
* Copyright (c) 2007 - 2008 by Damien Di Fede <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package ddf.minim.spi;
/**
* An <code>AudioSythesizer</code> is an <code>AudioStream</code> that generates
* sound, rather than reading sound. It uses the attached
* <code>AudioSignal</code> and <code>AudioEffect</code> to generate a signal.
*
* @author Damien Di Fede
*
*/
@SuppressWarnings("deprecation")
public interface AudioOut extends AudioResource
{
/**
* @return the size of the buffer used by this output.
*/
int bufferSize();
/**
* Sets the AudioSignal that this output will use to generate sound.
*
* @param signal
* the AudioSignal used to generate sound
*/
@Deprecated
void setAudioSignal(AudioSignal signal);
/**
* Sets the AudioStream that this output will use to generate sound.
*
* @param stream
*/
void setAudioStream(AudioStream stream);
/**
* Sets the AudioEffect to apply to the signal.
*
* @param effect
* the AudioEffect to apply to the signal
*/
@Deprecated
void setAudioEffect(AudioEffect effect);
/**
* Sets the AudioListener that will have sound broadcasted to it as the
* output generates.
*
* @param listen
*/
|
// Path: src/main/java/ddf/minim/AudioListener.java
// public interface AudioListener
// {
// /**
// * Called by the audio object this AudioListener is attached to
// * when that object has new samples.
// *
// * @example Advanced/AddAndRemoveAudioListener
// *
// * @param samp
// * a float[] buffer of samples from a MONO sound stream
// *
// * @related AudioListener
// */
// void samples(float[] samp);
//
// /**
// * Called by the <code>Recordable</code> object this is attached to
// * when that object has new samples.
// *
// * @param sampL
// * a float[] buffer containing the left channel of a STEREO sound stream
// * @param sampR
// * a float[] buffer containing the right channel of a STEREO sound stream
// *
// * @related AudioListener
// */
// void samples(float[] sampL, float[] sampR);
//
// // TODO: consider replacing above two methods with this single one
// // void samples( MultiChannelBuffer buffer );
// }
// Path: src/main/java/ddf/minim/spi/AudioOut.java
import ddf.minim.AudioEffect;
import ddf.minim.AudioListener;
import ddf.minim.AudioSignal;
/*
* Copyright (c) 2007 - 2008 by Damien Di Fede <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package ddf.minim.spi;
/**
* An <code>AudioSythesizer</code> is an <code>AudioStream</code> that generates
* sound, rather than reading sound. It uses the attached
* <code>AudioSignal</code> and <code>AudioEffect</code> to generate a signal.
*
* @author Damien Di Fede
*
*/
@SuppressWarnings("deprecation")
public interface AudioOut extends AudioResource
{
/**
* @return the size of the buffer used by this output.
*/
int bufferSize();
/**
* Sets the AudioSignal that this output will use to generate sound.
*
* @param signal
* the AudioSignal used to generate sound
*/
@Deprecated
void setAudioSignal(AudioSignal signal);
/**
* Sets the AudioStream that this output will use to generate sound.
*
* @param stream
*/
void setAudioStream(AudioStream stream);
/**
* Sets the AudioEffect to apply to the signal.
*
* @param effect
* the AudioEffect to apply to the signal
*/
@Deprecated
void setAudioEffect(AudioEffect effect);
/**
* Sets the AudioListener that will have sound broadcasted to it as the
* output generates.
*
* @param listen
*/
|
void setAudioListener(AudioListener listen);
|
ddf/Minim
|
src/main/java/ddf/minim/AudioSource.java
|
// Path: src/main/java/ddf/minim/spi/AudioOut.java
// @SuppressWarnings("deprecation")
// public interface AudioOut extends AudioResource
// {
// /**
// * @return the size of the buffer used by this output.
// */
// int bufferSize();
//
// /**
// * Sets the AudioSignal that this output will use to generate sound.
// *
// * @param signal
// * the AudioSignal used to generate sound
// */
// @Deprecated
// void setAudioSignal(AudioSignal signal);
//
// /**
// * Sets the AudioStream that this output will use to generate sound.
// *
// * @param stream
// */
// void setAudioStream(AudioStream stream);
//
// /**
// * Sets the AudioEffect to apply to the signal.
// *
// * @param effect
// * the AudioEffect to apply to the signal
// */
// @Deprecated
// void setAudioEffect(AudioEffect effect);
//
// /**
// * Sets the AudioListener that will have sound broadcasted to it as the
// * output generates.
// *
// * @param listen
// */
// void setAudioListener(AudioListener listen);
// }
|
import javax.sound.sampled.AudioFormat;
import ddf.minim.spi.AudioOut;
|
package ddf.minim;
/**
* An <code>AudioSource</code> is a kind of wrapper around an
* <code>AudioStream</code>. An <code>AudioSource</code> will add its
* <code>AudioBuffer</code>s as listeners on the stream so that you can access
* the stream's samples without having to implement <code>AudioListener</code>
* yourself. It also provides the <code>Effectable</code> and
* <code>Recordable</code> interface. Because an <code>AudioStream</code> must
* be closed when you are finished with it, you must remember to call
* {@link #close()} on any <code>AudioSource</code>s you obtain from Minim, such
* as <code>AudioInput</code>s, <code>AudioOutput</code>s, and
* <code>AudioPlayer</code>s.
*
* @author Damien Di Fede
* @invisible
*
*/
@SuppressWarnings("deprecation")
public class AudioSource extends Controller implements Effectable, Recordable
{
// the instance of Minim that created us, if one did.
Minim parent;
|
// Path: src/main/java/ddf/minim/spi/AudioOut.java
// @SuppressWarnings("deprecation")
// public interface AudioOut extends AudioResource
// {
// /**
// * @return the size of the buffer used by this output.
// */
// int bufferSize();
//
// /**
// * Sets the AudioSignal that this output will use to generate sound.
// *
// * @param signal
// * the AudioSignal used to generate sound
// */
// @Deprecated
// void setAudioSignal(AudioSignal signal);
//
// /**
// * Sets the AudioStream that this output will use to generate sound.
// *
// * @param stream
// */
// void setAudioStream(AudioStream stream);
//
// /**
// * Sets the AudioEffect to apply to the signal.
// *
// * @param effect
// * the AudioEffect to apply to the signal
// */
// @Deprecated
// void setAudioEffect(AudioEffect effect);
//
// /**
// * Sets the AudioListener that will have sound broadcasted to it as the
// * output generates.
// *
// * @param listen
// */
// void setAudioListener(AudioListener listen);
// }
// Path: src/main/java/ddf/minim/AudioSource.java
import javax.sound.sampled.AudioFormat;
import ddf.minim.spi.AudioOut;
package ddf.minim;
/**
* An <code>AudioSource</code> is a kind of wrapper around an
* <code>AudioStream</code>. An <code>AudioSource</code> will add its
* <code>AudioBuffer</code>s as listeners on the stream so that you can access
* the stream's samples without having to implement <code>AudioListener</code>
* yourself. It also provides the <code>Effectable</code> and
* <code>Recordable</code> interface. Because an <code>AudioStream</code> must
* be closed when you are finished with it, you must remember to call
* {@link #close()} on any <code>AudioSource</code>s you obtain from Minim, such
* as <code>AudioInput</code>s, <code>AudioOutput</code>s, and
* <code>AudioPlayer</code>s.
*
* @author Damien Di Fede
* @invisible
*
*/
@SuppressWarnings("deprecation")
public class AudioSource extends Controller implements Effectable, Recordable
{
// the instance of Minim that created us, if one did.
Minim parent;
|
private AudioOut stream;
|
ddf/Minim
|
src/main/java/ddf/minim/AudioInput.java
|
// Path: src/main/java/ddf/minim/spi/AudioOut.java
// @SuppressWarnings("deprecation")
// public interface AudioOut extends AudioResource
// {
// /**
// * @return the size of the buffer used by this output.
// */
// int bufferSize();
//
// /**
// * Sets the AudioSignal that this output will use to generate sound.
// *
// * @param signal
// * the AudioSignal used to generate sound
// */
// @Deprecated
// void setAudioSignal(AudioSignal signal);
//
// /**
// * Sets the AudioStream that this output will use to generate sound.
// *
// * @param stream
// */
// void setAudioStream(AudioStream stream);
//
// /**
// * Sets the AudioEffect to apply to the signal.
// *
// * @param effect
// * the AudioEffect to apply to the signal
// */
// @Deprecated
// void setAudioEffect(AudioEffect effect);
//
// /**
// * Sets the AudioListener that will have sound broadcasted to it as the
// * output generates.
// *
// * @param listen
// */
// void setAudioListener(AudioListener listen);
// }
//
// Path: src/main/java/ddf/minim/spi/AudioStream.java
// public interface AudioStream extends AudioResource
// {
// /**
// * Reads the next sample frame.
// *
// * @return an array of floats containing the value of each channel in the sample frame just read.
// * The size of the returned array will be the same size as getFormat().getChannels().
// */
// @Deprecated
// float[] read();
//
// /**
// * Reads buffer.getBufferSize() sample frames and puts them into buffer's channels.
// * The provided buffer will be forced to have the same number of channels that this
// * AudioStream does.
// *
// * @param buffer The MultiChannelBuffer to fill with audio samples.
// *
// * @return int: the number of sample frames that were actually read, could be smaller than the size of the buffer.
// */
// int read(MultiChannelBuffer buffer);
// }
|
import ddf.minim.spi.AudioOut;
import ddf.minim.spi.AudioStream;
|
/*
* Copyright (c) 2007 - 2008 by Damien Di Fede <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package ddf.minim;
/**
* An AudioInput is a connection to the current record source of the computer.
* How the record source for a computer is set will depend on the soundcard and OS,
* but typically a user can open a control panel and set the source from there.
* Unfortunately, there is no way to set the record source from Java.
* <p>
* You can obtain an AudioInput from Minim by using one of the getLineIn methods:
* <pre>
* // get the default STEREO input
* AudioInput getLineIn()
*
* // specifiy either Minim.MONO or Minim.STEREO for type
* AudioInput getLineIn(int type)
*
* // bufferSize is the size of the left, right,
* // and mix buffers of the input you get back
* AudioInput getLineIn(int type, int bufferSize)
*
* // sampleRate is a request for an input of a certain sample rate
* AudioInput getLineIn(int type, int bufferSize, float sampleRate)
*
* // bitDepth is a request for an input with a certain bit depth
* AudioInput getLineIn(int type, int bufferSize, float sampleRate, int bitDepth)
* </pre>
* In the event that an input doesn't exist with the requested parameters,
* Minim will spit out an error and return null. In general,
* you will want to use the first two methods listed above.
*
* @example Basics/MonitorInput
*
* @related Minim
*
* @author Damien Di Fede
*
*/
public class AudioInput extends AudioSource
{
boolean m_isMonitoring;
|
// Path: src/main/java/ddf/minim/spi/AudioOut.java
// @SuppressWarnings("deprecation")
// public interface AudioOut extends AudioResource
// {
// /**
// * @return the size of the buffer used by this output.
// */
// int bufferSize();
//
// /**
// * Sets the AudioSignal that this output will use to generate sound.
// *
// * @param signal
// * the AudioSignal used to generate sound
// */
// @Deprecated
// void setAudioSignal(AudioSignal signal);
//
// /**
// * Sets the AudioStream that this output will use to generate sound.
// *
// * @param stream
// */
// void setAudioStream(AudioStream stream);
//
// /**
// * Sets the AudioEffect to apply to the signal.
// *
// * @param effect
// * the AudioEffect to apply to the signal
// */
// @Deprecated
// void setAudioEffect(AudioEffect effect);
//
// /**
// * Sets the AudioListener that will have sound broadcasted to it as the
// * output generates.
// *
// * @param listen
// */
// void setAudioListener(AudioListener listen);
// }
//
// Path: src/main/java/ddf/minim/spi/AudioStream.java
// public interface AudioStream extends AudioResource
// {
// /**
// * Reads the next sample frame.
// *
// * @return an array of floats containing the value of each channel in the sample frame just read.
// * The size of the returned array will be the same size as getFormat().getChannels().
// */
// @Deprecated
// float[] read();
//
// /**
// * Reads buffer.getBufferSize() sample frames and puts them into buffer's channels.
// * The provided buffer will be forced to have the same number of channels that this
// * AudioStream does.
// *
// * @param buffer The MultiChannelBuffer to fill with audio samples.
// *
// * @return int: the number of sample frames that were actually read, could be smaller than the size of the buffer.
// */
// int read(MultiChannelBuffer buffer);
// }
// Path: src/main/java/ddf/minim/AudioInput.java
import ddf.minim.spi.AudioOut;
import ddf.minim.spi.AudioStream;
/*
* Copyright (c) 2007 - 2008 by Damien Di Fede <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package ddf.minim;
/**
* An AudioInput is a connection to the current record source of the computer.
* How the record source for a computer is set will depend on the soundcard and OS,
* but typically a user can open a control panel and set the source from there.
* Unfortunately, there is no way to set the record source from Java.
* <p>
* You can obtain an AudioInput from Minim by using one of the getLineIn methods:
* <pre>
* // get the default STEREO input
* AudioInput getLineIn()
*
* // specifiy either Minim.MONO or Minim.STEREO for type
* AudioInput getLineIn(int type)
*
* // bufferSize is the size of the left, right,
* // and mix buffers of the input you get back
* AudioInput getLineIn(int type, int bufferSize)
*
* // sampleRate is a request for an input of a certain sample rate
* AudioInput getLineIn(int type, int bufferSize, float sampleRate)
*
* // bitDepth is a request for an input with a certain bit depth
* AudioInput getLineIn(int type, int bufferSize, float sampleRate, int bitDepth)
* </pre>
* In the event that an input doesn't exist with the requested parameters,
* Minim will spit out an error and return null. In general,
* you will want to use the first two methods listed above.
*
* @example Basics/MonitorInput
*
* @related Minim
*
* @author Damien Di Fede
*
*/
public class AudioInput extends AudioSource
{
boolean m_isMonitoring;
|
AudioStream m_stream;
|
ddf/Minim
|
src/main/java/ddf/minim/AudioInput.java
|
// Path: src/main/java/ddf/minim/spi/AudioOut.java
// @SuppressWarnings("deprecation")
// public interface AudioOut extends AudioResource
// {
// /**
// * @return the size of the buffer used by this output.
// */
// int bufferSize();
//
// /**
// * Sets the AudioSignal that this output will use to generate sound.
// *
// * @param signal
// * the AudioSignal used to generate sound
// */
// @Deprecated
// void setAudioSignal(AudioSignal signal);
//
// /**
// * Sets the AudioStream that this output will use to generate sound.
// *
// * @param stream
// */
// void setAudioStream(AudioStream stream);
//
// /**
// * Sets the AudioEffect to apply to the signal.
// *
// * @param effect
// * the AudioEffect to apply to the signal
// */
// @Deprecated
// void setAudioEffect(AudioEffect effect);
//
// /**
// * Sets the AudioListener that will have sound broadcasted to it as the
// * output generates.
// *
// * @param listen
// */
// void setAudioListener(AudioListener listen);
// }
//
// Path: src/main/java/ddf/minim/spi/AudioStream.java
// public interface AudioStream extends AudioResource
// {
// /**
// * Reads the next sample frame.
// *
// * @return an array of floats containing the value of each channel in the sample frame just read.
// * The size of the returned array will be the same size as getFormat().getChannels().
// */
// @Deprecated
// float[] read();
//
// /**
// * Reads buffer.getBufferSize() sample frames and puts them into buffer's channels.
// * The provided buffer will be forced to have the same number of channels that this
// * AudioStream does.
// *
// * @param buffer The MultiChannelBuffer to fill with audio samples.
// *
// * @return int: the number of sample frames that were actually read, could be smaller than the size of the buffer.
// */
// int read(MultiChannelBuffer buffer);
// }
|
import ddf.minim.spi.AudioOut;
import ddf.minim.spi.AudioStream;
|
/*
* Copyright (c) 2007 - 2008 by Damien Di Fede <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package ddf.minim;
/**
* An AudioInput is a connection to the current record source of the computer.
* How the record source for a computer is set will depend on the soundcard and OS,
* but typically a user can open a control panel and set the source from there.
* Unfortunately, there is no way to set the record source from Java.
* <p>
* You can obtain an AudioInput from Minim by using one of the getLineIn methods:
* <pre>
* // get the default STEREO input
* AudioInput getLineIn()
*
* // specifiy either Minim.MONO or Minim.STEREO for type
* AudioInput getLineIn(int type)
*
* // bufferSize is the size of the left, right,
* // and mix buffers of the input you get back
* AudioInput getLineIn(int type, int bufferSize)
*
* // sampleRate is a request for an input of a certain sample rate
* AudioInput getLineIn(int type, int bufferSize, float sampleRate)
*
* // bitDepth is a request for an input with a certain bit depth
* AudioInput getLineIn(int type, int bufferSize, float sampleRate, int bitDepth)
* </pre>
* In the event that an input doesn't exist with the requested parameters,
* Minim will spit out an error and return null. In general,
* you will want to use the first two methods listed above.
*
* @example Basics/MonitorInput
*
* @related Minim
*
* @author Damien Di Fede
*
*/
public class AudioInput extends AudioSource
{
boolean m_isMonitoring;
AudioStream m_stream;
/** @invisible
*
* Constructs an <code>AudioInput</code> that uses <code>out</code> to read
* samples from <code>stream</code>. The samples from <code>stream</code>
* can be accessed by through the interface provided by <code>AudioSource</code>.
*
* @param stream the <code>AudioStream</code> that provides the samples
* @param out the <code>AudioOut</code> that will read from <code>stream</code>
*/
|
// Path: src/main/java/ddf/minim/spi/AudioOut.java
// @SuppressWarnings("deprecation")
// public interface AudioOut extends AudioResource
// {
// /**
// * @return the size of the buffer used by this output.
// */
// int bufferSize();
//
// /**
// * Sets the AudioSignal that this output will use to generate sound.
// *
// * @param signal
// * the AudioSignal used to generate sound
// */
// @Deprecated
// void setAudioSignal(AudioSignal signal);
//
// /**
// * Sets the AudioStream that this output will use to generate sound.
// *
// * @param stream
// */
// void setAudioStream(AudioStream stream);
//
// /**
// * Sets the AudioEffect to apply to the signal.
// *
// * @param effect
// * the AudioEffect to apply to the signal
// */
// @Deprecated
// void setAudioEffect(AudioEffect effect);
//
// /**
// * Sets the AudioListener that will have sound broadcasted to it as the
// * output generates.
// *
// * @param listen
// */
// void setAudioListener(AudioListener listen);
// }
//
// Path: src/main/java/ddf/minim/spi/AudioStream.java
// public interface AudioStream extends AudioResource
// {
// /**
// * Reads the next sample frame.
// *
// * @return an array of floats containing the value of each channel in the sample frame just read.
// * The size of the returned array will be the same size as getFormat().getChannels().
// */
// @Deprecated
// float[] read();
//
// /**
// * Reads buffer.getBufferSize() sample frames and puts them into buffer's channels.
// * The provided buffer will be forced to have the same number of channels that this
// * AudioStream does.
// *
// * @param buffer The MultiChannelBuffer to fill with audio samples.
// *
// * @return int: the number of sample frames that were actually read, could be smaller than the size of the buffer.
// */
// int read(MultiChannelBuffer buffer);
// }
// Path: src/main/java/ddf/minim/AudioInput.java
import ddf.minim.spi.AudioOut;
import ddf.minim.spi.AudioStream;
/*
* Copyright (c) 2007 - 2008 by Damien Di Fede <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package ddf.minim;
/**
* An AudioInput is a connection to the current record source of the computer.
* How the record source for a computer is set will depend on the soundcard and OS,
* but typically a user can open a control panel and set the source from there.
* Unfortunately, there is no way to set the record source from Java.
* <p>
* You can obtain an AudioInput from Minim by using one of the getLineIn methods:
* <pre>
* // get the default STEREO input
* AudioInput getLineIn()
*
* // specifiy either Minim.MONO or Minim.STEREO for type
* AudioInput getLineIn(int type)
*
* // bufferSize is the size of the left, right,
* // and mix buffers of the input you get back
* AudioInput getLineIn(int type, int bufferSize)
*
* // sampleRate is a request for an input of a certain sample rate
* AudioInput getLineIn(int type, int bufferSize, float sampleRate)
*
* // bitDepth is a request for an input with a certain bit depth
* AudioInput getLineIn(int type, int bufferSize, float sampleRate, int bitDepth)
* </pre>
* In the event that an input doesn't exist with the requested parameters,
* Minim will spit out an error and return null. In general,
* you will want to use the first two methods listed above.
*
* @example Basics/MonitorInput
*
* @related Minim
*
* @author Damien Di Fede
*
*/
public class AudioInput extends AudioSource
{
boolean m_isMonitoring;
AudioStream m_stream;
/** @invisible
*
* Constructs an <code>AudioInput</code> that uses <code>out</code> to read
* samples from <code>stream</code>. The samples from <code>stream</code>
* can be accessed by through the interface provided by <code>AudioSource</code>.
*
* @param stream the <code>AudioStream</code> that provides the samples
* @param out the <code>AudioOut</code> that will read from <code>stream</code>
*/
|
public AudioInput(AudioStream stream, AudioOut out)
|
ddf/Minim
|
src/main/java/ddf/minim/ugens/LiveInput.java
|
// Path: src/main/java/ddf/minim/spi/AudioStream.java
// public interface AudioStream extends AudioResource
// {
// /**
// * Reads the next sample frame.
// *
// * @return an array of floats containing the value of each channel in the sample frame just read.
// * The size of the returned array will be the same size as getFormat().getChannels().
// */
// @Deprecated
// float[] read();
//
// /**
// * Reads buffer.getBufferSize() sample frames and puts them into buffer's channels.
// * The provided buffer will be forced to have the same number of channels that this
// * AudioStream does.
// *
// * @param buffer The MultiChannelBuffer to fill with audio samples.
// *
// * @return int: the number of sample frames that were actually read, could be smaller than the size of the buffer.
// */
// int read(MultiChannelBuffer buffer);
// }
|
import ddf.minim.UGen;
import ddf.minim.spi.AudioStream;
|
package ddf.minim.ugens;
/**
* LiveInput is a way to wrap an input stream with the UGen interface so that you can
* easily route incoming audio through a UGen graph. You can get an AudioStream that is
* reading audio input from Minim by calling Minim.getInputStream.
*
* @example Synthesis/liveInputExample
*
* @author Damien Di Fede
*
* @related UGen
* @related Minim
*
*/
public class LiveInput extends UGen
{
|
// Path: src/main/java/ddf/minim/spi/AudioStream.java
// public interface AudioStream extends AudioResource
// {
// /**
// * Reads the next sample frame.
// *
// * @return an array of floats containing the value of each channel in the sample frame just read.
// * The size of the returned array will be the same size as getFormat().getChannels().
// */
// @Deprecated
// float[] read();
//
// /**
// * Reads buffer.getBufferSize() sample frames and puts them into buffer's channels.
// * The provided buffer will be forced to have the same number of channels that this
// * AudioStream does.
// *
// * @param buffer The MultiChannelBuffer to fill with audio samples.
// *
// * @return int: the number of sample frames that were actually read, could be smaller than the size of the buffer.
// */
// int read(MultiChannelBuffer buffer);
// }
// Path: src/main/java/ddf/minim/ugens/LiveInput.java
import ddf.minim.UGen;
import ddf.minim.spi.AudioStream;
package ddf.minim.ugens;
/**
* LiveInput is a way to wrap an input stream with the UGen interface so that you can
* easily route incoming audio through a UGen graph. You can get an AudioStream that is
* reading audio input from Minim by calling Minim.getInputStream.
*
* @example Synthesis/liveInputExample
*
* @author Damien Di Fede
*
* @related UGen
* @related Minim
*
*/
public class LiveInput extends UGen
{
|
private AudioStream mInputStream;
|
ddf/Minim
|
src/main/java/ddf/minim/BasicAudioOut.java
|
// Path: src/main/java/ddf/minim/spi/AudioOut.java
// @SuppressWarnings("deprecation")
// public interface AudioOut extends AudioResource
// {
// /**
// * @return the size of the buffer used by this output.
// */
// int bufferSize();
//
// /**
// * Sets the AudioSignal that this output will use to generate sound.
// *
// * @param signal
// * the AudioSignal used to generate sound
// */
// @Deprecated
// void setAudioSignal(AudioSignal signal);
//
// /**
// * Sets the AudioStream that this output will use to generate sound.
// *
// * @param stream
// */
// void setAudioStream(AudioStream stream);
//
// /**
// * Sets the AudioEffect to apply to the signal.
// *
// * @param effect
// * the AudioEffect to apply to the signal
// */
// @Deprecated
// void setAudioEffect(AudioEffect effect);
//
// /**
// * Sets the AudioListener that will have sound broadcasted to it as the
// * output generates.
// *
// * @param listen
// */
// void setAudioListener(AudioListener listen);
// }
//
// Path: src/main/java/ddf/minim/spi/AudioStream.java
// public interface AudioStream extends AudioResource
// {
// /**
// * Reads the next sample frame.
// *
// * @return an array of floats containing the value of each channel in the sample frame just read.
// * The size of the returned array will be the same size as getFormat().getChannels().
// */
// @Deprecated
// float[] read();
//
// /**
// * Reads buffer.getBufferSize() sample frames and puts them into buffer's channels.
// * The provided buffer will be forced to have the same number of channels that this
// * AudioStream does.
// *
// * @param buffer The MultiChannelBuffer to fill with audio samples.
// *
// * @return int: the number of sample frames that were actually read, could be smaller than the size of the buffer.
// */
// int read(MultiChannelBuffer buffer);
// }
|
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.Control;
import ddf.minim.spi.AudioOut;
import ddf.minim.spi.AudioStream;
|
package ddf.minim;
// ddf (9/5/15): very very basic audio out implementation
// : that is used when creating an AudioInput
// : in the event that getLineOut does not return
// : a usable audio out.
class BasicAudioOut extends Thread
implements AudioOut
{
private AudioFormat format;
private MultiChannelBuffer buffer;
private AudioListener listener;
|
// Path: src/main/java/ddf/minim/spi/AudioOut.java
// @SuppressWarnings("deprecation")
// public interface AudioOut extends AudioResource
// {
// /**
// * @return the size of the buffer used by this output.
// */
// int bufferSize();
//
// /**
// * Sets the AudioSignal that this output will use to generate sound.
// *
// * @param signal
// * the AudioSignal used to generate sound
// */
// @Deprecated
// void setAudioSignal(AudioSignal signal);
//
// /**
// * Sets the AudioStream that this output will use to generate sound.
// *
// * @param stream
// */
// void setAudioStream(AudioStream stream);
//
// /**
// * Sets the AudioEffect to apply to the signal.
// *
// * @param effect
// * the AudioEffect to apply to the signal
// */
// @Deprecated
// void setAudioEffect(AudioEffect effect);
//
// /**
// * Sets the AudioListener that will have sound broadcasted to it as the
// * output generates.
// *
// * @param listen
// */
// void setAudioListener(AudioListener listen);
// }
//
// Path: src/main/java/ddf/minim/spi/AudioStream.java
// public interface AudioStream extends AudioResource
// {
// /**
// * Reads the next sample frame.
// *
// * @return an array of floats containing the value of each channel in the sample frame just read.
// * The size of the returned array will be the same size as getFormat().getChannels().
// */
// @Deprecated
// float[] read();
//
// /**
// * Reads buffer.getBufferSize() sample frames and puts them into buffer's channels.
// * The provided buffer will be forced to have the same number of channels that this
// * AudioStream does.
// *
// * @param buffer The MultiChannelBuffer to fill with audio samples.
// *
// * @return int: the number of sample frames that were actually read, could be smaller than the size of the buffer.
// */
// int read(MultiChannelBuffer buffer);
// }
// Path: src/main/java/ddf/minim/BasicAudioOut.java
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.Control;
import ddf.minim.spi.AudioOut;
import ddf.minim.spi.AudioStream;
package ddf.minim;
// ddf (9/5/15): very very basic audio out implementation
// : that is used when creating an AudioInput
// : in the event that getLineOut does not return
// : a usable audio out.
class BasicAudioOut extends Thread
implements AudioOut
{
private AudioFormat format;
private MultiChannelBuffer buffer;
private AudioListener listener;
|
private AudioStream stream;
|
WassimBenltaief/ReactiveFB
|
app/src/main/java/com/beltaief/reactivefbexample/models/Privacy.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Logger.java
// public final class Logger {
//
// private static boolean DEBUG = false;
// private static boolean DEBUG_WITH_STACKTRACE = false;
//
// private Logger() {
// }
//
// public static <T> void logInfo(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.i(tag, "-----");
// Log.i(tag, LogType.INFO + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.i(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logWarning(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.w(tag, "-----");
// Log.w(tag, LogType.WARNING + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.w(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logError(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.e(tag, "-----");
// Log.e(tag, LogType.ERROR + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.e(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logError(Class<T> cls, String message, Throwable e) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.e(tag, "-----");
// Log.e(tag, LogType.ERROR + ": " + message, e);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.e(tag, getStackTrace());
// }
// }
// }
//
// private enum LogType {
// INFO,
// WARNING,
// ERROR
// }
//
// private static String getStackTrace() {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// new Throwable().printStackTrace(pw);
// return sw.toString();
// }
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Utils.java
// public final class Utils {
// private Utils() {
// }
//
// public static Bundle getBundle(String mFields, int limit) {
// Bundle bundle = new Bundle();
// if (mFields != null) {
// bundle.putString("fields", mFields);
// }
// if (limit > 0) {
// bundle.putString("limit", String.valueOf(limit));
// }
// return bundle;
// }
//
// @SuppressWarnings("resource")
// public static String encode(String key, String data) {
// try {
// Mac mac = Mac.getInstance("HmacSHA256");
// SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "HmacSHA256");
// mac.init(secretKey);
// byte[] bytes = mac.doFinal(data.getBytes());
// StringBuilder sb = new StringBuilder(bytes.length * 2);
// Formatter formatter = new Formatter(sb);
// for (byte b : bytes) {
// formatter.format("%02x", b);
// }
// return sb.toString();
// } catch (Exception e) {
// Logger.logError(Utils.class, "Failed to create sha256", e);
// return null;
// }
// }
// }
|
import com.beltaief.reactivefb.util.Logger;
import com.beltaief.reactivefb.util.Utils;
import com.google.gson.annotations.SerializedName;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Collection;
|
/**
* Add a predefined friend list to the allowed list This can <b>only</b>
* be {@link Privacy.PrivacySettings#ALL_FRIENDS ALL_FRIENDS} or
* {@link Privacy.PrivacySettings#FRIENDS_OF_FRIENDS FRIENDS_OF_FRIENDS} to
* include all members of those sets. <br>
* <b>Only applicable in case of selected {@link Privacy.PrivacySettings#CUSTOM
* CUSTOM} in {@link #setPrivacySettings(Privacy.PrivacySettings)} method.</b> <br>
* <br>
*
* <b>Note:</b><br>
* If you defined other privacy setting than
* {@link Privacy.PrivacySettings#CUSTOM CUSTOM} and still decided to use this
* method, then the privacy will be changed with warning to
* {@link Privacy.PrivacySettings#CUSTOM CUSTOM}.
*
* @param privacySettings
* {@link Privacy.PrivacySettings#ALL_FRIENDS ALL_FRIENDS} or
* {@link Privacy.PrivacySettings#FRIENDS_OF_FRIENDS
* FRIENDS_OF_FRIENDS} to include all members of those sets.
* @throws UnsupportedOperationException
* in case of using other values than
* {@link Privacy.PrivacySettings#ALL_FRIENDS ALL_FRIENDS} or
* {@link Privacy.PrivacySettings#FRIENDS_OF_FRIENDS
* FRIENDS_OF_FRIENDS}
*/
public Builder addAllowed(PrivacySettings privacySettings) {
validateListsAccessRequest();
if (privacySettings != PrivacySettings.ALL_FRIENDS || privacySettings != PrivacySettings.FRIENDS_OF_FRIENDS) {
UnsupportedOperationException exception = new UnsupportedOperationException("Can't add this predefined friend list. Only allowed are: ALL_FRIENDS or FRIENDS_OF_FRIENDS");
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Logger.java
// public final class Logger {
//
// private static boolean DEBUG = false;
// private static boolean DEBUG_WITH_STACKTRACE = false;
//
// private Logger() {
// }
//
// public static <T> void logInfo(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.i(tag, "-----");
// Log.i(tag, LogType.INFO + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.i(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logWarning(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.w(tag, "-----");
// Log.w(tag, LogType.WARNING + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.w(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logError(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.e(tag, "-----");
// Log.e(tag, LogType.ERROR + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.e(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logError(Class<T> cls, String message, Throwable e) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.e(tag, "-----");
// Log.e(tag, LogType.ERROR + ": " + message, e);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.e(tag, getStackTrace());
// }
// }
// }
//
// private enum LogType {
// INFO,
// WARNING,
// ERROR
// }
//
// private static String getStackTrace() {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// new Throwable().printStackTrace(pw);
// return sw.toString();
// }
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Utils.java
// public final class Utils {
// private Utils() {
// }
//
// public static Bundle getBundle(String mFields, int limit) {
// Bundle bundle = new Bundle();
// if (mFields != null) {
// bundle.putString("fields", mFields);
// }
// if (limit > 0) {
// bundle.putString("limit", String.valueOf(limit));
// }
// return bundle;
// }
//
// @SuppressWarnings("resource")
// public static String encode(String key, String data) {
// try {
// Mac mac = Mac.getInstance("HmacSHA256");
// SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "HmacSHA256");
// mac.init(secretKey);
// byte[] bytes = mac.doFinal(data.getBytes());
// StringBuilder sb = new StringBuilder(bytes.length * 2);
// Formatter formatter = new Formatter(sb);
// for (byte b : bytes) {
// formatter.format("%02x", b);
// }
// return sb.toString();
// } catch (Exception e) {
// Logger.logError(Utils.class, "Failed to create sha256", e);
// return null;
// }
// }
// }
// Path: app/src/main/java/com/beltaief/reactivefbexample/models/Privacy.java
import com.beltaief.reactivefb.util.Logger;
import com.beltaief.reactivefb.util.Utils;
import com.google.gson.annotations.SerializedName;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Collection;
/**
* Add a predefined friend list to the allowed list This can <b>only</b>
* be {@link Privacy.PrivacySettings#ALL_FRIENDS ALL_FRIENDS} or
* {@link Privacy.PrivacySettings#FRIENDS_OF_FRIENDS FRIENDS_OF_FRIENDS} to
* include all members of those sets. <br>
* <b>Only applicable in case of selected {@link Privacy.PrivacySettings#CUSTOM
* CUSTOM} in {@link #setPrivacySettings(Privacy.PrivacySettings)} method.</b> <br>
* <br>
*
* <b>Note:</b><br>
* If you defined other privacy setting than
* {@link Privacy.PrivacySettings#CUSTOM CUSTOM} and still decided to use this
* method, then the privacy will be changed with warning to
* {@link Privacy.PrivacySettings#CUSTOM CUSTOM}.
*
* @param privacySettings
* {@link Privacy.PrivacySettings#ALL_FRIENDS ALL_FRIENDS} or
* {@link Privacy.PrivacySettings#FRIENDS_OF_FRIENDS
* FRIENDS_OF_FRIENDS} to include all members of those sets.
* @throws UnsupportedOperationException
* in case of using other values than
* {@link Privacy.PrivacySettings#ALL_FRIENDS ALL_FRIENDS} or
* {@link Privacy.PrivacySettings#FRIENDS_OF_FRIENDS
* FRIENDS_OF_FRIENDS}
*/
public Builder addAllowed(PrivacySettings privacySettings) {
validateListsAccessRequest();
if (privacySettings != PrivacySettings.ALL_FRIENDS || privacySettings != PrivacySettings.FRIENDS_OF_FRIENDS) {
UnsupportedOperationException exception = new UnsupportedOperationException("Can't add this predefined friend list. Only allowed are: ALL_FRIENDS or FRIENDS_OF_FRIENDS");
|
Logger.logError(Privacy.class, "failed to add allowed users", exception);
|
WassimBenltaief/ReactiveFB
|
app/src/main/java/com/beltaief/reactivefbexample/models/Privacy.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Logger.java
// public final class Logger {
//
// private static boolean DEBUG = false;
// private static boolean DEBUG_WITH_STACKTRACE = false;
//
// private Logger() {
// }
//
// public static <T> void logInfo(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.i(tag, "-----");
// Log.i(tag, LogType.INFO + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.i(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logWarning(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.w(tag, "-----");
// Log.w(tag, LogType.WARNING + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.w(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logError(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.e(tag, "-----");
// Log.e(tag, LogType.ERROR + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.e(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logError(Class<T> cls, String message, Throwable e) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.e(tag, "-----");
// Log.e(tag, LogType.ERROR + ": " + message, e);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.e(tag, getStackTrace());
// }
// }
// }
//
// private enum LogType {
// INFO,
// WARNING,
// ERROR
// }
//
// private static String getStackTrace() {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// new Throwable().printStackTrace(pw);
// return sw.toString();
// }
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Utils.java
// public final class Utils {
// private Utils() {
// }
//
// public static Bundle getBundle(String mFields, int limit) {
// Bundle bundle = new Bundle();
// if (mFields != null) {
// bundle.putString("fields", mFields);
// }
// if (limit > 0) {
// bundle.putString("limit", String.valueOf(limit));
// }
// return bundle;
// }
//
// @SuppressWarnings("resource")
// public static String encode(String key, String data) {
// try {
// Mac mac = Mac.getInstance("HmacSHA256");
// SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "HmacSHA256");
// mac.init(secretKey);
// byte[] bytes = mac.doFinal(data.getBytes());
// StringBuilder sb = new StringBuilder(bytes.length * 2);
// Formatter formatter = new Formatter(sb);
// for (byte b : bytes) {
// formatter.format("%02x", b);
// }
// return sb.toString();
// } catch (Exception e) {
// Logger.logError(Utils.class, "Failed to create sha256", e);
// return null;
// }
// }
// }
|
import com.beltaief.reactivefb.util.Logger;
import com.beltaief.reactivefb.util.Utils;
import com.google.gson.annotations.SerializedName;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Collection;
|
/**
* Validates that the allowed / denied lists can be accessed.<br/>
* In case you use a predefined privacy setting different than
* {@link Privacy.PrivacySettings#CUSTOM CUSTOM}, you <b>must not</b> use the
* custom lists.
*/
private void validateListsAccessRequest() {
if (mPrivacySetting != PrivacySettings.CUSTOM) {
Logger.logWarning(Privacy.class, "Can't add / delete from allowed / " +
"denied lists when privacy setting is different than \"CUSTOM\"");
mPrivacySetting = PrivacySettings.CUSTOM;
}
}
}
/**
* Returns the {@code JSON} representation that should be used as the value
* of the privacy parameter<br/>
* in the entities that have privacy settings.
*
* @return A {@code String} representing the value of the privacy parameter
*/
public String getJSONString() {
JSONObject jsonRepresentation = new JSONObject();
try {
jsonRepresentation.put(PRIVACY, mPrivacySetting.name());
if (mPrivacySetting == PrivacySettings.CUSTOM) {
if (!mAllowedUsers.isEmpty()) {
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Logger.java
// public final class Logger {
//
// private static boolean DEBUG = false;
// private static boolean DEBUG_WITH_STACKTRACE = false;
//
// private Logger() {
// }
//
// public static <T> void logInfo(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.i(tag, "-----");
// Log.i(tag, LogType.INFO + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.i(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logWarning(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.w(tag, "-----");
// Log.w(tag, LogType.WARNING + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.w(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logError(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.e(tag, "-----");
// Log.e(tag, LogType.ERROR + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.e(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logError(Class<T> cls, String message, Throwable e) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.e(tag, "-----");
// Log.e(tag, LogType.ERROR + ": " + message, e);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.e(tag, getStackTrace());
// }
// }
// }
//
// private enum LogType {
// INFO,
// WARNING,
// ERROR
// }
//
// private static String getStackTrace() {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// new Throwable().printStackTrace(pw);
// return sw.toString();
// }
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Utils.java
// public final class Utils {
// private Utils() {
// }
//
// public static Bundle getBundle(String mFields, int limit) {
// Bundle bundle = new Bundle();
// if (mFields != null) {
// bundle.putString("fields", mFields);
// }
// if (limit > 0) {
// bundle.putString("limit", String.valueOf(limit));
// }
// return bundle;
// }
//
// @SuppressWarnings("resource")
// public static String encode(String key, String data) {
// try {
// Mac mac = Mac.getInstance("HmacSHA256");
// SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "HmacSHA256");
// mac.init(secretKey);
// byte[] bytes = mac.doFinal(data.getBytes());
// StringBuilder sb = new StringBuilder(bytes.length * 2);
// Formatter formatter = new Formatter(sb);
// for (byte b : bytes) {
// formatter.format("%02x", b);
// }
// return sb.toString();
// } catch (Exception e) {
// Logger.logError(Utils.class, "Failed to create sha256", e);
// return null;
// }
// }
// }
// Path: app/src/main/java/com/beltaief/reactivefbexample/models/Privacy.java
import com.beltaief.reactivefb.util.Logger;
import com.beltaief.reactivefb.util.Utils;
import com.google.gson.annotations.SerializedName;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Collection;
/**
* Validates that the allowed / denied lists can be accessed.<br/>
* In case you use a predefined privacy setting different than
* {@link Privacy.PrivacySettings#CUSTOM CUSTOM}, you <b>must not</b> use the
* custom lists.
*/
private void validateListsAccessRequest() {
if (mPrivacySetting != PrivacySettings.CUSTOM) {
Logger.logWarning(Privacy.class, "Can't add / delete from allowed / " +
"denied lists when privacy setting is different than \"CUSTOM\"");
mPrivacySetting = PrivacySettings.CUSTOM;
}
}
}
/**
* Returns the {@code JSON} representation that should be used as the value
* of the privacy parameter<br/>
* in the entities that have privacy settings.
*
* @return A {@code String} representing the value of the privacy parameter
*/
public String getJSONString() {
JSONObject jsonRepresentation = new JSONObject();
try {
jsonRepresentation.put(PRIVACY, mPrivacySetting.name());
if (mPrivacySetting == PrivacySettings.CUSTOM) {
if (!mAllowedUsers.isEmpty()) {
|
jsonRepresentation.put(ALLOW, Utils.join(mAllowedUsers.iterator(), ","));
|
WassimBenltaief/ReactiveFB
|
app/src/main/java/com/beltaief/reactivefbexample/views/LoginActivity.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/actions/ReactiveLogin.java
// public final class ReactiveLogin {
//
// /**
// * Login with com.facebook.login.LoginManager
// * The reason why this method returns a MayBe is that when a user cancel the operation, it
// * does not emit any value neither an error. Maybe have a onComplete method that is covering
// * this case.
// * Use onSuccess to handle a success result.
// * Use onComplete to handle canceled operation.
// *
// * @param activity instance of the current activity
// * @return a Maybe of LoginResult
// */
// @NonNull
// public static Maybe<LoginResult> login(@NonNull final Activity activity) {
// checkNotNull(activity, "activity == null");
// // save a weak reference to the activity
// ReactiveFB.getSessionManager().setActivity(activity);
// // login
// return Maybe.create(new LoginOnSubscribe());
// }
//
// /**
// * Login with com.facebook.login.widget.LoginButton
// * To be called from an Activity.
// * The reason why it's returning an Observable and not a MayBe like login() is that with MayBe
// * the subscribtion is done only one time. We need an observable in order to subscribe
// * continuously.
// *
// * @param loginButton instance of a com.facebook.login.widget.LoginButton
// * @return an Observable of LoginResult
// */
// @NonNull
// public static Observable<LoginResult> loginWithButton(@NonNull final LoginButton loginButton) {
//
// checkNotNull(loginButton, "loginButton == null");
// ReactiveFB.checkInit();
// // login
// return Observable.create(new LoginWithButtonOnSubscribe(loginButton));
// }
//
// /**
// * Login with com.facebook.login.widget.LoginButton
// * To be called from an android.support.v4.app.Fragment
// *
// * @param loginButton instance of a com.facebook.login.widget.LoginButton
// * @param fragment instance of support android.support.v4.app.Fragment
// * @return
// */
// @NonNull
// public static Observable<LoginResult> loginWithButton(@NonNull final LoginButton loginButton,
// @NonNull final Fragment fragment) {
//
// checkNotNull(fragment, "fragment == null");
// checkNotNull(loginButton, "loginButton == null");
// ReactiveFB.checkInit();
// // login
// return Observable.create(new LoginWithButtonOnSubscribe(loginButton));
// }
//
// /**
// * Login with com.facebook.login.widget.LoginButton
// * To be called from an android.app.Fragment
// *
// * @param loginButton instance of com.facebook.login.widget.LoginButton
// * @param fragment instance of android.app.Fragment
// * @return
// */
// @NonNull
// public static Observable<LoginResult> loginWithButton(@NonNull final LoginButton loginButton,
// @NonNull final android.app.Fragment fragment) {
//
// checkNotNull(fragment, "fragment == null");
// checkNotNull(loginButton, "loginButton == null");
// ReactiveFB.checkInit();
// // login
// return Observable.create(new LoginWithButtonOnSubscribe(loginButton));
// }
//
//
// /**
// * Redirect facebook callback onActivityResult to this library callback.
// * This is necessary with login/ loginWithButton methods.
// *
// * @param requestCode
// * @param resultCode
// * @param data
// */
// public static void onActivityResult(int requestCode, int resultCode, Intent data) {
// ReactiveFB.getSessionManager()
// .getCallbackManager()
// .onActivityResult(requestCode, resultCode, data);
// }
//
// /**
// * Request additional permissions from facebook. This launches a new login with additional
// * permissions.
// *
// * @param permissions List of {@link PermissionHelper}
// * @param activity current activity instance
// * @return a Maybe of LoginResult.
// */
// public static Maybe<LoginResult> requestAdditionalPermission(@NonNull final List<PermissionHelper> permissions,
// @NonNull final Activity activity) {
//
// checkNotNull(permissions, "permissions == null");
// checkNotNull(activity, "activity == null");
//
// ReactiveFB.getSessionManager().setActivity(activity);
//
// return Maybe.create(new AdditionalPermissionOnSubscribe(permissions));
// }
//
// private ReactiveLogin() {
// throw new AssertionError("No instances.");
// }
// }
|
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.beltaief.reactivefb.actions.ReactiveLogin;
import com.beltaief.reactivefbexample.R;
import com.facebook.login.LoginResult;
import io.reactivex.MaybeObserver;
import io.reactivex.disposables.Disposable;
|
package com.beltaief.reactivefbexample.views;
public class LoginActivity extends AppCompatActivity {
private static final String TAG = LoginActivity.class.getSimpleName();
private TextView result;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
Button button = (Button) findViewById(R.id.button);
result = (TextView) findViewById(R.id.result);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
login();
}
});
}
/**
* call login returns a MaybeObserver<LoginResult>
* onSuccess : returns a LoginResult
* onError : returns a FacebookException
* onComplete : called when a login terminates with no result, like onCanceled.
*/
private void login() {
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/actions/ReactiveLogin.java
// public final class ReactiveLogin {
//
// /**
// * Login with com.facebook.login.LoginManager
// * The reason why this method returns a MayBe is that when a user cancel the operation, it
// * does not emit any value neither an error. Maybe have a onComplete method that is covering
// * this case.
// * Use onSuccess to handle a success result.
// * Use onComplete to handle canceled operation.
// *
// * @param activity instance of the current activity
// * @return a Maybe of LoginResult
// */
// @NonNull
// public static Maybe<LoginResult> login(@NonNull final Activity activity) {
// checkNotNull(activity, "activity == null");
// // save a weak reference to the activity
// ReactiveFB.getSessionManager().setActivity(activity);
// // login
// return Maybe.create(new LoginOnSubscribe());
// }
//
// /**
// * Login with com.facebook.login.widget.LoginButton
// * To be called from an Activity.
// * The reason why it's returning an Observable and not a MayBe like login() is that with MayBe
// * the subscribtion is done only one time. We need an observable in order to subscribe
// * continuously.
// *
// * @param loginButton instance of a com.facebook.login.widget.LoginButton
// * @return an Observable of LoginResult
// */
// @NonNull
// public static Observable<LoginResult> loginWithButton(@NonNull final LoginButton loginButton) {
//
// checkNotNull(loginButton, "loginButton == null");
// ReactiveFB.checkInit();
// // login
// return Observable.create(new LoginWithButtonOnSubscribe(loginButton));
// }
//
// /**
// * Login with com.facebook.login.widget.LoginButton
// * To be called from an android.support.v4.app.Fragment
// *
// * @param loginButton instance of a com.facebook.login.widget.LoginButton
// * @param fragment instance of support android.support.v4.app.Fragment
// * @return
// */
// @NonNull
// public static Observable<LoginResult> loginWithButton(@NonNull final LoginButton loginButton,
// @NonNull final Fragment fragment) {
//
// checkNotNull(fragment, "fragment == null");
// checkNotNull(loginButton, "loginButton == null");
// ReactiveFB.checkInit();
// // login
// return Observable.create(new LoginWithButtonOnSubscribe(loginButton));
// }
//
// /**
// * Login with com.facebook.login.widget.LoginButton
// * To be called from an android.app.Fragment
// *
// * @param loginButton instance of com.facebook.login.widget.LoginButton
// * @param fragment instance of android.app.Fragment
// * @return
// */
// @NonNull
// public static Observable<LoginResult> loginWithButton(@NonNull final LoginButton loginButton,
// @NonNull final android.app.Fragment fragment) {
//
// checkNotNull(fragment, "fragment == null");
// checkNotNull(loginButton, "loginButton == null");
// ReactiveFB.checkInit();
// // login
// return Observable.create(new LoginWithButtonOnSubscribe(loginButton));
// }
//
//
// /**
// * Redirect facebook callback onActivityResult to this library callback.
// * This is necessary with login/ loginWithButton methods.
// *
// * @param requestCode
// * @param resultCode
// * @param data
// */
// public static void onActivityResult(int requestCode, int resultCode, Intent data) {
// ReactiveFB.getSessionManager()
// .getCallbackManager()
// .onActivityResult(requestCode, resultCode, data);
// }
//
// /**
// * Request additional permissions from facebook. This launches a new login with additional
// * permissions.
// *
// * @param permissions List of {@link PermissionHelper}
// * @param activity current activity instance
// * @return a Maybe of LoginResult.
// */
// public static Maybe<LoginResult> requestAdditionalPermission(@NonNull final List<PermissionHelper> permissions,
// @NonNull final Activity activity) {
//
// checkNotNull(permissions, "permissions == null");
// checkNotNull(activity, "activity == null");
//
// ReactiveFB.getSessionManager().setActivity(activity);
//
// return Maybe.create(new AdditionalPermissionOnSubscribe(permissions));
// }
//
// private ReactiveLogin() {
// throw new AssertionError("No instances.");
// }
// }
// Path: app/src/main/java/com/beltaief/reactivefbexample/views/LoginActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.beltaief.reactivefb.actions.ReactiveLogin;
import com.beltaief.reactivefbexample.R;
import com.facebook.login.LoginResult;
import io.reactivex.MaybeObserver;
import io.reactivex.disposables.Disposable;
package com.beltaief.reactivefbexample.views;
public class LoginActivity extends AppCompatActivity {
private static final String TAG = LoginActivity.class.getSimpleName();
private TextView result;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
Button button = (Button) findViewById(R.id.button);
result = (TextView) findViewById(R.id.result);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
login();
}
});
}
/**
* call login returns a MaybeObserver<LoginResult>
* onSuccess : returns a LoginResult
* onError : returns a FacebookException
* onComplete : called when a login terminates with no result, like onCanceled.
*/
private void login() {
|
ReactiveLogin.login(this).subscribe(new MaybeObserver<LoginResult>() {
|
WassimBenltaief/ReactiveFB
|
app/src/main/java/com/beltaief/reactivefbexample/models/Profile.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Attributes.java
// public abstract class Attributes {
//
// protected Map<String, String> attributes = new HashMap<String, String>();
// public Map<String, String> getAttributes() {
// return attributes;
// }
//
// /**
// * Create picture attributes
// *
// * @return {@link PictureAttributes}
// */
// public static PictureAttributes createPictureAttributes() {
// return new PictureAttributes();
// }
//
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Utils.java
// public final class Utils {
// private Utils() {
// }
//
// public static Bundle getBundle(String mFields, int limit) {
// Bundle bundle = new Bundle();
// if (mFields != null) {
// bundle.putString("fields", mFields);
// }
// if (limit > 0) {
// bundle.putString("limit", String.valueOf(limit));
// }
// return bundle;
// }
//
// @SuppressWarnings("resource")
// public static String encode(String key, String data) {
// try {
// Mac mac = Mac.getInstance("HmacSHA256");
// SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "HmacSHA256");
// mac.init(secretKey);
// byte[] bytes = mac.doFinal(data.getBytes());
// StringBuilder sb = new StringBuilder(bytes.length * 2);
// Formatter formatter = new Formatter(sb);
// for (byte b : bytes) {
// formatter.format("%02x", b);
// }
// return sb.toString();
// } catch (Exception e) {
// Logger.logError(Utils.class, "Failed to create sha256", e);
// return null;
// }
// }
// }
|
import android.os.Bundle;
import com.beltaief.reactivefb.util.Attributes;
import com.beltaief.reactivefb.util.Utils;
import com.google.gson.annotations.SerializedName;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
|
private String mBirthday;
@SerializedName(Properties.COVER)
private Photo mCover;
@SerializedName(Properties.CURRENCY)
private String mCurrency;
@SerializedName(Properties.EDUCATION)
private List<Education> mEducation;
@SerializedName(Properties.EMAIL)
private String mEmail;
@SerializedName(Properties.HOMETOWN)
private IdName mHometown;
@SerializedName(Properties.LOCATION)
private IdName mCurrentLocation;
@SerializedName(Properties.POLITICAL)
private String mPolitical;
@SerializedName(Properties.FAVORITE_ATHLETES)
private List<String> mFavoriteAthletes;
@SerializedName(Properties.FAVORITE_TEAMS)
private List<String> mFavoriteTeams;
@SerializedName(Properties.PICTURE)
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Attributes.java
// public abstract class Attributes {
//
// protected Map<String, String> attributes = new HashMap<String, String>();
// public Map<String, String> getAttributes() {
// return attributes;
// }
//
// /**
// * Create picture attributes
// *
// * @return {@link PictureAttributes}
// */
// public static PictureAttributes createPictureAttributes() {
// return new PictureAttributes();
// }
//
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Utils.java
// public final class Utils {
// private Utils() {
// }
//
// public static Bundle getBundle(String mFields, int limit) {
// Bundle bundle = new Bundle();
// if (mFields != null) {
// bundle.putString("fields", mFields);
// }
// if (limit > 0) {
// bundle.putString("limit", String.valueOf(limit));
// }
// return bundle;
// }
//
// @SuppressWarnings("resource")
// public static String encode(String key, String data) {
// try {
// Mac mac = Mac.getInstance("HmacSHA256");
// SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "HmacSHA256");
// mac.init(secretKey);
// byte[] bytes = mac.doFinal(data.getBytes());
// StringBuilder sb = new StringBuilder(bytes.length * 2);
// Formatter formatter = new Formatter(sb);
// for (byte b : bytes) {
// formatter.format("%02x", b);
// }
// return sb.toString();
// } catch (Exception e) {
// Logger.logError(Utils.class, "Failed to create sha256", e);
// return null;
// }
// }
// }
// Path: app/src/main/java/com/beltaief/reactivefbexample/models/Profile.java
import android.os.Bundle;
import com.beltaief.reactivefb.util.Attributes;
import com.beltaief.reactivefb.util.Utils;
import com.google.gson.annotations.SerializedName;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
private String mBirthday;
@SerializedName(Properties.COVER)
private Photo mCover;
@SerializedName(Properties.CURRENCY)
private String mCurrency;
@SerializedName(Properties.EDUCATION)
private List<Education> mEducation;
@SerializedName(Properties.EMAIL)
private String mEmail;
@SerializedName(Properties.HOMETOWN)
private IdName mHometown;
@SerializedName(Properties.LOCATION)
private IdName mCurrentLocation;
@SerializedName(Properties.POLITICAL)
private String mPolitical;
@SerializedName(Properties.FAVORITE_ATHLETES)
private List<String> mFavoriteAthletes;
@SerializedName(Properties.FAVORITE_TEAMS)
private List<String> mFavoriteTeams;
@SerializedName(Properties.PICTURE)
|
private Utils.SingleDataResult<Image> mPicture;
|
WassimBenltaief/ReactiveFB
|
app/src/main/java/com/beltaief/reactivefbexample/models/Profile.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Attributes.java
// public abstract class Attributes {
//
// protected Map<String, String> attributes = new HashMap<String, String>();
// public Map<String, String> getAttributes() {
// return attributes;
// }
//
// /**
// * Create picture attributes
// *
// * @return {@link PictureAttributes}
// */
// public static PictureAttributes createPictureAttributes() {
// return new PictureAttributes();
// }
//
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Utils.java
// public final class Utils {
// private Utils() {
// }
//
// public static Bundle getBundle(String mFields, int limit) {
// Bundle bundle = new Bundle();
// if (mFields != null) {
// bundle.putString("fields", mFields);
// }
// if (limit > 0) {
// bundle.putString("limit", String.valueOf(limit));
// }
// return bundle;
// }
//
// @SuppressWarnings("resource")
// public static String encode(String key, String data) {
// try {
// Mac mac = Mac.getInstance("HmacSHA256");
// SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "HmacSHA256");
// mac.init(secretKey);
// byte[] bytes = mac.doFinal(data.getBytes());
// StringBuilder sb = new StringBuilder(bytes.length * 2);
// Formatter formatter = new Formatter(sb);
// for (byte b : bytes) {
// formatter.format("%02x", b);
// }
// return sb.toString();
// } catch (Exception e) {
// Logger.logError(Utils.class, "Failed to create sha256", e);
// return null;
// }
// }
// }
|
import android.os.Bundle;
import com.beltaief.reactivefb.util.Attributes;
import com.beltaief.reactivefb.util.Utils;
import com.google.gson.annotations.SerializedName;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
|
Set<String> properties;
public Builder() {
properties = new HashSet<String>();
}
/**
* Add property you need
*
* @param property
* The property of the user profile<br>
* For example: {@link Profile.Properties#FIRST_NAME}
* @return {@link Profile.Properties.Builder}
*/
public Builder add(String property) {
properties.add(property);
return this;
}
/**
* Add property and attribute you need
*
* @param property
* The property of the user profile<br>
* For example: {@link Profile.Properties#PICTURE}
* @param attributes
* For example: picture can have type,width and height<br>
*
* @return {@link Profile.Properties.Builder}
*/
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Attributes.java
// public abstract class Attributes {
//
// protected Map<String, String> attributes = new HashMap<String, String>();
// public Map<String, String> getAttributes() {
// return attributes;
// }
//
// /**
// * Create picture attributes
// *
// * @return {@link PictureAttributes}
// */
// public static PictureAttributes createPictureAttributes() {
// return new PictureAttributes();
// }
//
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Utils.java
// public final class Utils {
// private Utils() {
// }
//
// public static Bundle getBundle(String mFields, int limit) {
// Bundle bundle = new Bundle();
// if (mFields != null) {
// bundle.putString("fields", mFields);
// }
// if (limit > 0) {
// bundle.putString("limit", String.valueOf(limit));
// }
// return bundle;
// }
//
// @SuppressWarnings("resource")
// public static String encode(String key, String data) {
// try {
// Mac mac = Mac.getInstance("HmacSHA256");
// SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "HmacSHA256");
// mac.init(secretKey);
// byte[] bytes = mac.doFinal(data.getBytes());
// StringBuilder sb = new StringBuilder(bytes.length * 2);
// Formatter formatter = new Formatter(sb);
// for (byte b : bytes) {
// formatter.format("%02x", b);
// }
// return sb.toString();
// } catch (Exception e) {
// Logger.logError(Utils.class, "Failed to create sha256", e);
// return null;
// }
// }
// }
// Path: app/src/main/java/com/beltaief/reactivefbexample/models/Profile.java
import android.os.Bundle;
import com.beltaief.reactivefb.util.Attributes;
import com.beltaief.reactivefb.util.Utils;
import com.google.gson.annotations.SerializedName;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
Set<String> properties;
public Builder() {
properties = new HashSet<String>();
}
/**
* Add property you need
*
* @param property
* The property of the user profile<br>
* For example: {@link Profile.Properties#FIRST_NAME}
* @return {@link Profile.Properties.Builder}
*/
public Builder add(String property) {
properties.add(property);
return this;
}
/**
* Add property and attribute you need
*
* @param property
* The property of the user profile<br>
* For example: {@link Profile.Properties#PICTURE}
* @param attributes
* For example: picture can have type,width and height<br>
*
* @return {@link Profile.Properties.Builder}
*/
|
public Builder add(String property, Attributes attributes) {
|
WassimBenltaief/ReactiveFB
|
reactivefb/src/main/java/com/beltaief/reactivefb/requests/ReactiveRequest.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/ReactiveFB.java
// public class ReactiveFB {
//
// private static ReactiveFB mInstance = null;
// private static SimpleFacebookConfiguration mConfiguration =
// new SimpleFacebookConfiguration.Builder().build();
// private static SessionManager mSessionManager = null;
//
// public static void sdkInitialize(Context context) {
// if (mInstance == null) {
// Class clazz = ReactiveFB.class;
// synchronized (clazz) {
// mInstance = new ReactiveFB();
// }
// FacebookSdk.sdkInitialize(context);
// mSessionManager = new SessionManager(mConfiguration);
// }
// }
//
// public static void checkInit() {
// if (!FacebookSdk.isInitialized()) {
// throw new RuntimeException("ReactiveFB not initialized. Are you missing " +
// "ReactiveFB.sdkInitialize(context) ?");
// }
// }
//
// public static SessionManager getSessionManager() {
// return mSessionManager;
// }
//
// public static SimpleFacebookConfiguration getConfiguration() {
// return mConfiguration;
// }
//
// public static void setConfiguration(SimpleFacebookConfiguration configuration) {
// mConfiguration = configuration;
// }
//
// public static boolean checkPermission(PermissionHelper permission) {
// return AccessToken.getCurrentAccessToken().getPermissions().contains(permission.getValue());
// }
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/GraphPath.java
// public class GraphPath {
//
// public static final String ME = "me";
// public static final String ATTACHMENTS = "attachments";
// public static final String FRIENDS = "friends";
// public static final String TAGGABLE_FRIENDS = "taggable_friends";
// public static final String INVITABLE_FRIENDS = "invitable_friends";
// public static final String ALBUMS = "albums";
// public static final String SCORES = "scores";
// public static final String APPREQUESTS = "apprequests";
// public static final String FEED = "feed";
// public static final String PHOTOS = "photos";
// public static final String VIDEOS = "videos";
// public static final String EVENTS = "events";
// public static final String GROUPS = "groups";
// public static final String POSTS = "posts";
// public static final String COMMENTS = "comments";
// public static final String LIKES = "likes";
// public static final String LINKS = "links";
// public static final String STATUSES = "statuses";
// public static final String TAGGED = "tagged";
// public static final String TAGGED_PLACES = "tagged_places";
// public static final String ACCOUNTS = "accounts";
// public static final String BOOKS = "books";
// public static final String MUSIC = "music";
// public static final String FAMILY = "family";
// public static final String MOVIES = "movies";
// public static final String GAMES = "games";
// public static final Object NOTIFICATIONS = "notifications";
// public static final String TELEVISION = "television";
// public static final String OBJECTS = "objects";
// }
|
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.beltaief.reactivefb.ReactiveFB;
import com.beltaief.reactivefb.util.GraphPath;
import com.facebook.GraphResponse;
import io.reactivex.Single;
|
package com.beltaief.reactivefb.requests;
/**
* Factory class for GraphRequest methods
* Created by wassim on 9/16/16.
*/
public class ReactiveRequest {
/**
* Get the profile of the logged in user
*
* @return a single of GraphResponse representing a Profile model.
*/
@NonNull
public static Single<GraphResponse> getMe() {
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/ReactiveFB.java
// public class ReactiveFB {
//
// private static ReactiveFB mInstance = null;
// private static SimpleFacebookConfiguration mConfiguration =
// new SimpleFacebookConfiguration.Builder().build();
// private static SessionManager mSessionManager = null;
//
// public static void sdkInitialize(Context context) {
// if (mInstance == null) {
// Class clazz = ReactiveFB.class;
// synchronized (clazz) {
// mInstance = new ReactiveFB();
// }
// FacebookSdk.sdkInitialize(context);
// mSessionManager = new SessionManager(mConfiguration);
// }
// }
//
// public static void checkInit() {
// if (!FacebookSdk.isInitialized()) {
// throw new RuntimeException("ReactiveFB not initialized. Are you missing " +
// "ReactiveFB.sdkInitialize(context) ?");
// }
// }
//
// public static SessionManager getSessionManager() {
// return mSessionManager;
// }
//
// public static SimpleFacebookConfiguration getConfiguration() {
// return mConfiguration;
// }
//
// public static void setConfiguration(SimpleFacebookConfiguration configuration) {
// mConfiguration = configuration;
// }
//
// public static boolean checkPermission(PermissionHelper permission) {
// return AccessToken.getCurrentAccessToken().getPermissions().contains(permission.getValue());
// }
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/GraphPath.java
// public class GraphPath {
//
// public static final String ME = "me";
// public static final String ATTACHMENTS = "attachments";
// public static final String FRIENDS = "friends";
// public static final String TAGGABLE_FRIENDS = "taggable_friends";
// public static final String INVITABLE_FRIENDS = "invitable_friends";
// public static final String ALBUMS = "albums";
// public static final String SCORES = "scores";
// public static final String APPREQUESTS = "apprequests";
// public static final String FEED = "feed";
// public static final String PHOTOS = "photos";
// public static final String VIDEOS = "videos";
// public static final String EVENTS = "events";
// public static final String GROUPS = "groups";
// public static final String POSTS = "posts";
// public static final String COMMENTS = "comments";
// public static final String LIKES = "likes";
// public static final String LINKS = "links";
// public static final String STATUSES = "statuses";
// public static final String TAGGED = "tagged";
// public static final String TAGGED_PLACES = "tagged_places";
// public static final String ACCOUNTS = "accounts";
// public static final String BOOKS = "books";
// public static final String MUSIC = "music";
// public static final String FAMILY = "family";
// public static final String MOVIES = "movies";
// public static final String GAMES = "games";
// public static final Object NOTIFICATIONS = "notifications";
// public static final String TELEVISION = "television";
// public static final String OBJECTS = "objects";
// }
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/requests/ReactiveRequest.java
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.beltaief.reactivefb.ReactiveFB;
import com.beltaief.reactivefb.util.GraphPath;
import com.facebook.GraphResponse;
import io.reactivex.Single;
package com.beltaief.reactivefb.requests;
/**
* Factory class for GraphRequest methods
* Created by wassim on 9/16/16.
*/
public class ReactiveRequest {
/**
* Get the profile of the logged in user
*
* @return a single of GraphResponse representing a Profile model.
*/
@NonNull
public static Single<GraphResponse> getMe() {
|
ReactiveFB.checkInit();
|
WassimBenltaief/ReactiveFB
|
reactivefb/src/main/java/com/beltaief/reactivefb/requests/ReactiveRequest.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/ReactiveFB.java
// public class ReactiveFB {
//
// private static ReactiveFB mInstance = null;
// private static SimpleFacebookConfiguration mConfiguration =
// new SimpleFacebookConfiguration.Builder().build();
// private static SessionManager mSessionManager = null;
//
// public static void sdkInitialize(Context context) {
// if (mInstance == null) {
// Class clazz = ReactiveFB.class;
// synchronized (clazz) {
// mInstance = new ReactiveFB();
// }
// FacebookSdk.sdkInitialize(context);
// mSessionManager = new SessionManager(mConfiguration);
// }
// }
//
// public static void checkInit() {
// if (!FacebookSdk.isInitialized()) {
// throw new RuntimeException("ReactiveFB not initialized. Are you missing " +
// "ReactiveFB.sdkInitialize(context) ?");
// }
// }
//
// public static SessionManager getSessionManager() {
// return mSessionManager;
// }
//
// public static SimpleFacebookConfiguration getConfiguration() {
// return mConfiguration;
// }
//
// public static void setConfiguration(SimpleFacebookConfiguration configuration) {
// mConfiguration = configuration;
// }
//
// public static boolean checkPermission(PermissionHelper permission) {
// return AccessToken.getCurrentAccessToken().getPermissions().contains(permission.getValue());
// }
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/GraphPath.java
// public class GraphPath {
//
// public static final String ME = "me";
// public static final String ATTACHMENTS = "attachments";
// public static final String FRIENDS = "friends";
// public static final String TAGGABLE_FRIENDS = "taggable_friends";
// public static final String INVITABLE_FRIENDS = "invitable_friends";
// public static final String ALBUMS = "albums";
// public static final String SCORES = "scores";
// public static final String APPREQUESTS = "apprequests";
// public static final String FEED = "feed";
// public static final String PHOTOS = "photos";
// public static final String VIDEOS = "videos";
// public static final String EVENTS = "events";
// public static final String GROUPS = "groups";
// public static final String POSTS = "posts";
// public static final String COMMENTS = "comments";
// public static final String LIKES = "likes";
// public static final String LINKS = "links";
// public static final String STATUSES = "statuses";
// public static final String TAGGED = "tagged";
// public static final String TAGGED_PLACES = "tagged_places";
// public static final String ACCOUNTS = "accounts";
// public static final String BOOKS = "books";
// public static final String MUSIC = "music";
// public static final String FAMILY = "family";
// public static final String MOVIES = "movies";
// public static final String GAMES = "games";
// public static final Object NOTIFICATIONS = "notifications";
// public static final String TELEVISION = "television";
// public static final String OBJECTS = "objects";
// }
|
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.beltaief.reactivefb.ReactiveFB;
import com.beltaief.reactivefb.util.GraphPath;
import com.facebook.GraphResponse;
import io.reactivex.Single;
|
package com.beltaief.reactivefb.requests;
/**
* Factory class for GraphRequest methods
* Created by wassim on 9/16/16.
*/
public class ReactiveRequest {
/**
* Get the profile of the logged in user
*
* @return a single of GraphResponse representing a Profile model.
*/
@NonNull
public static Single<GraphResponse> getMe() {
ReactiveFB.checkInit();
// getProfile
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/ReactiveFB.java
// public class ReactiveFB {
//
// private static ReactiveFB mInstance = null;
// private static SimpleFacebookConfiguration mConfiguration =
// new SimpleFacebookConfiguration.Builder().build();
// private static SessionManager mSessionManager = null;
//
// public static void sdkInitialize(Context context) {
// if (mInstance == null) {
// Class clazz = ReactiveFB.class;
// synchronized (clazz) {
// mInstance = new ReactiveFB();
// }
// FacebookSdk.sdkInitialize(context);
// mSessionManager = new SessionManager(mConfiguration);
// }
// }
//
// public static void checkInit() {
// if (!FacebookSdk.isInitialized()) {
// throw new RuntimeException("ReactiveFB not initialized. Are you missing " +
// "ReactiveFB.sdkInitialize(context) ?");
// }
// }
//
// public static SessionManager getSessionManager() {
// return mSessionManager;
// }
//
// public static SimpleFacebookConfiguration getConfiguration() {
// return mConfiguration;
// }
//
// public static void setConfiguration(SimpleFacebookConfiguration configuration) {
// mConfiguration = configuration;
// }
//
// public static boolean checkPermission(PermissionHelper permission) {
// return AccessToken.getCurrentAccessToken().getPermissions().contains(permission.getValue());
// }
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/GraphPath.java
// public class GraphPath {
//
// public static final String ME = "me";
// public static final String ATTACHMENTS = "attachments";
// public static final String FRIENDS = "friends";
// public static final String TAGGABLE_FRIENDS = "taggable_friends";
// public static final String INVITABLE_FRIENDS = "invitable_friends";
// public static final String ALBUMS = "albums";
// public static final String SCORES = "scores";
// public static final String APPREQUESTS = "apprequests";
// public static final String FEED = "feed";
// public static final String PHOTOS = "photos";
// public static final String VIDEOS = "videos";
// public static final String EVENTS = "events";
// public static final String GROUPS = "groups";
// public static final String POSTS = "posts";
// public static final String COMMENTS = "comments";
// public static final String LIKES = "likes";
// public static final String LINKS = "links";
// public static final String STATUSES = "statuses";
// public static final String TAGGED = "tagged";
// public static final String TAGGED_PLACES = "tagged_places";
// public static final String ACCOUNTS = "accounts";
// public static final String BOOKS = "books";
// public static final String MUSIC = "music";
// public static final String FAMILY = "family";
// public static final String MOVIES = "movies";
// public static final String GAMES = "games";
// public static final Object NOTIFICATIONS = "notifications";
// public static final String TELEVISION = "television";
// public static final String OBJECTS = "objects";
// }
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/requests/ReactiveRequest.java
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.beltaief.reactivefb.ReactiveFB;
import com.beltaief.reactivefb.util.GraphPath;
import com.facebook.GraphResponse;
import io.reactivex.Single;
package com.beltaief.reactivefb.requests;
/**
* Factory class for GraphRequest methods
* Created by wassim on 9/16/16.
*/
public class ReactiveRequest {
/**
* Get the profile of the logged in user
*
* @return a single of GraphResponse representing a Profile model.
*/
@NonNull
public static Single<GraphResponse> getMe() {
ReactiveFB.checkInit();
// getProfile
|
return Single.create(new RequestOnSubscribe(GraphPath.ME, null, null, 0));
|
WassimBenltaief/ReactiveFB
|
app/src/main/java/com/beltaief/reactivefbexample/models/Album.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/GraphPath.java
// public class GraphPath {
//
// public static final String ME = "me";
// public static final String ATTACHMENTS = "attachments";
// public static final String FRIENDS = "friends";
// public static final String TAGGABLE_FRIENDS = "taggable_friends";
// public static final String INVITABLE_FRIENDS = "invitable_friends";
// public static final String ALBUMS = "albums";
// public static final String SCORES = "scores";
// public static final String APPREQUESTS = "apprequests";
// public static final String FEED = "feed";
// public static final String PHOTOS = "photos";
// public static final String VIDEOS = "videos";
// public static final String EVENTS = "events";
// public static final String GROUPS = "groups";
// public static final String POSTS = "posts";
// public static final String COMMENTS = "comments";
// public static final String LIKES = "likes";
// public static final String LINKS = "links";
// public static final String STATUSES = "statuses";
// public static final String TAGGED = "tagged";
// public static final String TAGGED_PLACES = "tagged_places";
// public static final String ACCOUNTS = "accounts";
// public static final String BOOKS = "books";
// public static final String MUSIC = "music";
// public static final String FAMILY = "family";
// public static final String MOVIES = "movies";
// public static final String GAMES = "games";
// public static final Object NOTIFICATIONS = "notifications";
// public static final String TELEVISION = "television";
// public static final String OBJECTS = "objects";
// }
//
// Path: app/src/main/java/com/beltaief/reactivefbexample/util/Cover.java
// public class Cover {
//
// private static final String ID = "id";
// private static final String SOURCE = "source";
// private static final String CREATED_TIME = "created_time";
// private static final String OFFSET_X = "offset_x";
// private static final String OFFSET_Y = "offset_y";
// private static final String COVER_ID = "cover_id";
//
// @SerializedName(ID)
// private String mId = null;
//
// @SerializedName(SOURCE)
// private String mSource = null;
//
// @SerializedName(CREATED_TIME)
// private String mCreatedTime = null;
//
// @SerializedName(OFFSET_X)
// private String mOffsetX = null;
//
// @SerializedName(OFFSET_Y)
// private String mOffsetY = null;
//
// @SerializedName(COVER_ID)
// private String mCoverId = null;
//
// public String getId() {
// return mId;
// }
//
// public String getSource() {
// return mSource;
// }
//
// public String getCreatedTime() {
// return mCreatedTime;
// }
//
// public String getOffsetX() {
// return mOffsetX;
// }
//
// public String getOffsetY() {
// return mOffsetY;
// }
//
// public String getCoverId() {
// return mCoverId;
// }
// }
|
import android.os.Bundle;
import com.beltaief.reactivefb.util.GraphPath;
import com.beltaief.reactivefbexample.util.Cover;
import com.google.gson.annotations.SerializedName;
import java.util.Date;
|
private static final String TYPE = "type";
private static final String CREATED_TIME = "created_time";
private static final String UPDATED_TIME = "updated_time";
private static final String CAN_UPLOAD = "can_upload";
@SerializedName(ID)
private String mId = null;
@SerializedName(FROM)
private User mFrom = null;
@SerializedName(NAME)
private String mName = null;
@SerializedName(DESCRIPTION)
private String mDescription = null;
@SerializedName(LOCATION)
private String mLocation = null;
@SerializedName(LINK)
private String mLink = null;
@SerializedName(COUNT)
private Integer mCount = null;
@SerializedName(PRIVACY)
private String mPrivacy = null;
@SerializedName(COVER_PHOTO)
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/GraphPath.java
// public class GraphPath {
//
// public static final String ME = "me";
// public static final String ATTACHMENTS = "attachments";
// public static final String FRIENDS = "friends";
// public static final String TAGGABLE_FRIENDS = "taggable_friends";
// public static final String INVITABLE_FRIENDS = "invitable_friends";
// public static final String ALBUMS = "albums";
// public static final String SCORES = "scores";
// public static final String APPREQUESTS = "apprequests";
// public static final String FEED = "feed";
// public static final String PHOTOS = "photos";
// public static final String VIDEOS = "videos";
// public static final String EVENTS = "events";
// public static final String GROUPS = "groups";
// public static final String POSTS = "posts";
// public static final String COMMENTS = "comments";
// public static final String LIKES = "likes";
// public static final String LINKS = "links";
// public static final String STATUSES = "statuses";
// public static final String TAGGED = "tagged";
// public static final String TAGGED_PLACES = "tagged_places";
// public static final String ACCOUNTS = "accounts";
// public static final String BOOKS = "books";
// public static final String MUSIC = "music";
// public static final String FAMILY = "family";
// public static final String MOVIES = "movies";
// public static final String GAMES = "games";
// public static final Object NOTIFICATIONS = "notifications";
// public static final String TELEVISION = "television";
// public static final String OBJECTS = "objects";
// }
//
// Path: app/src/main/java/com/beltaief/reactivefbexample/util/Cover.java
// public class Cover {
//
// private static final String ID = "id";
// private static final String SOURCE = "source";
// private static final String CREATED_TIME = "created_time";
// private static final String OFFSET_X = "offset_x";
// private static final String OFFSET_Y = "offset_y";
// private static final String COVER_ID = "cover_id";
//
// @SerializedName(ID)
// private String mId = null;
//
// @SerializedName(SOURCE)
// private String mSource = null;
//
// @SerializedName(CREATED_TIME)
// private String mCreatedTime = null;
//
// @SerializedName(OFFSET_X)
// private String mOffsetX = null;
//
// @SerializedName(OFFSET_Y)
// private String mOffsetY = null;
//
// @SerializedName(COVER_ID)
// private String mCoverId = null;
//
// public String getId() {
// return mId;
// }
//
// public String getSource() {
// return mSource;
// }
//
// public String getCreatedTime() {
// return mCreatedTime;
// }
//
// public String getOffsetX() {
// return mOffsetX;
// }
//
// public String getOffsetY() {
// return mOffsetY;
// }
//
// public String getCoverId() {
// return mCoverId;
// }
// }
// Path: app/src/main/java/com/beltaief/reactivefbexample/models/Album.java
import android.os.Bundle;
import com.beltaief.reactivefb.util.GraphPath;
import com.beltaief.reactivefbexample.util.Cover;
import com.google.gson.annotations.SerializedName;
import java.util.Date;
private static final String TYPE = "type";
private static final String CREATED_TIME = "created_time";
private static final String UPDATED_TIME = "updated_time";
private static final String CAN_UPLOAD = "can_upload";
@SerializedName(ID)
private String mId = null;
@SerializedName(FROM)
private User mFrom = null;
@SerializedName(NAME)
private String mName = null;
@SerializedName(DESCRIPTION)
private String mDescription = null;
@SerializedName(LOCATION)
private String mLocation = null;
@SerializedName(LINK)
private String mLink = null;
@SerializedName(COUNT)
private Integer mCount = null;
@SerializedName(PRIVACY)
private String mPrivacy = null;
@SerializedName(COVER_PHOTO)
|
private Cover mCover = null;
|
WassimBenltaief/ReactiveFB
|
app/src/main/java/com/beltaief/reactivefbexample/models/Album.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/GraphPath.java
// public class GraphPath {
//
// public static final String ME = "me";
// public static final String ATTACHMENTS = "attachments";
// public static final String FRIENDS = "friends";
// public static final String TAGGABLE_FRIENDS = "taggable_friends";
// public static final String INVITABLE_FRIENDS = "invitable_friends";
// public static final String ALBUMS = "albums";
// public static final String SCORES = "scores";
// public static final String APPREQUESTS = "apprequests";
// public static final String FEED = "feed";
// public static final String PHOTOS = "photos";
// public static final String VIDEOS = "videos";
// public static final String EVENTS = "events";
// public static final String GROUPS = "groups";
// public static final String POSTS = "posts";
// public static final String COMMENTS = "comments";
// public static final String LIKES = "likes";
// public static final String LINKS = "links";
// public static final String STATUSES = "statuses";
// public static final String TAGGED = "tagged";
// public static final String TAGGED_PLACES = "tagged_places";
// public static final String ACCOUNTS = "accounts";
// public static final String BOOKS = "books";
// public static final String MUSIC = "music";
// public static final String FAMILY = "family";
// public static final String MOVIES = "movies";
// public static final String GAMES = "games";
// public static final Object NOTIFICATIONS = "notifications";
// public static final String TELEVISION = "television";
// public static final String OBJECTS = "objects";
// }
//
// Path: app/src/main/java/com/beltaief/reactivefbexample/util/Cover.java
// public class Cover {
//
// private static final String ID = "id";
// private static final String SOURCE = "source";
// private static final String CREATED_TIME = "created_time";
// private static final String OFFSET_X = "offset_x";
// private static final String OFFSET_Y = "offset_y";
// private static final String COVER_ID = "cover_id";
//
// @SerializedName(ID)
// private String mId = null;
//
// @SerializedName(SOURCE)
// private String mSource = null;
//
// @SerializedName(CREATED_TIME)
// private String mCreatedTime = null;
//
// @SerializedName(OFFSET_X)
// private String mOffsetX = null;
//
// @SerializedName(OFFSET_Y)
// private String mOffsetY = null;
//
// @SerializedName(COVER_ID)
// private String mCoverId = null;
//
// public String getId() {
// return mId;
// }
//
// public String getSource() {
// return mSource;
// }
//
// public String getCreatedTime() {
// return mCreatedTime;
// }
//
// public String getOffsetX() {
// return mOffsetX;
// }
//
// public String getOffsetY() {
// return mOffsetY;
// }
//
// public String getCoverId() {
// return mCoverId;
// }
// }
|
import android.os.Bundle;
import com.beltaief.reactivefb.util.GraphPath;
import com.beltaief.reactivefbexample.util.Cover;
import com.google.gson.annotations.SerializedName;
import java.util.Date;
|
/**
* Add description to the album
*
* @param message
* The description of the album
*/
public Builder setMessage(String message) {
mMessage = message;
return this;
}
/**
* Add privacy setting to the photo
*
* @param privacy
* The privacy setting of the album
* @see Privacy
*/
public Builder setPrivacy(Privacy privacy) {
mPublishPrivacy = privacy;
return this;
}
public Album build() {
return new Album(this);
}
}
@Override
public String getPath() {
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/GraphPath.java
// public class GraphPath {
//
// public static final String ME = "me";
// public static final String ATTACHMENTS = "attachments";
// public static final String FRIENDS = "friends";
// public static final String TAGGABLE_FRIENDS = "taggable_friends";
// public static final String INVITABLE_FRIENDS = "invitable_friends";
// public static final String ALBUMS = "albums";
// public static final String SCORES = "scores";
// public static final String APPREQUESTS = "apprequests";
// public static final String FEED = "feed";
// public static final String PHOTOS = "photos";
// public static final String VIDEOS = "videos";
// public static final String EVENTS = "events";
// public static final String GROUPS = "groups";
// public static final String POSTS = "posts";
// public static final String COMMENTS = "comments";
// public static final String LIKES = "likes";
// public static final String LINKS = "links";
// public static final String STATUSES = "statuses";
// public static final String TAGGED = "tagged";
// public static final String TAGGED_PLACES = "tagged_places";
// public static final String ACCOUNTS = "accounts";
// public static final String BOOKS = "books";
// public static final String MUSIC = "music";
// public static final String FAMILY = "family";
// public static final String MOVIES = "movies";
// public static final String GAMES = "games";
// public static final Object NOTIFICATIONS = "notifications";
// public static final String TELEVISION = "television";
// public static final String OBJECTS = "objects";
// }
//
// Path: app/src/main/java/com/beltaief/reactivefbexample/util/Cover.java
// public class Cover {
//
// private static final String ID = "id";
// private static final String SOURCE = "source";
// private static final String CREATED_TIME = "created_time";
// private static final String OFFSET_X = "offset_x";
// private static final String OFFSET_Y = "offset_y";
// private static final String COVER_ID = "cover_id";
//
// @SerializedName(ID)
// private String mId = null;
//
// @SerializedName(SOURCE)
// private String mSource = null;
//
// @SerializedName(CREATED_TIME)
// private String mCreatedTime = null;
//
// @SerializedName(OFFSET_X)
// private String mOffsetX = null;
//
// @SerializedName(OFFSET_Y)
// private String mOffsetY = null;
//
// @SerializedName(COVER_ID)
// private String mCoverId = null;
//
// public String getId() {
// return mId;
// }
//
// public String getSource() {
// return mSource;
// }
//
// public String getCreatedTime() {
// return mCreatedTime;
// }
//
// public String getOffsetX() {
// return mOffsetX;
// }
//
// public String getOffsetY() {
// return mOffsetY;
// }
//
// public String getCoverId() {
// return mCoverId;
// }
// }
// Path: app/src/main/java/com/beltaief/reactivefbexample/models/Album.java
import android.os.Bundle;
import com.beltaief.reactivefb.util.GraphPath;
import com.beltaief.reactivefbexample.util.Cover;
import com.google.gson.annotations.SerializedName;
import java.util.Date;
/**
* Add description to the album
*
* @param message
* The description of the album
*/
public Builder setMessage(String message) {
mMessage = message;
return this;
}
/**
* Add privacy setting to the photo
*
* @param privacy
* The privacy setting of the album
* @see Privacy
*/
public Builder setPrivacy(Privacy privacy) {
mPublishPrivacy = privacy;
return this;
}
public Album build() {
return new Album(this);
}
}
@Override
public String getPath() {
|
return GraphPath.ALBUMS;
|
WassimBenltaief/ReactiveFB
|
reactivefb/src/main/java/com/beltaief/reactivefb/requests/RequestOnSubscribe.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Utils.java
// public final class Utils {
// private Utils() {
// }
//
// public static Bundle getBundle(String mFields, int limit) {
// Bundle bundle = new Bundle();
// if (mFields != null) {
// bundle.putString("fields", mFields);
// }
// if (limit > 0) {
// bundle.putString("limit", String.valueOf(limit));
// }
// return bundle;
// }
//
// @SuppressWarnings("resource")
// public static String encode(String key, String data) {
// try {
// Mac mac = Mac.getInstance("HmacSHA256");
// SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "HmacSHA256");
// mac.init(secretKey);
// byte[] bytes = mac.doFinal(data.getBytes());
// StringBuilder sb = new StringBuilder(bytes.length * 2);
// Formatter formatter = new Formatter(sb);
// for (byte b : bytes) {
// formatter.format("%02x", b);
// }
// return sb.toString();
// } catch (Exception e) {
// Logger.logError(Utils.class, "Failed to create sha256", e);
// return null;
// }
// }
// }
|
import android.support.annotation.Nullable;
import com.beltaief.reactivefb.util.Utils;
import com.facebook.GraphResponse;
import io.reactivex.SingleEmitter;
import io.reactivex.SingleOnSubscribe;
|
package com.beltaief.reactivefb.requests;
/**
* A custom class that extends SingleOnSubscribe.
*
* Created by wassim on 10/7/16.
*/
class RequestOnSubscribe implements SingleOnSubscribe<GraphResponse> {
private final String mEdge;
private final String mTarget;
private final String mFields;
private final int mLimit;
/**
* The constructor used to instantiate the SingleOnSubscribe from Single.create().
* @param target the target in GraphAPI
* example : /v2.7/TARGET/albums
* @param edge the edge in GraphAPI
* example : /v2.7/me/EDGE
* @param fields the fields to get from the graphAPI
* example : /v2.7/me?FIELDS=id,name
* @param limit the limit of the number of elements returned by the graphAPI
* example : /v2.7/me/albums?fields=count&limit=10
*/
RequestOnSubscribe(@Nullable String target, @Nullable String edge,
@Nullable String fields, int limit) {
this.mTarget = target;
this.mEdge = edge;
this.mFields = fields;
this.mLimit = limit;
}
@Override
public void subscribe(SingleEmitter<GraphResponse> emitter) throws Exception {
RequestAction action = new RequestAction();
action.setSingleEmitter(emitter);
action.setTarget(mTarget);
action.setEdge(mEdge);
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Utils.java
// public final class Utils {
// private Utils() {
// }
//
// public static Bundle getBundle(String mFields, int limit) {
// Bundle bundle = new Bundle();
// if (mFields != null) {
// bundle.putString("fields", mFields);
// }
// if (limit > 0) {
// bundle.putString("limit", String.valueOf(limit));
// }
// return bundle;
// }
//
// @SuppressWarnings("resource")
// public static String encode(String key, String data) {
// try {
// Mac mac = Mac.getInstance("HmacSHA256");
// SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "HmacSHA256");
// mac.init(secretKey);
// byte[] bytes = mac.doFinal(data.getBytes());
// StringBuilder sb = new StringBuilder(bytes.length * 2);
// Formatter formatter = new Formatter(sb);
// for (byte b : bytes) {
// formatter.format("%02x", b);
// }
// return sb.toString();
// } catch (Exception e) {
// Logger.logError(Utils.class, "Failed to create sha256", e);
// return null;
// }
// }
// }
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/requests/RequestOnSubscribe.java
import android.support.annotation.Nullable;
import com.beltaief.reactivefb.util.Utils;
import com.facebook.GraphResponse;
import io.reactivex.SingleEmitter;
import io.reactivex.SingleOnSubscribe;
package com.beltaief.reactivefb.requests;
/**
* A custom class that extends SingleOnSubscribe.
*
* Created by wassim on 10/7/16.
*/
class RequestOnSubscribe implements SingleOnSubscribe<GraphResponse> {
private final String mEdge;
private final String mTarget;
private final String mFields;
private final int mLimit;
/**
* The constructor used to instantiate the SingleOnSubscribe from Single.create().
* @param target the target in GraphAPI
* example : /v2.7/TARGET/albums
* @param edge the edge in GraphAPI
* example : /v2.7/me/EDGE
* @param fields the fields to get from the graphAPI
* example : /v2.7/me?FIELDS=id,name
* @param limit the limit of the number of elements returned by the graphAPI
* example : /v2.7/me/albums?fields=count&limit=10
*/
RequestOnSubscribe(@Nullable String target, @Nullable String edge,
@Nullable String fields, int limit) {
this.mTarget = target;
this.mEdge = edge;
this.mFields = fields;
this.mLimit = limit;
}
@Override
public void subscribe(SingleEmitter<GraphResponse> emitter) throws Exception {
RequestAction action = new RequestAction();
action.setSingleEmitter(emitter);
action.setTarget(mTarget);
action.setEdge(mEdge);
|
action.setBundle(Utils.getBundle(mFields, mLimit));
|
WassimBenltaief/ReactiveFB
|
app/src/main/java/com/beltaief/reactivefbexample/views/MainActivity.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/ReactiveFB.java
// public class ReactiveFB {
//
// private static ReactiveFB mInstance = null;
// private static SimpleFacebookConfiguration mConfiguration =
// new SimpleFacebookConfiguration.Builder().build();
// private static SessionManager mSessionManager = null;
//
// public static void sdkInitialize(Context context) {
// if (mInstance == null) {
// Class clazz = ReactiveFB.class;
// synchronized (clazz) {
// mInstance = new ReactiveFB();
// }
// FacebookSdk.sdkInitialize(context);
// mSessionManager = new SessionManager(mConfiguration);
// }
// }
//
// public static void checkInit() {
// if (!FacebookSdk.isInitialized()) {
// throw new RuntimeException("ReactiveFB not initialized. Are you missing " +
// "ReactiveFB.sdkInitialize(context) ?");
// }
// }
//
// public static SessionManager getSessionManager() {
// return mSessionManager;
// }
//
// public static SimpleFacebookConfiguration getConfiguration() {
// return mConfiguration;
// }
//
// public static void setConfiguration(SimpleFacebookConfiguration configuration) {
// mConfiguration = configuration;
// }
//
// public static boolean checkPermission(PermissionHelper permission) {
// return AccessToken.getCurrentAccessToken().getPermissions().contains(permission.getValue());
// }
// }
//
// Path: app/src/main/java/com/beltaief/reactivefbexample/util/Example.java
// public class Example {
//
// private final String mTitle;
// private final Class<? extends Activity> aActivity;
// private final boolean mRequiresLogin;
//
// public Example(String title, Class<? extends Activity> clazz, boolean requiresLogin) {
// mTitle = title;
// aActivity = clazz;
// mRequiresLogin = requiresLogin;
// }
//
// public String getTitle() {
// return mTitle;
// }
//
// public Class<? extends Activity> getActivity() {
// return aActivity;
// }
//
// public boolean isRequireLogin() {
// return mRequiresLogin;
// }
//
// }
//
// Path: app/src/main/java/com/beltaief/reactivefbexample/util/ExampleAdapter.java
// public class ExampleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
//
// private RecyclerViewClickListener mListener;
// private List<Example> mCollection;
//
// public ExampleAdapter(List<Example> collection, RecyclerViewClickListener listener) {
// this.mCollection = collection;
// this.mListener = listener;
// }
//
// @Override
// public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View v = LayoutInflater
// .from(parent.getContext())
// .inflate(R.layout.item_example, parent, false);
//
// ExampleHolder viewHolder = new ExampleHolder(v);
// return viewHolder;
// }
//
// @Override
// public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// ExampleHolder mHolder = (ExampleHolder) holder;
// mHolder.button.setText(mCollection.get(position).getTitle());
// }
//
// @Override
// public int getItemCount() {
// return mCollection.size();
// }
//
// public void setData(List<Example> data) {
// mCollection = data;
// }
//
//
// class ExampleHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
//
// Button button;
//
// public ExampleHolder(View itemView) {
// super(itemView);
// button = (Button) itemView.findViewById(R.id.button);
// button.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View view) {
// mListener.recyclerViewListClicked(view, getLayoutPosition(), view.getId());
// }
// }
// }
//
// Path: app/src/main/java/com/beltaief/reactivefbexample/util/RecyclerViewClickListener.java
// public interface RecyclerViewClickListener {
// void recyclerViewListClicked(View v, int position, int id);
// }
|
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Toast;
import com.beltaief.reactivefb.ReactiveFB;
import com.beltaief.reactivefbexample.R;
import com.beltaief.reactivefbexample.util.Example;
import com.beltaief.reactivefbexample.util.ExampleAdapter;
import com.beltaief.reactivefbexample.util.RecyclerViewClickListener;
import java.util.ArrayList;
|
package com.beltaief.reactivefbexample.views;
public class MainActivity extends AppCompatActivity implements RecyclerViewClickListener {
private ArrayList<Example> mExamples;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("reactivefb examples");
mExamples = new ArrayList<>();
mExamples.add(new Example("Login ", LoginActivity.class, false));
mExamples.add(new Example("Login with button", LoginButtonActivity.class, false));
mExamples.add(new Example("Current Profile", ProfileActivity.class, true));
mExamples.add(new Example("Albums Profile", AlbumsActivity.class, true));
mExamples.add(new Example("My Pictures", MyPhotosActivity.class, true));
mExamples.add(new Example("Friends", FriendsActivity.class, true));
RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.recycler);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/ReactiveFB.java
// public class ReactiveFB {
//
// private static ReactiveFB mInstance = null;
// private static SimpleFacebookConfiguration mConfiguration =
// new SimpleFacebookConfiguration.Builder().build();
// private static SessionManager mSessionManager = null;
//
// public static void sdkInitialize(Context context) {
// if (mInstance == null) {
// Class clazz = ReactiveFB.class;
// synchronized (clazz) {
// mInstance = new ReactiveFB();
// }
// FacebookSdk.sdkInitialize(context);
// mSessionManager = new SessionManager(mConfiguration);
// }
// }
//
// public static void checkInit() {
// if (!FacebookSdk.isInitialized()) {
// throw new RuntimeException("ReactiveFB not initialized. Are you missing " +
// "ReactiveFB.sdkInitialize(context) ?");
// }
// }
//
// public static SessionManager getSessionManager() {
// return mSessionManager;
// }
//
// public static SimpleFacebookConfiguration getConfiguration() {
// return mConfiguration;
// }
//
// public static void setConfiguration(SimpleFacebookConfiguration configuration) {
// mConfiguration = configuration;
// }
//
// public static boolean checkPermission(PermissionHelper permission) {
// return AccessToken.getCurrentAccessToken().getPermissions().contains(permission.getValue());
// }
// }
//
// Path: app/src/main/java/com/beltaief/reactivefbexample/util/Example.java
// public class Example {
//
// private final String mTitle;
// private final Class<? extends Activity> aActivity;
// private final boolean mRequiresLogin;
//
// public Example(String title, Class<? extends Activity> clazz, boolean requiresLogin) {
// mTitle = title;
// aActivity = clazz;
// mRequiresLogin = requiresLogin;
// }
//
// public String getTitle() {
// return mTitle;
// }
//
// public Class<? extends Activity> getActivity() {
// return aActivity;
// }
//
// public boolean isRequireLogin() {
// return mRequiresLogin;
// }
//
// }
//
// Path: app/src/main/java/com/beltaief/reactivefbexample/util/ExampleAdapter.java
// public class ExampleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
//
// private RecyclerViewClickListener mListener;
// private List<Example> mCollection;
//
// public ExampleAdapter(List<Example> collection, RecyclerViewClickListener listener) {
// this.mCollection = collection;
// this.mListener = listener;
// }
//
// @Override
// public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View v = LayoutInflater
// .from(parent.getContext())
// .inflate(R.layout.item_example, parent, false);
//
// ExampleHolder viewHolder = new ExampleHolder(v);
// return viewHolder;
// }
//
// @Override
// public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// ExampleHolder mHolder = (ExampleHolder) holder;
// mHolder.button.setText(mCollection.get(position).getTitle());
// }
//
// @Override
// public int getItemCount() {
// return mCollection.size();
// }
//
// public void setData(List<Example> data) {
// mCollection = data;
// }
//
//
// class ExampleHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
//
// Button button;
//
// public ExampleHolder(View itemView) {
// super(itemView);
// button = (Button) itemView.findViewById(R.id.button);
// button.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View view) {
// mListener.recyclerViewListClicked(view, getLayoutPosition(), view.getId());
// }
// }
// }
//
// Path: app/src/main/java/com/beltaief/reactivefbexample/util/RecyclerViewClickListener.java
// public interface RecyclerViewClickListener {
// void recyclerViewListClicked(View v, int position, int id);
// }
// Path: app/src/main/java/com/beltaief/reactivefbexample/views/MainActivity.java
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Toast;
import com.beltaief.reactivefb.ReactiveFB;
import com.beltaief.reactivefbexample.R;
import com.beltaief.reactivefbexample.util.Example;
import com.beltaief.reactivefbexample.util.ExampleAdapter;
import com.beltaief.reactivefbexample.util.RecyclerViewClickListener;
import java.util.ArrayList;
package com.beltaief.reactivefbexample.views;
public class MainActivity extends AppCompatActivity implements RecyclerViewClickListener {
private ArrayList<Example> mExamples;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("reactivefb examples");
mExamples = new ArrayList<>();
mExamples.add(new Example("Login ", LoginActivity.class, false));
mExamples.add(new Example("Login with button", LoginButtonActivity.class, false));
mExamples.add(new Example("Current Profile", ProfileActivity.class, true));
mExamples.add(new Example("Albums Profile", AlbumsActivity.class, true));
mExamples.add(new Example("My Pictures", MyPhotosActivity.class, true));
mExamples.add(new Example("Friends", FriendsActivity.class, true));
RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.recycler);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
|
ExampleAdapter mExamplesAdapter = new ExampleAdapter(mExamples, this);
|
WassimBenltaief/ReactiveFB
|
app/src/main/java/com/beltaief/reactivefbexample/views/MainActivity.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/ReactiveFB.java
// public class ReactiveFB {
//
// private static ReactiveFB mInstance = null;
// private static SimpleFacebookConfiguration mConfiguration =
// new SimpleFacebookConfiguration.Builder().build();
// private static SessionManager mSessionManager = null;
//
// public static void sdkInitialize(Context context) {
// if (mInstance == null) {
// Class clazz = ReactiveFB.class;
// synchronized (clazz) {
// mInstance = new ReactiveFB();
// }
// FacebookSdk.sdkInitialize(context);
// mSessionManager = new SessionManager(mConfiguration);
// }
// }
//
// public static void checkInit() {
// if (!FacebookSdk.isInitialized()) {
// throw new RuntimeException("ReactiveFB not initialized. Are you missing " +
// "ReactiveFB.sdkInitialize(context) ?");
// }
// }
//
// public static SessionManager getSessionManager() {
// return mSessionManager;
// }
//
// public static SimpleFacebookConfiguration getConfiguration() {
// return mConfiguration;
// }
//
// public static void setConfiguration(SimpleFacebookConfiguration configuration) {
// mConfiguration = configuration;
// }
//
// public static boolean checkPermission(PermissionHelper permission) {
// return AccessToken.getCurrentAccessToken().getPermissions().contains(permission.getValue());
// }
// }
//
// Path: app/src/main/java/com/beltaief/reactivefbexample/util/Example.java
// public class Example {
//
// private final String mTitle;
// private final Class<? extends Activity> aActivity;
// private final boolean mRequiresLogin;
//
// public Example(String title, Class<? extends Activity> clazz, boolean requiresLogin) {
// mTitle = title;
// aActivity = clazz;
// mRequiresLogin = requiresLogin;
// }
//
// public String getTitle() {
// return mTitle;
// }
//
// public Class<? extends Activity> getActivity() {
// return aActivity;
// }
//
// public boolean isRequireLogin() {
// return mRequiresLogin;
// }
//
// }
//
// Path: app/src/main/java/com/beltaief/reactivefbexample/util/ExampleAdapter.java
// public class ExampleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
//
// private RecyclerViewClickListener mListener;
// private List<Example> mCollection;
//
// public ExampleAdapter(List<Example> collection, RecyclerViewClickListener listener) {
// this.mCollection = collection;
// this.mListener = listener;
// }
//
// @Override
// public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View v = LayoutInflater
// .from(parent.getContext())
// .inflate(R.layout.item_example, parent, false);
//
// ExampleHolder viewHolder = new ExampleHolder(v);
// return viewHolder;
// }
//
// @Override
// public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// ExampleHolder mHolder = (ExampleHolder) holder;
// mHolder.button.setText(mCollection.get(position).getTitle());
// }
//
// @Override
// public int getItemCount() {
// return mCollection.size();
// }
//
// public void setData(List<Example> data) {
// mCollection = data;
// }
//
//
// class ExampleHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
//
// Button button;
//
// public ExampleHolder(View itemView) {
// super(itemView);
// button = (Button) itemView.findViewById(R.id.button);
// button.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View view) {
// mListener.recyclerViewListClicked(view, getLayoutPosition(), view.getId());
// }
// }
// }
//
// Path: app/src/main/java/com/beltaief/reactivefbexample/util/RecyclerViewClickListener.java
// public interface RecyclerViewClickListener {
// void recyclerViewListClicked(View v, int position, int id);
// }
|
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Toast;
import com.beltaief.reactivefb.ReactiveFB;
import com.beltaief.reactivefbexample.R;
import com.beltaief.reactivefbexample.util.Example;
import com.beltaief.reactivefbexample.util.ExampleAdapter;
import com.beltaief.reactivefbexample.util.RecyclerViewClickListener;
import java.util.ArrayList;
|
package com.beltaief.reactivefbexample.views;
public class MainActivity extends AppCompatActivity implements RecyclerViewClickListener {
private ArrayList<Example> mExamples;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("reactivefb examples");
mExamples = new ArrayList<>();
mExamples.add(new Example("Login ", LoginActivity.class, false));
mExamples.add(new Example("Login with button", LoginButtonActivity.class, false));
mExamples.add(new Example("Current Profile", ProfileActivity.class, true));
mExamples.add(new Example("Albums Profile", AlbumsActivity.class, true));
mExamples.add(new Example("My Pictures", MyPhotosActivity.class, true));
mExamples.add(new Example("Friends", FriendsActivity.class, true));
RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.recycler);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
ExampleAdapter mExamplesAdapter = new ExampleAdapter(mExamples, this);
mRecyclerView.setAdapter(mExamplesAdapter);
}
@Override
public void recyclerViewListClicked(View v, int position, int id) {
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/ReactiveFB.java
// public class ReactiveFB {
//
// private static ReactiveFB mInstance = null;
// private static SimpleFacebookConfiguration mConfiguration =
// new SimpleFacebookConfiguration.Builder().build();
// private static SessionManager mSessionManager = null;
//
// public static void sdkInitialize(Context context) {
// if (mInstance == null) {
// Class clazz = ReactiveFB.class;
// synchronized (clazz) {
// mInstance = new ReactiveFB();
// }
// FacebookSdk.sdkInitialize(context);
// mSessionManager = new SessionManager(mConfiguration);
// }
// }
//
// public static void checkInit() {
// if (!FacebookSdk.isInitialized()) {
// throw new RuntimeException("ReactiveFB not initialized. Are you missing " +
// "ReactiveFB.sdkInitialize(context) ?");
// }
// }
//
// public static SessionManager getSessionManager() {
// return mSessionManager;
// }
//
// public static SimpleFacebookConfiguration getConfiguration() {
// return mConfiguration;
// }
//
// public static void setConfiguration(SimpleFacebookConfiguration configuration) {
// mConfiguration = configuration;
// }
//
// public static boolean checkPermission(PermissionHelper permission) {
// return AccessToken.getCurrentAccessToken().getPermissions().contains(permission.getValue());
// }
// }
//
// Path: app/src/main/java/com/beltaief/reactivefbexample/util/Example.java
// public class Example {
//
// private final String mTitle;
// private final Class<? extends Activity> aActivity;
// private final boolean mRequiresLogin;
//
// public Example(String title, Class<? extends Activity> clazz, boolean requiresLogin) {
// mTitle = title;
// aActivity = clazz;
// mRequiresLogin = requiresLogin;
// }
//
// public String getTitle() {
// return mTitle;
// }
//
// public Class<? extends Activity> getActivity() {
// return aActivity;
// }
//
// public boolean isRequireLogin() {
// return mRequiresLogin;
// }
//
// }
//
// Path: app/src/main/java/com/beltaief/reactivefbexample/util/ExampleAdapter.java
// public class ExampleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
//
// private RecyclerViewClickListener mListener;
// private List<Example> mCollection;
//
// public ExampleAdapter(List<Example> collection, RecyclerViewClickListener listener) {
// this.mCollection = collection;
// this.mListener = listener;
// }
//
// @Override
// public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View v = LayoutInflater
// .from(parent.getContext())
// .inflate(R.layout.item_example, parent, false);
//
// ExampleHolder viewHolder = new ExampleHolder(v);
// return viewHolder;
// }
//
// @Override
// public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// ExampleHolder mHolder = (ExampleHolder) holder;
// mHolder.button.setText(mCollection.get(position).getTitle());
// }
//
// @Override
// public int getItemCount() {
// return mCollection.size();
// }
//
// public void setData(List<Example> data) {
// mCollection = data;
// }
//
//
// class ExampleHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
//
// Button button;
//
// public ExampleHolder(View itemView) {
// super(itemView);
// button = (Button) itemView.findViewById(R.id.button);
// button.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View view) {
// mListener.recyclerViewListClicked(view, getLayoutPosition(), view.getId());
// }
// }
// }
//
// Path: app/src/main/java/com/beltaief/reactivefbexample/util/RecyclerViewClickListener.java
// public interface RecyclerViewClickListener {
// void recyclerViewListClicked(View v, int position, int id);
// }
// Path: app/src/main/java/com/beltaief/reactivefbexample/views/MainActivity.java
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Toast;
import com.beltaief.reactivefb.ReactiveFB;
import com.beltaief.reactivefbexample.R;
import com.beltaief.reactivefbexample.util.Example;
import com.beltaief.reactivefbexample.util.ExampleAdapter;
import com.beltaief.reactivefbexample.util.RecyclerViewClickListener;
import java.util.ArrayList;
package com.beltaief.reactivefbexample.views;
public class MainActivity extends AppCompatActivity implements RecyclerViewClickListener {
private ArrayList<Example> mExamples;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("reactivefb examples");
mExamples = new ArrayList<>();
mExamples.add(new Example("Login ", LoginActivity.class, false));
mExamples.add(new Example("Login with button", LoginButtonActivity.class, false));
mExamples.add(new Example("Current Profile", ProfileActivity.class, true));
mExamples.add(new Example("Albums Profile", AlbumsActivity.class, true));
mExamples.add(new Example("My Pictures", MyPhotosActivity.class, true));
mExamples.add(new Example("Friends", FriendsActivity.class, true));
RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.recycler);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
ExampleAdapter mExamplesAdapter = new ExampleAdapter(mExamples, this);
mRecyclerView.setAdapter(mExamplesAdapter);
}
@Override
public void recyclerViewListClicked(View v, int position, int id) {
|
if(!ReactiveFB.getSessionManager().isLoggedIn() && mExamples.get(position).isRequireLogin()){
|
WassimBenltaief/ReactiveFB
|
reactivefb/src/main/java/com/beltaief/reactivefb/SessionManager.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/actions/ReactiveLoginCallback.java
// public class ReactiveLoginCallback<T> implements FacebookCallback<T> {
//
// private MaybeEmitter<T> maybeEmitter;
// boolean askPublishPermissions;
// List<String> publishPermissions;
//
// @Override
// public void onSuccess(T loginResult) {
// maybeEmitter.onSuccess(loginResult);
// }
//
// @Override
// public void onCancel() {
// maybeEmitter.onComplete();
// }
//
// @Override
// public void onError(FacebookException error) {
// maybeEmitter.onError(new Throwable(error));
// }
//
// public void setEmitter(MaybeEmitter<T> emitter) {
// this.maybeEmitter = emitter;
// }
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/actions/ReactiveLoginWithButtonCallback.java
// public class ReactiveLoginWithButtonCallback<T> implements FacebookCallback<T> {
//
// private ObservableEmitter<T> maybeEmitter;
//
// @Override
// public void onSuccess(T loginResult) {
// maybeEmitter.onNext(loginResult);
// }
//
// @Override
// public void onCancel() {
// maybeEmitter.onError(new FacebookException("user canceled the operation"));
// }
//
// @Override
// public void onError(FacebookException error) {
// maybeEmitter.onError(new Throwable(error));
// }
//
// public void setEmitter(ObservableEmitter<T> emitter) {
// this.maybeEmitter = emitter;
// }
// }
|
import android.app.Activity;
import com.beltaief.reactivefb.actions.ReactiveLoginCallback;
import com.beltaief.reactivefb.actions.ReactiveLoginWithButtonCallback;
import com.facebook.AccessToken;
import com.facebook.CallbackManager;
import com.facebook.login.LoginManager;
import com.facebook.login.LoginResult;
import java.lang.ref.WeakReference;
import java.util.List;
import io.reactivex.MaybeEmitter;
import io.reactivex.ObservableEmitter;
|
package com.beltaief.reactivefb;
/**
* Created by wassim on 9/15/16.
*/
public class SessionManager {
private WeakReference<Activity> mActivity;
private static SimpleFacebookConfiguration configuration;
private final LoginManager mLoginManager;
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/actions/ReactiveLoginCallback.java
// public class ReactiveLoginCallback<T> implements FacebookCallback<T> {
//
// private MaybeEmitter<T> maybeEmitter;
// boolean askPublishPermissions;
// List<String> publishPermissions;
//
// @Override
// public void onSuccess(T loginResult) {
// maybeEmitter.onSuccess(loginResult);
// }
//
// @Override
// public void onCancel() {
// maybeEmitter.onComplete();
// }
//
// @Override
// public void onError(FacebookException error) {
// maybeEmitter.onError(new Throwable(error));
// }
//
// public void setEmitter(MaybeEmitter<T> emitter) {
// this.maybeEmitter = emitter;
// }
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/actions/ReactiveLoginWithButtonCallback.java
// public class ReactiveLoginWithButtonCallback<T> implements FacebookCallback<T> {
//
// private ObservableEmitter<T> maybeEmitter;
//
// @Override
// public void onSuccess(T loginResult) {
// maybeEmitter.onNext(loginResult);
// }
//
// @Override
// public void onCancel() {
// maybeEmitter.onError(new FacebookException("user canceled the operation"));
// }
//
// @Override
// public void onError(FacebookException error) {
// maybeEmitter.onError(new Throwable(error));
// }
//
// public void setEmitter(ObservableEmitter<T> emitter) {
// this.maybeEmitter = emitter;
// }
// }
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/SessionManager.java
import android.app.Activity;
import com.beltaief.reactivefb.actions.ReactiveLoginCallback;
import com.beltaief.reactivefb.actions.ReactiveLoginWithButtonCallback;
import com.facebook.AccessToken;
import com.facebook.CallbackManager;
import com.facebook.login.LoginManager;
import com.facebook.login.LoginResult;
import java.lang.ref.WeakReference;
import java.util.List;
import io.reactivex.MaybeEmitter;
import io.reactivex.ObservableEmitter;
package com.beltaief.reactivefb;
/**
* Created by wassim on 9/15/16.
*/
public class SessionManager {
private WeakReference<Activity> mActivity;
private static SimpleFacebookConfiguration configuration;
private final LoginManager mLoginManager;
|
private final ReactiveLoginCallback<LoginResult> mLoginCallback = new ReactiveLoginCallback<>();
|
WassimBenltaief/ReactiveFB
|
reactivefb/src/main/java/com/beltaief/reactivefb/SessionManager.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/actions/ReactiveLoginCallback.java
// public class ReactiveLoginCallback<T> implements FacebookCallback<T> {
//
// private MaybeEmitter<T> maybeEmitter;
// boolean askPublishPermissions;
// List<String> publishPermissions;
//
// @Override
// public void onSuccess(T loginResult) {
// maybeEmitter.onSuccess(loginResult);
// }
//
// @Override
// public void onCancel() {
// maybeEmitter.onComplete();
// }
//
// @Override
// public void onError(FacebookException error) {
// maybeEmitter.onError(new Throwable(error));
// }
//
// public void setEmitter(MaybeEmitter<T> emitter) {
// this.maybeEmitter = emitter;
// }
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/actions/ReactiveLoginWithButtonCallback.java
// public class ReactiveLoginWithButtonCallback<T> implements FacebookCallback<T> {
//
// private ObservableEmitter<T> maybeEmitter;
//
// @Override
// public void onSuccess(T loginResult) {
// maybeEmitter.onNext(loginResult);
// }
//
// @Override
// public void onCancel() {
// maybeEmitter.onError(new FacebookException("user canceled the operation"));
// }
//
// @Override
// public void onError(FacebookException error) {
// maybeEmitter.onError(new Throwable(error));
// }
//
// public void setEmitter(ObservableEmitter<T> emitter) {
// this.maybeEmitter = emitter;
// }
// }
|
import android.app.Activity;
import com.beltaief.reactivefb.actions.ReactiveLoginCallback;
import com.beltaief.reactivefb.actions.ReactiveLoginWithButtonCallback;
import com.facebook.AccessToken;
import com.facebook.CallbackManager;
import com.facebook.login.LoginManager;
import com.facebook.login.LoginResult;
import java.lang.ref.WeakReference;
import java.util.List;
import io.reactivex.MaybeEmitter;
import io.reactivex.ObservableEmitter;
|
package com.beltaief.reactivefb;
/**
* Created by wassim on 9/15/16.
*/
public class SessionManager {
private WeakReference<Activity> mActivity;
private static SimpleFacebookConfiguration configuration;
private final LoginManager mLoginManager;
private final ReactiveLoginCallback<LoginResult> mLoginCallback = new ReactiveLoginCallback<>();
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/actions/ReactiveLoginCallback.java
// public class ReactiveLoginCallback<T> implements FacebookCallback<T> {
//
// private MaybeEmitter<T> maybeEmitter;
// boolean askPublishPermissions;
// List<String> publishPermissions;
//
// @Override
// public void onSuccess(T loginResult) {
// maybeEmitter.onSuccess(loginResult);
// }
//
// @Override
// public void onCancel() {
// maybeEmitter.onComplete();
// }
//
// @Override
// public void onError(FacebookException error) {
// maybeEmitter.onError(new Throwable(error));
// }
//
// public void setEmitter(MaybeEmitter<T> emitter) {
// this.maybeEmitter = emitter;
// }
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/actions/ReactiveLoginWithButtonCallback.java
// public class ReactiveLoginWithButtonCallback<T> implements FacebookCallback<T> {
//
// private ObservableEmitter<T> maybeEmitter;
//
// @Override
// public void onSuccess(T loginResult) {
// maybeEmitter.onNext(loginResult);
// }
//
// @Override
// public void onCancel() {
// maybeEmitter.onError(new FacebookException("user canceled the operation"));
// }
//
// @Override
// public void onError(FacebookException error) {
// maybeEmitter.onError(new Throwable(error));
// }
//
// public void setEmitter(ObservableEmitter<T> emitter) {
// this.maybeEmitter = emitter;
// }
// }
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/SessionManager.java
import android.app.Activity;
import com.beltaief.reactivefb.actions.ReactiveLoginCallback;
import com.beltaief.reactivefb.actions.ReactiveLoginWithButtonCallback;
import com.facebook.AccessToken;
import com.facebook.CallbackManager;
import com.facebook.login.LoginManager;
import com.facebook.login.LoginResult;
import java.lang.ref.WeakReference;
import java.util.List;
import io.reactivex.MaybeEmitter;
import io.reactivex.ObservableEmitter;
package com.beltaief.reactivefb;
/**
* Created by wassim on 9/15/16.
*/
public class SessionManager {
private WeakReference<Activity> mActivity;
private static SimpleFacebookConfiguration configuration;
private final LoginManager mLoginManager;
private final ReactiveLoginCallback<LoginResult> mLoginCallback = new ReactiveLoginCallback<>();
|
private final ReactiveLoginWithButtonCallback<LoginResult> mLoginWithButtonCallback = new ReactiveLoginWithButtonCallback<>();
|
WassimBenltaief/ReactiveFB
|
app/src/main/java/com/beltaief/reactivefbexample/views/LoginButtonActivity.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/actions/ReactiveLogin.java
// public final class ReactiveLogin {
//
// /**
// * Login with com.facebook.login.LoginManager
// * The reason why this method returns a MayBe is that when a user cancel the operation, it
// * does not emit any value neither an error. Maybe have a onComplete method that is covering
// * this case.
// * Use onSuccess to handle a success result.
// * Use onComplete to handle canceled operation.
// *
// * @param activity instance of the current activity
// * @return a Maybe of LoginResult
// */
// @NonNull
// public static Maybe<LoginResult> login(@NonNull final Activity activity) {
// checkNotNull(activity, "activity == null");
// // save a weak reference to the activity
// ReactiveFB.getSessionManager().setActivity(activity);
// // login
// return Maybe.create(new LoginOnSubscribe());
// }
//
// /**
// * Login with com.facebook.login.widget.LoginButton
// * To be called from an Activity.
// * The reason why it's returning an Observable and not a MayBe like login() is that with MayBe
// * the subscribtion is done only one time. We need an observable in order to subscribe
// * continuously.
// *
// * @param loginButton instance of a com.facebook.login.widget.LoginButton
// * @return an Observable of LoginResult
// */
// @NonNull
// public static Observable<LoginResult> loginWithButton(@NonNull final LoginButton loginButton) {
//
// checkNotNull(loginButton, "loginButton == null");
// ReactiveFB.checkInit();
// // login
// return Observable.create(new LoginWithButtonOnSubscribe(loginButton));
// }
//
// /**
// * Login with com.facebook.login.widget.LoginButton
// * To be called from an android.support.v4.app.Fragment
// *
// * @param loginButton instance of a com.facebook.login.widget.LoginButton
// * @param fragment instance of support android.support.v4.app.Fragment
// * @return
// */
// @NonNull
// public static Observable<LoginResult> loginWithButton(@NonNull final LoginButton loginButton,
// @NonNull final Fragment fragment) {
//
// checkNotNull(fragment, "fragment == null");
// checkNotNull(loginButton, "loginButton == null");
// ReactiveFB.checkInit();
// // login
// return Observable.create(new LoginWithButtonOnSubscribe(loginButton));
// }
//
// /**
// * Login with com.facebook.login.widget.LoginButton
// * To be called from an android.app.Fragment
// *
// * @param loginButton instance of com.facebook.login.widget.LoginButton
// * @param fragment instance of android.app.Fragment
// * @return
// */
// @NonNull
// public static Observable<LoginResult> loginWithButton(@NonNull final LoginButton loginButton,
// @NonNull final android.app.Fragment fragment) {
//
// checkNotNull(fragment, "fragment == null");
// checkNotNull(loginButton, "loginButton == null");
// ReactiveFB.checkInit();
// // login
// return Observable.create(new LoginWithButtonOnSubscribe(loginButton));
// }
//
//
// /**
// * Redirect facebook callback onActivityResult to this library callback.
// * This is necessary with login/ loginWithButton methods.
// *
// * @param requestCode
// * @param resultCode
// * @param data
// */
// public static void onActivityResult(int requestCode, int resultCode, Intent data) {
// ReactiveFB.getSessionManager()
// .getCallbackManager()
// .onActivityResult(requestCode, resultCode, data);
// }
//
// /**
// * Request additional permissions from facebook. This launches a new login with additional
// * permissions.
// *
// * @param permissions List of {@link PermissionHelper}
// * @param activity current activity instance
// * @return a Maybe of LoginResult.
// */
// public static Maybe<LoginResult> requestAdditionalPermission(@NonNull final List<PermissionHelper> permissions,
// @NonNull final Activity activity) {
//
// checkNotNull(permissions, "permissions == null");
// checkNotNull(activity, "activity == null");
//
// ReactiveFB.getSessionManager().setActivity(activity);
//
// return Maybe.create(new AdditionalPermissionOnSubscribe(permissions));
// }
//
// private ReactiveLogin() {
// throw new AssertionError("No instances.");
// }
// }
|
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;
import com.beltaief.reactivefb.actions.ReactiveLogin;
import com.beltaief.reactivefbexample.R;
import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableObserver;
|
package com.beltaief.reactivefbexample.views;
public class LoginButtonActivity extends AppCompatActivity {
private static final String TAG = LoginButtonActivity.class.getSimpleName();
private LoginButton loginButton;
private TextView result;
private final CompositeDisposable disposables = new CompositeDisposable();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login_button);
loginButton = (LoginButton) findViewById(R.id.fb_button_login);
result = (TextView) findViewById(R.id.result);
registerlogin();
}
@Override
protected void onDestroy() {
super.onDestroy();
disposables.clear(); // do not send event after activity has been destroyed
}
private void registerlogin() {
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/actions/ReactiveLogin.java
// public final class ReactiveLogin {
//
// /**
// * Login with com.facebook.login.LoginManager
// * The reason why this method returns a MayBe is that when a user cancel the operation, it
// * does not emit any value neither an error. Maybe have a onComplete method that is covering
// * this case.
// * Use onSuccess to handle a success result.
// * Use onComplete to handle canceled operation.
// *
// * @param activity instance of the current activity
// * @return a Maybe of LoginResult
// */
// @NonNull
// public static Maybe<LoginResult> login(@NonNull final Activity activity) {
// checkNotNull(activity, "activity == null");
// // save a weak reference to the activity
// ReactiveFB.getSessionManager().setActivity(activity);
// // login
// return Maybe.create(new LoginOnSubscribe());
// }
//
// /**
// * Login with com.facebook.login.widget.LoginButton
// * To be called from an Activity.
// * The reason why it's returning an Observable and not a MayBe like login() is that with MayBe
// * the subscribtion is done only one time. We need an observable in order to subscribe
// * continuously.
// *
// * @param loginButton instance of a com.facebook.login.widget.LoginButton
// * @return an Observable of LoginResult
// */
// @NonNull
// public static Observable<LoginResult> loginWithButton(@NonNull final LoginButton loginButton) {
//
// checkNotNull(loginButton, "loginButton == null");
// ReactiveFB.checkInit();
// // login
// return Observable.create(new LoginWithButtonOnSubscribe(loginButton));
// }
//
// /**
// * Login with com.facebook.login.widget.LoginButton
// * To be called from an android.support.v4.app.Fragment
// *
// * @param loginButton instance of a com.facebook.login.widget.LoginButton
// * @param fragment instance of support android.support.v4.app.Fragment
// * @return
// */
// @NonNull
// public static Observable<LoginResult> loginWithButton(@NonNull final LoginButton loginButton,
// @NonNull final Fragment fragment) {
//
// checkNotNull(fragment, "fragment == null");
// checkNotNull(loginButton, "loginButton == null");
// ReactiveFB.checkInit();
// // login
// return Observable.create(new LoginWithButtonOnSubscribe(loginButton));
// }
//
// /**
// * Login with com.facebook.login.widget.LoginButton
// * To be called from an android.app.Fragment
// *
// * @param loginButton instance of com.facebook.login.widget.LoginButton
// * @param fragment instance of android.app.Fragment
// * @return
// */
// @NonNull
// public static Observable<LoginResult> loginWithButton(@NonNull final LoginButton loginButton,
// @NonNull final android.app.Fragment fragment) {
//
// checkNotNull(fragment, "fragment == null");
// checkNotNull(loginButton, "loginButton == null");
// ReactiveFB.checkInit();
// // login
// return Observable.create(new LoginWithButtonOnSubscribe(loginButton));
// }
//
//
// /**
// * Redirect facebook callback onActivityResult to this library callback.
// * This is necessary with login/ loginWithButton methods.
// *
// * @param requestCode
// * @param resultCode
// * @param data
// */
// public static void onActivityResult(int requestCode, int resultCode, Intent data) {
// ReactiveFB.getSessionManager()
// .getCallbackManager()
// .onActivityResult(requestCode, resultCode, data);
// }
//
// /**
// * Request additional permissions from facebook. This launches a new login with additional
// * permissions.
// *
// * @param permissions List of {@link PermissionHelper}
// * @param activity current activity instance
// * @return a Maybe of LoginResult.
// */
// public static Maybe<LoginResult> requestAdditionalPermission(@NonNull final List<PermissionHelper> permissions,
// @NonNull final Activity activity) {
//
// checkNotNull(permissions, "permissions == null");
// checkNotNull(activity, "activity == null");
//
// ReactiveFB.getSessionManager().setActivity(activity);
//
// return Maybe.create(new AdditionalPermissionOnSubscribe(permissions));
// }
//
// private ReactiveLogin() {
// throw new AssertionError("No instances.");
// }
// }
// Path: app/src/main/java/com/beltaief/reactivefbexample/views/LoginButtonActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;
import com.beltaief.reactivefb.actions.ReactiveLogin;
import com.beltaief.reactivefbexample.R;
import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableObserver;
package com.beltaief.reactivefbexample.views;
public class LoginButtonActivity extends AppCompatActivity {
private static final String TAG = LoginButtonActivity.class.getSimpleName();
private LoginButton loginButton;
private TextView result;
private final CompositeDisposable disposables = new CompositeDisposable();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login_button);
loginButton = (LoginButton) findViewById(R.id.fb_button_login);
result = (TextView) findViewById(R.id.result);
registerlogin();
}
@Override
protected void onDestroy() {
super.onDestroy();
disposables.clear(); // do not send event after activity has been destroyed
}
private void registerlogin() {
|
DisposableObserver<LoginResult> disposableObserver = ReactiveLogin.loginWithButton(loginButton)
|
WassimBenltaief/ReactiveFB
|
app/src/main/java/com/beltaief/reactivefbexample/models/Photo.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/GraphPath.java
// public class GraphPath {
//
// public static final String ME = "me";
// public static final String ATTACHMENTS = "attachments";
// public static final String FRIENDS = "friends";
// public static final String TAGGABLE_FRIENDS = "taggable_friends";
// public static final String INVITABLE_FRIENDS = "invitable_friends";
// public static final String ALBUMS = "albums";
// public static final String SCORES = "scores";
// public static final String APPREQUESTS = "apprequests";
// public static final String FEED = "feed";
// public static final String PHOTOS = "photos";
// public static final String VIDEOS = "videos";
// public static final String EVENTS = "events";
// public static final String GROUPS = "groups";
// public static final String POSTS = "posts";
// public static final String COMMENTS = "comments";
// public static final String LIKES = "likes";
// public static final String LINKS = "links";
// public static final String STATUSES = "statuses";
// public static final String TAGGED = "tagged";
// public static final String TAGGED_PLACES = "tagged_places";
// public static final String ACCOUNTS = "accounts";
// public static final String BOOKS = "books";
// public static final String MUSIC = "music";
// public static final String FAMILY = "family";
// public static final String MOVIES = "movies";
// public static final String GAMES = "games";
// public static final Object NOTIFICATIONS = "notifications";
// public static final String TELEVISION = "television";
// public static final String OBJECTS = "objects";
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Logger.java
// public final class Logger {
//
// private static boolean DEBUG = false;
// private static boolean DEBUG_WITH_STACKTRACE = false;
//
// private Logger() {
// }
//
// public static <T> void logInfo(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.i(tag, "-----");
// Log.i(tag, LogType.INFO + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.i(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logWarning(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.w(tag, "-----");
// Log.w(tag, LogType.WARNING + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.w(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logError(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.e(tag, "-----");
// Log.e(tag, LogType.ERROR + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.e(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logError(Class<T> cls, String message, Throwable e) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.e(tag, "-----");
// Log.e(tag, LogType.ERROR + ": " + message, e);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.e(tag, getStackTrace());
// }
// }
// }
//
// private enum LogType {
// INFO,
// WARNING,
// ERROR
// }
//
// private static String getStackTrace() {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// new Throwable().printStackTrace(pw);
// return sw.toString();
// }
// }
|
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;
import com.beltaief.reactivefb.util.GraphPath;
import com.beltaief.reactivefb.util.Logger;
import com.google.gson.annotations.SerializedName;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Date;
import java.util.List;
|
@SerializedName(PICTURE)
private String mPicture;
@SerializedName(SOURCE)
private String mSource;
@SerializedName(UPDATED_TIME)
private Date mUpdatedTime;
@SerializedName(WIDTH)
private Integer mWidth;
@SerializedName(PLACE)
private Place mPlace;
private String mPlaceId = null;
private Parcelable mParcelable = null;
private byte[] mBytes = null;
private Privacy mPrivacy = null;
private Photo(Builder builder) {
mName = builder.mName;
mPlaceId = builder.mPlaceId;
mParcelable = builder.mParcelable;
mBytes = builder.mBytes;
mPrivacy = builder.mPrivacy;
}
@Override
public String getPath() {
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/GraphPath.java
// public class GraphPath {
//
// public static final String ME = "me";
// public static final String ATTACHMENTS = "attachments";
// public static final String FRIENDS = "friends";
// public static final String TAGGABLE_FRIENDS = "taggable_friends";
// public static final String INVITABLE_FRIENDS = "invitable_friends";
// public static final String ALBUMS = "albums";
// public static final String SCORES = "scores";
// public static final String APPREQUESTS = "apprequests";
// public static final String FEED = "feed";
// public static final String PHOTOS = "photos";
// public static final String VIDEOS = "videos";
// public static final String EVENTS = "events";
// public static final String GROUPS = "groups";
// public static final String POSTS = "posts";
// public static final String COMMENTS = "comments";
// public static final String LIKES = "likes";
// public static final String LINKS = "links";
// public static final String STATUSES = "statuses";
// public static final String TAGGED = "tagged";
// public static final String TAGGED_PLACES = "tagged_places";
// public static final String ACCOUNTS = "accounts";
// public static final String BOOKS = "books";
// public static final String MUSIC = "music";
// public static final String FAMILY = "family";
// public static final String MOVIES = "movies";
// public static final String GAMES = "games";
// public static final Object NOTIFICATIONS = "notifications";
// public static final String TELEVISION = "television";
// public static final String OBJECTS = "objects";
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Logger.java
// public final class Logger {
//
// private static boolean DEBUG = false;
// private static boolean DEBUG_WITH_STACKTRACE = false;
//
// private Logger() {
// }
//
// public static <T> void logInfo(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.i(tag, "-----");
// Log.i(tag, LogType.INFO + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.i(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logWarning(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.w(tag, "-----");
// Log.w(tag, LogType.WARNING + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.w(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logError(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.e(tag, "-----");
// Log.e(tag, LogType.ERROR + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.e(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logError(Class<T> cls, String message, Throwable e) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.e(tag, "-----");
// Log.e(tag, LogType.ERROR + ": " + message, e);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.e(tag, getStackTrace());
// }
// }
// }
//
// private enum LogType {
// INFO,
// WARNING,
// ERROR
// }
//
// private static String getStackTrace() {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// new Throwable().printStackTrace(pw);
// return sw.toString();
// }
// }
// Path: app/src/main/java/com/beltaief/reactivefbexample/models/Photo.java
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;
import com.beltaief.reactivefb.util.GraphPath;
import com.beltaief.reactivefb.util.Logger;
import com.google.gson.annotations.SerializedName;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Date;
import java.util.List;
@SerializedName(PICTURE)
private String mPicture;
@SerializedName(SOURCE)
private String mSource;
@SerializedName(UPDATED_TIME)
private Date mUpdatedTime;
@SerializedName(WIDTH)
private Integer mWidth;
@SerializedName(PLACE)
private Place mPlace;
private String mPlaceId = null;
private Parcelable mParcelable = null;
private byte[] mBytes = null;
private Privacy mPrivacy = null;
private Photo(Builder builder) {
mName = builder.mName;
mPlaceId = builder.mPlaceId;
mParcelable = builder.mParcelable;
mBytes = builder.mBytes;
mPrivacy = builder.mPrivacy;
}
@Override
public String getPath() {
|
return GraphPath.PHOTOS;
|
WassimBenltaief/ReactiveFB
|
app/src/main/java/com/beltaief/reactivefbexample/models/Photo.java
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/GraphPath.java
// public class GraphPath {
//
// public static final String ME = "me";
// public static final String ATTACHMENTS = "attachments";
// public static final String FRIENDS = "friends";
// public static final String TAGGABLE_FRIENDS = "taggable_friends";
// public static final String INVITABLE_FRIENDS = "invitable_friends";
// public static final String ALBUMS = "albums";
// public static final String SCORES = "scores";
// public static final String APPREQUESTS = "apprequests";
// public static final String FEED = "feed";
// public static final String PHOTOS = "photos";
// public static final String VIDEOS = "videos";
// public static final String EVENTS = "events";
// public static final String GROUPS = "groups";
// public static final String POSTS = "posts";
// public static final String COMMENTS = "comments";
// public static final String LIKES = "likes";
// public static final String LINKS = "links";
// public static final String STATUSES = "statuses";
// public static final String TAGGED = "tagged";
// public static final String TAGGED_PLACES = "tagged_places";
// public static final String ACCOUNTS = "accounts";
// public static final String BOOKS = "books";
// public static final String MUSIC = "music";
// public static final String FAMILY = "family";
// public static final String MOVIES = "movies";
// public static final String GAMES = "games";
// public static final Object NOTIFICATIONS = "notifications";
// public static final String TELEVISION = "television";
// public static final String OBJECTS = "objects";
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Logger.java
// public final class Logger {
//
// private static boolean DEBUG = false;
// private static boolean DEBUG_WITH_STACKTRACE = false;
//
// private Logger() {
// }
//
// public static <T> void logInfo(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.i(tag, "-----");
// Log.i(tag, LogType.INFO + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.i(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logWarning(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.w(tag, "-----");
// Log.w(tag, LogType.WARNING + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.w(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logError(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.e(tag, "-----");
// Log.e(tag, LogType.ERROR + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.e(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logError(Class<T> cls, String message, Throwable e) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.e(tag, "-----");
// Log.e(tag, LogType.ERROR + ": " + message, e);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.e(tag, getStackTrace());
// }
// }
// }
//
// private enum LogType {
// INFO,
// WARNING,
// ERROR
// }
//
// private static String getStackTrace() {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// new Throwable().printStackTrace(pw);
// return sw.toString();
// }
// }
|
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;
import com.beltaief.reactivefb.util.GraphPath;
import com.beltaief.reactivefb.util.Logger;
import com.google.gson.annotations.SerializedName;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Date;
import java.util.List;
|
public static class Builder {
private String mName = null;
private String mPlaceId = null;
private Parcelable mParcelable = null;
private byte[] mBytes = null;
private Privacy mPrivacy = null;
public Builder() {
}
/**
* Set photo to be published
*
* @param bitmap
*/
public Builder setImage(Bitmap bitmap) {
mParcelable = bitmap;
return this;
}
/**
* Set photo to be published
*
* @param file
*/
public Builder setImage(File file) {
try {
mParcelable = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
} catch (FileNotFoundException e) {
|
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/GraphPath.java
// public class GraphPath {
//
// public static final String ME = "me";
// public static final String ATTACHMENTS = "attachments";
// public static final String FRIENDS = "friends";
// public static final String TAGGABLE_FRIENDS = "taggable_friends";
// public static final String INVITABLE_FRIENDS = "invitable_friends";
// public static final String ALBUMS = "albums";
// public static final String SCORES = "scores";
// public static final String APPREQUESTS = "apprequests";
// public static final String FEED = "feed";
// public static final String PHOTOS = "photos";
// public static final String VIDEOS = "videos";
// public static final String EVENTS = "events";
// public static final String GROUPS = "groups";
// public static final String POSTS = "posts";
// public static final String COMMENTS = "comments";
// public static final String LIKES = "likes";
// public static final String LINKS = "links";
// public static final String STATUSES = "statuses";
// public static final String TAGGED = "tagged";
// public static final String TAGGED_PLACES = "tagged_places";
// public static final String ACCOUNTS = "accounts";
// public static final String BOOKS = "books";
// public static final String MUSIC = "music";
// public static final String FAMILY = "family";
// public static final String MOVIES = "movies";
// public static final String GAMES = "games";
// public static final Object NOTIFICATIONS = "notifications";
// public static final String TELEVISION = "television";
// public static final String OBJECTS = "objects";
// }
//
// Path: reactivefb/src/main/java/com/beltaief/reactivefb/util/Logger.java
// public final class Logger {
//
// private static boolean DEBUG = false;
// private static boolean DEBUG_WITH_STACKTRACE = false;
//
// private Logger() {
// }
//
// public static <T> void logInfo(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.i(tag, "-----");
// Log.i(tag, LogType.INFO + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.i(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logWarning(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.w(tag, "-----");
// Log.w(tag, LogType.WARNING + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.w(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logError(Class<T> cls, String message) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.e(tag, "-----");
// Log.e(tag, LogType.ERROR + ": " + message);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.e(tag, getStackTrace());
// }
// }
// }
//
// public static <T> void logError(Class<T> cls, String message, Throwable e) {
// if (DEBUG || DEBUG_WITH_STACKTRACE) {
// String tag = cls.getName();
// Log.e(tag, "-----");
// Log.e(tag, LogType.ERROR + ": " + message, e);
//
// if (DEBUG_WITH_STACKTRACE) {
// Log.e(tag, getStackTrace());
// }
// }
// }
//
// private enum LogType {
// INFO,
// WARNING,
// ERROR
// }
//
// private static String getStackTrace() {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// new Throwable().printStackTrace(pw);
// return sw.toString();
// }
// }
// Path: app/src/main/java/com/beltaief/reactivefbexample/models/Photo.java
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;
import com.beltaief.reactivefb.util.GraphPath;
import com.beltaief.reactivefb.util.Logger;
import com.google.gson.annotations.SerializedName;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Date;
import java.util.List;
public static class Builder {
private String mName = null;
private String mPlaceId = null;
private Parcelable mParcelable = null;
private byte[] mBytes = null;
private Privacy mPrivacy = null;
public Builder() {
}
/**
* Set photo to be published
*
* @param bitmap
*/
public Builder setImage(Bitmap bitmap) {
mParcelable = bitmap;
return this;
}
/**
* Set photo to be published
*
* @param file
*/
public Builder setImage(File file) {
try {
mParcelable = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
} catch (FileNotFoundException e) {
|
Logger.logError(Photo.class, "Failed to create photo from file", e);
|
coil-lighting/udder
|
udder/src/main/java/com/coillighting/udder/infrastructure/HttpServiceContainer.java
|
// Path: udder/src/main/java/com/coillighting/udder/util/CollectionUtil.java
// public class CollectionUtil {
//
// // TODO see if there are already Boon equivalents for these - there likely are.
// public static <T extends Comparable<? super T>> List<T> sorted(Collection<T> c) {
// ArrayList<T> list = new ArrayList<T>(c);
// Collections.sort(list);
// return list;
// }
//
// }
//
// Path: udder/src/main/java/com/coillighting/udder/util/StringUtil.java
// public class StringUtil {
//
// // TODO see if there are already Boon equivalents for these - there likely are.
// /** String.join is available only with Java 1.8. We support 1.7.
// *
// * Format a list of items as strings, separated by the given conjunction.
// */
// static public String join(List<? extends Object> items, String conjunction) {
// StringBuilder sb = new StringBuilder();
// boolean first = true;
// for (Object x : items) {
// if (first) {
// first = false;
// } else {
// sb.append(conjunction);
// }
// if(x == null) {
// sb.append("<null>");
// } else {
// sb.append(x.toString());
// }
// }
// return sb.toString();
// }
//
// /** Draw an ASCII slider representing the value of x in range [0..1.0]. */
// public static final String plot1D(double x) {
// if(x < 0.0) {
// return "[< MIN ERR ----------------------------------------] " + x;
// } else if(x > 1.0) {
// return "[---------------------------------------- ERR MAX >] " + x;
// } else {
// if(x <= 0.01) {
// x = 0.0;
// } else if(x >= 0.99) {
// x = 1.0;
// }
// int xi = (int)(x * 50.999999999);
// StringBuffer sb = new StringBuffer(80);
// sb.append('[');
// for(int i=0; i<xi; i++) {
// sb.append('-');
// }
// sb.append('|');
// for(int i=xi+1; i<=50; i++) {
// sb.append('-');
// }
// sb.append(']').append(' ').append(x);
// return sb.toString();
// }
// }
//
// }
|
import java.io.*;
import java.net.URLDecoder;
import java.util.Map;
import java.util.Queue;
import org.boon.json.JsonFactory;
import org.simpleframework.http.core.Container;
import org.simpleframework.http.Path;
import org.simpleframework.http.Query;
import org.simpleframework.http.Request;
import org.simpleframework.http.Response;
import org.simpleframework.http.Status;
import static org.boon.Exceptions.SoftenedException;
import com.coillighting.udder.util.CollectionUtil;
import com.coillighting.udder.util.StringUtil;
import static com.coillighting.udder.util.LogUtil.log;
|
String responseBody = "TODO GET " + index;
this.respond(response, responseBody);
}
private void handlePost(Request request, Response response) {
int index = this.requestIndex;
++this.requestIndex; // Increment before any possible exception.
String responseBody;
try {
Command command = this.createCommand(request);
if(command == null) {
throw new NullPointerException("Unreachable code: comand is null.");
} else {
boolean accepted = this.queue.offer(command);
if(accepted) {
response.setStatus(Status.OK);
responseBody = "OK " + index;
if(this.debug) log(command.toString() + ' ' + responseBody);
} else {
// For some reason, Status doesn't know about RFC 6585.
response.setCode(429);
response.setDescription("Too Many Requests");
responseBody = "DROPPED " + index;
if(this.debug) log("Request " + index + " for " + command + " dropped. No room in queue.");
}
}
} catch (RoutingException e) {
|
// Path: udder/src/main/java/com/coillighting/udder/util/CollectionUtil.java
// public class CollectionUtil {
//
// // TODO see if there are already Boon equivalents for these - there likely are.
// public static <T extends Comparable<? super T>> List<T> sorted(Collection<T> c) {
// ArrayList<T> list = new ArrayList<T>(c);
// Collections.sort(list);
// return list;
// }
//
// }
//
// Path: udder/src/main/java/com/coillighting/udder/util/StringUtil.java
// public class StringUtil {
//
// // TODO see if there are already Boon equivalents for these - there likely are.
// /** String.join is available only with Java 1.8. We support 1.7.
// *
// * Format a list of items as strings, separated by the given conjunction.
// */
// static public String join(List<? extends Object> items, String conjunction) {
// StringBuilder sb = new StringBuilder();
// boolean first = true;
// for (Object x : items) {
// if (first) {
// first = false;
// } else {
// sb.append(conjunction);
// }
// if(x == null) {
// sb.append("<null>");
// } else {
// sb.append(x.toString());
// }
// }
// return sb.toString();
// }
//
// /** Draw an ASCII slider representing the value of x in range [0..1.0]. */
// public static final String plot1D(double x) {
// if(x < 0.0) {
// return "[< MIN ERR ----------------------------------------] " + x;
// } else if(x > 1.0) {
// return "[---------------------------------------- ERR MAX >] " + x;
// } else {
// if(x <= 0.01) {
// x = 0.0;
// } else if(x >= 0.99) {
// x = 1.0;
// }
// int xi = (int)(x * 50.999999999);
// StringBuffer sb = new StringBuffer(80);
// sb.append('[');
// for(int i=0; i<xi; i++) {
// sb.append('-');
// }
// sb.append('|');
// for(int i=xi+1; i<=50; i++) {
// sb.append('-');
// }
// sb.append(']').append(' ').append(x);
// return sb.toString();
// }
// }
//
// }
// Path: udder/src/main/java/com/coillighting/udder/infrastructure/HttpServiceContainer.java
import java.io.*;
import java.net.URLDecoder;
import java.util.Map;
import java.util.Queue;
import org.boon.json.JsonFactory;
import org.simpleframework.http.core.Container;
import org.simpleframework.http.Path;
import org.simpleframework.http.Query;
import org.simpleframework.http.Request;
import org.simpleframework.http.Response;
import org.simpleframework.http.Status;
import static org.boon.Exceptions.SoftenedException;
import com.coillighting.udder.util.CollectionUtil;
import com.coillighting.udder.util.StringUtil;
import static com.coillighting.udder.util.LogUtil.log;
String responseBody = "TODO GET " + index;
this.respond(response, responseBody);
}
private void handlePost(Request request, Response response) {
int index = this.requestIndex;
++this.requestIndex; // Increment before any possible exception.
String responseBody;
try {
Command command = this.createCommand(request);
if(command == null) {
throw new NullPointerException("Unreachable code: comand is null.");
} else {
boolean accepted = this.queue.offer(command);
if(accepted) {
response.setStatus(Status.OK);
responseBody = "OK " + index;
if(this.debug) log(command.toString() + ' ' + responseBody);
} else {
// For some reason, Status doesn't know about RFC 6585.
response.setCode(429);
response.setDescription("Too Many Requests");
responseBody = "DROPPED " + index;
if(this.debug) log("Request " + index + " for " + command + " dropped. No room in queue.");
}
}
} catch (RoutingException e) {
|
String routes = StringUtil.join(CollectionUtil.sorted(this.commandMap.keySet()), "\n ");
|
coil-lighting/udder
|
udder/src/main/java/com/coillighting/udder/infrastructure/HttpServiceContainer.java
|
// Path: udder/src/main/java/com/coillighting/udder/util/CollectionUtil.java
// public class CollectionUtil {
//
// // TODO see if there are already Boon equivalents for these - there likely are.
// public static <T extends Comparable<? super T>> List<T> sorted(Collection<T> c) {
// ArrayList<T> list = new ArrayList<T>(c);
// Collections.sort(list);
// return list;
// }
//
// }
//
// Path: udder/src/main/java/com/coillighting/udder/util/StringUtil.java
// public class StringUtil {
//
// // TODO see if there are already Boon equivalents for these - there likely are.
// /** String.join is available only with Java 1.8. We support 1.7.
// *
// * Format a list of items as strings, separated by the given conjunction.
// */
// static public String join(List<? extends Object> items, String conjunction) {
// StringBuilder sb = new StringBuilder();
// boolean first = true;
// for (Object x : items) {
// if (first) {
// first = false;
// } else {
// sb.append(conjunction);
// }
// if(x == null) {
// sb.append("<null>");
// } else {
// sb.append(x.toString());
// }
// }
// return sb.toString();
// }
//
// /** Draw an ASCII slider representing the value of x in range [0..1.0]. */
// public static final String plot1D(double x) {
// if(x < 0.0) {
// return "[< MIN ERR ----------------------------------------] " + x;
// } else if(x > 1.0) {
// return "[---------------------------------------- ERR MAX >] " + x;
// } else {
// if(x <= 0.01) {
// x = 0.0;
// } else if(x >= 0.99) {
// x = 1.0;
// }
// int xi = (int)(x * 50.999999999);
// StringBuffer sb = new StringBuffer(80);
// sb.append('[');
// for(int i=0; i<xi; i++) {
// sb.append('-');
// }
// sb.append('|');
// for(int i=xi+1; i<=50; i++) {
// sb.append('-');
// }
// sb.append(']').append(' ').append(x);
// return sb.toString();
// }
// }
//
// }
|
import java.io.*;
import java.net.URLDecoder;
import java.util.Map;
import java.util.Queue;
import org.boon.json.JsonFactory;
import org.simpleframework.http.core.Container;
import org.simpleframework.http.Path;
import org.simpleframework.http.Query;
import org.simpleframework.http.Request;
import org.simpleframework.http.Response;
import org.simpleframework.http.Status;
import static org.boon.Exceptions.SoftenedException;
import com.coillighting.udder.util.CollectionUtil;
import com.coillighting.udder.util.StringUtil;
import static com.coillighting.udder.util.LogUtil.log;
|
String responseBody = "TODO GET " + index;
this.respond(response, responseBody);
}
private void handlePost(Request request, Response response) {
int index = this.requestIndex;
++this.requestIndex; // Increment before any possible exception.
String responseBody;
try {
Command command = this.createCommand(request);
if(command == null) {
throw new NullPointerException("Unreachable code: comand is null.");
} else {
boolean accepted = this.queue.offer(command);
if(accepted) {
response.setStatus(Status.OK);
responseBody = "OK " + index;
if(this.debug) log(command.toString() + ' ' + responseBody);
} else {
// For some reason, Status doesn't know about RFC 6585.
response.setCode(429);
response.setDescription("Too Many Requests");
responseBody = "DROPPED " + index;
if(this.debug) log("Request " + index + " for " + command + " dropped. No room in queue.");
}
}
} catch (RoutingException e) {
|
// Path: udder/src/main/java/com/coillighting/udder/util/CollectionUtil.java
// public class CollectionUtil {
//
// // TODO see if there are already Boon equivalents for these - there likely are.
// public static <T extends Comparable<? super T>> List<T> sorted(Collection<T> c) {
// ArrayList<T> list = new ArrayList<T>(c);
// Collections.sort(list);
// return list;
// }
//
// }
//
// Path: udder/src/main/java/com/coillighting/udder/util/StringUtil.java
// public class StringUtil {
//
// // TODO see if there are already Boon equivalents for these - there likely are.
// /** String.join is available only with Java 1.8. We support 1.7.
// *
// * Format a list of items as strings, separated by the given conjunction.
// */
// static public String join(List<? extends Object> items, String conjunction) {
// StringBuilder sb = new StringBuilder();
// boolean first = true;
// for (Object x : items) {
// if (first) {
// first = false;
// } else {
// sb.append(conjunction);
// }
// if(x == null) {
// sb.append("<null>");
// } else {
// sb.append(x.toString());
// }
// }
// return sb.toString();
// }
//
// /** Draw an ASCII slider representing the value of x in range [0..1.0]. */
// public static final String plot1D(double x) {
// if(x < 0.0) {
// return "[< MIN ERR ----------------------------------------] " + x;
// } else if(x > 1.0) {
// return "[---------------------------------------- ERR MAX >] " + x;
// } else {
// if(x <= 0.01) {
// x = 0.0;
// } else if(x >= 0.99) {
// x = 1.0;
// }
// int xi = (int)(x * 50.999999999);
// StringBuffer sb = new StringBuffer(80);
// sb.append('[');
// for(int i=0; i<xi; i++) {
// sb.append('-');
// }
// sb.append('|');
// for(int i=xi+1; i<=50; i++) {
// sb.append('-');
// }
// sb.append(']').append(' ').append(x);
// return sb.toString();
// }
// }
//
// }
// Path: udder/src/main/java/com/coillighting/udder/infrastructure/HttpServiceContainer.java
import java.io.*;
import java.net.URLDecoder;
import java.util.Map;
import java.util.Queue;
import org.boon.json.JsonFactory;
import org.simpleframework.http.core.Container;
import org.simpleframework.http.Path;
import org.simpleframework.http.Query;
import org.simpleframework.http.Request;
import org.simpleframework.http.Response;
import org.simpleframework.http.Status;
import static org.boon.Exceptions.SoftenedException;
import com.coillighting.udder.util.CollectionUtil;
import com.coillighting.udder.util.StringUtil;
import static com.coillighting.udder.util.LogUtil.log;
String responseBody = "TODO GET " + index;
this.respond(response, responseBody);
}
private void handlePost(Request request, Response response) {
int index = this.requestIndex;
++this.requestIndex; // Increment before any possible exception.
String responseBody;
try {
Command command = this.createCommand(request);
if(command == null) {
throw new NullPointerException("Unreachable code: comand is null.");
} else {
boolean accepted = this.queue.offer(command);
if(accepted) {
response.setStatus(Status.OK);
responseBody = "OK " + index;
if(this.debug) log(command.toString() + ' ' + responseBody);
} else {
// For some reason, Status doesn't know about RFC 6585.
response.setCode(429);
response.setDescription("Too Many Requests");
responseBody = "DROPPED " + index;
if(this.debug) log("Request " + index + " for " + command + " dropped. No room in queue.");
}
}
} catch (RoutingException e) {
|
String routes = StringUtil.join(CollectionUtil.sorted(this.commandMap.keySet()), "\n ");
|
coil-lighting/udder
|
udder/src/main/java/com/coillighting/udder/geometry/wave/TriangleFloatWave.java
|
// Path: udder/src/main/java/com/coillighting/udder/geometry/Crossfade.java
// public class Crossfade {
//
// /** Linearly interpolate x, a value between 0 and 1, between two points,
// * (0, y0) and (1, y1). If you supply an x that is out of range, the
// * result will likewise be out of range.
// */
// public static final double linear(double x, double y0, double y1) {
// return y0 + x * (y1 - y0);
// }
//
// /** A 32-bit version of Crossfade.linear. */
// public static final float linear(float x, float y0, float y1) {
// return y0 + x * (y1 - y0);
// }
//
// /** For a fast attack followed by a slower follow-through, try an exponent
// * of 0.5 or 0.25. For a gradual attack with an accelerating follow-up,
// * try an exponent of 2-5. This is not really the shapliest easing curve
// * curve out there, but it's good to have in the arsenal.
// */
// public static final double exponential(double x, double exponent, double y0, double y1) {
// double balance = Reshape.exponential(x, exponent);
// return linear(balance, y0, y1);
// }
//
// /** A mostly 32-bit version of Crossfade.exponential. */
// public static final float exponential(float x, float exponent, float y0, float y1) {
// float balance = Reshape.exponential(x, exponent);
// return linear(balance, y0, y1);
// }
//
// /** Use a sinewave to approximate a sigmoidal cross-fade curve.
// * Submit this expression to wolframalpha.com to see the resulting curve:
// * 0.5*(1 + (sin((pi*(x-0.5)))))
// * Direct link:
// * http://www.wolframalpha.com/input/?i=0.5*%281+%2B+%28sin%28%28pi*%28x-0.5%29%29%29%29%29+from+-0.25+to+1.5
// */
// public static final double sinusoidal(double x, double y0, double y1) {
// double balance = Reshape.sinusoidal(x);
// return linear(balance, y0, y1);
// }
//
// /** A mostly 32-bit version of crossfadeExponential. */
// public static final float sinusoidal(float x, float y0, float y1) {
// float balance = Reshape.sinusoidal(x);
// return linear(balance, y0, y1);
// }
//
// // TODO logarithmic mode!
//
// }
|
import com.coillighting.udder.geometry.Crossfade;
|
package com.coillighting.udder.geometry.wave;
/** A linearly interpolated signal that continuously oscillates between two
* values, with sharp corners at the values themselves.
*/
public class TriangleFloatWave extends FloatWaveBase {
public TriangleFloatWave(float start, float end, long period) {
super(start, end, period);
}
public float interpolate(float x) {
float x0;
float x1;
if(x <= 0.5f) {
x0 = start;
x1 = end;
} else {
x -= 0.5f;
x0 = end;
x1 = start;
}
x *= 2.0f;
|
// Path: udder/src/main/java/com/coillighting/udder/geometry/Crossfade.java
// public class Crossfade {
//
// /** Linearly interpolate x, a value between 0 and 1, between two points,
// * (0, y0) and (1, y1). If you supply an x that is out of range, the
// * result will likewise be out of range.
// */
// public static final double linear(double x, double y0, double y1) {
// return y0 + x * (y1 - y0);
// }
//
// /** A 32-bit version of Crossfade.linear. */
// public static final float linear(float x, float y0, float y1) {
// return y0 + x * (y1 - y0);
// }
//
// /** For a fast attack followed by a slower follow-through, try an exponent
// * of 0.5 or 0.25. For a gradual attack with an accelerating follow-up,
// * try an exponent of 2-5. This is not really the shapliest easing curve
// * curve out there, but it's good to have in the arsenal.
// */
// public static final double exponential(double x, double exponent, double y0, double y1) {
// double balance = Reshape.exponential(x, exponent);
// return linear(balance, y0, y1);
// }
//
// /** A mostly 32-bit version of Crossfade.exponential. */
// public static final float exponential(float x, float exponent, float y0, float y1) {
// float balance = Reshape.exponential(x, exponent);
// return linear(balance, y0, y1);
// }
//
// /** Use a sinewave to approximate a sigmoidal cross-fade curve.
// * Submit this expression to wolframalpha.com to see the resulting curve:
// * 0.5*(1 + (sin((pi*(x-0.5)))))
// * Direct link:
// * http://www.wolframalpha.com/input/?i=0.5*%281+%2B+%28sin%28%28pi*%28x-0.5%29%29%29%29%29+from+-0.25+to+1.5
// */
// public static final double sinusoidal(double x, double y0, double y1) {
// double balance = Reshape.sinusoidal(x);
// return linear(balance, y0, y1);
// }
//
// /** A mostly 32-bit version of crossfadeExponential. */
// public static final float sinusoidal(float x, float y0, float y1) {
// float balance = Reshape.sinusoidal(x);
// return linear(balance, y0, y1);
// }
//
// // TODO logarithmic mode!
//
// }
// Path: udder/src/main/java/com/coillighting/udder/geometry/wave/TriangleFloatWave.java
import com.coillighting.udder.geometry.Crossfade;
package com.coillighting.udder.geometry.wave;
/** A linearly interpolated signal that continuously oscillates between two
* values, with sharp corners at the values themselves.
*/
public class TriangleFloatWave extends FloatWaveBase {
public TriangleFloatWave(float start, float end, long period) {
super(start, end, period);
}
public float interpolate(float x) {
float x0;
float x1;
if(x <= 0.5f) {
x0 = start;
x1 = end;
} else {
x -= 0.5f;
x0 = end;
x1 = start;
}
x *= 2.0f;
|
return Crossfade.linear(x, x0, x1);
|
coil-lighting/udder
|
udder/src/main/java/com/coillighting/udder/geometry/wave/FloatWaveBase.java
|
// Path: udder/src/main/java/com/coillighting/udder/mix/TimePoint.java
// public class TimePoint {
//
// /** The nomimally "real" time at which this frame was initialized. Although
// * this time is required by some animations which need to synchronize their
// * effects with the outside world -- a dusk/dawn almanac scheduler, for
// * instance -- you should ordinarily never refer to the realTimeMillis in
// * your animation functions. Instead, use TimePoint.sceneTimeMillis in
// * order to give the user the opportunity to apply timebase distortions.
// * Initialized with System.currentTimeMillis().
// *
// * Not to be confused with TimePoint.sceneTimeMillis.
// */
// private long realTimeMillis = 0;
//
// /** The reference time for all elements of the current scene. By using this
// * offset as the current time for timebase calculations in your animators,
// * you allow the user to apply timebase distortions, a powerful creative
// * tool. For ideas of what you might do with timebase distortions, sit
// * down with an old Invisibl Skratch Piklz, then imagine stretching and
// * reversing your graphical animations as if they were audio, at high rez.
// * This time is compatible with, but not necessarily identical to, the
// * "real" millisecond time offset returned by System.currentTimeMillis().
// * When a show is playing back in nominally real time, with no timebase
// * transformations or distortions, then this value will by convention
// * equal TimePoint.realTimeMillis minus the realTimeMillis when the show
// * started, and then this value will count up monotonically thereafter.
// * However, there is no guarantee that the user will choose to follow such
// * a straightforward path through time.
// *
// * Not to be confused with TimePoint.realTimeMillis.
// */
// private long sceneTimeMillis = 0;
//
// /** An integer counting the current frame. Normally a show begins at frame
// * 0 and proceeds to count up, +1 per frame, but there is no guarantee that
// * a user will configure a show to count incrementally. There is even no
// * guarantee that frameIndex will monotonically increase. However, a normal
// * show which doesn't replay its own history will by convention simply
// * start from 0 and monotonically increment +1 per animation loop.
// */
// private long frameIndex = 0;
//
// public TimePoint(long realTimeMillis, long sceneTimeMillis, long frameIndex) {
// this.realTimeMillis = realTimeMillis;
// this.sceneTimeMillis = sceneTimeMillis;
// this.frameIndex = frameIndex;
// }
//
// /** Copy constructor. */
// public TimePoint(TimePoint timePoint) {
// this.realTimeMillis = timePoint.realTimeMillis;
// this.sceneTimeMillis = timePoint.sceneTimeMillis;
// this.frameIndex = timePoint.frameIndex;
// }
//
// /** Initialize a TimePoint with the current system time as its nominally
// * "real" time offset. Start counting the scene time from 0 and frameIndex
// * at 0.
// */
// public TimePoint() {
// this.realTimeMillis = System.currentTimeMillis();
// this.sceneTimeMillis = 0;
// this.frameIndex = 0;
// }
//
// /** Return a new immutable TimePoint, incrementing frameIndex and updating
// * realTimeMillis and sceneTimeMillis on the assumption that the show is
// * taking a straightforward and undistorted path through time.
// */
// public TimePoint next() {
// long realTime = System.currentTimeMillis();
// long sceneTimeOffsetMillis = this.realTimeMillis - this.sceneTimeMillis;
// return new TimePoint(
// realTime,
// realTime - sceneTimeOffsetMillis,
// 1 + this.frameIndex);
// }
//
// public long realTimeMillis() {
// return this.realTimeMillis;
// }
//
// public long sceneTimeMillis() {
// return this.sceneTimeMillis;
// }
//
// public long getFrameIndex() {
// return this.frameIndex;
// }
//
// public String toString() {
// return "" + this.sceneTimeMillis + "ms [#" + this.frameIndex + ']';
// }
//
// }
|
import com.coillighting.udder.mix.TimePoint;
|
package com.coillighting.udder.geometry.wave;
/** Abstract base class for removing boilerplate from the implementation of
* periodic floating-point signal generators.
*/
public abstract class FloatWaveBase implements Wave<Float> {
protected float start = 0.0f;
protected float end = 0.0f;
protected long period = 0;
public FloatWaveBase(float start, float end, long period) {
this.start = start;
this.end = end;
this.period = period;
}
|
// Path: udder/src/main/java/com/coillighting/udder/mix/TimePoint.java
// public class TimePoint {
//
// /** The nomimally "real" time at which this frame was initialized. Although
// * this time is required by some animations which need to synchronize their
// * effects with the outside world -- a dusk/dawn almanac scheduler, for
// * instance -- you should ordinarily never refer to the realTimeMillis in
// * your animation functions. Instead, use TimePoint.sceneTimeMillis in
// * order to give the user the opportunity to apply timebase distortions.
// * Initialized with System.currentTimeMillis().
// *
// * Not to be confused with TimePoint.sceneTimeMillis.
// */
// private long realTimeMillis = 0;
//
// /** The reference time for all elements of the current scene. By using this
// * offset as the current time for timebase calculations in your animators,
// * you allow the user to apply timebase distortions, a powerful creative
// * tool. For ideas of what you might do with timebase distortions, sit
// * down with an old Invisibl Skratch Piklz, then imagine stretching and
// * reversing your graphical animations as if they were audio, at high rez.
// * This time is compatible with, but not necessarily identical to, the
// * "real" millisecond time offset returned by System.currentTimeMillis().
// * When a show is playing back in nominally real time, with no timebase
// * transformations or distortions, then this value will by convention
// * equal TimePoint.realTimeMillis minus the realTimeMillis when the show
// * started, and then this value will count up monotonically thereafter.
// * However, there is no guarantee that the user will choose to follow such
// * a straightforward path through time.
// *
// * Not to be confused with TimePoint.realTimeMillis.
// */
// private long sceneTimeMillis = 0;
//
// /** An integer counting the current frame. Normally a show begins at frame
// * 0 and proceeds to count up, +1 per frame, but there is no guarantee that
// * a user will configure a show to count incrementally. There is even no
// * guarantee that frameIndex will monotonically increase. However, a normal
// * show which doesn't replay its own history will by convention simply
// * start from 0 and monotonically increment +1 per animation loop.
// */
// private long frameIndex = 0;
//
// public TimePoint(long realTimeMillis, long sceneTimeMillis, long frameIndex) {
// this.realTimeMillis = realTimeMillis;
// this.sceneTimeMillis = sceneTimeMillis;
// this.frameIndex = frameIndex;
// }
//
// /** Copy constructor. */
// public TimePoint(TimePoint timePoint) {
// this.realTimeMillis = timePoint.realTimeMillis;
// this.sceneTimeMillis = timePoint.sceneTimeMillis;
// this.frameIndex = timePoint.frameIndex;
// }
//
// /** Initialize a TimePoint with the current system time as its nominally
// * "real" time offset. Start counting the scene time from 0 and frameIndex
// * at 0.
// */
// public TimePoint() {
// this.realTimeMillis = System.currentTimeMillis();
// this.sceneTimeMillis = 0;
// this.frameIndex = 0;
// }
//
// /** Return a new immutable TimePoint, incrementing frameIndex and updating
// * realTimeMillis and sceneTimeMillis on the assumption that the show is
// * taking a straightforward and undistorted path through time.
// */
// public TimePoint next() {
// long realTime = System.currentTimeMillis();
// long sceneTimeOffsetMillis = this.realTimeMillis - this.sceneTimeMillis;
// return new TimePoint(
// realTime,
// realTime - sceneTimeOffsetMillis,
// 1 + this.frameIndex);
// }
//
// public long realTimeMillis() {
// return this.realTimeMillis;
// }
//
// public long sceneTimeMillis() {
// return this.sceneTimeMillis;
// }
//
// public long getFrameIndex() {
// return this.frameIndex;
// }
//
// public String toString() {
// return "" + this.sceneTimeMillis + "ms [#" + this.frameIndex + ']';
// }
//
// }
// Path: udder/src/main/java/com/coillighting/udder/geometry/wave/FloatWaveBase.java
import com.coillighting.udder.mix.TimePoint;
package com.coillighting.udder.geometry.wave;
/** Abstract base class for removing boilerplate from the implementation of
* periodic floating-point signal generators.
*/
public abstract class FloatWaveBase implements Wave<Float> {
protected float start = 0.0f;
protected float end = 0.0f;
protected long period = 0;
public FloatWaveBase(float start, float end, long period) {
this.start = start;
this.end = end;
this.period = period;
}
|
public Float getValue(TimePoint time) {
|
coil-lighting/udder
|
udder/src/main/java/com/coillighting/udder/infrastructure/PatchElement.java
|
// Path: udder/src/main/java/com/coillighting/udder/model/Device.java
// public class Device extends Object {
//
// /** This Device's address in some arbitrary address space. For the dairy,
// * this address is in the space of a single OPC channel.
// *
// * FUTURE Multiple channels/universes.
// *
// * Not public because no effects should be computed on the basis of a
// * Device's address.
// */
// protected int addr = 0;
//
// /** A dirt simple grouping mechanism. Each Device belongs to exactly one
// * group (for now). For the Dairy installation, this will indicate gate
// * 0 or gate 1, in case an Animator cares which group the Device is in.
// *
// * Public because device group computations happen in the hottest inner loop.
// */
// public int group=0;
//
// /** Position in model space. Public because device positional
// * computations happen in the hottest inner loop.
// */
// public double x = 0.0;
// public double y = 0.0;
// public double z = 0.0;
//
// public Device(int addr, int group, double x, double y, double z) {
// if(addr < 0) {
// throw new IllegalArgumentException("Invalid Device address: " + addr);
// } else if(group < 0) {
// throw new IllegalArgumentException("Negative group index: " + addr);
// }
// this.addr = addr;
// this.group = group;
// this.x = x;
// this.y = y;
// this.z = z;
// }
//
// public String toString() {
// return "Device @"+addr+" ["+group+"] ("+x+","+y+","+z+")";
// }
//
// public int getAddr() {
// return this.addr;
// }
//
// public int getGroup() {
// return this.group;
// }
//
// // TODO refactor x, y and z as a double[] for consistency with other classes? or refactor as a Point3D (see below). We should standardize here.
// public double[] getPoint() {
// return new double[]{x, y, z};
// }
//
// public Point3D getPoint3D() {
// return new Point3D(x, y, z);
// }
//
// /** Return the 3D bounding box for the given devices. */
// public static BoundingCube getDeviceBoundingCube(Device[] devices) {
// if(devices==null) {
// return null;
// } else {
// // FIXME: determine the real min and max values that will compare properly.
// // A seed value of Double.MAX_VALUE did not work with all comparisons here. WTF?
// // For now you must place your devices within this cube, sorry:
// final double MAX_VALUE = 999999999.0;
// final double MIN_VALUE = -999999999.0;
//
// double minx=MAX_VALUE;
// double maxx=MIN_VALUE;
// double miny=MAX_VALUE;
// double maxy=MIN_VALUE;
// double minz=MAX_VALUE;
// double maxz=MIN_VALUE;
//
// for(Device d: devices) {
// double x = d.x;
// double y = d.y;
// double z = d.z;
// if(x < minx) minx = x;
// if(x > maxx) maxx = x;
// if(y < miny) miny = y;
// if(y > maxy) maxy = y;
// if(z < minz) minz = z;
// if(z > maxz) maxz = z;
// }
// return new BoundingCube(minx, miny, minz,
// maxx-minx, maxy-miny, maxz-minz);
// }
// }
// }
|
import com.coillighting.udder.model.Device;
|
package com.coillighting.udder.infrastructure;
/** This class is used as a JSON schema spec and output datatype for the Boon
* JsonFactory when it deserializes JSON patch sheets exported from Eric's
* visualizer. This is just an intermediate representation. We immediately
* convert these PatchElements to Devices after parsing.
*
* Example input consisting of three JSON-serialized PatchElements:
*
* [{
* "point": [-111, 92.33984355642154, -78.20986874321204],
* "group": 0,
* "address": 57
* }, {
* "point": [-111, 93.58520914575311, -78.05527879900943],
* "group": 0,
* "address": 56
* }, {
* "point": [-111, 94.70067095432645, -77.91681404627441],
* "group": 0,
* "address": 55
* }]
*
* Like Command and PatchElement, this class is structured for compatibility
* with the Boon JsonFactory, which automatically binds JSON bidirectionally
* to Java classes which adhere to its preferred (bean-style) layout.
*/
public class PatchElement {
private double[] point;
private int group;
private int address;
public PatchElement(double[] point, int group, int address) {
if(address < 0) throw new IllegalArgumentException("Negative device address: " + address);
if(group < 0) throw new IllegalArgumentException("Negative group index: " + group);
this.point = point;
this.group = group;
this.address = address;
this.getZ(); // validates point is between 1 and 3 dimensions
}
/* A 1D layout is mandatory. 2D is optional. Return y=0 if unspecified. */
private double getY() {
double y=0.0;
if(this.point == null) {
throw new IllegalArgumentException(
"You must provide a point in space for each output device in the patch sheet.");
} else if(this.point.length >= 2) {
y = this.point[1];
} else {
throw new IllegalArgumentException("Udder does not support "
+ this.point.length + "-dimensional shows.");
}
return y;
}
/* A 1D layout is mandatory. 3D is optional. Return z=0 if unspecified. */
private double getZ() {
double z=0.0;
if(this.point == null) {
throw new IllegalArgumentException(
"You must provide a point in space for each output device in the patch sheet.");
} else if(this.point.length == 3) {
z = this.point[2];
} else {
throw new IllegalArgumentException("Udder does not support "
+ this.point.length + "-dimensional shows.");
}
return z;
}
/** Convert this intermediate representation into a full-fledged 3D Udder
* Device.
*/
|
// Path: udder/src/main/java/com/coillighting/udder/model/Device.java
// public class Device extends Object {
//
// /** This Device's address in some arbitrary address space. For the dairy,
// * this address is in the space of a single OPC channel.
// *
// * FUTURE Multiple channels/universes.
// *
// * Not public because no effects should be computed on the basis of a
// * Device's address.
// */
// protected int addr = 0;
//
// /** A dirt simple grouping mechanism. Each Device belongs to exactly one
// * group (for now). For the Dairy installation, this will indicate gate
// * 0 or gate 1, in case an Animator cares which group the Device is in.
// *
// * Public because device group computations happen in the hottest inner loop.
// */
// public int group=0;
//
// /** Position in model space. Public because device positional
// * computations happen in the hottest inner loop.
// */
// public double x = 0.0;
// public double y = 0.0;
// public double z = 0.0;
//
// public Device(int addr, int group, double x, double y, double z) {
// if(addr < 0) {
// throw new IllegalArgumentException("Invalid Device address: " + addr);
// } else if(group < 0) {
// throw new IllegalArgumentException("Negative group index: " + addr);
// }
// this.addr = addr;
// this.group = group;
// this.x = x;
// this.y = y;
// this.z = z;
// }
//
// public String toString() {
// return "Device @"+addr+" ["+group+"] ("+x+","+y+","+z+")";
// }
//
// public int getAddr() {
// return this.addr;
// }
//
// public int getGroup() {
// return this.group;
// }
//
// // TODO refactor x, y and z as a double[] for consistency with other classes? or refactor as a Point3D (see below). We should standardize here.
// public double[] getPoint() {
// return new double[]{x, y, z};
// }
//
// public Point3D getPoint3D() {
// return new Point3D(x, y, z);
// }
//
// /** Return the 3D bounding box for the given devices. */
// public static BoundingCube getDeviceBoundingCube(Device[] devices) {
// if(devices==null) {
// return null;
// } else {
// // FIXME: determine the real min and max values that will compare properly.
// // A seed value of Double.MAX_VALUE did not work with all comparisons here. WTF?
// // For now you must place your devices within this cube, sorry:
// final double MAX_VALUE = 999999999.0;
// final double MIN_VALUE = -999999999.0;
//
// double minx=MAX_VALUE;
// double maxx=MIN_VALUE;
// double miny=MAX_VALUE;
// double maxy=MIN_VALUE;
// double minz=MAX_VALUE;
// double maxz=MIN_VALUE;
//
// for(Device d: devices) {
// double x = d.x;
// double y = d.y;
// double z = d.z;
// if(x < minx) minx = x;
// if(x > maxx) maxx = x;
// if(y < miny) miny = y;
// if(y > maxy) maxy = y;
// if(z < minz) minz = z;
// if(z > maxz) maxz = z;
// }
// return new BoundingCube(minx, miny, minz,
// maxx-minx, maxy-miny, maxz-minz);
// }
// }
// }
// Path: udder/src/main/java/com/coillighting/udder/infrastructure/PatchElement.java
import com.coillighting.udder.model.Device;
package com.coillighting.udder.infrastructure;
/** This class is used as a JSON schema spec and output datatype for the Boon
* JsonFactory when it deserializes JSON patch sheets exported from Eric's
* visualizer. This is just an intermediate representation. We immediately
* convert these PatchElements to Devices after parsing.
*
* Example input consisting of three JSON-serialized PatchElements:
*
* [{
* "point": [-111, 92.33984355642154, -78.20986874321204],
* "group": 0,
* "address": 57
* }, {
* "point": [-111, 93.58520914575311, -78.05527879900943],
* "group": 0,
* "address": 56
* }, {
* "point": [-111, 94.70067095432645, -77.91681404627441],
* "group": 0,
* "address": 55
* }]
*
* Like Command and PatchElement, this class is structured for compatibility
* with the Boon JsonFactory, which automatically binds JSON bidirectionally
* to Java classes which adhere to its preferred (bean-style) layout.
*/
public class PatchElement {
private double[] point;
private int group;
private int address;
public PatchElement(double[] point, int group, int address) {
if(address < 0) throw new IllegalArgumentException("Negative device address: " + address);
if(group < 0) throw new IllegalArgumentException("Negative group index: " + group);
this.point = point;
this.group = group;
this.address = address;
this.getZ(); // validates point is between 1 and 3 dimensions
}
/* A 1D layout is mandatory. 2D is optional. Return y=0 if unspecified. */
private double getY() {
double y=0.0;
if(this.point == null) {
throw new IllegalArgumentException(
"You must provide a point in space for each output device in the patch sheet.");
} else if(this.point.length >= 2) {
y = this.point[1];
} else {
throw new IllegalArgumentException("Udder does not support "
+ this.point.length + "-dimensional shows.");
}
return y;
}
/* A 1D layout is mandatory. 3D is optional. Return z=0 if unspecified. */
private double getZ() {
double z=0.0;
if(this.point == null) {
throw new IllegalArgumentException(
"You must provide a point in space for each output device in the patch sheet.");
} else if(this.point.length == 3) {
z = this.point[2];
} else {
throw new IllegalArgumentException("Udder does not support "
+ this.point.length + "-dimensional shows.");
}
return z;
}
/** Convert this intermediate representation into a full-fledged 3D Udder
* Device.
*/
|
public Device toDevice() {
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.