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 |
|---|---|---|---|---|---|---|
AtomicBlom/ShearMadness | src/main/java/com/github/atomicblom/shearmadness/api/ShearMadnessVariation.java | // Path: src/api/java/com/github/atomicblom/shearmadness/api/modelmaker/IModelMaker.java
// @FunctionalInterface
// @SideOnly(Side.CLIENT)
// public interface IModelMaker
// {
//
// /**
// * Create a model for a quadruped entity based on what has been chiseled onto it.
// * @param itemStack The item that was in the chisel when it was applied to the entity
// * @param entity The entity to create a model for
// * @return a model for the given itemStack
// */
// ModelQuadruped createModel(ItemStack itemStack, EntityLivingBase entity);
//
// /**
// * Utility method to convert an IBakedModel to a ModelRenderer for use on an entity body part.
// * @param partDefinition transforms for the body part
// * @param blockState block state to use when retrieving the model
// * @param model the IBakedModel to transform
// * @return a body part for the entity
// */
// default ModelRenderer getModelRendererForBlockState(PartDefinition partDefinition, IBlockState blockState, IBakedModel model)
// {
// final ModelRenderer renderer = new ModelRenderer(new ModelSheep1(), 0, 0);
// if (partDefinition == null) {
// return renderer;
// }
// renderer.setRotationPoint(
// partDefinition.getRotationPoint().x,
// partDefinition.getRotationPoint().y,
// partDefinition.getRotationPoint().z
// );
//
// final EntityMesh box = new EntityMesh(renderer);
//
// addBlockModelToEntityMesh(box, partDefinition, blockState, model);
//
// renderer.cubeList.add(box);
// return renderer;
// }
//
// default ModelRenderer createModelRenderer(PartDefinition partDefinition) {
// final ModelRenderer renderer = new ModelRenderer(new ModelSheep1(), 0, 0);
// if (partDefinition == null) {
// return renderer;
// }
// renderer.setRotationPoint(
// partDefinition.getRotationPoint().x,
// partDefinition.getRotationPoint().y,
// partDefinition.getRotationPoint().z
// );
//
// return renderer;
// }
//
// default EntityMesh addBlockModelToEntityMesh(EntityMesh box, PartDefinition partDefinition, IBlockState blockState, IBakedModel model) {
// final Matrix4f positionTransform = partDefinition.getPositionTransform();
// final Matrix3f textureTransform = partDefinition.getTextureTransform();
// //FIXME: When chisel start reporting their render layers correctly, we can improve this logic.
// //if (blockState == null || blockState.getBlock().canRenderInLayer(blockState, BlockRenderLayer.SOLID)) {
// ForgeHooksClient.setRenderLayer(BlockRenderLayer.SOLID);
// for (final EnumFacing value : EnumFacing.VALUES)
// {
// box.addBakedQuads(positionTransform, textureTransform, model.getQuads(blockState, value, 0));
// }
// box.addBakedQuads(positionTransform, textureTransform, model.getQuads(blockState, null, 0));
// //}
// //if (blockState != null && blockState.getBlock().canRenderInLayer(blockState, BlockRenderLayer.CUTOUT)) {
// ForgeHooksClient.setRenderLayer(BlockRenderLayer.CUTOUT);
// for (final EnumFacing value : EnumFacing.VALUES)
// {
// box.addBakedQuads(positionTransform, textureTransform, model.getQuads(blockState, value, 0));
// }
// box.addBakedQuads(positionTransform, textureTransform, model.getQuads(blockState, null, 0));
// //}
// //if (blockState != null && blockState.getBlock().canRenderInLayer(blockState, BlockRenderLayer.CUTOUT_MIPPED)) {
// ForgeHooksClient.setRenderLayer(BlockRenderLayer.CUTOUT_MIPPED);
// for (final EnumFacing value : EnumFacing.VALUES)
// {
// box.addBakedQuads(positionTransform, textureTransform, model.getQuads(blockState, value, 0));
// }
// box.addBakedQuads(positionTransform, textureTransform, model.getQuads(blockState, null, 0));
// //}
// /*if (blockState != null && blockState.getBlock().canRenderInLayer(blockState, BlockRenderLayer.TRANSLUCENT)) {
// ForgeHooksClient.setRenderLayer(BlockRenderLayer.TRANSLUCENT);
// for (final EnumFacing value : EnumFacing.VALUES)
// {
// box.addBakedQuads(positionTransform, textureTransform, model.getQuads(blockState, value, 0));
// }
// box.addBakedQuads(positionTransform, textureTransform, model.getQuads(blockState, null, 0));
// //}*/
//
// ForgeHooksClient.setRenderLayer(null);
// return box;
// }
//
// default IBakedModel getBakedModelForItem(ItemStack item, EntityLivingBase entity) {
// final RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
// IBakedModel itemModel = renderItem.getItemModelMesher().getItemModel(item);
// itemModel = itemModel.getOverrides().handleItemState(itemModel, item, Minecraft.getMinecraft().theWorld, entity);
// return itemModel;
// }
// }
| import com.github.atomicblom.shearmadness.api.modelmaker.IModelMaker;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.function.Function; | package com.github.atomicblom.shearmadness.api;
@SideOnly(Side.CLIENT)
class ShearMadnessVariation {
private final Function<ItemStack, Boolean> handlesVariant; | // Path: src/api/java/com/github/atomicblom/shearmadness/api/modelmaker/IModelMaker.java
// @FunctionalInterface
// @SideOnly(Side.CLIENT)
// public interface IModelMaker
// {
//
// /**
// * Create a model for a quadruped entity based on what has been chiseled onto it.
// * @param itemStack The item that was in the chisel when it was applied to the entity
// * @param entity The entity to create a model for
// * @return a model for the given itemStack
// */
// ModelQuadruped createModel(ItemStack itemStack, EntityLivingBase entity);
//
// /**
// * Utility method to convert an IBakedModel to a ModelRenderer for use on an entity body part.
// * @param partDefinition transforms for the body part
// * @param blockState block state to use when retrieving the model
// * @param model the IBakedModel to transform
// * @return a body part for the entity
// */
// default ModelRenderer getModelRendererForBlockState(PartDefinition partDefinition, IBlockState blockState, IBakedModel model)
// {
// final ModelRenderer renderer = new ModelRenderer(new ModelSheep1(), 0, 0);
// if (partDefinition == null) {
// return renderer;
// }
// renderer.setRotationPoint(
// partDefinition.getRotationPoint().x,
// partDefinition.getRotationPoint().y,
// partDefinition.getRotationPoint().z
// );
//
// final EntityMesh box = new EntityMesh(renderer);
//
// addBlockModelToEntityMesh(box, partDefinition, blockState, model);
//
// renderer.cubeList.add(box);
// return renderer;
// }
//
// default ModelRenderer createModelRenderer(PartDefinition partDefinition) {
// final ModelRenderer renderer = new ModelRenderer(new ModelSheep1(), 0, 0);
// if (partDefinition == null) {
// return renderer;
// }
// renderer.setRotationPoint(
// partDefinition.getRotationPoint().x,
// partDefinition.getRotationPoint().y,
// partDefinition.getRotationPoint().z
// );
//
// return renderer;
// }
//
// default EntityMesh addBlockModelToEntityMesh(EntityMesh box, PartDefinition partDefinition, IBlockState blockState, IBakedModel model) {
// final Matrix4f positionTransform = partDefinition.getPositionTransform();
// final Matrix3f textureTransform = partDefinition.getTextureTransform();
// //FIXME: When chisel start reporting their render layers correctly, we can improve this logic.
// //if (blockState == null || blockState.getBlock().canRenderInLayer(blockState, BlockRenderLayer.SOLID)) {
// ForgeHooksClient.setRenderLayer(BlockRenderLayer.SOLID);
// for (final EnumFacing value : EnumFacing.VALUES)
// {
// box.addBakedQuads(positionTransform, textureTransform, model.getQuads(blockState, value, 0));
// }
// box.addBakedQuads(positionTransform, textureTransform, model.getQuads(blockState, null, 0));
// //}
// //if (blockState != null && blockState.getBlock().canRenderInLayer(blockState, BlockRenderLayer.CUTOUT)) {
// ForgeHooksClient.setRenderLayer(BlockRenderLayer.CUTOUT);
// for (final EnumFacing value : EnumFacing.VALUES)
// {
// box.addBakedQuads(positionTransform, textureTransform, model.getQuads(blockState, value, 0));
// }
// box.addBakedQuads(positionTransform, textureTransform, model.getQuads(blockState, null, 0));
// //}
// //if (blockState != null && blockState.getBlock().canRenderInLayer(blockState, BlockRenderLayer.CUTOUT_MIPPED)) {
// ForgeHooksClient.setRenderLayer(BlockRenderLayer.CUTOUT_MIPPED);
// for (final EnumFacing value : EnumFacing.VALUES)
// {
// box.addBakedQuads(positionTransform, textureTransform, model.getQuads(blockState, value, 0));
// }
// box.addBakedQuads(positionTransform, textureTransform, model.getQuads(blockState, null, 0));
// //}
// /*if (blockState != null && blockState.getBlock().canRenderInLayer(blockState, BlockRenderLayer.TRANSLUCENT)) {
// ForgeHooksClient.setRenderLayer(BlockRenderLayer.TRANSLUCENT);
// for (final EnumFacing value : EnumFacing.VALUES)
// {
// box.addBakedQuads(positionTransform, textureTransform, model.getQuads(blockState, value, 0));
// }
// box.addBakedQuads(positionTransform, textureTransform, model.getQuads(blockState, null, 0));
// //}*/
//
// ForgeHooksClient.setRenderLayer(null);
// return box;
// }
//
// default IBakedModel getBakedModelForItem(ItemStack item, EntityLivingBase entity) {
// final RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
// IBakedModel itemModel = renderItem.getItemModelMesher().getItemModel(item);
// itemModel = itemModel.getOverrides().handleItemState(itemModel, item, Minecraft.getMinecraft().theWorld, entity);
// return itemModel;
// }
// }
// Path: src/main/java/com/github/atomicblom/shearmadness/api/ShearMadnessVariation.java
import com.github.atomicblom.shearmadness.api.modelmaker.IModelMaker;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.function.Function;
package com.github.atomicblom.shearmadness.api;
@SideOnly(Side.CLIENT)
class ShearMadnessVariation {
private final Function<ItemStack, Boolean> handlesVariant; | private final IModelMaker variationModelMaker; |
AtomicBlom/ShearMadness | src/api/java/com/github/atomicblom/shearmadness/api/events/RegisterShearMadnessBehaviourEvent.java | // Path: src/api/java/com/github/atomicblom/shearmadness/api/IBehaviourRegistry.java
// public interface IBehaviourRegistry {
//
// /**
// * Registers a Model Maker that will be used when the function predicate matches
// * @param handlesVariant a function that should return true if your IModelMaker applies to the itemStack
// * @param behaviourFactory the factory to create a behaviour for the sheep.
// */
// void registerBehaviour(Function<ItemStack, Boolean> handlesVariant, Function<EntitySheep, BehaviourBase> behaviourFactory);
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/IVariationRegistry.java
// @SideOnly(Side.CLIENT)
// public interface IVariationRegistry
// {
// /**
// * Registers a Model Maker that will be used when the function predicate matches
// * @param handlesVariant a function that should return true if your IModelMaker applies to the itemStack
// * @param variationModelMaker the model maker that will make the model for the quadruped.
// */
// void registerVariation(Function<ItemStack, Boolean> handlesVariant, IModelMaker variationModelMaker);
//
// /**
// * Registers a Model Maker that will be used when the function predicate matches using the default model maker
// * with custom transformations.
// * @param handlesVariant a function that should return true if your IModelMaker applies to the itemStack
// * @param transformDefinition the transforms for the model
// */
// void registerVariation(Function<ItemStack, Boolean> handlesVariant, QuadrupedTransformDefinition transformDefinition);
// }
| import com.github.atomicblom.shearmadness.api.IBehaviourRegistry;
import com.github.atomicblom.shearmadness.api.IVariationRegistry;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; | package com.github.atomicblom.shearmadness.api.events;
/**
* Fired during the init phase of Forge, provides a mechanism for mods to register
* how their sheep should behave by Shear Madness.
*/
public class RegisterShearMadnessBehaviourEvent extends Event
{ | // Path: src/api/java/com/github/atomicblom/shearmadness/api/IBehaviourRegistry.java
// public interface IBehaviourRegistry {
//
// /**
// * Registers a Model Maker that will be used when the function predicate matches
// * @param handlesVariant a function that should return true if your IModelMaker applies to the itemStack
// * @param behaviourFactory the factory to create a behaviour for the sheep.
// */
// void registerBehaviour(Function<ItemStack, Boolean> handlesVariant, Function<EntitySheep, BehaviourBase> behaviourFactory);
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/IVariationRegistry.java
// @SideOnly(Side.CLIENT)
// public interface IVariationRegistry
// {
// /**
// * Registers a Model Maker that will be used when the function predicate matches
// * @param handlesVariant a function that should return true if your IModelMaker applies to the itemStack
// * @param variationModelMaker the model maker that will make the model for the quadruped.
// */
// void registerVariation(Function<ItemStack, Boolean> handlesVariant, IModelMaker variationModelMaker);
//
// /**
// * Registers a Model Maker that will be used when the function predicate matches using the default model maker
// * with custom transformations.
// * @param handlesVariant a function that should return true if your IModelMaker applies to the itemStack
// * @param transformDefinition the transforms for the model
// */
// void registerVariation(Function<ItemStack, Boolean> handlesVariant, QuadrupedTransformDefinition transformDefinition);
// }
// Path: src/api/java/com/github/atomicblom/shearmadness/api/events/RegisterShearMadnessBehaviourEvent.java
import com.github.atomicblom.shearmadness.api.IBehaviourRegistry;
import com.github.atomicblom.shearmadness.api.IVariationRegistry;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
package com.github.atomicblom.shearmadness.api.events;
/**
* Fired during the init phase of Forge, provides a mechanism for mods to register
* how their sheep should behave by Shear Madness.
*/
public class RegisterShearMadnessBehaviourEvent extends Event
{ | private final IBehaviourRegistry registry; |
AtomicBlom/ShearMadness | src/api/java/com/github/atomicblom/shearmadness/api/modelmaker/DefaultModelMaker.java | // Path: src/api/java/com/github/atomicblom/shearmadness/api/rendering/QuadrupedTransformDefinition.java
// @SuppressWarnings({"OptionalUsedAsFieldOrParameterType", "ProtectedField"})
// @SideOnly(Side.CLIENT)
// public class QuadrupedTransformDefinition
// {
// public QuadrupedTransformDefinition()
// {
// bodyPartDefinition = Optional.empty();
// headPartDefinition = Optional.empty();
// leg1PartDefinition = Optional.empty();
// leg2PartDefinition = Optional.empty();
// leg3PartDefinition = Optional.empty();
// leg4PartDefinition = Optional.empty();
// defineParts();
// }
//
// protected static final float NintyDegrees = 3.141592653589793f;
//
// protected Optional<PartDefinition> bodyPartDefinition = Optional.empty();
// protected Optional<PartDefinition> headPartDefinition = Optional.empty();
// protected Optional<PartDefinition> leg1PartDefinition = Optional.empty();
// protected Optional<PartDefinition> leg2PartDefinition = Optional.empty();
// protected Optional<PartDefinition> leg3PartDefinition = Optional.empty();
// protected Optional<PartDefinition> leg4PartDefinition = Optional.empty();
//
// public void defineParts()
// {
// final Matrix4f rotate = new Matrix4f().rotate((float) Math.toRadians(-90), new Vector3f(1, 0, 0));
// bodyPartDefinition = Optional.of(new PartDefinition(
// new Vector3f(0.0f, 5.0f, 2.0f),
// Matrix4f.mul(
// createPartMatrix(
// new Vector3f(12, 20, 10),
// new Vector3f(0, -2, -14)), rotate, null),
// new Matrix3f()
// ));
//
// headPartDefinition = Optional.of(new PartDefinition(
// new Vector3f(0.0f, 6.0f, -8.0f),
// createPartMatrix(
// new Vector3f(8, 8, 8),
// new Vector3f(0, -1, -1)),
// new Matrix3f()
// ));
//
// leg1PartDefinition = Optional.of(new PartDefinition(
// new Vector3f(-3.0f, 12.0f, 7.0f),
// createPartMatrix(
// new Vector3f(5.6f, 7.4f, 5.6f),
// new Vector3f(0, 3, 0.1f)),
// new Matrix3f()
// ));
//
// leg2PartDefinition = Optional.of(new PartDefinition(
// new Vector3f(3.0f, 12.0f, 7.0f),
// createPartMatrix(
// new Vector3f(5.6f, 7.4f, 5.6f),
// new Vector3f(0, 3, 0.1f)),
// new Matrix3f()
// ));
//
// leg3PartDefinition = Optional.of(new PartDefinition(
// new Vector3f(-3.0f, 12.0f, -5.0f),
// createPartMatrix(
// new Vector3f(5.6f, 7.4f, 5.6f),
// new Vector3f(0, 3, 0.1f)),
// new Matrix3f()
// ));
//
// leg4PartDefinition = Optional.of(new PartDefinition(
// new Vector3f(3.0f, 12.0f, -5.0f),
// createPartMatrix(
// new Vector3f(5.6f, 7.4f, 5.6f),
// new Vector3f(0, 3, 0.1f)),
// new Matrix3f()
// ));
// }
//
// protected static Matrix4f createPartMatrix(Vector3f size, Vector3f additionalTranslate)
// {
// final Vector3f adjustedSize = size.translate(-0.5f, -0.5f, -0.5f);
// final Matrix4f matrix = new Matrix4f();
//
// matrix.rotate(NintyDegrees, new Vector3f(1, 0, 0));
// matrix.translate(
// (Vector3f) Vector3f.add(
// (Vector3f) new Vector3f(adjustedSize).scale(0.5f),
// additionalTranslate,
// null
// ).negate());
// matrix.scale(adjustedSize);
// return matrix;
// }
//
// public Optional<PartDefinition> getBodyPartDefinition()
// {
// return bodyPartDefinition;
// }
//
// public Optional<PartDefinition> getHeadPartDefinition()
// {
// return headPartDefinition;
// }
//
// public Optional<PartDefinition> getLeg1PartDefinition()
// {
// return leg1PartDefinition;
// }
//
// public Optional<PartDefinition> getLeg2PartDefinition()
// {
// return leg2PartDefinition;
// }
//
// public Optional<PartDefinition> getLeg3PartDefinition()
// {
// return leg3PartDefinition;
// }
//
// public Optional<PartDefinition> getLeg4PartDefinition()
// {
// return leg4PartDefinition;
// }
// }
| import com.github.atomicblom.shearmadness.api.rendering.QuadrupedTransformDefinition;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelQuadruped;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.model.ModelSheep1;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack; | package com.github.atomicblom.shearmadness.api.modelmaker;
@SuppressWarnings("ClassHasNoToStringMethod")
public class DefaultModelMaker implements IModelMaker
{ | // Path: src/api/java/com/github/atomicblom/shearmadness/api/rendering/QuadrupedTransformDefinition.java
// @SuppressWarnings({"OptionalUsedAsFieldOrParameterType", "ProtectedField"})
// @SideOnly(Side.CLIENT)
// public class QuadrupedTransformDefinition
// {
// public QuadrupedTransformDefinition()
// {
// bodyPartDefinition = Optional.empty();
// headPartDefinition = Optional.empty();
// leg1PartDefinition = Optional.empty();
// leg2PartDefinition = Optional.empty();
// leg3PartDefinition = Optional.empty();
// leg4PartDefinition = Optional.empty();
// defineParts();
// }
//
// protected static final float NintyDegrees = 3.141592653589793f;
//
// protected Optional<PartDefinition> bodyPartDefinition = Optional.empty();
// protected Optional<PartDefinition> headPartDefinition = Optional.empty();
// protected Optional<PartDefinition> leg1PartDefinition = Optional.empty();
// protected Optional<PartDefinition> leg2PartDefinition = Optional.empty();
// protected Optional<PartDefinition> leg3PartDefinition = Optional.empty();
// protected Optional<PartDefinition> leg4PartDefinition = Optional.empty();
//
// public void defineParts()
// {
// final Matrix4f rotate = new Matrix4f().rotate((float) Math.toRadians(-90), new Vector3f(1, 0, 0));
// bodyPartDefinition = Optional.of(new PartDefinition(
// new Vector3f(0.0f, 5.0f, 2.0f),
// Matrix4f.mul(
// createPartMatrix(
// new Vector3f(12, 20, 10),
// new Vector3f(0, -2, -14)), rotate, null),
// new Matrix3f()
// ));
//
// headPartDefinition = Optional.of(new PartDefinition(
// new Vector3f(0.0f, 6.0f, -8.0f),
// createPartMatrix(
// new Vector3f(8, 8, 8),
// new Vector3f(0, -1, -1)),
// new Matrix3f()
// ));
//
// leg1PartDefinition = Optional.of(new PartDefinition(
// new Vector3f(-3.0f, 12.0f, 7.0f),
// createPartMatrix(
// new Vector3f(5.6f, 7.4f, 5.6f),
// new Vector3f(0, 3, 0.1f)),
// new Matrix3f()
// ));
//
// leg2PartDefinition = Optional.of(new PartDefinition(
// new Vector3f(3.0f, 12.0f, 7.0f),
// createPartMatrix(
// new Vector3f(5.6f, 7.4f, 5.6f),
// new Vector3f(0, 3, 0.1f)),
// new Matrix3f()
// ));
//
// leg3PartDefinition = Optional.of(new PartDefinition(
// new Vector3f(-3.0f, 12.0f, -5.0f),
// createPartMatrix(
// new Vector3f(5.6f, 7.4f, 5.6f),
// new Vector3f(0, 3, 0.1f)),
// new Matrix3f()
// ));
//
// leg4PartDefinition = Optional.of(new PartDefinition(
// new Vector3f(3.0f, 12.0f, -5.0f),
// createPartMatrix(
// new Vector3f(5.6f, 7.4f, 5.6f),
// new Vector3f(0, 3, 0.1f)),
// new Matrix3f()
// ));
// }
//
// protected static Matrix4f createPartMatrix(Vector3f size, Vector3f additionalTranslate)
// {
// final Vector3f adjustedSize = size.translate(-0.5f, -0.5f, -0.5f);
// final Matrix4f matrix = new Matrix4f();
//
// matrix.rotate(NintyDegrees, new Vector3f(1, 0, 0));
// matrix.translate(
// (Vector3f) Vector3f.add(
// (Vector3f) new Vector3f(adjustedSize).scale(0.5f),
// additionalTranslate,
// null
// ).negate());
// matrix.scale(adjustedSize);
// return matrix;
// }
//
// public Optional<PartDefinition> getBodyPartDefinition()
// {
// return bodyPartDefinition;
// }
//
// public Optional<PartDefinition> getHeadPartDefinition()
// {
// return headPartDefinition;
// }
//
// public Optional<PartDefinition> getLeg1PartDefinition()
// {
// return leg1PartDefinition;
// }
//
// public Optional<PartDefinition> getLeg2PartDefinition()
// {
// return leg2PartDefinition;
// }
//
// public Optional<PartDefinition> getLeg3PartDefinition()
// {
// return leg3PartDefinition;
// }
//
// public Optional<PartDefinition> getLeg4PartDefinition()
// {
// return leg4PartDefinition;
// }
// }
// Path: src/api/java/com/github/atomicblom/shearmadness/api/modelmaker/DefaultModelMaker.java
import com.github.atomicblom.shearmadness.api.rendering.QuadrupedTransformDefinition;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelQuadruped;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.model.ModelSheep1;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
package com.github.atomicblom.shearmadness.api.modelmaker;
@SuppressWarnings("ClassHasNoToStringMethod")
public class DefaultModelMaker implements IModelMaker
{ | private final QuadrupedTransformDefinition transforms; |
AtomicBlom/ShearMadness | src/main/java/com/github/atomicblom/shearmadness/Events.java | // Path: src/integration/java/com/github/atomicblom/shearmadness/variations/CommonReference.java
// public final class CommonReference {
// public static final String MOD_ID = "shearmadness";
// public static final String MOD_NAME = "Shear Madness";
// public static final String VERSION = "@MOD_VERSION@";
//
// private CommonReference() {}
// }
| import com.github.atomicblom.shearmadness.variations.CommonReference;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; | package com.github.atomicblom.shearmadness;
@Mod.EventBusSubscriber
public class Events {
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void onTextureStitchEvent(TextureStitchEvent.Pre event) { | // Path: src/integration/java/com/github/atomicblom/shearmadness/variations/CommonReference.java
// public final class CommonReference {
// public static final String MOD_ID = "shearmadness";
// public static final String MOD_NAME = "Shear Madness";
// public static final String VERSION = "@MOD_VERSION@";
//
// private CommonReference() {}
// }
// Path: src/main/java/com/github/atomicblom/shearmadness/Events.java
import com.github.atomicblom.shearmadness.variations.CommonReference;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
package com.github.atomicblom.shearmadness;
@Mod.EventBusSubscriber
public class Events {
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void onTextureStitchEvent(TextureStitchEvent.Pre event) { | event.getMap().registerSprite(new ResourceLocation(CommonReference.MOD_ID, "bad-render")); |
AtomicBlom/ShearMadness | src/api/java/com/github/atomicblom/shearmadness/api/events/ShearMadnessSpecialInteractionEvent.java | // Path: src/api/java/com/github/atomicblom/shearmadness/api/capability/IChiseledSheepCapability.java
// public interface IChiseledSheepCapability
// {
// boolean isChiseled();
//
// void unChisel();
//
// void chisel(ItemStack itemStack);
//
// ItemStack getChiselItemStack();
//
// int getItemIdentifier();
//
// NBTTagCompound getExtraData();
// }
| import com.github.atomicblom.shearmadness.api.capability.IChiseledSheepCapability;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.eventhandler.Event; | package com.github.atomicblom.shearmadness.api.events;
public class ShearMadnessSpecialInteractionEvent extends Event {
private final World world;
private final EntityPlayer player;
private final EntitySheep sheep; | // Path: src/api/java/com/github/atomicblom/shearmadness/api/capability/IChiseledSheepCapability.java
// public interface IChiseledSheepCapability
// {
// boolean isChiseled();
//
// void unChisel();
//
// void chisel(ItemStack itemStack);
//
// ItemStack getChiselItemStack();
//
// int getItemIdentifier();
//
// NBTTagCompound getExtraData();
// }
// Path: src/api/java/com/github/atomicblom/shearmadness/api/events/ShearMadnessSpecialInteractionEvent.java
import com.github.atomicblom.shearmadness.api.capability.IChiseledSheepCapability;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.eventhandler.Event;
package com.github.atomicblom.shearmadness.api.events;
public class ShearMadnessSpecialInteractionEvent extends Event {
private final World world;
private final EntityPlayer player;
private final EntitySheep sheep; | private final IChiseledSheepCapability capability; |
AtomicBlom/ShearMadness | src/main/java/com/github/atomicblom/shearmadness/Chiseling.java | // Path: src/api/java/com/github/atomicblom/shearmadness/api/Capability.java
// public final class Capability {
// @CapabilityInject(IChiseledSheepCapability.class)
// public static final net.minecraftforge.common.capabilities.Capability<IChiseledSheepCapability> CHISELED_SHEEP;
//
// static {
// CHISELED_SHEEP = null;
// }
// }
//
// Path: src/main/java/com/github/atomicblom/shearmadness/capability/CapabilityProvider.java
// @SuppressWarnings({"ObjectEquality", "ConstantConditions", "ClassHasNoToStringMethod"})
// public class CapabilityProvider implements ICapabilityProvider, INBTSerializable<NBTBase>
// {
// private final IChiseledSheepCapability capability;
//
// public CapabilityProvider()
// {
// capability = new ChiseledSheepCapability();
// }
//
// @Override
// public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing)
// {
// return capability == CHISELED_SHEEP;
// }
//
// @Override
// public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing)
// {
// if (capability == CHISELED_SHEEP)
// {
// return CHISELED_SHEEP.cast(this.capability);
// }
// //noinspection ReturnOfNull
// return null;
// }
//
// @Override
// public NBTBase serializeNBT()
// {
// return ChiseledSheepCapabilityStorage.instance.writeNBT(CHISELED_SHEEP, capability, null);
// }
//
// @Override
// public void deserializeNBT(NBTBase nbt)
// {
// ChiseledSheepCapabilityStorage.instance.readNBT(CHISELED_SHEEP, capability, null, nbt);
// }
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/capability/IChiseledSheepCapability.java
// public interface IChiseledSheepCapability
// {
// boolean isChiseled();
//
// void unChisel();
//
// void chisel(ItemStack itemStack);
//
// ItemStack getChiselItemStack();
//
// int getItemIdentifier();
//
// NBTTagCompound getExtraData();
// }
//
// Path: src/main/java/com/github/atomicblom/shearmadness/networking/SheepChiseledMessage.java
// public class SheepChiseledMessage implements IMessage
// {
// private int sheepId;
// private boolean isChiseled;
// private ItemStack itemStack = null;
//
// @SuppressWarnings("unused")
// public SheepChiseledMessage() {}
//
// public SheepChiseledMessage(Entity sheep)
// {
// sheepId = sheep.getEntityId();
// final IChiseledSheepCapability capability = sheep.getCapability(Capability.CHISELED_SHEEP, null);
// isChiseled = capability.isChiseled();
// itemStack = capability.getChiselItemStack();
// }
//
// @Override
// public void fromBytes(ByteBuf buf)
// {
// sheepId = buf.readInt();
// isChiseled = buf.readBoolean();
// itemStack = ByteBufUtils.readItemStack(buf);
// }
//
// @Override
// public void toBytes(ByteBuf buf)
// {
// buf.writeInt(sheepId);
// buf.writeBoolean(isChiseled);
// ByteBufUtils.writeItemStack(buf, itemStack);
// }
//
// int getSheepId()
// {
// return sheepId;
// }
//
// boolean isChiseled()
// {
// return isChiseled;
// }
//
// ItemStack getChiselItemStack()
// {
// return itemStack;
// }
//
// @Override
// public String toString()
// {
// return Objects.toStringHelper(this)
// .add("sheepId", sheepId)
// .add("isChiseled", isChiseled)
// .add("itemStack", itemStack)
// .toString();
// }
// }
//
// Path: src/main/java/com/github/atomicblom/shearmadness/utility/ItemStackUtils.java
// @SuppressWarnings("UtilityClass")
// public final class ItemStackUtils
// {
// private ItemStackUtils() {}
//
// public static void dropItem(Entity nearEntity, ItemStack itemStack)
// {
// final EntityItem item = nearEntity.entityDropItem(itemStack, 1.0F);
// final Random rand = new Random();
// item.motionY += rand.nextFloat() * 0.05F;
// item.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
// item.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
// }
//
// private static final PooledByteBufAllocator allocator = new PooledByteBufAllocator(false);
//
// public static int getHash(ItemStack itemStack)
// {
// final ByteBuf buffer = allocator.heapBuffer();
// final PacketBuffer packetBuffer = new PacketBuffer(buffer);
// packetBuffer.writeItemStackToBuffer(itemStack);
// final int i = Arrays.hashCode(packetBuffer.array());
// packetBuffer.release();
// return i;
// }
// }
//
// Path: src/main/java/com/github/atomicblom/shearmadness/ShearMadnessMod.java
// public static final SimpleNetworkWrapper CHANNEL = NetworkRegistry.INSTANCE.newSimpleChannel(CommonReference.MOD_ID);
| import com.github.atomicblom.shearmadness.api.Capability;
import com.github.atomicblom.shearmadness.capability.CapabilityProvider;
import com.github.atomicblom.shearmadness.api.capability.IChiseledSheepCapability;
import com.github.atomicblom.shearmadness.networking.SheepChiseledMessage;
import com.github.atomicblom.shearmadness.utility.ItemStackUtils;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import static com.github.atomicblom.shearmadness.ShearMadnessMod.CHANNEL; | package com.github.atomicblom.shearmadness;
@SuppressWarnings({"BooleanMethodNameMustStartWithQuestion", "UtilityClass"})
public final class Chiseling
{
private Chiseling() {}
public static void chiselSheep(Entity sheep, EntityPlayer entityPlayer, ItemStack activeStack)
{ | // Path: src/api/java/com/github/atomicblom/shearmadness/api/Capability.java
// public final class Capability {
// @CapabilityInject(IChiseledSheepCapability.class)
// public static final net.minecraftforge.common.capabilities.Capability<IChiseledSheepCapability> CHISELED_SHEEP;
//
// static {
// CHISELED_SHEEP = null;
// }
// }
//
// Path: src/main/java/com/github/atomicblom/shearmadness/capability/CapabilityProvider.java
// @SuppressWarnings({"ObjectEquality", "ConstantConditions", "ClassHasNoToStringMethod"})
// public class CapabilityProvider implements ICapabilityProvider, INBTSerializable<NBTBase>
// {
// private final IChiseledSheepCapability capability;
//
// public CapabilityProvider()
// {
// capability = new ChiseledSheepCapability();
// }
//
// @Override
// public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing)
// {
// return capability == CHISELED_SHEEP;
// }
//
// @Override
// public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing)
// {
// if (capability == CHISELED_SHEEP)
// {
// return CHISELED_SHEEP.cast(this.capability);
// }
// //noinspection ReturnOfNull
// return null;
// }
//
// @Override
// public NBTBase serializeNBT()
// {
// return ChiseledSheepCapabilityStorage.instance.writeNBT(CHISELED_SHEEP, capability, null);
// }
//
// @Override
// public void deserializeNBT(NBTBase nbt)
// {
// ChiseledSheepCapabilityStorage.instance.readNBT(CHISELED_SHEEP, capability, null, nbt);
// }
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/capability/IChiseledSheepCapability.java
// public interface IChiseledSheepCapability
// {
// boolean isChiseled();
//
// void unChisel();
//
// void chisel(ItemStack itemStack);
//
// ItemStack getChiselItemStack();
//
// int getItemIdentifier();
//
// NBTTagCompound getExtraData();
// }
//
// Path: src/main/java/com/github/atomicblom/shearmadness/networking/SheepChiseledMessage.java
// public class SheepChiseledMessage implements IMessage
// {
// private int sheepId;
// private boolean isChiseled;
// private ItemStack itemStack = null;
//
// @SuppressWarnings("unused")
// public SheepChiseledMessage() {}
//
// public SheepChiseledMessage(Entity sheep)
// {
// sheepId = sheep.getEntityId();
// final IChiseledSheepCapability capability = sheep.getCapability(Capability.CHISELED_SHEEP, null);
// isChiseled = capability.isChiseled();
// itemStack = capability.getChiselItemStack();
// }
//
// @Override
// public void fromBytes(ByteBuf buf)
// {
// sheepId = buf.readInt();
// isChiseled = buf.readBoolean();
// itemStack = ByteBufUtils.readItemStack(buf);
// }
//
// @Override
// public void toBytes(ByteBuf buf)
// {
// buf.writeInt(sheepId);
// buf.writeBoolean(isChiseled);
// ByteBufUtils.writeItemStack(buf, itemStack);
// }
//
// int getSheepId()
// {
// return sheepId;
// }
//
// boolean isChiseled()
// {
// return isChiseled;
// }
//
// ItemStack getChiselItemStack()
// {
// return itemStack;
// }
//
// @Override
// public String toString()
// {
// return Objects.toStringHelper(this)
// .add("sheepId", sheepId)
// .add("isChiseled", isChiseled)
// .add("itemStack", itemStack)
// .toString();
// }
// }
//
// Path: src/main/java/com/github/atomicblom/shearmadness/utility/ItemStackUtils.java
// @SuppressWarnings("UtilityClass")
// public final class ItemStackUtils
// {
// private ItemStackUtils() {}
//
// public static void dropItem(Entity nearEntity, ItemStack itemStack)
// {
// final EntityItem item = nearEntity.entityDropItem(itemStack, 1.0F);
// final Random rand = new Random();
// item.motionY += rand.nextFloat() * 0.05F;
// item.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
// item.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
// }
//
// private static final PooledByteBufAllocator allocator = new PooledByteBufAllocator(false);
//
// public static int getHash(ItemStack itemStack)
// {
// final ByteBuf buffer = allocator.heapBuffer();
// final PacketBuffer packetBuffer = new PacketBuffer(buffer);
// packetBuffer.writeItemStackToBuffer(itemStack);
// final int i = Arrays.hashCode(packetBuffer.array());
// packetBuffer.release();
// return i;
// }
// }
//
// Path: src/main/java/com/github/atomicblom/shearmadness/ShearMadnessMod.java
// public static final SimpleNetworkWrapper CHANNEL = NetworkRegistry.INSTANCE.newSimpleChannel(CommonReference.MOD_ID);
// Path: src/main/java/com/github/atomicblom/shearmadness/Chiseling.java
import com.github.atomicblom.shearmadness.api.Capability;
import com.github.atomicblom.shearmadness.capability.CapabilityProvider;
import com.github.atomicblom.shearmadness.api.capability.IChiseledSheepCapability;
import com.github.atomicblom.shearmadness.networking.SheepChiseledMessage;
import com.github.atomicblom.shearmadness.utility.ItemStackUtils;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import static com.github.atomicblom.shearmadness.ShearMadnessMod.CHANNEL;
package com.github.atomicblom.shearmadness;
@SuppressWarnings({"BooleanMethodNameMustStartWithQuestion", "UtilityClass"})
public final class Chiseling
{
private Chiseling() {}
public static void chiselSheep(Entity sheep, EntityPlayer entityPlayer, ItemStack activeStack)
{ | if (sheep.hasCapability(Capability.CHISELED_SHEEP, null)) |
AtomicBlom/ShearMadness | src/integration/java/com/github/atomicblom/shearmadness/variations/vanilla/container/ContainerRepairSheep.java | // Path: src/api/java/com/github/atomicblom/shearmadness/api/Capability.java
// public final class Capability {
// @CapabilityInject(IChiseledSheepCapability.class)
// public static final net.minecraftforge.common.capabilities.Capability<IChiseledSheepCapability> CHISELED_SHEEP;
//
// static {
// CHISELED_SHEEP = null;
// }
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/capability/IChiseledSheepCapability.java
// public interface IChiseledSheepCapability
// {
// boolean isChiseled();
//
// void unChisel();
//
// void chisel(ItemStack itemStack);
//
// ItemStack getChiselItemStack();
//
// int getItemIdentifier();
//
// NBTTagCompound getExtraData();
// }
| import com.github.atomicblom.shearmadness.api.Capability;
import com.github.atomicblom.shearmadness.api.capability.IChiseledSheepCapability;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.ContainerRepair;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.world.World;
import java.util.Objects; | package com.github.atomicblom.shearmadness.variations.vanilla.container;
public class ContainerRepairSheep extends ContainerRepair
{
private final EntityLiving entity;
public ContainerRepairSheep(InventoryPlayer playerInventory, World worldIn, EntityPlayer player, EntityLiving entity)
{
super(playerInventory, worldIn, entity.getPosition(), player);
this.entity = entity;
}
@Override
public boolean canInteractWith(EntityPlayer playerIn) { | // Path: src/api/java/com/github/atomicblom/shearmadness/api/Capability.java
// public final class Capability {
// @CapabilityInject(IChiseledSheepCapability.class)
// public static final net.minecraftforge.common.capabilities.Capability<IChiseledSheepCapability> CHISELED_SHEEP;
//
// static {
// CHISELED_SHEEP = null;
// }
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/capability/IChiseledSheepCapability.java
// public interface IChiseledSheepCapability
// {
// boolean isChiseled();
//
// void unChisel();
//
// void chisel(ItemStack itemStack);
//
// ItemStack getChiselItemStack();
//
// int getItemIdentifier();
//
// NBTTagCompound getExtraData();
// }
// Path: src/integration/java/com/github/atomicblom/shearmadness/variations/vanilla/container/ContainerRepairSheep.java
import com.github.atomicblom.shearmadness.api.Capability;
import com.github.atomicblom.shearmadness.api.capability.IChiseledSheepCapability;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.ContainerRepair;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.world.World;
import java.util.Objects;
package com.github.atomicblom.shearmadness.variations.vanilla.container;
public class ContainerRepairSheep extends ContainerRepair
{
private final EntityLiving entity;
public ContainerRepairSheep(InventoryPlayer playerInventory, World worldIn, EntityPlayer player, EntityLiving entity)
{
super(playerInventory, worldIn, entity.getPosition(), player);
this.entity = entity;
}
@Override
public boolean canInteractWith(EntityPlayer playerIn) { | if (!entity.hasCapability(Capability.CHISELED_SHEEP, null)) { |
AtomicBlom/ShearMadness | src/integration/java/com/github/atomicblom/shearmadness/variations/vanilla/container/ContainerRepairSheep.java | // Path: src/api/java/com/github/atomicblom/shearmadness/api/Capability.java
// public final class Capability {
// @CapabilityInject(IChiseledSheepCapability.class)
// public static final net.minecraftforge.common.capabilities.Capability<IChiseledSheepCapability> CHISELED_SHEEP;
//
// static {
// CHISELED_SHEEP = null;
// }
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/capability/IChiseledSheepCapability.java
// public interface IChiseledSheepCapability
// {
// boolean isChiseled();
//
// void unChisel();
//
// void chisel(ItemStack itemStack);
//
// ItemStack getChiselItemStack();
//
// int getItemIdentifier();
//
// NBTTagCompound getExtraData();
// }
| import com.github.atomicblom.shearmadness.api.Capability;
import com.github.atomicblom.shearmadness.api.capability.IChiseledSheepCapability;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.ContainerRepair;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.world.World;
import java.util.Objects; | package com.github.atomicblom.shearmadness.variations.vanilla.container;
public class ContainerRepairSheep extends ContainerRepair
{
private final EntityLiving entity;
public ContainerRepairSheep(InventoryPlayer playerInventory, World worldIn, EntityPlayer player, EntityLiving entity)
{
super(playerInventory, worldIn, entity.getPosition(), player);
this.entity = entity;
}
@Override
public boolean canInteractWith(EntityPlayer playerIn) {
if (!entity.hasCapability(Capability.CHISELED_SHEEP, null)) {
return false;
} | // Path: src/api/java/com/github/atomicblom/shearmadness/api/Capability.java
// public final class Capability {
// @CapabilityInject(IChiseledSheepCapability.class)
// public static final net.minecraftforge.common.capabilities.Capability<IChiseledSheepCapability> CHISELED_SHEEP;
//
// static {
// CHISELED_SHEEP = null;
// }
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/capability/IChiseledSheepCapability.java
// public interface IChiseledSheepCapability
// {
// boolean isChiseled();
//
// void unChisel();
//
// void chisel(ItemStack itemStack);
//
// ItemStack getChiselItemStack();
//
// int getItemIdentifier();
//
// NBTTagCompound getExtraData();
// }
// Path: src/integration/java/com/github/atomicblom/shearmadness/variations/vanilla/container/ContainerRepairSheep.java
import com.github.atomicblom.shearmadness.api.Capability;
import com.github.atomicblom.shearmadness.api.capability.IChiseledSheepCapability;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.ContainerRepair;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.world.World;
import java.util.Objects;
package com.github.atomicblom.shearmadness.variations.vanilla.container;
public class ContainerRepairSheep extends ContainerRepair
{
private final EntityLiving entity;
public ContainerRepairSheep(InventoryPlayer playerInventory, World worldIn, EntityPlayer player, EntityLiving entity)
{
super(playerInventory, worldIn, entity.getPosition(), player);
this.entity = entity;
}
@Override
public boolean canInteractWith(EntityPlayer playerIn) {
if (!entity.hasCapability(Capability.CHISELED_SHEEP, null)) {
return false;
} | final IChiseledSheepCapability capability = entity.getCapability(Capability.CHISELED_SHEEP, null); |
AtomicBlom/ShearMadness | src/api/java/com/github/atomicblom/shearmadness/api/events/RegisterShearMadnessVariationEvent.java | // Path: src/api/java/com/github/atomicblom/shearmadness/api/IVariationRegistry.java
// @SideOnly(Side.CLIENT)
// public interface IVariationRegistry
// {
// /**
// * Registers a Model Maker that will be used when the function predicate matches
// * @param handlesVariant a function that should return true if your IModelMaker applies to the itemStack
// * @param variationModelMaker the model maker that will make the model for the quadruped.
// */
// void registerVariation(Function<ItemStack, Boolean> handlesVariant, IModelMaker variationModelMaker);
//
// /**
// * Registers a Model Maker that will be used when the function predicate matches using the default model maker
// * with custom transformations.
// * @param handlesVariant a function that should return true if your IModelMaker applies to the itemStack
// * @param transformDefinition the transforms for the model
// */
// void registerVariation(Function<ItemStack, Boolean> handlesVariant, QuadrupedTransformDefinition transformDefinition);
// }
| import com.github.atomicblom.shearmadness.api.IVariationRegistry;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; | package com.github.atomicblom.shearmadness.api.events;
/**
* Fired during the init phase of Forge, provides a mechanism for mods to register
* how their blocks should be rendered by Shear Madness.
* This event is only fired on clients.
*/
@SideOnly(Side.CLIENT)
public class RegisterShearMadnessVariationEvent extends Event
{ | // Path: src/api/java/com/github/atomicblom/shearmadness/api/IVariationRegistry.java
// @SideOnly(Side.CLIENT)
// public interface IVariationRegistry
// {
// /**
// * Registers a Model Maker that will be used when the function predicate matches
// * @param handlesVariant a function that should return true if your IModelMaker applies to the itemStack
// * @param variationModelMaker the model maker that will make the model for the quadruped.
// */
// void registerVariation(Function<ItemStack, Boolean> handlesVariant, IModelMaker variationModelMaker);
//
// /**
// * Registers a Model Maker that will be used when the function predicate matches using the default model maker
// * with custom transformations.
// * @param handlesVariant a function that should return true if your IModelMaker applies to the itemStack
// * @param transformDefinition the transforms for the model
// */
// void registerVariation(Function<ItemStack, Boolean> handlesVariant, QuadrupedTransformDefinition transformDefinition);
// }
// Path: src/api/java/com/github/atomicblom/shearmadness/api/events/RegisterShearMadnessVariationEvent.java
import com.github.atomicblom.shearmadness.api.IVariationRegistry;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
package com.github.atomicblom.shearmadness.api.events;
/**
* Fired during the init phase of Forge, provides a mechanism for mods to register
* how their blocks should be rendered by Shear Madness.
* This event is only fired on clients.
*/
@SideOnly(Side.CLIENT)
public class RegisterShearMadnessVariationEvent extends Event
{ | private final IVariationRegistry registry; |
AtomicBlom/ShearMadness | src/main/java/com/github/atomicblom/shearmadness/utility/BlockLibrary.java | // Path: src/main/java/com/github/atomicblom/shearmadness/block/InvisibleBlock.java
// public abstract class InvisibleBlock extends Block
// {
// InvisibleBlock()
// {
// super(Material.AIR);
// }
//
// @Override
// public boolean isCollidable()
// {
// return false;
// }
//
// @Nullable
// @Override
// @Deprecated
// public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos)
// {
// return Block.NULL_AABB;
// }
//
// @Override
// @Deprecated
// public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn)
// {
// }
//
// @Override
// public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos)
// {
// return true;
// }
//
// @Override
// public int getLightOpacity(IBlockState state, IBlockAccess world, BlockPos pos)
// {
// return 0;
// }
//
// @Override
// @Deprecated
// public EnumBlockRenderType getRenderType(IBlockState state)
// {
// return Settings.debugInvisibleBlocks() ?
// EnumBlockRenderType.MODEL :
// EnumBlockRenderType.INVISIBLE;
// }
//
// @Override
// @Deprecated
// public boolean isFullBlock(IBlockState state)
// {
// return false;
// }
//
// @Override
// @Deprecated
// public boolean isOpaqueCube(IBlockState state)
// {
// return false;
// }
// }
//
// Path: src/integration/java/com/github/atomicblom/shearmadness/variations/CommonReference.java
// public final class CommonReference {
// public static final String MOD_ID = "shearmadness";
// public static final String MOD_NAME = "Shear Madness";
// public static final String VERSION = "@MOD_VERSION@";
//
// private CommonReference() {}
// }
| import com.github.atomicblom.shearmadness.block.InvisibleBlock;
import com.github.atomicblom.shearmadness.variations.CommonReference;
import net.minecraft.block.Block;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; | package com.github.atomicblom.shearmadness.utility;
@SuppressWarnings("ALL")
@ObjectHolder(CommonReference.MOD_ID)
public final class BlockLibrary {
| // Path: src/main/java/com/github/atomicblom/shearmadness/block/InvisibleBlock.java
// public abstract class InvisibleBlock extends Block
// {
// InvisibleBlock()
// {
// super(Material.AIR);
// }
//
// @Override
// public boolean isCollidable()
// {
// return false;
// }
//
// @Nullable
// @Override
// @Deprecated
// public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos)
// {
// return Block.NULL_AABB;
// }
//
// @Override
// @Deprecated
// public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn)
// {
// }
//
// @Override
// public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos)
// {
// return true;
// }
//
// @Override
// public int getLightOpacity(IBlockState state, IBlockAccess world, BlockPos pos)
// {
// return 0;
// }
//
// @Override
// @Deprecated
// public EnumBlockRenderType getRenderType(IBlockState state)
// {
// return Settings.debugInvisibleBlocks() ?
// EnumBlockRenderType.MODEL :
// EnumBlockRenderType.INVISIBLE;
// }
//
// @Override
// @Deprecated
// public boolean isFullBlock(IBlockState state)
// {
// return false;
// }
//
// @Override
// @Deprecated
// public boolean isOpaqueCube(IBlockState state)
// {
// return false;
// }
// }
//
// Path: src/integration/java/com/github/atomicblom/shearmadness/variations/CommonReference.java
// public final class CommonReference {
// public static final String MOD_ID = "shearmadness";
// public static final String MOD_NAME = "Shear Madness";
// public static final String VERSION = "@MOD_VERSION@";
//
// private CommonReference() {}
// }
// Path: src/main/java/com/github/atomicblom/shearmadness/utility/BlockLibrary.java
import com.github.atomicblom.shearmadness.block.InvisibleBlock;
import com.github.atomicblom.shearmadness.variations.CommonReference;
import net.minecraft.block.Block;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
package com.github.atomicblom.shearmadness.utility;
@SuppressWarnings("ALL")
@ObjectHolder(CommonReference.MOD_ID)
public final class BlockLibrary {
| public static final InvisibleBlock invisibleRedstone; |
AtomicBlom/ShearMadness | src/main/java/com/github/atomicblom/shearmadness/capability/CapabilityProvider.java | // Path: src/api/java/com/github/atomicblom/shearmadness/api/capability/IChiseledSheepCapability.java
// public interface IChiseledSheepCapability
// {
// boolean isChiseled();
//
// void unChisel();
//
// void chisel(ItemStack itemStack);
//
// ItemStack getChiselItemStack();
//
// int getItemIdentifier();
//
// NBTTagCompound getExtraData();
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/Capability.java
// @CapabilityInject(IChiseledSheepCapability.class)
// public static final net.minecraftforge.common.capabilities.Capability<IChiseledSheepCapability> CHISELED_SHEEP;
| import com.github.atomicblom.shearmadness.api.capability.IChiseledSheepCapability;
import net.minecraft.nbt.NBTBase;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.INBTSerializable;
import javax.annotation.Nullable;
import static com.github.atomicblom.shearmadness.api.Capability.CHISELED_SHEEP; | package com.github.atomicblom.shearmadness.capability;
@SuppressWarnings({"ObjectEquality", "ConstantConditions", "ClassHasNoToStringMethod"})
public class CapabilityProvider implements ICapabilityProvider, INBTSerializable<NBTBase>
{ | // Path: src/api/java/com/github/atomicblom/shearmadness/api/capability/IChiseledSheepCapability.java
// public interface IChiseledSheepCapability
// {
// boolean isChiseled();
//
// void unChisel();
//
// void chisel(ItemStack itemStack);
//
// ItemStack getChiselItemStack();
//
// int getItemIdentifier();
//
// NBTTagCompound getExtraData();
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/Capability.java
// @CapabilityInject(IChiseledSheepCapability.class)
// public static final net.minecraftforge.common.capabilities.Capability<IChiseledSheepCapability> CHISELED_SHEEP;
// Path: src/main/java/com/github/atomicblom/shearmadness/capability/CapabilityProvider.java
import com.github.atomicblom.shearmadness.api.capability.IChiseledSheepCapability;
import net.minecraft.nbt.NBTBase;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.INBTSerializable;
import javax.annotation.Nullable;
import static com.github.atomicblom.shearmadness.api.Capability.CHISELED_SHEEP;
package com.github.atomicblom.shearmadness.capability;
@SuppressWarnings({"ObjectEquality", "ConstantConditions", "ClassHasNoToStringMethod"})
public class CapabilityProvider implements ICapabilityProvider, INBTSerializable<NBTBase>
{ | private final IChiseledSheepCapability capability; |
AtomicBlom/ShearMadness | src/main/java/com/github/atomicblom/shearmadness/capability/CapabilityProvider.java | // Path: src/api/java/com/github/atomicblom/shearmadness/api/capability/IChiseledSheepCapability.java
// public interface IChiseledSheepCapability
// {
// boolean isChiseled();
//
// void unChisel();
//
// void chisel(ItemStack itemStack);
//
// ItemStack getChiselItemStack();
//
// int getItemIdentifier();
//
// NBTTagCompound getExtraData();
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/Capability.java
// @CapabilityInject(IChiseledSheepCapability.class)
// public static final net.minecraftforge.common.capabilities.Capability<IChiseledSheepCapability> CHISELED_SHEEP;
| import com.github.atomicblom.shearmadness.api.capability.IChiseledSheepCapability;
import net.minecraft.nbt.NBTBase;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.INBTSerializable;
import javax.annotation.Nullable;
import static com.github.atomicblom.shearmadness.api.Capability.CHISELED_SHEEP; | package com.github.atomicblom.shearmadness.capability;
@SuppressWarnings({"ObjectEquality", "ConstantConditions", "ClassHasNoToStringMethod"})
public class CapabilityProvider implements ICapabilityProvider, INBTSerializable<NBTBase>
{
private final IChiseledSheepCapability capability;
public CapabilityProvider()
{
capability = new ChiseledSheepCapability();
}
@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing)
{ | // Path: src/api/java/com/github/atomicblom/shearmadness/api/capability/IChiseledSheepCapability.java
// public interface IChiseledSheepCapability
// {
// boolean isChiseled();
//
// void unChisel();
//
// void chisel(ItemStack itemStack);
//
// ItemStack getChiselItemStack();
//
// int getItemIdentifier();
//
// NBTTagCompound getExtraData();
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/Capability.java
// @CapabilityInject(IChiseledSheepCapability.class)
// public static final net.minecraftforge.common.capabilities.Capability<IChiseledSheepCapability> CHISELED_SHEEP;
// Path: src/main/java/com/github/atomicblom/shearmadness/capability/CapabilityProvider.java
import com.github.atomicblom.shearmadness.api.capability.IChiseledSheepCapability;
import net.minecraft.nbt.NBTBase;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.INBTSerializable;
import javax.annotation.Nullable;
import static com.github.atomicblom.shearmadness.api.Capability.CHISELED_SHEEP;
package com.github.atomicblom.shearmadness.capability;
@SuppressWarnings({"ObjectEquality", "ConstantConditions", "ClassHasNoToStringMethod"})
public class CapabilityProvider implements ICapabilityProvider, INBTSerializable<NBTBase>
{
private final IChiseledSheepCapability capability;
public CapabilityProvider()
{
capability = new ChiseledSheepCapability();
}
@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing)
{ | return capability == CHISELED_SHEEP; |
AtomicBlom/ShearMadness | src/integration/java/com/github/atomicblom/shearmadness/variations/vanilla/container/ContainerEnchantmentSheep.java | // Path: src/api/java/com/github/atomicblom/shearmadness/api/Capability.java
// public final class Capability {
// @CapabilityInject(IChiseledSheepCapability.class)
// public static final net.minecraftforge.common.capabilities.Capability<IChiseledSheepCapability> CHISELED_SHEEP;
//
// static {
// CHISELED_SHEEP = null;
// }
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/ItemStackHelper.java
// @SuppressWarnings("UtilityClass")
// public final class ItemStackHelper
// {
// private ItemStackHelper() {}
//
// public static boolean isStackForBlock(ItemStack itemStack, Block block)
// {
// if (itemStack == null) return false;
// final Item item = itemStack.getItem();
// if (item instanceof ItemBlock) {
// if (Objects.equals(((ItemBlock) item).block, block)) {
// return true;
// }
// }
// return false;
// }
//
// public static boolean isStackForBlockSubclassOf(ItemStack itemStack, Class<? extends Block> blockClass)
// {
// if (itemStack == null) return false;
// final Item item = itemStack.getItem();
// if (item instanceof ItemBlock) {
// if (blockClass.isAssignableFrom(((ItemBlock) item).block.getClass())) {
// return true;
// }
// }
// return false;
// }
//
// public static boolean isStackForBlock(ItemStack itemStack, Block block, int meta) {
// return isStackForBlock(itemStack, block) && itemStack.getItemDamage() == meta;
// }
//
// public static boolean isStackForBlock(ItemStack itemStack, Block... blocks) {
// return isStackForBlock(itemStack, Iterators.forArray(blocks));
// }
//
// private static boolean isStackForBlock(ItemStack itemStack, Iterator<Block> blocks) {
// if (itemStack == null) return false;
// final Item item = itemStack.getItem();
// if (item instanceof ItemBlock) {
// final Block block = ((ItemBlock) item).block;
// while (blocks.hasNext()) {
// if (Objects.equals(blocks.next(), block)) {
// return true;
// }
// }
// }
// return false;
// }
//
// public static boolean isStackForBlock(ItemStack itemStack, Iterable<Block> blocks) {
// return isStackForBlock(itemStack, blocks.iterator());
// }
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/capability/IChiseledSheepCapability.java
// public interface IChiseledSheepCapability
// {
// boolean isChiseled();
//
// void unChisel();
//
// void chisel(ItemStack itemStack);
//
// ItemStack getChiselItemStack();
//
// int getItemIdentifier();
//
// NBTTagCompound getExtraData();
// }
| import com.github.atomicblom.shearmadness.api.Capability;
import com.github.atomicblom.shearmadness.api.ItemStackHelper;
import com.github.atomicblom.shearmadness.api.capability.IChiseledSheepCapability;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentData;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.ContainerEnchantment;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import java.util.List;
import java.util.Random; | package com.github.atomicblom.shearmadness.variations.vanilla.container;
public class ContainerEnchantmentSheep extends ContainerEnchantment
{
private final EntityLiving entity;
private final Random rand;
private final World world;
public ContainerEnchantmentSheep(InventoryPlayer playerInventory, World worldIn, EntityLiving entity)
{
super(playerInventory, worldIn, entity.getPosition());
this.entity = entity;
rand = new Random();
world = worldIn;
}
@Override
public boolean canInteractWith(EntityPlayer playerIn) { | // Path: src/api/java/com/github/atomicblom/shearmadness/api/Capability.java
// public final class Capability {
// @CapabilityInject(IChiseledSheepCapability.class)
// public static final net.minecraftforge.common.capabilities.Capability<IChiseledSheepCapability> CHISELED_SHEEP;
//
// static {
// CHISELED_SHEEP = null;
// }
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/ItemStackHelper.java
// @SuppressWarnings("UtilityClass")
// public final class ItemStackHelper
// {
// private ItemStackHelper() {}
//
// public static boolean isStackForBlock(ItemStack itemStack, Block block)
// {
// if (itemStack == null) return false;
// final Item item = itemStack.getItem();
// if (item instanceof ItemBlock) {
// if (Objects.equals(((ItemBlock) item).block, block)) {
// return true;
// }
// }
// return false;
// }
//
// public static boolean isStackForBlockSubclassOf(ItemStack itemStack, Class<? extends Block> blockClass)
// {
// if (itemStack == null) return false;
// final Item item = itemStack.getItem();
// if (item instanceof ItemBlock) {
// if (blockClass.isAssignableFrom(((ItemBlock) item).block.getClass())) {
// return true;
// }
// }
// return false;
// }
//
// public static boolean isStackForBlock(ItemStack itemStack, Block block, int meta) {
// return isStackForBlock(itemStack, block) && itemStack.getItemDamage() == meta;
// }
//
// public static boolean isStackForBlock(ItemStack itemStack, Block... blocks) {
// return isStackForBlock(itemStack, Iterators.forArray(blocks));
// }
//
// private static boolean isStackForBlock(ItemStack itemStack, Iterator<Block> blocks) {
// if (itemStack == null) return false;
// final Item item = itemStack.getItem();
// if (item instanceof ItemBlock) {
// final Block block = ((ItemBlock) item).block;
// while (blocks.hasNext()) {
// if (Objects.equals(blocks.next(), block)) {
// return true;
// }
// }
// }
// return false;
// }
//
// public static boolean isStackForBlock(ItemStack itemStack, Iterable<Block> blocks) {
// return isStackForBlock(itemStack, blocks.iterator());
// }
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/capability/IChiseledSheepCapability.java
// public interface IChiseledSheepCapability
// {
// boolean isChiseled();
//
// void unChisel();
//
// void chisel(ItemStack itemStack);
//
// ItemStack getChiselItemStack();
//
// int getItemIdentifier();
//
// NBTTagCompound getExtraData();
// }
// Path: src/integration/java/com/github/atomicblom/shearmadness/variations/vanilla/container/ContainerEnchantmentSheep.java
import com.github.atomicblom.shearmadness.api.Capability;
import com.github.atomicblom.shearmadness.api.ItemStackHelper;
import com.github.atomicblom.shearmadness.api.capability.IChiseledSheepCapability;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentData;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.ContainerEnchantment;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import java.util.List;
import java.util.Random;
package com.github.atomicblom.shearmadness.variations.vanilla.container;
public class ContainerEnchantmentSheep extends ContainerEnchantment
{
private final EntityLiving entity;
private final Random rand;
private final World world;
public ContainerEnchantmentSheep(InventoryPlayer playerInventory, World worldIn, EntityLiving entity)
{
super(playerInventory, worldIn, entity.getPosition());
this.entity = entity;
rand = new Random();
world = worldIn;
}
@Override
public boolean canInteractWith(EntityPlayer playerIn) { | if (!entity.hasCapability(Capability.CHISELED_SHEEP, null)) { |
AtomicBlom/ShearMadness | src/integration/java/com/github/atomicblom/shearmadness/variations/vanilla/container/ContainerEnchantmentSheep.java | // Path: src/api/java/com/github/atomicblom/shearmadness/api/Capability.java
// public final class Capability {
// @CapabilityInject(IChiseledSheepCapability.class)
// public static final net.minecraftforge.common.capabilities.Capability<IChiseledSheepCapability> CHISELED_SHEEP;
//
// static {
// CHISELED_SHEEP = null;
// }
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/ItemStackHelper.java
// @SuppressWarnings("UtilityClass")
// public final class ItemStackHelper
// {
// private ItemStackHelper() {}
//
// public static boolean isStackForBlock(ItemStack itemStack, Block block)
// {
// if (itemStack == null) return false;
// final Item item = itemStack.getItem();
// if (item instanceof ItemBlock) {
// if (Objects.equals(((ItemBlock) item).block, block)) {
// return true;
// }
// }
// return false;
// }
//
// public static boolean isStackForBlockSubclassOf(ItemStack itemStack, Class<? extends Block> blockClass)
// {
// if (itemStack == null) return false;
// final Item item = itemStack.getItem();
// if (item instanceof ItemBlock) {
// if (blockClass.isAssignableFrom(((ItemBlock) item).block.getClass())) {
// return true;
// }
// }
// return false;
// }
//
// public static boolean isStackForBlock(ItemStack itemStack, Block block, int meta) {
// return isStackForBlock(itemStack, block) && itemStack.getItemDamage() == meta;
// }
//
// public static boolean isStackForBlock(ItemStack itemStack, Block... blocks) {
// return isStackForBlock(itemStack, Iterators.forArray(blocks));
// }
//
// private static boolean isStackForBlock(ItemStack itemStack, Iterator<Block> blocks) {
// if (itemStack == null) return false;
// final Item item = itemStack.getItem();
// if (item instanceof ItemBlock) {
// final Block block = ((ItemBlock) item).block;
// while (blocks.hasNext()) {
// if (Objects.equals(blocks.next(), block)) {
// return true;
// }
// }
// }
// return false;
// }
//
// public static boolean isStackForBlock(ItemStack itemStack, Iterable<Block> blocks) {
// return isStackForBlock(itemStack, blocks.iterator());
// }
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/capability/IChiseledSheepCapability.java
// public interface IChiseledSheepCapability
// {
// boolean isChiseled();
//
// void unChisel();
//
// void chisel(ItemStack itemStack);
//
// ItemStack getChiselItemStack();
//
// int getItemIdentifier();
//
// NBTTagCompound getExtraData();
// }
| import com.github.atomicblom.shearmadness.api.Capability;
import com.github.atomicblom.shearmadness.api.ItemStackHelper;
import com.github.atomicblom.shearmadness.api.capability.IChiseledSheepCapability;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentData;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.ContainerEnchantment;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import java.util.List;
import java.util.Random; | package com.github.atomicblom.shearmadness.variations.vanilla.container;
public class ContainerEnchantmentSheep extends ContainerEnchantment
{
private final EntityLiving entity;
private final Random rand;
private final World world;
public ContainerEnchantmentSheep(InventoryPlayer playerInventory, World worldIn, EntityLiving entity)
{
super(playerInventory, worldIn, entity.getPosition());
this.entity = entity;
rand = new Random();
world = worldIn;
}
@Override
public boolean canInteractWith(EntityPlayer playerIn) {
if (!entity.hasCapability(Capability.CHISELED_SHEEP, null)) {
return false;
} | // Path: src/api/java/com/github/atomicblom/shearmadness/api/Capability.java
// public final class Capability {
// @CapabilityInject(IChiseledSheepCapability.class)
// public static final net.minecraftforge.common.capabilities.Capability<IChiseledSheepCapability> CHISELED_SHEEP;
//
// static {
// CHISELED_SHEEP = null;
// }
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/ItemStackHelper.java
// @SuppressWarnings("UtilityClass")
// public final class ItemStackHelper
// {
// private ItemStackHelper() {}
//
// public static boolean isStackForBlock(ItemStack itemStack, Block block)
// {
// if (itemStack == null) return false;
// final Item item = itemStack.getItem();
// if (item instanceof ItemBlock) {
// if (Objects.equals(((ItemBlock) item).block, block)) {
// return true;
// }
// }
// return false;
// }
//
// public static boolean isStackForBlockSubclassOf(ItemStack itemStack, Class<? extends Block> blockClass)
// {
// if (itemStack == null) return false;
// final Item item = itemStack.getItem();
// if (item instanceof ItemBlock) {
// if (blockClass.isAssignableFrom(((ItemBlock) item).block.getClass())) {
// return true;
// }
// }
// return false;
// }
//
// public static boolean isStackForBlock(ItemStack itemStack, Block block, int meta) {
// return isStackForBlock(itemStack, block) && itemStack.getItemDamage() == meta;
// }
//
// public static boolean isStackForBlock(ItemStack itemStack, Block... blocks) {
// return isStackForBlock(itemStack, Iterators.forArray(blocks));
// }
//
// private static boolean isStackForBlock(ItemStack itemStack, Iterator<Block> blocks) {
// if (itemStack == null) return false;
// final Item item = itemStack.getItem();
// if (item instanceof ItemBlock) {
// final Block block = ((ItemBlock) item).block;
// while (blocks.hasNext()) {
// if (Objects.equals(blocks.next(), block)) {
// return true;
// }
// }
// }
// return false;
// }
//
// public static boolean isStackForBlock(ItemStack itemStack, Iterable<Block> blocks) {
// return isStackForBlock(itemStack, blocks.iterator());
// }
// }
//
// Path: src/api/java/com/github/atomicblom/shearmadness/api/capability/IChiseledSheepCapability.java
// public interface IChiseledSheepCapability
// {
// boolean isChiseled();
//
// void unChisel();
//
// void chisel(ItemStack itemStack);
//
// ItemStack getChiselItemStack();
//
// int getItemIdentifier();
//
// NBTTagCompound getExtraData();
// }
// Path: src/integration/java/com/github/atomicblom/shearmadness/variations/vanilla/container/ContainerEnchantmentSheep.java
import com.github.atomicblom.shearmadness.api.Capability;
import com.github.atomicblom.shearmadness.api.ItemStackHelper;
import com.github.atomicblom.shearmadness.api.capability.IChiseledSheepCapability;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentData;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.ContainerEnchantment;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import java.util.List;
import java.util.Random;
package com.github.atomicblom.shearmadness.variations.vanilla.container;
public class ContainerEnchantmentSheep extends ContainerEnchantment
{
private final EntityLiving entity;
private final Random rand;
private final World world;
public ContainerEnchantmentSheep(InventoryPlayer playerInventory, World worldIn, EntityLiving entity)
{
super(playerInventory, worldIn, entity.getPosition());
this.entity = entity;
rand = new Random();
world = worldIn;
}
@Override
public boolean canInteractWith(EntityPlayer playerIn) {
if (!entity.hasCapability(Capability.CHISELED_SHEEP, null)) {
return false;
} | final IChiseledSheepCapability capability = entity.getCapability(Capability.CHISELED_SHEEP, null); |
AtomicBlom/ShearMadness | src/integration/java/com/github/atomicblom/shearmadness/variations/chancecubes/ChanceCubesReference.java | // Path: src/integration/java/com/github/atomicblom/shearmadness/variations/CommonReference.java
// public final class CommonReference {
// public static final String MOD_ID = "shearmadness";
// public static final String MOD_NAME = "Shear Madness";
// public static final String VERSION = "@MOD_VERSION@";
//
// private CommonReference() {}
// }
//
// Path: src/integration/java/com/github/atomicblom/shearmadness/variations/chancecubes/capability/IChanceCubeParticipationCapability.java
// public interface IChanceCubeParticipationCapability {
// boolean isParticipating();
// void setParticipation(boolean isParticipating);
// }
| import com.github.atomicblom.shearmadness.variations.CommonReference;
import com.github.atomicblom.shearmadness.variations.chancecubes.capability.IChanceCubeParticipationCapability;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject; | package com.github.atomicblom.shearmadness.variations.chancecubes;
public final class ChanceCubesReference {
public static final String CHANCE_CUBES_MODID = "chancecubes";
| // Path: src/integration/java/com/github/atomicblom/shearmadness/variations/CommonReference.java
// public final class CommonReference {
// public static final String MOD_ID = "shearmadness";
// public static final String MOD_NAME = "Shear Madness";
// public static final String VERSION = "@MOD_VERSION@";
//
// private CommonReference() {}
// }
//
// Path: src/integration/java/com/github/atomicblom/shearmadness/variations/chancecubes/capability/IChanceCubeParticipationCapability.java
// public interface IChanceCubeParticipationCapability {
// boolean isParticipating();
// void setParticipation(boolean isParticipating);
// }
// Path: src/integration/java/com/github/atomicblom/shearmadness/variations/chancecubes/ChanceCubesReference.java
import com.github.atomicblom.shearmadness.variations.CommonReference;
import com.github.atomicblom.shearmadness.variations.chancecubes.capability.IChanceCubeParticipationCapability;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
package com.github.atomicblom.shearmadness.variations.chancecubes;
public final class ChanceCubesReference {
public static final String CHANCE_CUBES_MODID = "chancecubes";
| @CapabilityInject(IChanceCubeParticipationCapability.class) |
AtomicBlom/ShearMadness | src/integration/java/com/github/atomicblom/shearmadness/variations/chancecubes/ChanceCubesReference.java | // Path: src/integration/java/com/github/atomicblom/shearmadness/variations/CommonReference.java
// public final class CommonReference {
// public static final String MOD_ID = "shearmadness";
// public static final String MOD_NAME = "Shear Madness";
// public static final String VERSION = "@MOD_VERSION@";
//
// private CommonReference() {}
// }
//
// Path: src/integration/java/com/github/atomicblom/shearmadness/variations/chancecubes/capability/IChanceCubeParticipationCapability.java
// public interface IChanceCubeParticipationCapability {
// boolean isParticipating();
// void setParticipation(boolean isParticipating);
// }
| import com.github.atomicblom.shearmadness.variations.CommonReference;
import com.github.atomicblom.shearmadness.variations.chancecubes.capability.IChanceCubeParticipationCapability;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject; | package com.github.atomicblom.shearmadness.variations.chancecubes;
public final class ChanceCubesReference {
public static final String CHANCE_CUBES_MODID = "chancecubes";
@CapabilityInject(IChanceCubeParticipationCapability.class)
public static final Capability<IChanceCubeParticipationCapability> CHANCE_CUBE_PARTICIPATION;
| // Path: src/integration/java/com/github/atomicblom/shearmadness/variations/CommonReference.java
// public final class CommonReference {
// public static final String MOD_ID = "shearmadness";
// public static final String MOD_NAME = "Shear Madness";
// public static final String VERSION = "@MOD_VERSION@";
//
// private CommonReference() {}
// }
//
// Path: src/integration/java/com/github/atomicblom/shearmadness/variations/chancecubes/capability/IChanceCubeParticipationCapability.java
// public interface IChanceCubeParticipationCapability {
// boolean isParticipating();
// void setParticipation(boolean isParticipating);
// }
// Path: src/integration/java/com/github/atomicblom/shearmadness/variations/chancecubes/ChanceCubesReference.java
import com.github.atomicblom.shearmadness.variations.CommonReference;
import com.github.atomicblom.shearmadness.variations.chancecubes.capability.IChanceCubeParticipationCapability;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
package com.github.atomicblom.shearmadness.variations.chancecubes;
public final class ChanceCubesReference {
public static final String CHANCE_CUBES_MODID = "chancecubes";
@CapabilityInject(IChanceCubeParticipationCapability.class)
public static final Capability<IChanceCubeParticipationCapability> CHANCE_CUBE_PARTICIPATION;
| public static final ResourceLocation ChanceCubeParticipationCapability = new ResourceLocation(CommonReference.MOD_ID, "chance_cube_participation"); |
AtomicBlom/ShearMadness | src/main/java/com/github/atomicblom/shearmadness/proxy/ClientBlockProxy.java | // Path: src/main/java/com/github/atomicblom/shearmadness/utility/Reference.java
// public final class Reference
// {
// public static final CreativeTabs CreativeTab = CreativeTabs.BUILDING_BLOCKS;
// public static final String MOD_GUI_FACTORY = "com.github.atomicblom.shearmadness.configuration.client.ModGuiFactory";
// public static final String BEHAVIOUR_COMMENT = "Sets the behaviour when a sheep is sheared\n" +
// "* RevertSheep - will change the sheep back to a normal sheep (default).\n" +
// "* ChiselFarm - will allow the sheep to produce chiseled blocks (warning, this currently allows duping ores).\n" +
// "* CannotShear - You cannot shear the sheep while chiseled.\n";
// public static final String ALLOW_REDSTONE_COMMENT = "Chiseled redstone sheep will trigger Redstone circuits.";
// public static final String ALLOW_BOOKSHELF_COMMENT = "Chiseled bookshelf sheep will affect enchanting tables.";
// public static final String ALLOW_GLOWSTONE_COMMENT = "Chiseled glowstone sheep will light up the area around them.\n" +
// "WARNING: testing shows this creates a lot of chunk recalculation. I do not recommend this option.";
// public static final String ALLOW_CACTUS_COMMENT = "Chiseled Cactus sheep will deal damage players and destroy items.";
// public static final String ALLOW_TNT_COMMENT = "Chiseled TNT Sheep will be explode if exposed to active redstone.";
// public static final String ALLOW_FIRE_DAMAGE_COMMENT = "Chiseled Magma sheep will deal fire damage when touched.";
// public static final String DEBUG_MODELS = "Models will be regenerated every frame drawn.";
// public static final String DEBUG_INVISIBLE_BLOCKS = "Invisible Blocks will be shown in-game.";
// public static final String ALLOW_AUTO_CRAFTING = "Crafting Table sheep will use their recipe to consume and produce items.";
//
// private Reference() {}
//
// public static final class Blocks {
// public static final String NORMAL_VARIANT = "normal";
//
// public static final ResourceLocation InvisibleRedstone = new ResourceLocation(CommonReference.MOD_ID, "invisibleRedstone");
// public static final ResourceLocation InvisibleGlowstone = new ResourceLocation(CommonReference.MOD_ID, "invisibleGlowstone");
// public static final ResourceLocation InvisibleBookshelf = new ResourceLocation(CommonReference.MOD_ID, "invisibleBookshelf");
//
// private Blocks() {}
// }
//
// }
| import com.github.atomicblom.shearmadness.utility.Reference;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.model.ModelLoader; | package com.github.atomicblom.shearmadness.proxy;
@SuppressWarnings("unused")
public class ClientBlockProxy extends CommonBlockProxy
{
@Override
protected Item configureItemBlock(ItemBlock block)
{
final Item item = super.configureItemBlock(block);
ModelLoader.setCustomModelResourceLocation(
item,
0,
new ModelResourceLocation(
block.getRegistryName(), | // Path: src/main/java/com/github/atomicblom/shearmadness/utility/Reference.java
// public final class Reference
// {
// public static final CreativeTabs CreativeTab = CreativeTabs.BUILDING_BLOCKS;
// public static final String MOD_GUI_FACTORY = "com.github.atomicblom.shearmadness.configuration.client.ModGuiFactory";
// public static final String BEHAVIOUR_COMMENT = "Sets the behaviour when a sheep is sheared\n" +
// "* RevertSheep - will change the sheep back to a normal sheep (default).\n" +
// "* ChiselFarm - will allow the sheep to produce chiseled blocks (warning, this currently allows duping ores).\n" +
// "* CannotShear - You cannot shear the sheep while chiseled.\n";
// public static final String ALLOW_REDSTONE_COMMENT = "Chiseled redstone sheep will trigger Redstone circuits.";
// public static final String ALLOW_BOOKSHELF_COMMENT = "Chiseled bookshelf sheep will affect enchanting tables.";
// public static final String ALLOW_GLOWSTONE_COMMENT = "Chiseled glowstone sheep will light up the area around them.\n" +
// "WARNING: testing shows this creates a lot of chunk recalculation. I do not recommend this option.";
// public static final String ALLOW_CACTUS_COMMENT = "Chiseled Cactus sheep will deal damage players and destroy items.";
// public static final String ALLOW_TNT_COMMENT = "Chiseled TNT Sheep will be explode if exposed to active redstone.";
// public static final String ALLOW_FIRE_DAMAGE_COMMENT = "Chiseled Magma sheep will deal fire damage when touched.";
// public static final String DEBUG_MODELS = "Models will be regenerated every frame drawn.";
// public static final String DEBUG_INVISIBLE_BLOCKS = "Invisible Blocks will be shown in-game.";
// public static final String ALLOW_AUTO_CRAFTING = "Crafting Table sheep will use their recipe to consume and produce items.";
//
// private Reference() {}
//
// public static final class Blocks {
// public static final String NORMAL_VARIANT = "normal";
//
// public static final ResourceLocation InvisibleRedstone = new ResourceLocation(CommonReference.MOD_ID, "invisibleRedstone");
// public static final ResourceLocation InvisibleGlowstone = new ResourceLocation(CommonReference.MOD_ID, "invisibleGlowstone");
// public static final ResourceLocation InvisibleBookshelf = new ResourceLocation(CommonReference.MOD_ID, "invisibleBookshelf");
//
// private Blocks() {}
// }
//
// }
// Path: src/main/java/com/github/atomicblom/shearmadness/proxy/ClientBlockProxy.java
import com.github.atomicblom.shearmadness.utility.Reference;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.model.ModelLoader;
package com.github.atomicblom.shearmadness.proxy;
@SuppressWarnings("unused")
public class ClientBlockProxy extends CommonBlockProxy
{
@Override
protected Item configureItemBlock(ItemBlock block)
{
final Item item = super.configureItemBlock(block);
ModelLoader.setCustomModelResourceLocation(
item,
0,
new ModelResourceLocation(
block.getRegistryName(), | Reference.Blocks.NORMAL_VARIANT |
AtomicBlom/ShearMadness | src/integration/java/com/github/atomicblom/shearmadness/variations/vanilla/interactions/AnvilInteraction.java | // Path: src/integration/java/com/github/atomicblom/shearmadness/variations/vanilla/container/ContainerRepairSheep.java
// public class ContainerRepairSheep extends ContainerRepair
// {
// private final EntityLiving entity;
//
// public ContainerRepairSheep(InventoryPlayer playerInventory, World worldIn, EntityPlayer player, EntityLiving entity)
// {
// super(playerInventory, worldIn, entity.getPosition(), player);
// this.entity = entity;
// }
//
// @Override
// public boolean canInteractWith(EntityPlayer playerIn) {
// if (!entity.hasCapability(Capability.CHISELED_SHEEP, null)) {
// return false;
// }
// final IChiseledSheepCapability capability = entity.getCapability(Capability.CHISELED_SHEEP, null);
// final Item item = capability.getChiselItemStack().getItem();
// if (!(item instanceof ItemBlock) || !Objects.equals(((ItemBlock) item).block, Blocks.ANVIL)) {
// return false;
// }
//
// return playerIn.getDistanceSq(entity.getPosition()) <= 64.0D;
// }
// }
| import com.github.atomicblom.shearmadness.variations.vanilla.container.ContainerRepairSheep;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Container;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.IInteractionObject;
import net.minecraft.world.World; | package com.github.atomicblom.shearmadness.variations.vanilla.interactions;
public class AnvilInteraction implements IInteractionObject
{
private final World world;
private final EntityLiving entity;
public AnvilInteraction(World world, EntityLiving entity)
{
this.world = world;
this.entity = entity;
}
/**
* Get the name of this object. For players this returns their username
*/
@Override
public String getName()
{
return "anvil";
}
/**
* Returns true if this thing is named
*/
@Override
public boolean hasCustomName()
{
return false;
}
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
@Override
public ITextComponent getDisplayName()
{
return new TextComponentTranslation(Blocks.ANVIL.getUnlocalizedName() + ".name");
}
@Override
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
{ | // Path: src/integration/java/com/github/atomicblom/shearmadness/variations/vanilla/container/ContainerRepairSheep.java
// public class ContainerRepairSheep extends ContainerRepair
// {
// private final EntityLiving entity;
//
// public ContainerRepairSheep(InventoryPlayer playerInventory, World worldIn, EntityPlayer player, EntityLiving entity)
// {
// super(playerInventory, worldIn, entity.getPosition(), player);
// this.entity = entity;
// }
//
// @Override
// public boolean canInteractWith(EntityPlayer playerIn) {
// if (!entity.hasCapability(Capability.CHISELED_SHEEP, null)) {
// return false;
// }
// final IChiseledSheepCapability capability = entity.getCapability(Capability.CHISELED_SHEEP, null);
// final Item item = capability.getChiselItemStack().getItem();
// if (!(item instanceof ItemBlock) || !Objects.equals(((ItemBlock) item).block, Blocks.ANVIL)) {
// return false;
// }
//
// return playerIn.getDistanceSq(entity.getPosition()) <= 64.0D;
// }
// }
// Path: src/integration/java/com/github/atomicblom/shearmadness/variations/vanilla/interactions/AnvilInteraction.java
import com.github.atomicblom.shearmadness.variations.vanilla.container.ContainerRepairSheep;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Container;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.IInteractionObject;
import net.minecraft.world.World;
package com.github.atomicblom.shearmadness.variations.vanilla.interactions;
public class AnvilInteraction implements IInteractionObject
{
private final World world;
private final EntityLiving entity;
public AnvilInteraction(World world, EntityLiving entity)
{
this.world = world;
this.entity = entity;
}
/**
* Get the name of this object. For players this returns their username
*/
@Override
public String getName()
{
return "anvil";
}
/**
* Returns true if this thing is named
*/
@Override
public boolean hasCustomName()
{
return false;
}
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
@Override
public ITextComponent getDisplayName()
{
return new TextComponentTranslation(Blocks.ANVIL.getUnlocalizedName() + ".name");
}
@Override
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
{ | return new ContainerRepairSheep(playerInventory, world, playerIn, entity); |
AtomicBlom/ShearMadness | src/main/java/com/github/atomicblom/shearmadness/api/BehaviourRegistry.java | // Path: src/api/java/com/github/atomicblom/shearmadness/api/behaviour/BehaviourBase.java
// @SuppressWarnings({"NoopMethodInAbstractClass", "ClassHasNoToStringMethod", "WeakerAccess"})
// public abstract class BehaviourBase<T extends BehaviourBase> {
// private final EntitySheep entity;
// private final Supplier<Boolean> configuration;
//
// protected BehaviourBase(EntitySheep sheep) {
// this(sheep, () -> true);
// }
//
// protected BehaviourBase(EntitySheep entity, Supplier<Boolean> configuration)
// {
// this.entity = entity;
// this.configuration = configuration;
// }
//
// public boolean isBehaviourEnabled() {
// return configuration.get();
// }
//
// public void onSheepMovedBlock(BlockPos previousLocation, BlockPos newLocation) {}
//
// public void onBehaviourStarted(BlockPos currentPos) {}
//
// public void onBehaviourStopped(BlockPos previousPos) {}
//
// public void updateTask() {}
//
// public boolean isEquivalentTo(T other) {
// return entity.getUniqueID().equals(other.getEntity().getUniqueID());
// }
//
// public EntitySheep getEntity()
// {
// return entity;
// }
// }
| import com.github.atomicblom.shearmadness.api.behaviour.BehaviourBase;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.item.ItemStack;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.function.Function; | package com.github.atomicblom.shearmadness.api;
public class BehaviourRegistry implements IBehaviourRegistry {
public static final BehaviourRegistry INSTANCE = new BehaviourRegistry();
private final List<ShearMadnessBehaviour> behaviours = new LinkedList<>();
@Override | // Path: src/api/java/com/github/atomicblom/shearmadness/api/behaviour/BehaviourBase.java
// @SuppressWarnings({"NoopMethodInAbstractClass", "ClassHasNoToStringMethod", "WeakerAccess"})
// public abstract class BehaviourBase<T extends BehaviourBase> {
// private final EntitySheep entity;
// private final Supplier<Boolean> configuration;
//
// protected BehaviourBase(EntitySheep sheep) {
// this(sheep, () -> true);
// }
//
// protected BehaviourBase(EntitySheep entity, Supplier<Boolean> configuration)
// {
// this.entity = entity;
// this.configuration = configuration;
// }
//
// public boolean isBehaviourEnabled() {
// return configuration.get();
// }
//
// public void onSheepMovedBlock(BlockPos previousLocation, BlockPos newLocation) {}
//
// public void onBehaviourStarted(BlockPos currentPos) {}
//
// public void onBehaviourStopped(BlockPos previousPos) {}
//
// public void updateTask() {}
//
// public boolean isEquivalentTo(T other) {
// return entity.getUniqueID().equals(other.getEntity().getUniqueID());
// }
//
// public EntitySheep getEntity()
// {
// return entity;
// }
// }
// Path: src/main/java/com/github/atomicblom/shearmadness/api/BehaviourRegistry.java
import com.github.atomicblom.shearmadness.api.behaviour.BehaviourBase;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.item.ItemStack;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.function.Function;
package com.github.atomicblom.shearmadness.api;
public class BehaviourRegistry implements IBehaviourRegistry {
public static final BehaviourRegistry INSTANCE = new BehaviourRegistry();
private final List<ShearMadnessBehaviour> behaviours = new LinkedList<>();
@Override | public void registerBehaviour(Function<ItemStack, Boolean> handlesVariant, Function<EntitySheep, BehaviourBase> behaviourFactory) { |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/UIPreferenceFragment.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIPreferenceFragment extends PreferenceFragment implements IFragment, UIInterface {
private Core mCore;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
| // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/UIPreferenceFragment.java
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIPreferenceFragment extends PreferenceFragment implements IFragment, UIInterface {
private Core mCore;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
| mCore = CoreFactory.getCore(); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/UIPreferenceFragment.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIPreferenceFragment extends PreferenceFragment implements IFragment, UIInterface {
private Core mCore;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mCore = CoreFactory.getCore();
| // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/UIPreferenceFragment.java
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIPreferenceFragment extends PreferenceFragment implements IFragment, UIInterface {
private Core mCore;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mCore = CoreFactory.getCore();
| ((UIPlugin) mCore.getPlugin(Core.PLUGIN_UI)).registerUI(this); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIPreferenceCategory.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.view.View;
import android.widget.TextView;
import com.beerbong.zipinst.R;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.preference.PreferenceCategory;
import android.util.AttributeSet;
import android.util.TypedValue; |
public UIPreferenceCategory(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreferenceCategory(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
Context context = getContext();
Resources res = context.getResources();
if (mTextColor == 0) {
TypedValue typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(R.attr.fragmentTitleColor, typedValue, true);
mTextColor = typedValue.resourceId;
typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, typedValue, true);
mAppearanceMedium = typedValue.resourceId;
}
TextView titleView = (TextView) view.findViewById(android.R.id.title);
if (titleView != null) {
titleView.setTextAppearance(context, mAppearanceMedium);
titleView.setTextColor(res.getColor(mTextColor));
float size = res.getDimension(R.dimen.fragment_title_size);
titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
//titleView.setBackgroundColor(mTextColor);
} | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIPreferenceCategory.java
import android.view.View;
import android.widget.TextView;
import com.beerbong.zipinst.R;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.preference.PreferenceCategory;
import android.util.AttributeSet;
import android.util.TypedValue;
public UIPreferenceCategory(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreferenceCategory(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
Context context = getContext();
Resources res = context.getResources();
if (mTextColor == 0) {
TypedValue typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(R.attr.fragmentTitleColor, typedValue, true);
mTextColor = typedValue.resourceId;
typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, typedValue, true);
mAppearanceMedium = typedValue.resourceId;
}
TextView titleView = (TextView) view.findViewById(android.R.id.title);
if (titleView != null) {
titleView.setTextAppearance(context, mAppearanceMedium);
titleView.setTextColor(res.getColor(mTextColor));
float size = res.getDimension(R.dimen.fragment_title_size);
titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
//titleView.setBackgroundColor(mTextColor);
} | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIPreferenceCategory.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.view.View;
import android.widget.TextView;
import com.beerbong.zipinst.R;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.preference.PreferenceCategory;
import android.util.AttributeSet;
import android.util.TypedValue; |
public UIPreferenceCategory(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreferenceCategory(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
Context context = getContext();
Resources res = context.getResources();
if (mTextColor == 0) {
TypedValue typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(R.attr.fragmentTitleColor, typedValue, true);
mTextColor = typedValue.resourceId;
typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, typedValue, true);
mAppearanceMedium = typedValue.resourceId;
}
TextView titleView = (TextView) view.findViewById(android.R.id.title);
if (titleView != null) {
titleView.setTextAppearance(context, mAppearanceMedium);
titleView.setTextColor(res.getColor(mTextColor));
float size = res.getDimension(R.dimen.fragment_title_size);
titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
//titleView.setBackgroundColor(mTextColor);
} | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIPreferenceCategory.java
import android.view.View;
import android.widget.TextView;
import com.beerbong.zipinst.R;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.preference.PreferenceCategory;
import android.util.AttributeSet;
import android.util.TypedValue;
public UIPreferenceCategory(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreferenceCategory(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
Context context = getContext();
Resources res = context.getResources();
if (mTextColor == 0) {
TypedValue typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(R.attr.fragmentTitleColor, typedValue, true);
mTextColor = typedValue.resourceId;
typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, typedValue, true);
mAppearanceMedium = typedValue.resourceId;
}
TextView titleView = (TextView) view.findViewById(android.R.id.title);
if (titleView != null) {
titleView.setTextAppearance(context, mAppearanceMedium);
titleView.setTextColor(res.getColor(mTextColor));
float size = res.getDimension(R.dimen.fragment_title_size);
titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
//titleView.setBackgroundColor(mTextColor);
} | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIPreferenceCategory.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.view.View;
import android.widget.TextView;
import com.beerbong.zipinst.R;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.preference.PreferenceCategory;
import android.util.AttributeSet;
import android.util.TypedValue; |
public UIPreferenceCategory(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreferenceCategory(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
Context context = getContext();
Resources res = context.getResources();
if (mTextColor == 0) {
TypedValue typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(R.attr.fragmentTitleColor, typedValue, true);
mTextColor = typedValue.resourceId;
typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, typedValue, true);
mAppearanceMedium = typedValue.resourceId;
}
TextView titleView = (TextView) view.findViewById(android.R.id.title);
if (titleView != null) {
titleView.setTextAppearance(context, mAppearanceMedium);
titleView.setTextColor(res.getColor(mTextColor));
float size = res.getDimension(R.dimen.fragment_title_size);
titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
//titleView.setBackgroundColor(mTextColor);
} | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIPreferenceCategory.java
import android.view.View;
import android.widget.TextView;
import com.beerbong.zipinst.R;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.preference.PreferenceCategory;
import android.util.AttributeSet;
import android.util.TypedValue;
public UIPreferenceCategory(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreferenceCategory(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
Context context = getContext();
Resources res = context.getResources();
if (mTextColor == 0) {
TypedValue typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(R.attr.fragmentTitleColor, typedValue, true);
mTextColor = typedValue.resourceId;
typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, typedValue, true);
mAppearanceMedium = typedValue.resourceId;
}
TextView titleView = (TextView) view.findViewById(android.R.id.title);
if (titleView != null) {
titleView.setTextAppearance(context, mAppearanceMedium);
titleView.setTextColor(res.getColor(mTextColor));
float size = res.getDimension(R.dimen.fragment_title_size);
titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
//titleView.setBackgroundColor(mTextColor);
} | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/core/plugins/update/impl/GooUpdater.java | // Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
//
// public class RomInfo {
//
// public int id;
// public String filename;
// public String path;
// public String folder;
// public String md5;
// public String type;
// public String description;
// public int is_flashable;
// public long modified;
// public int downloads;
// public int status;
// public String additional_info;
// public String short_url;
// public int developer_id;
// public String developerid;
// public String board;
// public String rom;
// public long version;
// public int gapps_package;
// public int incremental_file;
// }
//
// public static final String PROPERTY_DEVICE = "ro.product.device";
//
// public static interface UpdaterListener {
//
// public void versionFound(RomInfo info);
// public void versionError(String error);
// }
//
// public String getRomName();
//
// public int getRomVersion();
//
// public void searchVersion();
//
// public boolean isScanning();
// }
//
// Path: src/com/beerbong/zipinst/http/URLStringReader.java
// public class URLStringReader extends AsyncTask<String, Void, Void> {
//
// public static interface URLStringReaderListener {
//
// public void onReadEnd(String buffer);
// public void onReadError(Exception ex);
// };
//
// private URLStringReaderListener mListener;
// private String mBuffer;
// private Exception mException;
//
// public URLStringReader(URLStringReaderListener listener) {
// mListener = listener;
// }
//
// @Override
// protected Void doInBackground(String... params) {
// try {
// mBuffer = readString(params[0]);
// return null;
// } catch (Exception ex) {
// ex.printStackTrace();
// mException = ex;
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (mListener != null) {
// if (mException != null) {
// mListener.onReadError(mException);
// } else {
// mListener.onReadEnd(mBuffer);
// }
// }
// }
//
// private String readString(String urlStr) throws Exception {
// URL url = new URL(urlStr);
// URLConnection yc = url.openConnection();
// BufferedReader in = null;
// StringBuffer sb = new StringBuffer();
// try {
// in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
// String inputLine;
// while ((inputLine = in.readLine()) != null)
// sb.append(inputLine);
// } finally {
// if (in != null)
// in.close();
// }
// return sb.toString();
// }
// }
//
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
//
// private static final int ALARM_ID = 122303221;
//
// public static String getProperty(String prop) {
// try {
// Process p = Runtime.getRuntime().exec("getprop " + prop);
// p.waitFor();
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line = input.readLine();
// return "".equals(line) ? null : line;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
//
// public static void setAlarm(Context context, long time, boolean trigger) {
//
// Intent i = new Intent(context, NotificationAlarm.class);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// PendingIntent pi = PendingIntent
// .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
//
// AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// am.cancel(pi);
// if (time > 0) {
// am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
// }
// }
//
// public static boolean alarmExists(Context context) {
// return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
// NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
// }
// }
| import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.URLStringReader;
import com.beerbong.zipinst.io.SystemProperties; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.core.plugins.update.impl;
public class GooUpdater implements Updater {
public static final String PROPERTY_GOO_DEVELOPER = "ro.goo.developerid";
public static final String PROPERTY_GOO_ROM = "ro.goo.rom";
public static final String PROPERTY_GOO_VERSION = "ro.goo.version";
private UpdaterListener mListener;
private List<RomInfo> mFoundRoms;
private int mScanning = 0;
public GooUpdater(UpdaterListener listener) {
mListener = listener;
}
public String getDeveloperId() { | // Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
//
// public class RomInfo {
//
// public int id;
// public String filename;
// public String path;
// public String folder;
// public String md5;
// public String type;
// public String description;
// public int is_flashable;
// public long modified;
// public int downloads;
// public int status;
// public String additional_info;
// public String short_url;
// public int developer_id;
// public String developerid;
// public String board;
// public String rom;
// public long version;
// public int gapps_package;
// public int incremental_file;
// }
//
// public static final String PROPERTY_DEVICE = "ro.product.device";
//
// public static interface UpdaterListener {
//
// public void versionFound(RomInfo info);
// public void versionError(String error);
// }
//
// public String getRomName();
//
// public int getRomVersion();
//
// public void searchVersion();
//
// public boolean isScanning();
// }
//
// Path: src/com/beerbong/zipinst/http/URLStringReader.java
// public class URLStringReader extends AsyncTask<String, Void, Void> {
//
// public static interface URLStringReaderListener {
//
// public void onReadEnd(String buffer);
// public void onReadError(Exception ex);
// };
//
// private URLStringReaderListener mListener;
// private String mBuffer;
// private Exception mException;
//
// public URLStringReader(URLStringReaderListener listener) {
// mListener = listener;
// }
//
// @Override
// protected Void doInBackground(String... params) {
// try {
// mBuffer = readString(params[0]);
// return null;
// } catch (Exception ex) {
// ex.printStackTrace();
// mException = ex;
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (mListener != null) {
// if (mException != null) {
// mListener.onReadError(mException);
// } else {
// mListener.onReadEnd(mBuffer);
// }
// }
// }
//
// private String readString(String urlStr) throws Exception {
// URL url = new URL(urlStr);
// URLConnection yc = url.openConnection();
// BufferedReader in = null;
// StringBuffer sb = new StringBuffer();
// try {
// in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
// String inputLine;
// while ((inputLine = in.readLine()) != null)
// sb.append(inputLine);
// } finally {
// if (in != null)
// in.close();
// }
// return sb.toString();
// }
// }
//
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
//
// private static final int ALARM_ID = 122303221;
//
// public static String getProperty(String prop) {
// try {
// Process p = Runtime.getRuntime().exec("getprop " + prop);
// p.waitFor();
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line = input.readLine();
// return "".equals(line) ? null : line;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
//
// public static void setAlarm(Context context, long time, boolean trigger) {
//
// Intent i = new Intent(context, NotificationAlarm.class);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// PendingIntent pi = PendingIntent
// .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
//
// AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// am.cancel(pi);
// if (time > 0) {
// am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
// }
// }
//
// public static boolean alarmExists(Context context) {
// return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
// NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
// }
// }
// Path: src/com/beerbong/zipinst/core/plugins/update/impl/GooUpdater.java
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.URLStringReader;
import com.beerbong.zipinst.io.SystemProperties;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.core.plugins.update.impl;
public class GooUpdater implements Updater {
public static final String PROPERTY_GOO_DEVELOPER = "ro.goo.developerid";
public static final String PROPERTY_GOO_ROM = "ro.goo.rom";
public static final String PROPERTY_GOO_VERSION = "ro.goo.version";
private UpdaterListener mListener;
private List<RomInfo> mFoundRoms;
private int mScanning = 0;
public GooUpdater(UpdaterListener listener) {
mListener = listener;
}
public String getDeveloperId() { | return SystemProperties.getProperty(PROPERTY_GOO_DEVELOPER); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/core/plugins/update/impl/GooUpdater.java | // Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
//
// public class RomInfo {
//
// public int id;
// public String filename;
// public String path;
// public String folder;
// public String md5;
// public String type;
// public String description;
// public int is_flashable;
// public long modified;
// public int downloads;
// public int status;
// public String additional_info;
// public String short_url;
// public int developer_id;
// public String developerid;
// public String board;
// public String rom;
// public long version;
// public int gapps_package;
// public int incremental_file;
// }
//
// public static final String PROPERTY_DEVICE = "ro.product.device";
//
// public static interface UpdaterListener {
//
// public void versionFound(RomInfo info);
// public void versionError(String error);
// }
//
// public String getRomName();
//
// public int getRomVersion();
//
// public void searchVersion();
//
// public boolean isScanning();
// }
//
// Path: src/com/beerbong/zipinst/http/URLStringReader.java
// public class URLStringReader extends AsyncTask<String, Void, Void> {
//
// public static interface URLStringReaderListener {
//
// public void onReadEnd(String buffer);
// public void onReadError(Exception ex);
// };
//
// private URLStringReaderListener mListener;
// private String mBuffer;
// private Exception mException;
//
// public URLStringReader(URLStringReaderListener listener) {
// mListener = listener;
// }
//
// @Override
// protected Void doInBackground(String... params) {
// try {
// mBuffer = readString(params[0]);
// return null;
// } catch (Exception ex) {
// ex.printStackTrace();
// mException = ex;
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (mListener != null) {
// if (mException != null) {
// mListener.onReadError(mException);
// } else {
// mListener.onReadEnd(mBuffer);
// }
// }
// }
//
// private String readString(String urlStr) throws Exception {
// URL url = new URL(urlStr);
// URLConnection yc = url.openConnection();
// BufferedReader in = null;
// StringBuffer sb = new StringBuffer();
// try {
// in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
// String inputLine;
// while ((inputLine = in.readLine()) != null)
// sb.append(inputLine);
// } finally {
// if (in != null)
// in.close();
// }
// return sb.toString();
// }
// }
//
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
//
// private static final int ALARM_ID = 122303221;
//
// public static String getProperty(String prop) {
// try {
// Process p = Runtime.getRuntime().exec("getprop " + prop);
// p.waitFor();
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line = input.readLine();
// return "".equals(line) ? null : line;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
//
// public static void setAlarm(Context context, long time, boolean trigger) {
//
// Intent i = new Intent(context, NotificationAlarm.class);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// PendingIntent pi = PendingIntent
// .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
//
// AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// am.cancel(pi);
// if (time > 0) {
// am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
// }
// }
//
// public static boolean alarmExists(Context context) {
// return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
// NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
// }
// }
| import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.URLStringReader;
import com.beerbong.zipinst.io.SystemProperties; | public String getRomName() {
return SystemProperties.getProperty(PROPERTY_GOO_ROM);
}
@Override
public int getRomVersion() {
String version = SystemProperties.getProperty(PROPERTY_GOO_VERSION);
if (version != null) {
try {
return Integer.parseInt(version);
} catch (NumberFormatException ex) {
}
}
return -1;
}
@Override
public void searchVersion() {
mScanning = 0;
mFoundRoms = new ArrayList<RomInfo>();
searchGoo("/devs/" + getDeveloperId());
}
@Override
public boolean isScanning() {
return mScanning > 0;
}
private void searchGoo(String path) {
mScanning++; | // Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
//
// public class RomInfo {
//
// public int id;
// public String filename;
// public String path;
// public String folder;
// public String md5;
// public String type;
// public String description;
// public int is_flashable;
// public long modified;
// public int downloads;
// public int status;
// public String additional_info;
// public String short_url;
// public int developer_id;
// public String developerid;
// public String board;
// public String rom;
// public long version;
// public int gapps_package;
// public int incremental_file;
// }
//
// public static final String PROPERTY_DEVICE = "ro.product.device";
//
// public static interface UpdaterListener {
//
// public void versionFound(RomInfo info);
// public void versionError(String error);
// }
//
// public String getRomName();
//
// public int getRomVersion();
//
// public void searchVersion();
//
// public boolean isScanning();
// }
//
// Path: src/com/beerbong/zipinst/http/URLStringReader.java
// public class URLStringReader extends AsyncTask<String, Void, Void> {
//
// public static interface URLStringReaderListener {
//
// public void onReadEnd(String buffer);
// public void onReadError(Exception ex);
// };
//
// private URLStringReaderListener mListener;
// private String mBuffer;
// private Exception mException;
//
// public URLStringReader(URLStringReaderListener listener) {
// mListener = listener;
// }
//
// @Override
// protected Void doInBackground(String... params) {
// try {
// mBuffer = readString(params[0]);
// return null;
// } catch (Exception ex) {
// ex.printStackTrace();
// mException = ex;
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (mListener != null) {
// if (mException != null) {
// mListener.onReadError(mException);
// } else {
// mListener.onReadEnd(mBuffer);
// }
// }
// }
//
// private String readString(String urlStr) throws Exception {
// URL url = new URL(urlStr);
// URLConnection yc = url.openConnection();
// BufferedReader in = null;
// StringBuffer sb = new StringBuffer();
// try {
// in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
// String inputLine;
// while ((inputLine = in.readLine()) != null)
// sb.append(inputLine);
// } finally {
// if (in != null)
// in.close();
// }
// return sb.toString();
// }
// }
//
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
//
// private static final int ALARM_ID = 122303221;
//
// public static String getProperty(String prop) {
// try {
// Process p = Runtime.getRuntime().exec("getprop " + prop);
// p.waitFor();
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line = input.readLine();
// return "".equals(line) ? null : line;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
//
// public static void setAlarm(Context context, long time, boolean trigger) {
//
// Intent i = new Intent(context, NotificationAlarm.class);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// PendingIntent pi = PendingIntent
// .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
//
// AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// am.cancel(pi);
// if (time > 0) {
// am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
// }
// }
//
// public static boolean alarmExists(Context context) {
// return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
// NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
// }
// }
// Path: src/com/beerbong/zipinst/core/plugins/update/impl/GooUpdater.java
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.URLStringReader;
import com.beerbong.zipinst.io.SystemProperties;
public String getRomName() {
return SystemProperties.getProperty(PROPERTY_GOO_ROM);
}
@Override
public int getRomVersion() {
String version = SystemProperties.getProperty(PROPERTY_GOO_VERSION);
if (version != null) {
try {
return Integer.parseInt(version);
} catch (NumberFormatException ex) {
}
}
return -1;
}
@Override
public void searchVersion() {
mScanning = 0;
mFoundRoms = new ArrayList<RomInfo>();
searchGoo("/devs/" + getDeveloperId());
}
@Override
public boolean isScanning() {
return mScanning > 0;
}
private void searchGoo(String path) {
mScanning++; | new URLStringReader(this).execute("http://goo.im/json2&path=" + path + "&ro_board=" |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIMultiSelectListPreference.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.content.Context;
import android.preference.MultiSelectListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIMultiSelectListPreference extends MultiSelectListPreference {
public UIMultiSelectListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIMultiSelectListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIMultiSelectListPreference.java
import android.content.Context;
import android.preference.MultiSelectListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIMultiSelectListPreference extends MultiSelectListPreference {
public UIMultiSelectListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIMultiSelectListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIMultiSelectListPreference.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.content.Context;
import android.preference.MultiSelectListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIMultiSelectListPreference extends MultiSelectListPreference {
public UIMultiSelectListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIMultiSelectListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIMultiSelectListPreference.java
import android.content.Context;
import android.preference.MultiSelectListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIMultiSelectListPreference extends MultiSelectListPreference {
public UIMultiSelectListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIMultiSelectListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIMultiSelectListPreference.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.content.Context;
import android.preference.MultiSelectListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIMultiSelectListPreference extends MultiSelectListPreference {
public UIMultiSelectListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIMultiSelectListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIMultiSelectListPreference.java
import android.content.Context;
import android.preference.MultiSelectListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIMultiSelectListPreference extends MultiSelectListPreference {
public UIMultiSelectListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIMultiSelectListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/io/SystemProperties.java | // Path: src/com/beerbong/zipinst/NotificationAlarm.java
// public class NotificationAlarm extends BroadcastReceiver {
//
// private RomUpdater mRomUpdater;
//
// @Override
// public void onReceive(Context context, Intent intent) {
//
// if (mRomUpdater == null) {
// mRomUpdater = new RomUpdater(context);
// }
//
// if (SystemProperties.isNetworkAvailable(context)) {
// mRomUpdater.check();
// }
// }
// }
| import java.io.BufferedReader;
import java.io.InputStreamReader;
import com.beerbong.zipinst.NotificationAlarm;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.io;
public class SystemProperties {
private static final int ALARM_ID = 122303221;
public static String getProperty(String prop) {
try {
Process p = Runtime.getRuntime().exec("getprop " + prop);
p.waitFor();
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = input.readLine();
return "".equals(line) ? null : line;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static boolean isNetworkAvailable(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
public static void setAlarm(Context context, long time, boolean trigger) {
| // Path: src/com/beerbong/zipinst/NotificationAlarm.java
// public class NotificationAlarm extends BroadcastReceiver {
//
// private RomUpdater mRomUpdater;
//
// @Override
// public void onReceive(Context context, Intent intent) {
//
// if (mRomUpdater == null) {
// mRomUpdater = new RomUpdater(context);
// }
//
// if (SystemProperties.isNetworkAvailable(context)) {
// mRomUpdater.check();
// }
// }
// }
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import com.beerbong.zipinst.NotificationAlarm;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.io;
public class SystemProperties {
private static final int ALARM_ID = 122303221;
public static String getProperty(String prop) {
try {
Process p = Runtime.getRuntime().exec("getprop " + prop);
p.waitFor();
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = input.readLine();
return "".equals(line) ? null : line;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static boolean isNetworkAvailable(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
public static void setAlarm(Context context, long time, boolean trigger) {
| Intent i = new Intent(context, NotificationAlarm.class); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/UIFragment.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.view.ViewGroup;
import java.io.Serializable;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIFragment extends Fragment implements IFragment, UIInterface, Serializable {
private Core mCore;
private View mMainView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
| // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/UIFragment.java
import android.view.ViewGroup;
import java.io.Serializable;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIFragment extends Fragment implements IFragment, UIInterface, Serializable {
private Core mCore;
private View mMainView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
| mCore = CoreFactory.getCore(); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/UIFragment.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.view.ViewGroup;
import java.io.Serializable;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIFragment extends Fragment implements IFragment, UIInterface, Serializable {
private Core mCore;
private View mMainView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mCore = CoreFactory.getCore();
| // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/UIFragment.java
import android.view.ViewGroup;
import java.io.Serializable;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIFragment extends Fragment implements IFragment, UIInterface, Serializable {
private Core mCore;
private View mMainView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mCore = CoreFactory.getCore();
| ((UIPlugin) mCore.getPlugin(Core.PLUGIN_UI)).registerUI(this); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/core/plugins/update/impl/OUCUpdater.java | // Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
//
// public class RomInfo {
//
// public int id;
// public String filename;
// public String path;
// public String folder;
// public String md5;
// public String type;
// public String description;
// public int is_flashable;
// public long modified;
// public int downloads;
// public int status;
// public String additional_info;
// public String short_url;
// public int developer_id;
// public String developerid;
// public String board;
// public String rom;
// public long version;
// public int gapps_package;
// public int incremental_file;
// }
//
// public static final String PROPERTY_DEVICE = "ro.product.device";
//
// public static interface UpdaterListener {
//
// public void versionFound(RomInfo info);
// public void versionError(String error);
// }
//
// public String getRomName();
//
// public int getRomVersion();
//
// public void searchVersion();
//
// public boolean isScanning();
// }
//
// Path: src/com/beerbong/zipinst/http/HttpStringReader.java
// public class HttpStringReader extends AsyncTask<String, Void, Void> {
//
// public static interface HttpStringReaderListener {
//
// public void onReadEnd(String buffer);
// public void onReadError(Exception ex);
// };
//
// private HttpStringReaderListener mListener;
// private String mResponse;
// private Exception mException;
//
// public HttpStringReader(HttpStringReaderListener listener) {
// mListener = listener;
// }
//
// @Override
// protected Void doInBackground(String... urls) {
// try {
// HttpClient client = new DefaultHttpClient();
// HttpGet get = new HttpGet(urls[0]);
// HttpResponse r = client.execute(get);
// int status = r.getStatusLine().getStatusCode();
// HttpEntity e = r.getEntity();
// if (status == 200) {
// mResponse = EntityUtils.toString(e);
// } else {
// if (e != null) e.consumeContent();
// String error = "Server responded with error " + status;
// mException = new Exception(error);
// }
// } catch (Exception ex) {
// ex.printStackTrace();
// mException = ex;
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (mListener != null) {
// if (mException != null) {
// mListener.onReadError(mException);
// } else {
// mListener.onReadEnd(mResponse);
// }
// }
// }
// }
//
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
//
// private static final int ALARM_ID = 122303221;
//
// public static String getProperty(String prop) {
// try {
// Process p = Runtime.getRuntime().exec("getprop " + prop);
// p.waitFor();
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line = input.readLine();
// return "".equals(line) ? null : line;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
//
// public static void setAlarm(Context context, long time, boolean trigger) {
//
// Intent i = new Intent(context, NotificationAlarm.class);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// PendingIntent pi = PendingIntent
// .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
//
// AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// am.cancel(pi);
// if (time > 0) {
// am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
// }
// }
//
// public static boolean alarmExists(Context context) {
// return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
// NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
// }
// }
| import java.util.ArrayList;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.HttpStringReader;
import com.beerbong.zipinst.io.SystemProperties; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.core.plugins.update.impl;
public class OUCUpdater implements Updater {
public static final String URL = "https://www.otaupdatecenter.pro/pages/romupdate.php";
public static final String PROPERTY_OTA_ID = "otaupdater.otaid";
public static final String PROPERTY_OTA_VER = "otaupdater.otaver";
public static final String PROPERTY_OTA_TIME = "otaupdater.otatime";
private UpdaterListener mListener;
private boolean mScanning = false;
public OUCUpdater(UpdaterListener listener) {
mListener = listener;
}
@Override
public String getRomName() { | // Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
//
// public class RomInfo {
//
// public int id;
// public String filename;
// public String path;
// public String folder;
// public String md5;
// public String type;
// public String description;
// public int is_flashable;
// public long modified;
// public int downloads;
// public int status;
// public String additional_info;
// public String short_url;
// public int developer_id;
// public String developerid;
// public String board;
// public String rom;
// public long version;
// public int gapps_package;
// public int incremental_file;
// }
//
// public static final String PROPERTY_DEVICE = "ro.product.device";
//
// public static interface UpdaterListener {
//
// public void versionFound(RomInfo info);
// public void versionError(String error);
// }
//
// public String getRomName();
//
// public int getRomVersion();
//
// public void searchVersion();
//
// public boolean isScanning();
// }
//
// Path: src/com/beerbong/zipinst/http/HttpStringReader.java
// public class HttpStringReader extends AsyncTask<String, Void, Void> {
//
// public static interface HttpStringReaderListener {
//
// public void onReadEnd(String buffer);
// public void onReadError(Exception ex);
// };
//
// private HttpStringReaderListener mListener;
// private String mResponse;
// private Exception mException;
//
// public HttpStringReader(HttpStringReaderListener listener) {
// mListener = listener;
// }
//
// @Override
// protected Void doInBackground(String... urls) {
// try {
// HttpClient client = new DefaultHttpClient();
// HttpGet get = new HttpGet(urls[0]);
// HttpResponse r = client.execute(get);
// int status = r.getStatusLine().getStatusCode();
// HttpEntity e = r.getEntity();
// if (status == 200) {
// mResponse = EntityUtils.toString(e);
// } else {
// if (e != null) e.consumeContent();
// String error = "Server responded with error " + status;
// mException = new Exception(error);
// }
// } catch (Exception ex) {
// ex.printStackTrace();
// mException = ex;
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (mListener != null) {
// if (mException != null) {
// mListener.onReadError(mException);
// } else {
// mListener.onReadEnd(mResponse);
// }
// }
// }
// }
//
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
//
// private static final int ALARM_ID = 122303221;
//
// public static String getProperty(String prop) {
// try {
// Process p = Runtime.getRuntime().exec("getprop " + prop);
// p.waitFor();
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line = input.readLine();
// return "".equals(line) ? null : line;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
//
// public static void setAlarm(Context context, long time, boolean trigger) {
//
// Intent i = new Intent(context, NotificationAlarm.class);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// PendingIntent pi = PendingIntent
// .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
//
// AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// am.cancel(pi);
// if (time > 0) {
// am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
// }
// }
//
// public static boolean alarmExists(Context context) {
// return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
// NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
// }
// }
// Path: src/com/beerbong/zipinst/core/plugins/update/impl/OUCUpdater.java
import java.util.ArrayList;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.HttpStringReader;
import com.beerbong.zipinst.io.SystemProperties;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.core.plugins.update.impl;
public class OUCUpdater implements Updater {
public static final String URL = "https://www.otaupdatecenter.pro/pages/romupdate.php";
public static final String PROPERTY_OTA_ID = "otaupdater.otaid";
public static final String PROPERTY_OTA_VER = "otaupdater.otaver";
public static final String PROPERTY_OTA_TIME = "otaupdater.otatime";
private UpdaterListener mListener;
private boolean mScanning = false;
public OUCUpdater(UpdaterListener listener) {
mListener = listener;
}
@Override
public String getRomName() { | return SystemProperties.getProperty(PROPERTY_OTA_ID); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/core/plugins/update/impl/OUCUpdater.java | // Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
//
// public class RomInfo {
//
// public int id;
// public String filename;
// public String path;
// public String folder;
// public String md5;
// public String type;
// public String description;
// public int is_flashable;
// public long modified;
// public int downloads;
// public int status;
// public String additional_info;
// public String short_url;
// public int developer_id;
// public String developerid;
// public String board;
// public String rom;
// public long version;
// public int gapps_package;
// public int incremental_file;
// }
//
// public static final String PROPERTY_DEVICE = "ro.product.device";
//
// public static interface UpdaterListener {
//
// public void versionFound(RomInfo info);
// public void versionError(String error);
// }
//
// public String getRomName();
//
// public int getRomVersion();
//
// public void searchVersion();
//
// public boolean isScanning();
// }
//
// Path: src/com/beerbong/zipinst/http/HttpStringReader.java
// public class HttpStringReader extends AsyncTask<String, Void, Void> {
//
// public static interface HttpStringReaderListener {
//
// public void onReadEnd(String buffer);
// public void onReadError(Exception ex);
// };
//
// private HttpStringReaderListener mListener;
// private String mResponse;
// private Exception mException;
//
// public HttpStringReader(HttpStringReaderListener listener) {
// mListener = listener;
// }
//
// @Override
// protected Void doInBackground(String... urls) {
// try {
// HttpClient client = new DefaultHttpClient();
// HttpGet get = new HttpGet(urls[0]);
// HttpResponse r = client.execute(get);
// int status = r.getStatusLine().getStatusCode();
// HttpEntity e = r.getEntity();
// if (status == 200) {
// mResponse = EntityUtils.toString(e);
// } else {
// if (e != null) e.consumeContent();
// String error = "Server responded with error " + status;
// mException = new Exception(error);
// }
// } catch (Exception ex) {
// ex.printStackTrace();
// mException = ex;
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (mListener != null) {
// if (mException != null) {
// mListener.onReadError(mException);
// } else {
// mListener.onReadEnd(mResponse);
// }
// }
// }
// }
//
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
//
// private static final int ALARM_ID = 122303221;
//
// public static String getProperty(String prop) {
// try {
// Process p = Runtime.getRuntime().exec("getprop " + prop);
// p.waitFor();
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line = input.readLine();
// return "".equals(line) ? null : line;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
//
// public static void setAlarm(Context context, long time, boolean trigger) {
//
// Intent i = new Intent(context, NotificationAlarm.class);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// PendingIntent pi = PendingIntent
// .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
//
// AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// am.cancel(pi);
// if (time > 0) {
// am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
// }
// }
//
// public static boolean alarmExists(Context context) {
// return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
// NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
// }
// }
| import java.util.ArrayList;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.HttpStringReader;
import com.beerbong.zipinst.io.SystemProperties; |
String date = json.getString("date");
date = date.replace("-", "");
RomInfo info = new RomInfo();
info.md5 = json.getString("md5");
info.version = Long.parseLong(date);
info.path = json.getString("url");
info.filename = json.getString("rom") + "-" + json.getString("date") + ".zip";
if (getRomVersion() < info.version) {
mListener.versionFound(info);
}
} catch (Exception ex) {
ex.printStackTrace();
mListener.versionError(null);
}
}
@Override
public void onReadError(Exception ex) {
mListener.versionError(null);
}
@Override
public void searchVersion() {
mScanning = true;
ArrayList<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("device", android.os.Build.DEVICE.toLowerCase()));
params.add(new BasicNameValuePair("rom", getRomName())); | // Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
//
// public class RomInfo {
//
// public int id;
// public String filename;
// public String path;
// public String folder;
// public String md5;
// public String type;
// public String description;
// public int is_flashable;
// public long modified;
// public int downloads;
// public int status;
// public String additional_info;
// public String short_url;
// public int developer_id;
// public String developerid;
// public String board;
// public String rom;
// public long version;
// public int gapps_package;
// public int incremental_file;
// }
//
// public static final String PROPERTY_DEVICE = "ro.product.device";
//
// public static interface UpdaterListener {
//
// public void versionFound(RomInfo info);
// public void versionError(String error);
// }
//
// public String getRomName();
//
// public int getRomVersion();
//
// public void searchVersion();
//
// public boolean isScanning();
// }
//
// Path: src/com/beerbong/zipinst/http/HttpStringReader.java
// public class HttpStringReader extends AsyncTask<String, Void, Void> {
//
// public static interface HttpStringReaderListener {
//
// public void onReadEnd(String buffer);
// public void onReadError(Exception ex);
// };
//
// private HttpStringReaderListener mListener;
// private String mResponse;
// private Exception mException;
//
// public HttpStringReader(HttpStringReaderListener listener) {
// mListener = listener;
// }
//
// @Override
// protected Void doInBackground(String... urls) {
// try {
// HttpClient client = new DefaultHttpClient();
// HttpGet get = new HttpGet(urls[0]);
// HttpResponse r = client.execute(get);
// int status = r.getStatusLine().getStatusCode();
// HttpEntity e = r.getEntity();
// if (status == 200) {
// mResponse = EntityUtils.toString(e);
// } else {
// if (e != null) e.consumeContent();
// String error = "Server responded with error " + status;
// mException = new Exception(error);
// }
// } catch (Exception ex) {
// ex.printStackTrace();
// mException = ex;
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (mListener != null) {
// if (mException != null) {
// mListener.onReadError(mException);
// } else {
// mListener.onReadEnd(mResponse);
// }
// }
// }
// }
//
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
//
// private static final int ALARM_ID = 122303221;
//
// public static String getProperty(String prop) {
// try {
// Process p = Runtime.getRuntime().exec("getprop " + prop);
// p.waitFor();
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line = input.readLine();
// return "".equals(line) ? null : line;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
//
// public static void setAlarm(Context context, long time, boolean trigger) {
//
// Intent i = new Intent(context, NotificationAlarm.class);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// PendingIntent pi = PendingIntent
// .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
//
// AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// am.cancel(pi);
// if (time > 0) {
// am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
// }
// }
//
// public static boolean alarmExists(Context context) {
// return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
// NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
// }
// }
// Path: src/com/beerbong/zipinst/core/plugins/update/impl/OUCUpdater.java
import java.util.ArrayList;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.HttpStringReader;
import com.beerbong.zipinst.io.SystemProperties;
String date = json.getString("date");
date = date.replace("-", "");
RomInfo info = new RomInfo();
info.md5 = json.getString("md5");
info.version = Long.parseLong(date);
info.path = json.getString("url");
info.filename = json.getString("rom") + "-" + json.getString("date") + ".zip";
if (getRomVersion() < info.version) {
mListener.versionFound(info);
}
} catch (Exception ex) {
ex.printStackTrace();
mListener.versionError(null);
}
}
@Override
public void onReadError(Exception ex) {
mListener.versionError(null);
}
@Override
public void searchVersion() {
mScanning = true;
ArrayList<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("device", android.os.Build.DEVICE.toLowerCase()));
params.add(new BasicNameValuePair("rom", getRomName())); | new HttpStringReader(this).execute(URL + "?" + URLEncodedUtils.format(params, "UTF-8")); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UICheckBoxPreference.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.content.Context;
import android.preference.CheckBoxPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UICheckBoxPreference extends CheckBoxPreference {
public UICheckBoxPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public UICheckBoxPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UICheckBoxPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UICheckBoxPreference.java
import android.content.Context;
import android.preference.CheckBoxPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UICheckBoxPreference extends CheckBoxPreference {
public UICheckBoxPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public UICheckBoxPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UICheckBoxPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UICheckBoxPreference.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.content.Context;
import android.preference.CheckBoxPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UICheckBoxPreference extends CheckBoxPreference {
public UICheckBoxPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public UICheckBoxPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UICheckBoxPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UICheckBoxPreference.java
import android.content.Context;
import android.preference.CheckBoxPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UICheckBoxPreference extends CheckBoxPreference {
public UICheckBoxPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public UICheckBoxPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UICheckBoxPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UICheckBoxPreference.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.content.Context;
import android.preference.CheckBoxPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UICheckBoxPreference extends CheckBoxPreference {
public UICheckBoxPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public UICheckBoxPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UICheckBoxPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UICheckBoxPreference.java
import android.content.Context;
import android.preference.CheckBoxPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UICheckBoxPreference extends CheckBoxPreference {
public UICheckBoxPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public UICheckBoxPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UICheckBoxPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIPreference.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIPreference extends Preference {
public UIPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public UIPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIPreference.java
import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIPreference extends Preference {
public UIPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public UIPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIPreference.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIPreference extends Preference {
public UIPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public UIPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIPreference.java
import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIPreference extends Preference {
public UIPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public UIPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIPreference.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIPreference extends Preference {
public UIPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public UIPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIPreference.java
import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIPreference extends Preference {
public UIPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public UIPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/UIActivity.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import java.io.Serializable;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIActivity extends Activity implements UIInterface, Serializable {
private Core mCore;
@Override
protected void onCreate(Bundle savedInstanceState) {
| // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/UIActivity.java
import java.io.Serializable;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIActivity extends Activity implements UIInterface, Serializable {
private Core mCore;
@Override
protected void onCreate(Bundle savedInstanceState) {
| CoreFactory.init(this); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/UIActivity.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import java.io.Serializable;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIActivity extends Activity implements UIInterface, Serializable {
private Core mCore;
@Override
protected void onCreate(Bundle savedInstanceState) {
CoreFactory.init(this);
mCore = CoreFactory.getCore();
| // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/UIActivity.java
import java.io.Serializable;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIActivity extends Activity implements UIInterface, Serializable {
private Core mCore;
@Override
protected void onCreate(Bundle savedInstanceState) {
CoreFactory.init(this);
mCore = CoreFactory.getCore();
| ((UIPlugin) mCore.getPlugin(Core.PLUGIN_UI)).registerUI(this); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/core/CoreFactory.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
| import com.beerbong.zipinst.core.Core.CoreListener;
import android.content.Context; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.core;
public class CoreFactory {
private static Core sInstance;
public static synchronized void init(Context context) {
init(context, null);
}
| // Path: src/com/beerbong/zipinst/core/Core.java
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
import com.beerbong.zipinst.core.Core.CoreListener;
import android.content.Context;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.core;
public class CoreFactory {
private static Core sInstance;
public static synchronized void init(Context context) {
init(context, null);
}
| public static synchronized void init(Context context, CoreListener listener) { |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIListPreference.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.content.Context;
import android.preference.ListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIListPreference extends ListPreference {
public UIListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIListPreference.java
import android.content.Context;
import android.preference.ListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIListPreference extends ListPreference {
public UIListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIListPreference.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.content.Context;
import android.preference.ListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIListPreference extends ListPreference {
public UIListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIListPreference.java
import android.content.Context;
import android.preference.ListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIListPreference extends ListPreference {
public UIListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIListPreference.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.content.Context;
import android.preference.ListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIListPreference extends ListPreference {
public UIListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIListPreference.java
import android.content.Context;
import android.preference.ListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIListPreference extends ListPreference {
public UIListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
nikhaldi/android-view-selector | src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/ViewSelectionAssertTest.java | // Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/testutil/Robolectric2ViewFactory.java
// public class Robolectric2ViewFactory extends ProvidedContextViewFactory {
//
// public Robolectric2ViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectionAssertTest.java
// public abstract class AbstractViewSelectionAssertTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).attribute("text").containsOnly("foo");
// assertThatSelection("TextView", view).attribute("tag").containsOnly("bar");
// }
//
// @Test
// public void testAttributeMultiple() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// TextView view2 = viewFactory.createTextView();
// view2.setText("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// assertThatSelection("TextView", root)
// .hasSize(2)
// .attribute("text").containsExactly("foo", "bar");
// }
//
// @Test
// public void testFailingAttributeOnEmptySelection() {
// try {
// assertThatSelection("ImageView", viewFactory.createTextView()).attribute("tag");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasAttributeEqualTo() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).hasAttributeEqualTo("text", "foo");
// assertThatSelection("TextView", view).hasAttributeEqualTo("tag", "bar");
// }
//
// @Test
// public void testFailingHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("text", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testFailingHasAttributeEqualToOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("ImageView", view).hasAttributeEqualTo("tag", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testNonExistentHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("foo", "bar");
// failHard();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTag() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertThatSelection("TextView", view).hasTag("foo");
// }
//
// @Test
// public void testHasTagFailureOnMismatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnNoTag() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("ImageView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnPartialSelectionMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// TextView view2 = viewFactory.createTextView();
// view.setTag("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// try {
// assertThatSelection("TextView", view).hasTag("foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric2.testutil.Robolectric2ViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectionAssertTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import org.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric2;
@RunWith(RobolectricTestRunner.class)
public class ViewSelectionAssertTest extends AbstractViewSelectionAssertTest {
| // Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/testutil/Robolectric2ViewFactory.java
// public class Robolectric2ViewFactory extends ProvidedContextViewFactory {
//
// public Robolectric2ViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectionAssertTest.java
// public abstract class AbstractViewSelectionAssertTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).attribute("text").containsOnly("foo");
// assertThatSelection("TextView", view).attribute("tag").containsOnly("bar");
// }
//
// @Test
// public void testAttributeMultiple() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// TextView view2 = viewFactory.createTextView();
// view2.setText("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// assertThatSelection("TextView", root)
// .hasSize(2)
// .attribute("text").containsExactly("foo", "bar");
// }
//
// @Test
// public void testFailingAttributeOnEmptySelection() {
// try {
// assertThatSelection("ImageView", viewFactory.createTextView()).attribute("tag");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasAttributeEqualTo() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).hasAttributeEqualTo("text", "foo");
// assertThatSelection("TextView", view).hasAttributeEqualTo("tag", "bar");
// }
//
// @Test
// public void testFailingHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("text", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testFailingHasAttributeEqualToOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("ImageView", view).hasAttributeEqualTo("tag", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testNonExistentHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("foo", "bar");
// failHard();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTag() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertThatSelection("TextView", view).hasTag("foo");
// }
//
// @Test
// public void testHasTagFailureOnMismatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnNoTag() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("ImageView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnPartialSelectionMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// TextView view2 = viewFactory.createTextView();
// view.setTag("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// try {
// assertThatSelection("TextView", view).hasTag("foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/ViewSelectionAssertTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric2.testutil.Robolectric2ViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectionAssertTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import org.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric2;
@RunWith(RobolectricTestRunner.class)
public class ViewSelectionAssertTest extends AbstractViewSelectionAssertTest {
| protected ViewFactory createViewFactory() { |
nikhaldi/android-view-selector | src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/ViewSelectionAssertTest.java | // Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/testutil/Robolectric2ViewFactory.java
// public class Robolectric2ViewFactory extends ProvidedContextViewFactory {
//
// public Robolectric2ViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectionAssertTest.java
// public abstract class AbstractViewSelectionAssertTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).attribute("text").containsOnly("foo");
// assertThatSelection("TextView", view).attribute("tag").containsOnly("bar");
// }
//
// @Test
// public void testAttributeMultiple() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// TextView view2 = viewFactory.createTextView();
// view2.setText("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// assertThatSelection("TextView", root)
// .hasSize(2)
// .attribute("text").containsExactly("foo", "bar");
// }
//
// @Test
// public void testFailingAttributeOnEmptySelection() {
// try {
// assertThatSelection("ImageView", viewFactory.createTextView()).attribute("tag");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasAttributeEqualTo() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).hasAttributeEqualTo("text", "foo");
// assertThatSelection("TextView", view).hasAttributeEqualTo("tag", "bar");
// }
//
// @Test
// public void testFailingHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("text", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testFailingHasAttributeEqualToOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("ImageView", view).hasAttributeEqualTo("tag", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testNonExistentHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("foo", "bar");
// failHard();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTag() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertThatSelection("TextView", view).hasTag("foo");
// }
//
// @Test
// public void testHasTagFailureOnMismatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnNoTag() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("ImageView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnPartialSelectionMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// TextView view2 = viewFactory.createTextView();
// view.setTag("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// try {
// assertThatSelection("TextView", view).hasTag("foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric2.testutil.Robolectric2ViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectionAssertTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import org.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric2;
@RunWith(RobolectricTestRunner.class)
public class ViewSelectionAssertTest extends AbstractViewSelectionAssertTest {
protected ViewFactory createViewFactory() { | // Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/testutil/Robolectric2ViewFactory.java
// public class Robolectric2ViewFactory extends ProvidedContextViewFactory {
//
// public Robolectric2ViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectionAssertTest.java
// public abstract class AbstractViewSelectionAssertTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).attribute("text").containsOnly("foo");
// assertThatSelection("TextView", view).attribute("tag").containsOnly("bar");
// }
//
// @Test
// public void testAttributeMultiple() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// TextView view2 = viewFactory.createTextView();
// view2.setText("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// assertThatSelection("TextView", root)
// .hasSize(2)
// .attribute("text").containsExactly("foo", "bar");
// }
//
// @Test
// public void testFailingAttributeOnEmptySelection() {
// try {
// assertThatSelection("ImageView", viewFactory.createTextView()).attribute("tag");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasAttributeEqualTo() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).hasAttributeEqualTo("text", "foo");
// assertThatSelection("TextView", view).hasAttributeEqualTo("tag", "bar");
// }
//
// @Test
// public void testFailingHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("text", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testFailingHasAttributeEqualToOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("ImageView", view).hasAttributeEqualTo("tag", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testNonExistentHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("foo", "bar");
// failHard();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTag() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertThatSelection("TextView", view).hasTag("foo");
// }
//
// @Test
// public void testHasTagFailureOnMismatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnNoTag() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("ImageView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnPartialSelectionMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// TextView view2 = viewFactory.createTextView();
// view.setTag("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// try {
// assertThatSelection("TextView", view).hasTag("foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/ViewSelectionAssertTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric2.testutil.Robolectric2ViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectionAssertTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import org.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric2;
@RunWith(RobolectricTestRunner.class)
public class ViewSelectionAssertTest extends AbstractViewSelectionAssertTest {
protected ViewFactory createViewFactory() { | return new Robolectric2ViewFactory(); |
nikhaldi/android-view-selector | src/android-test/src/com/nikhaldimann/viewselector/android/checker/AttributeSpecifierCheckerTest.java | // Path: src/android-test/src/com/nikhaldimann/viewselector/android/testutil/AndroidTestViewFactory.java
// public class AndroidTestViewFactory extends ProvidedContextViewFactory {
//
// public AndroidTestViewFactory(Context context) {
// super(context);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractAttributeSpecifierCheckerTest.java
// public abstract class AbstractAttributeSpecifierCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> checkExistence(String name, View view) {
// return check(new AttributeSpecifier(name), view);
// }
//
// private Iterable<View> check(String name, String value, Match match, View view) {
// return check(new AttributeSpecifier(name, value, match), view);
// }
//
// private Iterable<View> check(AttributeSpecifier specifier, View view) {
// AttributeSpecifierChecker checker = new AttributeSpecifierChecker(specifier, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testAttributeExistence() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(checkExistence("tag", view));
// assertContentsInOrder(checkExistence("text", view), view);
// assertContentsInOrder(checkExistence("width", view), view);
// assertContentsInOrder(checkExistence("foo", view));
// }
//
// @Test
// public void testExactMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertContentsInOrder(check("tag", "foo", Match.EXACT, view), view);
// assertContentsInOrder(check("tag", "bar", Match.EXACT, view));
// assertContentsInOrder(check("gobbledygook", "bar", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithNumbers() {
// TextView view = viewFactory.createTextView();
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// assertContentsInOrder(
// check("inputType", String.valueOf(InputType.TYPE_CLASS_TEXT), Match.EXACT, view),
// view);
// assertContentsInOrder(check("inputType", "42", Match.EXACT, view));
// assertContentsInOrder(check("inputType", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithBooleans() {
// TextView view = viewFactory.createTextView();
// view.setVisibility(View.INVISIBLE);
// assertContentsInOrder(check("isShown", "false", Match.EXACT, view), view);
// assertContentsInOrder(check("isShown", "true", Match.EXACT, view));
// assertContentsInOrder(check("isShown", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testContainsMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "oba", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "baar", Match.CONTAINS, view));
// assertContentsInOrder(check("isShown", "foo", Match.CONTAINS, view));
// }
//
// @Test
// public void testPrefixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "foob", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foe", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foobare", Match.PREFIX, view));
// assertContentsInOrder(check("isShown", "foo", Match.PREFIX, view));
// }
//
// @Test
// public void testSuffixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "r", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "a foobar", Match.SUFFIX, view));
// assertContentsInOrder(check("tag", "foo", Match.SUFFIX, view));
// assertContentsInOrder(check("isShown", "false", Match.SUFFIX, view));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import com.nikhaldimann.viewselector.android.testutil.AndroidTestViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractAttributeSpecifierCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory; | package com.nikhaldimann.viewselector.android.checker;
public class AttributeSpecifierCheckerTest extends AbstractAttributeSpecifierCheckerTest {
protected ViewFactory createViewFactory() { | // Path: src/android-test/src/com/nikhaldimann/viewselector/android/testutil/AndroidTestViewFactory.java
// public class AndroidTestViewFactory extends ProvidedContextViewFactory {
//
// public AndroidTestViewFactory(Context context) {
// super(context);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractAttributeSpecifierCheckerTest.java
// public abstract class AbstractAttributeSpecifierCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> checkExistence(String name, View view) {
// return check(new AttributeSpecifier(name), view);
// }
//
// private Iterable<View> check(String name, String value, Match match, View view) {
// return check(new AttributeSpecifier(name, value, match), view);
// }
//
// private Iterable<View> check(AttributeSpecifier specifier, View view) {
// AttributeSpecifierChecker checker = new AttributeSpecifierChecker(specifier, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testAttributeExistence() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(checkExistence("tag", view));
// assertContentsInOrder(checkExistence("text", view), view);
// assertContentsInOrder(checkExistence("width", view), view);
// assertContentsInOrder(checkExistence("foo", view));
// }
//
// @Test
// public void testExactMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertContentsInOrder(check("tag", "foo", Match.EXACT, view), view);
// assertContentsInOrder(check("tag", "bar", Match.EXACT, view));
// assertContentsInOrder(check("gobbledygook", "bar", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithNumbers() {
// TextView view = viewFactory.createTextView();
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// assertContentsInOrder(
// check("inputType", String.valueOf(InputType.TYPE_CLASS_TEXT), Match.EXACT, view),
// view);
// assertContentsInOrder(check("inputType", "42", Match.EXACT, view));
// assertContentsInOrder(check("inputType", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithBooleans() {
// TextView view = viewFactory.createTextView();
// view.setVisibility(View.INVISIBLE);
// assertContentsInOrder(check("isShown", "false", Match.EXACT, view), view);
// assertContentsInOrder(check("isShown", "true", Match.EXACT, view));
// assertContentsInOrder(check("isShown", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testContainsMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "oba", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "baar", Match.CONTAINS, view));
// assertContentsInOrder(check("isShown", "foo", Match.CONTAINS, view));
// }
//
// @Test
// public void testPrefixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "foob", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foe", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foobare", Match.PREFIX, view));
// assertContentsInOrder(check("isShown", "foo", Match.PREFIX, view));
// }
//
// @Test
// public void testSuffixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "r", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "a foobar", Match.SUFFIX, view));
// assertContentsInOrder(check("tag", "foo", Match.SUFFIX, view));
// assertContentsInOrder(check("isShown", "false", Match.SUFFIX, view));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/android-test/src/com/nikhaldimann/viewselector/android/checker/AttributeSpecifierCheckerTest.java
import com.nikhaldimann.viewselector.android.testutil.AndroidTestViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractAttributeSpecifierCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
package com.nikhaldimann.viewselector.android.checker;
public class AttributeSpecifierCheckerTest extends AbstractAttributeSpecifierCheckerTest {
protected ViewFactory createViewFactory() { | return new AndroidTestViewFactory(getContext()); |
nikhaldi/android-view-selector | src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/checker/ClassCheckerTest.java | // Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/testutil/Robolectric2ViewFactory.java
// public class Robolectric2ViewFactory extends ProvidedContextViewFactory {
//
// public Robolectric2ViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractClassCheckerTest.java
// public abstract class AbstractClassCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> check(String selectorTag, Combinator combinator, View view) {
// Selector selector = new Selector(selectorTag, combinator);
// ClassChecker checker = new ClassChecker(selector, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testSingleView() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, view));
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, view), view);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, view), view);
// }
//
// @Test
// public void testViewGroupWithDescendants() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, layout), layout, view1, view2, layout2, view3);
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.DESCENDANT, layout), layout);
// assertContentsInOrder(check("FrameLayout", Combinator.DESCENDANT, layout), layout2);
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, layout), view1, view2, view3);
// }
//
// @Test
// public void testViewGroupWithChildren() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("FooView", Combinator.CHILD, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.CHILD, layout));
// assertContentsInOrder(check("TextView", Combinator.CHILD, layout), view1, view2);
// assertContentsInOrder(check("FrameLayout", Combinator.CHILD, layout2));
// }
//
// @Test
// public void testAdjacentSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view1), view2);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view3));
// }
//
// @Test
// public void testGeneralSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view1), view2, view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view3));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric2.testutil.Robolectric2ViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractClassCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import org.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric2.checker;
@RunWith(RobolectricTestRunner.class)
public class ClassCheckerTest extends AbstractClassCheckerTest {
| // Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/testutil/Robolectric2ViewFactory.java
// public class Robolectric2ViewFactory extends ProvidedContextViewFactory {
//
// public Robolectric2ViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractClassCheckerTest.java
// public abstract class AbstractClassCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> check(String selectorTag, Combinator combinator, View view) {
// Selector selector = new Selector(selectorTag, combinator);
// ClassChecker checker = new ClassChecker(selector, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testSingleView() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, view));
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, view), view);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, view), view);
// }
//
// @Test
// public void testViewGroupWithDescendants() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, layout), layout, view1, view2, layout2, view3);
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.DESCENDANT, layout), layout);
// assertContentsInOrder(check("FrameLayout", Combinator.DESCENDANT, layout), layout2);
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, layout), view1, view2, view3);
// }
//
// @Test
// public void testViewGroupWithChildren() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("FooView", Combinator.CHILD, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.CHILD, layout));
// assertContentsInOrder(check("TextView", Combinator.CHILD, layout), view1, view2);
// assertContentsInOrder(check("FrameLayout", Combinator.CHILD, layout2));
// }
//
// @Test
// public void testAdjacentSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view1), view2);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view3));
// }
//
// @Test
// public void testGeneralSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view1), view2, view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view3));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/checker/ClassCheckerTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric2.testutil.Robolectric2ViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractClassCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import org.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric2.checker;
@RunWith(RobolectricTestRunner.class)
public class ClassCheckerTest extends AbstractClassCheckerTest {
| protected ViewFactory createViewFactory() { |
nikhaldi/android-view-selector | src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/checker/ClassCheckerTest.java | // Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/testutil/Robolectric2ViewFactory.java
// public class Robolectric2ViewFactory extends ProvidedContextViewFactory {
//
// public Robolectric2ViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractClassCheckerTest.java
// public abstract class AbstractClassCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> check(String selectorTag, Combinator combinator, View view) {
// Selector selector = new Selector(selectorTag, combinator);
// ClassChecker checker = new ClassChecker(selector, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testSingleView() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, view));
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, view), view);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, view), view);
// }
//
// @Test
// public void testViewGroupWithDescendants() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, layout), layout, view1, view2, layout2, view3);
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.DESCENDANT, layout), layout);
// assertContentsInOrder(check("FrameLayout", Combinator.DESCENDANT, layout), layout2);
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, layout), view1, view2, view3);
// }
//
// @Test
// public void testViewGroupWithChildren() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("FooView", Combinator.CHILD, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.CHILD, layout));
// assertContentsInOrder(check("TextView", Combinator.CHILD, layout), view1, view2);
// assertContentsInOrder(check("FrameLayout", Combinator.CHILD, layout2));
// }
//
// @Test
// public void testAdjacentSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view1), view2);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view3));
// }
//
// @Test
// public void testGeneralSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view1), view2, view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view3));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric2.testutil.Robolectric2ViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractClassCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import org.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric2.checker;
@RunWith(RobolectricTestRunner.class)
public class ClassCheckerTest extends AbstractClassCheckerTest {
protected ViewFactory createViewFactory() { | // Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/testutil/Robolectric2ViewFactory.java
// public class Robolectric2ViewFactory extends ProvidedContextViewFactory {
//
// public Robolectric2ViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractClassCheckerTest.java
// public abstract class AbstractClassCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> check(String selectorTag, Combinator combinator, View view) {
// Selector selector = new Selector(selectorTag, combinator);
// ClassChecker checker = new ClassChecker(selector, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testSingleView() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, view));
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, view), view);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, view), view);
// }
//
// @Test
// public void testViewGroupWithDescendants() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, layout), layout, view1, view2, layout2, view3);
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.DESCENDANT, layout), layout);
// assertContentsInOrder(check("FrameLayout", Combinator.DESCENDANT, layout), layout2);
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, layout), view1, view2, view3);
// }
//
// @Test
// public void testViewGroupWithChildren() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("FooView", Combinator.CHILD, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.CHILD, layout));
// assertContentsInOrder(check("TextView", Combinator.CHILD, layout), view1, view2);
// assertContentsInOrder(check("FrameLayout", Combinator.CHILD, layout2));
// }
//
// @Test
// public void testAdjacentSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view1), view2);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view3));
// }
//
// @Test
// public void testGeneralSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view1), view2, view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view3));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/checker/ClassCheckerTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric2.testutil.Robolectric2ViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractClassCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import org.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric2.checker;
@RunWith(RobolectricTestRunner.class)
public class ClassCheckerTest extends AbstractClassCheckerTest {
protected ViewFactory createViewFactory() { | return new Robolectric2ViewFactory(); |
nikhaldi/android-view-selector | src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/attributes/ViewAttributesTest.java | // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/attributes/AbstractViewAttributesTest.java
// public abstract class AbstractViewAttributesTest extends ViewSelectorAndroidTestCase {
//
// @Test
// public void testGetGetterMethodName() {
// assertEquals("getText", ViewAttributes.getGetterMethodName("text"));
// assertEquals("getText", ViewAttributes.getGetterMethodName("Text"));
// assertEquals("getFooText", ViewAttributes.getGetterMethodName("fooText"));
// }
//
// @Test
// public void testGetGetterMethodNameBooleanAttribute() {
// assertEquals("isFoo", ViewAttributes.getGetterMethodName("isFoo"));
// assertEquals("hasFoo", ViewAttributes.getGetterMethodName("hasFoo"));
// assertEquals("getIs", ViewAttributes.getGetterMethodName("is"));
// assertEquals("getIsland", ViewAttributes.getGetterMethodName("island"));
// assertEquals("getHas", ViewAttributes.getGetterMethodName("has"));
// assertEquals("getHash", ViewAttributes.getGetterMethodName("hash"));
// }
//
// @Test
// public void testCallGetter() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// view.setVisibility(View.INVISIBLE);
// assertEquals("foo", ViewAttributes.callGetter(view, "getText").toString());
// assertEquals(null, ViewAttributes.callGetter(view, "getTag"));
// assertEquals(InputType.TYPE_CLASS_TEXT, ViewAttributes.callGetter(view, "getInputType"));
// assertEquals(false, ViewAttributes.callGetter(view, "isShown"));
// // TODO need to figure out how to deal with base class methods in Robolectric
// }
//
// @Test
// public void testCallGetterNoSuchMethod() {
// try {
// ViewAttributes.callGetter(viewFactory.createTextView(), "getFoo");
// fail();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.attributes.AbstractViewAttributesTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric.attributes;
@RunWith(RobolectricTestRunner.class)
public class ViewAttributesTest extends AbstractViewAttributesTest {
| // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/attributes/AbstractViewAttributesTest.java
// public abstract class AbstractViewAttributesTest extends ViewSelectorAndroidTestCase {
//
// @Test
// public void testGetGetterMethodName() {
// assertEquals("getText", ViewAttributes.getGetterMethodName("text"));
// assertEquals("getText", ViewAttributes.getGetterMethodName("Text"));
// assertEquals("getFooText", ViewAttributes.getGetterMethodName("fooText"));
// }
//
// @Test
// public void testGetGetterMethodNameBooleanAttribute() {
// assertEquals("isFoo", ViewAttributes.getGetterMethodName("isFoo"));
// assertEquals("hasFoo", ViewAttributes.getGetterMethodName("hasFoo"));
// assertEquals("getIs", ViewAttributes.getGetterMethodName("is"));
// assertEquals("getIsland", ViewAttributes.getGetterMethodName("island"));
// assertEquals("getHas", ViewAttributes.getGetterMethodName("has"));
// assertEquals("getHash", ViewAttributes.getGetterMethodName("hash"));
// }
//
// @Test
// public void testCallGetter() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// view.setVisibility(View.INVISIBLE);
// assertEquals("foo", ViewAttributes.callGetter(view, "getText").toString());
// assertEquals(null, ViewAttributes.callGetter(view, "getTag"));
// assertEquals(InputType.TYPE_CLASS_TEXT, ViewAttributes.callGetter(view, "getInputType"));
// assertEquals(false, ViewAttributes.callGetter(view, "isShown"));
// // TODO need to figure out how to deal with base class methods in Robolectric
// }
//
// @Test
// public void testCallGetterNoSuchMethod() {
// try {
// ViewAttributes.callGetter(viewFactory.createTextView(), "getFoo");
// fail();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/attributes/ViewAttributesTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.attributes.AbstractViewAttributesTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric.attributes;
@RunWith(RobolectricTestRunner.class)
public class ViewAttributesTest extends AbstractViewAttributesTest {
| protected ViewFactory createViewFactory() { |
nikhaldi/android-view-selector | src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/attributes/ViewAttributesTest.java | // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/attributes/AbstractViewAttributesTest.java
// public abstract class AbstractViewAttributesTest extends ViewSelectorAndroidTestCase {
//
// @Test
// public void testGetGetterMethodName() {
// assertEquals("getText", ViewAttributes.getGetterMethodName("text"));
// assertEquals("getText", ViewAttributes.getGetterMethodName("Text"));
// assertEquals("getFooText", ViewAttributes.getGetterMethodName("fooText"));
// }
//
// @Test
// public void testGetGetterMethodNameBooleanAttribute() {
// assertEquals("isFoo", ViewAttributes.getGetterMethodName("isFoo"));
// assertEquals("hasFoo", ViewAttributes.getGetterMethodName("hasFoo"));
// assertEquals("getIs", ViewAttributes.getGetterMethodName("is"));
// assertEquals("getIsland", ViewAttributes.getGetterMethodName("island"));
// assertEquals("getHas", ViewAttributes.getGetterMethodName("has"));
// assertEquals("getHash", ViewAttributes.getGetterMethodName("hash"));
// }
//
// @Test
// public void testCallGetter() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// view.setVisibility(View.INVISIBLE);
// assertEquals("foo", ViewAttributes.callGetter(view, "getText").toString());
// assertEquals(null, ViewAttributes.callGetter(view, "getTag"));
// assertEquals(InputType.TYPE_CLASS_TEXT, ViewAttributes.callGetter(view, "getInputType"));
// assertEquals(false, ViewAttributes.callGetter(view, "isShown"));
// // TODO need to figure out how to deal with base class methods in Robolectric
// }
//
// @Test
// public void testCallGetterNoSuchMethod() {
// try {
// ViewAttributes.callGetter(viewFactory.createTextView(), "getFoo");
// fail();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.attributes.AbstractViewAttributesTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric.attributes;
@RunWith(RobolectricTestRunner.class)
public class ViewAttributesTest extends AbstractViewAttributesTest {
protected ViewFactory createViewFactory() { | // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/attributes/AbstractViewAttributesTest.java
// public abstract class AbstractViewAttributesTest extends ViewSelectorAndroidTestCase {
//
// @Test
// public void testGetGetterMethodName() {
// assertEquals("getText", ViewAttributes.getGetterMethodName("text"));
// assertEquals("getText", ViewAttributes.getGetterMethodName("Text"));
// assertEquals("getFooText", ViewAttributes.getGetterMethodName("fooText"));
// }
//
// @Test
// public void testGetGetterMethodNameBooleanAttribute() {
// assertEquals("isFoo", ViewAttributes.getGetterMethodName("isFoo"));
// assertEquals("hasFoo", ViewAttributes.getGetterMethodName("hasFoo"));
// assertEquals("getIs", ViewAttributes.getGetterMethodName("is"));
// assertEquals("getIsland", ViewAttributes.getGetterMethodName("island"));
// assertEquals("getHas", ViewAttributes.getGetterMethodName("has"));
// assertEquals("getHash", ViewAttributes.getGetterMethodName("hash"));
// }
//
// @Test
// public void testCallGetter() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// view.setVisibility(View.INVISIBLE);
// assertEquals("foo", ViewAttributes.callGetter(view, "getText").toString());
// assertEquals(null, ViewAttributes.callGetter(view, "getTag"));
// assertEquals(InputType.TYPE_CLASS_TEXT, ViewAttributes.callGetter(view, "getInputType"));
// assertEquals(false, ViewAttributes.callGetter(view, "isShown"));
// // TODO need to figure out how to deal with base class methods in Robolectric
// }
//
// @Test
// public void testCallGetterNoSuchMethod() {
// try {
// ViewAttributes.callGetter(viewFactory.createTextView(), "getFoo");
// fail();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/attributes/ViewAttributesTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.attributes.AbstractViewAttributesTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric.attributes;
@RunWith(RobolectricTestRunner.class)
public class ViewAttributesTest extends AbstractViewAttributesTest {
protected ViewFactory createViewFactory() { | return new RobolectricViewFactory(); |
nikhaldi/android-view-selector | src/android-test/src/com/nikhaldimann/viewselector/android/activities/SimpleFragmentTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/HelloWorldExampleActivity.java
// public class HelloWorldExampleActivity extends Activity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_hello_world);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/SimpleFragment.java
// @SuppressLint("NewApi")
// public class SimpleFragment extends Fragment {
//
// @SuppressLint("NewApi")
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
// super.onCreateView(inflater, container, savedState);
// return inflater.inflate(R.layout.fragment_simple, container, false);
// }
//
// }
| import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Intent;
import android.test.ActivityUnitTestCase;
import com.nikhaldimann.viewselector.test.HelloWorldExampleActivity;
import com.nikhaldimann.viewselector.test.SimpleFragment; | package com.nikhaldimann.viewselector.android.activities;
/**
* Example unit test for a simple fragment. Though creating an activity to fully
* start the fragment may not be necessary for most cases.
*
* Keep this example self-contained so it can be referenced from documentation.
*/
public class SimpleFragmentTest extends ActivityUnitTestCase<HelloWorldExampleActivity> {
public SimpleFragmentTest() {
super(HelloWorldExampleActivity.class);
}
private HelloWorldExampleActivity activity;
@Override
protected void setUp() throws Exception {
super.setUp();
startActivity(new Intent(getInstrumentation().getTargetContext(),
HelloWorldExampleActivity.class), null, null);
activity = getActivity();
}
/**
* Adds the fragment to a the activity, thereby fully initializing its view.
*/
private void startFragment(Fragment fragment) {
FragmentManager manager = activity.getFragmentManager();
manager.beginTransaction().add(fragment, null).commit();
manager.executePendingTransactions();
}
public void testSimpleFragment() { | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/HelloWorldExampleActivity.java
// public class HelloWorldExampleActivity extends Activity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_hello_world);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/SimpleFragment.java
// @SuppressLint("NewApi")
// public class SimpleFragment extends Fragment {
//
// @SuppressLint("NewApi")
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
// super.onCreateView(inflater, container, savedState);
// return inflater.inflate(R.layout.fragment_simple, container, false);
// }
//
// }
// Path: src/android-test/src/com/nikhaldimann/viewselector/android/activities/SimpleFragmentTest.java
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Intent;
import android.test.ActivityUnitTestCase;
import com.nikhaldimann.viewselector.test.HelloWorldExampleActivity;
import com.nikhaldimann.viewselector.test.SimpleFragment;
package com.nikhaldimann.viewselector.android.activities;
/**
* Example unit test for a simple fragment. Though creating an activity to fully
* start the fragment may not be necessary for most cases.
*
* Keep this example self-contained so it can be referenced from documentation.
*/
public class SimpleFragmentTest extends ActivityUnitTestCase<HelloWorldExampleActivity> {
public SimpleFragmentTest() {
super(HelloWorldExampleActivity.class);
}
private HelloWorldExampleActivity activity;
@Override
protected void setUp() throws Exception {
super.setUp();
startActivity(new Intent(getInstrumentation().getTargetContext(),
HelloWorldExampleActivity.class), null, null);
activity = getActivity();
}
/**
* Adds the fragment to a the activity, thereby fully initializing its view.
*/
private void startFragment(Fragment fragment) {
FragmentManager manager = activity.getFragmentManager();
manager.beginTransaction().add(fragment, null).commit();
manager.executePendingTransactions();
}
public void testSimpleFragment() { | SimpleFragment fragment = new SimpleFragment(); |
nikhaldi/android-view-selector | src/android-test/src/com/nikhaldimann/viewselector/android/activities/SimpleFragmentTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/HelloWorldExampleActivity.java
// public class HelloWorldExampleActivity extends Activity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_hello_world);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/SimpleFragment.java
// @SuppressLint("NewApi")
// public class SimpleFragment extends Fragment {
//
// @SuppressLint("NewApi")
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
// super.onCreateView(inflater, container, savedState);
// return inflater.inflate(R.layout.fragment_simple, container, false);
// }
//
// }
| import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Intent;
import android.test.ActivityUnitTestCase;
import com.nikhaldimann.viewselector.test.HelloWorldExampleActivity;
import com.nikhaldimann.viewselector.test.SimpleFragment; | package com.nikhaldimann.viewselector.android.activities;
/**
* Example unit test for a simple fragment. Though creating an activity to fully
* start the fragment may not be necessary for most cases.
*
* Keep this example self-contained so it can be referenced from documentation.
*/
public class SimpleFragmentTest extends ActivityUnitTestCase<HelloWorldExampleActivity> {
public SimpleFragmentTest() {
super(HelloWorldExampleActivity.class);
}
private HelloWorldExampleActivity activity;
@Override
protected void setUp() throws Exception {
super.setUp();
startActivity(new Intent(getInstrumentation().getTargetContext(),
HelloWorldExampleActivity.class), null, null);
activity = getActivity();
}
/**
* Adds the fragment to a the activity, thereby fully initializing its view.
*/
private void startFragment(Fragment fragment) {
FragmentManager manager = activity.getFragmentManager();
manager.beginTransaction().add(fragment, null).commit();
manager.executePendingTransactions();
}
public void testSimpleFragment() {
SimpleFragment fragment = new SimpleFragment();
startFragment(fragment); | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/HelloWorldExampleActivity.java
// public class HelloWorldExampleActivity extends Activity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_hello_world);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/SimpleFragment.java
// @SuppressLint("NewApi")
// public class SimpleFragment extends Fragment {
//
// @SuppressLint("NewApi")
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
// super.onCreateView(inflater, container, savedState);
// return inflater.inflate(R.layout.fragment_simple, container, false);
// }
//
// }
// Path: src/android-test/src/com/nikhaldimann/viewselector/android/activities/SimpleFragmentTest.java
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Intent;
import android.test.ActivityUnitTestCase;
import com.nikhaldimann.viewselector.test.HelloWorldExampleActivity;
import com.nikhaldimann.viewselector.test.SimpleFragment;
package com.nikhaldimann.viewselector.android.activities;
/**
* Example unit test for a simple fragment. Though creating an activity to fully
* start the fragment may not be necessary for most cases.
*
* Keep this example self-contained so it can be referenced from documentation.
*/
public class SimpleFragmentTest extends ActivityUnitTestCase<HelloWorldExampleActivity> {
public SimpleFragmentTest() {
super(HelloWorldExampleActivity.class);
}
private HelloWorldExampleActivity activity;
@Override
protected void setUp() throws Exception {
super.setUp();
startActivity(new Intent(getInstrumentation().getTargetContext(),
HelloWorldExampleActivity.class), null, null);
activity = getActivity();
}
/**
* Adds the fragment to a the activity, thereby fully initializing its view.
*/
private void startFragment(Fragment fragment) {
FragmentManager manager = activity.getFragmentManager();
manager.beginTransaction().add(fragment, null).commit();
manager.executePendingTransactions();
}
public void testSimpleFragment() {
SimpleFragment fragment = new SimpleFragment();
startFragment(fragment); | assertThatSelection("TextView#hello_world", fragment.getView()).hasSize(1); |
nikhaldi/android-view-selector | src/main/java/com/nikhaldimann/viewselector/ViewSelectionAssert.java | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/AttributeAccessException.java
// public class AttributeAccessException extends RuntimeException {
//
// public AttributeAccessException(Exception cause) {
// super(cause);
// }
//
// public AttributeAccessException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewSelectionAttribute.java
// public class ViewSelectionAttribute extends ArrayList<Object> {
//
// public ViewSelectionAttribute() {
// super();
// }
//
// public ViewSelectionAttribute(ViewSelection selection, String attributeName) {
// super();
// String getterMethodName = ViewAttributes.getGetterMethodName(attributeName);
// for (View matched : selection) {
// add(ViewAttributes.callGetterNormalizingStrings(matched, getterMethodName));
// }
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
| import org.fest.assertions.api.ANDROID;
import org.fest.assertions.api.AbstractIterableAssert;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewParent;
import android.view.animation.Animation;
import com.nikhaldimann.viewselector.attributes.AttributeAccessException;
import com.nikhaldimann.viewselector.attributes.ViewSelectionAttribute;
import com.nikhaldimann.viewselector.selection.ViewSelection; | package com.nikhaldimann.viewselector;
/**
* Custom assertions for {@link ViewSelection}s. Generally, use entry points in
* {@link ViewSelectorAssertions} to get access to these.
*/
public class ViewSelectionAssert
extends AbstractIterableAssert<ViewSelectionAssert, ViewSelection, View> {
public ViewSelectionAssert(ViewSelection actual) {
super(actual, ViewSelectionAssert.class);
}
/**
* Creates an object for making assertions about an attribute set extracted from
* each view in the selection. This always fails for an empty selection.
* @param attributeName name of the attribute to check (e.g., {@code "text"}. The
* implementation will call a getter on each view based on this attribute name
* (e.g., {@code getText()}.
* @return a new assert over a set of attributes
*/
public ViewSelectionAttributeAssert attribute(String attributeName) {
isNotEmpty(); | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/AttributeAccessException.java
// public class AttributeAccessException extends RuntimeException {
//
// public AttributeAccessException(Exception cause) {
// super(cause);
// }
//
// public AttributeAccessException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewSelectionAttribute.java
// public class ViewSelectionAttribute extends ArrayList<Object> {
//
// public ViewSelectionAttribute() {
// super();
// }
//
// public ViewSelectionAttribute(ViewSelection selection, String attributeName) {
// super();
// String getterMethodName = ViewAttributes.getGetterMethodName(attributeName);
// for (View matched : selection) {
// add(ViewAttributes.callGetterNormalizingStrings(matched, getterMethodName));
// }
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectionAssert.java
import org.fest.assertions.api.ANDROID;
import org.fest.assertions.api.AbstractIterableAssert;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewParent;
import android.view.animation.Animation;
import com.nikhaldimann.viewselector.attributes.AttributeAccessException;
import com.nikhaldimann.viewselector.attributes.ViewSelectionAttribute;
import com.nikhaldimann.viewselector.selection.ViewSelection;
package com.nikhaldimann.viewselector;
/**
* Custom assertions for {@link ViewSelection}s. Generally, use entry points in
* {@link ViewSelectorAssertions} to get access to these.
*/
public class ViewSelectionAssert
extends AbstractIterableAssert<ViewSelectionAssert, ViewSelection, View> {
public ViewSelectionAssert(ViewSelection actual) {
super(actual, ViewSelectionAssert.class);
}
/**
* Creates an object for making assertions about an attribute set extracted from
* each view in the selection. This always fails for an empty selection.
* @param attributeName name of the attribute to check (e.g., {@code "text"}. The
* implementation will call a getter on each view based on this attribute name
* (e.g., {@code getText()}.
* @return a new assert over a set of attributes
*/
public ViewSelectionAttributeAssert attribute(String attributeName) {
isNotEmpty(); | ViewSelectionAttribute attributeValues = new ViewSelectionAttribute(actual, attributeName); |
nikhaldi/android-view-selector | src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/activities/HelloWorldActivityTest.java | // Path: src/robolectric-test/src/com/nikhaldimann/viewselector/robolectric/RobolectricTestHelloWorldActivity.java
// public class RobolectricTestHelloWorldActivity extends Activity {
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_hello_world);
// }
//
// }
| import org.junit.runner.RunWith;
import android.app.Activity;
import com.nikhaldimann.viewselector.robolectric.RobolectricTestHelloWorldActivity;
import com.xtremelabs.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric.activities;
@RunWith(RobolectricTestRunner.class)
public class HelloWorldActivityTest extends AbstractMainActivityTest {
protected Activity createActivity() { | // Path: src/robolectric-test/src/com/nikhaldimann/viewselector/robolectric/RobolectricTestHelloWorldActivity.java
// public class RobolectricTestHelloWorldActivity extends Activity {
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_hello_world);
// }
//
// }
// Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/activities/HelloWorldActivityTest.java
import org.junit.runner.RunWith;
import android.app.Activity;
import com.nikhaldimann.viewselector.robolectric.RobolectricTestHelloWorldActivity;
import com.xtremelabs.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric.activities;
@RunWith(RobolectricTestRunner.class)
public class HelloWorldActivityTest extends AbstractMainActivityTest {
protected Activity createActivity() { | RobolectricTestHelloWorldActivity activity = new RobolectricTestHelloWorldActivity(); |
nikhaldi/android-view-selector | src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/ViewSelectorAssertionsTest.java | // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java
// public abstract class AbstractViewSelectorAssertionsTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAssertThat() {
// TextView view = viewFactory.createTextView();
// assertThat(selection("TextView", view))
// .hasSize(1)
// .startsWith(view)
// .endsWith(view);
// }
//
// @Test
// public void testFailingAssertThat() {
// try {
// assertThat(selection("TextView", viewFactory.createTextView())).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testAssertThatSelection() {
// assertThatSelection("TextView", viewFactory.createTextView()).hasSize(1);
// }
//
// @Test
// public void testFailingAssertThatSelection() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView()).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testExtractAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// assertThat(extractAttribute("text").from(selection("TextView", view)))
// .containsExactly("foo");
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectorAssertionsTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric;
@RunWith(RobolectricTestRunner.class)
public class ViewSelectorAssertionsTest extends AbstractViewSelectorAssertionsTest {
| // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java
// public abstract class AbstractViewSelectorAssertionsTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAssertThat() {
// TextView view = viewFactory.createTextView();
// assertThat(selection("TextView", view))
// .hasSize(1)
// .startsWith(view)
// .endsWith(view);
// }
//
// @Test
// public void testFailingAssertThat() {
// try {
// assertThat(selection("TextView", viewFactory.createTextView())).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testAssertThatSelection() {
// assertThatSelection("TextView", viewFactory.createTextView()).hasSize(1);
// }
//
// @Test
// public void testFailingAssertThatSelection() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView()).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testExtractAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// assertThat(extractAttribute("text").from(selection("TextView", view)))
// .containsExactly("foo");
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/ViewSelectorAssertionsTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectorAssertionsTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric;
@RunWith(RobolectricTestRunner.class)
public class ViewSelectorAssertionsTest extends AbstractViewSelectorAssertionsTest {
| protected ViewFactory createViewFactory() { |
nikhaldi/android-view-selector | src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/ViewSelectorAssertionsTest.java | // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java
// public abstract class AbstractViewSelectorAssertionsTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAssertThat() {
// TextView view = viewFactory.createTextView();
// assertThat(selection("TextView", view))
// .hasSize(1)
// .startsWith(view)
// .endsWith(view);
// }
//
// @Test
// public void testFailingAssertThat() {
// try {
// assertThat(selection("TextView", viewFactory.createTextView())).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testAssertThatSelection() {
// assertThatSelection("TextView", viewFactory.createTextView()).hasSize(1);
// }
//
// @Test
// public void testFailingAssertThatSelection() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView()).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testExtractAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// assertThat(extractAttribute("text").from(selection("TextView", view)))
// .containsExactly("foo");
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectorAssertionsTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric;
@RunWith(RobolectricTestRunner.class)
public class ViewSelectorAssertionsTest extends AbstractViewSelectorAssertionsTest {
protected ViewFactory createViewFactory() { | // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java
// public abstract class AbstractViewSelectorAssertionsTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAssertThat() {
// TextView view = viewFactory.createTextView();
// assertThat(selection("TextView", view))
// .hasSize(1)
// .startsWith(view)
// .endsWith(view);
// }
//
// @Test
// public void testFailingAssertThat() {
// try {
// assertThat(selection("TextView", viewFactory.createTextView())).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testAssertThatSelection() {
// assertThatSelection("TextView", viewFactory.createTextView()).hasSize(1);
// }
//
// @Test
// public void testFailingAssertThatSelection() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView()).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testExtractAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// assertThat(extractAttribute("text").from(selection("TextView", view)))
// .containsExactly("foo");
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/ViewSelectorAssertionsTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectorAssertionsTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric;
@RunWith(RobolectricTestRunner.class)
public class ViewSelectorAssertionsTest extends AbstractViewSelectorAssertionsTest {
protected ViewFactory createViewFactory() { | return new RobolectricViewFactory(); |
nikhaldi/android-view-selector | src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/ViewSelectionAssertTest.java | // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectionAssertTest.java
// public abstract class AbstractViewSelectionAssertTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).attribute("text").containsOnly("foo");
// assertThatSelection("TextView", view).attribute("tag").containsOnly("bar");
// }
//
// @Test
// public void testAttributeMultiple() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// TextView view2 = viewFactory.createTextView();
// view2.setText("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// assertThatSelection("TextView", root)
// .hasSize(2)
// .attribute("text").containsExactly("foo", "bar");
// }
//
// @Test
// public void testFailingAttributeOnEmptySelection() {
// try {
// assertThatSelection("ImageView", viewFactory.createTextView()).attribute("tag");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasAttributeEqualTo() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).hasAttributeEqualTo("text", "foo");
// assertThatSelection("TextView", view).hasAttributeEqualTo("tag", "bar");
// }
//
// @Test
// public void testFailingHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("text", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testFailingHasAttributeEqualToOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("ImageView", view).hasAttributeEqualTo("tag", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testNonExistentHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("foo", "bar");
// failHard();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTag() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertThatSelection("TextView", view).hasTag("foo");
// }
//
// @Test
// public void testHasTagFailureOnMismatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnNoTag() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("ImageView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnPartialSelectionMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// TextView view2 = viewFactory.createTextView();
// view.setTag("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// try {
// assertThatSelection("TextView", view).hasTag("foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectionAssertTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric;
@RunWith(RobolectricTestRunner.class)
public class ViewSelectionAssertTest extends AbstractViewSelectionAssertTest {
| // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectionAssertTest.java
// public abstract class AbstractViewSelectionAssertTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).attribute("text").containsOnly("foo");
// assertThatSelection("TextView", view).attribute("tag").containsOnly("bar");
// }
//
// @Test
// public void testAttributeMultiple() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// TextView view2 = viewFactory.createTextView();
// view2.setText("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// assertThatSelection("TextView", root)
// .hasSize(2)
// .attribute("text").containsExactly("foo", "bar");
// }
//
// @Test
// public void testFailingAttributeOnEmptySelection() {
// try {
// assertThatSelection("ImageView", viewFactory.createTextView()).attribute("tag");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasAttributeEqualTo() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).hasAttributeEqualTo("text", "foo");
// assertThatSelection("TextView", view).hasAttributeEqualTo("tag", "bar");
// }
//
// @Test
// public void testFailingHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("text", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testFailingHasAttributeEqualToOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("ImageView", view).hasAttributeEqualTo("tag", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testNonExistentHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("foo", "bar");
// failHard();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTag() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertThatSelection("TextView", view).hasTag("foo");
// }
//
// @Test
// public void testHasTagFailureOnMismatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnNoTag() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("ImageView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnPartialSelectionMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// TextView view2 = viewFactory.createTextView();
// view.setTag("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// try {
// assertThatSelection("TextView", view).hasTag("foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/ViewSelectionAssertTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectionAssertTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric;
@RunWith(RobolectricTestRunner.class)
public class ViewSelectionAssertTest extends AbstractViewSelectionAssertTest {
| protected ViewFactory createViewFactory() { |
nikhaldi/android-view-selector | src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/ViewSelectionAssertTest.java | // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectionAssertTest.java
// public abstract class AbstractViewSelectionAssertTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).attribute("text").containsOnly("foo");
// assertThatSelection("TextView", view).attribute("tag").containsOnly("bar");
// }
//
// @Test
// public void testAttributeMultiple() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// TextView view2 = viewFactory.createTextView();
// view2.setText("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// assertThatSelection("TextView", root)
// .hasSize(2)
// .attribute("text").containsExactly("foo", "bar");
// }
//
// @Test
// public void testFailingAttributeOnEmptySelection() {
// try {
// assertThatSelection("ImageView", viewFactory.createTextView()).attribute("tag");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasAttributeEqualTo() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).hasAttributeEqualTo("text", "foo");
// assertThatSelection("TextView", view).hasAttributeEqualTo("tag", "bar");
// }
//
// @Test
// public void testFailingHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("text", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testFailingHasAttributeEqualToOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("ImageView", view).hasAttributeEqualTo("tag", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testNonExistentHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("foo", "bar");
// failHard();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTag() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertThatSelection("TextView", view).hasTag("foo");
// }
//
// @Test
// public void testHasTagFailureOnMismatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnNoTag() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("ImageView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnPartialSelectionMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// TextView view2 = viewFactory.createTextView();
// view.setTag("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// try {
// assertThatSelection("TextView", view).hasTag("foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectionAssertTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric;
@RunWith(RobolectricTestRunner.class)
public class ViewSelectionAssertTest extends AbstractViewSelectionAssertTest {
protected ViewFactory createViewFactory() { | // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectionAssertTest.java
// public abstract class AbstractViewSelectionAssertTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).attribute("text").containsOnly("foo");
// assertThatSelection("TextView", view).attribute("tag").containsOnly("bar");
// }
//
// @Test
// public void testAttributeMultiple() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// TextView view2 = viewFactory.createTextView();
// view2.setText("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// assertThatSelection("TextView", root)
// .hasSize(2)
// .attribute("text").containsExactly("foo", "bar");
// }
//
// @Test
// public void testFailingAttributeOnEmptySelection() {
// try {
// assertThatSelection("ImageView", viewFactory.createTextView()).attribute("tag");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasAttributeEqualTo() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).hasAttributeEqualTo("text", "foo");
// assertThatSelection("TextView", view).hasAttributeEqualTo("tag", "bar");
// }
//
// @Test
// public void testFailingHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("text", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testFailingHasAttributeEqualToOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("ImageView", view).hasAttributeEqualTo("tag", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testNonExistentHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("foo", "bar");
// failHard();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTag() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertThatSelection("TextView", view).hasTag("foo");
// }
//
// @Test
// public void testHasTagFailureOnMismatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnNoTag() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("ImageView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnPartialSelectionMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// TextView view2 = viewFactory.createTextView();
// view.setTag("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// try {
// assertThatSelection("TextView", view).hasTag("foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/ViewSelectionAssertTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectionAssertTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric;
@RunWith(RobolectricTestRunner.class)
public class ViewSelectionAssertTest extends AbstractViewSelectionAssertTest {
protected ViewFactory createViewFactory() { | return new RobolectricViewFactory(); |
nikhaldi/android-view-selector | src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectionAssertTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/AttributeAccessException.java
// public class AttributeAccessException extends RuntimeException {
//
// public AttributeAccessException(Exception cause) {
// super(cause);
// }
//
// public AttributeAccessException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
| import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import org.junit.Test;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nikhaldimann.viewselector.attributes.AttributeAccessException;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase; | package com.nikhaldimann.viewselector.test.abstrakt;
public abstract class AbstractViewSelectionAssertTest extends ViewSelectorAndroidTestCase {
/**
* Fails with a RuntimeException, so we can distinguish this from planned
* assertion failures.
*/
private void failHard() {
throw new RuntimeException("Failed to cause an assertion failure");
}
@Test
public void testAttribute() {
TextView view = viewFactory.createTextView();
view.setText("foo");
view.setTag("bar"); | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/AttributeAccessException.java
// public class AttributeAccessException extends RuntimeException {
//
// public AttributeAccessException(Exception cause) {
// super(cause);
// }
//
// public AttributeAccessException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectionAssertTest.java
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import org.junit.Test;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nikhaldimann.viewselector.attributes.AttributeAccessException;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase;
package com.nikhaldimann.viewselector.test.abstrakt;
public abstract class AbstractViewSelectionAssertTest extends ViewSelectorAndroidTestCase {
/**
* Fails with a RuntimeException, so we can distinguish this from planned
* assertion failures.
*/
private void failHard() {
throw new RuntimeException("Failed to cause an assertion failure");
}
@Test
public void testAttribute() {
TextView view = viewFactory.createTextView();
view.setText("foo");
view.setTag("bar"); | assertThatSelection("TextView", view).attribute("text").containsOnly("foo"); |
nikhaldi/android-view-selector | src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectionAssertTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/AttributeAccessException.java
// public class AttributeAccessException extends RuntimeException {
//
// public AttributeAccessException(Exception cause) {
// super(cause);
// }
//
// public AttributeAccessException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
| import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import org.junit.Test;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nikhaldimann.viewselector.attributes.AttributeAccessException;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase; |
@Test
public void testFailingHasAttributeEqualTo() {
try {
assertThatSelection("TextView", viewFactory.createTextView())
.hasAttributeEqualTo("text", "foo");
failHard();
} catch (AssertionError ex) {
// expected
}
}
@Test
public void testFailingHasAttributeEqualToOnEmptySelection() {
TextView view = viewFactory.createTextView();
view.setTag("foo");
try {
assertThatSelection("ImageView", view).hasAttributeEqualTo("tag", "foo");
failHard();
} catch (AssertionError ex) {
// expected
}
}
@Test
public void testNonExistentHasAttributeEqualTo() {
try {
assertThatSelection("TextView", viewFactory.createTextView())
.hasAttributeEqualTo("foo", "bar");
failHard(); | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/AttributeAccessException.java
// public class AttributeAccessException extends RuntimeException {
//
// public AttributeAccessException(Exception cause) {
// super(cause);
// }
//
// public AttributeAccessException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectionAssertTest.java
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import org.junit.Test;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nikhaldimann.viewselector.attributes.AttributeAccessException;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase;
@Test
public void testFailingHasAttributeEqualTo() {
try {
assertThatSelection("TextView", viewFactory.createTextView())
.hasAttributeEqualTo("text", "foo");
failHard();
} catch (AssertionError ex) {
// expected
}
}
@Test
public void testFailingHasAttributeEqualToOnEmptySelection() {
TextView view = viewFactory.createTextView();
view.setTag("foo");
try {
assertThatSelection("ImageView", view).hasAttributeEqualTo("tag", "foo");
failHard();
} catch (AssertionError ex) {
// expected
}
}
@Test
public void testNonExistentHasAttributeEqualTo() {
try {
assertThatSelection("TextView", viewFactory.createTextView())
.hasAttributeEqualTo("foo", "bar");
failHard(); | } catch (AttributeAccessException ex) { |
nikhaldi/android-view-selector | src/android-test/src/com/nikhaldimann/viewselector/android/attributes/ViewAttributesTest.java | // Path: src/android-test/src/com/nikhaldimann/viewselector/android/testutil/AndroidTestViewFactory.java
// public class AndroidTestViewFactory extends ProvidedContextViewFactory {
//
// public AndroidTestViewFactory(Context context) {
// super(context);
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewAttributes.java
// public class ViewAttributes {
//
// private ViewAttributes() { }
//
// /**
// * @return the full getter method name for a plain attribute, following conventions
// * used in the Android code. Prepends "get" to the attribute name and formats
// * it in camel-case. Recognizes boolean attributes of the format {@code isFoo} or
// * {@code hasFoo} and returns them unchanged.
// */
// public static String getGetterMethodName(String attributeName) {
// if (isBooleanAttribute(attributeName, "is") || isBooleanAttribute(attributeName, "has")) {
// return attributeName;
// }
// return "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1);
// }
//
// private static boolean isBooleanAttribute(String attributeName, String prefix) {
// return attributeName.startsWith(prefix)
// && attributeName.length() > prefix.length()
// && Character.isUpperCase(attributeName.charAt(prefix.length()));
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetter(View view, String methodName) {
// try {
// Method method = view.getClass().getMethod(methodName);
// return method.invoke(view);
// } catch (SecurityException ex) {
// throw new AttributeAccessException(ex);
// } catch (NoSuchMethodException ex) {
// throw new AttributeAccessException("No such attribute", ex);
// } catch (IllegalAccessException ex) {
// throw new AttributeAccessException(ex);
// } catch (InvocationTargetException ex) {
// throw new AttributeAccessException(ex);
// }
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// *
// * This method normalizes all instances of CharSequences to be instances of String.
// * This is useful because Android is using some CharSequence representations
// * internally that don't compare well with strings (in particular as returned
// * from TextView.getText()).
// *
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetterNormalizingStrings(View view, String methodName) {
// Object value = callGetter(view, methodName);
// if (value instanceof CharSequence) {
// value = value.toString();
// }
// return value;
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/attributes/AbstractViewAttributesTest.java
// public abstract class AbstractViewAttributesTest extends ViewSelectorAndroidTestCase {
//
// @Test
// public void testGetGetterMethodName() {
// assertEquals("getText", ViewAttributes.getGetterMethodName("text"));
// assertEquals("getText", ViewAttributes.getGetterMethodName("Text"));
// assertEquals("getFooText", ViewAttributes.getGetterMethodName("fooText"));
// }
//
// @Test
// public void testGetGetterMethodNameBooleanAttribute() {
// assertEquals("isFoo", ViewAttributes.getGetterMethodName("isFoo"));
// assertEquals("hasFoo", ViewAttributes.getGetterMethodName("hasFoo"));
// assertEquals("getIs", ViewAttributes.getGetterMethodName("is"));
// assertEquals("getIsland", ViewAttributes.getGetterMethodName("island"));
// assertEquals("getHas", ViewAttributes.getGetterMethodName("has"));
// assertEquals("getHash", ViewAttributes.getGetterMethodName("hash"));
// }
//
// @Test
// public void testCallGetter() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// view.setVisibility(View.INVISIBLE);
// assertEquals("foo", ViewAttributes.callGetter(view, "getText").toString());
// assertEquals(null, ViewAttributes.callGetter(view, "getTag"));
// assertEquals(InputType.TYPE_CLASS_TEXT, ViewAttributes.callGetter(view, "getInputType"));
// assertEquals(false, ViewAttributes.callGetter(view, "isShown"));
// // TODO need to figure out how to deal with base class methods in Robolectric
// }
//
// @Test
// public void testCallGetterNoSuchMethod() {
// try {
// ViewAttributes.callGetter(viewFactory.createTextView(), "getFoo");
// fail();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import android.widget.TextView;
import com.nikhaldimann.viewselector.android.testutil.AndroidTestViewFactory;
import com.nikhaldimann.viewselector.attributes.ViewAttributes;
import com.nikhaldimann.viewselector.test.abstrakt.attributes.AbstractViewAttributesTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory; | package com.nikhaldimann.viewselector.android.attributes;
public class ViewAttributesTest extends AbstractViewAttributesTest {
protected ViewFactory createViewFactory() { | // Path: src/android-test/src/com/nikhaldimann/viewselector/android/testutil/AndroidTestViewFactory.java
// public class AndroidTestViewFactory extends ProvidedContextViewFactory {
//
// public AndroidTestViewFactory(Context context) {
// super(context);
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewAttributes.java
// public class ViewAttributes {
//
// private ViewAttributes() { }
//
// /**
// * @return the full getter method name for a plain attribute, following conventions
// * used in the Android code. Prepends "get" to the attribute name and formats
// * it in camel-case. Recognizes boolean attributes of the format {@code isFoo} or
// * {@code hasFoo} and returns them unchanged.
// */
// public static String getGetterMethodName(String attributeName) {
// if (isBooleanAttribute(attributeName, "is") || isBooleanAttribute(attributeName, "has")) {
// return attributeName;
// }
// return "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1);
// }
//
// private static boolean isBooleanAttribute(String attributeName, String prefix) {
// return attributeName.startsWith(prefix)
// && attributeName.length() > prefix.length()
// && Character.isUpperCase(attributeName.charAt(prefix.length()));
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetter(View view, String methodName) {
// try {
// Method method = view.getClass().getMethod(methodName);
// return method.invoke(view);
// } catch (SecurityException ex) {
// throw new AttributeAccessException(ex);
// } catch (NoSuchMethodException ex) {
// throw new AttributeAccessException("No such attribute", ex);
// } catch (IllegalAccessException ex) {
// throw new AttributeAccessException(ex);
// } catch (InvocationTargetException ex) {
// throw new AttributeAccessException(ex);
// }
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// *
// * This method normalizes all instances of CharSequences to be instances of String.
// * This is useful because Android is using some CharSequence representations
// * internally that don't compare well with strings (in particular as returned
// * from TextView.getText()).
// *
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetterNormalizingStrings(View view, String methodName) {
// Object value = callGetter(view, methodName);
// if (value instanceof CharSequence) {
// value = value.toString();
// }
// return value;
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/attributes/AbstractViewAttributesTest.java
// public abstract class AbstractViewAttributesTest extends ViewSelectorAndroidTestCase {
//
// @Test
// public void testGetGetterMethodName() {
// assertEquals("getText", ViewAttributes.getGetterMethodName("text"));
// assertEquals("getText", ViewAttributes.getGetterMethodName("Text"));
// assertEquals("getFooText", ViewAttributes.getGetterMethodName("fooText"));
// }
//
// @Test
// public void testGetGetterMethodNameBooleanAttribute() {
// assertEquals("isFoo", ViewAttributes.getGetterMethodName("isFoo"));
// assertEquals("hasFoo", ViewAttributes.getGetterMethodName("hasFoo"));
// assertEquals("getIs", ViewAttributes.getGetterMethodName("is"));
// assertEquals("getIsland", ViewAttributes.getGetterMethodName("island"));
// assertEquals("getHas", ViewAttributes.getGetterMethodName("has"));
// assertEquals("getHash", ViewAttributes.getGetterMethodName("hash"));
// }
//
// @Test
// public void testCallGetter() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// view.setVisibility(View.INVISIBLE);
// assertEquals("foo", ViewAttributes.callGetter(view, "getText").toString());
// assertEquals(null, ViewAttributes.callGetter(view, "getTag"));
// assertEquals(InputType.TYPE_CLASS_TEXT, ViewAttributes.callGetter(view, "getInputType"));
// assertEquals(false, ViewAttributes.callGetter(view, "isShown"));
// // TODO need to figure out how to deal with base class methods in Robolectric
// }
//
// @Test
// public void testCallGetterNoSuchMethod() {
// try {
// ViewAttributes.callGetter(viewFactory.createTextView(), "getFoo");
// fail();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/android-test/src/com/nikhaldimann/viewselector/android/attributes/ViewAttributesTest.java
import android.widget.TextView;
import com.nikhaldimann.viewselector.android.testutil.AndroidTestViewFactory;
import com.nikhaldimann.viewselector.attributes.ViewAttributes;
import com.nikhaldimann.viewselector.test.abstrakt.attributes.AbstractViewAttributesTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
package com.nikhaldimann.viewselector.android.attributes;
public class ViewAttributesTest extends AbstractViewAttributesTest {
protected ViewFactory createViewFactory() { | return new AndroidTestViewFactory(getContext()); |
nikhaldi/android-view-selector | src/android-test/src/com/nikhaldimann/viewselector/android/attributes/ViewAttributesTest.java | // Path: src/android-test/src/com/nikhaldimann/viewselector/android/testutil/AndroidTestViewFactory.java
// public class AndroidTestViewFactory extends ProvidedContextViewFactory {
//
// public AndroidTestViewFactory(Context context) {
// super(context);
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewAttributes.java
// public class ViewAttributes {
//
// private ViewAttributes() { }
//
// /**
// * @return the full getter method name for a plain attribute, following conventions
// * used in the Android code. Prepends "get" to the attribute name and formats
// * it in camel-case. Recognizes boolean attributes of the format {@code isFoo} or
// * {@code hasFoo} and returns them unchanged.
// */
// public static String getGetterMethodName(String attributeName) {
// if (isBooleanAttribute(attributeName, "is") || isBooleanAttribute(attributeName, "has")) {
// return attributeName;
// }
// return "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1);
// }
//
// private static boolean isBooleanAttribute(String attributeName, String prefix) {
// return attributeName.startsWith(prefix)
// && attributeName.length() > prefix.length()
// && Character.isUpperCase(attributeName.charAt(prefix.length()));
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetter(View view, String methodName) {
// try {
// Method method = view.getClass().getMethod(methodName);
// return method.invoke(view);
// } catch (SecurityException ex) {
// throw new AttributeAccessException(ex);
// } catch (NoSuchMethodException ex) {
// throw new AttributeAccessException("No such attribute", ex);
// } catch (IllegalAccessException ex) {
// throw new AttributeAccessException(ex);
// } catch (InvocationTargetException ex) {
// throw new AttributeAccessException(ex);
// }
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// *
// * This method normalizes all instances of CharSequences to be instances of String.
// * This is useful because Android is using some CharSequence representations
// * internally that don't compare well with strings (in particular as returned
// * from TextView.getText()).
// *
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetterNormalizingStrings(View view, String methodName) {
// Object value = callGetter(view, methodName);
// if (value instanceof CharSequence) {
// value = value.toString();
// }
// return value;
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/attributes/AbstractViewAttributesTest.java
// public abstract class AbstractViewAttributesTest extends ViewSelectorAndroidTestCase {
//
// @Test
// public void testGetGetterMethodName() {
// assertEquals("getText", ViewAttributes.getGetterMethodName("text"));
// assertEquals("getText", ViewAttributes.getGetterMethodName("Text"));
// assertEquals("getFooText", ViewAttributes.getGetterMethodName("fooText"));
// }
//
// @Test
// public void testGetGetterMethodNameBooleanAttribute() {
// assertEquals("isFoo", ViewAttributes.getGetterMethodName("isFoo"));
// assertEquals("hasFoo", ViewAttributes.getGetterMethodName("hasFoo"));
// assertEquals("getIs", ViewAttributes.getGetterMethodName("is"));
// assertEquals("getIsland", ViewAttributes.getGetterMethodName("island"));
// assertEquals("getHas", ViewAttributes.getGetterMethodName("has"));
// assertEquals("getHash", ViewAttributes.getGetterMethodName("hash"));
// }
//
// @Test
// public void testCallGetter() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// view.setVisibility(View.INVISIBLE);
// assertEquals("foo", ViewAttributes.callGetter(view, "getText").toString());
// assertEquals(null, ViewAttributes.callGetter(view, "getTag"));
// assertEquals(InputType.TYPE_CLASS_TEXT, ViewAttributes.callGetter(view, "getInputType"));
// assertEquals(false, ViewAttributes.callGetter(view, "isShown"));
// // TODO need to figure out how to deal with base class methods in Robolectric
// }
//
// @Test
// public void testCallGetterNoSuchMethod() {
// try {
// ViewAttributes.callGetter(viewFactory.createTextView(), "getFoo");
// fail();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import android.widget.TextView;
import com.nikhaldimann.viewselector.android.testutil.AndroidTestViewFactory;
import com.nikhaldimann.viewselector.attributes.ViewAttributes;
import com.nikhaldimann.viewselector.test.abstrakt.attributes.AbstractViewAttributesTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory; | package com.nikhaldimann.viewselector.android.attributes;
public class ViewAttributesTest extends AbstractViewAttributesTest {
protected ViewFactory createViewFactory() {
return new AndroidTestViewFactory(getContext());
}
public void testCallGettersOnBaseClass() {
TextView view = viewFactory.createTextView();
view.setMinimumHeight(200);
view.setPivotX(1.25f); | // Path: src/android-test/src/com/nikhaldimann/viewselector/android/testutil/AndroidTestViewFactory.java
// public class AndroidTestViewFactory extends ProvidedContextViewFactory {
//
// public AndroidTestViewFactory(Context context) {
// super(context);
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewAttributes.java
// public class ViewAttributes {
//
// private ViewAttributes() { }
//
// /**
// * @return the full getter method name for a plain attribute, following conventions
// * used in the Android code. Prepends "get" to the attribute name and formats
// * it in camel-case. Recognizes boolean attributes of the format {@code isFoo} or
// * {@code hasFoo} and returns them unchanged.
// */
// public static String getGetterMethodName(String attributeName) {
// if (isBooleanAttribute(attributeName, "is") || isBooleanAttribute(attributeName, "has")) {
// return attributeName;
// }
// return "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1);
// }
//
// private static boolean isBooleanAttribute(String attributeName, String prefix) {
// return attributeName.startsWith(prefix)
// && attributeName.length() > prefix.length()
// && Character.isUpperCase(attributeName.charAt(prefix.length()));
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetter(View view, String methodName) {
// try {
// Method method = view.getClass().getMethod(methodName);
// return method.invoke(view);
// } catch (SecurityException ex) {
// throw new AttributeAccessException(ex);
// } catch (NoSuchMethodException ex) {
// throw new AttributeAccessException("No such attribute", ex);
// } catch (IllegalAccessException ex) {
// throw new AttributeAccessException(ex);
// } catch (InvocationTargetException ex) {
// throw new AttributeAccessException(ex);
// }
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// *
// * This method normalizes all instances of CharSequences to be instances of String.
// * This is useful because Android is using some CharSequence representations
// * internally that don't compare well with strings (in particular as returned
// * from TextView.getText()).
// *
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetterNormalizingStrings(View view, String methodName) {
// Object value = callGetter(view, methodName);
// if (value instanceof CharSequence) {
// value = value.toString();
// }
// return value;
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/attributes/AbstractViewAttributesTest.java
// public abstract class AbstractViewAttributesTest extends ViewSelectorAndroidTestCase {
//
// @Test
// public void testGetGetterMethodName() {
// assertEquals("getText", ViewAttributes.getGetterMethodName("text"));
// assertEquals("getText", ViewAttributes.getGetterMethodName("Text"));
// assertEquals("getFooText", ViewAttributes.getGetterMethodName("fooText"));
// }
//
// @Test
// public void testGetGetterMethodNameBooleanAttribute() {
// assertEquals("isFoo", ViewAttributes.getGetterMethodName("isFoo"));
// assertEquals("hasFoo", ViewAttributes.getGetterMethodName("hasFoo"));
// assertEquals("getIs", ViewAttributes.getGetterMethodName("is"));
// assertEquals("getIsland", ViewAttributes.getGetterMethodName("island"));
// assertEquals("getHas", ViewAttributes.getGetterMethodName("has"));
// assertEquals("getHash", ViewAttributes.getGetterMethodName("hash"));
// }
//
// @Test
// public void testCallGetter() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// view.setVisibility(View.INVISIBLE);
// assertEquals("foo", ViewAttributes.callGetter(view, "getText").toString());
// assertEquals(null, ViewAttributes.callGetter(view, "getTag"));
// assertEquals(InputType.TYPE_CLASS_TEXT, ViewAttributes.callGetter(view, "getInputType"));
// assertEquals(false, ViewAttributes.callGetter(view, "isShown"));
// // TODO need to figure out how to deal with base class methods in Robolectric
// }
//
// @Test
// public void testCallGetterNoSuchMethod() {
// try {
// ViewAttributes.callGetter(viewFactory.createTextView(), "getFoo");
// fail();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/android-test/src/com/nikhaldimann/viewselector/android/attributes/ViewAttributesTest.java
import android.widget.TextView;
import com.nikhaldimann.viewselector.android.testutil.AndroidTestViewFactory;
import com.nikhaldimann.viewselector.attributes.ViewAttributes;
import com.nikhaldimann.viewselector.test.abstrakt.attributes.AbstractViewAttributesTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
package com.nikhaldimann.viewselector.android.attributes;
public class ViewAttributesTest extends AbstractViewAttributesTest {
protected ViewFactory createViewFactory() {
return new AndroidTestViewFactory(getContext());
}
public void testCallGettersOnBaseClass() {
TextView view = viewFactory.createTextView();
view.setMinimumHeight(200);
view.setPivotX(1.25f); | assertEquals(200, ViewAttributes.callGetter(view, "getMinimumHeight")); |
nikhaldi/android-view-selector | src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewSelectionAttribute.java
// public class ViewSelectionAttribute extends ArrayList<Object> {
//
// public ViewSelectionAttribute() {
// super();
// }
//
// public ViewSelectionAttribute(ViewSelection selection, String attributeName) {
// super();
// String getterMethodName = ViewAttributes.getGetterMethodName(attributeName);
// for (View matched : selection) {
// add(ViewAttributes.callGetterNormalizingStrings(matched, getterMethodName));
// }
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
| import org.fest.assertions.api.Assertions;
import android.app.Activity;
import android.view.View;
import com.nikhaldimann.viewselector.attributes.ViewSelectionAttribute;
import com.nikhaldimann.viewselector.selection.ViewSelection; | package com.nikhaldimann.viewselector;
/**
* Static assertion entry points for fluent FEST-style assertions. Example usage:
*
* <pre>
* // Assert that activity has 5 views that are TextViews
* assertThat(selection("TextView", activity)).hasSize(5);
*
* // ... or equivalent:
* assertThatSelection("TextView", activity).hasSize(5);
*
* // Assert that all TextViews in activity have the text "Hello World"
* assertThatSelection("TextView", activity).attribute("text")
* .containsOnly("Hello World");
*
* // ... or equivalent:
* assertThat(extractAttribute("text").from(selection("TextView", activity)))
* .containsOnly("Hello World");
*
* // Assert that the 3 TextViews in activity have the texts "foo", "bar", "baz",
* // in that order
* assertThatSelection("TextView", activity).attribute("text")
* .containsExactly("foo", "bar", "baz");
* </pre>
*/
public class ViewSelectorAssertions extends Assertions {
private ViewSelectorAssertions() { }
/**
* Fluent assertion entry point for {@link ViewSelection}. Often used together
* with {@link #selection(String, Activity)} to create the selection.
*/ | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewSelectionAttribute.java
// public class ViewSelectionAttribute extends ArrayList<Object> {
//
// public ViewSelectionAttribute() {
// super();
// }
//
// public ViewSelectionAttribute(ViewSelection selection, String attributeName) {
// super();
// String getterMethodName = ViewAttributes.getGetterMethodName(attributeName);
// for (View matched : selection) {
// add(ViewAttributes.callGetterNormalizingStrings(matched, getterMethodName));
// }
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
import org.fest.assertions.api.Assertions;
import android.app.Activity;
import android.view.View;
import com.nikhaldimann.viewselector.attributes.ViewSelectionAttribute;
import com.nikhaldimann.viewselector.selection.ViewSelection;
package com.nikhaldimann.viewselector;
/**
* Static assertion entry points for fluent FEST-style assertions. Example usage:
*
* <pre>
* // Assert that activity has 5 views that are TextViews
* assertThat(selection("TextView", activity)).hasSize(5);
*
* // ... or equivalent:
* assertThatSelection("TextView", activity).hasSize(5);
*
* // Assert that all TextViews in activity have the text "Hello World"
* assertThatSelection("TextView", activity).attribute("text")
* .containsOnly("Hello World");
*
* // ... or equivalent:
* assertThat(extractAttribute("text").from(selection("TextView", activity)))
* .containsOnly("Hello World");
*
* // Assert that the 3 TextViews in activity have the texts "foo", "bar", "baz",
* // in that order
* assertThatSelection("TextView", activity).attribute("text")
* .containsExactly("foo", "bar", "baz");
* </pre>
*/
public class ViewSelectorAssertions extends Assertions {
private ViewSelectorAssertions() { }
/**
* Fluent assertion entry point for {@link ViewSelection}. Often used together
* with {@link #selection(String, Activity)} to create the selection.
*/ | public static ViewSelectionAssert assertThat(ViewSelection actual) { |
nikhaldi/android-view-selector | src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewSelectionAttribute.java
// public class ViewSelectionAttribute extends ArrayList<Object> {
//
// public ViewSelectionAttribute() {
// super();
// }
//
// public ViewSelectionAttribute(ViewSelection selection, String attributeName) {
// super();
// String getterMethodName = ViewAttributes.getGetterMethodName(attributeName);
// for (View matched : selection) {
// add(ViewAttributes.callGetterNormalizingStrings(matched, getterMethodName));
// }
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
| import org.fest.assertions.api.Assertions;
import android.app.Activity;
import android.view.View;
import com.nikhaldimann.viewselector.attributes.ViewSelectionAttribute;
import com.nikhaldimann.viewselector.selection.ViewSelection; | package com.nikhaldimann.viewselector;
/**
* Static assertion entry points for fluent FEST-style assertions. Example usage:
*
* <pre>
* // Assert that activity has 5 views that are TextViews
* assertThat(selection("TextView", activity)).hasSize(5);
*
* // ... or equivalent:
* assertThatSelection("TextView", activity).hasSize(5);
*
* // Assert that all TextViews in activity have the text "Hello World"
* assertThatSelection("TextView", activity).attribute("text")
* .containsOnly("Hello World");
*
* // ... or equivalent:
* assertThat(extractAttribute("text").from(selection("TextView", activity)))
* .containsOnly("Hello World");
*
* // Assert that the 3 TextViews in activity have the texts "foo", "bar", "baz",
* // in that order
* assertThatSelection("TextView", activity).attribute("text")
* .containsExactly("foo", "bar", "baz");
* </pre>
*/
public class ViewSelectorAssertions extends Assertions {
private ViewSelectorAssertions() { }
/**
* Fluent assertion entry point for {@link ViewSelection}. Often used together
* with {@link #selection(String, Activity)} to create the selection.
*/
public static ViewSelectionAssert assertThat(ViewSelection actual) {
return new ViewSelectionAssert(actual);
}
/**
* Fluent assertion entry point for a selection of views from the given activity
* based on the given selector. It may be helpful to statically import this rather
* than {@link #assertThat(ViewSelection)} to avoid conflicts with other statically
* imported {@code assertThat()} methods.
*/
public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
return assertThat(selection(selector, activity));
}
/**
* Fluent assertion entry point for a selection of views from the given view
* based on the given selector. It may be helpful to statically import this rather
* than {@link #assertThat(ViewSelection)} to avoid conflicts with other statically
* imported {@code assertThat()} methods.
*/
public static ViewSelectionAssert assertThatSelection(String selector, View view) {
return assertThat(selection(selector, view));
}
/**
* @return the selection of views from the given activity based on the given selector
*/
public static ViewSelection selection(String selector, Activity activity) {
return selection(selector, activity.findViewById(android.R.id.content));
}
/**
* @return the selection of views from the given view based on the given selector
*/
public static ViewSelection selection(String selector, View view) {
return ViewSelector.compile(selector).selectViews(view);
}
/**
* Fluent assertion entry point for {@link ViewSelectionAttribute}. Often used
* together with {@link #extractAttribute(String)} to extract attributes from
* a selection.
*/ | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewSelectionAttribute.java
// public class ViewSelectionAttribute extends ArrayList<Object> {
//
// public ViewSelectionAttribute() {
// super();
// }
//
// public ViewSelectionAttribute(ViewSelection selection, String attributeName) {
// super();
// String getterMethodName = ViewAttributes.getGetterMethodName(attributeName);
// for (View matched : selection) {
// add(ViewAttributes.callGetterNormalizingStrings(matched, getterMethodName));
// }
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
import org.fest.assertions.api.Assertions;
import android.app.Activity;
import android.view.View;
import com.nikhaldimann.viewselector.attributes.ViewSelectionAttribute;
import com.nikhaldimann.viewselector.selection.ViewSelection;
package com.nikhaldimann.viewselector;
/**
* Static assertion entry points for fluent FEST-style assertions. Example usage:
*
* <pre>
* // Assert that activity has 5 views that are TextViews
* assertThat(selection("TextView", activity)).hasSize(5);
*
* // ... or equivalent:
* assertThatSelection("TextView", activity).hasSize(5);
*
* // Assert that all TextViews in activity have the text "Hello World"
* assertThatSelection("TextView", activity).attribute("text")
* .containsOnly("Hello World");
*
* // ... or equivalent:
* assertThat(extractAttribute("text").from(selection("TextView", activity)))
* .containsOnly("Hello World");
*
* // Assert that the 3 TextViews in activity have the texts "foo", "bar", "baz",
* // in that order
* assertThatSelection("TextView", activity).attribute("text")
* .containsExactly("foo", "bar", "baz");
* </pre>
*/
public class ViewSelectorAssertions extends Assertions {
private ViewSelectorAssertions() { }
/**
* Fluent assertion entry point for {@link ViewSelection}. Often used together
* with {@link #selection(String, Activity)} to create the selection.
*/
public static ViewSelectionAssert assertThat(ViewSelection actual) {
return new ViewSelectionAssert(actual);
}
/**
* Fluent assertion entry point for a selection of views from the given activity
* based on the given selector. It may be helpful to statically import this rather
* than {@link #assertThat(ViewSelection)} to avoid conflicts with other statically
* imported {@code assertThat()} methods.
*/
public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
return assertThat(selection(selector, activity));
}
/**
* Fluent assertion entry point for a selection of views from the given view
* based on the given selector. It may be helpful to statically import this rather
* than {@link #assertThat(ViewSelection)} to avoid conflicts with other statically
* imported {@code assertThat()} methods.
*/
public static ViewSelectionAssert assertThatSelection(String selector, View view) {
return assertThat(selection(selector, view));
}
/**
* @return the selection of views from the given activity based on the given selector
*/
public static ViewSelection selection(String selector, Activity activity) {
return selection(selector, activity.findViewById(android.R.id.content));
}
/**
* @return the selection of views from the given view based on the given selector
*/
public static ViewSelection selection(String selector, View view) {
return ViewSelector.compile(selector).selectViews(view);
}
/**
* Fluent assertion entry point for {@link ViewSelectionAttribute}. Often used
* together with {@link #extractAttribute(String)} to extract attributes from
* a selection.
*/ | public static ViewSelectionAttributeAssert assertThat(ViewSelectionAttribute actual) { |
nikhaldi/android-view-selector | src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/activities/AbstractMainActivityTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
| import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import org.junit.Before;
import org.junit.Test;
import android.app.Activity; | package com.nikhaldimann.viewselector.robolectric.activities;
public abstract class AbstractMainActivityTest {
private Activity activity;
protected abstract Activity createActivity();
@Before
public void setUp() {
activity = createActivity();
}
@Test
public void helloWorld() { | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
// Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/activities/AbstractMainActivityTest.java
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import org.junit.Before;
import org.junit.Test;
import android.app.Activity;
package com.nikhaldimann.viewselector.robolectric.activities;
public abstract class AbstractMainActivityTest {
private Activity activity;
protected abstract Activity createActivity();
@Before
public void setUp() {
activity = createActivity();
}
@Test
public void helloWorld() { | assertThatSelection("TextView#hello_world", activity).hasSize(1); |
nikhaldi/android-view-selector | src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/checker/ClassCheckerTest.java | // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractClassCheckerTest.java
// public abstract class AbstractClassCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> check(String selectorTag, Combinator combinator, View view) {
// Selector selector = new Selector(selectorTag, combinator);
// ClassChecker checker = new ClassChecker(selector, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testSingleView() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, view));
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, view), view);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, view), view);
// }
//
// @Test
// public void testViewGroupWithDescendants() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, layout), layout, view1, view2, layout2, view3);
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.DESCENDANT, layout), layout);
// assertContentsInOrder(check("FrameLayout", Combinator.DESCENDANT, layout), layout2);
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, layout), view1, view2, view3);
// }
//
// @Test
// public void testViewGroupWithChildren() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("FooView", Combinator.CHILD, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.CHILD, layout));
// assertContentsInOrder(check("TextView", Combinator.CHILD, layout), view1, view2);
// assertContentsInOrder(check("FrameLayout", Combinator.CHILD, layout2));
// }
//
// @Test
// public void testAdjacentSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view1), view2);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view3));
// }
//
// @Test
// public void testGeneralSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view1), view2, view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view3));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractClassCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric.checker;
@RunWith(RobolectricTestRunner.class)
public class ClassCheckerTest extends AbstractClassCheckerTest {
| // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractClassCheckerTest.java
// public abstract class AbstractClassCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> check(String selectorTag, Combinator combinator, View view) {
// Selector selector = new Selector(selectorTag, combinator);
// ClassChecker checker = new ClassChecker(selector, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testSingleView() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, view));
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, view), view);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, view), view);
// }
//
// @Test
// public void testViewGroupWithDescendants() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, layout), layout, view1, view2, layout2, view3);
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.DESCENDANT, layout), layout);
// assertContentsInOrder(check("FrameLayout", Combinator.DESCENDANT, layout), layout2);
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, layout), view1, view2, view3);
// }
//
// @Test
// public void testViewGroupWithChildren() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("FooView", Combinator.CHILD, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.CHILD, layout));
// assertContentsInOrder(check("TextView", Combinator.CHILD, layout), view1, view2);
// assertContentsInOrder(check("FrameLayout", Combinator.CHILD, layout2));
// }
//
// @Test
// public void testAdjacentSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view1), view2);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view3));
// }
//
// @Test
// public void testGeneralSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view1), view2, view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view3));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/checker/ClassCheckerTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractClassCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric.checker;
@RunWith(RobolectricTestRunner.class)
public class ClassCheckerTest extends AbstractClassCheckerTest {
| protected ViewFactory createViewFactory() { |
nikhaldi/android-view-selector | src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/checker/ClassCheckerTest.java | // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractClassCheckerTest.java
// public abstract class AbstractClassCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> check(String selectorTag, Combinator combinator, View view) {
// Selector selector = new Selector(selectorTag, combinator);
// ClassChecker checker = new ClassChecker(selector, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testSingleView() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, view));
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, view), view);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, view), view);
// }
//
// @Test
// public void testViewGroupWithDescendants() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, layout), layout, view1, view2, layout2, view3);
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.DESCENDANT, layout), layout);
// assertContentsInOrder(check("FrameLayout", Combinator.DESCENDANT, layout), layout2);
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, layout), view1, view2, view3);
// }
//
// @Test
// public void testViewGroupWithChildren() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("FooView", Combinator.CHILD, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.CHILD, layout));
// assertContentsInOrder(check("TextView", Combinator.CHILD, layout), view1, view2);
// assertContentsInOrder(check("FrameLayout", Combinator.CHILD, layout2));
// }
//
// @Test
// public void testAdjacentSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view1), view2);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view3));
// }
//
// @Test
// public void testGeneralSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view1), view2, view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view3));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractClassCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric.checker;
@RunWith(RobolectricTestRunner.class)
public class ClassCheckerTest extends AbstractClassCheckerTest {
protected ViewFactory createViewFactory() { | // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractClassCheckerTest.java
// public abstract class AbstractClassCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> check(String selectorTag, Combinator combinator, View view) {
// Selector selector = new Selector(selectorTag, combinator);
// ClassChecker checker = new ClassChecker(selector, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testSingleView() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, view));
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, view), view);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, view), view);
// }
//
// @Test
// public void testViewGroupWithDescendants() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, layout), layout, view1, view2, layout2, view3);
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.DESCENDANT, layout), layout);
// assertContentsInOrder(check("FrameLayout", Combinator.DESCENDANT, layout), layout2);
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, layout), view1, view2, view3);
// }
//
// @Test
// public void testViewGroupWithChildren() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("FooView", Combinator.CHILD, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.CHILD, layout));
// assertContentsInOrder(check("TextView", Combinator.CHILD, layout), view1, view2);
// assertContentsInOrder(check("FrameLayout", Combinator.CHILD, layout2));
// }
//
// @Test
// public void testAdjacentSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view1), view2);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view3));
// }
//
// @Test
// public void testGeneralSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view1), view2, view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view3));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/checker/ClassCheckerTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractClassCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric.checker;
@RunWith(RobolectricTestRunner.class)
public class ClassCheckerTest extends AbstractClassCheckerTest {
protected ViewFactory createViewFactory() { | return new RobolectricViewFactory(); |
nikhaldi/android-view-selector | src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/checker/AttributeSpecifierCheckerTest.java | // Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/testutil/Robolectric2ViewFactory.java
// public class Robolectric2ViewFactory extends ProvidedContextViewFactory {
//
// public Robolectric2ViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractAttributeSpecifierCheckerTest.java
// public abstract class AbstractAttributeSpecifierCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> checkExistence(String name, View view) {
// return check(new AttributeSpecifier(name), view);
// }
//
// private Iterable<View> check(String name, String value, Match match, View view) {
// return check(new AttributeSpecifier(name, value, match), view);
// }
//
// private Iterable<View> check(AttributeSpecifier specifier, View view) {
// AttributeSpecifierChecker checker = new AttributeSpecifierChecker(specifier, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testAttributeExistence() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(checkExistence("tag", view));
// assertContentsInOrder(checkExistence("text", view), view);
// assertContentsInOrder(checkExistence("width", view), view);
// assertContentsInOrder(checkExistence("foo", view));
// }
//
// @Test
// public void testExactMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertContentsInOrder(check("tag", "foo", Match.EXACT, view), view);
// assertContentsInOrder(check("tag", "bar", Match.EXACT, view));
// assertContentsInOrder(check("gobbledygook", "bar", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithNumbers() {
// TextView view = viewFactory.createTextView();
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// assertContentsInOrder(
// check("inputType", String.valueOf(InputType.TYPE_CLASS_TEXT), Match.EXACT, view),
// view);
// assertContentsInOrder(check("inputType", "42", Match.EXACT, view));
// assertContentsInOrder(check("inputType", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithBooleans() {
// TextView view = viewFactory.createTextView();
// view.setVisibility(View.INVISIBLE);
// assertContentsInOrder(check("isShown", "false", Match.EXACT, view), view);
// assertContentsInOrder(check("isShown", "true", Match.EXACT, view));
// assertContentsInOrder(check("isShown", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testContainsMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "oba", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "baar", Match.CONTAINS, view));
// assertContentsInOrder(check("isShown", "foo", Match.CONTAINS, view));
// }
//
// @Test
// public void testPrefixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "foob", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foe", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foobare", Match.PREFIX, view));
// assertContentsInOrder(check("isShown", "foo", Match.PREFIX, view));
// }
//
// @Test
// public void testSuffixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "r", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "a foobar", Match.SUFFIX, view));
// assertContentsInOrder(check("tag", "foo", Match.SUFFIX, view));
// assertContentsInOrder(check("isShown", "false", Match.SUFFIX, view));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric2.testutil.Robolectric2ViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractAttributeSpecifierCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import org.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric2.checker;
@RunWith(RobolectricTestRunner.class)
public class AttributeSpecifierCheckerTest extends AbstractAttributeSpecifierCheckerTest {
| // Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/testutil/Robolectric2ViewFactory.java
// public class Robolectric2ViewFactory extends ProvidedContextViewFactory {
//
// public Robolectric2ViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractAttributeSpecifierCheckerTest.java
// public abstract class AbstractAttributeSpecifierCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> checkExistence(String name, View view) {
// return check(new AttributeSpecifier(name), view);
// }
//
// private Iterable<View> check(String name, String value, Match match, View view) {
// return check(new AttributeSpecifier(name, value, match), view);
// }
//
// private Iterable<View> check(AttributeSpecifier specifier, View view) {
// AttributeSpecifierChecker checker = new AttributeSpecifierChecker(specifier, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testAttributeExistence() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(checkExistence("tag", view));
// assertContentsInOrder(checkExistence("text", view), view);
// assertContentsInOrder(checkExistence("width", view), view);
// assertContentsInOrder(checkExistence("foo", view));
// }
//
// @Test
// public void testExactMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertContentsInOrder(check("tag", "foo", Match.EXACT, view), view);
// assertContentsInOrder(check("tag", "bar", Match.EXACT, view));
// assertContentsInOrder(check("gobbledygook", "bar", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithNumbers() {
// TextView view = viewFactory.createTextView();
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// assertContentsInOrder(
// check("inputType", String.valueOf(InputType.TYPE_CLASS_TEXT), Match.EXACT, view),
// view);
// assertContentsInOrder(check("inputType", "42", Match.EXACT, view));
// assertContentsInOrder(check("inputType", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithBooleans() {
// TextView view = viewFactory.createTextView();
// view.setVisibility(View.INVISIBLE);
// assertContentsInOrder(check("isShown", "false", Match.EXACT, view), view);
// assertContentsInOrder(check("isShown", "true", Match.EXACT, view));
// assertContentsInOrder(check("isShown", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testContainsMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "oba", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "baar", Match.CONTAINS, view));
// assertContentsInOrder(check("isShown", "foo", Match.CONTAINS, view));
// }
//
// @Test
// public void testPrefixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "foob", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foe", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foobare", Match.PREFIX, view));
// assertContentsInOrder(check("isShown", "foo", Match.PREFIX, view));
// }
//
// @Test
// public void testSuffixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "r", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "a foobar", Match.SUFFIX, view));
// assertContentsInOrder(check("tag", "foo", Match.SUFFIX, view));
// assertContentsInOrder(check("isShown", "false", Match.SUFFIX, view));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/checker/AttributeSpecifierCheckerTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric2.testutil.Robolectric2ViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractAttributeSpecifierCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import org.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric2.checker;
@RunWith(RobolectricTestRunner.class)
public class AttributeSpecifierCheckerTest extends AbstractAttributeSpecifierCheckerTest {
| protected ViewFactory createViewFactory() { |
nikhaldi/android-view-selector | src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/checker/AttributeSpecifierCheckerTest.java | // Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/testutil/Robolectric2ViewFactory.java
// public class Robolectric2ViewFactory extends ProvidedContextViewFactory {
//
// public Robolectric2ViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractAttributeSpecifierCheckerTest.java
// public abstract class AbstractAttributeSpecifierCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> checkExistence(String name, View view) {
// return check(new AttributeSpecifier(name), view);
// }
//
// private Iterable<View> check(String name, String value, Match match, View view) {
// return check(new AttributeSpecifier(name, value, match), view);
// }
//
// private Iterable<View> check(AttributeSpecifier specifier, View view) {
// AttributeSpecifierChecker checker = new AttributeSpecifierChecker(specifier, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testAttributeExistence() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(checkExistence("tag", view));
// assertContentsInOrder(checkExistence("text", view), view);
// assertContentsInOrder(checkExistence("width", view), view);
// assertContentsInOrder(checkExistence("foo", view));
// }
//
// @Test
// public void testExactMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertContentsInOrder(check("tag", "foo", Match.EXACT, view), view);
// assertContentsInOrder(check("tag", "bar", Match.EXACT, view));
// assertContentsInOrder(check("gobbledygook", "bar", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithNumbers() {
// TextView view = viewFactory.createTextView();
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// assertContentsInOrder(
// check("inputType", String.valueOf(InputType.TYPE_CLASS_TEXT), Match.EXACT, view),
// view);
// assertContentsInOrder(check("inputType", "42", Match.EXACT, view));
// assertContentsInOrder(check("inputType", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithBooleans() {
// TextView view = viewFactory.createTextView();
// view.setVisibility(View.INVISIBLE);
// assertContentsInOrder(check("isShown", "false", Match.EXACT, view), view);
// assertContentsInOrder(check("isShown", "true", Match.EXACT, view));
// assertContentsInOrder(check("isShown", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testContainsMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "oba", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "baar", Match.CONTAINS, view));
// assertContentsInOrder(check("isShown", "foo", Match.CONTAINS, view));
// }
//
// @Test
// public void testPrefixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "foob", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foe", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foobare", Match.PREFIX, view));
// assertContentsInOrder(check("isShown", "foo", Match.PREFIX, view));
// }
//
// @Test
// public void testSuffixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "r", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "a foobar", Match.SUFFIX, view));
// assertContentsInOrder(check("tag", "foo", Match.SUFFIX, view));
// assertContentsInOrder(check("isShown", "false", Match.SUFFIX, view));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric2.testutil.Robolectric2ViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractAttributeSpecifierCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import org.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric2.checker;
@RunWith(RobolectricTestRunner.class)
public class AttributeSpecifierCheckerTest extends AbstractAttributeSpecifierCheckerTest {
protected ViewFactory createViewFactory() { | // Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/testutil/Robolectric2ViewFactory.java
// public class Robolectric2ViewFactory extends ProvidedContextViewFactory {
//
// public Robolectric2ViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractAttributeSpecifierCheckerTest.java
// public abstract class AbstractAttributeSpecifierCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> checkExistence(String name, View view) {
// return check(new AttributeSpecifier(name), view);
// }
//
// private Iterable<View> check(String name, String value, Match match, View view) {
// return check(new AttributeSpecifier(name, value, match), view);
// }
//
// private Iterable<View> check(AttributeSpecifier specifier, View view) {
// AttributeSpecifierChecker checker = new AttributeSpecifierChecker(specifier, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testAttributeExistence() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(checkExistence("tag", view));
// assertContentsInOrder(checkExistence("text", view), view);
// assertContentsInOrder(checkExistence("width", view), view);
// assertContentsInOrder(checkExistence("foo", view));
// }
//
// @Test
// public void testExactMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertContentsInOrder(check("tag", "foo", Match.EXACT, view), view);
// assertContentsInOrder(check("tag", "bar", Match.EXACT, view));
// assertContentsInOrder(check("gobbledygook", "bar", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithNumbers() {
// TextView view = viewFactory.createTextView();
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// assertContentsInOrder(
// check("inputType", String.valueOf(InputType.TYPE_CLASS_TEXT), Match.EXACT, view),
// view);
// assertContentsInOrder(check("inputType", "42", Match.EXACT, view));
// assertContentsInOrder(check("inputType", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithBooleans() {
// TextView view = viewFactory.createTextView();
// view.setVisibility(View.INVISIBLE);
// assertContentsInOrder(check("isShown", "false", Match.EXACT, view), view);
// assertContentsInOrder(check("isShown", "true", Match.EXACT, view));
// assertContentsInOrder(check("isShown", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testContainsMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "oba", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "baar", Match.CONTAINS, view));
// assertContentsInOrder(check("isShown", "foo", Match.CONTAINS, view));
// }
//
// @Test
// public void testPrefixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "foob", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foe", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foobare", Match.PREFIX, view));
// assertContentsInOrder(check("isShown", "foo", Match.PREFIX, view));
// }
//
// @Test
// public void testSuffixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "r", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "a foobar", Match.SUFFIX, view));
// assertContentsInOrder(check("tag", "foo", Match.SUFFIX, view));
// assertContentsInOrder(check("isShown", "false", Match.SUFFIX, view));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/checker/AttributeSpecifierCheckerTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric2.testutil.Robolectric2ViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractAttributeSpecifierCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import org.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric2.checker;
@RunWith(RobolectricTestRunner.class)
public class AttributeSpecifierCheckerTest extends AbstractAttributeSpecifierCheckerTest {
protected ViewFactory createViewFactory() { | return new Robolectric2ViewFactory(); |
nikhaldi/android-view-selector | src/android-test/src/com/nikhaldimann/viewselector/android/ViewSelectionAssertTest.java | // Path: src/android-test/src/com/nikhaldimann/viewselector/android/testutil/AndroidTestViewFactory.java
// public class AndroidTestViewFactory extends ProvidedContextViewFactory {
//
// public AndroidTestViewFactory(Context context) {
// super(context);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectionAssertTest.java
// public abstract class AbstractViewSelectionAssertTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).attribute("text").containsOnly("foo");
// assertThatSelection("TextView", view).attribute("tag").containsOnly("bar");
// }
//
// @Test
// public void testAttributeMultiple() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// TextView view2 = viewFactory.createTextView();
// view2.setText("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// assertThatSelection("TextView", root)
// .hasSize(2)
// .attribute("text").containsExactly("foo", "bar");
// }
//
// @Test
// public void testFailingAttributeOnEmptySelection() {
// try {
// assertThatSelection("ImageView", viewFactory.createTextView()).attribute("tag");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasAttributeEqualTo() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).hasAttributeEqualTo("text", "foo");
// assertThatSelection("TextView", view).hasAttributeEqualTo("tag", "bar");
// }
//
// @Test
// public void testFailingHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("text", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testFailingHasAttributeEqualToOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("ImageView", view).hasAttributeEqualTo("tag", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testNonExistentHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("foo", "bar");
// failHard();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTag() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertThatSelection("TextView", view).hasTag("foo");
// }
//
// @Test
// public void testHasTagFailureOnMismatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnNoTag() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("ImageView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnPartialSelectionMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// TextView view2 = viewFactory.createTextView();
// view.setTag("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// try {
// assertThatSelection("TextView", view).hasTag("foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import com.nikhaldimann.viewselector.android.testutil.AndroidTestViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectionAssertTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory; | package com.nikhaldimann.viewselector.android;
public class ViewSelectionAssertTest extends AbstractViewSelectionAssertTest {
protected ViewFactory createViewFactory() { | // Path: src/android-test/src/com/nikhaldimann/viewselector/android/testutil/AndroidTestViewFactory.java
// public class AndroidTestViewFactory extends ProvidedContextViewFactory {
//
// public AndroidTestViewFactory(Context context) {
// super(context);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectionAssertTest.java
// public abstract class AbstractViewSelectionAssertTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).attribute("text").containsOnly("foo");
// assertThatSelection("TextView", view).attribute("tag").containsOnly("bar");
// }
//
// @Test
// public void testAttributeMultiple() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// TextView view2 = viewFactory.createTextView();
// view2.setText("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// assertThatSelection("TextView", root)
// .hasSize(2)
// .attribute("text").containsExactly("foo", "bar");
// }
//
// @Test
// public void testFailingAttributeOnEmptySelection() {
// try {
// assertThatSelection("ImageView", viewFactory.createTextView()).attribute("tag");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasAttributeEqualTo() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// view.setTag("bar");
// assertThatSelection("TextView", view).hasAttributeEqualTo("text", "foo");
// assertThatSelection("TextView", view).hasAttributeEqualTo("tag", "bar");
// }
//
// @Test
// public void testFailingHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("text", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testFailingHasAttributeEqualToOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("ImageView", view).hasAttributeEqualTo("tag", "foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testNonExistentHasAttributeEqualTo() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView())
// .hasAttributeEqualTo("foo", "bar");
// failHard();
// } catch (AttributeAccessException ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTag() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertThatSelection("TextView", view).hasTag("foo");
// }
//
// @Test
// public void testHasTagFailureOnMismatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnNoTag() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("TextView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnEmptySelection() {
// TextView view = viewFactory.createTextView();
// try {
// assertThatSelection("ImageView", view).hasTag("bar");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testHasTagFailureOnPartialSelectionMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// TextView view2 = viewFactory.createTextView();
// view.setTag("bar");
// LinearLayout root = viewFactory.createLinearLayout();
// root.addView(view);
// root.addView(view2);
// try {
// assertThatSelection("TextView", view).hasTag("foo");
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/android-test/src/com/nikhaldimann/viewselector/android/ViewSelectionAssertTest.java
import com.nikhaldimann.viewselector.android.testutil.AndroidTestViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectionAssertTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
package com.nikhaldimann.viewselector.android;
public class ViewSelectionAssertTest extends AbstractViewSelectionAssertTest {
protected ViewFactory createViewFactory() { | return new AndroidTestViewFactory(getContext()); |
nikhaldi/android-view-selector | src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/InvalidSelectorException.java
// public class InvalidSelectorException extends RuntimeException {
//
// public InvalidSelectorException(String message) {
// super(message);
// }
//
// public InvalidSelectorException(String message, Exception cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelector.java
// public class ViewSelector {
//
// private final List<List<Selector>> selectorGroups;
//
// public ViewSelector(List<List<Selector>> selectorGroups) {
// this.selectorGroups = selectorGroups;
// }
//
// /**
// * Applies this selector to the given view, selecting all descendants of the
// * view that match this selector.
// * @return the ordered set of views that matches this selector
// */
// public ViewSelection selectViews(View view) {
// ViewSelection result = new ViewSelection();
// for (List<Selector> selectorParts : selectorGroups) {
// result.addAll(selectViewsForGroup(selectorParts, view));
// }
// return result;
// }
//
// private ViewSelection selectViewsForGroup(List<Selector> selectorParts, View view) {
// ViewSelection result = new ViewSelection();
// result.add(view);
// for (Selector selector : selectorParts) {
// ViewTraversalChecker checker = new ClassChecker(selector, view);
// result = checker.check(result);
// if (result.isEmpty()) {
// return result;
// }
//
// if (selector.hasSpecifiers()) {
// for (Specifier specifier : selector.getSpecifiers()) {
// switch (specifier.getType()) {
// case ATTRIBUTE:
// checker = new AttributeSpecifierChecker((AttributeSpecifier) specifier, view);
// break;
// default:
// throw new UnsupportedOperationException();
// }
// result = checker.check(result);
// if (result.isEmpty()) {
// return result;
// }
// }
// }
// }
// return result;
// }
//
// /**
// * @return a new ViewSelector from the given selector string
// * @throws InvalidSelectorException if the given selector string can't be parsed into
// * a valid selector
// */
// public static ViewSelector compile(String selectorString) {
// List<List<Selector>> groups;
// try {
// Scanner scanner = new Scanner(selectorString);
// groups = scanner.scan();
// } catch (ScannerException ex) {
// throw new InvalidSelectorException("Invalid selector: " + selectorString, ex);
// }
// return new ViewSelector(groups);
// }
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
| import org.junit.Test;
import android.text.InputType;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nikhaldimann.viewselector.InvalidSelectorException;
import com.nikhaldimann.viewselector.ViewSelector;
import com.nikhaldimann.viewselector.selection.ViewSelection;
import com.nikhaldimann.viewselector.test.R;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase; | package com.nikhaldimann.viewselector.test.abstrakt;
public abstract class AbstractViewSelectorTest extends ViewSelectorAndroidTestCase {
private ViewSelection selectViews(String selector, View view) { | // Path: src/main/java/com/nikhaldimann/viewselector/InvalidSelectorException.java
// public class InvalidSelectorException extends RuntimeException {
//
// public InvalidSelectorException(String message) {
// super(message);
// }
//
// public InvalidSelectorException(String message, Exception cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelector.java
// public class ViewSelector {
//
// private final List<List<Selector>> selectorGroups;
//
// public ViewSelector(List<List<Selector>> selectorGroups) {
// this.selectorGroups = selectorGroups;
// }
//
// /**
// * Applies this selector to the given view, selecting all descendants of the
// * view that match this selector.
// * @return the ordered set of views that matches this selector
// */
// public ViewSelection selectViews(View view) {
// ViewSelection result = new ViewSelection();
// for (List<Selector> selectorParts : selectorGroups) {
// result.addAll(selectViewsForGroup(selectorParts, view));
// }
// return result;
// }
//
// private ViewSelection selectViewsForGroup(List<Selector> selectorParts, View view) {
// ViewSelection result = new ViewSelection();
// result.add(view);
// for (Selector selector : selectorParts) {
// ViewTraversalChecker checker = new ClassChecker(selector, view);
// result = checker.check(result);
// if (result.isEmpty()) {
// return result;
// }
//
// if (selector.hasSpecifiers()) {
// for (Specifier specifier : selector.getSpecifiers()) {
// switch (specifier.getType()) {
// case ATTRIBUTE:
// checker = new AttributeSpecifierChecker((AttributeSpecifier) specifier, view);
// break;
// default:
// throw new UnsupportedOperationException();
// }
// result = checker.check(result);
// if (result.isEmpty()) {
// return result;
// }
// }
// }
// }
// return result;
// }
//
// /**
// * @return a new ViewSelector from the given selector string
// * @throws InvalidSelectorException if the given selector string can't be parsed into
// * a valid selector
// */
// public static ViewSelector compile(String selectorString) {
// List<List<Selector>> groups;
// try {
// Scanner scanner = new Scanner(selectorString);
// groups = scanner.scan();
// } catch (ScannerException ex) {
// throw new InvalidSelectorException("Invalid selector: " + selectorString, ex);
// }
// return new ViewSelector(groups);
// }
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorTest.java
import org.junit.Test;
import android.text.InputType;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nikhaldimann.viewselector.InvalidSelectorException;
import com.nikhaldimann.viewselector.ViewSelector;
import com.nikhaldimann.viewselector.selection.ViewSelection;
import com.nikhaldimann.viewselector.test.R;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase;
package com.nikhaldimann.viewselector.test.abstrakt;
public abstract class AbstractViewSelectorTest extends ViewSelectorAndroidTestCase {
private ViewSelection selectViews(String selector, View view) { | return ViewSelector.compile(selector).selectViews(view); |
nikhaldi/android-view-selector | src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/InvalidSelectorException.java
// public class InvalidSelectorException extends RuntimeException {
//
// public InvalidSelectorException(String message) {
// super(message);
// }
//
// public InvalidSelectorException(String message, Exception cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelector.java
// public class ViewSelector {
//
// private final List<List<Selector>> selectorGroups;
//
// public ViewSelector(List<List<Selector>> selectorGroups) {
// this.selectorGroups = selectorGroups;
// }
//
// /**
// * Applies this selector to the given view, selecting all descendants of the
// * view that match this selector.
// * @return the ordered set of views that matches this selector
// */
// public ViewSelection selectViews(View view) {
// ViewSelection result = new ViewSelection();
// for (List<Selector> selectorParts : selectorGroups) {
// result.addAll(selectViewsForGroup(selectorParts, view));
// }
// return result;
// }
//
// private ViewSelection selectViewsForGroup(List<Selector> selectorParts, View view) {
// ViewSelection result = new ViewSelection();
// result.add(view);
// for (Selector selector : selectorParts) {
// ViewTraversalChecker checker = new ClassChecker(selector, view);
// result = checker.check(result);
// if (result.isEmpty()) {
// return result;
// }
//
// if (selector.hasSpecifiers()) {
// for (Specifier specifier : selector.getSpecifiers()) {
// switch (specifier.getType()) {
// case ATTRIBUTE:
// checker = new AttributeSpecifierChecker((AttributeSpecifier) specifier, view);
// break;
// default:
// throw new UnsupportedOperationException();
// }
// result = checker.check(result);
// if (result.isEmpty()) {
// return result;
// }
// }
// }
// }
// return result;
// }
//
// /**
// * @return a new ViewSelector from the given selector string
// * @throws InvalidSelectorException if the given selector string can't be parsed into
// * a valid selector
// */
// public static ViewSelector compile(String selectorString) {
// List<List<Selector>> groups;
// try {
// Scanner scanner = new Scanner(selectorString);
// groups = scanner.scan();
// } catch (ScannerException ex) {
// throw new InvalidSelectorException("Invalid selector: " + selectorString, ex);
// }
// return new ViewSelector(groups);
// }
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
| import org.junit.Test;
import android.text.InputType;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nikhaldimann.viewselector.InvalidSelectorException;
import com.nikhaldimann.viewselector.ViewSelector;
import com.nikhaldimann.viewselector.selection.ViewSelection;
import com.nikhaldimann.viewselector.test.R;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase; | package com.nikhaldimann.viewselector.test.abstrakt;
public abstract class AbstractViewSelectorTest extends ViewSelectorAndroidTestCase {
private ViewSelection selectViews(String selector, View view) {
return ViewSelector.compile(selector).selectViews(view);
}
@Test
public void testSelectViewsSimpleSingleView() {
TextView view = viewFactory.createTextView();
assertContentsInOrder(selectViews("EditView", view));
assertContentsInOrder(selectViews("TextView", view), view);
assertContentsInOrder(selectViews("", view));
assertContentsInOrder(selectViews(" ", view));
}
@Test
public void testCompileInvalidSelector() {
try {
ViewSelector.compile("> EditView");
fail(); | // Path: src/main/java/com/nikhaldimann/viewselector/InvalidSelectorException.java
// public class InvalidSelectorException extends RuntimeException {
//
// public InvalidSelectorException(String message) {
// super(message);
// }
//
// public InvalidSelectorException(String message, Exception cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelector.java
// public class ViewSelector {
//
// private final List<List<Selector>> selectorGroups;
//
// public ViewSelector(List<List<Selector>> selectorGroups) {
// this.selectorGroups = selectorGroups;
// }
//
// /**
// * Applies this selector to the given view, selecting all descendants of the
// * view that match this selector.
// * @return the ordered set of views that matches this selector
// */
// public ViewSelection selectViews(View view) {
// ViewSelection result = new ViewSelection();
// for (List<Selector> selectorParts : selectorGroups) {
// result.addAll(selectViewsForGroup(selectorParts, view));
// }
// return result;
// }
//
// private ViewSelection selectViewsForGroup(List<Selector> selectorParts, View view) {
// ViewSelection result = new ViewSelection();
// result.add(view);
// for (Selector selector : selectorParts) {
// ViewTraversalChecker checker = new ClassChecker(selector, view);
// result = checker.check(result);
// if (result.isEmpty()) {
// return result;
// }
//
// if (selector.hasSpecifiers()) {
// for (Specifier specifier : selector.getSpecifiers()) {
// switch (specifier.getType()) {
// case ATTRIBUTE:
// checker = new AttributeSpecifierChecker((AttributeSpecifier) specifier, view);
// break;
// default:
// throw new UnsupportedOperationException();
// }
// result = checker.check(result);
// if (result.isEmpty()) {
// return result;
// }
// }
// }
// }
// return result;
// }
//
// /**
// * @return a new ViewSelector from the given selector string
// * @throws InvalidSelectorException if the given selector string can't be parsed into
// * a valid selector
// */
// public static ViewSelector compile(String selectorString) {
// List<List<Selector>> groups;
// try {
// Scanner scanner = new Scanner(selectorString);
// groups = scanner.scan();
// } catch (ScannerException ex) {
// throw new InvalidSelectorException("Invalid selector: " + selectorString, ex);
// }
// return new ViewSelector(groups);
// }
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorTest.java
import org.junit.Test;
import android.text.InputType;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nikhaldimann.viewselector.InvalidSelectorException;
import com.nikhaldimann.viewselector.ViewSelector;
import com.nikhaldimann.viewselector.selection.ViewSelection;
import com.nikhaldimann.viewselector.test.R;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase;
package com.nikhaldimann.viewselector.test.abstrakt;
public abstract class AbstractViewSelectorTest extends ViewSelectorAndroidTestCase {
private ViewSelection selectViews(String selector, View view) {
return ViewSelector.compile(selector).selectViews(view);
}
@Test
public void testSelectViewsSimpleSingleView() {
TextView view = viewFactory.createTextView();
assertContentsInOrder(selectViews("EditView", view));
assertContentsInOrder(selectViews("TextView", view), view);
assertContentsInOrder(selectViews("", view));
assertContentsInOrder(selectViews(" ", view));
}
@Test
public void testCompileInvalidSelector() {
try {
ViewSelector.compile("> EditView");
fail(); | } catch (InvalidSelectorException ex) { |
nikhaldi/android-view-selector | src/main/java/com/nikhaldimann/viewselector/checker/ClassChecker.java | // Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
| import java.util.Set;
import se.fishtank.css.selectors.Selector;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import com.nikhaldimann.viewselector.selection.ViewSelection; | package com.nikhaldimann.viewselector.checker;
/**
* Checks views based on matching the tag from a selector to the class of
* a view.
*/
public class ClassChecker implements ViewTraversalChecker {
private final Selector selector;
private final MatchPredicate matchPredicate;
public ClassChecker(Selector selector, View root) {
this.selector = selector;
final String className = selector.getTagName();
if (className.equals(Selector.UNIVERSAL_TAG)) {
matchPredicate = MatchPredicates.ALWAYS_TRUE_PREDICATE;
} else {
matchPredicate = new MatchPredicate() {
public boolean matches(View view) {
return className.equals(view.getClass().getSimpleName());
}
};
}
}
| // Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
// Path: src/main/java/com/nikhaldimann/viewselector/checker/ClassChecker.java
import java.util.Set;
import se.fishtank.css.selectors.Selector;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import com.nikhaldimann.viewselector.selection.ViewSelection;
package com.nikhaldimann.viewselector.checker;
/**
* Checks views based on matching the tag from a selector to the class of
* a view.
*/
public class ClassChecker implements ViewTraversalChecker {
private final Selector selector;
private final MatchPredicate matchPredicate;
public ClassChecker(Selector selector, View root) {
this.selector = selector;
final String className = selector.getTagName();
if (className.equals(Selector.UNIVERSAL_TAG)) {
matchPredicate = MatchPredicates.ALWAYS_TRUE_PREDICATE;
} else {
matchPredicate = new MatchPredicate() {
public boolean matches(View view) {
return className.equals(view.getClass().getSimpleName());
}
};
}
}
| public ViewSelection check(Set<View> views) { |
nikhaldi/android-view-selector | src/main/java/com/nikhaldimann/viewselector/attributes/ViewSelectionAttribute.java | // Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
| import java.util.ArrayList;
import android.view.View;
import com.nikhaldimann.viewselector.selection.ViewSelection; | package com.nikhaldimann.viewselector.attributes;
/**
* Collection representing an attribute of a selection of views made. We're
* making this its own type in order to be able to single it out in FEST-style
* {@code assertThat()} calls.
*/
public class ViewSelectionAttribute extends ArrayList<Object> {
public ViewSelectionAttribute() {
super();
}
| // Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewSelectionAttribute.java
import java.util.ArrayList;
import android.view.View;
import com.nikhaldimann.viewselector.selection.ViewSelection;
package com.nikhaldimann.viewselector.attributes;
/**
* Collection representing an attribute of a selection of views made. We're
* making this its own type in order to be able to single it out in FEST-style
* {@code assertThat()} calls.
*/
public class ViewSelectionAttribute extends ArrayList<Object> {
public ViewSelectionAttribute() {
super();
}
| public ViewSelectionAttribute(ViewSelection selection, String attributeName) { |
nikhaldi/android-view-selector | src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractClassCheckerTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/checker/ClassChecker.java
// public class ClassChecker implements ViewTraversalChecker {
//
// private final Selector selector;
// private final MatchPredicate matchPredicate;
//
// public ClassChecker(Selector selector, View root) {
// this.selector = selector;
//
// final String className = selector.getTagName();
// if (className.equals(Selector.UNIVERSAL_TAG)) {
// matchPredicate = MatchPredicates.ALWAYS_TRUE_PREDICATE;
// } else {
// matchPredicate = new MatchPredicate() {
// public boolean matches(View view) {
// return className.equals(view.getClass().getSimpleName());
// }
// };
// }
// }
//
// public ViewSelection check(Set<View> views) {
// ViewSelection result = new ViewSelection();
// for (View view : views) {
// switch (selector.getCombinator()) {
// case DESCENDANT:
// checkDescendantsRecursively(view, result);
// break;
// case CHILD:
// if (!(view instanceof ViewGroup)) {
// continue;
// }
// checkChildren((ViewGroup) view, result);
// break;
// case ADJACENT_SIBLING:
// checkSiblings(view, result, true);
// break;
// case GENERAL_SIBLING:
// checkSiblings(view, result, false);
// break;
// default:
// throw new UnsupportedOperationException(
// "Unsupported combinator " + selector.getCombinator());
// }
//
// }
// return result;
// }
//
// private void checkDescendantsRecursively(View view, Set<View> result) {
// // Note: Using recursion. We hope that real-world layouts don't get deep
// // enough that this causes a problem.
// if (matchesView(view)) {
// result.add(view);
// }
// if (view instanceof ViewGroup) {
// ViewGroup group = (ViewGroup) view;
// for (int i = 0; i < group.getChildCount(); i++) {
// View childView = group.getChildAt(i);
// checkDescendantsRecursively(childView, result);
// }
// }
// }
//
// private void checkChildren(ViewGroup group, Set<View> result) {
// for (int i = 0; i < group.getChildCount(); i++) {
// View childView = group.getChildAt(i);
// if (matchesView(childView)) {
// result.add(childView);
// }
// }
// }
//
// private void checkSiblings(View view, Set<View> result, boolean isAdjacent) {
// ViewParent parent = view.getParent();
// if (!(parent instanceof ViewGroup)) {
// return;
// }
// ViewGroup parentGroup = (ViewGroup) parent;
//
// int childPos = 0;
// while (parentGroup.getChildAt(childPos) != view) {
// childPos++;
// }
//
// if (isAdjacent && parentGroup.getChildCount() > childPos + 1) {
// View sibling = parentGroup.getChildAt(childPos + 1);
// if (matchesView(sibling)) {
// result.add(sibling);
// }
// } else {
// for (int i = childPos + 1; parentGroup.getChildCount() > i; i++) {
// View sibling = parentGroup.getChildAt(i);
// if (matchesView(sibling)) {
// result.add(sibling);
// }
// }
// }
// }
//
// private boolean matchesView(View view) {
// return matchPredicate.matches(view);
// }
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
| import org.junit.Test;
import se.fishtank.css.selectors.Selector;
import se.fishtank.css.selectors.Selector.Combinator;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nikhaldimann.viewselector.checker.ClassChecker;
import com.nikhaldimann.viewselector.selection.ViewSelection;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase; | package com.nikhaldimann.viewselector.test.abstrakt.checker;
public abstract class AbstractClassCheckerTest extends ViewSelectorAndroidTestCase {
private Iterable<View> check(String selectorTag, Combinator combinator, View view) {
Selector selector = new Selector(selectorTag, combinator); | // Path: src/main/java/com/nikhaldimann/viewselector/checker/ClassChecker.java
// public class ClassChecker implements ViewTraversalChecker {
//
// private final Selector selector;
// private final MatchPredicate matchPredicate;
//
// public ClassChecker(Selector selector, View root) {
// this.selector = selector;
//
// final String className = selector.getTagName();
// if (className.equals(Selector.UNIVERSAL_TAG)) {
// matchPredicate = MatchPredicates.ALWAYS_TRUE_PREDICATE;
// } else {
// matchPredicate = new MatchPredicate() {
// public boolean matches(View view) {
// return className.equals(view.getClass().getSimpleName());
// }
// };
// }
// }
//
// public ViewSelection check(Set<View> views) {
// ViewSelection result = new ViewSelection();
// for (View view : views) {
// switch (selector.getCombinator()) {
// case DESCENDANT:
// checkDescendantsRecursively(view, result);
// break;
// case CHILD:
// if (!(view instanceof ViewGroup)) {
// continue;
// }
// checkChildren((ViewGroup) view, result);
// break;
// case ADJACENT_SIBLING:
// checkSiblings(view, result, true);
// break;
// case GENERAL_SIBLING:
// checkSiblings(view, result, false);
// break;
// default:
// throw new UnsupportedOperationException(
// "Unsupported combinator " + selector.getCombinator());
// }
//
// }
// return result;
// }
//
// private void checkDescendantsRecursively(View view, Set<View> result) {
// // Note: Using recursion. We hope that real-world layouts don't get deep
// // enough that this causes a problem.
// if (matchesView(view)) {
// result.add(view);
// }
// if (view instanceof ViewGroup) {
// ViewGroup group = (ViewGroup) view;
// for (int i = 0; i < group.getChildCount(); i++) {
// View childView = group.getChildAt(i);
// checkDescendantsRecursively(childView, result);
// }
// }
// }
//
// private void checkChildren(ViewGroup group, Set<View> result) {
// for (int i = 0; i < group.getChildCount(); i++) {
// View childView = group.getChildAt(i);
// if (matchesView(childView)) {
// result.add(childView);
// }
// }
// }
//
// private void checkSiblings(View view, Set<View> result, boolean isAdjacent) {
// ViewParent parent = view.getParent();
// if (!(parent instanceof ViewGroup)) {
// return;
// }
// ViewGroup parentGroup = (ViewGroup) parent;
//
// int childPos = 0;
// while (parentGroup.getChildAt(childPos) != view) {
// childPos++;
// }
//
// if (isAdjacent && parentGroup.getChildCount() > childPos + 1) {
// View sibling = parentGroup.getChildAt(childPos + 1);
// if (matchesView(sibling)) {
// result.add(sibling);
// }
// } else {
// for (int i = childPos + 1; parentGroup.getChildCount() > i; i++) {
// View sibling = parentGroup.getChildAt(i);
// if (matchesView(sibling)) {
// result.add(sibling);
// }
// }
// }
// }
//
// private boolean matchesView(View view) {
// return matchPredicate.matches(view);
// }
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractClassCheckerTest.java
import org.junit.Test;
import se.fishtank.css.selectors.Selector;
import se.fishtank.css.selectors.Selector.Combinator;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nikhaldimann.viewselector.checker.ClassChecker;
import com.nikhaldimann.viewselector.selection.ViewSelection;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase;
package com.nikhaldimann.viewselector.test.abstrakt.checker;
public abstract class AbstractClassCheckerTest extends ViewSelectorAndroidTestCase {
private Iterable<View> check(String selectorTag, Combinator combinator, View view) {
Selector selector = new Selector(selectorTag, combinator); | ClassChecker checker = new ClassChecker(selector, view); |
nikhaldi/android-view-selector | src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractClassCheckerTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/checker/ClassChecker.java
// public class ClassChecker implements ViewTraversalChecker {
//
// private final Selector selector;
// private final MatchPredicate matchPredicate;
//
// public ClassChecker(Selector selector, View root) {
// this.selector = selector;
//
// final String className = selector.getTagName();
// if (className.equals(Selector.UNIVERSAL_TAG)) {
// matchPredicate = MatchPredicates.ALWAYS_TRUE_PREDICATE;
// } else {
// matchPredicate = new MatchPredicate() {
// public boolean matches(View view) {
// return className.equals(view.getClass().getSimpleName());
// }
// };
// }
// }
//
// public ViewSelection check(Set<View> views) {
// ViewSelection result = new ViewSelection();
// for (View view : views) {
// switch (selector.getCombinator()) {
// case DESCENDANT:
// checkDescendantsRecursively(view, result);
// break;
// case CHILD:
// if (!(view instanceof ViewGroup)) {
// continue;
// }
// checkChildren((ViewGroup) view, result);
// break;
// case ADJACENT_SIBLING:
// checkSiblings(view, result, true);
// break;
// case GENERAL_SIBLING:
// checkSiblings(view, result, false);
// break;
// default:
// throw new UnsupportedOperationException(
// "Unsupported combinator " + selector.getCombinator());
// }
//
// }
// return result;
// }
//
// private void checkDescendantsRecursively(View view, Set<View> result) {
// // Note: Using recursion. We hope that real-world layouts don't get deep
// // enough that this causes a problem.
// if (matchesView(view)) {
// result.add(view);
// }
// if (view instanceof ViewGroup) {
// ViewGroup group = (ViewGroup) view;
// for (int i = 0; i < group.getChildCount(); i++) {
// View childView = group.getChildAt(i);
// checkDescendantsRecursively(childView, result);
// }
// }
// }
//
// private void checkChildren(ViewGroup group, Set<View> result) {
// for (int i = 0; i < group.getChildCount(); i++) {
// View childView = group.getChildAt(i);
// if (matchesView(childView)) {
// result.add(childView);
// }
// }
// }
//
// private void checkSiblings(View view, Set<View> result, boolean isAdjacent) {
// ViewParent parent = view.getParent();
// if (!(parent instanceof ViewGroup)) {
// return;
// }
// ViewGroup parentGroup = (ViewGroup) parent;
//
// int childPos = 0;
// while (parentGroup.getChildAt(childPos) != view) {
// childPos++;
// }
//
// if (isAdjacent && parentGroup.getChildCount() > childPos + 1) {
// View sibling = parentGroup.getChildAt(childPos + 1);
// if (matchesView(sibling)) {
// result.add(sibling);
// }
// } else {
// for (int i = childPos + 1; parentGroup.getChildCount() > i; i++) {
// View sibling = parentGroup.getChildAt(i);
// if (matchesView(sibling)) {
// result.add(sibling);
// }
// }
// }
// }
//
// private boolean matchesView(View view) {
// return matchPredicate.matches(view);
// }
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
| import org.junit.Test;
import se.fishtank.css.selectors.Selector;
import se.fishtank.css.selectors.Selector.Combinator;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nikhaldimann.viewselector.checker.ClassChecker;
import com.nikhaldimann.viewselector.selection.ViewSelection;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase; | package com.nikhaldimann.viewselector.test.abstrakt.checker;
public abstract class AbstractClassCheckerTest extends ViewSelectorAndroidTestCase {
private Iterable<View> check(String selectorTag, Combinator combinator, View view) {
Selector selector = new Selector(selectorTag, combinator);
ClassChecker checker = new ClassChecker(selector, view); | // Path: src/main/java/com/nikhaldimann/viewselector/checker/ClassChecker.java
// public class ClassChecker implements ViewTraversalChecker {
//
// private final Selector selector;
// private final MatchPredicate matchPredicate;
//
// public ClassChecker(Selector selector, View root) {
// this.selector = selector;
//
// final String className = selector.getTagName();
// if (className.equals(Selector.UNIVERSAL_TAG)) {
// matchPredicate = MatchPredicates.ALWAYS_TRUE_PREDICATE;
// } else {
// matchPredicate = new MatchPredicate() {
// public boolean matches(View view) {
// return className.equals(view.getClass().getSimpleName());
// }
// };
// }
// }
//
// public ViewSelection check(Set<View> views) {
// ViewSelection result = new ViewSelection();
// for (View view : views) {
// switch (selector.getCombinator()) {
// case DESCENDANT:
// checkDescendantsRecursively(view, result);
// break;
// case CHILD:
// if (!(view instanceof ViewGroup)) {
// continue;
// }
// checkChildren((ViewGroup) view, result);
// break;
// case ADJACENT_SIBLING:
// checkSiblings(view, result, true);
// break;
// case GENERAL_SIBLING:
// checkSiblings(view, result, false);
// break;
// default:
// throw new UnsupportedOperationException(
// "Unsupported combinator " + selector.getCombinator());
// }
//
// }
// return result;
// }
//
// private void checkDescendantsRecursively(View view, Set<View> result) {
// // Note: Using recursion. We hope that real-world layouts don't get deep
// // enough that this causes a problem.
// if (matchesView(view)) {
// result.add(view);
// }
// if (view instanceof ViewGroup) {
// ViewGroup group = (ViewGroup) view;
// for (int i = 0; i < group.getChildCount(); i++) {
// View childView = group.getChildAt(i);
// checkDescendantsRecursively(childView, result);
// }
// }
// }
//
// private void checkChildren(ViewGroup group, Set<View> result) {
// for (int i = 0; i < group.getChildCount(); i++) {
// View childView = group.getChildAt(i);
// if (matchesView(childView)) {
// result.add(childView);
// }
// }
// }
//
// private void checkSiblings(View view, Set<View> result, boolean isAdjacent) {
// ViewParent parent = view.getParent();
// if (!(parent instanceof ViewGroup)) {
// return;
// }
// ViewGroup parentGroup = (ViewGroup) parent;
//
// int childPos = 0;
// while (parentGroup.getChildAt(childPos) != view) {
// childPos++;
// }
//
// if (isAdjacent && parentGroup.getChildCount() > childPos + 1) {
// View sibling = parentGroup.getChildAt(childPos + 1);
// if (matchesView(sibling)) {
// result.add(sibling);
// }
// } else {
// for (int i = childPos + 1; parentGroup.getChildCount() > i; i++) {
// View sibling = parentGroup.getChildAt(i);
// if (matchesView(sibling)) {
// result.add(sibling);
// }
// }
// }
// }
//
// private boolean matchesView(View view) {
// return matchPredicate.matches(view);
// }
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractClassCheckerTest.java
import org.junit.Test;
import se.fishtank.css.selectors.Selector;
import se.fishtank.css.selectors.Selector.Combinator;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nikhaldimann.viewselector.checker.ClassChecker;
import com.nikhaldimann.viewselector.selection.ViewSelection;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase;
package com.nikhaldimann.viewselector.test.abstrakt.checker;
public abstract class AbstractClassCheckerTest extends ViewSelectorAndroidTestCase {
private Iterable<View> check(String selectorTag, Combinator combinator, View view) {
Selector selector = new Selector(selectorTag, combinator);
ClassChecker checker = new ClassChecker(selector, view); | ViewSelection selection = new ViewSelection(); |
nikhaldi/android-view-selector | src/android-test/src/com/nikhaldimann/viewselector/android/ViewSelectorAssertionsTest.java | // Path: src/android-test/src/com/nikhaldimann/viewselector/android/testutil/AndroidTestViewFactory.java
// public class AndroidTestViewFactory extends ProvidedContextViewFactory {
//
// public AndroidTestViewFactory(Context context) {
// super(context);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java
// public abstract class AbstractViewSelectorAssertionsTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAssertThat() {
// TextView view = viewFactory.createTextView();
// assertThat(selection("TextView", view))
// .hasSize(1)
// .startsWith(view)
// .endsWith(view);
// }
//
// @Test
// public void testFailingAssertThat() {
// try {
// assertThat(selection("TextView", viewFactory.createTextView())).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testAssertThatSelection() {
// assertThatSelection("TextView", viewFactory.createTextView()).hasSize(1);
// }
//
// @Test
// public void testFailingAssertThatSelection() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView()).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testExtractAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// assertThat(extractAttribute("text").from(selection("TextView", view)))
// .containsExactly("foo");
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import com.nikhaldimann.viewselector.android.testutil.AndroidTestViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectorAssertionsTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory; | package com.nikhaldimann.viewselector.android;
public class ViewSelectorAssertionsTest extends AbstractViewSelectorAssertionsTest {
protected ViewFactory createViewFactory() { | // Path: src/android-test/src/com/nikhaldimann/viewselector/android/testutil/AndroidTestViewFactory.java
// public class AndroidTestViewFactory extends ProvidedContextViewFactory {
//
// public AndroidTestViewFactory(Context context) {
// super(context);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java
// public abstract class AbstractViewSelectorAssertionsTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAssertThat() {
// TextView view = viewFactory.createTextView();
// assertThat(selection("TextView", view))
// .hasSize(1)
// .startsWith(view)
// .endsWith(view);
// }
//
// @Test
// public void testFailingAssertThat() {
// try {
// assertThat(selection("TextView", viewFactory.createTextView())).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testAssertThatSelection() {
// assertThatSelection("TextView", viewFactory.createTextView()).hasSize(1);
// }
//
// @Test
// public void testFailingAssertThatSelection() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView()).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testExtractAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// assertThat(extractAttribute("text").from(selection("TextView", view)))
// .containsExactly("foo");
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/android-test/src/com/nikhaldimann/viewselector/android/ViewSelectorAssertionsTest.java
import com.nikhaldimann.viewselector.android.testutil.AndroidTestViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectorAssertionsTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
package com.nikhaldimann.viewselector.android;
public class ViewSelectorAssertionsTest extends AbstractViewSelectorAssertionsTest {
protected ViewFactory createViewFactory() { | return new AndroidTestViewFactory(getContext()); |
nikhaldi/android-view-selector | src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/checker/AttributeSpecifierCheckerTest.java | // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractAttributeSpecifierCheckerTest.java
// public abstract class AbstractAttributeSpecifierCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> checkExistence(String name, View view) {
// return check(new AttributeSpecifier(name), view);
// }
//
// private Iterable<View> check(String name, String value, Match match, View view) {
// return check(new AttributeSpecifier(name, value, match), view);
// }
//
// private Iterable<View> check(AttributeSpecifier specifier, View view) {
// AttributeSpecifierChecker checker = new AttributeSpecifierChecker(specifier, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testAttributeExistence() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(checkExistence("tag", view));
// assertContentsInOrder(checkExistence("text", view), view);
// assertContentsInOrder(checkExistence("width", view), view);
// assertContentsInOrder(checkExistence("foo", view));
// }
//
// @Test
// public void testExactMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertContentsInOrder(check("tag", "foo", Match.EXACT, view), view);
// assertContentsInOrder(check("tag", "bar", Match.EXACT, view));
// assertContentsInOrder(check("gobbledygook", "bar", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithNumbers() {
// TextView view = viewFactory.createTextView();
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// assertContentsInOrder(
// check("inputType", String.valueOf(InputType.TYPE_CLASS_TEXT), Match.EXACT, view),
// view);
// assertContentsInOrder(check("inputType", "42", Match.EXACT, view));
// assertContentsInOrder(check("inputType", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithBooleans() {
// TextView view = viewFactory.createTextView();
// view.setVisibility(View.INVISIBLE);
// assertContentsInOrder(check("isShown", "false", Match.EXACT, view), view);
// assertContentsInOrder(check("isShown", "true", Match.EXACT, view));
// assertContentsInOrder(check("isShown", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testContainsMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "oba", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "baar", Match.CONTAINS, view));
// assertContentsInOrder(check("isShown", "foo", Match.CONTAINS, view));
// }
//
// @Test
// public void testPrefixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "foob", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foe", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foobare", Match.PREFIX, view));
// assertContentsInOrder(check("isShown", "foo", Match.PREFIX, view));
// }
//
// @Test
// public void testSuffixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "r", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "a foobar", Match.SUFFIX, view));
// assertContentsInOrder(check("tag", "foo", Match.SUFFIX, view));
// assertContentsInOrder(check("isShown", "false", Match.SUFFIX, view));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractAttributeSpecifierCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric.checker;
@RunWith(RobolectricTestRunner.class)
public class AttributeSpecifierCheckerTest extends AbstractAttributeSpecifierCheckerTest {
| // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractAttributeSpecifierCheckerTest.java
// public abstract class AbstractAttributeSpecifierCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> checkExistence(String name, View view) {
// return check(new AttributeSpecifier(name), view);
// }
//
// private Iterable<View> check(String name, String value, Match match, View view) {
// return check(new AttributeSpecifier(name, value, match), view);
// }
//
// private Iterable<View> check(AttributeSpecifier specifier, View view) {
// AttributeSpecifierChecker checker = new AttributeSpecifierChecker(specifier, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testAttributeExistence() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(checkExistence("tag", view));
// assertContentsInOrder(checkExistence("text", view), view);
// assertContentsInOrder(checkExistence("width", view), view);
// assertContentsInOrder(checkExistence("foo", view));
// }
//
// @Test
// public void testExactMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertContentsInOrder(check("tag", "foo", Match.EXACT, view), view);
// assertContentsInOrder(check("tag", "bar", Match.EXACT, view));
// assertContentsInOrder(check("gobbledygook", "bar", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithNumbers() {
// TextView view = viewFactory.createTextView();
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// assertContentsInOrder(
// check("inputType", String.valueOf(InputType.TYPE_CLASS_TEXT), Match.EXACT, view),
// view);
// assertContentsInOrder(check("inputType", "42", Match.EXACT, view));
// assertContentsInOrder(check("inputType", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithBooleans() {
// TextView view = viewFactory.createTextView();
// view.setVisibility(View.INVISIBLE);
// assertContentsInOrder(check("isShown", "false", Match.EXACT, view), view);
// assertContentsInOrder(check("isShown", "true", Match.EXACT, view));
// assertContentsInOrder(check("isShown", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testContainsMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "oba", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "baar", Match.CONTAINS, view));
// assertContentsInOrder(check("isShown", "foo", Match.CONTAINS, view));
// }
//
// @Test
// public void testPrefixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "foob", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foe", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foobare", Match.PREFIX, view));
// assertContentsInOrder(check("isShown", "foo", Match.PREFIX, view));
// }
//
// @Test
// public void testSuffixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "r", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "a foobar", Match.SUFFIX, view));
// assertContentsInOrder(check("tag", "foo", Match.SUFFIX, view));
// assertContentsInOrder(check("isShown", "false", Match.SUFFIX, view));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/checker/AttributeSpecifierCheckerTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractAttributeSpecifierCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric.checker;
@RunWith(RobolectricTestRunner.class)
public class AttributeSpecifierCheckerTest extends AbstractAttributeSpecifierCheckerTest {
| protected ViewFactory createViewFactory() { |
nikhaldi/android-view-selector | src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/checker/AttributeSpecifierCheckerTest.java | // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractAttributeSpecifierCheckerTest.java
// public abstract class AbstractAttributeSpecifierCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> checkExistence(String name, View view) {
// return check(new AttributeSpecifier(name), view);
// }
//
// private Iterable<View> check(String name, String value, Match match, View view) {
// return check(new AttributeSpecifier(name, value, match), view);
// }
//
// private Iterable<View> check(AttributeSpecifier specifier, View view) {
// AttributeSpecifierChecker checker = new AttributeSpecifierChecker(specifier, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testAttributeExistence() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(checkExistence("tag", view));
// assertContentsInOrder(checkExistence("text", view), view);
// assertContentsInOrder(checkExistence("width", view), view);
// assertContentsInOrder(checkExistence("foo", view));
// }
//
// @Test
// public void testExactMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertContentsInOrder(check("tag", "foo", Match.EXACT, view), view);
// assertContentsInOrder(check("tag", "bar", Match.EXACT, view));
// assertContentsInOrder(check("gobbledygook", "bar", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithNumbers() {
// TextView view = viewFactory.createTextView();
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// assertContentsInOrder(
// check("inputType", String.valueOf(InputType.TYPE_CLASS_TEXT), Match.EXACT, view),
// view);
// assertContentsInOrder(check("inputType", "42", Match.EXACT, view));
// assertContentsInOrder(check("inputType", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithBooleans() {
// TextView view = viewFactory.createTextView();
// view.setVisibility(View.INVISIBLE);
// assertContentsInOrder(check("isShown", "false", Match.EXACT, view), view);
// assertContentsInOrder(check("isShown", "true", Match.EXACT, view));
// assertContentsInOrder(check("isShown", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testContainsMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "oba", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "baar", Match.CONTAINS, view));
// assertContentsInOrder(check("isShown", "foo", Match.CONTAINS, view));
// }
//
// @Test
// public void testPrefixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "foob", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foe", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foobare", Match.PREFIX, view));
// assertContentsInOrder(check("isShown", "foo", Match.PREFIX, view));
// }
//
// @Test
// public void testSuffixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "r", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "a foobar", Match.SUFFIX, view));
// assertContentsInOrder(check("tag", "foo", Match.SUFFIX, view));
// assertContentsInOrder(check("isShown", "false", Match.SUFFIX, view));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractAttributeSpecifierCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric.checker;
@RunWith(RobolectricTestRunner.class)
public class AttributeSpecifierCheckerTest extends AbstractAttributeSpecifierCheckerTest {
protected ViewFactory createViewFactory() { | // Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/testutil/RobolectricViewFactory.java
// public class RobolectricViewFactory extends ProvidedContextViewFactory {
//
// public RobolectricViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractAttributeSpecifierCheckerTest.java
// public abstract class AbstractAttributeSpecifierCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> checkExistence(String name, View view) {
// return check(new AttributeSpecifier(name), view);
// }
//
// private Iterable<View> check(String name, String value, Match match, View view) {
// return check(new AttributeSpecifier(name, value, match), view);
// }
//
// private Iterable<View> check(AttributeSpecifier specifier, View view) {
// AttributeSpecifierChecker checker = new AttributeSpecifierChecker(specifier, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testAttributeExistence() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(checkExistence("tag", view));
// assertContentsInOrder(checkExistence("text", view), view);
// assertContentsInOrder(checkExistence("width", view), view);
// assertContentsInOrder(checkExistence("foo", view));
// }
//
// @Test
// public void testExactMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foo");
// assertContentsInOrder(check("tag", "foo", Match.EXACT, view), view);
// assertContentsInOrder(check("tag", "bar", Match.EXACT, view));
// assertContentsInOrder(check("gobbledygook", "bar", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithNumbers() {
// TextView view = viewFactory.createTextView();
// view.setInputType(InputType.TYPE_CLASS_TEXT);
// assertContentsInOrder(
// check("inputType", String.valueOf(InputType.TYPE_CLASS_TEXT), Match.EXACT, view),
// view);
// assertContentsInOrder(check("inputType", "42", Match.EXACT, view));
// assertContentsInOrder(check("inputType", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testExactMatchWithBooleans() {
// TextView view = viewFactory.createTextView();
// view.setVisibility(View.INVISIBLE);
// assertContentsInOrder(check("isShown", "false", Match.EXACT, view), view);
// assertContentsInOrder(check("isShown", "true", Match.EXACT, view));
// assertContentsInOrder(check("isShown", "foo", Match.EXACT, view));
// }
//
// @Test
// public void testContainsMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "oba", Match.CONTAINS, view), view);
// assertContentsInOrder(check("tag", "baar", Match.CONTAINS, view));
// assertContentsInOrder(check("isShown", "foo", Match.CONTAINS, view));
// }
//
// @Test
// public void testPrefixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "f", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "foob", Match.PREFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foe", Match.PREFIX, view));
// assertContentsInOrder(check("tag", "foobare", Match.PREFIX, view));
// assertContentsInOrder(check("isShown", "foo", Match.PREFIX, view));
// }
//
// @Test
// public void testSuffixMatch() {
// TextView view = viewFactory.createTextView();
// view.setTag("foobar");
// assertContentsInOrder(check("tag", "r", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "bar", Match.SUFFIX, view), view);
// assertContentsInOrder(check("tag", "a foobar", Match.SUFFIX, view));
// assertContentsInOrder(check("tag", "foo", Match.SUFFIX, view));
// assertContentsInOrder(check("isShown", "false", Match.SUFFIX, view));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/checker/AttributeSpecifierCheckerTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric.testutil.RobolectricViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractAttributeSpecifierCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import com.xtremelabs.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric.checker;
@RunWith(RobolectricTestRunner.class)
public class AttributeSpecifierCheckerTest extends AbstractAttributeSpecifierCheckerTest {
protected ViewFactory createViewFactory() { | return new RobolectricViewFactory(); |
nikhaldi/android-view-selector | src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThat(ViewSelection actual) {
// return new ViewSelectionAssert(actual);
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static Attributes extractAttribute(String attributeName) {
// return new Attributes(attributeName);
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelection selection(String selector, Activity activity) {
// return selection(selector, activity.findViewById(android.R.id.content));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
| import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThat;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.extractAttribute;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.selection;
import org.junit.Test;
import android.widget.TextView;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase; | package com.nikhaldimann.viewselector.test.abstrakt;
public abstract class AbstractViewSelectorAssertionsTest extends ViewSelectorAndroidTestCase {
/**
* Fails with a RuntimeException, so we can distinguish this from planned
* assertion failures.
*/
private void failHard() {
throw new RuntimeException("Failed to cause an assertion failure");
}
@Test
public void testAssertThat() {
TextView view = viewFactory.createTextView(); | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThat(ViewSelection actual) {
// return new ViewSelectionAssert(actual);
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static Attributes extractAttribute(String attributeName) {
// return new Attributes(attributeName);
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelection selection(String selector, Activity activity) {
// return selection(selector, activity.findViewById(android.R.id.content));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThat;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.extractAttribute;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.selection;
import org.junit.Test;
import android.widget.TextView;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase;
package com.nikhaldimann.viewselector.test.abstrakt;
public abstract class AbstractViewSelectorAssertionsTest extends ViewSelectorAndroidTestCase {
/**
* Fails with a RuntimeException, so we can distinguish this from planned
* assertion failures.
*/
private void failHard() {
throw new RuntimeException("Failed to cause an assertion failure");
}
@Test
public void testAssertThat() {
TextView view = viewFactory.createTextView(); | assertThat(selection("TextView", view)) |
nikhaldi/android-view-selector | src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThat(ViewSelection actual) {
// return new ViewSelectionAssert(actual);
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static Attributes extractAttribute(String attributeName) {
// return new Attributes(attributeName);
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelection selection(String selector, Activity activity) {
// return selection(selector, activity.findViewById(android.R.id.content));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
| import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThat;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.extractAttribute;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.selection;
import org.junit.Test;
import android.widget.TextView;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase; | package com.nikhaldimann.viewselector.test.abstrakt;
public abstract class AbstractViewSelectorAssertionsTest extends ViewSelectorAndroidTestCase {
/**
* Fails with a RuntimeException, so we can distinguish this from planned
* assertion failures.
*/
private void failHard() {
throw new RuntimeException("Failed to cause an assertion failure");
}
@Test
public void testAssertThat() {
TextView view = viewFactory.createTextView(); | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThat(ViewSelection actual) {
// return new ViewSelectionAssert(actual);
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static Attributes extractAttribute(String attributeName) {
// return new Attributes(attributeName);
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelection selection(String selector, Activity activity) {
// return selection(selector, activity.findViewById(android.R.id.content));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThat;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.extractAttribute;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.selection;
import org.junit.Test;
import android.widget.TextView;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase;
package com.nikhaldimann.viewselector.test.abstrakt;
public abstract class AbstractViewSelectorAssertionsTest extends ViewSelectorAndroidTestCase {
/**
* Fails with a RuntimeException, so we can distinguish this from planned
* assertion failures.
*/
private void failHard() {
throw new RuntimeException("Failed to cause an assertion failure");
}
@Test
public void testAssertThat() {
TextView view = viewFactory.createTextView(); | assertThat(selection("TextView", view)) |
nikhaldi/android-view-selector | src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThat(ViewSelection actual) {
// return new ViewSelectionAssert(actual);
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static Attributes extractAttribute(String attributeName) {
// return new Attributes(attributeName);
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelection selection(String selector, Activity activity) {
// return selection(selector, activity.findViewById(android.R.id.content));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
| import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThat;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.extractAttribute;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.selection;
import org.junit.Test;
import android.widget.TextView;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase; | package com.nikhaldimann.viewselector.test.abstrakt;
public abstract class AbstractViewSelectorAssertionsTest extends ViewSelectorAndroidTestCase {
/**
* Fails with a RuntimeException, so we can distinguish this from planned
* assertion failures.
*/
private void failHard() {
throw new RuntimeException("Failed to cause an assertion failure");
}
@Test
public void testAssertThat() {
TextView view = viewFactory.createTextView();
assertThat(selection("TextView", view))
.hasSize(1)
.startsWith(view)
.endsWith(view);
}
@Test
public void testFailingAssertThat() {
try {
assertThat(selection("TextView", viewFactory.createTextView())).isEmpty();
failHard();
} catch (AssertionError ex) {
// expected
}
}
@Test
public void testAssertThatSelection() { | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThat(ViewSelection actual) {
// return new ViewSelectionAssert(actual);
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static Attributes extractAttribute(String attributeName) {
// return new Attributes(attributeName);
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelection selection(String selector, Activity activity) {
// return selection(selector, activity.findViewById(android.R.id.content));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThat;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.extractAttribute;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.selection;
import org.junit.Test;
import android.widget.TextView;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase;
package com.nikhaldimann.viewselector.test.abstrakt;
public abstract class AbstractViewSelectorAssertionsTest extends ViewSelectorAndroidTestCase {
/**
* Fails with a RuntimeException, so we can distinguish this from planned
* assertion failures.
*/
private void failHard() {
throw new RuntimeException("Failed to cause an assertion failure");
}
@Test
public void testAssertThat() {
TextView view = viewFactory.createTextView();
assertThat(selection("TextView", view))
.hasSize(1)
.startsWith(view)
.endsWith(view);
}
@Test
public void testFailingAssertThat() {
try {
assertThat(selection("TextView", viewFactory.createTextView())).isEmpty();
failHard();
} catch (AssertionError ex) {
// expected
}
}
@Test
public void testAssertThatSelection() { | assertThatSelection("TextView", viewFactory.createTextView()).hasSize(1); |
nikhaldi/android-view-selector | src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThat(ViewSelection actual) {
// return new ViewSelectionAssert(actual);
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static Attributes extractAttribute(String attributeName) {
// return new Attributes(attributeName);
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelection selection(String selector, Activity activity) {
// return selection(selector, activity.findViewById(android.R.id.content));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
| import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThat;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.extractAttribute;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.selection;
import org.junit.Test;
import android.widget.TextView;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase; |
@Test
public void testFailingAssertThat() {
try {
assertThat(selection("TextView", viewFactory.createTextView())).isEmpty();
failHard();
} catch (AssertionError ex) {
// expected
}
}
@Test
public void testAssertThatSelection() {
assertThatSelection("TextView", viewFactory.createTextView()).hasSize(1);
}
@Test
public void testFailingAssertThatSelection() {
try {
assertThatSelection("TextView", viewFactory.createTextView()).isEmpty();
failHard();
} catch (AssertionError ex) {
// expected
}
}
@Test
public void testExtractAttribute() {
TextView view = viewFactory.createTextView();
view.setText("foo"); | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThat(ViewSelection actual) {
// return new ViewSelectionAssert(actual);
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static Attributes extractAttribute(String attributeName) {
// return new Attributes(attributeName);
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelection selection(String selector, Activity activity) {
// return selection(selector, activity.findViewById(android.R.id.content));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThat;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.extractAttribute;
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.selection;
import org.junit.Test;
import android.widget.TextView;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase;
@Test
public void testFailingAssertThat() {
try {
assertThat(selection("TextView", viewFactory.createTextView())).isEmpty();
failHard();
} catch (AssertionError ex) {
// expected
}
}
@Test
public void testAssertThatSelection() {
assertThatSelection("TextView", viewFactory.createTextView()).hasSize(1);
}
@Test
public void testFailingAssertThatSelection() {
try {
assertThatSelection("TextView", viewFactory.createTextView()).isEmpty();
failHard();
} catch (AssertionError ex) {
// expected
}
}
@Test
public void testExtractAttribute() {
TextView view = viewFactory.createTextView();
view.setText("foo"); | assertThat(extractAttribute("text").from(selection("TextView", view))) |
nikhaldi/android-view-selector | src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/ViewSelectorAssertionsTest.java | // Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/testutil/Robolectric2ViewFactory.java
// public class Robolectric2ViewFactory extends ProvidedContextViewFactory {
//
// public Robolectric2ViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java
// public abstract class AbstractViewSelectorAssertionsTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAssertThat() {
// TextView view = viewFactory.createTextView();
// assertThat(selection("TextView", view))
// .hasSize(1)
// .startsWith(view)
// .endsWith(view);
// }
//
// @Test
// public void testFailingAssertThat() {
// try {
// assertThat(selection("TextView", viewFactory.createTextView())).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testAssertThatSelection() {
// assertThatSelection("TextView", viewFactory.createTextView()).hasSize(1);
// }
//
// @Test
// public void testFailingAssertThatSelection() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView()).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testExtractAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// assertThat(extractAttribute("text").from(selection("TextView", view)))
// .containsExactly("foo");
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric2.testutil.Robolectric2ViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectorAssertionsTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import org.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric2;
@RunWith(RobolectricTestRunner.class)
public class ViewSelectorAssertionsTest extends AbstractViewSelectorAssertionsTest {
| // Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/testutil/Robolectric2ViewFactory.java
// public class Robolectric2ViewFactory extends ProvidedContextViewFactory {
//
// public Robolectric2ViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java
// public abstract class AbstractViewSelectorAssertionsTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAssertThat() {
// TextView view = viewFactory.createTextView();
// assertThat(selection("TextView", view))
// .hasSize(1)
// .startsWith(view)
// .endsWith(view);
// }
//
// @Test
// public void testFailingAssertThat() {
// try {
// assertThat(selection("TextView", viewFactory.createTextView())).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testAssertThatSelection() {
// assertThatSelection("TextView", viewFactory.createTextView()).hasSize(1);
// }
//
// @Test
// public void testFailingAssertThatSelection() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView()).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testExtractAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// assertThat(extractAttribute("text").from(selection("TextView", view)))
// .containsExactly("foo");
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/ViewSelectorAssertionsTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric2.testutil.Robolectric2ViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectorAssertionsTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import org.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric2;
@RunWith(RobolectricTestRunner.class)
public class ViewSelectorAssertionsTest extends AbstractViewSelectorAssertionsTest {
| protected ViewFactory createViewFactory() { |
nikhaldi/android-view-selector | src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/ViewSelectorAssertionsTest.java | // Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/testutil/Robolectric2ViewFactory.java
// public class Robolectric2ViewFactory extends ProvidedContextViewFactory {
//
// public Robolectric2ViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java
// public abstract class AbstractViewSelectorAssertionsTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAssertThat() {
// TextView view = viewFactory.createTextView();
// assertThat(selection("TextView", view))
// .hasSize(1)
// .startsWith(view)
// .endsWith(view);
// }
//
// @Test
// public void testFailingAssertThat() {
// try {
// assertThat(selection("TextView", viewFactory.createTextView())).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testAssertThatSelection() {
// assertThatSelection("TextView", viewFactory.createTextView()).hasSize(1);
// }
//
// @Test
// public void testFailingAssertThatSelection() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView()).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testExtractAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// assertThat(extractAttribute("text").from(selection("TextView", view)))
// .containsExactly("foo");
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric2.testutil.Robolectric2ViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectorAssertionsTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import org.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric2;
@RunWith(RobolectricTestRunner.class)
public class ViewSelectorAssertionsTest extends AbstractViewSelectorAssertionsTest {
protected ViewFactory createViewFactory() { | // Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/testutil/Robolectric2ViewFactory.java
// public class Robolectric2ViewFactory extends ProvidedContextViewFactory {
//
// public Robolectric2ViewFactory() {
// super(Robolectric.application);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorAssertionsTest.java
// public abstract class AbstractViewSelectorAssertionsTest extends ViewSelectorAndroidTestCase {
//
// /**
// * Fails with a RuntimeException, so we can distinguish this from planned
// * assertion failures.
// */
// private void failHard() {
// throw new RuntimeException("Failed to cause an assertion failure");
// }
//
// @Test
// public void testAssertThat() {
// TextView view = viewFactory.createTextView();
// assertThat(selection("TextView", view))
// .hasSize(1)
// .startsWith(view)
// .endsWith(view);
// }
//
// @Test
// public void testFailingAssertThat() {
// try {
// assertThat(selection("TextView", viewFactory.createTextView())).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testAssertThatSelection() {
// assertThatSelection("TextView", viewFactory.createTextView()).hasSize(1);
// }
//
// @Test
// public void testFailingAssertThatSelection() {
// try {
// assertThatSelection("TextView", viewFactory.createTextView()).isEmpty();
// failHard();
// } catch (AssertionError ex) {
// // expected
// }
// }
//
// @Test
// public void testExtractAttribute() {
// TextView view = viewFactory.createTextView();
// view.setText("foo");
// assertThat(extractAttribute("text").from(selection("TextView", view)))
// .containsExactly("foo");
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/robolectric2-test/test/com/nikhaldimann/viewselector/robolectric2/ViewSelectorAssertionsTest.java
import org.junit.runner.RunWith;
import com.nikhaldimann.viewselector.robolectric2.testutil.Robolectric2ViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.AbstractViewSelectorAssertionsTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
import org.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric2;
@RunWith(RobolectricTestRunner.class)
public class ViewSelectorAssertionsTest extends AbstractViewSelectorAssertionsTest {
protected ViewFactory createViewFactory() { | return new Robolectric2ViewFactory(); |
nikhaldi/android-view-selector | src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/attributes/AbstractViewAttributesTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/AttributeAccessException.java
// public class AttributeAccessException extends RuntimeException {
//
// public AttributeAccessException(Exception cause) {
// super(cause);
// }
//
// public AttributeAccessException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewAttributes.java
// public class ViewAttributes {
//
// private ViewAttributes() { }
//
// /**
// * @return the full getter method name for a plain attribute, following conventions
// * used in the Android code. Prepends "get" to the attribute name and formats
// * it in camel-case. Recognizes boolean attributes of the format {@code isFoo} or
// * {@code hasFoo} and returns them unchanged.
// */
// public static String getGetterMethodName(String attributeName) {
// if (isBooleanAttribute(attributeName, "is") || isBooleanAttribute(attributeName, "has")) {
// return attributeName;
// }
// return "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1);
// }
//
// private static boolean isBooleanAttribute(String attributeName, String prefix) {
// return attributeName.startsWith(prefix)
// && attributeName.length() > prefix.length()
// && Character.isUpperCase(attributeName.charAt(prefix.length()));
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetter(View view, String methodName) {
// try {
// Method method = view.getClass().getMethod(methodName);
// return method.invoke(view);
// } catch (SecurityException ex) {
// throw new AttributeAccessException(ex);
// } catch (NoSuchMethodException ex) {
// throw new AttributeAccessException("No such attribute", ex);
// } catch (IllegalAccessException ex) {
// throw new AttributeAccessException(ex);
// } catch (InvocationTargetException ex) {
// throw new AttributeAccessException(ex);
// }
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// *
// * This method normalizes all instances of CharSequences to be instances of String.
// * This is useful because Android is using some CharSequence representations
// * internally that don't compare well with strings (in particular as returned
// * from TextView.getText()).
// *
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetterNormalizingStrings(View view, String methodName) {
// Object value = callGetter(view, methodName);
// if (value instanceof CharSequence) {
// value = value.toString();
// }
// return value;
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
| import org.junit.Test;
import android.text.InputType;
import android.view.View;
import android.widget.TextView;
import com.nikhaldimann.viewselector.attributes.AttributeAccessException;
import com.nikhaldimann.viewselector.attributes.ViewAttributes;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase; | package com.nikhaldimann.viewselector.test.abstrakt.attributes;
public abstract class AbstractViewAttributesTest extends ViewSelectorAndroidTestCase {
@Test
public void testGetGetterMethodName() { | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/AttributeAccessException.java
// public class AttributeAccessException extends RuntimeException {
//
// public AttributeAccessException(Exception cause) {
// super(cause);
// }
//
// public AttributeAccessException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewAttributes.java
// public class ViewAttributes {
//
// private ViewAttributes() { }
//
// /**
// * @return the full getter method name for a plain attribute, following conventions
// * used in the Android code. Prepends "get" to the attribute name and formats
// * it in camel-case. Recognizes boolean attributes of the format {@code isFoo} or
// * {@code hasFoo} and returns them unchanged.
// */
// public static String getGetterMethodName(String attributeName) {
// if (isBooleanAttribute(attributeName, "is") || isBooleanAttribute(attributeName, "has")) {
// return attributeName;
// }
// return "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1);
// }
//
// private static boolean isBooleanAttribute(String attributeName, String prefix) {
// return attributeName.startsWith(prefix)
// && attributeName.length() > prefix.length()
// && Character.isUpperCase(attributeName.charAt(prefix.length()));
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetter(View view, String methodName) {
// try {
// Method method = view.getClass().getMethod(methodName);
// return method.invoke(view);
// } catch (SecurityException ex) {
// throw new AttributeAccessException(ex);
// } catch (NoSuchMethodException ex) {
// throw new AttributeAccessException("No such attribute", ex);
// } catch (IllegalAccessException ex) {
// throw new AttributeAccessException(ex);
// } catch (InvocationTargetException ex) {
// throw new AttributeAccessException(ex);
// }
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// *
// * This method normalizes all instances of CharSequences to be instances of String.
// * This is useful because Android is using some CharSequence representations
// * internally that don't compare well with strings (in particular as returned
// * from TextView.getText()).
// *
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetterNormalizingStrings(View view, String methodName) {
// Object value = callGetter(view, methodName);
// if (value instanceof CharSequence) {
// value = value.toString();
// }
// return value;
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/attributes/AbstractViewAttributesTest.java
import org.junit.Test;
import android.text.InputType;
import android.view.View;
import android.widget.TextView;
import com.nikhaldimann.viewselector.attributes.AttributeAccessException;
import com.nikhaldimann.viewselector.attributes.ViewAttributes;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase;
package com.nikhaldimann.viewselector.test.abstrakt.attributes;
public abstract class AbstractViewAttributesTest extends ViewSelectorAndroidTestCase {
@Test
public void testGetGetterMethodName() { | assertEquals("getText", ViewAttributes.getGetterMethodName("text")); |
nikhaldi/android-view-selector | src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/attributes/AbstractViewAttributesTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/AttributeAccessException.java
// public class AttributeAccessException extends RuntimeException {
//
// public AttributeAccessException(Exception cause) {
// super(cause);
// }
//
// public AttributeAccessException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewAttributes.java
// public class ViewAttributes {
//
// private ViewAttributes() { }
//
// /**
// * @return the full getter method name for a plain attribute, following conventions
// * used in the Android code. Prepends "get" to the attribute name and formats
// * it in camel-case. Recognizes boolean attributes of the format {@code isFoo} or
// * {@code hasFoo} and returns them unchanged.
// */
// public static String getGetterMethodName(String attributeName) {
// if (isBooleanAttribute(attributeName, "is") || isBooleanAttribute(attributeName, "has")) {
// return attributeName;
// }
// return "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1);
// }
//
// private static boolean isBooleanAttribute(String attributeName, String prefix) {
// return attributeName.startsWith(prefix)
// && attributeName.length() > prefix.length()
// && Character.isUpperCase(attributeName.charAt(prefix.length()));
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetter(View view, String methodName) {
// try {
// Method method = view.getClass().getMethod(methodName);
// return method.invoke(view);
// } catch (SecurityException ex) {
// throw new AttributeAccessException(ex);
// } catch (NoSuchMethodException ex) {
// throw new AttributeAccessException("No such attribute", ex);
// } catch (IllegalAccessException ex) {
// throw new AttributeAccessException(ex);
// } catch (InvocationTargetException ex) {
// throw new AttributeAccessException(ex);
// }
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// *
// * This method normalizes all instances of CharSequences to be instances of String.
// * This is useful because Android is using some CharSequence representations
// * internally that don't compare well with strings (in particular as returned
// * from TextView.getText()).
// *
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetterNormalizingStrings(View view, String methodName) {
// Object value = callGetter(view, methodName);
// if (value instanceof CharSequence) {
// value = value.toString();
// }
// return value;
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
| import org.junit.Test;
import android.text.InputType;
import android.view.View;
import android.widget.TextView;
import com.nikhaldimann.viewselector.attributes.AttributeAccessException;
import com.nikhaldimann.viewselector.attributes.ViewAttributes;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase; | }
@Test
public void testGetGetterMethodNameBooleanAttribute() {
assertEquals("isFoo", ViewAttributes.getGetterMethodName("isFoo"));
assertEquals("hasFoo", ViewAttributes.getGetterMethodName("hasFoo"));
assertEquals("getIs", ViewAttributes.getGetterMethodName("is"));
assertEquals("getIsland", ViewAttributes.getGetterMethodName("island"));
assertEquals("getHas", ViewAttributes.getGetterMethodName("has"));
assertEquals("getHash", ViewAttributes.getGetterMethodName("hash"));
}
@Test
public void testCallGetter() {
TextView view = viewFactory.createTextView();
view.setText("foo");
view.setInputType(InputType.TYPE_CLASS_TEXT);
view.setVisibility(View.INVISIBLE);
assertEquals("foo", ViewAttributes.callGetter(view, "getText").toString());
assertEquals(null, ViewAttributes.callGetter(view, "getTag"));
assertEquals(InputType.TYPE_CLASS_TEXT, ViewAttributes.callGetter(view, "getInputType"));
assertEquals(false, ViewAttributes.callGetter(view, "isShown"));
// TODO need to figure out how to deal with base class methods in Robolectric
}
@Test
public void testCallGetterNoSuchMethod() {
try {
ViewAttributes.callGetter(viewFactory.createTextView(), "getFoo");
fail(); | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/AttributeAccessException.java
// public class AttributeAccessException extends RuntimeException {
//
// public AttributeAccessException(Exception cause) {
// super(cause);
// }
//
// public AttributeAccessException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewAttributes.java
// public class ViewAttributes {
//
// private ViewAttributes() { }
//
// /**
// * @return the full getter method name for a plain attribute, following conventions
// * used in the Android code. Prepends "get" to the attribute name and formats
// * it in camel-case. Recognizes boolean attributes of the format {@code isFoo} or
// * {@code hasFoo} and returns them unchanged.
// */
// public static String getGetterMethodName(String attributeName) {
// if (isBooleanAttribute(attributeName, "is") || isBooleanAttribute(attributeName, "has")) {
// return attributeName;
// }
// return "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1);
// }
//
// private static boolean isBooleanAttribute(String attributeName, String prefix) {
// return attributeName.startsWith(prefix)
// && attributeName.length() > prefix.length()
// && Character.isUpperCase(attributeName.charAt(prefix.length()));
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetter(View view, String methodName) {
// try {
// Method method = view.getClass().getMethod(methodName);
// return method.invoke(view);
// } catch (SecurityException ex) {
// throw new AttributeAccessException(ex);
// } catch (NoSuchMethodException ex) {
// throw new AttributeAccessException("No such attribute", ex);
// } catch (IllegalAccessException ex) {
// throw new AttributeAccessException(ex);
// } catch (InvocationTargetException ex) {
// throw new AttributeAccessException(ex);
// }
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// *
// * This method normalizes all instances of CharSequences to be instances of String.
// * This is useful because Android is using some CharSequence representations
// * internally that don't compare well with strings (in particular as returned
// * from TextView.getText()).
// *
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetterNormalizingStrings(View view, String methodName) {
// Object value = callGetter(view, methodName);
// if (value instanceof CharSequence) {
// value = value.toString();
// }
// return value;
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
//
// protected ViewFactory viewFactory;
//
// @Before
// public void setUp() throws Exception {
// super.setUp();
// viewFactory = createViewFactory();
// }
//
// /**
// * @return the factory to be used for creating views in this test
// */
// protected abstract ViewFactory createViewFactory();
//
// /**
// * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
// * can't use MoreAsserts in Robolectric 1.2.
// */
// public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
// ArrayList<Object> actualList = new ArrayList<Object>();
// for (Object o : actual) {
// actualList.add(o);
// }
// assertEquals(Arrays.asList(expected), actualList);
// }
// }
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/attributes/AbstractViewAttributesTest.java
import org.junit.Test;
import android.text.InputType;
import android.view.View;
import android.widget.TextView;
import com.nikhaldimann.viewselector.attributes.AttributeAccessException;
import com.nikhaldimann.viewselector.attributes.ViewAttributes;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase;
}
@Test
public void testGetGetterMethodNameBooleanAttribute() {
assertEquals("isFoo", ViewAttributes.getGetterMethodName("isFoo"));
assertEquals("hasFoo", ViewAttributes.getGetterMethodName("hasFoo"));
assertEquals("getIs", ViewAttributes.getGetterMethodName("is"));
assertEquals("getIsland", ViewAttributes.getGetterMethodName("island"));
assertEquals("getHas", ViewAttributes.getGetterMethodName("has"));
assertEquals("getHash", ViewAttributes.getGetterMethodName("hash"));
}
@Test
public void testCallGetter() {
TextView view = viewFactory.createTextView();
view.setText("foo");
view.setInputType(InputType.TYPE_CLASS_TEXT);
view.setVisibility(View.INVISIBLE);
assertEquals("foo", ViewAttributes.callGetter(view, "getText").toString());
assertEquals(null, ViewAttributes.callGetter(view, "getTag"));
assertEquals(InputType.TYPE_CLASS_TEXT, ViewAttributes.callGetter(view, "getInputType"));
assertEquals(false, ViewAttributes.callGetter(view, "isShown"));
// TODO need to figure out how to deal with base class methods in Robolectric
}
@Test
public void testCallGetterNoSuchMethod() {
try {
ViewAttributes.callGetter(viewFactory.createTextView(), "getFoo");
fail(); | } catch (AttributeAccessException ex) { |
nikhaldi/android-view-selector | src/main/java/com/nikhaldimann/viewselector/Attributes.java | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewSelectionAttribute.java
// public class ViewSelectionAttribute extends ArrayList<Object> {
//
// public ViewSelectionAttribute() {
// super();
// }
//
// public ViewSelectionAttribute(ViewSelection selection, String attributeName) {
// super();
// String getterMethodName = ViewAttributes.getGetterMethodName(attributeName);
// for (View matched : selection) {
// add(ViewAttributes.callGetterNormalizingStrings(matched, getterMethodName));
// }
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
| import com.nikhaldimann.viewselector.attributes.ViewSelectionAttribute;
import com.nikhaldimann.viewselector.selection.ViewSelection; | package com.nikhaldimann.viewselector;
/**
* An attribute extractor, generally used via calling
* {@code ViewSelectorAssertions.extractAttribute(String)}.
*/
public class Attributes {
private final String attributeName;
public Attributes(String attributeName) {
this.attributeName = attributeName;
}
/**
* @param selection the selection to extract attributes from
* @return extracted attributes ready to make assertions about
*/ | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewSelectionAttribute.java
// public class ViewSelectionAttribute extends ArrayList<Object> {
//
// public ViewSelectionAttribute() {
// super();
// }
//
// public ViewSelectionAttribute(ViewSelection selection, String attributeName) {
// super();
// String getterMethodName = ViewAttributes.getGetterMethodName(attributeName);
// for (View matched : selection) {
// add(ViewAttributes.callGetterNormalizingStrings(matched, getterMethodName));
// }
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
// Path: src/main/java/com/nikhaldimann/viewselector/Attributes.java
import com.nikhaldimann.viewselector.attributes.ViewSelectionAttribute;
import com.nikhaldimann.viewselector.selection.ViewSelection;
package com.nikhaldimann.viewselector;
/**
* An attribute extractor, generally used via calling
* {@code ViewSelectorAssertions.extractAttribute(String)}.
*/
public class Attributes {
private final String attributeName;
public Attributes(String attributeName) {
this.attributeName = attributeName;
}
/**
* @param selection the selection to extract attributes from
* @return extracted attributes ready to make assertions about
*/ | public ViewSelectionAttribute from(ViewSelection selection) { |
nikhaldi/android-view-selector | src/main/java/com/nikhaldimann/viewselector/Attributes.java | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewSelectionAttribute.java
// public class ViewSelectionAttribute extends ArrayList<Object> {
//
// public ViewSelectionAttribute() {
// super();
// }
//
// public ViewSelectionAttribute(ViewSelection selection, String attributeName) {
// super();
// String getterMethodName = ViewAttributes.getGetterMethodName(attributeName);
// for (View matched : selection) {
// add(ViewAttributes.callGetterNormalizingStrings(matched, getterMethodName));
// }
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
| import com.nikhaldimann.viewselector.attributes.ViewSelectionAttribute;
import com.nikhaldimann.viewselector.selection.ViewSelection; | package com.nikhaldimann.viewselector;
/**
* An attribute extractor, generally used via calling
* {@code ViewSelectorAssertions.extractAttribute(String)}.
*/
public class Attributes {
private final String attributeName;
public Attributes(String attributeName) {
this.attributeName = attributeName;
}
/**
* @param selection the selection to extract attributes from
* @return extracted attributes ready to make assertions about
*/ | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewSelectionAttribute.java
// public class ViewSelectionAttribute extends ArrayList<Object> {
//
// public ViewSelectionAttribute() {
// super();
// }
//
// public ViewSelectionAttribute(ViewSelection selection, String attributeName) {
// super();
// String getterMethodName = ViewAttributes.getGetterMethodName(attributeName);
// for (View matched : selection) {
// add(ViewAttributes.callGetterNormalizingStrings(matched, getterMethodName));
// }
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
// Path: src/main/java/com/nikhaldimann/viewselector/Attributes.java
import com.nikhaldimann.viewselector.attributes.ViewSelectionAttribute;
import com.nikhaldimann.viewselector.selection.ViewSelection;
package com.nikhaldimann.viewselector;
/**
* An attribute extractor, generally used via calling
* {@code ViewSelectorAssertions.extractAttribute(String)}.
*/
public class Attributes {
private final String attributeName;
public Attributes(String attributeName) {
this.attributeName = attributeName;
}
/**
* @param selection the selection to extract attributes from
* @return extracted attributes ready to make assertions about
*/ | public ViewSelectionAttribute from(ViewSelection selection) { |
nikhaldi/android-view-selector | src/main/java/com/nikhaldimann/viewselector/checker/AttributeSpecifierChecker.java | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/AttributeAccessException.java
// public class AttributeAccessException extends RuntimeException {
//
// public AttributeAccessException(Exception cause) {
// super(cause);
// }
//
// public AttributeAccessException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewAttributes.java
// public class ViewAttributes {
//
// private ViewAttributes() { }
//
// /**
// * @return the full getter method name for a plain attribute, following conventions
// * used in the Android code. Prepends "get" to the attribute name and formats
// * it in camel-case. Recognizes boolean attributes of the format {@code isFoo} or
// * {@code hasFoo} and returns them unchanged.
// */
// public static String getGetterMethodName(String attributeName) {
// if (isBooleanAttribute(attributeName, "is") || isBooleanAttribute(attributeName, "has")) {
// return attributeName;
// }
// return "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1);
// }
//
// private static boolean isBooleanAttribute(String attributeName, String prefix) {
// return attributeName.startsWith(prefix)
// && attributeName.length() > prefix.length()
// && Character.isUpperCase(attributeName.charAt(prefix.length()));
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetter(View view, String methodName) {
// try {
// Method method = view.getClass().getMethod(methodName);
// return method.invoke(view);
// } catch (SecurityException ex) {
// throw new AttributeAccessException(ex);
// } catch (NoSuchMethodException ex) {
// throw new AttributeAccessException("No such attribute", ex);
// } catch (IllegalAccessException ex) {
// throw new AttributeAccessException(ex);
// } catch (InvocationTargetException ex) {
// throw new AttributeAccessException(ex);
// }
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// *
// * This method normalizes all instances of CharSequences to be instances of String.
// * This is useful because Android is using some CharSequence representations
// * internally that don't compare well with strings (in particular as returned
// * from TextView.getText()).
// *
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetterNormalizingStrings(View view, String methodName) {
// Object value = callGetter(view, methodName);
// if (value instanceof CharSequence) {
// value = value.toString();
// }
// return value;
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
| import java.util.Set;
import se.fishtank.css.selectors.specifier.AttributeSpecifier;
import android.view.View;
import com.nikhaldimann.viewselector.attributes.AttributeAccessException;
import com.nikhaldimann.viewselector.attributes.ViewAttributes;
import com.nikhaldimann.viewselector.selection.ViewSelection; | package com.nikhaldimann.viewselector.checker;
/**
* Checks views based on a selectors attribute specifier, handling all the
* attribute selection. Note that selection by id via a hash (e.g.,
* {@code TextView#foo}) is also translated to an attribute specifier.
*/
public class AttributeSpecifierChecker implements ViewTraversalChecker {
private static class ExactMatchPredicate implements MatchPredicate {
private final String methodName;
private final String value;
public ExactMatchPredicate(String methodName, String value) {
this.methodName = methodName;
this.value = value;
}
public boolean matches(View view) {
Object actualValue;
try { | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/AttributeAccessException.java
// public class AttributeAccessException extends RuntimeException {
//
// public AttributeAccessException(Exception cause) {
// super(cause);
// }
//
// public AttributeAccessException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewAttributes.java
// public class ViewAttributes {
//
// private ViewAttributes() { }
//
// /**
// * @return the full getter method name for a plain attribute, following conventions
// * used in the Android code. Prepends "get" to the attribute name and formats
// * it in camel-case. Recognizes boolean attributes of the format {@code isFoo} or
// * {@code hasFoo} and returns them unchanged.
// */
// public static String getGetterMethodName(String attributeName) {
// if (isBooleanAttribute(attributeName, "is") || isBooleanAttribute(attributeName, "has")) {
// return attributeName;
// }
// return "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1);
// }
//
// private static boolean isBooleanAttribute(String attributeName, String prefix) {
// return attributeName.startsWith(prefix)
// && attributeName.length() > prefix.length()
// && Character.isUpperCase(attributeName.charAt(prefix.length()));
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetter(View view, String methodName) {
// try {
// Method method = view.getClass().getMethod(methodName);
// return method.invoke(view);
// } catch (SecurityException ex) {
// throw new AttributeAccessException(ex);
// } catch (NoSuchMethodException ex) {
// throw new AttributeAccessException("No such attribute", ex);
// } catch (IllegalAccessException ex) {
// throw new AttributeAccessException(ex);
// } catch (InvocationTargetException ex) {
// throw new AttributeAccessException(ex);
// }
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// *
// * This method normalizes all instances of CharSequences to be instances of String.
// * This is useful because Android is using some CharSequence representations
// * internally that don't compare well with strings (in particular as returned
// * from TextView.getText()).
// *
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetterNormalizingStrings(View view, String methodName) {
// Object value = callGetter(view, methodName);
// if (value instanceof CharSequence) {
// value = value.toString();
// }
// return value;
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
// Path: src/main/java/com/nikhaldimann/viewselector/checker/AttributeSpecifierChecker.java
import java.util.Set;
import se.fishtank.css.selectors.specifier.AttributeSpecifier;
import android.view.View;
import com.nikhaldimann.viewselector.attributes.AttributeAccessException;
import com.nikhaldimann.viewselector.attributes.ViewAttributes;
import com.nikhaldimann.viewselector.selection.ViewSelection;
package com.nikhaldimann.viewselector.checker;
/**
* Checks views based on a selectors attribute specifier, handling all the
* attribute selection. Note that selection by id via a hash (e.g.,
* {@code TextView#foo}) is also translated to an attribute specifier.
*/
public class AttributeSpecifierChecker implements ViewTraversalChecker {
private static class ExactMatchPredicate implements MatchPredicate {
private final String methodName;
private final String value;
public ExactMatchPredicate(String methodName, String value) {
this.methodName = methodName;
this.value = value;
}
public boolean matches(View view) {
Object actualValue;
try { | actualValue = ViewAttributes.callGetterNormalizingStrings(view, methodName); |
nikhaldi/android-view-selector | src/main/java/com/nikhaldimann/viewselector/checker/AttributeSpecifierChecker.java | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/AttributeAccessException.java
// public class AttributeAccessException extends RuntimeException {
//
// public AttributeAccessException(Exception cause) {
// super(cause);
// }
//
// public AttributeAccessException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewAttributes.java
// public class ViewAttributes {
//
// private ViewAttributes() { }
//
// /**
// * @return the full getter method name for a plain attribute, following conventions
// * used in the Android code. Prepends "get" to the attribute name and formats
// * it in camel-case. Recognizes boolean attributes of the format {@code isFoo} or
// * {@code hasFoo} and returns them unchanged.
// */
// public static String getGetterMethodName(String attributeName) {
// if (isBooleanAttribute(attributeName, "is") || isBooleanAttribute(attributeName, "has")) {
// return attributeName;
// }
// return "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1);
// }
//
// private static boolean isBooleanAttribute(String attributeName, String prefix) {
// return attributeName.startsWith(prefix)
// && attributeName.length() > prefix.length()
// && Character.isUpperCase(attributeName.charAt(prefix.length()));
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetter(View view, String methodName) {
// try {
// Method method = view.getClass().getMethod(methodName);
// return method.invoke(view);
// } catch (SecurityException ex) {
// throw new AttributeAccessException(ex);
// } catch (NoSuchMethodException ex) {
// throw new AttributeAccessException("No such attribute", ex);
// } catch (IllegalAccessException ex) {
// throw new AttributeAccessException(ex);
// } catch (InvocationTargetException ex) {
// throw new AttributeAccessException(ex);
// }
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// *
// * This method normalizes all instances of CharSequences to be instances of String.
// * This is useful because Android is using some CharSequence representations
// * internally that don't compare well with strings (in particular as returned
// * from TextView.getText()).
// *
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetterNormalizingStrings(View view, String methodName) {
// Object value = callGetter(view, methodName);
// if (value instanceof CharSequence) {
// value = value.toString();
// }
// return value;
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
| import java.util.Set;
import se.fishtank.css.selectors.specifier.AttributeSpecifier;
import android.view.View;
import com.nikhaldimann.viewselector.attributes.AttributeAccessException;
import com.nikhaldimann.viewselector.attributes.ViewAttributes;
import com.nikhaldimann.viewselector.selection.ViewSelection; | package com.nikhaldimann.viewselector.checker;
/**
* Checks views based on a selectors attribute specifier, handling all the
* attribute selection. Note that selection by id via a hash (e.g.,
* {@code TextView#foo}) is also translated to an attribute specifier.
*/
public class AttributeSpecifierChecker implements ViewTraversalChecker {
private static class ExactMatchPredicate implements MatchPredicate {
private final String methodName;
private final String value;
public ExactMatchPredicate(String methodName, String value) {
this.methodName = methodName;
this.value = value;
}
public boolean matches(View view) {
Object actualValue;
try {
actualValue = ViewAttributes.callGetterNormalizingStrings(view, methodName); | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/AttributeAccessException.java
// public class AttributeAccessException extends RuntimeException {
//
// public AttributeAccessException(Exception cause) {
// super(cause);
// }
//
// public AttributeAccessException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewAttributes.java
// public class ViewAttributes {
//
// private ViewAttributes() { }
//
// /**
// * @return the full getter method name for a plain attribute, following conventions
// * used in the Android code. Prepends "get" to the attribute name and formats
// * it in camel-case. Recognizes boolean attributes of the format {@code isFoo} or
// * {@code hasFoo} and returns them unchanged.
// */
// public static String getGetterMethodName(String attributeName) {
// if (isBooleanAttribute(attributeName, "is") || isBooleanAttribute(attributeName, "has")) {
// return attributeName;
// }
// return "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1);
// }
//
// private static boolean isBooleanAttribute(String attributeName, String prefix) {
// return attributeName.startsWith(prefix)
// && attributeName.length() > prefix.length()
// && Character.isUpperCase(attributeName.charAt(prefix.length()));
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetter(View view, String methodName) {
// try {
// Method method = view.getClass().getMethod(methodName);
// return method.invoke(view);
// } catch (SecurityException ex) {
// throw new AttributeAccessException(ex);
// } catch (NoSuchMethodException ex) {
// throw new AttributeAccessException("No such attribute", ex);
// } catch (IllegalAccessException ex) {
// throw new AttributeAccessException(ex);
// } catch (InvocationTargetException ex) {
// throw new AttributeAccessException(ex);
// }
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// *
// * This method normalizes all instances of CharSequences to be instances of String.
// * This is useful because Android is using some CharSequence representations
// * internally that don't compare well with strings (in particular as returned
// * from TextView.getText()).
// *
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetterNormalizingStrings(View view, String methodName) {
// Object value = callGetter(view, methodName);
// if (value instanceof CharSequence) {
// value = value.toString();
// }
// return value;
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
// Path: src/main/java/com/nikhaldimann/viewselector/checker/AttributeSpecifierChecker.java
import java.util.Set;
import se.fishtank.css.selectors.specifier.AttributeSpecifier;
import android.view.View;
import com.nikhaldimann.viewselector.attributes.AttributeAccessException;
import com.nikhaldimann.viewselector.attributes.ViewAttributes;
import com.nikhaldimann.viewselector.selection.ViewSelection;
package com.nikhaldimann.viewselector.checker;
/**
* Checks views based on a selectors attribute specifier, handling all the
* attribute selection. Note that selection by id via a hash (e.g.,
* {@code TextView#foo}) is also translated to an attribute specifier.
*/
public class AttributeSpecifierChecker implements ViewTraversalChecker {
private static class ExactMatchPredicate implements MatchPredicate {
private final String methodName;
private final String value;
public ExactMatchPredicate(String methodName, String value) {
this.methodName = methodName;
this.value = value;
}
public boolean matches(View view) {
Object actualValue;
try {
actualValue = ViewAttributes.callGetterNormalizingStrings(view, methodName); | } catch (AttributeAccessException ex) { |
nikhaldi/android-view-selector | src/main/java/com/nikhaldimann/viewselector/checker/AttributeSpecifierChecker.java | // Path: src/main/java/com/nikhaldimann/viewselector/attributes/AttributeAccessException.java
// public class AttributeAccessException extends RuntimeException {
//
// public AttributeAccessException(Exception cause) {
// super(cause);
// }
//
// public AttributeAccessException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewAttributes.java
// public class ViewAttributes {
//
// private ViewAttributes() { }
//
// /**
// * @return the full getter method name for a plain attribute, following conventions
// * used in the Android code. Prepends "get" to the attribute name and formats
// * it in camel-case. Recognizes boolean attributes of the format {@code isFoo} or
// * {@code hasFoo} and returns them unchanged.
// */
// public static String getGetterMethodName(String attributeName) {
// if (isBooleanAttribute(attributeName, "is") || isBooleanAttribute(attributeName, "has")) {
// return attributeName;
// }
// return "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1);
// }
//
// private static boolean isBooleanAttribute(String attributeName, String prefix) {
// return attributeName.startsWith(prefix)
// && attributeName.length() > prefix.length()
// && Character.isUpperCase(attributeName.charAt(prefix.length()));
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetter(View view, String methodName) {
// try {
// Method method = view.getClass().getMethod(methodName);
// return method.invoke(view);
// } catch (SecurityException ex) {
// throw new AttributeAccessException(ex);
// } catch (NoSuchMethodException ex) {
// throw new AttributeAccessException("No such attribute", ex);
// } catch (IllegalAccessException ex) {
// throw new AttributeAccessException(ex);
// } catch (InvocationTargetException ex) {
// throw new AttributeAccessException(ex);
// }
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// *
// * This method normalizes all instances of CharSequences to be instances of String.
// * This is useful because Android is using some CharSequence representations
// * internally that don't compare well with strings (in particular as returned
// * from TextView.getText()).
// *
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetterNormalizingStrings(View view, String methodName) {
// Object value = callGetter(view, methodName);
// if (value instanceof CharSequence) {
// value = value.toString();
// }
// return value;
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
| import java.util.Set;
import se.fishtank.css.selectors.specifier.AttributeSpecifier;
import android.view.View;
import com.nikhaldimann.viewselector.attributes.AttributeAccessException;
import com.nikhaldimann.viewselector.attributes.ViewAttributes;
import com.nikhaldimann.viewselector.selection.ViewSelection; | return false;
}
if (!(actualValue instanceof CharSequence)) {
return false;
}
// Android is using some CharSequence representations internally that
// don't compare well with strings (in particularly as returned from
// TextView.getText()), so we convert to a strong explicitly.
String actualString = actualValue.toString();
switch (specifier.getMatch()) {
case CONTAINS:
return actualString.contains(specifier.getValue());
case PREFIX:
return actualString.startsWith(specifier.getValue());
case SUFFIX:
return actualString.endsWith(specifier.getValue());
default:
throw new UnsupportedOperationException();
}
}
};
break;
default:
throw new UnsupportedOperationException();
}
}
}
| // Path: src/main/java/com/nikhaldimann/viewselector/attributes/AttributeAccessException.java
// public class AttributeAccessException extends RuntimeException {
//
// public AttributeAccessException(Exception cause) {
// super(cause);
// }
//
// public AttributeAccessException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/attributes/ViewAttributes.java
// public class ViewAttributes {
//
// private ViewAttributes() { }
//
// /**
// * @return the full getter method name for a plain attribute, following conventions
// * used in the Android code. Prepends "get" to the attribute name and formats
// * it in camel-case. Recognizes boolean attributes of the format {@code isFoo} or
// * {@code hasFoo} and returns them unchanged.
// */
// public static String getGetterMethodName(String attributeName) {
// if (isBooleanAttribute(attributeName, "is") || isBooleanAttribute(attributeName, "has")) {
// return attributeName;
// }
// return "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1);
// }
//
// private static boolean isBooleanAttribute(String attributeName, String prefix) {
// return attributeName.startsWith(prefix)
// && attributeName.length() > prefix.length()
// && Character.isUpperCase(attributeName.charAt(prefix.length()));
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetter(View view, String methodName) {
// try {
// Method method = view.getClass().getMethod(methodName);
// return method.invoke(view);
// } catch (SecurityException ex) {
// throw new AttributeAccessException(ex);
// } catch (NoSuchMethodException ex) {
// throw new AttributeAccessException("No such attribute", ex);
// } catch (IllegalAccessException ex) {
// throw new AttributeAccessException(ex);
// } catch (InvocationTargetException ex) {
// throw new AttributeAccessException(ex);
// }
// }
//
// /**
// * Calls the given method by name on the given view, assuming that it's a getter,
// * i.e., it doesn't have arguments.
// *
// * This method normalizes all instances of CharSequences to be instances of String.
// * This is useful because Android is using some CharSequence representations
// * internally that don't compare well with strings (in particular as returned
// * from TextView.getText()).
// *
// * @return the result of the method call
// * @throws AttributeAccessException when the method doesn't exist or can't be
// * called for various reasons
// */
// public static Object callGetterNormalizingStrings(View view, String methodName) {
// Object value = callGetter(view, methodName);
// if (value instanceof CharSequence) {
// value = value.toString();
// }
// return value;
// }
//
// }
//
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
//
// }
// Path: src/main/java/com/nikhaldimann/viewselector/checker/AttributeSpecifierChecker.java
import java.util.Set;
import se.fishtank.css.selectors.specifier.AttributeSpecifier;
import android.view.View;
import com.nikhaldimann.viewselector.attributes.AttributeAccessException;
import com.nikhaldimann.viewselector.attributes.ViewAttributes;
import com.nikhaldimann.viewselector.selection.ViewSelection;
return false;
}
if (!(actualValue instanceof CharSequence)) {
return false;
}
// Android is using some CharSequence representations internally that
// don't compare well with strings (in particularly as returned from
// TextView.getText()), so we convert to a strong explicitly.
String actualString = actualValue.toString();
switch (specifier.getMatch()) {
case CONTAINS:
return actualString.contains(specifier.getValue());
case PREFIX:
return actualString.startsWith(specifier.getValue());
case SUFFIX:
return actualString.endsWith(specifier.getValue());
default:
throw new UnsupportedOperationException();
}
}
};
break;
default:
throw new UnsupportedOperationException();
}
}
}
| public ViewSelection check(Set<View> views) { |
nikhaldi/android-view-selector | src/android-test/src/com/nikhaldimann/viewselector/android/activities/HelloWorldExampleActivityTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/HelloWorldExampleActivity.java
// public class HelloWorldExampleActivity extends Activity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_hello_world);
// }
//
// }
| import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import android.content.Intent;
import android.test.ActivityUnitTestCase;
import com.nikhaldimann.viewselector.test.HelloWorldExampleActivity; | package com.nikhaldimann.viewselector.android.activities;
/**
* Example unit test for a simple activity. The layout of the activity has a single
* TextView with id "hello_world" and text "Hello world!".
*
* Keep this example self-contained so it can be referenced from documentation.
*/
public class HelloWorldExampleActivityTest extends ActivityUnitTestCase<HelloWorldExampleActivity> {
public HelloWorldExampleActivityTest() {
super(HelloWorldExampleActivity.class);
}
private HelloWorldExampleActivity activity;
public void testHelloWorld() {
activity = startActivity(new Intent(getInstrumentation().getTargetContext(),
HelloWorldExampleActivity.class), null, null);
| // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/HelloWorldExampleActivity.java
// public class HelloWorldExampleActivity extends Activity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_hello_world);
// }
//
// }
// Path: src/android-test/src/com/nikhaldimann/viewselector/android/activities/HelloWorldExampleActivityTest.java
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import android.content.Intent;
import android.test.ActivityUnitTestCase;
import com.nikhaldimann.viewselector.test.HelloWorldExampleActivity;
package com.nikhaldimann.viewselector.android.activities;
/**
* Example unit test for a simple activity. The layout of the activity has a single
* TextView with id "hello_world" and text "Hello world!".
*
* Keep this example self-contained so it can be referenced from documentation.
*/
public class HelloWorldExampleActivityTest extends ActivityUnitTestCase<HelloWorldExampleActivity> {
public HelloWorldExampleActivityTest() {
super(HelloWorldExampleActivity.class);
}
private HelloWorldExampleActivity activity;
public void testHelloWorld() {
activity = startActivity(new Intent(getInstrumentation().getTargetContext(),
HelloWorldExampleActivity.class), null, null);
| assertThatSelection("TextView#hello_world", activity) |
nikhaldi/android-view-selector | src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/activities/HelloWorldFragmentActivityTest.java | // Path: src/robolectric-test/src/com/nikhaldimann/viewselector/robolectric/RobolectricTestHelloWorldFragmentActivity.java
// public class RobolectricTestHelloWorldFragmentActivity extends FragmentActivity {
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_hello_world);
// }
//
// }
| import org.junit.runner.RunWith;
import android.app.Activity;
import com.nikhaldimann.viewselector.robolectric.RobolectricTestHelloWorldFragmentActivity;
import com.xtremelabs.robolectric.RobolectricTestRunner; | package com.nikhaldimann.viewselector.robolectric.activities;
@RunWith(RobolectricTestRunner.class)
public class HelloWorldFragmentActivityTest extends AbstractMainActivityTest {
protected Activity createActivity() { | // Path: src/robolectric-test/src/com/nikhaldimann/viewselector/robolectric/RobolectricTestHelloWorldFragmentActivity.java
// public class RobolectricTestHelloWorldFragmentActivity extends FragmentActivity {
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_hello_world);
// }
//
// }
// Path: src/robolectric-test/test/com/nikhaldimann/viewselector/robolectric/activities/HelloWorldFragmentActivityTest.java
import org.junit.runner.RunWith;
import android.app.Activity;
import com.nikhaldimann.viewselector.robolectric.RobolectricTestHelloWorldFragmentActivity;
import com.xtremelabs.robolectric.RobolectricTestRunner;
package com.nikhaldimann.viewselector.robolectric.activities;
@RunWith(RobolectricTestRunner.class)
public class HelloWorldFragmentActivityTest extends AbstractMainActivityTest {
protected Activity createActivity() { | RobolectricTestHelloWorldFragmentActivity activity = new RobolectricTestHelloWorldFragmentActivity(); |
nikhaldi/android-view-selector | src/android-test/src/com/nikhaldimann/viewselector/android/checker/ClassCheckerTest.java | // Path: src/android-test/src/com/nikhaldimann/viewselector/android/testutil/AndroidTestViewFactory.java
// public class AndroidTestViewFactory extends ProvidedContextViewFactory {
//
// public AndroidTestViewFactory(Context context) {
// super(context);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractClassCheckerTest.java
// public abstract class AbstractClassCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> check(String selectorTag, Combinator combinator, View view) {
// Selector selector = new Selector(selectorTag, combinator);
// ClassChecker checker = new ClassChecker(selector, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testSingleView() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, view));
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, view), view);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, view), view);
// }
//
// @Test
// public void testViewGroupWithDescendants() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, layout), layout, view1, view2, layout2, view3);
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.DESCENDANT, layout), layout);
// assertContentsInOrder(check("FrameLayout", Combinator.DESCENDANT, layout), layout2);
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, layout), view1, view2, view3);
// }
//
// @Test
// public void testViewGroupWithChildren() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("FooView", Combinator.CHILD, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.CHILD, layout));
// assertContentsInOrder(check("TextView", Combinator.CHILD, layout), view1, view2);
// assertContentsInOrder(check("FrameLayout", Combinator.CHILD, layout2));
// }
//
// @Test
// public void testAdjacentSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view1), view2);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view3));
// }
//
// @Test
// public void testGeneralSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view1), view2, view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view3));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
| import com.nikhaldimann.viewselector.android.testutil.AndroidTestViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractClassCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory; | package com.nikhaldimann.viewselector.android.checker;
public class ClassCheckerTest extends AbstractClassCheckerTest {
protected ViewFactory createViewFactory() { | // Path: src/android-test/src/com/nikhaldimann/viewselector/android/testutil/AndroidTestViewFactory.java
// public class AndroidTestViewFactory extends ProvidedContextViewFactory {
//
// public AndroidTestViewFactory(Context context) {
// super(context);
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/checker/AbstractClassCheckerTest.java
// public abstract class AbstractClassCheckerTest extends ViewSelectorAndroidTestCase {
//
// private Iterable<View> check(String selectorTag, Combinator combinator, View view) {
// Selector selector = new Selector(selectorTag, combinator);
// ClassChecker checker = new ClassChecker(selector, view);
// ViewSelection selection = new ViewSelection();
// selection.add(view);
// return checker.check(selection);
// }
//
// @Test
// public void testSingleView() {
// TextView view = viewFactory.createTextView();
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, view));
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, view), view);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, view), view);
// }
//
// @Test
// public void testViewGroupWithDescendants() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("*", Combinator.DESCENDANT, layout), layout, view1, view2, layout2, view3);
// assertContentsInOrder(check("FooView", Combinator.DESCENDANT, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.DESCENDANT, layout), layout);
// assertContentsInOrder(check("FrameLayout", Combinator.DESCENDANT, layout), layout2);
// assertContentsInOrder(check("TextView", Combinator.DESCENDANT, layout), view1, view2, view3);
// }
//
// @Test
// public void testViewGroupWithChildren() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// FrameLayout layout2 = viewFactory.createFrameLayout();
// TextView view3 = viewFactory.createTextView();
// layout2.addView(view3);
// layout.addView(layout2);
// assertContentsInOrder(check("FooView", Combinator.CHILD, layout));
// assertContentsInOrder(check("LinearLayout", Combinator.CHILD, layout));
// assertContentsInOrder(check("TextView", Combinator.CHILD, layout), view1, view2);
// assertContentsInOrder(check("FrameLayout", Combinator.CHILD, layout2));
// }
//
// @Test
// public void testAdjacentSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view1), view2);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.ADJACENT_SIBLING, view3));
// }
//
// @Test
// public void testGeneralSiblings() {
// LinearLayout layout = viewFactory.createLinearLayout();
// TextView view1 = viewFactory.createTextView();
// TextView view2 = viewFactory.createTextView();
// TextView view3 = viewFactory.createTextView();
// layout.addView(view1);
// layout.addView(view2);
// layout.addView(view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, layout));
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view1), view2, view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view2), view3);
// assertContentsInOrder(
// check("TextView", Combinator.GENERAL_SIBLING, view3));
// }
//
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewFactory.java
// public interface ViewFactory {
//
// TextView createTextView();
//
// LinearLayout createLinearLayout();
//
// FrameLayout createFrameLayout();
//
// }
// Path: src/android-test/src/com/nikhaldimann/viewselector/android/checker/ClassCheckerTest.java
import com.nikhaldimann.viewselector.android.testutil.AndroidTestViewFactory;
import com.nikhaldimann.viewselector.test.abstrakt.checker.AbstractClassCheckerTest;
import com.nikhaldimann.viewselector.test.util.ViewFactory;
package com.nikhaldimann.viewselector.android.checker;
public class ClassCheckerTest extends AbstractClassCheckerTest {
protected ViewFactory createViewFactory() { | return new AndroidTestViewFactory(getContext()); |
nikhaldi/android-view-selector | src/android-test/src/com/nikhaldimann/viewselector/android/activities/HelloWorldExampleFragmentActivityTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/HelloWorldExampleFragmentActivity.java
// public class HelloWorldExampleFragmentActivity extends FragmentActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_hello_world);
// }
//
// }
| import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import android.content.Intent;
import android.test.ActivityUnitTestCase;
import com.nikhaldimann.viewselector.test.HelloWorldExampleFragmentActivity; | package com.nikhaldimann.viewselector.android.activities;
/**
* Example unit test for a simple activity. The layout of the activity has a single
* TextView with id "hello_world" and text "Hello world!".
*
* This is equivalent to {@link HelloWorldExampleActivityTest} but uses a
* {@code FragmentActivity}.
*
* Keep this example self-contained so it can be referenced from documentation.
*/
public class HelloWorldExampleFragmentActivityTest extends ActivityUnitTestCase<HelloWorldExampleFragmentActivity> {
public HelloWorldExampleFragmentActivityTest() {
super(HelloWorldExampleFragmentActivity.class);
}
private HelloWorldExampleFragmentActivity activity;
public void testHelloWorld() {
activity = startActivity(new Intent(getInstrumentation().getTargetContext(),
HelloWorldExampleFragmentActivity.class), null, null);
| // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/HelloWorldExampleFragmentActivity.java
// public class HelloWorldExampleFragmentActivity extends FragmentActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_hello_world);
// }
//
// }
// Path: src/android-test/src/com/nikhaldimann/viewselector/android/activities/HelloWorldExampleFragmentActivityTest.java
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import android.content.Intent;
import android.test.ActivityUnitTestCase;
import com.nikhaldimann.viewselector.test.HelloWorldExampleFragmentActivity;
package com.nikhaldimann.viewselector.android.activities;
/**
* Example unit test for a simple activity. The layout of the activity has a single
* TextView with id "hello_world" and text "Hello world!".
*
* This is equivalent to {@link HelloWorldExampleActivityTest} but uses a
* {@code FragmentActivity}.
*
* Keep this example self-contained so it can be referenced from documentation.
*/
public class HelloWorldExampleFragmentActivityTest extends ActivityUnitTestCase<HelloWorldExampleFragmentActivity> {
public HelloWorldExampleFragmentActivityTest() {
super(HelloWorldExampleFragmentActivity.class);
}
private HelloWorldExampleFragmentActivity activity;
public void testHelloWorld() {
activity = startActivity(new Intent(getInstrumentation().getTargetContext(),
HelloWorldExampleFragmentActivity.class), null, null);
| assertThatSelection("TextView#hello_world", activity) |
nikhaldi/android-view-selector | src/android-test/src/com/nikhaldimann/viewselector/android/activities/ListViewExampleActivityTest.java | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/ListViewExampleActivity.java
// public class ListViewExampleActivity extends Activity {
//
// private ArrayAdapter<String> listAdapter;
// private List<String> groceries;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_list_view);
//
// ListView list = (ListView) this.findViewById(R.id.groceries);
// groceries = new ArrayList<String>();
// listAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, groceries);
// list.setAdapter(listAdapter);
// }
//
// /**
// * Adds an item to the grocery list.
// */
// public void addGroceryItem(String item) {
// groceries.add(item);
// listAdapter.notifyDataSetChanged();
// }
//
// }
| import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import android.test.ActivityInstrumentationTestCase2;
import com.nikhaldimann.viewselector.test.ListViewExampleActivity; | package com.nikhaldimann.viewselector.android.activities;
/**
* Example unit test for an activity with a dynamic list view. The activity has
* a ListView with the id "groceries". We can add items to the list.
*
* Keep this example self-contained so it can be referenced from documentation.
*/
public class ListViewExampleActivityTest extends ActivityInstrumentationTestCase2<ListViewExampleActivity> {
private ListViewExampleActivity activity;
public ListViewExampleActivityTest() {
super(ListViewExampleActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
activity = getActivity();
}
public void testListView() {
// Assert that there is a ListView with id "groceries" in this activity | // Path: src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java
// public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
// return assertThat(selection(selector, activity));
// }
//
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/ListViewExampleActivity.java
// public class ListViewExampleActivity extends Activity {
//
// private ArrayAdapter<String> listAdapter;
// private List<String> groceries;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_list_view);
//
// ListView list = (ListView) this.findViewById(R.id.groceries);
// groceries = new ArrayList<String>();
// listAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, groceries);
// list.setAdapter(listAdapter);
// }
//
// /**
// * Adds an item to the grocery list.
// */
// public void addGroceryItem(String item) {
// groceries.add(item);
// listAdapter.notifyDataSetChanged();
// }
//
// }
// Path: src/android-test/src/com/nikhaldimann/viewselector/android/activities/ListViewExampleActivityTest.java
import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection;
import android.test.ActivityInstrumentationTestCase2;
import com.nikhaldimann.viewselector.test.ListViewExampleActivity;
package com.nikhaldimann.viewselector.android.activities;
/**
* Example unit test for an activity with a dynamic list view. The activity has
* a ListView with the id "groceries". We can add items to the list.
*
* Keep this example self-contained so it can be referenced from documentation.
*/
public class ListViewExampleActivityTest extends ActivityInstrumentationTestCase2<ListViewExampleActivity> {
private ListViewExampleActivity activity;
public ListViewExampleActivityTest() {
super(ListViewExampleActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
activity = getActivity();
}
public void testListView() {
// Assert that there is a ListView with id "groceries" in this activity | assertThatSelection("ListView#groceries", activity).hasSize(1); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.